jenkins-bot has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/398680 )
Change subject: Use new editor instead of old editor for undoing topic summary
edits
......................................................................
Use new editor instead of old editor for undoing topic summary edits
setupUndoPage() and replaceNoJSEditor() between them already handled
evey other case where the old editor system was used, this was the last
unhandled case.
Change-Id: I5b129047630bfaea04d361322701d7020287c8c2
---
M modules/mw.flow.Initializer.js
1 file changed, 59 insertions(+), 3 deletions(-)
Approvals:
Sbisson: Looks good to me, approved
jenkins-bot: Verified
diff --git a/modules/mw.flow.Initializer.js b/modules/mw.flow.Initializer.js
index d5e37f4..bfbc12d 100644
--- a/modules/mw.flow.Initializer.js
+++ b/modules/mw.flow.Initializer.js
@@ -859,7 +859,8 @@
*/
mw.flow.Initializer.prototype.isUndoForm = function () {
return !!( $( 'form[data-module="topic"]' ).length ||
- $( 'form[data-module="header"]' ).length );
+ $( 'form[data-module="header"]' ).length ) ||
+ $( 'form[data-module="topicsummary"]' ).length;
};
/**
@@ -869,7 +870,9 @@
if ( $( 'form[data-module="topic"]' ).length ) {
this.replaceEditorInUndoEditPost( $(
'form[data-module="topic"]' ) );
} else if ( $( 'form[data-module="header"]' ).length ) {
- this.replaceEditorInUndoHeaderPost( $(
'form[data-module="header"]' ) );
+ this.replaceEditorInUndoHeader( $(
'form[data-module="header"]' ) );
+ } else if ( $( 'form[data-module="topicsummary"]' ).length ) {
+ this.replaceEditorInUndoSummary( $(
'form[data-module="topicsummary"]' ) );
}
};
@@ -930,7 +933,7 @@
*
* @param {jQuery} $form The form where the no-js editor exists to be
replaced
*/
- mw.flow.Initializer.prototype.replaceEditorInUndoHeaderPost = function
( $form ) {
+ mw.flow.Initializer.prototype.replaceEditorInUndoHeader = function (
$form ) {
var prevRevId, editor, content,
apiHandler,
pageName = mw.config.get( 'wgPageName' ),
@@ -978,6 +981,59 @@
};
/**
+ * Replace the editor in undo edit topic summary pages
+ *
+ * @param {jQuery} $form The form where the no-js editor exists to be
replaced
+ */
+ mw.flow.Initializer.prototype.replaceEditorInUndoSummary = function (
$form ) {
+ var prevRevId, editor, content,
+ apiHandler,
+ pageName = mw.config.get( 'wgPageName' ),
+ title = mw.Title.newFromText( pageName ),
+ topicId = title.getNameText(),
+ returnToTitle = function () {
+ window.location.href = title.getUrl();
+ };
+
+ if ( !$form.length ) {
+ return;
+ }
+
+ prevRevId = $form.find(
'input[name="topicsummary_prev_revision"]' ).val();
+ content = $form.find( 'textarea' ).val();
+
+ apiHandler = new mw.flow.dm.APIHandler(
+ 'Topic:' + topicId,
+ {
+ currentRevision: prevRevId
+ }
+ );
+
+ // Create the editor
+ editor = this.createEditorWidget(
+ $form,
+ content,
+ 'flow-topic-action-update-topic-summary'
+ );
+
+ // Events
+ editor
+ .on( 'afterSaveContent', function ( content,
contentFormat, captcha, handleFailure ) {
+ apiHandler.saveTopicSummary( topicId, content,
contentFormat, captcha )
+ .then(
+ // Success
+ returnToTitle,
+
+ // Failure
+ handleFailure
+ );
+ } )
+ .on( 'afterCancel', function () {
+ returnToTitle();
+ } );
+ };
+
+ /**
* Finish the loading process
*/
mw.flow.Initializer.prototype.finishLoading = function () {
--
To view, visit https://gerrit.wikimedia.org/r/398680
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I5b129047630bfaea04d361322701d7020287c8c2
Gerrit-PatchSet: 5
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: Catrope <[email protected]>
Gerrit-Reviewer: Catrope <[email protected]>
Gerrit-Reviewer: Esanders <[email protected]>
Gerrit-Reviewer: Sbisson <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits