Skip to content

Commit 3873612

Browse files
Merge pull request #645 from jeff-phillips-18/wizard
feature(wizard): deprecate title parameter, simplify buttons
2 parents 64bad5a + bd4056b commit 3873612

File tree

9 files changed

+372
-368
lines changed

9 files changed

+372
-368
lines changed

src/wizard/examples/wizard.js

Lines changed: 316 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,316 @@
1+
/**
2+
* @ngdoc directive
3+
* @name patternfly.wizard.component:pfWizard
4+
* @restrict E
5+
*
6+
* @description
7+
* Component for rendering a Wizard modal. Each wizard dynamically creates the step navigation both in the header and the left-hand side based on nested steps.
8+
* Use pf-wizard-step to define individual steps within a wizard and pf-wizard-substep to define portions of pf-wizard-steps if so desired. For instance, Step one can have two substeps - 1A and 1B when it is logical to group those together.
9+
* <br /><br />
10+
* The basic structure should be:
11+
* <pre>
12+
* <pf-wizard>
13+
* <pf-wizard-step>
14+
* <pf-wizard-substep><!-- content here --></pf-wizard-substep>
15+
* <pf-wizard-substep><!-- content here --></pf-wizard-substep>
16+
* </pf-wizard-step>
17+
* <pf-wizard-step><!-- additional configuration can be added here with substeps if desired --></pf-wizard-step>
18+
* <pf-wizard-step><!-- review steps and final command here --></pf-wizard-step>
19+
* </pf-wizard>
20+
* </pre>
21+
*
22+
* @param {string} wizardTitle The wizard title displayed in the header
23+
* @param {boolean=} hideIndicators Hides the step indicators in the header of the wizard
24+
* @param {boolean=} activeStepTitleOnly Shows the title only for the active step in the step indicators, optional, default is false.
25+
* @param {boolean=} hideSidebar Hides page navigation sidebar on the wizard pages
26+
* @param {boolean=} hideHeader Optional value to hide the title bar. Default is false.
27+
* @param {boolean=} hideBackButton Optional value to hide the back button, useful in 2 step wizards. Default is false.
28+
* @param {string=} stepClass Optional CSS class to be given to the steps page container. Used for the sidebar panel as well unless a sidebarClass is provided.
29+
* @param {string=} sidebarClass Optional CSS class to be give to the sidebar panel. Only used if the stepClass is also provided.
30+
* @param {string=} contentHeight The height the wizard content should be set to. This is used ONLY if the stepClass is not given. This defaults to 300px if the property is not supplied.
31+
* @param {boolean=} hideIndicators Hides the step indicators in the header of the wizard
32+
* @param {string=} currentStep The current step can be changed externally - this is the title of the step to switch the wizard to
33+
* @param {string=} cancelTitle The text to display on the cancel button
34+
* @param {string=} backTitle The text to display on the back button
35+
* @param {string=} nextTitle The text to display on the next button
36+
* @param {function(step)=} backCallback Called to notify when the back button is clicked
37+
* @param {function(step)=} nextCallback Called to notify when the next button is clicked
38+
* @param {function()=} onFinish Called to notify when when the wizard is complete. Returns a boolean value to indicate if the finish operation is complete
39+
* @param {function()=} onCancel Called when the wizard is canceled, returns a boolean value to indicate if cancel is successful
40+
* @param {boolean} wizardReady Value that is set when the wizard is ready
41+
* @param {boolean=} wizardDone Value that is set when the wizard is done
42+
* @param {string} loadingWizardTitle The text displayed when the wizard is loading
43+
* @param {string=} loadingSecondaryInformation Secondary descriptive information to display when the wizard is loading
44+
* @param {boolean=} embedInPage Value that indicates wizard is embedded in a page (not a modal). This moves the navigation buttons to the left hand side of the footer and removes the close button.
45+
* @param {function(step, index)=} onStepChanged Called when the wizard step is changed, passes in the step and the step index of the step changed to
46+
* @deprecated {string} title The wizard title displayed in the head (use wizardTitle instead)
47+
* @example
48+
<example module="patternfly.wizard" deps="patternfly.form">
49+
<file name="index.html">
50+
<div ng-controller="WizardModalController">
51+
<button ng-click="openWizardModel()" class="btn btn-default">Launch Wizard</button>
52+
</div>
53+
</file>
54+
<file name="wizard-container.html">
55+
<pf-wizard wizard-title="Wizard Title"
56+
wizard-ready="deployProviderReady"
57+
on-finish="finishedWizard()"
58+
on-cancel="cancelDeploymentWizard()"
59+
next-title="nextButtonTitle"
60+
next-callback="nextCallback"
61+
back-callback="backCallback"
62+
wizard-done="deployComplete || deployInProgress"
63+
sidebar-class="example-wizard-sidebar"
64+
step-class="example-wizard-step"
65+
loading-secondary-information="secondaryLoadInformation"
66+
on-step-changed="stepChanged(step, index)">
67+
<pf-wizard-step step-title="First Step" next-tooltip="firstStepNextTooltip" prev-tooltip="firstStepPrevTooltip" substeps="true" step-id="details" step-priority="0" show-review="true" show-review-details="true">
68+
<div ng-include="'detail-page.html'">
69+
</div>
70+
<pf-wizard-substep step-title="Details - Extra" next-enabled="true" step-id="details-extra" step-priority="1" show-review="true" show-review-details="true" review-template="review-second-template.html">
71+
<form class="form-horizontal">
72+
<pf-form-group pf-label="Lorem" pf-label-class="col-sm-3 col-md-2" pf-input-class="col-sm-9 col-md-10" required>
73+
<input id="new-lorem" name="lorem" ng-model="data.lorem" type="text" required/>
74+
</pf-form-group>
75+
<pf-form-group pf-label="Ipsum" pf-label-class="col-sm-3 col-md-2" pf-input-class="col-sm-9 col-md-10" >
76+
<input id="new-ipsum" name="ipsum" ng-model="data.ipsum" type="text" />
77+
</pf-form-group>
78+
</form>
79+
</pf-wizard-substep>
80+
</pf-wizard-step>
81+
<pf-wizard-step step-title="Second Step" next-tooltip="secondStepNextTooltip" prev-tooltip="secondStepPrevTooltip" substeps="false" step-id="configuration" step-priority="1" show-review="true" review-template="review-second-template.html" >
82+
<form class="form-horizontal">
83+
<h3>Wizards should make use of substeps consistently throughout (either using them or not using them). This is an example only.</h3>
84+
<pf-form-group pf-label="Lorem" pf-label-class="col-sm-3 col-md-2" pf-input-class="col-sm-9 col-md-10" >
85+
<input id="new-lorem" name="lorem" ng-model="data.lorem" type="text"/>
86+
</pf-form-group>
87+
<pf-form-group pf-label="Ipsum" pf-label-class="col-sm-3 col-md-2" pf-input-class="col-sm-9 col-md-10" >
88+
<input id="new-ipsum" name="ipsum" ng-model="data.ipsum" type="text" />
89+
</pf-form-group>
90+
</form>
91+
</pf-wizard-step>
92+
<pf-wizard-step step-title="Review" next-tooltip="reviewStepNextTooltip" prev-tooltip="reviewStepPrevTooltip" substeps="true" step-id="review" step-priority="2">
93+
<div ng-include="'summary.html'"></div>
94+
<div ng-include="'deployment.html'"></div>
95+
</pf-wizard-step>
96+
</pf-wizard>
97+
</file>
98+
<file name="detail-page.html">
99+
<div ng-controller="DetailsGeneralController">
100+
<pf-wizard-substep step-title="General" next-enabled="detailsGeneralComplete" step-id="details-general" step-priority="0" on-show="onShow" review-template="{{reviewTemplate}}" show-review-details="true">
101+
<form class="form-horizontal">
102+
<pf-form-group pf-label="Name" pf-label-class="col-sm-3 col-md-2" pf-input-class="col-sm-9 col-md-10" required>
103+
<input id="new-name" name="name" ng-model="data.name" type="text" ng-change="updateName()" required/>
104+
</pf-form-group>
105+
<pf-form-group pf-label="Description" pf-label-class="col-sm-3 col-md-2" pf-input-class="col-sm-9 col-md-10" >
106+
<input id="new-description" name="description" ng-model="data.description" type="text" />
107+
</pf-form-group>
108+
</form>
109+
</pf-wizard-substep>
110+
</div>
111+
</file>
112+
<file name="review-template.html">
113+
<div ng-controller="DetailsReviewController">
114+
<form class="form">
115+
<div class="wizard-pf-review-item">
116+
<span class="wizard-pf-review-item-label">Name:</span>
117+
<span class="wizard-pf-review-item-value">{{data.name}}</span>
118+
</div>
119+
<div class="wizard-pf-review-item">
120+
<span class="wizard-pf-review-item-label">Description:</span>
121+
<span class="wizard-pf-review-item-value">{{data.description}}</span>
122+
</div>
123+
</form>
124+
</div>
125+
</file>
126+
<file name="review-second-template.html">
127+
<div ng-controller="DetailsReviewController">
128+
<form class="form">
129+
<div class="wizard-pf-review-item">
130+
<span class="wizard-pf-review-item-label">Lorem:</span>
131+
<span class="wizard-pf-review-item-value">{{data.lorem}}</span>
132+
</div>
133+
<div class="wizard-pf-review-item">
134+
<span class="wizard-pf-review-item-label">Ipsum:</span>
135+
<span class="wizard-pf-review-item-value">{{data.ipsum}}</span>
136+
</div>
137+
</form>
138+
</div>
139+
</file>
140+
<file name="summary.html">
141+
<div ng-controller="SummaryController">
142+
<pf-wizard-substep step-title="Summary" step-id="review-summary" step-priority="0" next-enabled="true" prev-enabled="true" ok-to-nav-away="true" wz-disabled="false" on-show="onShow">
143+
<pf-wizard-review-page shown="pageShown" wizard-data="data"></pf-wizard-review-page>
144+
</pf-wizard-substep>
145+
</div>
146+
</file>
147+
<file name="deployment.html">
148+
<div ng-controller="DeploymentController">
149+
<pf-wizard-substep step-title="Deploy" step-id="review-progress" step-priority="1" next-enabled="true" prev-enabled="false" ok-to-nav-away="true" wz-disabled="false" on-show="onShow">
150+
<div class="wizard-pf-contents" ng-controller="DeploymentController">
151+
<div class="wizard-pf-process blank-slate-pf" ng-if="!deploymentComplete">
152+
<div class="spinner spinner-lg blank-slate-pf-icon"></div>
153+
<h3 class="blank-slate-pf-main-action">Deployment in progress</h3>
154+
<p class="blank-slate-pf-secondary-action">Lorem ipsum dolor sit amet, porta at suspendisse ac, ut wisi vivamus, lorem sociosqu eget nunc amet. </p>
155+
</div>
156+
<div class="wizard-pf-complete blank-slate-pf" ng-if="deploymentComplete">
157+
<div class="wizard-pf-success-icon"><span class="glyphicon glyphicon-ok-circle"></span></div>
158+
<h3 class="blank-slate-pf-main-action">Deployment was successful</h3>
159+
<p class="blank-slate-pf-secondary-action">Lorem ipsum dolor sit amet, porta at suspendisse ac, ut wisi vivamus, lorem sociosqu eget nunc amet. </p>
160+
<button type="button" class="btn btn-lg btn-primary">View Deployment</button>
161+
</div>
162+
</div>
163+
</pf-wizard-substep>
164+
</div>
165+
</file>
166+
<file name="script.js">
167+
angular.module('patternfly.wizard').controller('WizardModalController', ['$scope', '$timeout', '$uibModal', '$rootScope',
168+
function ($scope, $timeout, $uibModal, $rootScope) {
169+
$scope.openWizardModel = function () {
170+
var wizardDoneListener,
171+
modalInstance = $uibModal.open({
172+
animation: true,
173+
backdrop: 'static',
174+
templateUrl: 'wizard-container.html',
175+
controller: 'WizardController',
176+
size: 'lg'
177+
});
178+
179+
var closeWizard = function (e, reason) {
180+
modalInstance.dismiss(reason);
181+
wizardDoneListener();
182+
};
183+
184+
modalInstance.result.then(function () { }, function () { });
185+
186+
wizardDoneListener = $rootScope.$on('wizard.done', closeWizard);
187+
};
188+
}
189+
]);
190+
angular.module('patternfly.wizard').controller('WizardController', ['$scope', '$timeout', '$rootScope',
191+
function ($scope, $timeout, $rootScope) {
192+
193+
194+
var initializeWizard = function () {
195+
$scope.data = {
196+
name: '',
197+
description: '',
198+
lorem: 'default setting',
199+
ipsum: ''
200+
};
201+
$scope.secondaryLoadInformation = 'ipsum dolor sit amet, porta at suspendisse ac, ut wisi vivamus, lorem sociosqu eget nunc amet.';
202+
$timeout(function () {
203+
$scope.deployReady = true;
204+
}, 1000);
205+
$scope.nextButtonTitle = "Next >";
206+
};
207+
208+
var startDeploy = function () {
209+
$timeout(function() { }, 10000);
210+
$scope.deployInProgress = true;
211+
};
212+
213+
$scope.data = {};
214+
215+
$scope.firstStepNextTooltip = "First step next";
216+
$scope.firstStepPrevTooltip = "First step back";
217+
$scope.secondStepNextTooltip = "Second step next";
218+
$scope.secondStepPrevTooltip = "Second step back";
219+
$scope.reviewStepNextTooltip = "Review step next";
220+
$scope.reviewStepPrevTooltip = "Review step back";
221+
222+
$scope.nextCallback = function (step) {
223+
// call startdeploy after deploy button is clicked on review-summary tab
224+
if (step.stepId === 'review-summary') {
225+
startDeploy();
226+
}
227+
return true;
228+
};
229+
$scope.backCallback = function (step) {
230+
return true;
231+
};
232+
233+
$scope.stepChanged = function (step, index) {
234+
if (step.stepId === 'review-summary') {
235+
$scope.nextButtonTitle = "Deploy";
236+
} else if (step.stepId === 'review-progress') {
237+
$scope.nextButtonTitle = "Close";
238+
} else {
239+
$scope.nextButtonTitle = "Next >";
240+
}
241+
};
242+
243+
$scope.cancelDeploymentWizard = function () {
244+
$rootScope.$emit('wizard.done', 'cancel');
245+
};
246+
247+
$scope.finishedWizard = function () {
248+
$rootScope.$emit('wizard.done', 'done');
249+
return true;
250+
};
251+
252+
initializeWizard();
253+
}
254+
]);
255+
256+
angular.module('patternfly.wizard').controller('DetailsGeneralController', ['$rootScope', '$scope',
257+
function ($rootScope, $scope) {
258+
'use strict';
259+
260+
$scope.reviewTemplate = "review-template.html";
261+
$scope.detailsGeneralComplete = false;
262+
263+
$scope.onShow = function() { };
264+
265+
$scope.updateName = function() {
266+
$scope.detailsGeneralComplete = angular.isDefined($scope.data.name) && $scope.data.name.length > 0;
267+
};
268+
}
269+
]);
270+
271+
angular.module('patternfly.wizard').controller('DetailsReviewController', ['$rootScope', '$scope',
272+
function ($rootScope, $scope) {
273+
'use strict';
274+
275+
// Find the data!
276+
var next = $scope;
277+
while (angular.isUndefined($scope.data)) {
278+
next = next.$parent;
279+
if (angular.isUndefined(next)) {
280+
$scope.data = {};
281+
} else {
282+
$scope.data = next.$ctrl.wizardData;
283+
}
284+
}
285+
}
286+
]);
287+
288+
angular.module('patternfly.wizard').controller('SummaryController', ['$rootScope', '$scope', '$timeout',
289+
function ($rootScope, $scope, $timeout) {
290+
'use strict';
291+
$scope.pageShown = false;
292+
293+
$scope.onShow = function () {
294+
$scope.pageShown = true;
295+
$timeout(function () {
296+
$scope.pageShown = false; // done so the next time the page is shown it updates
297+
});
298+
}
299+
}
300+
]);
301+
302+
angular.module('patternfly.wizard').controller('DeploymentController', ['$rootScope', '$scope', '$timeout',
303+
function ($rootScope, $scope, $timeout) {
304+
'use strict';
305+
306+
$scope.onShow = function() {
307+
$scope.deploymentComplete = false;
308+
$timeout(function() {
309+
$scope.deploymentComplete = true;
310+
}, 2500);
311+
};
312+
}
313+
]);
314+
</file>
315+
</example>
316+
*/

