Conditional elements display: Difference between revisions
Jump to navigation
Jump to search
(Created page with "==== 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...") |
No edit summary |
||
Line 17: | Line 17: | ||
==== Additional Information ==== | ==== Additional Information ==== | ||
Added validation logic, which handles custom expressions <nowiki>{{xxxx}}</nowiki> by converting them to a value, so that they wouldn't trigger a falsely invalid function body. | Added validation logic, which handles custom expressions <nowiki>{{xxxx}}</nowiki> 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 <code>!!window?.contactUser?.Id</code> (e.g. to hide/show login/logout buttons) | |||
To show an element only when a user is NOT signed in, use <code>!window?.contactUser?.Id</code> (e.g. to hide/show login/logout buttons) | |||
[[Category:3B Onboarding]] | [[Category:3B Onboarding]] | ||
[[Category:3B Portals]] | [[Category:3B Portals]] |
Latest revision as of 10:27, 7 April 2025
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)