diff --git a/extension.json b/extension.json index 71cddff0..511f1447 100644 --- a/extension.json +++ b/extension.json @@ -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", diff --git a/i18n/en.json b/i18n/en.json index fe218c7e..2755dc15 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -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)", diff --git a/i18n/qqq.json b/i18n/qqq.json index 89ff7000..92fb090d 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -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}}", diff --git a/modules/ext.templateDataGenerator.data/Model.js b/modules/ext.templateDataGenerator.data/Model.js index 81a2d93a..2fe04d23 100644 --- a/modules/ext.templateDataGenerator.data/Model.js +++ b/modules/ext.templateDataGenerator.data/Model.js @@ -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': diff --git a/modules/ext.templateDataGenerator.editTemplatePage/Dialog.js b/modules/ext.templateDataGenerator.editTemplatePage/Dialog.js index 9140858a..eb4ad6dc 100644 --- a/modules/ext.templateDataGenerator.editTemplatePage/Dialog.js +++ b/modules/ext.templateDataGenerator.editTemplatePage/Dialog.js @@ -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, diff --git a/tests/qunit/ext.templateData.tests.js b/tests/qunit/ext.templateData.tests.js index 0640f4e1..edcffbb1 100644 --- a/tests/qunit/ext.templateData.tests.js +++ b/tests/qunit/ext.templateData.tests.js @@ -328,6 +328,7 @@ QUnit.test( 'Validation tools', function ( assert ) { 'suggestedvalues', 'default', 'autovalue', + 'status', 'deprecated', 'deprecatedValue', 'required',