From 89f8b35018b16951b78fa93c985799d7239ea0eb Mon Sep 17 00:00:00 2001 From: Ed Sanders Date: Wed, 24 Feb 2016 17:34:18 +0000 Subject: [PATCH] Avoid calling repopulateParamSelectWidget multiple times on setup Change-Id: I05ce3d8ff1109980248a0c2389298591f9b54553 --- .../ext.templateDataGenerator.ui.tdDialog.js | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/modules/ext.templateDataGenerator.ui.tdDialog.js b/modules/ext.templateDataGenerator.ui.tdDialog.js index a3a4532c..de121178 100644 --- a/modules/ext.templateDataGenerator.ui.tdDialog.js +++ b/modules/ext.templateDataGenerator.ui.tdDialog.js @@ -18,6 +18,7 @@ mw.TemplateData.Dialog = function mwTemplateDataDialog( config ) { this.selectedParamKey = ''; this.propInputs = {}; this.propFieldLayout = {}; + this.isSetup = false; // Initialize this.$element.addClass( 'tdg-templateDataDialog' ); @@ -501,10 +502,15 @@ mw.TemplateData.Dialog.prototype.reset = function () { * Empty and repopulate the parameter select widget. */ mw.TemplateData.Dialog.prototype.repopulateParamSelectWidget = function () { - var i, paramKey, - missingParams = this.model.getMissingParams(), - paramList = this.model.getParams(), - paramOrder = this.model.getTemplateParamOrder(); + var i, paramKey, missingParams, paramList, paramOrder; + + if ( !this.isSetup ) { + return; + } + + missingParams = this.model.getMissingParams(); + paramList = this.model.getParams(); + paramOrder = this.model.getTemplateParamOrder(); this.paramSelect.clearItems(); @@ -764,6 +770,8 @@ mw.TemplateData.Dialog.prototype.getSetupProcess = function ( data ) { var i, language, languages, languageItems = []; + this.isSetup = false; + this.reset(); // The dialog must be supplied with a reference to a model @@ -821,6 +829,10 @@ mw.TemplateData.Dialog.prototype.getSetupProcess = function ( data ) { // Trigger the initial language choice this.languageDropdownWidget.getMenu().selectItemByData( language ); + this.isSetup = true; + + this.repopulateParamSelectWidget(); + // Show the panel this.$spinner.hide(); this.panels.$element.show();