framework/extensions/approval/js/admin/dist/extension.js
Toby Zerner 4282b9be20 Add separate "start discussions without approval" permission
- Register required permissions so that "start discussions without approval" can only be set for groups that already have permission to "start discussions" (and same for reply)
- Change the "hidden" trash badge into a more descriptive gavel badge for discussions that are awaiting approval

closes flarum/core#904
2016-05-27 14:40:59 +09:30

51 lines
1.9 KiB
JavaScript

'use strict';
System.register('flarum/approval/main', ['flarum/extend', 'flarum/app', 'flarum/components/PermissionGrid'], function (_export, _context) {
var extend, app, PermissionGrid;
return {
setters: [function (_flarumExtend) {
extend = _flarumExtend.extend;
}, function (_flarumApp) {
app = _flarumApp.default;
}, function (_flarumComponentsPermissionGrid) {
PermissionGrid = _flarumComponentsPermissionGrid.default;
}],
execute: function () {
app.initializers.add('approval', function () {
extend(app, 'getRequiredPermissions', function (required, permission) {
if (permission === 'discussion.startWithoutApproval') {
required.push('startDiscussion');
}
if (permission === 'discussion.replyWithoutApproval') {
required.push('discussion.reply');
}
});
extend(PermissionGrid.prototype, 'startItems', function (items) {
items.add('startDiscussionsWithoutApproval', {
icon: 'check',
label: app.translator.trans('flarum-approval.admin.permissions.start_discussions_without_approval_label'),
permission: 'discussion.startWithoutApproval'
}, 95);
});
extend(PermissionGrid.prototype, 'replyItems', function (items) {
items.add('replyWithoutApproval', {
icon: 'check',
label: app.translator.trans('flarum-approval.admin.permissions.reply_without_approval_label'),
permission: 'discussion.replyWithoutApproval'
}, 95);
});
extend(PermissionGrid.prototype, 'moderateItems', function (items) {
items.add('approvePosts', {
icon: 'check',
label: app.translator.trans('flarum-approval.admin.permissions.approve_posts_label'),
permission: 'discussion.approvePosts'
}, 65);
});
});
}
};
});