mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
feat: prevent navigation away from groups page if changes are unsaved
This commit is contained in:
@@ -5,7 +5,8 @@ define('admin/manage/group', [
|
|||||||
'forum/groups/memberlist',
|
'forum/groups/memberlist',
|
||||||
'iconSelect',
|
'iconSelect',
|
||||||
'admin/modules/colorpicker',
|
'admin/modules/colorpicker',
|
||||||
], function (memberList, iconSelect, colorpicker) {
|
'translator',
|
||||||
|
], function (memberList, iconSelect, colorpicker, translator) {
|
||||||
var Groups = {};
|
var Groups = {};
|
||||||
|
|
||||||
Groups.init = function () {
|
Groups.init = function () {
|
||||||
@@ -90,8 +91,21 @@ define('admin/manage/group', [
|
|||||||
|
|
||||||
$('[component="category/list"] [data-cid]').on('click', function () {
|
$('[component="category/list"] [data-cid]').on('click', function () {
|
||||||
var cid = $(this).attr('data-cid');
|
var cid = $(this).attr('data-cid');
|
||||||
|
|
||||||
if (cid) {
|
if (cid) {
|
||||||
ajaxify.go('admin/manage/privileges/' + cid);
|
var url = 'admin/manage/privileges/' + cid;
|
||||||
|
if (app.flags && app.flags._unsaved === true) {
|
||||||
|
translator.translate('[[global:unsaved-changes]]', function (text) {
|
||||||
|
bootbox.confirm(text, function (navigate) {
|
||||||
|
if (navigate) {
|
||||||
|
app.flags._unsaved = false;
|
||||||
|
ajaxify.go(url);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ajaxify.go(url);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -103,6 +117,11 @@ define('admin/manage/group', [
|
|||||||
groupLabelPreview.css('color', '#' + hex);
|
groupLabelPreview.css('color', '#' + hex);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('form').on('change', 'input, select, textarea', function () {
|
||||||
|
app.flags = app.flags || {};
|
||||||
|
app.flags._unsaved = true;
|
||||||
|
});
|
||||||
|
|
||||||
$('#save').on('click', function () {
|
$('#save').on('click', function () {
|
||||||
socket.emit('admin.groups.update', {
|
socket.emit('admin.groups.update', {
|
||||||
groupName: groupName,
|
groupName: groupName,
|
||||||
|
|||||||
Reference in New Issue
Block a user