Augment existing frontend code to allow adjustment of notification settings

This commit is contained in:
Oliver Walters 2022-05-08 10:50:57 +10:00
parent cd6a6b9196
commit dd017f36c7
2 changed files with 12 additions and 2 deletions

View File

@ -75,7 +75,7 @@ $('table').find('.boolean-setting').change(function() {
var checked = this.checked; var checked = this.checked;
// Global setting by default // Global setting by default
var url = `/api/settings/global/${pk}/`; var url = `/api/settings/global/${setting}/`;
if (plugin) { if (plugin) {
url = `/api/plugin/settings/${pk}/`; url = `/api/plugin/settings/${pk}/`;
@ -108,6 +108,7 @@ $('table').find('.btn-edit-setting').click(function() {
var pk = $(this).attr('pk'); var pk = $(this).attr('pk');
var plugin = $(this).attr('plugin'); var plugin = $(this).attr('plugin');
var is_global = true; var is_global = true;
var notification = $(this).attr('notification');
if ($(this).attr('user')){ if ($(this).attr('user')){
is_global = false; is_global = false;
@ -117,8 +118,11 @@ $('table').find('.btn-edit-setting').click(function() {
if (plugin != null) { if (plugin != null) {
title = '{% trans "Edit Plugin Setting" %}'; title = '{% trans "Edit Plugin Setting" %}';
} else if (notification) {
title = '{% trans "Edit Notification Setting" %}';
} else if (is_global) { } else if (is_global) {
title = '{% trans "Edit Global Setting" %}'; title = '{% trans "Edit Global Setting" %}';
pk = setting;
} else { } else {
title = '{% trans "Edit User Setting" %}'; title = '{% trans "Edit User Setting" %}';
} }
@ -126,6 +130,7 @@ $('table').find('.btn-edit-setting').click(function() {
editSetting(pk, { editSetting(pk, {
plugin: plugin, plugin: plugin,
global: is_global, global: is_global,
notification: notification,
title: title, title: title,
}); });
}); });

View File

@ -29,7 +29,8 @@ const plugins_enabled = false;
{% endif %} {% 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={}) { function editSetting(pk, options={}) {
@ -38,10 +39,14 @@ function editSetting(pk, options={}) {
var plugin = options.plugin; var plugin = options.plugin;
var notification = options.notification;
var url = ''; var url = '';
if (plugin) { if (plugin) {
url = `/api/plugin/settings/${pk}/`; url = `/api/plugin/settings/${pk}/`;
} else if (notification) {
url = `/api/settings/notification/${pk}/`;
} else if (global) { } else if (global) {
url = `/api/settings/global/${pk}/`; url = `/api/settings/global/${pk}/`;
} else { } else {