mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-01-01 21:30:30 +01:00
@@ -18,5 +18,14 @@
|
||||
"remove": "Remove",
|
||||
"notify": "Notify",
|
||||
"notify-user": "Notify User",
|
||||
"confirm-reject": "Do you want to reject this post?"
|
||||
"confirm-reject": "Do you want to reject this post?",
|
||||
"bulk-actions": "Bulk Actions",
|
||||
"accept-all": "Accept All",
|
||||
"accept-selected": "Accept Selected",
|
||||
"reject-all": "Reject All",
|
||||
"reject-all-confirm": "Do you want to reject all posts?",
|
||||
"reject-selected": "Reject Selected",
|
||||
"reject-selected-confirm": "Do you want to reject selected posts?",
|
||||
"bulk-accept-success": "%1 posts accepted",
|
||||
"bulk-reject-success": "%1 posts rejected"
|
||||
}
|
||||
@@ -13,6 +13,8 @@ define('forum/post-queue', [
|
||||
privilege: 'moderate',
|
||||
});
|
||||
|
||||
handleBulkActions();
|
||||
|
||||
$('.posts-list').on('click', '[data-action]', async function () {
|
||||
function getMessage() {
|
||||
return new Promise((resolve) => {
|
||||
@@ -33,17 +35,13 @@ define('forum/post-queue', [
|
||||
});
|
||||
});
|
||||
}
|
||||
function confirmReject() {
|
||||
return new Promise((resolve) => {
|
||||
bootbox.confirm('[[post-queue:confirm-reject]]', resolve);
|
||||
});
|
||||
}
|
||||
|
||||
const parent = $(this).parents('[data-id]');
|
||||
const action = $(this).attr('data-action');
|
||||
const id = parent.attr('data-id');
|
||||
const listContainer = parent.get(0).parentNode;
|
||||
|
||||
if ((!['accept', 'reject', 'notify'].includes(action)) || (action === 'reject' && !await confirmReject())) {
|
||||
if ((!['accept', 'reject', 'notify'].includes(action)) || (action === 'reject' && !await confirmReject('[[post-queue:confirm-reject]]'))) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -59,7 +57,11 @@ define('forum/post-queue', [
|
||||
}
|
||||
|
||||
if (listContainer.childElementCount === 0) {
|
||||
ajaxify.refresh();
|
||||
if (ajaxify.data.singlePost) {
|
||||
ajaxify.go('/post-queue' + window.location.search);
|
||||
} else {
|
||||
ajaxify.refresh();
|
||||
}
|
||||
}
|
||||
});
|
||||
return false;
|
||||
@@ -102,6 +104,12 @@ define('forum/post-queue', [
|
||||
$('[component="post/content"] img:not(.not-responsive)').addClass('img-responsive');
|
||||
};
|
||||
|
||||
function confirmReject(msg) {
|
||||
return new Promise((resolve) => {
|
||||
bootbox.confirm(msg, resolve);
|
||||
});
|
||||
}
|
||||
|
||||
function handleContentEdit(displayClass, editableClass, inputSelector) {
|
||||
$('.posts-list').on('click', displayClass, function () {
|
||||
const el = $(this);
|
||||
@@ -143,5 +151,35 @@ define('forum/post-queue', [
|
||||
});
|
||||
}
|
||||
|
||||
function handleBulkActions() {
|
||||
$('[component="post-queue/bulk-actions"]').on('click', '[data-action]', async function () {
|
||||
const bulkAction = $(this).attr('data-action');
|
||||
let queueEls = $('.posts-list [data-id]');
|
||||
if (bulkAction === 'accept-selected' || bulkAction === 'reject-selected') {
|
||||
queueEls = queueEls.filter(
|
||||
(i, el) => $(el).find('input[type="checkbox"]').is(':checked')
|
||||
);
|
||||
}
|
||||
const ids = queueEls.map((i, el) => $(el).attr('data-id')).get();
|
||||
const showConfirm = bulkAction === 'reject-all' || bulkAction === 'reject-selected';
|
||||
if (!ids.length || (showConfirm && !(await confirmReject(`[[post-queue:${bulkAction}-confirm]]`)))) {
|
||||
return;
|
||||
}
|
||||
const action = bulkAction.split('-')[0];
|
||||
const promises = ids.map(id => socket.emit('posts.' + action, { id: id }));
|
||||
|
||||
Promise.allSettled(promises).then(function (results) {
|
||||
const fulfilled = results.filter(res => res.status === 'fulfilled').length;
|
||||
const errors = results.filter(res => res.status === 'rejected');
|
||||
if (fulfilled) {
|
||||
alerts.success(`[[post-queue:bulk-${action}-success, ${fulfilled}]]`);
|
||||
ajaxify.refresh();
|
||||
}
|
||||
|
||||
errors.forEach(res => alerts.error(res.reason));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
return PostQueue;
|
||||
});
|
||||
|
||||
@@ -194,5 +194,6 @@ modsController.postQueue = async function (req, res, next) {
|
||||
allCategoriesUrl: `post-queue${helpers.buildQueryString(req.query, 'cid', '')}`,
|
||||
pagination: pagination.create(page, pageCount),
|
||||
breadcrumbs: helpers.buildBreadcrumbs(crumbs),
|
||||
singlePost: !!id,
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user