ForeignStructuredUpload: Stop using methods from CapsuleMultiselectWidget
authorPrateek Saxena <prtksxna@gmail.com>
Thu, 28 Jun 2018 07:13:29 +0000 (12:43 +0530)
committerBartosz Dziewoński <matma.rex@gmail.com>
Thu, 28 Jun 2018 12:57:30 +0000 (12:57 +0000)
After I2146d8ce6505dae55750b4b12bd806b83796c1c5 CategoryMultiselectWidget
inherits from TagMultiselectWidget instead of CapsuleMultiselectWidget.

TagMultiselectWidget has a setValue method instead of setItemsFromData,
and instead of getItemsData we need to use getItems and extract the data.

Bug: T183299
Bug: T198362
Change-Id: Iff1f8a520a01e6771d6b496a87e4749b7c30a877

resources/src/mediawiki.ForeignStructuredUpload.BookletLayout/BookletLayout.js

index 7d4ed53..d38adcd 100644 (file)
         * @inheritdoc
         */
        mw.ForeignStructuredUpload.BookletLayout.prototype.getText = function () {
-               var language = mw.config.get( 'wgContentLanguage' );
+               var language = mw.config.get( 'wgContentLanguage' ),
+                       categories = this.categoriesWidget.getItems().map( function ( item ) {
+                               return item.data;
+                       } );
                this.upload.clearDescriptions();
                this.upload.addDescription( language, this.descriptionWidget.getValue() );
                this.upload.setDate( this.dateWidget.getValue() );
                this.upload.clearCategories();
-               this.upload.addCategories( this.categoriesWidget.getItemsData() );
+               this.upload.addCategories( categories );
                return this.upload.getText();
        };
 
                mw.ForeignStructuredUpload.BookletLayout.parent.prototype.clear.call( this );
 
                this.ownWorkCheckbox.setSelected( false );
-               this.categoriesWidget.setItemsFromData( [] );
+               this.categoriesWidget.setValue( [] );
                this.dateWidget.setValue( '' ).setValidityFlag( true );
        };