diff --git a/InvenTree/templates/InvenTree/settings/setting.html b/InvenTree/templates/InvenTree/settings/setting.html index 16fc67ef86..743e37bf8e 100644 --- a/InvenTree/templates/InvenTree/settings/setting.html +++ b/InvenTree/templates/InvenTree/settings/setting.html @@ -16,10 +16,13 @@ {% endif %} {{ setting.name }} + + {{ setting.description }} + {% if setting.is_bool %}
- +
{% else %}
@@ -31,16 +34,12 @@ {% endif %} {{ setting.units }} +
+ +
{% endif %} - - {{ setting.description }} - -
- -
- - \ No newline at end of file + diff --git a/InvenTree/templates/InvenTree/settings/settings.html b/InvenTree/templates/InvenTree/settings/settings.html index 5fcd18644f..ba27187747 100644 --- a/InvenTree/templates/InvenTree/settings/settings.html +++ b/InvenTree/templates/InvenTree/settings/settings.html @@ -62,6 +62,43 @@ {% 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) { + showApiError(xhr, url); + } + } + ); + +}); + +// 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');