mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/TemplateData
synced 2024-11-27 17:20:01 +00:00
Allow adding a new parameter again
Due to a bug, new parameters could not be added unless they were previously deleted. This commit fixes that bug. Change-Id: I3784d1b3d650893f26abb63994d13c08b148075b
This commit is contained in:
parent
c087fe89c7
commit
c525aef5b0
|
@ -812,7 +812,7 @@ mw.TemplateData.Model.prototype.getParams = function () {
|
||||||
};
|
};
|
||||||
|
|
||||||
mw.TemplateData.Model.prototype.isParamDeleted = function ( key ) {
|
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 ) {
|
mw.TemplateData.Model.prototype.isParamExists = function ( key ) {
|
||||||
|
|
|
@ -224,7 +224,15 @@ mw.TemplateData.Dialog.prototype.onModelChangeDescription = function ( descripti
|
||||||
};
|
};
|
||||||
|
|
||||||
mw.TemplateData.Dialog.prototype.onAddParamInputChange = function ( value ) {
|
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
|
// Disable the add button
|
||||||
this.addParamButton.setDisabled( true );
|
this.addParamButton.setDisabled( true );
|
||||||
} else {
|
} else {
|
||||||
|
@ -355,14 +363,11 @@ mw.TemplateData.Dialog.prototype.onAddParamButtonClick = function () {
|
||||||
allProps = mw.TemplateData.Model.static.getAllProperties( true );
|
allProps = mw.TemplateData.Model.static.getAllProperties( true );
|
||||||
|
|
||||||
// Validate parameter
|
// Validate parameter
|
||||||
if (
|
if ( !newParamKey.match( allProps.name.restrict ) ) {
|
||||||
!newParamKey.match( allProps.name.restrict ) &&
|
|
||||||
this.model.isParamExists( newParamKey )
|
|
||||||
) {
|
|
||||||
if ( this.model.isParamDeleted( newParamKey ) ) {
|
if ( this.model.isParamDeleted( newParamKey ) ) {
|
||||||
// Empty param
|
// Empty param
|
||||||
this.model.emptyParamData( newParamKey );
|
this.model.emptyParamData( newParamKey );
|
||||||
} else {
|
} else if ( !this.model.isParamExists( newParamKey ) ) {
|
||||||
// Add to model
|
// Add to model
|
||||||
if ( this.model.addParam( newParamKey ) ) {
|
if ( this.model.addParam( newParamKey ) ) {
|
||||||
// Add parameter to list
|
// Add parameter to list
|
||||||
|
|
Loading…
Reference in a new issue