fix: closes #13897, display group create errors properly

fix typo in redirect after group deletion
This commit is contained in:
Barış Soner Uşaklı
2026-01-16 10:58:03 -05:00
parent 639ea42d5a
commit 7d36c75790
4 changed files with 10 additions and 15 deletions

View File

@@ -88,7 +88,7 @@ define('admin/manage/group', [
bootbox.confirm('[[admin/manage/groups:alerts.confirm-delete]]', function (confirm) {
if (confirm) {
api.del(`/groups/${slugify(ajaxify.data.group.name)}`, {}).then(() => {
ajaxify.go('/admin/managegroups');
ajaxify.go('/admin/manage/groups');
}).catch(alerts.error);
}
});

View File

@@ -40,7 +40,6 @@ define('admin/manage/groups', [
const createModal = $('#create-modal');
const createGroupName = $('#create-group-name');
const createModalGo = $('#create-modal-go');
const createModalError = $('#create-modal-error');
createGroupName.trigger('focus');
createModal.on('keypress', function (e) {
@@ -61,18 +60,12 @@ define('admin/manage/groups', [
};
api.post('/groups', submitObj).then((response) => {
createModalError.addClass('hide');
createGroupName.val('');
createModal.on('hidden.bs.modal', function () {
ajaxify.go('admin/manage/groups/' + response.name);
});
createModal.modal('hide');
}).catch((err) => {
if (!utils.hasLanguageKey(err.status.message)) {
err.status.message = '[[admin/manage/groups:alerts.create-failure]]';
}
createModalError.translateHtml(err.status.message).removeClass('hide');
});
}).catch(alerts.error);
});
});
});

View File

@@ -8,13 +8,16 @@ define('forum/groups/list', [
Groups.init = function () {
// Group creation
$('button[data-action="new"]').on('click', function () {
bootbox.prompt('[[groups:new-group.group-name]]', function (name) {
if (name && name.length) {
api.post('/groups', {
name: name,
}).then((res) => {
const modal = bootbox.prompt('[[groups:new-group.group-name]]', function (name) {
if (name === '') {
return false;
}
if (name && name.trim().length) {
api.post('/groups', { name }).then((res) => {
modal.modal('hide');
ajaxify.go('groups/' + res.slug);
}).catch(alerts.error);
return false;
}
});
});

View File

@@ -6,7 +6,6 @@
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-hidden="true"></button>
</div>
<div class="modal-body">
<div class="alert alert-danger hide" id="create-modal-error"></div>
<form>
<div class="mb-3">
<label class="form-label" for="create-group-name">[[admin/manage/groups:name]]</label>