Conditional elements display
Jump to navigation
Jump to search
Features Added
- Added new setting in the builder to enter conditional display formula
- Extended the file structure to allow adding new trait types, following a class-based code structure.
- Added new custom trait type: codeblock
- Assigned a new trait "hide-if" to all components, when the Portal Builder has finished rendering
Testing and Validation
- Create a new portal page
- Add any element
- Go to settings/traits (second tab of the right-side panel)
- The codeblock 'Hide if' expects an inner function body Example:
return 1 == 1;
orreturn {{currentUser.Id}} == null
- Save the page & preview
- The condition will be evaluated and if the result is 'true', the element will be hidden.
Additional Information
Added validation logic, which handles custom expressions {{xxxx}} by converting them to a value, so that they wouldn't trigger a falsely invalid function body.
Examples
To show an element only when the user is signed in, use !!window?.contactUser?.Id
(e.g. to hide/show login/logout buttons)
To show an element only when a user is NOT signed in, use !window?.contactUser?.Id
(e.g. to hide/show login/logout buttons)