mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-02-14 18:47:32 +01:00
fix: closes #13897, display group create errors properly
fix typo in redirect after group deletion
This commit is contained in:
@@ -88,7 +88,7 @@ define('admin/manage/group', [
|
|||||||
bootbox.confirm('[[admin/manage/groups:alerts.confirm-delete]]', function (confirm) {
|
bootbox.confirm('[[admin/manage/groups:alerts.confirm-delete]]', function (confirm) {
|
||||||
if (confirm) {
|
if (confirm) {
|
||||||
api.del(`/groups/${slugify(ajaxify.data.group.name)}`, {}).then(() => {
|
api.del(`/groups/${slugify(ajaxify.data.group.name)}`, {}).then(() => {
|
||||||
ajaxify.go('/admin/managegroups');
|
ajaxify.go('/admin/manage/groups');
|
||||||
}).catch(alerts.error);
|
}).catch(alerts.error);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -40,7 +40,6 @@ define('admin/manage/groups', [
|
|||||||
const createModal = $('#create-modal');
|
const createModal = $('#create-modal');
|
||||||
const createGroupName = $('#create-group-name');
|
const createGroupName = $('#create-group-name');
|
||||||
const createModalGo = $('#create-modal-go');
|
const createModalGo = $('#create-modal-go');
|
||||||
const createModalError = $('#create-modal-error');
|
|
||||||
|
|
||||||
createGroupName.trigger('focus');
|
createGroupName.trigger('focus');
|
||||||
createModal.on('keypress', function (e) {
|
createModal.on('keypress', function (e) {
|
||||||
@@ -61,18 +60,12 @@ define('admin/manage/groups', [
|
|||||||
};
|
};
|
||||||
|
|
||||||
api.post('/groups', submitObj).then((response) => {
|
api.post('/groups', submitObj).then((response) => {
|
||||||
createModalError.addClass('hide');
|
|
||||||
createGroupName.val('');
|
createGroupName.val('');
|
||||||
createModal.on('hidden.bs.modal', function () {
|
createModal.on('hidden.bs.modal', function () {
|
||||||
ajaxify.go('admin/manage/groups/' + response.name);
|
ajaxify.go('admin/manage/groups/' + response.name);
|
||||||
});
|
});
|
||||||
createModal.modal('hide');
|
createModal.modal('hide');
|
||||||
}).catch((err) => {
|
}).catch(alerts.error);
|
||||||
if (!utils.hasLanguageKey(err.status.message)) {
|
|
||||||
err.status.message = '[[admin/manage/groups:alerts.create-failure]]';
|
|
||||||
}
|
|
||||||
createModalError.translateHtml(err.status.message).removeClass('hide');
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -8,13 +8,16 @@ define('forum/groups/list', [
|
|||||||
Groups.init = function () {
|
Groups.init = function () {
|
||||||
// Group creation
|
// Group creation
|
||||||
$('button[data-action="new"]').on('click', function () {
|
$('button[data-action="new"]').on('click', function () {
|
||||||
bootbox.prompt('[[groups:new-group.group-name]]', function (name) {
|
const modal = bootbox.prompt('[[groups:new-group.group-name]]', function (name) {
|
||||||
if (name && name.length) {
|
if (name === '') {
|
||||||
api.post('/groups', {
|
return false;
|
||||||
name: name,
|
}
|
||||||
}).then((res) => {
|
if (name && name.trim().length) {
|
||||||
|
api.post('/groups', { name }).then((res) => {
|
||||||
|
modal.modal('hide');
|
||||||
ajaxify.go('groups/' + res.slug);
|
ajaxify.go('groups/' + res.slug);
|
||||||
}).catch(alerts.error);
|
}).catch(alerts.error);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -6,7 +6,6 @@
|
|||||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-hidden="true"></button>
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-hidden="true"></button>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<div class="alert alert-danger hide" id="create-modal-error"></div>
|
|
||||||
<form>
|
<form>
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label class="form-label" for="create-group-name">[[admin/manage/groups:name]]</label>
|
<label class="form-label" for="create-group-name">[[admin/manage/groups:name]]</label>
|
||||||
|
|||||||
Reference in New Issue
Block a user