jenkins-bot has submitted this change and it was merged. Change subject: Move parts of detailsSubmit to details step ......................................................................
Move parts of detailsSubmit to details step Bug: T90771 Change-Id: I67d65724ed0d8535a656087f26221ea71c06f203 --- M resources/controller/uw.controller.Details.js M resources/mw.UploadWizard.js M resources/mw.UploadWizardDetails.js M resources/ui/uw.ui.Details.js 4 files changed, 73 insertions(+), 43 deletions(-) Approvals: Gilles: Looks good to me, approved jenkins-bot: Verified diff --git a/resources/controller/uw.controller.Details.js b/resources/controller/uw.controller.Details.js index f4aeba4..dc8a8f7 100644 --- a/resources/controller/uw.controller.Details.js +++ b/resources/controller/uw.controller.Details.js @@ -93,6 +93,7 @@ this.valid().done( function () { details.ui.hideEndButtons(); + details.submit(); details.emit( 'start-details' ); } ).fail( function () { details.emit( 'details-error' ); @@ -195,5 +196,32 @@ upload.details.submit(); }; + /** + * Submit details to the API. + * @TODO move the actual submission here - need to fiddle with makeTransitioner first + */ + DP.submit = function () { + $.each( this.uploads, function ( i, upload ) { + // Skip empty uploads + if ( upload === undefined ) { + return; + } + + // Clear error state + if ( upload.state === 'error' ) { + upload.state = 'details'; + } + + // Set details view to have correct title + upload.details.setVisibleTitle( upload.title.getMain() ); + } ); + + // Disable edit interface + this.ui.disableEdits(); + + // Hide errors (maybe this submission fixes them) + this.ui.hideErrors(); + }; + uw.controller.Details = Details; }( mediaWiki.uploadWizard, jQuery, OO ) ); diff --git a/resources/mw.UploadWizard.js b/resources/mw.UploadWizard.js index c94214d..eb93da7 100644 --- a/resources/mw.UploadWizard.js +++ b/resources/mw.UploadWizard.js @@ -53,13 +53,13 @@ } ) .on( 'next-step', function () { - wizard.removeErrorUploads( function () { - if ( wizard.showDeed ) { - wizard.moveToStep( 'deeds' ); - } else { - wizard.moveToStep( 'details' ); - } - } ); + wizard.removeErrorUploads(); + + if ( wizard.showDeed ) { + wizard.moveToStep( 'deeds' ); + } else { + wizard.moveToStep( 'details' ); + } } ) .on( 'reset', function () { @@ -77,7 +77,7 @@ details: new uw.controller.Details( config ) .on( 'start-details', function () { - wizard.detailsSubmit( function () { + wizard.detailsSubmit().done( function () { wizard.detailsErrorCount(); wizard.showNext( 'details', 'complete', finalizeDetails ); } ); @@ -88,7 +88,8 @@ } ) .on( 'finalize-details-after-removal', function () { - wizard.removeErrorUploads( finalizeDetails ); + wizard.removeErrorUploads(); + finalizeDetails(); } ) .on( 'no-uploads', function () { @@ -486,13 +487,11 @@ /** * Clear out uploads that are in error mode, perhaps before proceeding to the next step - * @param {Function} to be called when done */ - removeErrorUploads: function ( endCallback ) { + removeErrorUploads: function () { this.removeMatchingUploads( function ( upload ) { return upload.state === 'error'; } ); - endCallback(); }, /** @@ -658,43 +657,18 @@ /** * Submit all edited details and other metadata * Works just like startUploads -- parallel simultaneous submits with progress bar. - * @param {Function} endCallback - called when all uploads complete. In our case is probably a move to the next step + * @return {jQuery.Promise} */ - detailsSubmit: function ( endCallback ) { - $.each( this.uploads, function ( i, upload ) { - if ( upload === undefined ) { - return; - } - // clear out error states, so we don't end up in an infinite loop - if ( upload.state === 'error' ) { - upload.state = 'details'; - } - - // set the "minimized" view of the details to have the right title - $( upload.details.submittingDiv ) - .find( '.mwe-upwiz-visible-file-filename-text' ) - .html( upload.title.getMain() ); - } ); - - // remove ability to edit details - $( '#mwe-upwiz-stepdiv-details' ) - .find( '.mwe-upwiz-data' ) - .morphCrossfade( '.mwe-upwiz-submitting' ); - - // hide errors ( assuming maybe this submission will fix it, if it hadn't blocked ) - $( '#mwe-upwiz-stepdiv-details' ) - .find( 'label.mwe-error' ) - .hide().empty(); - - $( '#mwe-upwiz-stepdiv-details' ) - .find( 'input.mwe-error' ) - .removeClass( 'mwe-error' ); + detailsSubmit: function () { + var deferred = $.Deferred(); // add the upload progress bar, with ETA // add in the upload count this.steps.details.transitionAll().done( function () { - endCallback(); + deferred.resolve(); } ); + + return deferred.promise(); }, /** diff --git a/resources/mw.UploadWizardDetails.js b/resources/mw.UploadWizardDetails.js index 950618f..2355376 100644 --- a/resources/mw.UploadWizardDetails.js +++ b/resources/mw.UploadWizardDetails.js @@ -1761,6 +1761,12 @@ this.upload.title = mw.UploadWizardDetails.makeTitleInFileNS( cleaned + '.' + ext ) || this.upload.title; return this.upload.title; + }, + + setVisibleTitle: function ( s ) { + $( this.submittingDiv ) + .find( '.mwe-upwiz-visible-file-filename-text' ) + .text( s ); } }; diff --git a/resources/ui/uw.ui.Details.js b/resources/ui/uw.ui.Details.js index eae634e..61bb44c 100644 --- a/resources/ui/uw.ui.Details.js +++ b/resources/ui/uw.ui.Details.js @@ -98,5 +98,27 @@ .hide(); }; + /** + * Disable edits to the details. + */ + DP.disableEdits = function () { + this.$div + .find( '.mwe-upwiz-data' ) + .morphCrossfade( '.mwe-upwiz-submitting' ); + }; + + /** + * Hide validation errors. + */ + DP.hideErrors = function () { + this.$div + .find( 'label.mwe-error' ) + .hide().empty(); + + this.$div + .find( 'input.mwe-error' ) + .removeClass( 'mwe-error' ); + }; + ui.Details = Details; }( mediaWiki, jQuery, mediaWiki.uploadWizard.ui, OO ) ); -- To view, visit https://gerrit.wikimedia.org/r/192873 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I67d65724ed0d8535a656087f26221ea71c06f203 Gerrit-PatchSet: 5 Gerrit-Project: mediawiki/extensions/UploadWizard Gerrit-Branch: master Gerrit-Owner: MarkTraceur <mtrac...@member.fsf.org> Gerrit-Reviewer: Gilles <gdu...@wikimedia.org> Gerrit-Reviewer: MarkTraceur <mtrac...@member.fsf.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits