Closed
Description
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.
- Implement tools to work on a layout as a hierarchical structure (respecting repeating group rows, etc), so the expression can be evaluated in the context of a layout node (finding the closest component references when looking up another component id - which could be inside the same repeating group row, the one above, etc).
- Implement support for evaluating recursive layout expressions
- Implement a
useLayoutExpression()
hook that can resolve layout expressions anywhere - Test the above hook in a unit-test
- Use resolved layout expressions (for the
required
property) when validating a group usingtriggers: ['validation']
- Validate all expressions to make sure they are valid when loading the layout (generate error messages if not)
- Implement support for pre-processing compact lisp-like expressions into full/verbose expressions (do this once in the fetchLayout saga, along with the initial layout expression validation)
- Evaluate expressions in sagas to make sure we still use and populate the
hiddenFields
state even when using layout expressions.- This could probably benefit from some index, optimizing the code so that we don't have to iterate the entire layout for every form item change - only for those that affects layout expressions.
- ~~[ ] Optimize the code so layout expressions (and especially the hierarchical layout functions) don't run when we don't absolutely need them to. Memoization should go a long way. ~~ I think I'm deciding against this for now, as it seems to be fast enough (optimizations now might be premature)
- Make sure expression results are used in places where the properties are read. This means expressions needs to be resolved when performing empty field validation (for expressions in the the
required
property), etc. - Investigate changes/increases in time and memory spent type-checking after these changes. There are quite a few new (and slow/complex) types added in the branch, and during development node has sometimes crashed with out-of-memory errors. Make sure type-checking for happy-path changes does not change significantly for other developers.
- Support hiding entire pages/layouts
- Clean up code to avoid complexity warnings from eslint
- Search for added TODOs in the code and fix them
- Return default value when top-level expression returns
null
- Expressions: Implement Cypress test(s) #620
Metadata
Metadata
Assignees
Type
Projects
Status
✅ Done