Skip to content

Commit

Permalink
Merge pull request #413 from Tangerine-Community/disable-specific-com…
Browse files Browse the repository at this point in the history
…ponents-when-form-unlocked

feat(tangy-form): Disable specific components when form is unlocked
  • Loading branch information
esurface authored Jul 18, 2024
2 parents e03b0f9 + 34b9df5 commit ea67fa4
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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__
Expand Down
6 changes: 5 additions & 1 deletion tangy-form-reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
Expand Down
4 changes: 2 additions & 2 deletions tangy-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ea67fa4

Please sign in to comment.