Krinkle has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/70111


Change subject: ve.dm.MWTemplateSpecModel: Expand parameter aliases
......................................................................

ve.dm.MWTemplateSpecModel: Expand parameter aliases

We were previously ignoring this data leading to situations
where a template that can be invoked like {{foo|1=bar}} and
{{foo|thing=bar}} (where the template data documents param
thing with alias '1') will show up in the editor with no
parameter information or label for the 1= call, but will show
up for the thing= call.

Now they are properly aliases so both will appear the same
in the editor dialog.

Bug: 49838
Change-Id: I37ec0e152df905844ac58ed1834fca29dccb4eec
---
M modules/ve/dm/models/ve.dm.MWTemplateSpecModel.js
M modules/ve/dm/models/ve.dm.MWTransclusionModel.js
2 files changed, 17 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor 
refs/changes/11/70111/1

diff --git a/modules/ve/dm/models/ve.dm.MWTemplateSpecModel.js 
b/modules/ve/dm/models/ve.dm.MWTemplateSpecModel.js
index 0f3b0fe..9823a92 100644
--- a/modules/ve/dm/models/ve.dm.MWTemplateSpecModel.js
+++ b/modules/ve/dm/models/ve.dm.MWTemplateSpecModel.js
@@ -67,16 +67,25 @@
  * @param {string[][]} [data.sets] Lists of param sets
  */
 ve.dm.MWTemplateSpecModel.prototype.extend = function ( data ) {
-       var key;
+       var key, paramObj, i, len;
 
        if ( data.description !== null ) {
                this.description = data.description;
        }
        if ( ve.isPlainObject( data.params ) ) {
                for ( key in data.params ) {
+                       paramObj = data.params[key];
                        this.params[key] = ve.extendObject(
-                               true, this.getDefaultParameterSpec( key ), 
data.params[key]
+                               true,
+                               this.getDefaultParameterSpec( key ),
+                               paramObj
                        );
+                       if ( paramObj.aliases.length ) {
+                               for ( i = 0, len = paramObj.aliases.length; i < 
len; i++ ) {
+                                       this.params[ paramObj.aliases[i] ] = 
paramObj;
+                               }
+                       }
+                       delete paramObj.aliases;
                }
        }
        if ( data.sets ) {
diff --git a/modules/ve/dm/models/ve.dm.MWTransclusionModel.js 
b/modules/ve/dm/models/ve.dm.MWTransclusionModel.js
index 7dacad8..595c3e2 100644
--- a/modules/ve/dm/models/ve.dm.MWTransclusionModel.js
+++ b/modules/ve/dm/models/ve.dm.MWTransclusionModel.js
@@ -79,10 +79,10 @@
                        }
                }
        }
-       // Promise is resolved passing the specs object as the first argument - 
binding #specs
-       // to precede that argument and passing them both to extendObject will 
cause #specs to be added
-       // to when the promise is resolved
-       return this.fetchSpecs( templates ).done( ve.bind( ve.extendObject, 
null, this.specs ) );
+       // Add fetched specs to #specs store when the promise is resolved
+       return this.fetchSpecs( templates ).done( function ( specs ) {
+               ve.extendObject( this.specs, specs );
+       } );
 };
 
 /**
@@ -92,7 +92,8 @@
  * @returns {jQuery.Promise} Promise, resolved when spec is loaded
  */
 ve.dm.MWTransclusionModel.prototype.fetchSpecs = function ( templates ) {
-       var i, len, title, deferred = $.Deferred(),
+       var i, len, title,
+               deferred = $.Deferred(),
                specs = {},
                titles = [];
 

-- 
To view, visit https://gerrit.wikimedia.org/r/70111
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I37ec0e152df905844ac58ed1834fca29dccb4eec
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Krinkle <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to