ExpertBox.com is a knowledge automation platform that is used by experts from different domains to create constructs of systematic conversations that converse with users, for free or for a fee.
[ ] Add optional boolean isSwitch attribute to Branch, Leaf and Expression ComponentTypes.
[ ] Add optional switchLink attribute to Branch ComponentType, only show it in forms if isSwitch is set.
[ ] Add optional array switchCases attribute to Branch ComponentType, when switchLink is a Choice component, the cases are shown as dropdown list, else as an array of text fields.
[ ] Create Add Switch in Designer Action Button.
[ ] Show autoform modal of type meteor method when the user clicks on Add Switch in the Action Menu. See example form for deployButton.
[ ] In modal form, populate doc with hidden prop parent, which is the id of the selected component.
[ ] In modal form, ask user to choose Pivot from any prior input control or expression.
[ ] In modal form, if Pivot is a Choice, ask user to choose cases from the choice options.
[ ] In modal form, if Pivot is not a Choice, ask user to specify case values.
[ ] In modal form, ask user if a default case is required.
[ ] In components API, add function to handle adding of components.
[ ] Add meteor client/server method component-add which calls the API function.
[ ] In ComponentType of Branch component, define design.add function, which will be called by the API when adding a component of this type. This will later be converted to an OO structure.
[ ] Add autoform hook to call the method component-add on submission of the form.
[ ] In add function of Select ComponentType, create a branch with isSwitch set to true, with parent from form data.
[ ] In add function of Select ComponentType, create a leaf per case and set isSwitch. Name the leaf to Text.to.camelCase(`is-${Case}-leaf`).
[ ] In add function of Select ComponentType, per leaf, route to and add the the link selected in the form.
[ ] In add function of Select ComponentType, per leaf, add an expression that checks the case matches the value of the link, and mark the expression as being part of a switch. Name the expression to Text.to.camelCase(`is-${Case}-expression`). Important, use == comparator to ensure automatic type conversion between value of the link and the specified case values.
[ ] In designer, do not show expressions that are marked as being part of a switch.
[ ] In designer, do not show edit action for leaves that are marked as being part of a switch.
[ ] When the user edits a branch and sets isSwith to false, unset isSwitch in all Leaves and their Expressions.
Background
It is a very frequent use case when designing a construct to want the user to select an option from a choice and then do something directly based on this choice. For example a menu structure.
This functionality is currently possible using a branch, however, branches may appear intimidating due to the leaves and expressions used to users without software backgrounds. For this reason, a simplified branch is being introduced, the Switch.
While a Branch can be compared with a JavaScript if then else then if chain with expressions, a Switch is modeled on JavaScript switch statement, the decision pivots on a single point instead of multiple expressions.
Branch Component processing, expressed in JavaScript
for (let leaf of branch.leaves) {
if (leaf.expression) {
process(leafA.component)
break;
}
}
A Switch is just a Branch with Managed Leaves with Managed Expressions with leaf expressions not being shown to the user in the designer. A switch must also be able to convert to a Branch, for when the user learns the logic is not a simple switch and needs multiple expressions.
It is not simple to convert Branches to switches, as the complexity of Branches is greater than Switches, and logic may be lost during simplification, and it is difficult to map which expressions should be replaced with which managed expressions. For this reason Branch to Switch is a one-way conversion. If you want to make a Switch from a Branch, create a new Switch and drag the Leaf Components one by one into the switch as applicable.
When a Switch is created and linked to a Choice, each Choice option becomes a Leaf with an Expression with a script return choice.value === option.value, and a default leaf if the user wants one.
When a Switch is created and linked to a Question, the user needs to supply the cases to compare the value to, because there could be an excessive amount of valid combinations (such as an alphabetic formatted question with a max length of 5 has more than 11 million possible answers).
How it must thus work, for example, if the question.value is a number between 1 and 5, you might only want cases for 2 and 4, and ignore the rest or having a default to catch them.
Todo:
Text.to.camelCase(`is-${Case}-leaf`)
.Text.to.camelCase(`is-${Case}-expression`)
. Important, use==
comparator to ensure automatic type conversion between value of the link and the specified case values.Background
It is a very frequent use case when designing a construct to want the user to select an option from a choice and then do something directly based on this choice. For example a menu structure.
This functionality is currently possible using a branch, however, branches may appear intimidating due to the leaves and expressions used to users without software backgrounds. For this reason, a simplified branch is being introduced, the Switch.
While a Branch can be compared with a JavaScript if then else then if chain with expressions, a Switch is modeled on JavaScript switch statement, the decision pivots on a single point instead of multiple expressions.
Branch Component processing, expressed in JavaScript
A Switch is just a Branch with Managed Leaves with Managed Expressions with leaf expressions not being shown to the user in the designer. A switch must also be able to convert to a Branch, for when the user learns the logic is not a simple switch and needs multiple expressions.
It is not simple to convert Branches to switches, as the complexity of Branches is greater than Switches, and logic may be lost during simplification, and it is difficult to map which expressions should be replaced with which managed expressions. For this reason Branch to Switch is a one-way conversion. If you want to make a Switch from a Branch, create a new Switch and drag the Leaf Components one by one into the switch as applicable.
When a Switch is created and linked to a Choice, each Choice option becomes a Leaf with an Expression with a script
return choice.value === option.value
, and a default leaf if the user wants one.When a Switch is created and linked to a Question, the user needs to supply the cases to compare the value to, because there could be an excessive amount of valid combinations (such as an alphabetic formatted question with a max length of 5 has more than 11 million possible answers).
How it must thus work, for example, if the question.value is a number between 1 and 5, you might only want cases for 2 and 4, and ignore the rest or having a default to catch them.