Mooeypoo has uploaded a new change for review. https://gerrit.wikimedia.org/r/133944
Change subject: Block object descriptions from edit ...................................................................... Block object descriptions from edit Some descriptions allow for language objects. For the moment, these should be blocked for editing so the original json string won't be corrupted. Change-Id: I9b13e2f3cfd805d382564e270484557567932a0f --- M TemplateData.php M i18n/en.json M i18n/qqq.json M modules/ext.templateDataGenerator.core.js 4 files changed, 31 insertions(+), 4 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/TemplateData refs/changes/44/133944/1 diff --git a/TemplateData.php b/TemplateData.php index acc34e5..3d076c9 100644 --- a/TemplateData.php +++ b/TemplateData.php @@ -105,6 +105,7 @@ 'templatedata-modal-table-param-type-string', 'templatedata-modal-table-param-type-undefined', 'templatedata-modal-table-param-type-user', + 'templatedata-modal-table-param-uneditablefield', 'templatedata-modal-title', 'templatedata-modal-title-templatedesc', 'templatedata-modal-title-templateparams', diff --git a/i18n/en.json b/i18n/en.json index c928f5f..bede97c 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -52,6 +52,7 @@ "templatedata-modal-table-param-type-string": "String", "templatedata-modal-table-param-type-undefined": "Undefined", "templatedata-modal-table-param-type-user": "User", + "templatedata-modal-table-param-uneditablefield": "Uneditable", "templatedata-modal-title": "Template documentation editor", "templatedata-modal-title-templatedesc": "Template description", "templatedata-modal-title-templateparams": "Template parameters" diff --git a/i18n/qqq.json b/i18n/qqq.json index 3d73e31..3cb1211 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -53,6 +53,7 @@ "templatedata-modal-table-param-type-string": "A possible parameter type: String", "templatedata-modal-table-param-type-undefined": "A possible parameter type: Undefined", "templatedata-modal-table-param-type-user": "A possible parameter type: User", + "templatedata-modal-table-param-uneditablefield": "Placeholder text notifying the user the field is uneditable", "templatedata-modal-title": "Title of the modal popup.", "templatedata-modal-title-templatedesc": "The title for the template description textbox", "templatedata-modal-title-templateparams": "The title for the template parameters table" diff --git a/modules/ext.templateDataGenerator.core.js b/modules/ext.templateDataGenerator.core.js index 0bc84f8..8be668e 100644 --- a/modules/ext.templateDataGenerator.core.js +++ b/modules/ext.templateDataGenerator.core.js @@ -278,11 +278,22 @@ paramsJson.params[paramid] && paramsJson.params[paramid][paramAttr] ) { - // make sure we set the value correctly based on the DOM element - if ( paramAttrObj[paramAttr].prop( 'type' ) === 'checkbox' ) { - paramAttrObj[paramAttr].prop( 'checked', paramsJson.params[paramid][paramAttr] ); + // Deal with 'description' being an object + if ( paramAttr === 'description' ) { + if ( $.isPlainObject( paramsJson.params[paramid][paramAttr] ) ) { + paramAttrObj[paramAttr].prop( 'disabled', true ); + paramAttrObj[paramAttr].data( 'isObject', true ); + paramAttrObj[paramAttr].val( '[ ' + mw.msg( 'templatedata-modal-table-param-uneditablefield' ) + ' ]' ); + } else { + paramAttrObj[paramAttr].val( paramsJson.params[paramid][paramAttr] ); + } } else { - paramAttrObj[paramAttr].val( paramsJson.params[paramid][paramAttr] ); + // make sure we set the value correctly based on the DOM element + if ( paramAttrObj[paramAttr].prop( 'type' ) === 'checkbox' ) { + paramAttrObj[paramAttr].prop( 'checked', paramsJson.params[paramid][paramAttr] ); + } else { + paramAttrObj[paramAttr].val( paramsJson.params[paramid][paramAttr] ); + } } } @@ -555,6 +566,19 @@ } break; case 'description': + // Only update if the description isn't an object + if ( !$domEl.data( 'isObject' ) ) { + newValue = $domEl.val(); + if ( paramObj[paramProp] !== newValue ) { + if ( !newValue || newValue.length === 0 ) { + delete paramObj[paramProp]; + continue; + } else { + paramObj[paramProp] = newValue; + } + } + } + break; case 'default': case 'label': newValue = $domEl.val(); -- To view, visit https://gerrit.wikimedia.org/r/133944 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I9b13e2f3cfd805d382564e270484557567932a0f Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/TemplateData Gerrit-Branch: master Gerrit-Owner: Mooeypoo <mor...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits