diff --git a/modules/ext.templateDataGenerator.data.js b/modules/ext.templateDataGenerator.data.js index bd4fa94a..76af9763 100644 --- a/modules/ext.templateDataGenerator.data.js +++ b/modules/ext.templateDataGenerator.data.js @@ -812,7 +812,7 @@ mw.TemplateData.Model.prototype.getParams = function () { }; mw.TemplateData.Model.prototype.isParamDeleted = function ( key ) { - return this.params[key].deleted === true; + return this.params[key] && this.params[key].deleted === true; }; mw.TemplateData.Model.prototype.isParamExists = function ( key ) { diff --git a/modules/ext.templateDataGenerator.ui.tdDialog.js b/modules/ext.templateDataGenerator.ui.tdDialog.js index ddd794a8..d44edb19 100644 --- a/modules/ext.templateDataGenerator.ui.tdDialog.js +++ b/modules/ext.templateDataGenerator.ui.tdDialog.js @@ -224,7 +224,15 @@ mw.TemplateData.Dialog.prototype.onModelChangeDescription = function ( descripti }; mw.TemplateData.Dialog.prototype.onAddParamInputChange = function ( value ) { - if ( this.model.isParamExists( value ) && !this.model.isParamDeleted( value ) ) { + var allProps = mw.TemplateData.Model.static.getAllProperties( true ); + + if ( + value.match( allProps.name.restrict ) || + ( + this.model.isParamExists( value ) && + !this.model.isParamDeleted( value ) + ) + ) { // Disable the add button this.addParamButton.setDisabled( true ); } else { @@ -355,14 +363,11 @@ mw.TemplateData.Dialog.prototype.onAddParamButtonClick = function () { allProps = mw.TemplateData.Model.static.getAllProperties( true ); // Validate parameter - if ( - !newParamKey.match( allProps.name.restrict ) && - this.model.isParamExists( newParamKey ) - ) { + if ( !newParamKey.match( allProps.name.restrict ) ) { if ( this.model.isParamDeleted( newParamKey ) ) { // Empty param this.model.emptyParamData( newParamKey ); - } else { + } else if ( !this.model.isParamExists( newParamKey ) ) { // Add to model if ( this.model.addParam( newParamKey ) ) { // Add parameter to list