Skip to content

Commit 8fc5d14

Browse files
Wizard Enhancements
allow hiding header allow hiding the sidebar navigation panel add disabled class to step indicators when disabled allow adding a class to the sidebar and step panels rather than setting a height allow use of the wizard from typescript bases applications
1 parent 8d07d3f commit 8fc5d14

14 files changed

+282
-67
lines changed

misc/examples.css

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,3 +130,14 @@ hr {
130130
.dropdown-kebab-pf.red .btn-link {
131131
color: red;
132132
}
133+
134+
.example-wizard-sidebar {
135+
height: 500px;
136+
max-height: 500px;
137+
overflow-y: auto;
138+
}
139+
.example-wizard-step {
140+
height: 500px;
141+
max-height: 500px;
142+
overflow-y: auto;
143+
}

src/wizard/wizard-buttons.js

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,32 @@
55
.directive(action, function () {
66
return {
77
restrict: 'A',
8-
require: '^pf-wizard',
98
scope: {
109
callback: "=?"
1110
},
12-
link: function ($scope, $element, $attrs, wizard) {
11+
controller: function ($scope) {
12+
var findWizard = function (scope) {
13+
var wizard;
14+
15+
if (scope) {
16+
if (angular.isDefined(scope.wizard)) {
17+
wizard = scope.wizard;
18+
} else {
19+
wizard = findWizard(scope.$parent);
20+
}
21+
}
22+
23+
return wizard;
24+
};
25+
$scope.wizard = findWizard($scope);
26+
},
27+
link: function ($scope, $element, $attrs) {
1328
$element.on("click", function (e) {
1429
e.preventDefault();
1530
$scope.$apply(function () {
1631
// scope apply in button module
1732
$scope.$eval($attrs[action]);
18-
wizard[action.replace("pfWiz", "").toLowerCase()]($scope.callback);
33+
$scope.wizard[action.replace("pfWiz", "").toLowerCase()]($scope.callback);
1934
});
2035
});
2136
}

src/wizard/wizard-directive.js

Lines changed: 55 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@
2020
*
2121
* @param {string} title The wizard title displayed in the header
2222
* @param {boolean=} hideIndicators Hides the step indicators in the header of the wizard
23+
* @param {boolean=} hideSidebar Hides page navigation sidebar on the wizard pages
24+
* @param {boolean=} hideHeader Optional value to hide the title bar. Default is false.
25+
* @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.
26+
* @param {string=} aidebarClass Optional CSS class to be give to the aidebar panel. Only used if the stepClass is also provided.
27+
* @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.
2328
* @param {string=} currentStep The current step can be changed externally - this is the title of the step to switch the wizard to
2429
* @param {string=} cancelTitle The text to display on the cancel button
2530
* @param {string=} backTitle The text to display on the back button
@@ -32,7 +37,6 @@
3237
* @param {boolean=} wizardDone Value that is set when the wizard is done
3338
* @param {string} loadingWizardTitle The text displayed when the wizard is loading
3439
* @param {string=} loadingSecondaryInformation Secondary descriptive information to display when the wizard is loading
35-
* @param {string=} contentHeight The height the wizard content should be set to. This defaults to 300px if the property is not supplied.
3640
* @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.
3741
*
3842
* @example
@@ -51,7 +55,8 @@
5155
next-callback="nextCallback"
5256
back-callback="backCallback"
5357
wizard-done="deployComplete || deployInProgress"
54-
content-height="'600px'"
58+
sidebar-class="example-wizard-sidebar"
59+
step-class="example-wizard-step"
5560
loading-secondary-information="secondaryLoadInformation">
5661
<div pf-wizard-step step-title="First Step" substeps="true" step-id="details" step-priority="0" show-review="true" show-review-details="true">
5762
<div ng-include="'detail-page.html'">
@@ -305,6 +310,11 @@ angular.module('patternfly.wizard').directive('pfWizard', function ($window) {
305310
scope: {
306311
title: '@',
307312
hideIndicators: '=?',
313+
hideSidebar: '@',
314+
hideHeader: '@',
315+
sidebarClass: '@',
316+
stepClass: '@',
317+
contentHeight: '=?',
308318
currentStep: '=?',
309319
cancelTitle: '=?',
310320
backTitle: '=?',
@@ -317,7 +327,6 @@ angular.module('patternfly.wizard').directive('pfWizard', function ($window) {
317327
wizardDone: '=?',
318328
loadingWizardTitle: '=?',
319329
loadingSecondaryInformation: '=?',
320-
contentHeight: '=?',
321330
embedInPage: '=?'
322331
},
323332
templateUrl: 'wizard/wizard.html',
@@ -388,21 +397,36 @@ angular.module('patternfly.wizard').directive('pfWizard', function ($window) {
388397
$scope.steps = [];
389398
$scope.context = {};
390399
this.context = $scope.context;
400+
$scope.hideHeader = $scope.hideHeader === 'true';
401+
this.hideSidebar = $scope.hideSidebar === 'true';
391402

392-
if (angular.isUndefined($scope.wizardReady)) {
393-
$scope.wizardReady = true;
403+
// If a step class is given use it for all steps
404+
if (angular.isDefined($scope.stepClass)) {
405+
this.stepClass = $scope.stepClass;
406+
407+
// If a sidebarClass is given, us it for sidebar panel, if not, apply the stepsClass to the sidebar panel
408+
if (angular.isDefined($scope.sidebarClass)) {
409+
this.sidebarClass = $scope.sidebarClass;
410+
} else {
411+
this.sidebarClass = $scope.stepClass;
412+
}
413+
} else {
414+
// No step claass give, setup the content style to allow scrolling and a fixed height
415+
if (angular.isUndefined($scope.contentHeight)) {
416+
$scope.contentHeight = '300px';
417+
}
418+
this.contentHeight = $scope.contentHeight;
419+
$scope.contentStyle = {
420+
'height': $scope.contentHeight,
421+
'max-height': $scope.contentHeight,
422+
'overflow-y': 'auto'
423+
};
424+
this.contentStyle = $scope.contentStyle;
394425
}
395426

396-
if (angular.isUndefined($scope.contentHeight)) {
397-
$scope.contentHeight = '300px';
427+
if (angular.isUndefined($scope.wizardReady)) {
428+
$scope.wizardReady = true;
398429
}
399-
this.contentHeight = $scope.contentHeight;
400-
$scope.contentStyle = {
401-
'height': $scope.contentHeight,
402-
'max-height': $scope.contentHeight,
403-
'overflow-y': 'auto'
404-
};
405-
this.contentStyle = $scope.contentStyle;
406430

407431
$scope.nextEnabled = false;
408432
$scope.prevEnabled = false;
@@ -513,6 +537,14 @@ angular.module('patternfly.wizard').directive('pfWizard', function ($window) {
513537
}
514538
};
515539

540+
$scope.allowStepIndicatorClick = function (step) {
541+
return step.allowClickNav &&
542+
!$scope.wizardDone &&
543+
$scope.selectedStep.okToNavAway &&
544+
($scope.selectedStep.nextEnabled || (step.stepPriority < $scope.selectedStep.stepPriority)) &&
545+
($scope.selectedStep.prevEnabled || (step.stepPriority > $scope.selectedStep.stepPriority));
546+
};
547+
516548
$scope.stepClick = function (step) {
517549
if (step.allowClickNav) {
518550
$scope.goTo(step, true);
@@ -645,6 +677,12 @@ angular.module('patternfly.wizard').directive('pfWizard', function ($window) {
645677
$scope.goTo($scope.getEnabledSteps()[index - 1]);
646678
}
647679
}
680+
} else {
681+
if (index === 0) {
682+
throw new Error("Can't go back. It's already in step 0");
683+
} else {
684+
$scope.goTo($scope.getEnabledSteps()[index - 1]);
685+
}
648686
}
649687
};
650688

@@ -673,6 +711,9 @@ angular.module('patternfly.wizard').directive('pfWizard', function ($window) {
673711
//go to first step
674712
this.goTo(0);
675713
};
714+
715+
// Provide wizard controls to steps and sub-steps
716+
$scope.wizard = this;
676717
},
677718
link: function ($scope) {
678719
$scope.$watch('wizardReady', function () {

src/wizard/wizard-step-directive.js

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ angular.module('patternfly.wizard').directive('pfWizardStep', function () {
4747
showReviewDetails: '@?',
4848
reviewTemplate: '@?'
4949
},
50-
require: '^pf-wizard',
5150
templateUrl: 'wizard/wizard-step.html',
5251
controller: function ($scope, $timeout) {
5352
var firstRun = true;
@@ -113,8 +112,23 @@ angular.module('patternfly.wizard').directive('pfWizardStep', function () {
113112
return foundStep;
114113
};
115114

115+
var findWizard = function (scope) {
116+
var wizard;
117+
if (scope) {
118+
if (angular.isDefined(scope.wizard)) {
119+
wizard = scope.wizard;
120+
} else {
121+
wizard = findWizard(scope.$parent);
122+
}
123+
}
124+
125+
return wizard;
126+
};
127+
116128
$scope.steps = [];
117129
$scope.context = {};
130+
$scope.wizard = findWizard($scope.$parent);
131+
this.wizard = $scope.wizard;
118132
this.context = $scope.context;
119133

120134
if (angular.isUndefined($scope.nextEnabled)) {
@@ -328,6 +342,9 @@ angular.module('patternfly.wizard').directive('pfWizardStep', function () {
328342
$scope.goTo(stepTo);
329343
};
330344

345+
// Provide wizard step controls to sub-steps
346+
$scope.wizardStep = this;
347+
331348
// Method used for next button within step
332349
$scope.next = function (callback) {
333350
var enabledSteps = $scope.getEnabledSteps();
@@ -387,14 +404,13 @@ angular.module('patternfly.wizard').directive('pfWizardStep', function () {
387404
};
388405
}
389406
},
390-
link: function ($scope, $element, $attrs, wizard) {
407+
link: function ($scope, $element, $attrs) {
391408
$scope.$watch($attrs.ngShow, function (value) {
392-
$scope.pageNumber = wizard.getStepNumber($scope);
409+
$scope.pageNumber = $scope.wizard.getStepNumber($scope);
393410
});
394411
$scope.title = $scope.stepTitle;
395-
$scope.contentStyle = wizard.contentStyle;
396-
wizard.addStep($scope);
397-
$scope.wizard = wizard;
412+
$scope.contentStyle = $scope.wizard.contentStyle;
413+
$scope.wizard.addStep($scope);
398414
}
399415
};
400416
});

src/wizard/wizard-step.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<section ng-show="selected" ng-class="{current: selected, done: completed}">
2-
<div class="wizard-pf-sidebar" ng-style="contentStyle" ng-if="substeps === true">
2+
<div ng-if="!wizard.hideSidebar" class="wizard-pf-sidebar" ng-style="contentStyle" ng-class="wizard.sidebarClass" ng-if="substeps === true">
33
<ul class="list-group">
44
<li class="list-group-item" ng-class="{active: step.selected}" ng-repeat="step in getEnabledSteps()">
55
<a ng-click="stepClick(step)">
@@ -9,7 +9,7 @@
99
</li>
1010
</ul>
1111
</div>
12-
<div class="wizard-pf-main" ng-class="{'wizard-pf-singlestep': !substeps}" ng-style="contentStyle">
12+
<div class="wizard-pf-main {{wizard.stepClass}}" ng-style="contentStyle" ng-class="{'wizard-pf-singlestep': !substeps || wizard.hideSidebar}">
1313
<div class="wizard-pf-contents" ng-transclude></div>
1414
</div>
1515
</section>

src/wizard/wizard-substep-directive.js

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,24 @@ angular.module('patternfly.wizard').directive('pfWizardSubstep', function () {
3939
showReviewDetails: '@?',
4040
reviewTemplate: '@?'
4141
},
42-
require: '^pf-wizard-step',
4342
templateUrl: 'wizard/wizard-substep.html',
4443
controller: function ($scope) {
44+
var findWizardStep = function (scope) {
45+
var wizardStep;
46+
47+
if (scope) {
48+
if (angular.isDefined(scope.wizardStep)) {
49+
wizardStep = scope.wizardStep;
50+
} else {
51+
wizardStep = findWizardStep(scope.$parent);
52+
}
53+
}
54+
55+
return wizardStep;
56+
};
57+
58+
$scope.wizardStep = findWizardStep($scope);
59+
4560
if (angular.isUndefined($scope.nextEnabled)) {
4661
$scope.nextEnabled = true;
4762
}
@@ -74,9 +89,9 @@ angular.module('patternfly.wizard').directive('pfWizardSubstep', function () {
7489
};
7590

7691
},
77-
link: function ($scope, $element, $attrs, step) {
92+
link: function ($scope, $element, $attrs) {
7893
$scope.title = $scope.stepTitle;
79-
step.addStep($scope);
94+
$scope.wizardStep.addStep($scope);
8095
}
8196
};
8297
});

src/wizard/wizard.html

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<div>
2-
<div class="modal-header">
2+
<div class="modal-header" ng-if="!hideHeader">
33
<button type="button" class="close wizard-pf-dismiss" aria-label="Close" ng-click="onCancel()" ng-if="!embedInPage">
44
<span aria-hidden="true">&times;</span>
55
</button>
@@ -10,7 +10,10 @@
1010
<div class="wizard-pf-steps" ng-class="{'invisible': !wizardReady}">
1111
<ul class="wizard-pf-steps-indicator" ng-if="!hideIndicators" ng-class="{'invisible': !wizardReady}">
1212
<li class="wizard-pf-step" ng-class="{active: step.selected}" ng-repeat="step in getEnabledSteps()" data-tabgroup="{{$index }}">
13-
<a ng-click="stepClick(step)"><span class="wizard-pf-step-number">{{$index + 1}}</span><span class="wizard-pf-step-title">{{step.title}}</span></a>
13+
<a ng-click="stepClick(step)" ng-class="{'disabled': !allowStepIndicatorClick(step)}">
14+
<span class="wizard-pf-step-number">{{$index + 1}}</span>
15+
<span class="wizard-pf-step-title">{{step.title}}</span>
16+
</a>
1417
</li>
1518
</ul>
1619
</div>

styles/angular-patternfly.css

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,3 +470,13 @@ accordion > .panel-group .panel-open .panel-title > a:before {
470470
.pf-expand-placeholder {
471471
margin-right: 15px;
472472
}
473+
474+
.wizard-pf-steps-indicator li a.disabled {
475+
cursor: default;
476+
}
477+
478+
.wizard-pf-steps-indicator li a.disabled:hover .wizard-pf-step-number {
479+
background-color: #fff;
480+
border-color: #bbb;
481+
color: #bbb;
482+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<div pf-wizard title="Wizard Title"
2+
wizard-ready="deployReady"
3+
on-finish="finishedWizard()"
4+
on-cancel="cancelDeploymentWizard()"
5+
next-title="nextButtonTitle"
6+
next-callback="nextCallback"
7+
back-callback="backCallback"
8+
current-step="currentStep"
9+
hide-indicators="hideIndicators"
10+
hide-sidebar="true"
11+
hide-header="true"
12+
wizard-done="deployComplete || deployInProgress"
13+
loading-secondary-information="secondaryLoadInformation">
14+
<div ng-include="'test/wizard/wizard-test-steps.html'"></div>
15+
</div>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<div pf-wizard title="Wizard Title"
2+
step-class="test-step-class"
3+
wizard-ready="deployReady"
4+
on-finish="finishedWizard()"
5+
on-cancel="cancelDeploymentWizard()"
6+
next-title="nextButtonTitle"
7+
next-callback="nextCallback"
8+
back-callback="backCallback"
9+
current-step="currentStep"
10+
hide-indicators="hideIndicators"
11+
wizard-done="deployComplete || deployInProgress"
12+
loading-secondary-information="secondaryLoadInformation">
13+
<div ng-include="'test/wizard/wizard-test-steps.html'"></div>
14+
</div>

0 commit comments

Comments
 (0)