<breadcrumbAction/>
Description
Added in release 1.57.x is the breadcrumb action. Breadcrumb actions are similar to regular actions, with the difference being that their main function should be navigational. Breadcrumb actions are place in a specific location on the view and should represent the navigational structure of an applications views. The label is specified as a key to a lang file entry and is required. Another required attribute is the action, which should resolve with a DSL_VIEW
. Visibility bindings, appearance bindings, Tooltips & confirm dialog are also supported.
Breadcrumb actions also allow for a dedicated back button which is declared by using the backAction='true'
attribute. If not specified, the default value of backAction='false'
is assumed and the back button will be disabled.
Note: Only one back action may be declared per view.
Example
<breadcrumbAction label="button.back" action="backAction" backAction="true"/>
<breadcrumbAction label="view_heading.breadcrumb_view_1" action="goToView1">
<visible function="showView1"/>
</breadcrumbAction>
<breadcrumbAction label="view_heading.breadcrumb_view_2" action="goToView2">
<visible function="showView2"/>
</breadcrumbAction>
<breadcrumbAction label="view_heading.breadcrumb_view_3" action="goToView3">
<visible function="showView3"/>
</breadcrumbAction>
<breadcrumbAction label="view_heading.breadcrumb_view_4" action="goToView4">
<visible function="showView4"/>
<appearance function="disabledAppearance"/>
</breadcrumbAction>
unit BreadcrumbDemoUnit;
// Mock fields for our breadcrumb flow views
string multiView1a;
string multiView2a;
string multiView3a;
string multiView4a;
string multiView1b;
string multiView2b;
string multiView3b;
string multiView4b;
// For us to keep track of the breadcrumbs
Breadcrumb selectedBreadcrumb;
Breadcrumb[] allBreadCrumbs;
Breadcrumb[] currentBreadCrumbs;
// Current navigation state and available views
DSL_VIEWS currentView;
int currentViewIndex;
DSL_VIEWS[] views;
bool inited;
int maxViewIndex;
// The init constructs our available views,
// breadcrumbs and initial breadcrumbs to display
void init() {
if(inited == null || inited == false) {
initMockFields();
currentView = DSL_VIEWS.BreadcrumbDemoMultiView1;
currentViewIndex = 0;
maxViewIndex = 0;
// The destination views for our flow
views.clear();
views.append(DSL_VIEWS.BreadcrumbDemoMultiView1);
views.append(DSL_VIEWS.BreadcrumbDemoMultiView2);
views.append(DSL_VIEWS.BreadcrumbDemoMultiView3);
views.append(DSL_VIEWS.BreadcrumbDemoMultiView4);
// Breadcrumbs matching the destination views above
Breadcrumb breadCrumb1 = createBreadCrumb("View 1", null, false, null, null, false);
Breadcrumb breadCrumb2 = createBreadCrumb("View 2", null, false, null, null, false);
Breadcrumb breadCrumb3 = createBreadCrumb("View 3", null, false, null, null, false);
Breadcrumb breadCrumb4 = createBreadCrumb("View 4", null, false, null, null, false);
allBreadCrumbs.clear();
allBreadCrumbs.append(breadCrumb1);
allBreadCrumbs.append(breadCrumb2);
allBreadCrumbs.append(breadCrumb3);
allBreadCrumbs.append(breadCrumb4);
// Breadcrumbs to display on init
currentBreadCrumbs.clear();
currentBreadCrumbs.append(breadCrumb1);
inited = true;
}
}
void initMockFields() {
multiView1a = null;
multiView2a = null;
multiView3a = null;
multiView4a = null;
multiView1b = null;
multiView2b = null;
multiView3b = null;
multiView4b = null;
}
Breadcrumb[] getCurrentBreadCrumbs() {
return currentBreadCrumbs;
}
DSL_VIEWS proceedAction() {
// Leave a breadcrumb if we go to the view for the first time
if(currentViewIndex >= currentBreadCrumbs.length() - 1) {
currentBreadCrumbs.append(allBreadCrumbs.get(currentViewIndex + 1));
}
// Find the next view and go to it
setViewIndex(currentViewIndex + 1);
DSL_VIEWS nextView = views.get(currentViewIndex);
currentView = nextView;
return currentView;
}
// Find the previous view and go to it
DSL_VIEWS backAction() {
setViewIndex(currentViewIndex - 1);
DSL_VIEWS prevView = views.get(currentViewIndex);
currentView = prevView;
return currentView;
}
// Go to the view associated with the selected breadcrumb
DSL_VIEWS breadcrumbAction() {
int index = findIndexForSelectedBreadcrumb();
setViewIndex(index);
Mez:log(currentViewIndex);
currentView = views.get(currentViewIndex);
return currentView;
}
// Finish the flow and reset
DSL_VIEWS finishAction() {
inited = false;
return views.get(0);
}
// Utility method: Find the view and breadcrumb index from the selected breadcrumb
int findIndexForSelectedBreadcrumb() {
for(int i = 0; i < allBreadCrumbs.length(); i++) {
Breadcrumb current = allBreadCrumbs.get(i);
if(selectedBreadcrumb.label == current.label) {
return i;
}
}
}
// Utility method: Create a breadcrumb
Breadcrumb createBreadCrumb(string label, string tooltip, bool requiresConfirm, string confirmSubj, string confirmBody, bool isBack) {
Breadcrumb breadCrumb = Breadcrumb:new();
breadCrumb.label = label;
breadCrumb.tooltip = tooltip;
breadCrumb.requiresConfirmation = requiresConfirm;
breadCrumb.confirmationMessageSubject = confirmSubj;
breadCrumb.confirmationMessageBody = confirmBody;
breadCrumb.isBack = isBack;
return breadCrumb;
}
DSL_VIEWS goToView1() {
return navigateToViewForIndex(0);
}
DSL_VIEWS goToView2() {
return navigateToViewForIndex(1);
}
DSL_VIEWS goToView3() {
return navigateToViewForIndex(2);
}
DSL_VIEWS goToView4() {
return navigateToViewForIndex(3);
}
DSL_VIEWS navigateToViewForIndex(int index) {
setViewIndex(index);
currentView = views.get(index);
return currentView;
}
bool showView1() {
return true;
}
bool showView2() {
return showViewBreadcrumb(1);
}
bool showView3() {
return showViewBreadcrumb(2);
}
bool showView4() {
return showViewBreadcrumb(3);
}
bool showViewBreadcrumb(int viewIndex) {
if(currentViewIndex >= viewIndex) {
return true;
}
return false;
}
void setViewIndex(int index) {
currentViewIndex = index;
if(currentViewIndex > maxViewIndex) {
maxViewIndex = currentViewIndex;
}
}
DSL_APPEARANCE disabledAppearance() {
return DSL_APPEARANCE.Disable;
}
Â