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

Change subject: Move some upload step UI stuff out of ui.Wizard
......................................................................


Move some upload step UI stuff out of ui.Wizard

Bug: T78057
Change-Id: I5135b7dbbd7791a6e24b2aeb69cfb339f1cdb280
---
M resources/controller/uw.controller.Upload.js
M resources/mw.UploadWizard.js
M resources/ui/uw.ui.Upload.js
M resources/ui/uw.ui.Wizard.js
4 files changed, 59 insertions(+), 74 deletions(-)

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



diff --git a/resources/controller/uw.controller.Upload.js 
b/resources/controller/uw.controller.Upload.js
index 0cc6870..31c0463 100644
--- a/resources/controller/uw.controller.Upload.js
+++ b/resources/controller/uw.controller.Upload.js
@@ -22,6 +22,11 @@
                uw.controller.Step.call(
                        this,
                        new uw.ui.Upload()
+                               .connect( this, {
+                                       retry: [ 'emit', 'retry' ],
+                                       'next-step': [ 'emit', 'next-step' ],
+                                       'flickr-ui-init': [ 'emit', 
'flickr-ui-init' ]
+                               } )
                );
        }
 
diff --git a/resources/mw.UploadWizard.js b/resources/mw.UploadWizard.js
index 6f43a23..b7a5799 100644
--- a/resources/mw.UploadWizard.js
+++ b/resources/mw.UploadWizard.js
@@ -40,7 +40,27 @@
                                .on( 'next-step', function () {
                                        wizard.moveToStep( 'file' );
                                } ),
-                       file: new uw.controller.Upload(),
+                       file: new uw.controller.Upload()
+                               .on( 'retry', function () {
+                                       uw.eventFlowLogger.logEvent( 
'retry-uploads-button-clicked' );
+                                       wizard.startUploads();
+                               } )
+
+                               .on( 'flickr-ui-init', function () {
+                                       wizard.flickrInterfaceInit();
+                                       uw.eventFlowLogger.logEvent( 
'flickr-upload-button-clicked' );
+                               } )
+
+                               .on( 'next-step', function () {
+                                       wizard.removeErrorUploads( function () {
+                                               if ( wizard.showDeed ) {
+                                                       
wizard.prepareAndMoveToDeeds();
+                                               } else {
+                                                       wizard.moveToStep( 
'details' );
+                                               }
+                                       } );
+                               } ),
+
                        deeds: new uw.controller.Deed(),
 
                        details: new uw.controller.Details()
