Bartosz Dziewoński has uploaded a new change for review.

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

Change subject: Split off uw.CategoriesDetailsWidget from UploadWizardDetails 
(improve warnings)
......................................................................

Split off uw.CategoriesDetailsWidget from UploadWizardDetails (improve warnings)

This change converts the category fields to use uw.FieldLayout and
uw.DetailsWidget rather than custom code. As this field was already using
OOjs UI, there should be no user-visible changes.

It also generalizes the warning about submitting uploads with no
categories to use the warning system from uw.DetailsWidget.
* uw.controller.Details now knows about the warnings and displays the
  confirmation dialogs if there are any, rather than hardcoding the
  category check.
* Some code has been moved to UploadWizardDetails so that the controller
  doesn't have to know about individual fields anymore.

The warning message in the form is temporarily hidden with CSS, though,
to avoid changing the behavior in only some parts of the form until we
change other things to use similar warnings. I filed T117117 and T117119
to track this work.

Bug: T96917
Change-Id: Iee797ce14e2457759e40e08dcf16746e7041384c
---
M UploadWizardHooks.php
M i18n/en.json
M i18n/qqq.json
M resources/controller/uw.controller.Details.js
A resources/details/uw.CategoriesDetailsWidget.js
A resources/details/uw.CategoriesDetailsWidget.less
M resources/mw.UploadWizardDetails.js
7 files changed, 235 insertions(+), 134 deletions(-)


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

diff --git a/UploadWizardHooks.php b/UploadWizardHooks.php
index 5b02dc9..058a125 100644
--- a/UploadWizardHooks.php
+++ b/UploadWizardHooks.php
@@ -71,6 +71,7 @@
                                'resources/uw.DetailsWidget.js',
                                'resources/uw.FieldLayout.js',
                                'resources/details/uw.DateDetailsWidget.js',
+                               
'resources/details/uw.CategoriesDetailsWidget.js',
 
                                // common utilities
                                'resources/mw.fileApi.js',
@@ -117,6 +118,7 @@
                                'resources/jquery/jquery.showThumbCtrl.css',
                                // OOjs UI interface elements
                                'resources/details/uw.DateDetailsWidget.less',
+                               
'resources/details/uw.CategoriesDetailsWidget.less',
                        ),
                        'messages' => array(
                                'comma-separator',
@@ -352,6 +354,7 @@
                                'mwe-upwiz-error-license-wikitext-missing',
                                'mwe-upwiz-error-license-wikitext-too-short',
                                'mwe-upwiz-error-license-wikitext-too-long',
+                               'mwe-upwiz-warning-categories-missing',
                                'mwe-upwiz-details-error-count',
                                'mwe-upwiz-license-cc-by-sa-4.0',
                                'mwe-upwiz-license-cc-by-sa-3.0',
diff --git a/i18n/en.json b/i18n/en.json
index 52df3ab..ceafee3 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -218,6 +218,7 @@
        "mwe-upwiz-error-license-wikitext-missing": "You selected an option 
which requires you to enter wikitext.",
        "mwe-upwiz-error-license-wikitext-too-short": "The wikitext here is too 
short to be a license",
        "mwe-upwiz-error-license-wikitext-too-long": "The wikitext you entered 
is too long.",
+       "mwe-upwiz-warning-categories-missing": "It is recommended that you 
fill in some categories for your uploads.",
        "mwe-upwiz-details-error-count": "There {{PLURAL:$1|is one error|are $1 
errors}} with the {{PLURAL:$2|form|forms}} above. Correct the 
{{PLURAL:$1|error|errors}}, and try submitting again.",
        "mwe-upwiz-too-many-files-text": "You can only upload $1 
{{PLURAL:$1|file|files}} at once but you tried to upload $2 
{{PLURAL:$2|file|files}} in total. Please try again with fewer files!",
        "mwe-upwiz-too-many-files": "Too many files.",
diff --git a/i18n/qqq.json b/i18n/qqq.json
index b96b97f..c44252b 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -241,12 +241,13 @@
        "mwe-upwiz-error-license-wikitext-missing": "Informs the user that they 
must input wikitext before the form can be submitted.",
        "mwe-upwiz-error-license-wikitext-too-short": "Message for a failed 
minimum length validation on the license form.",
        "mwe-upwiz-error-license-wikitext-too-long": "Message for a failed 
maximum length validation on the license form.",
+       "mwe-upwiz-warning-categories-missing": "Warning message displayed when 
the user has not selected any categories.\n\nThis should use the same wording 
as {{msg-mw|mwe-upwiz-necessary-confirm}}.",
        "mwe-upwiz-details-error-count": "Used as error message. Parameters:\n* 
$1 - number of errors\n* $2 - number of forms. i.e. number of uploads",
        "mwe-upwiz-too-many-files-text": "Error message informing the user 
there are too many uploads in a dialog. Each param is a file 
count.\n\nParameters:\n* $1 - limit number of files\n* $2 - number of files you 
tried to upload",
        "mwe-upwiz-too-many-files": "Error dialog title",
        "mwe-upwiz-file-too-large-text": "Error message informing the user that 
their file is too large to upload. Parameters:\n* $1 - the maximum file size\n* 
$2 - the size of the file they tried to upload\nThese two parameters use any 
one of the following messages:\n** {{msg-mw|Size-bytes}}\n** 
{{msg-mw|Size-kilobytes}}\n** {{msg-mw|Size-megabytes}}\n** 
{{msg-mw|Size-gigabytes}}",
        "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-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.\n\nThis should use the same wording as 
{{msg-mw|mwe-upwiz-warning-categories-missing}}.",
        "mwe-upwiz-dialog-yes": "{{Identical|Yes}}",
        "mwe-upwiz-dialog-no": "{{Identical|No}}",
        "mwe-upwiz-dialog-title": "{{Identical|Warning}}",
diff --git a/resources/controller/uw.controller.Details.js 
b/resources/controller/uw.controller.Details.js
index b864e3d..9f81103 100644
--- a/resources/controller/uw.controller.Details.js
+++ b/resources/controller/uw.controller.Details.js
@@ -107,8 +107,7 @@
        uw.controller.Details.prototype.valid = function () {
                var
                        validityPromises = [],
-                       necessary = 0,
-                       total = 0,
+                       warningValidityPromises = [],
                        titles = {};
 
                $.each( this.uploads, function ( i, upload ) {
@@ -117,12 +116,19 @@
                        }
 
                        // Update any error/warning messages about all 
DetailsWidgets
-                       upload.details.dateDetailsField.checkValidity();
+                       upload.details.checkValidity();
 
-                       validityPromises.push( $.when(
-                               upload.details.dateDetails.getErrors()
-                               // Other DetailsWidgets errors go here...
-                       ).then( function () {
+                       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();
+                                       }
+                               }
+                       } ) );
+
+                       validityPromises.push( upload.details.getErrors().then( 
function () {
                                var i, title, hasErrors = false;
 
                                for ( i = 0; i < arguments.length; i++ ) {
@@ -148,27 +154,25 @@
                                        titles[ title ] = true;
                                }
 
-                               if ( upload.details.necessaryFilled() ) {
-                                       necessary += 1;
-                               }
-
                                if ( hasErrors ) {
                                        return $.Deferred().reject();
                                }
                        } ) );
-
-                       total += 1;
                } );
 
                // If not all uploads are valid, $.when will reject this
                return $.when.apply( $, validityPromises ).then( function () {
-                       if ( necessary === total ) {
-                               // All uploads valid, all necessary fields 
filled
-                               return $.Deferred().resolve();
-                       } else {
-                               // Valid, but recommended fields missing, ask 
for confirmation
-                               return this.confirmationDialog();
-                       }
+                       // If not all uploads are warning-free, $.when will 
reject this too
+                       return $.when.apply( $, warningValidityPromises ).then(
+                               // All uploads valid, no warnings
+                               function () {
+                                       return $.Deferred().resolve();
+                               },
+                               function () {
+                                       // Valid, but with warnings, ask for 
confirmation
+                                       return this.confirmationDialog();
+                               }.bind( this )
+                       );
                }.bind( this ) );
        };
 
@@ -181,6 +185,8 @@
 
                return windowManager.openWindow( confirmationDialog, {
                        title: mw.message( 'mwe-upwiz-dialog-title' ).text(),
+                       // FIXME We currently only have one kind of warning, 
ever, and this message has the
+                       // appropriate text "hard-coded". It should be 
generated dynamically.
                        message: mw.message( 'mwe-upwiz-necessary-confirm' 
).text(),
                        verbose: true,
                        actions: [
diff --git a/resources/details/uw.CategoriesDetailsWidget.js 
b/resources/details/uw.CategoriesDetailsWidget.js
new file mode 100644
index 0000000..0e811cf
--- /dev/null
+++ b/resources/details/uw.CategoriesDetailsWidget.js
@@ -0,0 +1,146 @@
+( function ( mw, uw, $, OO ) {
+
+       /**
+        * A categories field in UploadWizard's "Details" step form.
+        *
+        * @extends uw.DetailsWidget
+        */
+       uw.CategoriesDetailsWidget = function UWCategoriesDetailsWidget() {
+               uw.CategoriesDetailsWidget.parent.call( this );
+
+               var categories = ( mw.UploadWizard.config.defaults.categories 
|| [] ).filter( function ( cat ) {
+                       // Keep only valid titles
+                       return !!mw.Title.newFromText( 'Category:' + cat );
+               } );
+
+               this.categoriesWidget = new mw.widgets.CategorySelector();
+
+               this.categoriesWidget.createItemWidget = function ( data ) {
+                       var widget = 
this.constructor.prototype.createItemWidget.call( this, data );
+                       widget.setMissing = function ( missing ) {
+                               this.constructor.prototype.setMissing.call( 
this, missing );
+                               if ( !missing ) {
+                                       this.$element.removeAttr( 'title' );
+                               } else {
+                                       this.$element
+                                               .attr( 'title', mw.msg( 
'mwe-upwiz-categories-missing' ) )
+                                               .tipsy()
+                                               .tipsy( 'show' );
+                               }
+                       };
+                       return widget;
+               };
+               this.categoriesWidget.setItemsFromData( categories );
+
+               this.categoriesWidgetPrevItems = 
this.categoriesWidget.getItems();
+               this.categoriesWidget.on( 'change', function () {
+                       var i;
+                       // Kill any active tipsies, they like to get stuck
+                       for ( i = 0; i < this.categoriesWidgetPrevItems.length; 
i++ ) {
+                               this.categoriesWidgetPrevItems[ i 
].$element.tipsy( 'hide' );
+                       }
+                       this.categoriesWidgetPrevItems = 
this.categoriesWidget.getItems();
+               }.bind( this ) );
+
+               this.$element.addClass( 'mwe-upwiz-categoriesDetailsWidget' );
+               this.$element.append( this.categoriesWidget.$element );
+
+               // Aggregate 'change' event
+               this.categoriesWidget.connect( this, { change: [ 'emit', 
'change' ] } );
+       };
+       OO.inheritClass( uw.CategoriesDetailsWidget, uw.DetailsWidget );
+
+       /**
+        * @inheritdoc
+        */
+       uw.CategoriesDetailsWidget.prototype.getErrors = function () {
+               var i;
+               // Kill any active tipsies, they like to get stuck.
+               // TODO This is a really stupid place to put this.
+               // It's here to ensure we clear them when we advance to next 
step.
+               for ( i = 0; i < this.categoriesWidgetPrevItems.length; i++ ) {
+                       this.categoriesWidgetPrevItems[ i ].$element.tipsy( 
'hide' );
+               }
+
+               return $.Deferred().resolve( [] ).promise();
+       };
+
+       /**
+        * @inheritdoc
+        */
+       uw.CategoriesDetailsWidget.prototype.getWarnings = function () {
+               var warnings = [];
+               if ( mw.UploadWizard.config.enableCategoryCheck && 
this.categoriesWidget.getItemsData().length === 0 ) {
+                       warnings.push( mw.message( 
'mwe-upwiz-warning-categories-missing' ) );
+               }
+               return $.Deferred().resolve( warnings ).promise();
+       };
+
+       /**
+        * @inheritdoc
+        */
+       uw.CategoriesDetailsWidget.prototype.getWikiText = function () {
+               var hiddenCats, missingCatsWikiText, categories, wikiText;
+
+               hiddenCats = [];
+               if ( mw.UploadWizard.config.autoAdd.categories ) {
+                       hiddenCats = hiddenCats.concat( 
mw.UploadWizard.config.autoAdd.categories );
+               }
+               if ( mw.UploadWizard.config.trackingCategory ) {
+                       if ( mw.UploadWizard.config.trackingCategory.all ) {
+                               hiddenCats.push( 
mw.UploadWizard.config.trackingCategory.all );
+                       }
+                       if ( mw.UploadWizard.config.trackingCategory.campaign ) 
{
+                               hiddenCats.push( 
mw.UploadWizard.config.trackingCategory.campaign );
+                       }
+               }
+               hiddenCats = hiddenCats.filter( function ( cat ) {
+                       // Keep only valid titles
+                       return !!mw.Title.newFromText( 'Category:' + cat );
+               } );
+
+               missingCatsWikiText = null;
+               if (
+                       typeof mw.UploadWizard.config.missingCategoriesWikiText 
=== 'string' &&
+                       mw.UploadWizard.config.missingCategoriesWikiText.length 
> 0
+               ) {
+                       missingCatsWikiText = 
mw.UploadWizard.config.missingCategoriesWikiText;
+               }
+
+               categories = this.categoriesWidget.getItemsData();
+
+               // add all categories
+               wikiText = categories.concat( hiddenCats )
+                       .map( function ( cat ) {
+                               return '[[' + mw.Title.newFromText( 'Category:' 
+ cat ).getPrefixedText() + ']]';
+                       } )
+                       .join( '\n' );
+
+               // if so configured, and there are no user-visible categories, 
add warning
+               if ( missingCatsWikiText !== null && categories.length === 0 ) {
+                       wikiText += '\n\n' + missingCatsWikiText;
+               }
+
+               return wikiText;
+       };
+
+       /**
+        * @inheritdoc
+        * @return {Object} See #setSerialized
+        */
+       uw.CategoriesDetailsWidget.prototype.getSerialized = function () {
+               return {
+                       value: this.categoriesWidget.getItemsData()
+               };
+       };
+
+       /**
+        * @inheritdoc
+        * @param {Object} serialized
+        * @param {string[]} serialized.value List of categories
+        */
+       uw.CategoriesDetailsWidget.prototype.setSerialized = function ( 
serialized ) {
+               this.categoriesWidget.setItemsFromData( serialized.value );
+       };
+
+} )( mediaWiki, mediaWiki.uploadWizard, jQuery, OO );
diff --git a/resources/details/uw.CategoriesDetailsWidget.less 
b/resources/details/uw.CategoriesDetailsWidget.less
new file mode 100644
index 0000000..f68f1e1
--- /dev/null
+++ b/resources/details/uw.CategoriesDetailsWidget.less
@@ -0,0 +1,4 @@
+// Hide the warning message until we switch to using this style consistently
+.oo-ui-fieldLayout-messages > 
.mwe-upwiz-fieldLayout-notice-mwe-upwiz-warning-categories-missing {
+       display: none;
+}
diff --git a/resources/mw.UploadWizardDetails.js 
b/resources/mw.UploadWizardDetails.js
index 0a41a37..d831147 100644
--- a/resources/mw.UploadWizardDetails.js
+++ b/resources/mw.UploadWizardDetails.js
@@ -10,12 +10,11 @@
         * @param {jQuery} containerDiv The `div` to put the interface into
         */
        mw.UploadWizardDetails = function ( upload, containerDiv ) {
-               var descriptionAdderDiv, titleContainerDiv, $categoriesDiv,
+               var descriptionAdderDiv, titleContainerDiv,
                        categoriesHinter,
-                       categoriesId,
                        moreDetailsCtrlDiv, moreDetailsDiv, otherInformationId,
                        otherInformationDiv, latitudeDiv, longitudeDiv, 
headingDiv,
-                       showMap, linkDiv, locationHinter, locationDiv, 
categories,
+                       showMap, linkDiv, locationHinter, locationDiv,
                        $list,
                        details = this;
 
@@ -112,12 +111,10 @@
                                this.deedDiv
                        );
 
-               $categoriesDiv = $(
-                       '<div class="mwe-upwiz-details-fieldname-input 
ui-helper-clearfix">' +
-                               '<div 
class="mwe-upwiz-details-fieldname"></div>' +
-                               '<div class="mwe-upwiz-details-input"></div>' +
-                       '</div>'
-               );
+               this.categoriesDetails = new uw.CategoriesDetailsWidget();
+               this.categoriesDetailsField = new uw.FieldLayout( 
this.categoriesDetails, {
+                       label: mw.message( 'mwe-upwiz-categories' ).text()
+               } );
                categoriesHinter = function () {
                        var commonsCategoriesLink = $( '<a>' ).attr( {
                                target: '_blank',
@@ -125,10 +122,8 @@
                        } );
                        return mw.message( 'mwe-upwiz-tooltip-categories', 
commonsCategoriesLink ).parse();
                };
-               $categoriesDiv
-                       .find( '.mwe-upwiz-details-fieldname' )
-                       .text( mw.message( 'mwe-upwiz-categories' ).text() )
-                       .addHint( 'mwe-upwiz-categories-hint', categoriesHinter 
);
+               // TODO Rethink hints
+               this.categoriesDetailsField.$label.addHint( 
'mwe-upwiz-categories-hint', categoriesHinter );
 
                this.dateDetails = new uw.DateDetailsWidget();
                this.dateDetailsField = new uw.FieldLayout( this.dateDetails, {
@@ -199,7 +194,7 @@
                        descriptionAdderDiv,
                        this.copyrightInfoFieldset,
                        this.dateDetailsField.$element,
-                       $categoriesDiv
+                       this.categoriesDetailsField.$element
                );
 
                this.$form.on( 'submit', function ( e ) {
@@ -388,46 +383,6 @@
                                        }
                                } );
                }
-
-               categories = ( mw.UploadWizard.config.defaults.categories || [] 
).filter( function ( cat ) {
-                       // Keep only valid titles
-                       return !!mw.Title.newFromText( 'Category:' + cat );
-               } );
-
-               categoriesId = 'categories' + this.upload.index;
-               this.categoriesWidget = new mw.widgets.CategorySelector( {
-                       id: categoriesId
-               } );
-
-               this.categoriesWidget.createItemWidget = function ( data ) {
-                       var widget = 
this.constructor.prototype.createItemWidget.call( this, data );
-                       widget.setMissing = function ( missing ) {
-                               this.constructor.prototype.setMissing.call( 
this, missing );
-                               if ( !missing ) {
-                                       this.$element.removeAttr( 'title' );
-                               } else {
-                                       this.$element
-                                               .attr( 'title', mw.msg( 
'mwe-upwiz-categories-missing' ) )
-                                               .tipsy()
-                                               .tipsy( 'show' );
-                               }
-                       };
-                       return widget;
-               };
-               this.categoriesWidget.setItemsFromData( categories );
-
-               this.categoriesWidgetItems = this.categoriesWidget.getItems();
-               this.categoriesWidget.on( 'change', function () {
-                       var i;
-                       // Kill any active tipsies, they like to get stuck
-                       for ( i = 0; i < this.categoriesWidgetItems.length; i++ 
) {
-                               this.categoriesWidgetItems[ i ].$element.tipsy( 
'hide' );
-                       }
-                       this.categoriesWidgetItems = 
this.categoriesWidget.getItems();
-               }.bind( this ) );
-
-               $categoriesDiv.find( '.mwe-upwiz-details-input' )
-                       .append( this.categoriesWidget.$element );
        };
 
        /**
@@ -643,9 +598,9 @@
 
                        } else if ( metadataType === 'categories' ) {
 
-                               oouiCopy( 'categoriesWidget', {
-                                       get: 'getItemsData',
-                                       set: 'setItemsFromData'
+                               oouiCopy( 'categoriesDetails', {
+                                       get: 'getSerialized',
+                                       set: 'setSerialized'
                                } );
 
                        } else if ( metadataType === 'location' ) {
@@ -767,18 +722,15 @@
                },
 
                /**
-                * check entire form for validity
-                * side effect: add error text to the page for fields in an 
incorrect state.
+                * Check the fields using the legacy jquery.validate system for 
validity. You must also call
+                * #getErrors to check validity of fields using the new OOUI 
system.
+                *
+                * Side effect: add error text to the page for fields in an 
incorrect state.
                 *
                 * @return {boolean} Whether the form is valid.
                 */
                valid: function () {
-                       var i, deedValid, formValid;
-
-                       // Kill any active tipsies, they like to get stuck
-                       for ( i = 0; i < this.categoriesWidgetItems.length; i++ 
) {
-                               this.categoriesWidgetItems[ i ].$element.tipsy( 
'hide' );
-                       }
+                       var deedValid, formValid;
 
                        // make sure licenses are valid (needed for multi-file 
deed selection)
                        deedValid = this.upload.deedChooser.valid();
@@ -791,16 +743,43 @@
                },
 
                /**
-                * check if we have all the *must have* but not mandatory 
fields filled in
-                * Currently this tests for the following:
-                * 1) Empty category
+                * Check the fields using the new OOjs UI system for validity. 
You must also call #valid to
+                * check validity of fields using the legacy jquery.validate 
system.
                 *
-                * @return {boolean}
+                * @return {jQuery.Promise} Promise resolved with multiple 
array arguments, each containing a
+                *   list of error messages for a single field. If API requests 
necessary to check validity
+                *   fail, the promise may be rejected. The form is valid if 
the promise is resolved with all
+                *   empty arrays.
                 */
-               necessaryFilled: function () {
-                       // check for empty category input
-                       return !mw.UploadWizard.config.enableCategoryCheck ||
-                               this.categoriesWidget.getItemsData().length > 0;
+               getErrors: function () {
+                       return $.when(
+                               this.dateDetails.getErrors(),
+                               this.categoriesDetails.getErrors()
+                               // More fields will go here as we convert 
things to the new system...
+                       );
+               },
+
+               /**
+                * Check the fields using the new OOjs UI system for warnings.
+                *
+                * @return {jQuery.Promise} Same as #getErrors
+                */
+               getWarnings: function () {
+                       return $.when(
+                               this.dateDetails.getWarnings(),
+                               this.categoriesDetails.getWarnings()
+                               // More fields will go here as we convert 
things to the new system...
+                       );
+               },
+
+               /**
+                * Check the fields using the new OOjs UI system for errors and 
warnings and display them in the
+                * UI.
+                */
+               checkValidity: function () {
+                       this.dateDetailsField.checkValidity();
+                       this.categoriesDetailsField.checkValidity();
+                       // More fields will go here as we convert things to the 
new system...
                },
 
                /**
@@ -1334,7 +1313,6 @@
                 */
                getWikiText: function () {
                        var deed, info, key, latitude, longitude, 
otherInfoWikiText, heading,
-                               hiddenCats, missingCatsWikiText, categories,
                                locationThings, information,
                                wikiText = '';
 
@@ -1429,45 +1407,7 @@
                                }
 
                                // categories
-
-                               hiddenCats = [];
-                               if ( mw.UploadWizard.config.autoAdd.categories 
) {
-                                       hiddenCats = hiddenCats.concat( 
mw.UploadWizard.config.autoAdd.categories );
-                               }
-                               if ( mw.UploadWizard.config.trackingCategory ) {
-                                       if ( 
mw.UploadWizard.config.trackingCategory.all ) {
-                                               hiddenCats.push( 
mw.UploadWizard.config.trackingCategory.all );
-                                       }
-                                       if ( 
mw.UploadWizard.config.trackingCategory.campaign ) {
-                                               hiddenCats.push( 
mw.UploadWizard.config.trackingCategory.campaign );
-                                       }
-                               }
-                               hiddenCats = hiddenCats.filter( function ( cat 
) {
-                                       // Keep only valid titles
-                                       return !!mw.Title.newFromText( 
'Category:' + cat );
-                               } );
-
-                               missingCatsWikiText = null;
-                               if (
-                                       typeof 
mw.UploadWizard.config.missingCategoriesWikiText === 'string' &&
-                                       
mw.UploadWizard.config.missingCategoriesWikiText.length > 0
-                               ) {
-                                       missingCatsWikiText = 
mw.UploadWizard.config.missingCategoriesWikiText;
-                               }
-
-                               categories = 
this.categoriesWidget.getItemsData();
-
-                               // add all categories
-                               wikiText += '\n' + categories.concat( 
hiddenCats )
-                                       .map( function ( cat ) {
-                                               return '[[' + 
mw.Title.newFromText( 'Category:' + cat ).getPrefixedText() + ']]';
-                                       } )
-                                       .join( '\n' ) + '\n';
-
-                               // if so configured, and there are no 
user-visible categories, add warning
-                               if ( missingCatsWikiText !== null && 
categories.length === 0 ) {
-                                       wikiText += '\n' + missingCatsWikiText;
-                               }
+                               wikiText += '\n' + 
this.categoriesDetails.getWikiText();
 
                                // sanitize wikitext if TextCleaner is defined 
(MediaWiki:TextCleaner.js)
                                if ( typeof window.TextCleaner !== 'undefined' 
&& typeof window.TextCleaner.sanitizeWikiText === 'function' ) {

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iee797ce14e2457759e40e08dcf16746e7041384c
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/UploadWizard
Gerrit-Branch: master
Gerrit-Owner: Bartosz Dziewoński <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to