r87764 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r87763‎ | r87764 | r87765 >
Date:20:14, 9 May 2011
Author:neilk
Status:ok (Comments)
Tags:
Comment:
count the errors and show them next to the submit button (this helps when the errors are scrolled off page)
Modified paths:
  • /trunk/extensions/UploadWizard/resources/mw.UploadWizard.js (modified) (history)

Diff [purge]

Index: trunk/extensions/UploadWizard/resources/mw.UploadWizard.js
@@ -784,8 +784,11 @@
785785 if ( _this.detailsValid() ) {
786786 _this.hideDetailsEndButtons();
787787 _this.detailsSubmit( function() {
 788+ _this.detailsErrorCount();
788789 _this.showNext( 'details', 'complete', finalizeDetails );
789790 } );
 791+ } else {
 792+ _this.detailsErrorCount();
790793 }
791794 };
792795
@@ -1321,6 +1324,25 @@
13221325 );
13231326 },
13241327
 1328+ /**
 1329+ * The details page can be vertically long so sometimes it is not obvious there are errors above. This counts them and puts the count
 1330+ * right next to the submit button, so it should be obvious to the user they need to fix things.
 1331+ * This is a bit of a hack. The validator library actually already has a way to count errors but some errors are generated
 1332+ * outside of that library. So we are going to just look for any visible inputs in an error state.
 1333+ */
 1334+ detailsErrorCount: function() {
 1335+ var errorCount =
 1336+ $( '#mwe-upwiz-stepdiv-details' ).find( 'input.mwe-error' ).length
 1337+ + $( '#mwe-upwiz-stepdiv-details' ).find( 'textarea.mwe-error' ).length
 1338+ + $( '#mwe-upwiz-stepdiv-details' ).find( 'input.mwe-validator-error' ).length
 1339+ + $( '#mwe-upwiz-stepdiv-details' ).find( 'textarea.mwe-validator-error' ).length;
 1340+ if ( errorCount > 0 ) {
 1341+ $( '#mwe-upwiz-details-error-count' ).msg( 'mwe-upwiz-details-error-count', errorCount, this.uploads.length );
 1342+ } else {
 1343+ $( '#mwe-upwiz-details-error-count' ).empty();
 1344+ }
 1345+ },
 1346+
13251347 prefillThanksPage: function() {
13261348 var _this = this;
13271349

Follow-up revisions

RevisionCommit summaryAuthorDate
r87771followup to r87764; use simpler jquery selectorneilk20:53, 9 May 2011

Comments

#Comment by Brion VIBBER (talk | contribs)   20:44, 9 May 2011

fyi -- should be able to do this in one lookup like:

$( '#mwe-upwiz-stepdiv-details' ).find( 'input.mwe-error, textarea.mwe-error, input.mwe-validator-error, textarea.mwe-validator-error' ).length

However... if one field has both .mwe-error and .mwe-validator-error on it, then this will also avoid duplicating them, counting the field only once instead of twice. If it should be counted twice, then leave as is -- if they're mutually exclusive than it doesn't matter, use whichever is more convenient.

#Comment by NeilK (talk | contribs)   21:08, 9 May 2011

fixed in r87771

Status & tagging log