MarkTraceur has uploaded a new change for review.

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

Change subject: Move the rest of detailsSubmit to the controller
......................................................................

Move the rest of detailsSubmit to the controller

Bug: T90771
Change-Id: I936cf4c99c9020f3bfe553c884ade43625b20cfa
---
M resources/controller/uw.controller.Details.js
M resources/controller/uw.controller.Step.js
M resources/mw.UploadWizard.js
M resources/ui/uw.ui.Step.js
4 files changed, 14 insertions(+), 25 deletions(-)


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

diff --git a/resources/controller/uw.controller.Details.js 
b/resources/controller/uw.controller.Details.js
index 1b75bfc..a888ee6 100644
--- a/resources/controller/uw.controller.Details.js
+++ b/resources/controller/uw.controller.Details.js
@@ -198,9 +198,11 @@
 
        /**
         * Submit details to the API.
-        * @TODO move the actual submission here - need to fiddle with 
makeTransitioner first
+        * @returns {jQuery.Promise}
         */
        DP.submit = function () {
+               var details = this;
+
                $.each( this.uploads, function ( i, upload ) {
                        // Skip empty uploads
                        if ( upload === undefined ) {
@@ -221,6 +223,11 @@
 
                // Hide errors (maybe this submission fixes them)
                this.ui.hideErrors();
+
+               return this.transitionAll().then( function () {
+                       details.showErrors();
+                       details.emit( 'details-submitted' );
+               } );
        };
 
        /**
diff --git a/resources/controller/uw.controller.Step.js 
b/resources/controller/uw.controller.Step.js
index 1ea5840..eed11a2 100644
--- a/resources/controller/uw.controller.Step.js
+++ b/resources/controller/uw.controller.Step.js
@@ -60,7 +60,7 @@
         */
        SP.moveTo = function ( uploads ) {
                this.uploads = uploads;
-               this.ui.moveTo();
+               this.ui.moveTo( uploads );
        };
 
        /**
diff --git a/resources/mw.UploadWizard.js b/resources/mw.UploadWizard.js
index 0037954..3ae392d 100644
--- a/resources/mw.UploadWizard.js
+++ b/resources/mw.UploadWizard.js
@@ -76,11 +76,8 @@
                                } ),
 
                        details: new uw.controller.Details( config )
-                               .on( 'start-details', function () {
-                                       wizard.detailsSubmit().done( function 
() {
-                                               
wizard.steps.details.showErrors();
-                                               wizard.showNext( 'details', 
'complete', finalizeDetails );
-                                       } );
+                               .on( 'details-submitted', function () {
+                                       wizard.showNext( 'details', 'complete', 
finalizeDetails );
                                } )
 
                                .on( 'details-error', function () {
@@ -652,23 +649,6 @@
                                }
                        } );
                        return count;
-               },
-
-               /**
-                * Submit all edited details and other metadata
-                * Works just like startUploads -- parallel simultaneous 
submits with progress bar.
-                * @return {jQuery.Promise}
-                */
-               detailsSubmit: function () {
-                       var deferred = $.Deferred();
-
-                       // add the upload progress bar, with ETA
-                       // add in the upload count
-                       this.steps.details.transitionAll().done( function () {
-                               deferred.resolve();
-                       } );
-
-                       return deferred.promise();
                }
        };
 
diff --git a/resources/ui/uw.ui.Step.js b/resources/ui/uw.ui.Step.js
index 93eda3a..99cf30a 100644
--- a/resources/ui/uw.ui.Step.js
+++ b/resources/ui/uw.ui.Step.js
@@ -39,8 +39,10 @@
 
        /**
         * Move to the step.
+        * @param {mw.UploadWizardUpload[]} uploads
         */
-       SP.moveTo = function () {
+       SP.moveTo = function ( uploads ) {
+               this.uploads = uploads;
                // Remove the initial spinner if it's still present
                $( '#mwe-first-spinner' ).remove();
                this.$div.show();

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

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

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

Reply via email to