jenkins-bot has submitted this change and it was merged. Change subject: Add a way to make categories more require-looking ......................................................................
Add a way to make categories more require-looking Bug: 49710 Change-Id: I72ed4a357d09d7ba5b1ebf5cb6e19f580f4860ea --- M UploadWizard.i18n.php M UploadWizardHooks.php M resources/mw.UploadWizard.js M resources/mw.UploadWizardDetails.js 4 files changed, 59 insertions(+), 4 deletions(-) Approvals: MarkTraceur: Looks good to me, approved jenkins-bot: Verified diff --git a/UploadWizard.i18n.php b/UploadWizard.i18n.php index 7744a18..dcfc348 100644 --- a/UploadWizard.i18n.php +++ b/UploadWizard.i18n.php @@ -246,6 +246,10 @@ 'mwe-upwiz-file-too-large-ok' => 'OK', '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-necessary-confirm' => 'It is recommended that you fill in a category for your uploads. Do you want to continue without filling all the fields?', + 'mwe-upwiz-dialog-yes' => 'Yes', + 'mwe-upwiz-dialog-no' => 'No', + 'mwe-upwiz-dialog-title' => 'Warning', /* LICENSES & combinations of licenses */ /* may be a good idea to shift to WikimediaLicenseTexts? */ @@ -759,6 +763,10 @@ * $1 is the maximum file size; * $2 is the size of the file they tried to upload.', 'mwe-upwiz-file-too-large' => 'Error dialog title', + 'mwe-upwiz-necessary-confirm' => 'Confirmation box suggesting that it is recommended to fill in a category for uploads and asking the uploader whether they want to continue without them', + 'mwe-upwiz-dialog-yes' => 'Yes', + 'mwe-upwiz-dialog-no' => 'No', + 'mwe-upwiz-dialog-title' => 'Warning', 'mwe-upwiz-license-cc-by-sa-3.0' => '{{CreativeCommonsLicense|by-sa|3.0}} For more information, see https://www.mediawiki.org/wiki/UploadWizard', 'mwe-upwiz-license-cc-by-sa-3.0-at' => '{{CreativeCommonsLicense|by-sa|3.0|at}} diff --git a/UploadWizardHooks.php b/UploadWizardHooks.php index 7dc6fbf..f3c4a5f 100644 --- a/UploadWizardHooks.php +++ b/UploadWizardHooks.php @@ -450,6 +450,10 @@ 'mwe-upwiz-file-too-large-ok', 'mwe-upwiz-file-too-large-text', 'mwe-upwiz-file-too-large', + 'mwe-upwiz-necessary-confirm', + 'mwe-upwiz-dialog-yes', + 'mwe-upwiz-dialog-no', + 'mwe-upwiz-dialog-title', 'prefs-uploads', 'prefs-upwiz-interface', 'colon-separator', diff --git a/resources/mw.UploadWizard.js b/resources/mw.UploadWizard.js index 1c7a638..f0a3144 100644 --- a/resources/mw.UploadWizard.js +++ b/resources/mw.UploadWizard.js @@ -1038,9 +1038,10 @@ * @return boolean */ detailsValid: function(cb, cberr) { - var _this = this; - var valid = 0; - var total = 0; + var _this = this, + valid = 0, + necessary = 0, + total = 0; $j.each( _this.uploads, function(i, upload) { if ( upload === undefined ) { return; @@ -1049,9 +1050,39 @@ upload.details.valid( function () { valid += 1; }); + upload.details.necessaryFilled( function () { + necessary += 1; + }); }); - if ( valid == total ) { + + // Set up buttons for dialog box. We have to do it the hard way since the json keys are localized + var buttons = {}; + buttons[ mw.msg( 'mwe-upwiz-dialog-yes' ) ] = function() { + $( this ).dialog( "close" ); cb(); + }; + buttons[ mw.msg( 'mwe-upwiz-dialog-no' ) ] = function() { + $( this ).dialog( "close" ); + }; + var confirmationDialog = $j( '<div></div>' ) + .html( mw.msg( 'mwe-upwiz-necessary-confirm' ) ) + .dialog( { + width: 500, + zIndex: 200000, + autoOpen: false, + modal: true, + buttons: buttons, + title: mw.msg( 'mwe-upwiz-dialog-title' ), + open: function () { + $( this ).siblings( '.ui-dialog-buttonpane' ).find( 'button:eq(1)' ).focus(); + } + } ); + if ( valid === total ) { + if ( necessary === total ) { + cb(); + } else { + confirmationDialog.dialog( 'open' ); + } } else { cberr(); } diff --git a/resources/mw.UploadWizardDetails.js b/resources/mw.UploadWizardDetails.js index b796c00..c7b0fac 100644 --- a/resources/mw.UploadWizardDetails.js +++ b/resources/mw.UploadWizardDetails.js @@ -672,6 +672,18 @@ } }, + /** + * check if we have all the *must have* but not mandatory fields filled in + * Currently this tests for the following: + * 1) Empty category + * 2) TODO + */ + necessaryFilled: function( cb ) { + // check for empty category input + if ( this.div.find( '.categoryInput' ).val() !== '' ) { + cb(); + } + }, /** * toggles whether we use the 'macro' deed or our own -- To view, visit https://gerrit.wikimedia.org/r/69284 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I72ed4a357d09d7ba5b1ebf5cb6e19f580f4860ea Gerrit-PatchSet: 2 Gerrit-Project: mediawiki/extensions/UploadWizard Gerrit-Branch: master Gerrit-Owner: Nischayn22 <nischay...@gmail.com> Gerrit-Reviewer: MarkTraceur <mtrac...@member.fsf.org> Gerrit-Reviewer: Siebrand <siebr...@wikimedia.org> Gerrit-Reviewer: jenkins-bot _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits