diff --git a/src/modules/twinklexfd.js b/src/modules/twinklexfd.js index 249fd28a4..e536867e1 100644 --- a/src/modules/twinklexfd.js +++ b/src/modules/twinklexfd.js @@ -317,6 +317,19 @@ Twinkle.xfd.callback.change_category = function twinklexfdCallbackChangeCategory style: 'margin-bottom: 5px; margin-top: -5px;' }); + work_area.append({ + type: 'select', + name: 'outcome', + label: 'Desired outcome:', + event: Twinkle.xfd.callbacks.changeOutcome, + list: [ + { label: 'Delete', value: 'deletion' }, + { label: 'Merge', value: 'merging' }, + { label: 'Redirect', value: 'redirecting' }, + { label: 'Draftify', value: 'draftification' } + ] + }); + work_area.append({ type: 'checkbox', list: [ @@ -750,6 +763,15 @@ Twinkle.xfd.callback.change_category = function twinklexfdCallbackChangeCategory }; Twinkle.xfd.callbacks = { + changeOutcome: function(outcome) { + const form = outcome.target.form; + const reasonBox = form.querySelector('textarea[name="reason"]'); + if (outcome.target.value === 'draftification') { + reasonBox.value = "I propose '''draftifying''' because "; + } else { + reasonBox.value = ''; + } + }, // Requires having the tag text (params.tagText) set ahead of time autoEditRequest: function(pageobj, params) { const talkName = new mw.Title(pageobj.getPageName()).getTalkPage().toText(); @@ -900,11 +922,12 @@ Twinkle.xfd.callbacks = { // Ensure items with User talk or no namespace prefix both end // up at user talkspace as expected, but retain the // prefix-less username for addToLog - notifyTarget = mw.Title.newFromText(notifyTarget, 3); + const userTalkNamespace = 3; + notifyTarget = mw.Title.newFromText(notifyTarget, userTalkNamespace); const targetNS = notifyTarget.getNamespaceId(); - const usernameOrTarget = notifyTarget.getRelativeText(3); + const usernameOrTarget = notifyTarget.getRelativeText(userTalkNamespace); notifyTarget = notifyTarget.toText(); - if (targetNS === 3) { + if (targetNS === userTalkNamespace) { // Disallow warning yourself if (usernameOrTarget === mw.config.get('wgUserName')) { Morebits.Status.warn('You (' + usernameOrTarget + ') created this page; skipping user notification'); @@ -919,11 +942,19 @@ Twinkle.xfd.callbacks = { actionName = actionName || 'Notifying initial contributor (' + usernameOrTarget + ')'; } + // For grep: Afd notice, Mfd notice, Tfd notice, Cfd notice, Ffd notice, Rfd notice let notifytext = '\n{{subst:' + params.venue + ' notice'; // Venue-specific parameters switch (params.venue) { case 'afd': + if (params.outcome !== 'deletion') { + notifytext += '|outcome=' + params.outcome; + } + // tell the template to add " (Xnd nomination)" to the XFD title, if needed + notifytext += params.numbering !== '' ? '|order= ' + params.numbering : ''; + break; case 'mfd': + // tell the template to add " (Xnd nomination)" to the XFD title, if needed notifytext += params.numbering !== '' ? '|order= ' + params.numbering : ''; break; case 'tfd': @@ -1179,8 +1210,27 @@ Twinkle.xfd.callbacks = { Twinkle.xfd.callbacks.addToLog(params, null); } - params.tagText = (params.noinclude ? '{{' : '{{') + (params.number === '' ? 'subst:afd|help=off' : 'subst:afdx|' + - params.number + '|help=off') + (params.noinclude ? '}}\n' : '}}\n'); + let noIncludeStart = ''; + let noIncludeEnd = ''; + if (params.noinclude) { + noIncludeStart = ''; + noIncludeEnd = ''; + } + + let outcome = ''; + if (params.outcome !== 'deletion') { + outcome = '|outcome=' + params.outcome; + } + + let templateAndParams = ''; + const isFirstNomination = params.number === ''; + if (isFirstNomination) { + templateAndParams = 'subst:afd|help=off' + outcome; + } else { + templateAndParams = 'subst:afdx|' + params.number + '|help=off' + outcome; + } + + params.tagText = noIncludeStart + '{{' + templateAndParams + '}}' + noIncludeEnd + '\n'; if (pageobj.canEdit()) { // Remove some tags that should always be removed on AfD.