Complex Switch Handler
It is used when we need to perform some actions both before and after switching tabs or steps.
Generally, Broker portals are not guided flows as the brokers are more trained on the system. And in such a system if the broker is making multiple changes on multiple pages (tabs or steps) then there is a chance that some of the changes may go unsaved. To solve this problem, an idea is to autosave the current tab or step changes when moving from the current tab or step to another. To accommodate this use case we can use the complex Switch handler.
Syntax
"switch" : { "before" : {….} "condition" : "", "after" : {….} }
The above syntax contains the following fields:
- Before handler: Configure anything that should happen before switching to a new tab or step.
- Condition: Configure an expression that evaluates to a boolean. This indicates when the after-handler trigger should happen.
- After handler: Configure anything that should happen after switching to a new tab or step.
The beforeevent handler gets executed when the user clicks on any other step or tab and the conditionindicates when to execute the afterevent handler.
Complex Switch Handler for Tabs
- Each container should have a unique flag mentioned in General Handler.
- The container should pass the same flag to the respective save action.
- The Child Container should have a Master action which should contain all the assignments mentioned in General Handler.
- The Child Container flag should be set under the parent Container General handler.
- The Conditional assignment is Mandatory.
Complex Switch Handler for Steps
- Each container should have a unique flag mentioned in General Handler.
- The container should pass the same flag to the respective save action.
- The Child Container should have a Master action which should contain all the assignments mentioned in General Handler.
- The Child Container flag should be set under the parent Container General handler.
- The Conditional assignment is Mandatory.
- When a user uses Action (Next or Back button) that time we need to mention all the assignments under respective action.
- When a user uses Stepper Navigability, the user has to mention all the assignments under General Handler.
- When a user uses Action (Next or Back button) as well as Stepper Navigability, the user has to mention all the assignments under respective action and also under General Handler.
Simple Switch Handler Example
In the following example, we have a tabs actor named "TabsActor" with multiple tabs. Out of these tabs, only the first tab has an input form and a save action, while other tabs are just read-only data views. When the user makes some changes in the first tab and moves to another tab, the configured switch handler takes care of saving data automatically. And only when the first tab data is saved successfully the user moves to another tab. In case of errors, the user must correct the issues before proceeding to other tabs.
"switch": { "before": { "assignments": [{ "field": "$global.attr(triggeredSwitchEvt);", "value": true }], "actions": [{ "condition": "$nav(TabsActor).appearance(current); == 0", "actorName": "RangeFieldActor", "name": "save" },{ "condition": "$nav(TabsActor).appearance(current); != 0", "name": "setProceedToNextStepOrTabFlag" }] },
"after": { "assignments": [{ "field": "$global.attr(proceedToNextStepOrTab);", "value": false },{ "field": "$global.attr(triggeredSwitchEvt);", "value": false }], "actions": [{ "name": "showConfirmationAfterSwitch" }] }, "condition": " $global.attr(triggeredSwitchEvt); and $global.attr(proceedToNextStepOrTab);" } }