Wizard sequencer -- Examples


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);

Simple modification to the previous example gives another workflow:

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
    ]

Longer cycles

This dialog adds longer cycle to the above dialog.

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
    ]
];
As stated in the above example, the clicks [Next], [Expert], [Next], [OK], [Back] leads back to the "begin" dialog. (And not to the "expert2" !)

Special or void dialogs

This is an example of the special widget. The [Decide] dialog is removed from the flow. It represents either popup or a special function which doesn't have any gui.

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
    ]
];
The true means that this function is special.

More advanced examples will follow