feat(angular-wizard): setEditMode method definition (#41244)

- docs
- test

Thanks!s
This commit is contained in:
Piotr Błażejewicz (Peter Blazejewicz)
2020-01-03 00:55:58 +01:00
committed by Ryan Cavanaugh
parent c1bea6ce63
commit bf8cc8a772
2 changed files with 18 additions and 1 deletions

View File

@@ -6,6 +6,7 @@ import * as ng from "angular";
import * as angular from "angular";
interface IWizardScope extends ng.IScope {
editMode: boolean;
referenceCurrentStep: string;
stepValidation: () => void;
finishedWizard: () => void;
@@ -30,7 +31,8 @@ describe('AngularWizard', function () {
*/
function createGenericView(scope: IWizardScope) {
scope.referenceCurrentStep = null;
var element = angular.element('<wizard on-finish="finishedWizard()" current-step="referenceCurrentStep" ng-init="msg = 14" >'
scope.editMode = false;
var element = angular.element('<wizard on-finish="finishedWizard()" current-step="referenceCurrentStep" ng-init="msg = 14" edit-mode="editMode">'
+ ' <wz-step wz-title="Starting" canenter="enterValidation" description="Step description">'
+ ' <h1>This is the first step</h1>'
+ ' <p>Here you can use whatever you want. You can use other directives, binding, etc.</p>'
@@ -306,4 +308,13 @@ describe('AngularWizard', function () {
var view = createGenericView(scope);
expect((<any>view.isolateScope()).steps[0].description).toEqual('Step description');
});
it("should set edit mode through custom method", () => {
const scope = <IWizardScope>$rootScope.$new();
scope.editMode = true;
createGenericView(scope);
expect(scope.editMode).toBeTrue();
WizardHandler.wizard().setEditMode(false);
$rootScope.$digest();
expect(scope.editMode).toBeFalse();
});
});

View File

@@ -29,6 +29,12 @@ declare module 'angular' {
currentStepTitle: () => string;
getEnabledSteps(): WzStep[];
totalStepCount(): number;
/** Set the edit mode of the wizard.
* Setting editMode to `true` will make ALL steps accessible,
* setting edit mode to `false` will make all steps with an index lower than
* the latest "completed" step accessible.
*/
setEditMode(editMode: boolean): void;
}
interface WzStep {