MarkTraceur has uploaded a new change for review.
https://gerrit.wikimedia.org/r/192873
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/ui/uw.ui.Details.js
3 files changed, 60 insertions(+), 31 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/UploadWizard
refs/changes/73/192873/1
diff --git a/resources/controller/uw.controller.Details.js
b/resources/controller/uw.controller.Details.js
index 5d76b57..b225f0b 100644
--- a/resources/controller/uw.controller.Details.js
+++ b/resources/controller/uw.controller.Details.js
@@ -92,6 +92,7 @@
this.valid().done( function () {
details.ui.hideEndButtons();
+ details.submit();
details.emit( 'start-details' );
} ).fail( function () {
details.emit( 'details-error' );
@@ -170,5 +171,34 @@
}
};
+ /**
+ * 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.submittingDiv )
+ .find( '.mwe-upwiz-visible-file-filename-text' )
+ .html( 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 b35c04b..47b42dd 100644
--- a/resources/mw.UploadWizard.js
+++ b/resources/mw.UploadWizard.js
@@ -68,7 +68,7 @@
details: new uw.controller.Details()
.on( 'start-details', function () {
- wizard.detailsSubmit( function () {
+ wizard.detailsSubmit().done( function
() {
wizard.detailsErrorCount();
wizard.showNext( 'details',
'complete', finalizeDetails );
} );
@@ -719,37 +719,10 @@
/**
* 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' );
+ var deferred = $.Deferred();
// add the upload progress bar, with ETA
// add in the upload count
@@ -760,8 +733,12 @@
function ( upload ) {
upload.details.submit();
},
- endCallback /* called when all uploads are in a
valid end state */
+ function () {
+ deferred.resolve.apply( deferred,
arguments );
+ }
);
+
+ return deferred.promise();
},
/**
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: newchange
Gerrit-Change-Id: I67d65724ed0d8535a656087f26221ea71c06f203
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