From: Bartosz DziewoƄski Date: Thu, 5 Nov 2015 18:26:55 +0000 (+0100) Subject: mw.ForeignStructuredUpload: Prevent categories and descriptions from being duplicated X-Git-Tag: 1.31.0-rc.0~9088^2 X-Git-Url: http://git.cyclocoop.org/data/Fool?a=commitdiff_plain;h=fd9630bca2189cd676a053f69f7bf299b58304c7;p=lhc%2Fweb%2Fwiklou.git mw.ForeignStructuredUpload: Prevent categories and descriptions from being duplicated 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 --- diff --git a/resources/src/mediawiki/mediawiki.ForeignStructuredUpload.BookletLayout.js b/resources/src/mediawiki/mediawiki.ForeignStructuredUpload.BookletLayout.js index 717e2ecfab..859538615c 100644 --- a/resources/src/mediawiki/mediawiki.ForeignStructuredUpload.BookletLayout.js +++ b/resources/src/mediawiki/mediawiki.ForeignStructuredUpload.BookletLayout.js @@ -231,8 +231,10 @@ */ 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(); }; diff --git a/resources/src/mediawiki/mediawiki.ForeignStructuredUpload.js b/resources/src/mediawiki/mediawiki.ForeignStructuredUpload.js index 1471e46efc..8d2f753a05 100644 --- a/resources/src/mediawiki/mediawiki.ForeignStructuredUpload.js +++ b/resources/src/mediawiki/mediawiki.ForeignStructuredUpload.js @@ -40,6 +40,13 @@ } }; + /** + * Empty the list of categories for the upload. + */ + ForeignStructuredUpload.prototype.clearCategories = function () { + this.categories = []; + }; + /** * Add a description to the upload. * @@ -53,6 +60,13 @@ } ); }; + /** + * Empty the list of descriptions for the upload. + */ + ForeignStructuredUpload.prototype.clearDescriptions = function () { + this.descriptions = []; + }; + /** * Set the date of creation for the upload. *