diff --git a/VisualEditor.php b/VisualEditor.php index 26d0ab8f1a..bb0adc5873 100644 --- a/VisualEditor.php +++ b/VisualEditor.php @@ -669,6 +669,7 @@ $wgResourceModules += array( 'visualeditor-dialog-transclusion-remove-content', 'visualeditor-dialog-transclusion-remove-param', 'visualeditor-dialog-transclusion-remove-template', + 'visualeditor-dialog-transclusion-required-parameter', 'visualeditor-dialog-transclusion-title', 'visualeditor-dialog-transclusion-wikitext-label', 'visualeditor-dialogbutton-media-tooltip', diff --git a/modules/ve-mw/dm/models/ve.dm.MWTemplateParameterModel.js b/modules/ve-mw/dm/models/ve.dm.MWTemplateParameterModel.js index 8924bdb106..cc03bc9d6b 100644 --- a/modules/ve-mw/dm/models/ve.dm.MWTemplateParameterModel.js +++ b/modules/ve-mw/dm/models/ve.dm.MWTemplateParameterModel.js @@ -26,6 +26,17 @@ ve.dm.MWTemplateParameterModel = function VeDmMWTemplateParameterModel( template /* Methods */ +/** + * Check if parameter is required. + * + * @method + * @param {string} name Parameter name + * @returns {boolean} Parameter is required + */ +ve.dm.MWTemplateParameterModel.prototype.isRequired = function () { + return this.template.getSpec().isParameterRequired( this.name ); +}; + /** * Get template parameter is part of. * diff --git a/modules/ve-mw/i18n/en.json b/modules/ve-mw/i18n/en.json index 68999d8faf..2c36ce6d48 100644 --- a/modules/ve-mw/i18n/en.json +++ b/modules/ve-mw/i18n/en.json @@ -83,6 +83,7 @@ "visualeditor-dialog-transclusion-remove-content": "Remove content", "visualeditor-dialog-transclusion-remove-param": "Remove parameter", "visualeditor-dialog-transclusion-remove-template": "Remove template", + "visualeditor-dialog-transclusion-required-parameter": "Required parameter", "visualeditor-dialog-transclusion-title": "Transclusion", "visualeditor-dialogbutton-media-tooltip": "Media", "visualeditor-dialogbutton-meta-tooltip": "Page settings", diff --git a/modules/ve-mw/i18n/qqq.json b/modules/ve-mw/i18n/qqq.json index c414fed540..e03f098656 100644 --- a/modules/ve-mw/i18n/qqq.json +++ b/modules/ve-mw/i18n/qqq.json @@ -88,6 +88,7 @@ "visualeditor-dialog-transclusion-remove-content": "Label for button that removes content between transclusion parts", "visualeditor-dialog-transclusion-remove-param": "Label for button that removes a parameter from a template", "visualeditor-dialog-transclusion-remove-template": "Label for button that removes a template from a transclusion.\n{{Identical|Remove template}}", + "visualeditor-dialog-transclusion-required-parameter": "Tooltip for required parameter indicator", "visualeditor-dialog-transclusion-title": "{{Identical|Transclusion}}", "visualeditor-dialogbutton-media-tooltip": "{{Identical|Media}}", "visualeditor-dialogbutton-meta-tooltip": "{{Identical|Page settings}}", diff --git a/modules/ve-mw/ui/pages/ve.ui.MWTemplateParameterPage.js b/modules/ve-mw/ui/pages/ve.ui.MWTemplateParameterPage.js index 568c77a871..09b793e560 100644 --- a/modules/ve-mw/ui/pages/ve.ui.MWTemplateParameterPage.js +++ b/modules/ve-mw/ui/pages/ve.ui.MWTemplateParameterPage.js @@ -18,7 +18,14 @@ */ ve.ui.MWTemplateParameterPage = function VeUiMWTemplateParameter( parameter, name, config ) { // Configuration initialization - config = ve.extendObject( { 'icon': 'parameter', 'movable': false, 'level': 1 }, config ); + config = ve.extendObject( + parameter.isRequired() ? { + 'indicator': 'required', + 'indicatorLabel': ve.msg( 'visualeditor-dialog-transclusion-required-parameter' ) + } : {}, + { 'icon': 'parameter', 'movable': false, 'level': 1 }, + config + ); // Parent constructor OO.ui.PageLayout.call( this, name, config );