From ababab944bcd72372ea625d6e500487d09a9cca7 Mon Sep 17 00:00:00 2001 From: Oliver Date: Thu, 3 Feb 2022 15:25:21 +1100 Subject: [PATCH] Boolean settings are now directly clickable --- .../templates/InvenTree/settings/setting.html | 4 ++- .../InvenTree/settings/settings.html | 36 +++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/InvenTree/templates/InvenTree/settings/setting.html b/InvenTree/templates/InvenTree/settings/setting.html index 16fc67ef86..dc15760ef5 100644 --- a/InvenTree/templates/InvenTree/settings/setting.html +++ b/InvenTree/templates/InvenTree/settings/setting.html @@ -19,7 +19,7 @@ {% if setting.is_bool %}
- +
{% else %}
@@ -37,10 +37,12 @@ {{ setting.description }} + {% if not setting.is_bool %}
+ {% endif %} \ No newline at end of file diff --git a/InvenTree/templates/InvenTree/settings/settings.html b/InvenTree/templates/InvenTree/settings/settings.html index 5fcd18644f..4b6c9e9320 100644 --- a/InvenTree/templates/InvenTree/settings/settings.html +++ b/InvenTree/templates/InvenTree/settings/settings.html @@ -62,6 +62,42 @@ {% block js_ready %} {{ block.super }} +// Callback for when boolean settings are edited +$('table').find('.boolean-setting').change(function() { + + var setting = $(this).attr('setting'); + var pk = $(this).attr('pk'); + var plugin = $(this).attr('plugin'); + var user = $(this).attr('user'); + + var checked = this.checked; + + // Global setting by default + var url = `/api/settings/global/${pk}/`; + + if (plugin) { + url = `/api/plugin/settings/${pk}/`; + } else if (user) { + url = `/api/settings/user/${pk}/`; + } + + inventreePut( + url, + { + value: checked.toString(), + }, + { + method: 'PATCH', + onSuccess: function(data) { + }, + error: function(xhr) { + } + } + ); + +}); + +// Callback for when non-boolean settings are edited $('table').find('.btn-edit-setting').click(function() { var setting = $(this).attr('setting'); var pk = $(this).attr('pk');