diff options
Diffstat (limited to 'js/PrefUsers.js')
-rw-r--r-- | js/PrefUsers.js | 200 |
1 files changed, 98 insertions, 102 deletions
diff --git a/js/PrefUsers.js b/js/PrefUsers.js index 55dc43dfa..1e7ed6523 100644 --- a/js/PrefUsers.js +++ b/js/PrefUsers.js @@ -1,122 +1,118 @@ 'use strict' /* global __, ngettext */ -define(["dojo/_base/declare"], function (declare) { - Users = { - reload: function(sort) { - const user_search = $("user_search"); - const search = user_search ? user_search.value : ""; - - xhrPost("backend.php", { op: "pref-users", sort: sort, search: search }, (transport) => { - dijit.byId('userConfigTab').attr('content', transport.responseText); - Notify.close(); - }); - }, - add: function() { - const login = prompt(__("Please enter username:"), ""); - - if (login) { - Notify.progress("Adding user..."); - - xhrPost("backend.php", {op: "pref-users", method: "add", login: login}, (transport) => { - alert(transport.responseText); - Users.reload(); - }); - } - }, - edit: function(id) { - const query = "backend.php?op=pref-users&method=edit&id=" + - encodeURIComponent(id); - - if (dijit.byId("userEditDlg")) - dijit.byId("userEditDlg").destroyRecursive(); - - const dialog = new dijit.Dialog({ - id: "userEditDlg", - title: __("User Editor"), - style: "width: 600px", - execute: function () { - if (this.validate()) { - Notify.progress("Saving data...", true); - - xhrPost("backend.php", dojo.formToObject("user_edit_form"), (transport) => { - dialog.hide(); - Users.reload(); - }); - } - }, - href: query +const Users = { + reload: function(sort) { + const user_search = $("user_search"); + const search = user_search ? user_search.value : ""; + + xhrPost("backend.php", { op: "pref-users", sort: sort, search: search }, (transport) => { + dijit.byId('userConfigTab').attr('content', transport.responseText); + Notify.close(); + }); + }, + add: function() { + const login = prompt(__("Please enter username:"), ""); + + if (login) { + Notify.progress("Adding user..."); + + xhrPost("backend.php", {op: "pref-users", method: "add", login: login}, (transport) => { + alert(transport.responseText); + Users.reload(); }); - dialog.show(); - }, - resetSelected: function() { - const rows = this.getSelection(); - - if (rows.length == 0) { - alert(__("No users selected.")); - return; - } - - if (rows.length > 1) { - alert(__("Please select one user.")); - return; - } - - if (confirm(__("Reset password of selected user?"))) { - Notify.progress("Resetting password for selected user..."); + } + }, + edit: function(id) { + const query = "backend.php?op=pref-users&method=edit&id=" + + encodeURIComponent(id); + + if (dijit.byId("userEditDlg")) + dijit.byId("userEditDlg").destroyRecursive(); + + const dialog = new dijit.Dialog({ + id: "userEditDlg", + title: __("User Editor"), + style: "width: 600px", + execute: function () { + if (this.validate()) { + Notify.progress("Saving data...", true); + + xhrPost("backend.php", dojo.formToObject("user_edit_form"), (transport) => { + dialog.hide(); + Users.reload(); + }); + } + }, + href: query + }); + + dialog.show(); + }, + resetSelected: function() { + const rows = this.getSelection(); + + if (rows.length == 0) { + alert(__("No users selected.")); + return; + } - const id = rows[0]; + if (rows.length > 1) { + alert(__("Please select one user.")); + return; + } - xhrPost("backend.php", {op: "pref-users", method: "resetPass", id: id}, (transport) => { - Notify.close(); - Notify.info(transport.responseText, true); - }); + if (confirm(__("Reset password of selected user?"))) { + Notify.progress("Resetting password for selected user..."); - } - }, - removeSelected: function() { - const sel_rows = this.getSelection(); + const id = rows[0]; - if (sel_rows.length > 0) { - if (confirm(__("Remove selected users? Neither default admin nor your account will be removed."))) { - Notify.progress("Removing selected users..."); + xhrPost("backend.php", {op: "pref-users", method: "resetPass", id: id}, (transport) => { + Notify.close(); + Notify.info(transport.responseText, true); + }); - const query = { - op: "pref-users", method: "remove", - ids: sel_rows.toString() - }; + } + }, + removeSelected: function() { + const sel_rows = this.getSelection(); - xhrPost("backend.php", query, () => { - this.reload(); - }); - } + if (sel_rows.length > 0) { + if (confirm(__("Remove selected users? Neither default admin nor your account will be removed."))) { + Notify.progress("Removing selected users..."); - } else { - alert(__("No users selected.")); - } - }, - editSelected: function() { - const rows = this.getSelection(); + const query = { + op: "pref-users", method: "remove", + ids: sel_rows.toString() + }; - if (rows.length == 0) { - alert(__("No users selected.")); - return; + xhrPost("backend.php", query, () => { + this.reload(); + }); } - if (rows.length > 1) { - alert(__("Please select one user.")); - return; - } + } else { + alert(__("No users selected.")); + } + }, + editSelected: function() { + const rows = this.getSelection(); - this.edit(rows[0]); - }, - getSelection :function() { - return Tables.getSelected("prefUserList"); + if (rows.length == 0) { + alert(__("No users selected.")); + return; } - } - return Users; -}); + if (rows.length > 1) { + alert(__("Please select one user.")); + return; + } + this.edit(rows[0]); + }, + getSelection :function() { + return Tables.getSelected("prefUserList"); + } +} |