MWTemplateDialog: When opening the dialog, add in any unset suggested and required parameters

Bug: T97482
Change-Id: Iaf280355f442240aba4e1f74d3ee402fc5d329b0
This commit is contained in:
James D. Forrester 2016-05-13 12:43:47 -07:00 committed by Esanders
parent 953422a605
commit 832118e051
4 changed files with 23 additions and 4 deletions

View file

@ -288,10 +288,7 @@ ve.dm.MWTemplateModel.prototype.removeParameter = function ( param ) {
};
/**
* Add all non-existing required and suggested parameters, if any.
*
* @method
* @return {number} Number of parameters added
* @inheritdoc
*/
ve.dm.MWTemplateModel.prototype.addPromptedParameters = function () {
var i, len, addedCount = 0,

View file

@ -542,4 +542,14 @@
return -1;
};
/*
* Add missing required and suggested parameters to each transclusion.
*/
ve.dm.MWTransclusionModel.prototype.addPromptedParameters = function () {
var i;
for ( i = 0; i < this.parts.length; i++ ) {
this.parts[ i ].addPromptedParameters();
}
};
}() );

View file

@ -77,3 +77,13 @@ ve.dm.MWTransclusionPartModel.prototype.serialize = function () {
ve.dm.MWTransclusionPartModel.prototype.getWikitext = function () {
return '';
};
/**
* Add all non-existing required and suggested parameters, if any.
*
* @method
* @return {number} Number of parameters added
*/
ve.dm.MWTransclusionPartModel.prototype.addPromptedParameters = function () {
return 0;
};

View file

@ -78,6 +78,8 @@ ve.ui.MWTemplateDialog.static.bookletLayoutConfig = {
* Handle the transclusion being ready to use.
*/
ve.ui.MWTemplateDialog.prototype.onTransclusionReady = function () {
// Add missing required and suggested parameters to each transclusion.
this.transclusionModel.addPromptedParameters();
this.loaded = true;
this.$element.addClass( 've-ui-mwTemplateDialog-ready' );
this.$body.append( this.bookletLayout.$element );