@@ -103,45 +123,6 @@
                        this.ui = new uw.ui.Wizard( this )
                                .on( 'reset-wizard', function () {
                                        wizard.reset();
-                               } )
-
-                               .on( 'upload-start', function () {
-                                       // check if there is an upload at all 
(should never happen)
-                                       if ( wizard.uploads.length === 0 ) {
-                                               $( '<div>' )
-                                                       .text( mw.message( 
'mwe-upwiz-file-need-file' ).text() )
-                                                       .dialog( {
-                                                               width: 500,
-                                                               zIndex: 200000,
-                                                               autoOpen: true,
-                                                               modal: true
-                                                       } );
-                                               return;
-                                       }
-
-                                       wizard.removeEmptyUploads();
-                                       wizard.startUploads();
-                               } )
-
-                               .on( 'flickr-ui-init', function () {
-                                       wizard.flickrInterfaceInit();
-                                       uw.eventFlowLogger.logEvent( 
'flickr-upload-button-clicked' );
-                               } )
-
-                               .on( 'retry-uploads', function () {
-                                       uw.eventFlowLogger.logEvent( 
'retry-uploads-button-clicked' );
-                                       wizard.ui.hideFileEndButtons();
-                                       wizard.startUploads();
-                               } )
-
-                               .on( 'next-from-upload', function () {
-                                       wizard.removeErrorUploads( function () {
-                                               if ( wizard.showDeed ) {
-                                                       
wizard.prepareAndMoveToDeeds();
-                                               } else {
-                                                       wizard.moveToStep( 
'details' );
-                                               }
-                                       } );
                                } )
 
                                .on( 'next-from-deeds', function () {
@@ -701,7 +682,7 @@
                        var wizard = this;
                        // remove the upload button, and the add file button
                        $( '#mwe-upwiz-upload-ctrls' ).hide();
-                       this.ui.hideFileEndButtons();
+                       this.steps.file.ui.hideEndButtons();
                        $( '#mwe-upwiz-add-file' ).hide();
 
                        // reset any uploads in error state back to be shiny & 
new
@@ -843,7 +824,7 @@
                        }
 
                        // First reset the wizard buttons.
-                       this.ui.hideFileEndButtons();
+                       this.steps.file.ui.hideEndButtons();
 
                        this.currentStepObject.updateFileCounts( ( 
this.uploads.length - this.countEmpties() ) > 0, this.maxUploads, this.uploads 
);
 
diff --git a/resources/ui/uw.ui.Upload.js b/resources/ui/uw.ui.Upload.js
index bbf3492..78ed47b 100644
--- a/resources/ui/uw.ui.Upload.js
+++ b/resources/ui/uw.ui.Upload.js
@@ -25,6 +25,8 @@
         * @constructor
         */
        function Upload() {
+               var upload = this;
+
                ui.Step.call(
                        this,
                        $( '#mwe-upwiz-stepdiv-file' ),
@@ -36,15 +38,33 @@
                this.$uploadCenterDivide = $( '#mwe-upwiz-upload-ctr-divide' );
                this.$uploadStepButtons = $( '#mwe-upwiz-stepdiv-file 
.mwe-upwiz-buttons' );
 
-               this.$addFile = $( '#mwe-upwiz-add-file' );
+               this.$addFile = $( '#mwe-upwiz-add-file' )
+                       .button();
                this.$addFileContainer = $( '#mwe-upwiz-add-file-container' );
 
-               this.$flickrAddFile = $( '#mwe-upwiz-upload-ctrl-flickr' );
+               this.$flickrAddFile = $( '#mwe-upwiz-upload-ctrl-flickr' )
+                       .button()
+                       .click( function () {
+                               upload.emit( 'flickr-ui-init' );
+                       } );
                this.$flickrAddFileContainer = $( 
'#mwe-upwiz-upload-ctrl-flickr-container' );
 
                this.$flickrSelect = $( '#mwe-upwiz-select-flickr' );
                this.$flickrSelectList = $( '#mwe-upwiz-flickr-select-list' );
                this.$flickrSelectListContainer = $( 
'#mwe-upwiz-flickr-select-list-container' );
+
+               this.$nextStepButton = this.$div
+                       .find( '.mwe-upwiz-buttons .mwe-upwiz-button-next' )
+                       .click( function () {
+                               upload.emit( 'next-step' );
+                       } );
+
+               this.$retryButton = this.$div
+                       .find( '.mwe-upwiz-buttons .mwe-upwiz-button-retry' )
+                       .click( function () {
+                               upload.hideEndButtons();
+                               upload.emit( 'retry' );
+                       } );
 
                this.$fileList = $( '#mwe-upwiz-filelist' );
 
@@ -161,5 +181,14 @@
                this.$fileList.removeClass( 'mwe-upwiz-filled-filelist' );
        };
 
+       /**
+        * Hide the buttons for moving to the next step.
+        */
+       UP.hideEndButtons = function () {
+               this.$div
+                       .find( '.mwe-upwiz-buttons .mwe-upwiz-file-endchoice' )
+                       .hide();
+       };
+
        ui.Upload = Upload;
 }( mediaWiki, jQuery, mediaWiki.uploadWizard.ui, OO ) );
diff --git a/resources/ui/uw.ui.Wizard.js b/resources/ui/uw.ui.Wizard.js
index 4d43fad..cf22f08 100644
--- a/resources/ui/uw.ui.Wizard.js
+++ b/resources/ui/uw.ui.Wizard.js
@@ -38,7 +38,6 @@
                this.initButtons();
 
                this.initTutorial();
-               this.initUpload();
                this.initDeeds();
        }
 
@@ -213,28 +212,6 @@
        };
 
        /**
-        * Initialize the upload step interface.
-        */
-       UWIP.initUpload = function () {
-               var ui = this;
-
-               $( '#mwe-upwiz-add-file, #mwe-upwiz-upload-ctrl-flickr' 
).button();
-
-               // Call Flickr Initiator function on click event
-               $( '#mwe-upwiz-upload-ctrl-flickr' ).click( function () {
-                       ui.emit( 'flickr-ui-init' );
-               } );
-
-               $( '#mwe-upwiz-stepdiv-file .mwe-upwiz-buttons 
.mwe-upwiz-button-next' ).click( function () {
-                       ui.emit( 'next-from-upload' );
-               } );
-
-               $( '#mwe-upwiz-stepdiv-file .mwe-upwiz-buttons 
.mwe-upwiz-button-retry' ).click( function () {
-                       ui.emit( 'retry-uploads' );
-               } );
-       };
-
-       /**
         * Initializes the deed step interface.
         */
        UWIP.initDeeds = function () {
@@ -248,13 +225,6 @@
 
                        ui.emit( 'next-from-deeds' );
                } );
-       };
-
-       /**
-        * Hide the button choices at the end of the file step.
-        */
-       UWIP.hideFileEndButtons = function () {
-               $( '#mwe-upwiz-stepdiv-file .mwe-upwiz-buttons 
.mwe-upwiz-file-endchoice' ).hide();
        };
 
        ui.Wizard = UploadWizardInterface;

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I5135b7dbbd7791a6e24b2aeb69cfb339f1cdb280
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/extensions/UploadWizard
Gerrit-Branch: master
Gerrit-Owner: MarkTraceur <[email protected]>
Gerrit-Reviewer: Gilles <[email protected]>
Gerrit-Reviewer: MarkTraceur <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to