diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b12df51..303f0798 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,17 @@ # CHANGELOG +## v4.44.0 + +At times we may need to disable some components when form is unlocked A good example is the tangy-gps component + +Add disabled property and readOnly property + +For example: `this.unlockFormResponses? this.formEl.unlock({disableComponents:['TANGY-GPS']}): null` + +Refs [Tangerine-Community/Tangerine#3703](https://github.com/Tangerine-Community/Tangerine/issues/3703) +Part of [Tangerine-Community/Tangerine#3719](https://github.com/Tangerine-Community/Tangerine/pull/3719) + + ## v4.43.0, v4.43.1, v4.43.2 __Tangerine Radio Blocks__ diff --git a/tangy-form-reducer.js b/tangy-form-reducer.js index 1d99eef5..f1576033 100644 --- a/tangy-form-reducer.js +++ b/tangy-form-reducer.js @@ -166,7 +166,11 @@ const tangyFormReducer = function (state = initialState, action) { } props.inputs = item.inputs.map(input => { const inputMeta = itemMeta.inputs.find(inputMeta => inputMeta.name === input.name) - return Object.assign({}, input, {disabled: inputMeta ? inputMeta.disabled : false}) + if(action.meta.disableComponents && action.meta.disableComponents.length > 0){ + inputMeta.disabled = action.meta.disableComponents.find(e => e.toLowerCase() === input.tagName.toLowerCase()) + inputMeta.readOnly = true + } + return Object.assign({}, input, {disabled: inputMeta ? !!inputMeta.disabled : false, readOnly: inputMeta.readOnly}) }) return Object.assign({}, item, itemMeta, props) }) diff --git a/tangy-form.js b/tangy-form.js index 6e6cf037..d769d529 100644 --- a/tangy-form.js +++ b/tangy-form.js @@ -810,8 +810,8 @@ export class TangyForm extends PolymerElement { } - unlock() { - const meta = this.getMeta() + unlock(options ={}) { + const meta = {...this.getMeta(), ...options} this.store.dispatch({ type: 'UNLOCK', meta