mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-12-04 18:58:37 +00:00
Streamline and harden template paramter search widget behavior
What this changes: * The moment the user selects anything in the parameter search widget, the input is cleared, no matter what happens next. Even in case of an error. We know the input was bad in this case. Let's get rid of it. * The method makes sure it does not even try to add a duplicate parameter. This should be unreachable, but better be safe than sorry. This is split from I5eeb973. I run into this while playing around with different approaches related to hiding deprecated parameters. Typically there should be no way the parameter search widget offers a duplicate. Still I believe it's a good idea to have this extra safety-net. Bug: T272487 Bug: T288827 Change-Id: I04e76d73b4a3f6467d0ccf3ccff5d2f6b4114bd9
This commit is contained in:
parent
0acf57904d
commit
45096d1e2f
|
@ -105,16 +105,16 @@ ve.ui.MWParameterPlaceholderPage.prototype.setOutlineItem = function () {
|
|||
};
|
||||
|
||||
ve.ui.MWParameterPlaceholderPage.prototype.onParameterChoose = function ( name ) {
|
||||
if ( !name ) {
|
||||
this.addParameterSearch.query.setValue( '' );
|
||||
|
||||
if ( !name || this.template.hasParameter( name ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Note that every parameter is known after it is added
|
||||
var knownBefore = this.template.getSpec().isKnownParameterOrAlias( name ),
|
||||
param = new ve.dm.MWParameterModel( this.template, name );
|
||||
var knownBefore = this.template.getSpec().isKnownParameterOrAlias( name );
|
||||
|
||||
this.addParameterSearch.query.setValue( '' );
|
||||
this.template.addParameter( param );
|
||||
this.template.addParameter( new ve.dm.MWParameterModel( this.template, name ) );
|
||||
|
||||
ve.track( 'activity.transclusion', {
|
||||
action: knownBefore ? 'add-known-parameter' : 'add-unknown-parameter'
|
||||
|
|
Loading…
Reference in a new issue