jenkins-bot has submitted this change and it was merged.

Change subject: Provide a possibility to skip preview in mobile frontend
......................................................................


Provide a possibility to skip preview in mobile frontend

New value for wgMFEditorOptions: skipPreview to skip the editor preview and save
the changes directly.

Bug: T78504
Change-Id: Ic8fbbad646e50bc20a86c4b25f88de3611ec6fbf
---
M includes/config/Editing.php
M javascripts/modules/editor/EditorOverlay.js
M javascripts/modules/editor/EditorOverlayBase.js
M javascripts/modules/editor/VisualEditorOverlay.js
M tests/qunit/modules/editor/test_EditorOverlay.js
5 files changed, 33 insertions(+), 3 deletions(-)

Approvals:
  Robmoen: Looks good to me, approved
  Jdlrobson: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/config/Editing.php b/includes/config/Editing.php
index 9602fd5..b25bd3f 100644
--- a/includes/config/Editing.php
+++ b/includes/config/Editing.php
@@ -25,7 +25,10 @@
  *     until anonymous editing experience is addressed in this extension. 
Anonymous editing
  *     on mobile is still a big unknown. See bug 53069.
  *     Thoughts welcomed on 
https://www.mediawiki.org/wiki/Mobile_wikitext_editing#Anonymous_editing
+ * - 'skipPreview': Should the mobile edit workflow contain an edit preview 
(before save) to give
+ *     the user the possibility to review the new text resulting of his 
changes or not.
  */
 $wgMFEditorOptions = array(
        'anonymousEditing' => false,
+       'skipPreview' => false,
 );
diff --git a/javascripts/modules/editor/EditorOverlay.js 
b/javascripts/modules/editor/EditorOverlay.js
index 7233c86..a0ef9f7 100644
--- a/javascripts/modules/editor/EditorOverlay.js
+++ b/javascripts/modules/editor/EditorOverlay.js
@@ -169,8 +169,8 @@
                _showEditorAfterWarning: function () {
                        this.showSpinner();
                        this.$anonWarning.hide();
-                       // reenable "Next" button and handle click
-                       this.$( '.continue' ).show().on( 'click', $.proxy( 
this, 'onStageChanges' ) );
+                       // reenable "Next" button
+                       this.$( '.continue' ).show();
                        this._loadContent();
                },
 
diff --git a/javascripts/modules/editor/EditorOverlayBase.js 
b/javascripts/modules/editor/EditorOverlayBase.js
index 0fd584b..8f55ec0 100644
--- a/javascripts/modules/editor/EditorOverlayBase.js
+++ b/javascripts/modules/editor/EditorOverlayBase.js
@@ -208,6 +208,7 @@
                        this.sectionId = options.sectionId;
                        this.funnel = options.funnel;
                        this.schema = new SchemaMobileWebEditing();
+                       this.config = mw.config.get( 'wgMFEditorOptions' );
 
                        Overlay.prototype.initialize.apply( this, arguments );
                },
@@ -266,11 +267,21 @@
                                // log cancel attempt
                                self.log( 'cancel' );
                        } );
+                       // decide what happens, when the user clicks the 
continue button
+                       if ( this.config.skipPreview ) {
+                               // skip the preview and save the changes
+                               this.nextStep = 'onSaveBegin';
+                               this.$( '.continue' ).text( 
this.defaults.saveMsg );
+                       } else {
+                               // default: show the preview step
+                               this.nextStep = 'onStageChanges';
+                       }
                        Overlay.prototype.postRender.apply( this, arguments );
                        // FIXME: Don't call a private method that is outside 
the class.
                        this._showHidden( '.initial-header' );
+                       // FIXME: Events should be managed with the events array
                        this.$( '.submit' ).on( 'click', $.proxy( this, 
'onSaveBegin' ) );
-                       this.$( '.continue' ).on( 'click', $.proxy( this, 
'onStageChanges' ) );
+                       this.$( '.continue' ).on( 'click', $.proxy( this, 
this.nextStep ) );
                },
                /**
                 * Set up the editor switching interface
diff --git a/javascripts/modules/editor/VisualEditorOverlay.js 
b/javascripts/modules/editor/VisualEditorOverlay.js
index 5b125c6..b6d1680 100644
--- a/javascripts/modules/editor/VisualEditorOverlay.js
+++ b/javascripts/modules/editor/VisualEditorOverlay.js
@@ -39,6 +39,10 @@
                        options.editingMsg = mw.msg( 
'mobile-frontend-editor-editing' );
                        EditorOverlayBase.prototype.initialize.apply( this, 
arguments );
                        this._hasChanged = false;
+                       // force editor preview step for VE
+                       this.config = $.extend( this.config, {
+                               skipPreview: false
+                       } );
                        this.$continueBtn = self.$( '.continue' ).prop( 
'disabled', true );
                        this.initializeSwitcher();
                },
diff --git a/tests/qunit/modules/editor/test_EditorOverlay.js 
b/tests/qunit/modules/editor/test_EditorOverlay.js
index 4a21fdd..33b1489 100644
--- a/tests/qunit/modules/editor/test_EditorOverlay.js
+++ b/tests/qunit/modules/editor/test_EditorOverlay.js
@@ -32,6 +32,18 @@
                assert.strictEqual( editorOverlay.$preview.text(), 
'\npreviewtest\n', 'preview loaded correctly' );
        } );
 
+       QUnit.test( '#without-preview', 1, function( assert ) {
+               var editorOverlay;
+
+               this.sandbox.stub( mw.config, 'get' ).withArgs( 
'wgMFEditorOptions' ).returns( {
+                       skipPreview: true,
+                       anonymousEditing: true
+               } );
+
+               editorOverlay = new EditorOverlay( { title: 'test', sectionId: 
0 } );
+               assert.strictEqual( editorOverlay.$( '.continue' ).text(), 
'Save', 'no preview loaded' );
+       } );
+
        QUnit.test( '#initialize, without a section', 2, function( assert ) {
                new EditorOverlay( { title: 'test.css' } );
 

-- 
To view, visit https://gerrit.wikimedia.org/r/179863
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ic8fbbad646e50bc20a86c4b25f88de3611ec6fbf
Gerrit-PatchSet: 23
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Florianschmidtwelzow <[email protected]>
Gerrit-Reviewer: Awjrichards <[email protected]>
Gerrit-Reviewer: Bmansurov <[email protected]>
Gerrit-Reviewer: Florianschmidtwelzow <[email protected]>
Gerrit-Reviewer: Jdlrobson <[email protected]>
Gerrit-Reviewer: Robmoen <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to