Skip to content

Commit

Permalink
fluff: Allow for a list of custom edit summaries
Browse files Browse the repository at this point in the history
fluff: Allow for a list of custom edit summaries

twinkle: Allow for a list of custom edit summaries

Fix lint errors

Fix lint errors

Fix lint errors

Fix
  • Loading branch information
TheTVExpert committed Jan 20, 2021
1 parent dd83b7b commit f153779
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 14 deletions.
9 changes: 8 additions & 1 deletion modules/twinkleconfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,14 @@ Twinkle.config.sections = [
type: 'enum',
enumValues: Twinkle.config.watchlistEnums
},

{
name: 'customReversionSummaryList',
label: 'Custom reversion edit summaries to display',
helptip: 'These appear as options in the enter reversion edit summary dialog',
type: 'customList',
customListValueTitle: 'Edit summary',
customListLabelTitle: 'Text to show in the dialog'
},
// TwinkleConfig.offerReasonOnNormalRevert (boolean)
// If to offer a prompt for extra summary reason for normal reverts, default to true
{
Expand Down
23 changes: 10 additions & 13 deletions modules/twinklefluff.js
Original file line number Diff line number Diff line change
Expand Up @@ -399,22 +399,20 @@ Twinkle.fluff.revertToRevision = function revertToRevision(oldrev) {
wikipedia_api.params = { rev: oldrev, type: 'torev' };
wikipedia_api.post();
};

Twinkle.fluff.getSummary = function getSummary(apiobj) {
Twinkle.fluff.apiobj = apiobj;
var params = apiobj.params;
var type = params.type;
if (type == 'vand' || (type == 'norm' && !Twinkle.getPref('offerReasonOnNormalRevert'))) {
if (type === 'vand' || (type === 'norm' && !Twinkle.getPref('offerReasonOnNormalRevert'))) {
Twinkle.fluff.callbacks.main('noSummary');
} else {
Twinkle.fluff.simpleWindow = new Morebits.simpleWindow(600, 350);
Twinkle.fluff.simpleWindow.setTitle('Enter reversion edit summary');
Twinkle.fluff.simpleWindow.setScriptName('Twinkle');
Twinkle.fluff.simpleWindow.addFooterLink('Revert and rollback prefs', 'WP:TW/PREF#fluff');
Twinkle.fluff.simpleWindow.addFooterLink('Twinkle help', 'WP:TW/DOC#fluff');

var form = new Morebits.quickForm(type == 'torev' ? Twinkle.fluff.callbacks.toRevision : Twinkle.fluff.callbacks.main);

var form = new Morebits.quickForm(type === 'torev' ? Twinkle.fluff.callbacks.toRevision : Twinkle.fluff.callbacks.main);
if (Twinkle.getPref('customReversionSummaryList').length) {
form.append({
type: 'radio',
Expand All @@ -427,30 +425,28 @@ Twinkle.fluff.getSummary = function getSummary(apiobj) {
}
});
}

form.append({
id: 'editSummaryInput',
type: 'input',
name: 'summary',
label: 'Edit summary: '
});

form.append({ type: 'submit' });

var result = form.render();
Twinkle.fluff.simpleWindow.setContent(result);
Twinkle.fluff.simpleWindow.display();
document.getElementById('editSummaryInput').focus();
}
}
};

Twinkle.fluff.callbacks = {
toRevision: function(e) {
var optional_summary;
if (e !== 'noSummary') {
e.preventDefault();
var form = e.target;
var input = Morebits.quickForm.getInputData(form);
var optional_summary = input.summary;
optional_summary = input.summary;
Twinkle.fluff.simpleWindow.close();
}
var apiobj = Twinkle.fluff.apiobj;
Expand Down Expand Up @@ -500,7 +496,7 @@ Twinkle.fluff.callbacks = {
} else {
query.watchlist = 'watch';
// number allowed but not used in Twinkle.config.watchlistEnums
if (!page.watched && typeof watchOrExpiry === 'string' && watchOrExpiry !== 'yes') {
if ((!page.watched || page.watchlistexpiry) && typeof watchOrExpiry === 'string' && watchOrExpiry !== 'yes') {
query.watchlistexpiry = watchOrExpiry;
}
}
Expand All @@ -514,11 +510,12 @@ Twinkle.fluff.callbacks = {
wikipedia_api.post();
},
main: function(e) {
var extra_summary;
if (e !== 'noSummary') {
e.preventDefault();
var form = e.target;
var input = Morebits.quickForm.getInputData(form);
var extra_summary = input.summary;
extra_summary = input.summary;
Twinkle.fluff.simpleWindow.close();
}
var apiobj = Twinkle.fluff.apiobj;
Expand Down Expand Up @@ -727,7 +724,7 @@ Twinkle.fluff.callbacks = {
} else {
query.watchlist = 'watch';
// number allowed but not used in Twinkle.config.watchlistEnums
if (!page.watched && typeof watchOrExpiry === 'string' && watchOrExpiry !== 'yes') {
if ((!page.watched || page.watchlistexpiry) && typeof watchOrExpiry === 'string' && watchOrExpiry !== 'yes') {
query.watchlistexpiry = watchOrExpiry;
}
}
Expand Down
1 change: 1 addition & 0 deletions twinkle.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ Twinkle.defaultConfig = {
markRevertedPagesAsMinor: [ 'vand' ],
watchRevertedPages: [ 'agf', 'norm', 'vand', 'torev' ],
watchRevertedExpiry: 'yes',
customReversionSummaryList: [],
offerReasonOnNormalRevert: true,
confirmOnFluff: false,
confirmOnMobileFluff: true,
Expand Down

0 comments on commit f153779

Please sign in to comment.