Matthias Mullie has uploaded a new change for review.

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

Change subject: Display warnings in confirmation window
......................................................................

Display warnings in confirmation window

These can be confusing. Categories, for example, is a
non-required field, but will yield a warning when trying
to submit empty. Up until the point the form is submitted,
a warning that it should be filled out has never been
displayed, and that confirmation window will be confusing.

All this does is also show a list of the warnings in the
confirmation window, which hopefully helps with the confusion.

Bug: T146155
Change-Id: Ibe7d22b68da0a1db0aa8672229e1f127de359907
---
M i18n/en.json
M resources/controller/uw.controller.Details.js
2 files changed, 26 insertions(+), 11 deletions(-)


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

diff --git a/i18n/en.json b/i18n/en.json
index 06cacad..ecae51a 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -233,7 +233,7 @@
        "mwe-upwiz-too-many-files": "Too many files.",
        "mwe-upwiz-file-too-large-text": "You can only upload files with a size 
of up to $1. You tried to upload a file that is $2.",
        "mwe-upwiz-file-too-large": "File too large.",
-       "mwe-upwiz-dialog-warning": "We recommend that you properly fill in all 
the fields. Do you want to continue without correcting warnings?",
+       "mwe-upwiz-dialog-warning": "We recommend that you properly fill in all 
the fields. Do you want to continue without correcting these warnings?",
        "mwe-upwiz-dialog-yes": "Yes",
        "mwe-upwiz-dialog-no": "No",
        "mwe-upwiz-dialog-title": "Warning",
diff --git a/resources/controller/uw.controller.Details.js 
b/resources/controller/uw.controller.Details.js
index 3f962d6..63da6e6 100644
--- a/resources/controller/uw.controller.Details.js
+++ b/resources/controller/uw.controller.Details.js
@@ -134,12 +134,16 @@
                        upload.details.checkValidity();
 
                        warningValidityPromises.push( 
upload.details.getWarnings().then( function () {
-                               var i;
-                               for ( i = 0; i < arguments.length; i++ ) {
-                                       if ( arguments[ i ].length ) {
-                                               // One of the DetailsWidgets 
has warnings
-                                               return $.Deferred().reject();
-                                       }
+                               // iterate all arguments (which is an array of 
arrays of
+                               // warnings) and turn it into a one-dimensional 
warnings array
+                               var args = Array.prototype.slice.call( 
arguments ),
+                                       warnings = args.reduce( function( 
result, warnings ) {
+                                       return result.concat( warnings );
+                               }, [] );
+
+                               if ( warnings.length ) {
+                                       // One of the DetailsWidgets has 
warnings
+                                       return $.Deferred().reject( warnings );
                                }
                        } ) );
 
@@ -180,10 +184,10 @@
                                                return $.Deferred().resolve( 
true );
                                        },
                                        // Valid, but with warnings, ask for 
confirmation
-                                       function () {
+                                       function ( warnings ) {
                                                // Update warning count before 
dialog
                                                detailsController.showErrors();
-                                               return 
detailsController.confirmationDialog();
+                                               return 
detailsController.confirmationDialog( warnings );
                                        }
                                );
                        },
@@ -193,8 +197,19 @@
                );
        };
 
-       uw.controller.Details.prototype.confirmationDialog = function () {
-               return OO.ui.confirm( mw.message( 'mwe-upwiz-dialog-warning' 
).text(), {
+       uw.controller.Details.prototype.confirmationDialog = function ( 
warnings ) {
+               var i,
+                       message = '<p>' + mw.message( 
'mwe-upwiz-dialog-warning' ).text() + '</p>';
+
+               if ( warnings.length ) {
+                       message += '<ul>';
+                       for ( i = 0; i < warnings.length; i++ ) {
+                               message += '<li>' + warnings[ i ].text() + 
'</li>';
+                       }
+                       message += '</ul>';
+               }
+
+               return OO.ui.confirm( $( message ), {
                        title: mw.message( 'mwe-upwiz-dialog-title' ).text()
                } );
        };

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ibe7d22b68da0a1db0aa8672229e1f127de359907
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/UploadWizard
Gerrit-Branch: master
Gerrit-Owner: Matthias Mullie <mmul...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to