Matthias Mullie has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/314024

Change subject: Add 'back' button throughout UW workflow
......................................................................

Add 'back' button throughout UW workflow

* Renamed moveFrom to moveNext, now that we also have
  a second direction to move to
* Added a 'previous' button, very similar to existing
  'next' buttons

Bug: T122923
Change-Id: Ib8931cdc6d7b2f9ab33536641aa822376ebf6b35
---
M extension.json
M i18n/en.json
M i18n/qqq.json
M resources/controller/uw.controller.Deed.js
M resources/controller/uw.controller.Details.js
M resources/controller/uw.controller.Step.js
M resources/controller/uw.controller.Tutorial.js
M resources/mw.UploadWizard.js
M resources/ui/steps/uw.ui.Deed.js
M resources/ui/steps/uw.ui.Details.js
M resources/ui/steps/uw.ui.Tutorial.js
M resources/ui/steps/uw.ui.Upload.js
M resources/ui/uw.ui.Step.js
M resources/uploadWizard.css
14 files changed, 99 insertions(+), 16 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/UploadWizard 
refs/changes/24/314024/1

diff --git a/extension.json b/extension.json
index 3e1f13b..9367745 100644
--- a/extension.json
+++ b/extension.json
@@ -430,6 +430,7 @@
                                "mwe-upwiz-next-file",
                                "mwe-upwiz-next-deeds",
                                "mwe-upwiz-next-details",
+                               "mwe-upwiz-previous",
                                "mwe-upwiz-home",
                                "mwe-upwiz-upload-another",
                                "mwe-prevent-close",
diff --git a/i18n/en.json b/i18n/en.json
index 2c1af6c..6ec1894 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -180,6 +180,7 @@
        "mwe-upwiz-next-file": "Continue",
        "mwe-upwiz-next-deeds": "Next",
        "mwe-upwiz-next-details": "Next",
+       "mwe-upwiz-previous": "Back",
        "mwe-upwiz-home": "Go to wiki home page",
        "mwe-upwiz-upload-another": "Upload more files",
        "mwe-prevent-close": "Leaving this page may cause you to lose any 
changes you have made.",
diff --git a/i18n/qqq.json b/i18n/qqq.json
index 8c6f2c5..66cd83c 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -204,6 +204,7 @@
        "mwe-upwiz-next-file": "{{Identical|Continue}}",
        "mwe-upwiz-next-deeds": "{{Identical|Next}}",
        "mwe-upwiz-next-details": "{{Identical|Next}}",
+       "mwe-upwiz-previous": "{{Identical|Back}}",
        "mwe-upwiz-home": "[[file:commons-uw-L52S.png|The End of the 
\"{{MediaWiki:mwe-upwiz-step-thanks/en}}\" page|thumb|right]]\n\nThis is a 
button label, used at the end in the \"{{MediaWiki:mwe-upwiz-step-thanks/en}}\" 
page of the [[:mw:Extension:UploadWizard|MediaWiki Upload Wizard]].",
        "mwe-upwiz-upload-another": "[[file:commons-uw-L52S.png|The End of the 
\"{{MediaWiki:mwe-upwiz-step-thanks/en}}\" page|thumb|right]]\n\nThis is a 
button label, used at the end in the \"{{MediaWiki:mwe-upwiz-step-thanks/en}}\" 
page of the [[:mw:Extension:UploadWizard|MediaWiki Upload Wizard]].",
        "mwe-prevent-close": "Default message for a confirmation dialog used to 
prevent the user from closing the window accidentally.",
diff --git a/resources/controller/uw.controller.Deed.js 
b/resources/controller/uw.controller.Deed.js
index 877f8e9..5e48e57 100644
--- a/resources/controller/uw.controller.Deed.js
+++ b/resources/controller/uw.controller.Deed.js
@@ -37,14 +37,14 @@
 
        OO.inheritClass( uw.controller.Deed, uw.controller.Step );
 
-       uw.controller.Deed.prototype.moveFrom = function () {
+       uw.controller.Deed.prototype.moveNext = function () {
                var
                        deedController = this,
                        valid = true,
                        fields;
 
                if ( !this.deedChooser ) {
-                       uw.controller.Step.prototype.moveFrom.call( this );
+                       uw.controller.Step.prototype.moveNext.call( this );
                        return;
                }
 
@@ -69,7 +69,7 @@
                                        }
                                }
 
-                               uw.controller.Step.prototype.moveFrom.call( 
deedController );
+                               uw.controller.Step.prototype.moveNext.call( 
deedController );
                        } );
                }
        };
@@ -94,7 +94,7 @@
                // If all of the uploads are from URLs, then we know the 
licenses
                // already, we don't need this step.
                if ( !showDeed ) {
-                       this.moveFrom();
+                       this.moveNext();
                        return;
                }
 
