forked from patternfly/angular-patternfly
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwizard-substep.component.js
More file actions
113 lines (101 loc) · 3.95 KB
/
Copy pathwizard-substep.component.js
File metadata and controls
113 lines (101 loc) · 3.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/** @ngdoc directive
* @name patternfly.wizard.directive:pfWizardSubstep
* @restrict E
*
* @description
* Component for rendering a Wizard substep. Each substep must be a child of a pf-wizardstep in a pf-wizard directive.
*
* @param {string} stepTitle The step title displayed in the header and used for the review screen when displayed
* @param {string} stepId Sets the text identifier of the step
* @param {number} stepPriority This sets the priority of this wizard step relative to other wizard steps. They should be numbered sequentially in the order they should be viewed.
* @param {boolean=} nextEnabled Sets whether the next button should be enabled when this step is first displayed
* @param {boolean=} prevEnabled Sets whether the back button should be enabled when this step is first displayed
* @param {boolean=} wzDisabled Hides the step when set to True
* @param {boolean} okToNavAway Sets whether or not it's ok for the user to leave this page
* @param {boolean=} allowClickNav Sets whether the user can click on the numeric step indicators to navigate directly to this step
* @param {string=} description The step description
* @param {object} wizardData Data passed to the step that is shared by the entire wizard
* @param {function()=} onShow The function called when the wizard shows this step
* @param {object=} focusSelectors Array of selectors to be used (in the order given) to find the initial focus component for the page
* @param {boolean=} showReviewDetails Indicators whether the review information should be expanded by default when the review step is reached
* @param {string=} reviewTemplate The template that should be used for the review details screen
*/
angular.module('patternfly.wizard').component('pfWizardSubstep', {
transclude: true,
bindings: {
stepTitle: '@',
stepId: '@',
stepPriority: '@',
nextEnabled: '<?',
prevEnabled: '<?',
okToNavAway: '<?',
allowClickNav: '<?',
disabled: '@?wzDisabled',
description: '@',
wizardData: '=',
onShow: '=?',
focusSelectors: '<?',
showReviewDetails: '@?',
reviewTemplate: '@?'
},
templateUrl: 'wizard/wizard-substep.html',
controller: function ($scope) {
'use strict';
var ctrl = this;
ctrl.$onInit = function () {
var findWizardStep = function (scope) {
var wizardStep;
if (scope) {
if (angular.isDefined(scope.wizardStep)) {
wizardStep = scope.wizardStep;
} else {
wizardStep = findWizardStep(scope.$parent);
}
}
return wizardStep;
};
ctrl.step = findWizardStep($scope);
if (angular.isUndefined(ctrl.nextEnabled)) {
ctrl.nextEnabled = true;
}
if (angular.isUndefined(ctrl.prevEnabled)) {
ctrl.prevEnabled = true;
}
if (angular.isUndefined(ctrl.showReviewDetails)) {
ctrl.showReviewDetails = false;
}
if (angular.isUndefined(ctrl.stepPriority)) {
ctrl.stepPriority = 999;
} else {
ctrl.stepPriority = parseInt(ctrl.stepPriority);
}
if (angular.isUndefined(ctrl.okToNavAway)) {
ctrl.okToNavAway = true;
}
if (angular.isUndefined(ctrl.allowClickNav)) {
ctrl.allowClickNav = true;
}
ctrl.step.okToNavAway = ctrl.okToNavAway;
ctrl.step.allowClickNav = ctrl.allowClickNav;
ctrl.title = ctrl.stepTitle;
ctrl.step.addStep(ctrl);
};
ctrl.$onChanges = function (changesObj) {
if (!ctrl.step) {
return;
}
if (changesObj.okToNavAway) {
ctrl.step.okToNavAway = changesObj.okToNavAway.currentValue;
}
if (changesObj.allowClickNav) {
ctrl.step.allowClickNav = changesObj.allowClickNav.currentValue;
}
};
ctrl.isNextEnabled = function () {
return angular.isUndefined(ctrl.nextEnabled) || ctrl.nextEnabled;
};
ctrl.isPrevEnabled = function () {
return angular.isUndefined(ctrl.prevEnabled) || ctrl.prevEnabled;
};
}
});