mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
refactor(api): update group deletion calls to use write API
This commit is contained in:
@@ -2,8 +2,9 @@
|
|||||||
|
|
||||||
define('admin/manage/groups', [
|
define('admin/manage/groups', [
|
||||||
'categorySelector',
|
'categorySelector',
|
||||||
|
'slugify',
|
||||||
'api',
|
'api',
|
||||||
], function (categorySelector, api) {
|
], function (categorySelector, slugify, api) {
|
||||||
var Groups = {};
|
var Groups = {};
|
||||||
|
|
||||||
var intervalId = 0;
|
var intervalId = 0;
|
||||||
@@ -61,15 +62,7 @@ define('admin/manage/groups', [
|
|||||||
case 'delete':
|
case 'delete':
|
||||||
bootbox.confirm('[[admin/manage/groups:alerts.confirm-delete]]', function (confirm) {
|
bootbox.confirm('[[admin/manage/groups:alerts.confirm-delete]]', function (confirm) {
|
||||||
if (confirm) {
|
if (confirm) {
|
||||||
socket.emit('groups.delete', {
|
api.del(`/groups/${slugify(groupName)}`, {}).then(ajaxify.refresh).catch(app.alertError);
|
||||||
groupName: groupName,
|
|
||||||
}, function (err) {
|
|
||||||
if (err) {
|
|
||||||
return app.alertError(err.message);
|
|
||||||
}
|
|
||||||
|
|
||||||
ajaxify.refresh();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -229,16 +229,10 @@ define('forum/groups/details', [
|
|||||||
if (confirm) {
|
if (confirm) {
|
||||||
bootbox.prompt('Please enter the name of this group in order to delete it:', function (response) {
|
bootbox.prompt('Please enter the name of this group in order to delete it:', function (response) {
|
||||||
if (response === groupName) {
|
if (response === groupName) {
|
||||||
socket.emit('groups.delete', {
|
api.del(`/groups/${slugify(groupName)}`, {}).then(() => {
|
||||||
groupName: groupName,
|
app.alertSuccess('[[groups:event.deleted, ' + utils.escapeHTML(groupName) + ']]');
|
||||||
}, function (err) {
|
ajaxify.go('groups');
|
||||||
if (!err) {
|
}).catch(app.alertError);
|
||||||
app.alertSuccess('[[groups:event.deleted, ' + utils.escapeHTML(groupName) + ']]');
|
|
||||||
ajaxify.go('groups');
|
|
||||||
} else {
|
|
||||||
app.alertError(err.message);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user