mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/TemplateData
synced 2024-11-23 23:43:54 +00:00
Merge "Turn deprecated/required/suggested checkboxes into select widget"
This commit is contained in:
commit
ca8061b4a5
|
@ -111,6 +111,10 @@
|
|||
"messages": [
|
||||
"comma-separator",
|
||||
"templatedata-doc-no-params-set",
|
||||
"templatedata-doc-param-status-optional",
|
||||
"templatedata-doc-param-status-deprecated",
|
||||
"templatedata-doc-param-status-required",
|
||||
"templatedata-doc-param-status-suggested",
|
||||
"templatedata-doc-param-type-boolean",
|
||||
"templatedata-doc-param-type-content",
|
||||
"templatedata-doc-param-type-date",
|
||||
|
@ -164,6 +168,7 @@
|
|||
"templatedata-modal-table-param-suggestedvalues",
|
||||
"templatedata-modal-placeholder-multiselect",
|
||||
"templatedata-modal-table-param-default",
|
||||
"templatedata-modal-table-param-status",
|
||||
"templatedata-modal-table-param-deprecated",
|
||||
"templatedata-modal-table-param-deprecatedValue",
|
||||
"templatedata-modal-table-param-description",
|
||||
|
|
|
@ -92,6 +92,7 @@
|
|||
"templatedata-modal-table-param-aliases": "Aliases",
|
||||
"templatedata-modal-table-param-autovalue": "Auto value",
|
||||
"templatedata-modal-table-param-default": "Default ($1)",
|
||||
"templatedata-modal-table-param-status": "Status",
|
||||
"templatedata-modal-table-param-deprecated": "Deprecated",
|
||||
"templatedata-modal-table-param-deprecatedValue": "Deprecated guidance",
|
||||
"templatedata-modal-table-param-description": "Description ($1)",
|
||||
|
|
|
@ -105,6 +105,7 @@
|
|||
"templatedata-modal-table-param-aliases": "Label for a parameter property input: Aliases of the parameter.",
|
||||
"templatedata-modal-table-param-autovalue": "Label for a parameter property input: Parameter auto value in the table",
|
||||
"templatedata-modal-table-param-default": "Label for a parameter property input: Default value of the parameter.\n\nParameters:\n* $1 - currently showing language\n{{Identical|Default}}",
|
||||
"templatedata-modal-table-param-status": "Label for a parameter property input: Status of the parameter, i.e. if the parameter is deprecated, required, suggested, or an ordinary optional parameter.",
|
||||
"templatedata-modal-table-param-deprecated": "Label for a parameter property input: Deprecated status of the parameter.\n{{Identical|Deprecated}}",
|
||||
"templatedata-modal-table-param-deprecatedValue": "Label for a parameter property input: Deprecated guidance of the parameter. This string will be shown to users as an explanation why the parameter is deprecated and what the users should do about it.",
|
||||
"templatedata-modal-table-param-description": "Label for a parameter property input: Description of the parameter.\n\nParameters:\n* $1 - currently showing language\n{{Identical|Description}}",
|
||||
|
|
|
@ -164,6 +164,16 @@ Model.static.getAllProperties = function ( getFullData ) {
|
|||
autovalue: {
|
||||
type: 'string'
|
||||
},
|
||||
status: {
|
||||
type: 'select',
|
||||
children: [
|
||||
'optional',
|
||||
'deprecated',
|
||||
'required',
|
||||
'suggested'
|
||||
],
|
||||
default: 'optional'
|
||||
},
|
||||
deprecated: {
|
||||
type: 'boolean',
|
||||
// This should only be defined for boolean properties.
|
||||
|
@ -996,7 +1006,7 @@ Model.prototype.outputTemplateData = function () {
|
|||
|
||||
// Go over all properties
|
||||
for ( var prop in allProps ) {
|
||||
if ( prop === 'deprecatedValue' || prop === 'name' ) {
|
||||
if ( prop === 'status' || prop === 'deprecatedValue' || prop === 'name' ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -1006,12 +1016,12 @@ Model.prototype.outputTemplateData = function () {
|
|||
// or if the current type is not undefined
|
||||
if (
|
||||
original.params[ key ] &&
|
||||
original.params[ key ].type !== 'unknown' &&
|
||||
this.params[ key ].type === 'unknown'
|
||||
original.params[ key ][ prop ] !== 'unknown' &&
|
||||
this.params[ key ][ prop ] === 'unknown'
|
||||
) {
|
||||
result.params[ name ][ prop ] = undefined;
|
||||
} else {
|
||||
result.params[ name ][ prop ] = this.params[ key ].type;
|
||||
result.params[ name ][ prop ] = this.params[ key ][ prop ];
|
||||
}
|
||||
break;
|
||||
case 'boolean':
|
||||
|
|
|
@ -860,7 +860,7 @@ Dialog.prototype.onParamPropertyInputChange = function ( propName, value ) {
|
|||
propInput = this.propInputs[ propName ],
|
||||
dependentField = prop.textValue;
|
||||
|
||||
if ( prop.type === 'select' ) {
|
||||
if ( propName === 'type' ) {
|
||||
var selected = propInput.getMenu().findSelectedItem();
|
||||
value = selected ? selected.getData() : prop.default;
|
||||
this.toggleSuggestedValues( value );
|
||||
|
@ -961,6 +961,38 @@ Dialog.prototype.getParameterDetails = function ( paramKey ) {
|
|||
// Update suggested values field visibility
|
||||
this.toggleSuggestedValues( paramData.type || allProps.type.default );
|
||||
|
||||
var status;
|
||||
// This accepts one of the three booleans only if the other two are false
|
||||
if ( paramData.deprecated ) {
|
||||
status = !paramData.required && !paramData.suggested && 'deprecated';
|
||||
} else if ( paramData.required ) {
|
||||
status = !paramData.deprecated && !paramData.suggested && 'required';
|
||||
} else if ( paramData.suggested ) {
|
||||
status = !paramData.deprecated && !paramData.required && 'suggested';
|
||||
} else {
|
||||
status = 'optional';
|
||||
}
|
||||
// Status is false at this point when more than one was set to true
|
||||
this.propFieldLayout.status.toggle( status );
|
||||
this.propFieldLayout.deprecated.toggle( !status );
|
||||
this.propFieldLayout.required.toggle( !status );
|
||||
this.propFieldLayout.suggested.toggle( !status );
|
||||
if ( !status ) {
|
||||
// No unambiguous status found, can't use the dropdown
|
||||
this.propInputs.status.getMenu().disconnect( this );
|
||||
} else {
|
||||
this.changeParamPropertyInput( paramKey, 'status', status );
|
||||
this.propInputs.status.getMenu().connect( this, {
|
||||
choose: function ( item ) {
|
||||
var selected = item.getData();
|
||||
// Forward selection from the dropdown to the hidden checkboxes, these get saved
|
||||
this.propInputs.deprecated.setSelected( selected === 'deprecated' );
|
||||
this.propInputs.required.setSelected( selected === 'required' );
|
||||
this.propInputs.suggested.setSelected( selected === 'suggested' );
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
this.startParameterInputTracking( paramData );
|
||||
};
|
||||
|
||||
|
@ -1136,6 +1168,10 @@ Dialog.prototype.createParamDetails = function () {
|
|||
data: prop.children[ i ],
|
||||
|
||||
// The following messages are used here:
|
||||
// * templatedata-doc-param-status-optional
|
||||
// * templatedata-doc-param-status-deprecated
|
||||
// * templatedata-doc-param-status-required
|
||||
// * templatedata-doc-param-status-suggested
|
||||
// * templatedata-doc-param-type-boolean, templatedata-doc-param-type-content,
|
||||
// * templatedata-doc-param-type-date, templatedata-doc-param-type-line,
|
||||
// * templatedata-doc-param-type-number, templatedata-doc-param-type-string,
|
||||
|
|
|
@ -328,6 +328,7 @@ QUnit.test( 'Validation tools', function ( assert ) {
|
|||
'suggestedvalues',
|
||||
'default',
|
||||
'autovalue',
|
||||
'status',
|
||||
'deprecated',
|
||||
'deprecatedValue',
|
||||
'required',
|
||||
|
|
Loading…
Reference in a new issue