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;
// 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,
});
});

View File

@ -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 {