-
Notifications
You must be signed in to change notification settings - Fork 32
Logic/expressions in layout #355
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Note: This comment is outdated. Futher talk about the expression format can be found in #8774In #220 the following syntax has been proposed for toggling hidden fields dynamically via layout expressions: "hidden": {
"function": "equals",
"args": [
{
"dataModel": "MyModel.Group.Field"
},
{
"component": "my-input-field"
}
]
} Along with a simpler DSL variant: "hidden": {
"expr": "dataModel(MyModel.Group.Field) == component(my-input-field)"
} In #61 we'll need an implementation where the text resource for the group edit button changes based on some expression, which requires some extensions to this syntax (as the output is not a boolean true/false, but string constants). This might be an alternative for non-boolean values: "textResourceBindings": {
"edit_label": {
"function": "equals",
"args": [
{
"dataModel": "MyModel.Group.Field.IsEditable"
},
"isEditable"
],
"mapping": {
"true": "edit",
"false": "Inspect non-editable values"
}
}
} Along with a simpler DSL variant: "textResourceBindings": {
"edit_label": {
"expr": "dataModel(MyModel.Group.Field.IsEditable) == true",
"mapping": {
"true": "edit",
"false": "Inspect non-editable values"
}
}
} This also leads to the obvious, where the text resource key is fetched directly from the data model without mapping the expression result via a boolean: "textResourceBindings": {
"edit_label": {
"expr": "dataModel(MyModel.Group.Field.EditLabel)"
}
} Which, when decoded to an expanded expression could perhaps equal: "textResourceBindings": {
"edit_label": {
"function": "lookup",
"args": [
{
"dataModel": "MyModel.Group.Field.EditLabel"
}
]
}
} This comment is me thinking out loud. I think I'll go forwards with this solution (adding a This means you could also map the lookup if your data model values are not lookup keys already: "textResourceBindings": {
"edit_label": {
"expr": "dataModel(MyModel.Group.Field.EditLabel)",
"mapping": {
"null": "edit",
"customLabel": "Inspect non-editable values"
}
}
} |
Automatically closed when merged, but testing (and cypress tests) remain here. |
Closing as done. This has already seen quite some testing, even though Cypress tests are missing as of now. |
Description
Several issues require some form of logic/dynamics in layout files. Along with the solution proposed in #220, we can start implementing this form for layout logic (in issues like #61 and #64), without introducing breaking changes (as in #220).
This issue tracks the implementation of layout expressions in frontend. The project itself is tracked in more detail here.
In scope
New layout logic, as described much more clearly in #220
Out of scope
Breaking changes 😉
Tasks
Development is underway in the feat/layout-expressions branch.
useLayoutExpression()
hook that can resolve layout expressions anywhererequired
property) when validating a group usingtriggers: ['validation']
hiddenFields
state even when using layout expressions.required
property), etc.null
The text was updated successfully, but these errors were encountered: