Content deleted Content added
fix api init. |
MusikAnimal (talk | contribs) add expiry option :) |
||
Line 31:
'Page mover': 'Page mover granted',
'Pending changes reviewer': 'Pending changes reviewer granted',
'Rollback': '
'Template editor': 'Template editor granted'
};
Line 41:
permaLink, userName, dialog;
mw.loader.using(['oojs-ui', 'mediawiki.api', 'mediawiki.widgets.DateInputWidget'], function() {
api = new mw.Api();
$('.perm-assign-permissions a').on('click', function(e) {
Line 66:
};
Dialog.prototype.getBodyHeight = function() {
return
};
Dialog.prototype.initialize = function() {
Line 79:
this.rightsChangeSummaryInput = new OO.ui.TextInputWidget({
value: 'Requested at [[WP:PERM]]'
});
this.expiryInput = new mw.widgets.DateInputWidget({
$overlay: $('.oo-ui-window')
});
this.closingRemarksInput = new OO.ui.TextInputWidget({
Line 89 ⟶ 92:
new OO.ui.FieldLayout(this.rightsChangeSummaryInput, {
label: 'Summary'
}),
new OO.ui.FieldLayout(this.expiryInput, {
label: 'Expiry (optional)'
}),
new OO.ui.FieldLayout(this.closingRemarksInput, {
Line 121 ⟶ 127:
} );
this.$body.append( this.stackLayout.$element );
$( '.mw-widget-dateInputWidget' ).css( 'width', '100%' );
};
Line 179 ⟶ 186:
assignPermission(
this.rightsChangeSummaryInput.getValue(),
data.edit.newrevid,
this.expiryInput.getValue()
)
).then(function() {
Line 188 ⟶ 196:
addPromise(
self.issueTemplateProgressField,
issueTemplate(this.watchTalkPageCheckbox.isSelected(), this.expiryInput.getValue())
);
}
Line 217 ⟶ 225:
}
function assignPermission(summary, revId, expiry) {
permaLink = '[[Special:PermaLink/' + revId + '#User:' + userName + ']]';
return api.postWithToken( 'userrights', {
Line 224 ⟶ 232:
user: userName.replace(/ /g, '_'),
add: permissionNames[permission],
reason: '+' + permissionNames[permission] + '; ' + summary + '; ' + permaLink + tagLine,
expiry: expiry === '' ? 'infinity' : expiry
});
}
Line 241 ⟶ 250:
}
function issueTemplate(watch, expiry) {
var talkPage = 'User talk:' + userName.replace(/ /g, '_');
return api.postWithToken( 'edit', {
Line 249 ⟶ 258:
section: 'new',
summary: permission + ' granted per ' + permaLink + tagLine,
text: '{{subst:' + templates[permission] + (expiry === '' ? '' : '|expiry=' + expiry) + '}}',
sectiontitle: permission + ' granted',
watchlist: watch ? 'watch' : 'unwatch'
|