mw.ForeignStructuredUpload: Prevent categories and descriptions from being duplicated
authorBartosz Dziewoński <matma.rex@gmail.com>
Thu, 5 Nov 2015 18:26:55 +0000 (19:26 +0100)
committerJforrester <jforrester@wikimedia.org>
Thu, 5 Nov 2015 18:43:24 +0000 (18:43 +0000)
One copy would be added every time the user tried to save the file.
If they got an error and corrected it before trying again, there would
be two or more copies.

Bug: T116394
Change-Id: Ib4642d48e21d679ed675614efb29c77fa0e2c9c4

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

index 717e2ec..8595386 100644 (file)
         */
        mw.ForeignStructuredUpload.BookletLayout.prototype.getText = function () {
                var language = mw.config.get( 'wgContentLanguage' );
+               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() );
                return this.upload.getText();
        };
index 1471e46..8d2f753 100644 (file)
                }
        };
 
+       /**
+        * Empty the list of categories for the upload.
+        */
+       ForeignStructuredUpload.prototype.clearCategories = function () {
+               this.categories = [];
+       };
+
        /**
         * Add a description to the upload.
         *
                } );
        };
 
+       /**
+        * Empty the list of descriptions for the upload.
+        */
+       ForeignStructuredUpload.prototype.clearDescriptions = function () {
+               this.descriptions = [];
+       };
+
        /**
         * Set the date of creation for the upload.
         *