Content deleted Content added
[f1889df] prevent wiping comments if diffs remain |
v0.2.1; https://github.com/ChlodAlejandro/deputy/releases/tag/v0.2.1 |
||
Line 39:
*//*!
* @package idb
* @version 7.
* @license ISC
* @author Jake Archibald
Line 286:
if (upgrade) {
request.addEventListener('upgradeneeded', (event) => {
upgrade(wrap(request.result), event.oldVersion, event.newVersion, wrap(request.transaction), event);
});
}
if (blocked) {
request.addEventListener('blocked', (event) => blocked(
// Casting due to https://github.com/microsoft/TypeScript-DOM-lib-generator/pull/1405
event.oldVersion, event.newVersion, event));
}
openPromise
.then((db) => {
if (terminated)
db.addEventListener('close', () => terminated());
if (blocking) {
db.addEventListener('versionchange', (event) => blocking(event.oldVersion, event.newVersion, event));
}
})
.catch(() => { });
Line 759 ⟶ 763:
return (_a = this.content) !== null && _a !== void 0 ? _a : (this.content = yield getPageContent(this.casePage.pageId));
});
}
/**
* Removes the cached wikitext for this page.
*/
resetCachedWikitext() {
this.content = undefined;
}
/**
Line 770 ⟶ 780:
return __awaiter(this, void 0, void 0, function* () {
if (typeof section === 'number') {
return getPageContent(this.casePage.pageId, { rvsection: section }).then((v) =>
return Object.assign(v.toString(), {
revid: v.revid
});
});
}
else {
Line 795 ⟶ 809:
}
}
return Object.assign(sectionLines.join('\n')
revid: wikitext.revid
});
}
});
Line 1,203 ⟶ 1,219:
'deputy.session.start').text()),
h_1("span", { class: "dp-sessionStarter-bracket" }, "]"));
}
Line 1,246 ⟶ 1,245:
}
return el.$element[0];
}
Line 1,702 ⟶ 1,667:
[ContributionSurveyRowStatus.PresumptiveRemoval]: /\{\{x}}/gi
};
/**
* Swaps two elements in the DOM. Element 1 will be removed from the DOM, Element 2 will
* be added in its place.
*
* @param element1 The element to remove
* @param element2 The element to insert
* @return `element2`, for chaining
*/
function swapElements (element1, element2) {
try {
element1.insertAdjacentElement('afterend', element2);
element1.parentElement.removeChild(element1);
return element2;
}
catch (e) {
console.error(e, { element1, element2 });
// Caught for debug only. Rethrow.
throw e;
}
}
/**
Line 2,211 ⟶ 2,197:
}
}
return processedClasses.filter((v) => v != null &&
}
Line 2,840 ⟶ 2,826:
this.unfinishedMessageBox = new OO.ui.MessageWidget({
classes: ['dp-cs-row-unfinishedWarning'],
type: '
label: mw.msg('deputy.session.row.unfinishedWarning')
});
Line 3,128 ⟶ 3,114:
* @param closingComments Closing comments for this section
* @param wikitext The original wikitext of this section
* @param revid The revision ID of the wikitext attached to this section.
*/
constructor(casePage, name, closed, closingComments, wikitext, revid) {
this.casePage = casePage;
this.name = name;
Line 3,136 ⟶ 3,123:
this.originalWikitext = wikitext;
this.originallyClosed = closed;
this.revid = revid;
}
}
Line 3,316 ⟶ 3,304:
section = yield getSectionId(page, section);
}
return MwApi.action.get(Object.assign({ action: 'parse', prop: 'text|wikitext|revid', page: normalizeTitle(page).getPrefixedText(), section: section, disablelimitreport: true }, extraOptions)).then((data) => {
const temp = document.createElement('span');
temp.innerHTML = data.parse.text;
return {
element: temp.children[0],
wikitext: data.parse.wikitext,
revid: data.parse.revid
};
});
Line 3,342 ⟶ 3,331:
* modifying it manually.
*/
var deputyVersion = /* v */ '0.2.
/**
Line 3,376 ⟶ 3,365:
ContributionSurveyRowSigningBehavior["Never"] = "never";
})(ContributionSurveyRowSigningBehavior || (ContributionSurveyRowSigningBehavior = {}));
let InternalDeputyMessageWidget;
/**
* Initializes the process element.
*/
function initDeputyMessageWidget() {
InternalDeputyMessageWidget = class DeputyMessageWidget extends OO.ui.MessageWidget {
/**
* @param config Configuration to be passed to the element.
*/
constructor(config) {
var _a;
super(config);
this.$element.addClass('dp-messageWidget');
const elLabel = this.$label[0];
if (!config.label) {
if (config.title) {
elLabel.appendChild(h_1("b", { style: { display: 'block' } }, config.title));
}
if (config.message) {
elLabel.appendChild(h_1("p", { class: "dp-messageWidget-message" }, config.message));
}
}
if (config.actions || config.closable) {
const actionContainer = h_1("div", { class: "dp-messageWidget-actions" });
for (const action of ((_a = config.actions) !== null && _a !== void 0 ? _a : [])) {
if (action instanceof OO.ui.Widget) {
actionContainer.appendChild(unwrapWidget(action));
}
else {
actionContainer.appendChild(action);
}
}
if (config.closable) {
const closeButton = new OO.ui.ButtonWidget({
label: mw.msg('deputy.dismiss')
});
closeButton.on('click', () => {
removeElement(unwrapWidget(this));
});
actionContainer.appendChild(unwrapWidget(closeButton));
}
elLabel.appendChild(actionContainer);
}
}
};
}
/**
* Creates a new DeputyMessageWidget. This is an extension of the default
* OOUI MessageWidget. It includes support for a title, a message, and button
* actions.
*
* @param config Configuration to be passed to the element.
* @return A DeputyMessageWidget object
*/
function DeputyMessageWidget (config) {
if (!InternalDeputyMessageWidget) {
initDeputyMessageWidget();
}
return new InternalDeputyMessageWidget(config);
}
/**
Line 3,557 ⟶ 3,607:
return __awaiter(this, void 0, void 0, function* () {
const collapsible = (_b = (_a = this.sectionElements.find((v) => v.querySelector('.mw-collapsible'))) === null || _a === void 0 ? void 0 : _a.querySelector('.mw-collapsible')) !== null && _b !== void 0 ? _b : null;
const sectionWikitext = yield this.casePage.wikitext.getSectionWikitext(this.headingName);
return (_c = this._section) !== null && _c !== void 0 ? _c : (this._section = new ContributionSurveySection(this.casePage, this.headingName, collapsible != null, collapsible === null || collapsible === void 0 ? void 0 : collapsible.querySelector('th > div').innerText, wikitext !== null && wikitext !== void 0 ? wikitext : });
}
Line 3,587 ⟶ 3,638:
}
}
const
const sectionWikitext = section.originalWikitext;
this.revid = section.revid;
const wikitextLines = sectionWikitext.split('\n');
this.rows = [];
Line 3,600 ⟶ 3,653:
catch (e) {
// Only trigger on actual bulleted lists.
if (
console.warn('Could not parse row.', line, e);
// For debugging and tests.
mw.hook('deputy.errors.cciRowParse').fire({
line, error: e.toString()
});
}
rowElement = line;
Line 3,672 ⟶ 3,727:
section: sectionId,
text: this.wikitext,
baserevid: this.revid,
summary: decorateEditSummary(this.editSummary)
}).then(function (data) {
return data;
},
if (code === 'editconflict') {
// Wipe cache.
this.casePage.wikitext.resetCachedWikitext();
OO.ui.alert(mw.msg('deputy.session.section.conflict.help'), {
title: mw.msg('deputy.session.section.conflict.title')
}).then(() => {
window.deputy.session.rootSession.restartSession();
});
return false;
}
mw.notify(h_1("span", { dangerouslySetInnerHTML: data.errors[0].html }), {
autoHide: false,
Line 3,751 ⟶ 3,817:
mw.notify(mw.msg('deputy.session.section.saved'));
// Rebuild the entire section to HTML, and then reopen.
const { element, wikitext, revid } = yield getSectionHTML(this.casePage.title, sectionId);
removeElement(this.container);
const sectionElements = this.casePage.getContributionSurveySection(this.heading);
Line 3,768 ⟶ 3,834:
if (!this._section.closed) {
this._section = null;
yield this.getSection(Object.assign(wikitext, { revid }));
yield this.prepare();
oldHeading.insertAdjacentElement('afterend', this.render());
// Run this asynchronously.
setTimeout(this.loadData.bind(this), 0);
}
removeElement(oldHeading);
Line 3,782 ⟶ 3,850:
this.setDisabled(false);
}));
const closingWarning = DeputyMessageWidget({
classes: ['dp-cs-section-unfinishedWarning'],
type: 'warning',
label: mw.msg('deputy.session.section.closeWarning')
});
closingWarning.toggle(false);
const closingCommentsField = new OO.ui.FieldLayout(this.closingComments, {
align: 'top',
Line 3,799 ⟶ 3,873:
this.closed = v;
closingCommentsField.toggle(v);
closingWarning.toggle(v && this.rows.some((row) => !row.completed));
this.toggleClosingComments(v);
});
Line 3,819 ⟶ 3,894:
label: mw.msg('deputy.session.section.close')
})),
unwrapWidget(closingWarning),
unwrapWidget(closingCommentsField)),
h_1("div", { style: { display: 'flex', alignItems: 'end' } },
Line 3,826 ⟶ 3,902:
saveContainer));
}
}
Line 3,911 ⟶ 3,972:
const firstHeading = casePage.findContributionSurveyHeadings()[0];
if (firstHeading) {
flags: ['primary', 'destructive']
});
const messageBox = new OO.ui.MessageWidget({
classes: [
Line 3,919 ⟶ 3,982:
type: 'notice',
icon: 'alert',
});
stopButton.on('click', () => __awaiter(this, void 0, void 0, function* () {
Line 3,943 ⟶ 4,004:
window.deputy.session.init();
});
firstHeading.insertAdjacentElement('beforebegin', unwrapWidget(messageBox));
}
Line 3,967 ⟶ 4,026:
// Insert element directly into widget (not as text, or else event
// handlers will be destroyed).
const
label: mw.msg('deputy.session.continue.button'),
flags: ['primary', 'progressive']
});
const messageBox = DeputyMessageWidget({
classes: [
'deputy', 'dp-cs-session-notice', 'dp-cs-session-lastActive'
Line 3,973 ⟶ 4,036:
type: 'notice',
icon: 'history',
title: mw.msg('deputy.session.continue.head', new Date().toLocaleString(mw.config.get('wgUserLanguage'), { dateStyle: 'long', timeStyle: 'medium' })),
message:
});
const sessionStartListener = () => __awaiter(this, void 0, void 0, function* () {
Line 3,991 ⟶ 4,050:
window.deputy.comms.removeEventListener('sessionStarted', sessionStartListener);
});
firstHeading.insertAdjacentElement('beforebegin', unwrapWidget(messageBox));
window.deputy.comms.addEventListener('sessionStarted', sessionStartListener, { once: true });
Line 4,013 ⟶ 4,070:
const firstHeading = casePage.findContributionSurveyHeadings()[0];
if (firstHeading) {
const messageBox =
classes: [
'deputy', 'dp-cs-session-notice', 'dp-cs-session-tabActive'
],
type: 'info',
message: mw.msg('deputy.session.tabActive.help'),
closable: true
});
firstHeading.insertAdjacentElement('beforebegin', unwrapWidget(messageBox));
Line 4,288 ⟶ 4,347:
}
}
});
}
/**
* Restarts the section. This rebuilds *everything* from the ground up, which may
* be required when there's an edit conflict.
*/
restartSession() {
return __awaiter(this, void 0, void 0, function* () {
const casePage = this.casePage;
yield this.closeSession();
yield window.deputy.session.DeputyRootSession.continueSession(casePage);
});
}
Line 5,934 ⟶ 6,004:
constructor(parent) {
this._parent = parent;
const r = window.btoa((Math.random() * 10000).toString()).slice(0, 6);
this.name = this.parent.name + '#' + r;
this.id = window.btoa(parent.node.getTarget().wt) + '-' + this.name;
}
/**
Line 6,411 ⟶ 6,481:
this.name = this.element.getAttribute('about')
.replace(/^#mwt/, '') + '-' + this.i;
this.id = window.btoa(node.getTarget().wt) + '-' + this.name;
this.parse();
}
Line 7,795 ⟶ 7,865:
* @param _regex The regular expression to exec with
* @param string The string to exec against
* @return The matches found
*/
function matchAll(_regex, string) {
Line 8,226 ⟶ 8,297:
if (this.backwardsCopyTemplate.node.hasParameter('bot')) {
const bot = this.backwardsCopyTemplate.node.getParameter('bot');
return unwrapWidget(
type: 'notice',
icon: 'robot',
label: new OO.ui.HtmlSnippet(mw.message('deputy.ante.backwardsCopy.bot', bot).parse()),
closable: true
}));
}
Line 8,245 ⟶ 8,317:
// Insert element directly into widget (not as text, or else event
// handlers will be destroyed).
const messageBox =
type: 'notice',
icon: 'alert',
label: new OO.ui.HtmlSnippet(DemoTemplateMessage().innerHTML),
closable: true
});
const clearButton = new OO.ui.ButtonWidget({
Line 10,518 ⟶ 10,591:
previewButton.on('click', () => __awaiter(this, void 0, void 0, function* () {
previewButton.setDisabled(true);
yield openWindow(DeputyReviewDialog({
title: normalizeTitle(this.parsoid.getPage()),
from: yield getPageContent(this.parsoid.getPage()),
Line 11,035 ⟶ 11,108:
yield mw.loader.using('moment')
.then(() => true, () => null);
yield mw.loader.getScript(new URL(`resources/lib/moment/locale/${locale}.js`, new URL(mw.util.wikiScript('index'), window.___location.href)).
});
}
Line 12,205 ⟶ 12,278:
*/
function ConfigurationReloadBanner() {
const
flags: ['progressive', 'primary'],
label: mw.msg('deputy.settings.wikiOutdated.reload')
});
const messageBox = DeputyMessageWidget({
classes: [
'deputy', 'dp-mb'
],
type: 'info',
actions:
});
reloadButton.on('click', () => __awaiter(this, void 0, void 0, function* () {
Line 12,226 ⟶ 12,295:
}));
const box = unwrapWidget(messageBox);
box.style.fontSize = 'calc(1em * 0.875)';
return box;
Line 12,702 ⟶ 12,770:
"deputy.negativeDiff": "-{{FORMATNUM:$1}}",
"deputy.moreInfo": "More information",
"deputy.dismiss": "Dismiss",
"deputy.comma-separator": ", ",
"deputy.diff": "Review your changes",
Line 12,875 ⟶ 12,944:
];
var deputyStyles = "/*=============================================================================== GLOBAL DEPUTY CLASSES===============================================================================*/* > .deputy.dp-heading {position: absolute;opacity: 0;pointer-events: none;}*:hover > .deputy.dp-heading:not(.dp-heading--active) {opacity: 1;pointer-events: all;}.dp-loadingDots-1, .dp-loadingDots-2, .dp-loadingDots-3 {display: inline-block;margin: 0.1em 0.6em 0.1em 0.1em;width: 0.8em;height: 0.8em;background-color: rgba(0, 0, 0, 50%);animation: dp-loadingDots linear 3s infinite;border-radius: 50%;}@keyframes dp-loadingDots {0% {background-color: rgba(0, 0, 0, 10%);}16% {background-color: rgba(0, 0, 0, 40%);}32% {background-color: rgba(0, 0, 0, 10%);}100% {background-color: rgba(0, 0, 0, 10%);}}.dp-loadingDots-1 {animation-delay: -1s;}.dp-loadingDots-2 {animation-delay: -0.5s;}#mw-content-text.dp-reloading {opacity: 0.2;pointer-events: none;}p.dp-messageWidget-message {margin: 0 0 0.5em 0;}.dp-messageWidget-actions .oo-ui-buttonElement {margin-top: 0;}/*=============================================================================== DEPUTY REVIEW DIALOG (DeputyReviewDialog)===============================================================================*/.dp-review-progress {flex: 1;width: 60%;min-width: 300px;}/*=============================================================================== DEPUTY ENTRY POINTS (DeputyCCISessionStartLink, etc.)===============================================================================*/.deputy.dp-sessionStarter {font-size: small;font-weight: normal;margin-left: 0.25em;vertical-align: baseline;line-height: 1em;}.deputy.dp-sessionStarter::before {content: '\\200B';}.mw-content-ltr .deputy.dp-sessionStarter .dp-sessionStarter-bracket:first-of-type,.mw-content-rtl .deputy.dp-sessionStarter .dp-sessionStarter-bracket:not(:first-of-type) {margin-right: 0.25em;color: #54595d;}.client-js .deputy.dp-sessionStarter .dp-sessionStarter-bracket:first-of-type,.client-js .deputy.dp-sessionStarter .dp-sessionStarter-bracket:not(:first-of-type) {margin-left: 0.25em;color: #54595d
var deputyCoreEnglish = {
Line 12,898 ⟶ 12,967:
"deputy.session.section.closeComments": "Archiving comments",
"deputy.session.section.closeHelp": "Your signature will automatically be included.",
"deputy.session.section.closeWarning": "Some revisions remain unassessed. You may want to mark these revisions as assessed before archiving this section.",
"deputy.session.section.closeWarn": "You have unsaved changes. Close the section without saving?",
"deputy.session.section.stop": "Stop session",
Line 12,903 ⟶ 12,973:
"deputy.session.section.failed": "Failed to save section",
"deputy.session.section.missingSection": "The target section is missing from the case page.",
"deputy.session.section.conflict.title": "Edit conflict",
"deputy.session.section.conflict.help": "Someone else edited the page before you. Deputy will restart to load the new case content. Your changes will be preserved.",
"deputy.session.row.status": "Current page status",
"deputy.session.row.status.unfinished": "Unfinished",
|