From bf8cc8a772ce43a579a4c953d7f22f83e34bc40a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20B=C5=82a=C5=BCejewicz=20=28Peter=20Blazejewicz=29?= Date: Fri, 3 Jan 2020 00:55:58 +0100 Subject: [PATCH] feat(angular-wizard): `setEditMode` method definition (#41244) - docs - test Thanks!s --- types/angular-wizard/angular-wizard-tests.ts | 13 ++++++++++++- types/angular-wizard/index.d.ts | 6 ++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/types/angular-wizard/angular-wizard-tests.ts b/types/angular-wizard/angular-wizard-tests.ts index 3fd77ae8a8..19f93b4fac 100644 --- a/types/angular-wizard/angular-wizard-tests.ts +++ b/types/angular-wizard/angular-wizard-tests.ts @@ -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('' + scope.editMode = false; + var element = angular.element('' + ' ' + '

This is the first step

' + '

Here you can use whatever you want. You can use other directives, binding, etc.

' @@ -306,4 +308,13 @@ describe('AngularWizard', function () { var view = createGenericView(scope); expect((view.isolateScope()).steps[0].description).toEqual('Step description'); }); + it("should set edit mode through custom method", () => { + const scope = $rootScope.$new(); + scope.editMode = true; + createGenericView(scope); + expect(scope.editMode).toBeTrue(); + WizardHandler.wizard().setEditMode(false); + $rootScope.$digest(); + expect(scope.editMode).toBeFalse(); + }); }); diff --git a/types/angular-wizard/index.d.ts b/types/angular-wizard/index.d.ts index 2c95393078..9395b0b43a 100644 --- a/types/angular-wizard/index.d.ts +++ b/types/angular-wizard/index.d.ts @@ -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 {