Logic for disable fields (#103)

* Feature: Disabled fields

* disable field for rating

* logic for disable fields

---------

Co-authored-by: Julien Nahum <julien@nahum.net>
This commit is contained in:
Chirag Chhatrala
2023-03-22 20:20:29 +05:30
committed by GitHub
parent 9b3f5ddbdf
commit 8d11d2c976
4 changed files with 32 additions and 3 deletions

View File

@@ -40,6 +40,21 @@ class FormLogicPropertyResolver {
return this.property.required
}
}
isDisabled () {
if (!this.logic) {
return this.property.disabled
}
const conditionsMet = this.conditionsMet(this.logic.conditions, this.formData)
if (conditionsMet && this.property.disabled && this.logic.actions.length > 0 && this.logic.actions.includes('enable-block')) {
return false
} else if (conditionsMet && !this.property.disabled && this.logic.actions.length > 0 && this.logic.actions.includes('disable-block')) {
return true
} else {
return this.property.disabled
}
}
}
export default FormLogicPropertyResolver