Examples
For simplicity, all examples use common aliases definition and user
interface dialogs are done via unified GUI function. This all is defined
in the file examples.ycp, which is
included by all examples.
Simple
This example shows, how the simple workflow is defined and run.
The workflow looks like this:
map Aliases = $[ "begin" : ``(BeginDialog()), "end" : ``(EndDialog()), "config" : ``(ConfigDialog()), "details" : ``(DetailsDialog()) ]; map Sequence = $[ "ws_start" : "begin", "begin" : $[ `next : "config" ], "config" : $[ `next : "end", `details : "details" ], "details" : $[ `next : "end" ], "end" : $[ `finish : `ws_finish ] ]; any result = Sequencer::Run(Aliases,Sequence); |
The only thing we must do to make this change is to update the "details" map:
"details" : $[ `ok : "config" ], |
The back arrow from "details" is blue because it closes the cycle. It means that it is not part of the wizard flow any more, as it is a special case. If the user clicks onto [Details] and [OK], he don't want with back to go through the whole branch back.
So, in the "config" dialog, after the clicks [Details], [OK] and [Back],
the current dialog should be the "begin", not "details".
Deeper nesting
This example shows the deeper nesting of dialogs.
There are more ways of reaching some dialogs only for demonstration
of abilities of WS. In reality, there should be only one way.
map Aliases = $[ "begin" : ``(BeginDialog()), "end" : ``(EndDialog()), "config" : ``(ConfigDialog()), "details" : ``(DetailsDialog()), "superdetails" : ``(SuperDetailsDialog()) ]; map Sequence = $[ "ws_start" : "begin", "begin" : $[ `next : "config" ], "config" : $[ `next : "end", `details : "details" ], "details" : $[ `next : "end", `details: "superdetails", `ok : "config" ], "superdetails" : $[ `next: "end", `ok: "details" ], "end" : $[ `finish : `ws_finish ] |
map Sequence = $[ "ws_start" : "begin", "begin" : $[ `next : "config" ], "config" : $[ `next : "end", `details : "details", `expert: "expert" ], "details" : $[ `next : "end", `details: "superdetails", `ok : "config" ], "superdetails" : $[ `next: "end", `ok: "details" ], "expert" : $[ `next : "expert2" ], "expert2" : $[ `next : "end", `ok : "config" ], "end" : $[ `finish : `ws_finish ] ]; |
map Aliases = $[ "begin" : ``(BeginDialog()), "end" : ``(EndDialog()), "config" : ``(ConfigDialog()), "decide" : [ ``(Decide()), true ] ]; map Sequence = $[ "ws_start" : "begin", "begin" : $[ `next : "decide" ], "config" : $[ `next : "end" ], "decide" : $[ `no : "end", `yes: "config" ], "end" : $[ `finish : `ws_finish ] ]; |