src/wizard/wizard-step.component.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,15 @@ angular.module('patternfly.wizard').component('pfWizardStep', {
147147

148148
ctrl.$onChanges = function (changesObj) {
149149
if (changesObj.nextTooltip) {
150-
ctrl.wizard.nextTooltip = changesObj.nextTooltip.currentValue;
150+
if (_.get(ctrl.wizard, 'selectedStep') === ctrl) {
151+
ctrl.wizard.nextTooltip = changesObj.nextTooltip.currentValue;
152+
}
151153
}
152154

153155
if (changesObj.prevTooltip) {
154-
ctrl.wizard.prevTooltip = changesObj.prevTooltip.currentValue;
156+
if (_.get(ctrl.wizard, 'selectedStep') === ctrl) {
157+
ctrl.wizard.prevTooltip = changesObj.prevTooltip.currentValue;
158+
}
155159
}
156160
};
157161

@@ -183,20 +187,16 @@ angular.module('patternfly.wizard').component('pfWizardStep', {
183187

184188
ctrl.isNextEnabled = function () {
185189
var enabled = angular.isUndefined(ctrl.nextEnabled) || ctrl.nextEnabled;
186-
if (ctrl.substeps) {
187-
angular.forEach(ctrl.getEnabledSteps(), function (step) {
188-
enabled = enabled && step.nextEnabled;
189-
});
190+
if (ctrl.substeps && ctrl.selectedStep) {
191+
enabled = enabled && ctrl.selectedStep.isNextEnabled();
190192
}
191193
return enabled;
192194
};
193195

194196
ctrl.isPrevEnabled = function () {
195197
var enabled = angular.isUndefined(ctrl.prevEnabled) || ctrl.prevEnabled;
196-
if (ctrl.substeps) {
197-
angular.forEach(ctrl.getEnabledSteps(), function (step) {
198-
enabled = enabled && step.prevEnabled;
199-
});
198+
if (ctrl.substeps && ctrl.selectedStep) {
199+
enabled = enabled && ctrl.selectedStep.isPrevEnabled();
200200
}
201201
return enabled;
202202
};

0 commit comments

Comments
 (0)