|
|
|
@ -136,33 +136,14 @@ define('forum/flags/list', [
|
|
|
|
|
if (subselector) {
|
|
|
|
|
const action = subselector.getAttribute('data-action');
|
|
|
|
|
const flagIds = Flags.getSelected();
|
|
|
|
|
const promises = [];
|
|
|
|
|
|
|
|
|
|
// TODO: this can be better done with flagIds.map to return promises
|
|
|
|
|
flagIds.forEach(function (flagId) {
|
|
|
|
|
promises.push(new Promise(function (resolve, reject) {
|
|
|
|
|
const handler = function (err) {
|
|
|
|
|
if (err) {
|
|
|
|
|
reject(err);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
resolve(arguments[1]);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
switch (action) {
|
|
|
|
|
case 'bulk-assign':
|
|
|
|
|
api.put(`/flags/${flagId}`, {
|
|
|
|
|
assignee: app.user.uid,
|
|
|
|
|
}, handler);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'bulk-mark-resolved':
|
|
|
|
|
api.put(`/flags/${flagId}`, {
|
|
|
|
|
state: 'resolved',
|
|
|
|
|
}, handler);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}));
|
|
|
|
|
const promises = flagIds.map((flagId) => {
|
|
|
|
|
const data = {};
|
|
|
|
|
if (action === 'bulk-assign') {
|
|
|
|
|
data.assignee = app.user.uid;
|
|
|
|
|
} else if (action === 'bulk-mark-resolved') {
|
|
|
|
|
data.state = 'resolved';
|
|
|
|
|
}
|
|
|
|
|
return api.put(`/flags/${flagId}`, data);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Promise.allSettled(promises).then(function (results) {
|
|
|
|
|