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:
15
resources/js/forms/FormLogicPropertyResolver.js
vendored
15
resources/js/forms/FormLogicPropertyResolver.js
vendored
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user