Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 55 additions & 5 deletions src/modules/twinklexfd.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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');
Expand All @@ -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':
Expand Down Expand Up @@ -1179,8 +1210,27 @@ Twinkle.xfd.callbacks = {
Twinkle.xfd.callbacks.addToLog(params, null);
}

params.tagText = (params.noinclude ? '<noinclude>{{' : '{{') + (params.number === '' ? 'subst:afd|help=off' : 'subst:afdx|' +
params.number + '|help=off') + (params.noinclude ? '}}</noinclude>\n' : '}}\n');
let noIncludeStart = '';
let noIncludeEnd = '';
if (params.noinclude) {
noIncludeStart = '<noinclude>';
noIncludeEnd = '</noinclude>';
}

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.
Expand Down
Loading