framework/extensions/approval/js/admin/dist/extension.js

51 lines
1.9 KiB
JavaScript
Raw Normal View History

2016-03-18 07:01:17 +08:00
'use strict';
2015-10-11 20:24:48 +08:00
2016-03-18 07:01:17 +08:00
System.register('flarum/approval/main', ['flarum/extend', 'flarum/app', 'flarum/components/PermissionGrid'], function (_export, _context) {
2015-10-11 20:24:48 +08:00
var extend, app, PermissionGrid;
return {
setters: [function (_flarumExtend) {
extend = _flarumExtend.extend;
}, function (_flarumApp) {
2016-03-18 07:01:17 +08:00
app = _flarumApp.default;
2015-10-11 20:24:48 +08:00
}, function (_flarumComponentsPermissionGrid) {
2016-03-18 07:01:17 +08:00
PermissionGrid = _flarumComponentsPermissionGrid.default;
2015-10-11 20:24:48 +08:00
}],
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);
});
2015-10-11 20:24:48 +08:00
extend(PermissionGrid.prototype, 'replyItems', function (items) {
items.add('replyWithoutApproval', {
icon: 'check',
label: app.translator.trans('flarum-approval.admin.permissions.reply_without_approval_label'),
2015-10-11 20:24:48 +08:00
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'),
2015-10-11 20:24:48 +08:00
permission: 'discussion.approvePosts'
}, 65);
});
});
}
};
});