diff --git a/resources/controller/uw.controller.Details.js 
b/resources/controller/uw.controller.Details.js
index 03f77c6..6ec57eb 100644
--- a/resources/controller/uw.controller.Details.js
+++ b/resources/controller/uw.controller.Details.js
@@ -338,7 +338,7 @@
                        details.showErrors();
 
                        if ( details.showNext() ) {
-                               details.moveFrom();
+                               details.moveNext();
                        }
                } );
        };
diff --git a/resources/controller/uw.controller.Step.js 
b/resources/controller/uw.controller.Step.js
index ce84ee5..787b51a 100644
--- a/resources/controller/uw.controller.Step.js
+++ b/resources/controller/uw.controller.Step.js
@@ -43,7 +43,11 @@
                this.ui = ui;
 
                this.ui.on( 'next-step', function () {
-                       step.moveFrom();
+                       step.moveNext();
+               } );
+
+               this.ui.on( 'previous-step', function () {
+                       step.movePrevious();
                } );
 
                /**
@@ -51,6 +55,12 @@
                 * The next step in the process.
                 */
                this.nextStep = null;
+
+               /**
+                * @property {uw.controller.Step} previousStep
+                * The previous step in the process.
+                */
+               this.previousStep = null;
        };
 
        OO.mixinClass( uw.controller.Step, OO.EventEmitter );
@@ -70,6 +80,16 @@
        uw.controller.Step.prototype.setNextStep = function ( step ) {
                this.nextStep = step;
                this.ui.enableNextButton();
+       };
+
+       /**
+        * Set the previous step in the process.
+        *
+        * @param {uw.controller.Step} step
+        */
+       uw.controller.Step.prototype.setPreviousStep = function ( step ) {
+               this.previousStep = step;
+               this.ui.enablePreviousButton();
        };
 
        /**
@@ -102,10 +122,10 @@
        };
 
        /**
-        * Move out of this step.
+        * Move to the next step.
         */
-       uw.controller.Step.prototype.moveFrom = function () {
-               this.ui.moveFrom( this.uploads );
+       uw.controller.Step.prototype.moveNext = function () {
+               this.ui.moveNext( this.uploads );
 
                this.movedFrom = true;
 
@@ -115,11 +135,24 @@
        };
 
        /**
+        * Move to the previous step.
+        */
+       uw.controller.Step.prototype.movePrevious = function () {
+               this.ui.movePrevious( this.uploads );
+
+               this.movedFrom = true;
+
+               if ( this.previousStep ) {
+                       this.previousStep.moveTo( this.uploads );
+               }
+       };
+
+       /**
         * Skip this step.
         */
        uw.controller.Step.prototype.skip = function () {
                uw.eventFlowLogger.logSkippedStep( this.stepName );
-               this.moveFrom();
+               this.moveNext();
        };
 
        /**
diff --git a/resources/controller/uw.controller.Tutorial.js 
b/resources/controller/uw.controller.Tutorial.js
index 25ae3e6..52d6b68 100644
--- a/resources/controller/uw.controller.Tutorial.js
+++ b/resources/controller/uw.controller.Tutorial.js
@@ -85,7 +85,7 @@
                }
        };
 
-       uw.controller.Tutorial.prototype.moveFrom = function () {
+       uw.controller.Tutorial.prototype.moveNext = function () {
                uw.eventFlowLogger.logTutorialAction( 'continue' );
 
                // if the skip checkbox is checked, set the skip user preference
@@ -93,7 +93,7 @@
                        this.setSkipPreference();
                }
 
-               uw.controller.Step.prototype.moveFrom.call( this );
+               uw.controller.Step.prototype.moveNext.call( this );
        };
 
        uw.controller.Tutorial.prototype.isComplete = function () {
diff --git a/resources/mw.UploadWizard.js b/resources/mw.UploadWizard.js
index 6bd8d26..c01b3a8 100644
--- a/resources/mw.UploadWizard.js
+++ b/resources/mw.UploadWizard.js
@@ -157,7 +157,7 @@
 
                                .on( 'finalize-details-after-removal', function 
() {
                                        wizard.removeErrorUploads();
-                                       wizard.steps.details.moveFrom();
+                                       wizard.steps.details.moveNext();
                                } );
 
                        this.steps.thanks = new uw.controller.Thanks( this.api, 
this.config )
@@ -179,9 +179,18 @@
                                        } );
                        } );
 
+                       if ( !this.config.tutorial.skip ) {
+                               this.steps.file.setPreviousStep( 
this.steps.tutorial );
+                       }
                        this.steps.file.setNextStep( this.steps.deeds );
+
+                       this.steps.deeds.setPreviousStep( this.steps.file );
                        this.steps.deeds.setNextStep( this.steps.details );
+
+                       this.steps.details.setPreviousStep( this.steps.deeds );
                        this.steps.details.setNextStep( this.steps.thanks );
+
+                       // thanks doesn't need a "previous" step, there's no 
undoing uploads!
                        this.steps.thanks.setNextStep( this.steps.file );
 
                        $( '#mwe-upwiz-steps' ).arrowSteps();
diff --git a/resources/ui/steps/uw.ui.Deed.js b/resources/ui/steps/uw.ui.Deed.js
index 808d64e..90f1d67 100644
--- a/resources/ui/steps/uw.ui.Deed.js
+++ b/resources/ui/steps/uw.ui.Deed.js
@@ -29,6 +29,7 @@
                        'deeds'
                );
 
+               this.addPreviousButton();
                this.addNextButton();
        };
 
diff --git a/resources/ui/steps/uw.ui.Details.js 
b/resources/ui/steps/uw.ui.Details.js
index 2e8602b..eac5d28 100644
--- a/resources/ui/steps/uw.ui.Details.js
+++ b/resources/ui/steps/uw.ui.Details.js
@@ -62,6 +62,7 @@
                        flags: [ 'progressive', 'primary' ]
                } ).on( 'click', startDetails );
 
+               this.addPreviousButton();
                this.addNextButton();
        };
 
diff --git a/resources/ui/steps/uw.ui.Tutorial.js 
b/resources/ui/steps/uw.ui.Tutorial.js
index 5e02cd8..8f9736c 100644
--- a/resources/ui/steps/uw.ui.Tutorial.js
+++ b/resources/ui/steps/uw.ui.Tutorial.js
@@ -88,6 +88,7 @@
                        ui.emit( 'helpdesk-click' );
                } );
 
+               this.addPreviousButton();
                this.addNextButton();
        };
 
diff --git a/resources/ui/steps/uw.ui.Upload.js 
b/resources/ui/steps/uw.ui.Upload.js
index 42e7428..daca2ef 100644
--- a/resources/ui/steps/uw.ui.Upload.js
+++ b/resources/ui/steps/uw.ui.Upload.js
@@ -125,6 +125,7 @@
                        .attr( 'id', 'mwe-upwiz-progress' )
                        .addClass( 'ui-helper-clearfix' );
 
+               this.addPreviousButton();
                this.addNextButton();
        };
 
diff --git a/resources/ui/uw.ui.Step.js b/resources/ui/uw.ui.Step.js
index a631987..e2b00df 100644
--- a/resources/ui/uw.ui.Step.js
+++ b/resources/ui/uw.ui.Step.js
@@ -46,9 +46,10 @@
 
                $( '#mwe-upwiz-steps' ).append( this.$arrow );
 
-               // this will make sure that button will only be added if it's 
been
+               // this will make sure that buttons will only be added if 
they've been
                // set in the controller, otherwise there's nowhere to go...
                this.nextButtonPromise = $.Deferred();
+               this.previousButtonPromise = $.Deferred();
        };
 
        OO.mixinClass( uw.ui.Step, OO.EventEmitter );
@@ -72,9 +73,16 @@
        };
 
        /**
-        * Move out of the step.
+        * Move to the next step.
         */
-       uw.ui.Step.prototype.moveFrom = function () {
+       uw.ui.Step.prototype.moveNext = function () {
+               this.$div.children().detach();
+       };
+
+       /**
+        * Move to the previous step.
+        */
+       uw.ui.Step.prototype.movePrevious = function () {
                this.$div.children().detach();
        };
 
@@ -85,6 +93,10 @@
 
        uw.ui.Step.prototype.enableNextButton = function () {
                this.nextButtonPromise.resolve();
+       };
+
+       uw.ui.Step.prototype.enablePreviousButton = function () {
+               this.previousButtonPromise.resolve();
        };
 
        /**
@@ -106,4 +118,22 @@
                } );
        };
 
+       /**
+        * Add a 'previous' button to the step's button container
+        */
+       uw.ui.Step.prototype.addPreviousButton = function () {
+               var ui = this;
+
+               this.previousButton = new OO.ui.ButtonWidget( {
+                       classes: [ 'mwe-upwiz-button-previous' ],
+                       label: mw.message( 'mwe-upwiz-previous' ).text(),
+                       flags: [ 'progressive', 'primary' ]
+               } ).on( 'click', function () {
+                       ui.emit( 'previous-step' );
+               } );
+
+               this.previousButtonPromise.done( function () {
+                       ui.$buttons.append( ui.previousButton.$element );
+               } );
+       };
 }( mediaWiki, jQuery, mediaWiki.uploadWizard, OO ) );
diff --git a/resources/uploadWizard.css b/resources/uploadWizard.css
index 897a2f2..fc9b13d 100644
--- a/resources/uploadWizard.css
+++ b/resources/uploadWizard.css
@@ -423,6 +423,10 @@
        text-align: right;
 }
 
+.mwe-upwiz-button-previous {
+       float: left;
+}
+
 a.mwe-upwiz-tooltip-link {
        cursor: pointer;
 }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib8931cdc6d7b2f9ab33536641aa822376ebf6b35
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/UploadWizard
Gerrit-Branch: master
Gerrit-Owner: Matthias Mullie <[email protected]>

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

Reply via email to