From dd017f36c7c48afe0a0f6437457314e597b3fa67 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sun, 8 May 2022 10:50:57 +1000 Subject: [PATCH] Augment existing frontend code to allow adjustment of notification settings --- InvenTree/templates/InvenTree/settings/settings.html | 7 ++++++- InvenTree/templates/js/dynamic/settings.js | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/InvenTree/templates/InvenTree/settings/settings.html b/InvenTree/templates/InvenTree/settings/settings.html index b35ec0107a..abcd914385 100644 --- a/InvenTree/templates/InvenTree/settings/settings.html +++ b/InvenTree/templates/InvenTree/settings/settings.html @@ -75,7 +75,7 @@ $('table').find('.boolean-setting').change(function() { var checked = this.checked; // Global setting by default - var url = `/api/settings/global/${pk}/`; + var url = `/api/settings/global/${setting}/`; if (plugin) { url = `/api/plugin/settings/${pk}/`; @@ -108,6 +108,7 @@ $('table').find('.btn-edit-setting').click(function() { var pk = $(this).attr('pk'); var plugin = $(this).attr('plugin'); var is_global = true; + var notification = $(this).attr('notification'); if ($(this).attr('user')){ is_global = false; @@ -117,8 +118,11 @@ $('table').find('.btn-edit-setting').click(function() { if (plugin != null) { title = '{% trans "Edit Plugin Setting" %}'; + } else if (notification) { + title = '{% trans "Edit Notification Setting" %}'; } else if (is_global) { title = '{% trans "Edit Global Setting" %}'; + pk = setting; } else { title = '{% trans "Edit User Setting" %}'; } @@ -126,6 +130,7 @@ $('table').find('.btn-edit-setting').click(function() { editSetting(pk, { plugin: plugin, global: is_global, + notification: notification, title: title, }); }); diff --git a/InvenTree/templates/js/dynamic/settings.js b/InvenTree/templates/js/dynamic/settings.js index 2832bd3482..6f0c904f1a 100644 --- a/InvenTree/templates/js/dynamic/settings.js +++ b/InvenTree/templates/js/dynamic/settings.js @@ -29,7 +29,8 @@ const plugins_enabled = false; {% endif %} /* - * Edit a setting value + * Interactively edit a setting value. + * Launches a modal dialog form to adjut the value of the setting. */ function editSetting(pk, options={}) { @@ -38,10 +39,14 @@ function editSetting(pk, options={}) { var plugin = options.plugin; + var notification = options.notification; + var url = ''; if (plugin) { url = `/api/plugin/settings/${pk}/`; + } else if (notification) { + url = `/api/settings/notification/${pk}/`; } else if (global) { url = `/api/settings/global/${pk}/`; } else {