Giter VIP home page Giter VIP logo

angular-archwizard's Introduction

Overview angular-archwizard

Build Status Dependency Status Dev-Dependency Status Codacy Badge Codacy Badge NPM Version

This project contains a functional module with a wizard component and some supportive components and directives for Angular version 9 or later.

Build

Run npm run build to build the project. The build artifacts will be stored in the dist/ directory.

Running unit tests

Run npm test to execute the unit tests via Karma.

Compatibility

Latest angular-archwizard is compatible with Angular 9+. Older versions of angular-archwizard can be used together with older versions of Angular. The following table shows which version of angular-archwizard has been built with which Angular version:

angular-archwizard version Angular version
3.0.0 Angular 5
4.0.0 Angular 7
5.0.1 Angular 8
6.1.0 Angular 9
7.0.0 Angular 11

Gitpod

angular-archwizard can be developed with Gitpod, a free one-click online IDE for GitHub:

Open in Gitpod

Installation

Step 1: Install angular-archwizard

angular-archwizard is available as a NPM package. To install angular-archwizard in your project directory run:

$ npm install --save angular-archwizard

Step 2: Import the ArchwizardModule

After installation you can import angular-archwizard into your Angular project by adding the ArchwizardModule to your module declaration as follows:

import { ArchwizardModule } from 'angular-archwizard';

@NgModule({
  imports: [
    ArchwizardModule
  ],
})
export class Module { }

Step 3: Include styles

To allow customization, angular-archwizard bundles CSS styles separately. If you are using Angular CLI, import them into your styles.css...

@import '../node_modules/angular-archwizard/styles/archwizard.css';

...or include them into angular.json:

{
  // ...
  "styles": [
    "node_modules/angular-archwizard/styles/archwizard.css",
    "src/styles.css"
  ]
  // ...
}

If you are using SCSS, you can include the styles in the form of a .scss file: node_modules/angular-archwizard/styles/archwizard.scss. This way you can easily customize wizard's appearance by tweaking SCSS variables as described in Styles Customization.

How to use the wizard

To use this wizard component in an angular project simply add a aw-wizard component to the html template of your component:

<aw-wizard>
  <aw-wizard-step stepTitle="Title of step 1">
    Content of Step 1
    <button type="button" awNextStep>Next Step</button>
    <button type="button" [awGoToStep]="{stepIndex: 2}">Go directly to third Step</button>
  </aw-wizard-step>
  <aw-wizard-step stepTitle="Title of step 2" awOptionalStep>
    Content of Step 2
    <button type="button" awPreviousStep>Go to previous step</button>
    <button type="button" awNextStep>Go to next step</button>
  </aw-wizard-step>
  <aw-wizard-step stepTitle="Title of step 3">
    Content of Step 3
    <button type="button" awPreviousStep>Previous Step</button>
    <button type="button" (click)="finishFunction()">Finish</button>
  </aw-wizard-step>
</aw-wizard>

Components

<aw-wizard>

The <aw-wizard> environment is the environment in which you define the steps belonging to your wizard. In addition to the contained wizard steps, angular-archwizard enables you to define the location and the layout of the navigation bar inside your wizard. To set the location, the layout of the navigation bar and many other settings, you can pass the following parameters to the aw-wizard component:

[navBarLocation]

The location of the navigation bar, contained inside the wizard, can be specified through the navBarLocation input value. This value can be either top, bottom, left or right, where the values specify the position at which the navigation bar will be shown. In addition top and bottom will lead to a horizontal navigation bar, when left and right lead to a vertical navigation bar at the left or right side. If no navBarLocation is given the navigation bar will be shown at the top of the wizard.

[navBarLayout]

Another option that can be changed is the design or layout of the navigation bar. Currently five different navigation bar layouts exist. These are small, large-filled, large-empty, large-filled-symbols and large-empty-symbols.

The first three layouts are showing circles with or without a background, for each step of your wizard, in the navigation bar. The second two layouts large-filled-symbols and large-empty-symbols optionally add a symbol in the center of the circle, for each step of your wizard, in the navigation bar, if such a symbol has been defined for the step.

[navBarDirection]

Normally the steps in the navigation bar are layed out from left to right or from top to bottom. In some cases, like with languages that are written from right to left, it may be required to change this direction to layout the steps from right to left. To layout the steps from right to left you can pass right-to-left to the navBarDirection input of the wizard component.

[defaultStepIndex]

Per default the wizard always starts with the first wizard step, after initialisation. The same applies for a reset, where the wizard normally resets to the first step. Sometimes this needs to be changed. If another default wizard step needs to be used, you can set it, by using the [defaultStepIndex] input of the wizard component. For example, to start the wizard in the second step, [defaultStepIndex]="2" needs to be set.

Please be aware, that angular will interpret the given input value as a string if it's not enclosed by []!

[disableNavigationBar]

Sometimes it may be necessary to disable navigation via the navigation bar. In such a case you can disable navigation via the navigation bar by setting the input [disableNavigationBar] of the wizard component to true.

After disabling the navigation bar, the user can't use the navigation bar anymore to navigate between steps. Disabling the navigation bar doesn't restrict the use of elements (buttons or links) with an awNextStep, awPreviousStep or awGoToStep directive.

Parameter overview

Possible <aw-wizard> parameters:

Parameter name Possible Values Default Value
[navBarLocation] 'top' | 'bottom' | 'left' | 'right' 'top'
[navBarLayout] 'small' | 'large-filled' | 'large-empty' | 'large-filled-symbols' | 'large-empty-symbols' 'small'
[navBarDirection] 'left-to-right' | 'right-to-left' 'left-to-right'
[defaultStepIndex] number 0
[disableNavigationBar] boolean false

<aw-wizard-step>

angular-archwizard contains two ways to define a wizard step. One of these two ways is by using the <aw-wizard-step> component.

[stepId]

A wizard step can have its own unique id. This id can then be used to navigate to the step. In addition the [stepId] of a wizard step is used as the id of the li element for the wizard step in the navigation bar.

[stepTitle]

A wizard step needs to contain a title, which is shown in the navigation bar of the wizard. To set the title of a step, add the stepTitle input attribute, with the choosen step title, to the definition of your wizard step.

[navigationSymbol]

Sometimes it's useful to add a symbol in the center of the circle in the navigation bar, which belongs to the step. angular-archwizard supports this through the [navigationSymbol] input attribute of the wizard step.

Be aware, that not all layouts display the symbols. Only the layouts large-filled-symbols and large-empty-symbols display the symbols!

If you want to add a 2 to the circle in the navigation bar belonging to the second step, you can do it like this:

<aw-wizard-step stepTitle="Second Step" [navigationSymbol]="{ symbol: '2' }">
  ...
</aw-wizard-step>

In addition to normal symbols it's also possible to use an icon from a font as a symbol. To use an icon from a font you need to first search for the unicode belonging to the icon you want to insert. Afterwards you can use the unicode in the numeric character reference format as the symbol for the step. In addition you need to specify the font family, to which the icon belongs, otherwise the symbol can't be displayed correctly.

The font family of the used symbol can be specified via the fontFamily field of the given [navigationSymbol] json input object. For example, if you want to show the icon with the unicode \f2dd of FontAwesome inside a step circle in the navigation bar, then you can do this via the following [navigationSymbol] input attribute:

<aw-wizard-step stepTitle="Second Step" [navigationSymbol]="{ symbol: '&#xf2dd;', fontFamily: 'FontAwesome' }">
  ...
</aw-wizard-step>

[canEnter]

Sometimes it's required to only allow the user to enter a specific step if a certain validation method returns true. In such a case you can use the [canEnter] input of the targeted wizard step. This input can be either a boolean, which directly tells the wizard if the targeted step can be entered, or a lambda function, taking a MovingDirection and returning a boolean or a Promise<boolean>. This function will then be called, with the direction in which the targeted step will be entered, whenever an operation has been performed, that leads to a change of the current step. It then returns true, when the step change should succeed and false otherwise.

[canExit]

If you have an additional check or validation you need to perform to decide, if the step can be exited (both to the next step and to the previous step), you can either pass a boolean or a function, taking a MovingDirection enum and returning a boolean or a Promise<boolean>, to the [canExit] attribute of the wizard step. This boolean, or function, is taken into account, when an operation has been performed, which leads to a transition of the current step. If [canExit] has been bound to a boolean, it needs to be true to leave the step in either direction (foreward AND backward). If only exiting in one direction should be covered, you can pass a function, taking a MovingDirection and returning a boolean, to [canExit]. This function will then be called whenever an operation has been performed, that leads to a change of the current step.

(stepEnter)

If you need to call a function to do some initialisation work before entering a wizard step you can add a stepEnter attribute to the wizard step environment like this:

<aw-wizard-step stepTitle="Second Step" (stepEnter)="enterSecondStep($event)">
  ...
</aw-wizard-step>

This leads to the calling of the enterSecondStep function when the wizard moves to this step. When the first step of the wizard contains a stepEnter function, it not only gets called when the user moves back from a later step to the first step, but also after the wizard is initialized. The event emitter will call the given function with a parameter that contains the MovingDirection of the user. If the user went backwards, for example from the third step to the second or first step, then MovingDirection.Backwards will be passed to the function. If the user went forwards MovingDirection.Forwards will be passed to the function.

(stepExit)

Similar to stepEnter you can add a stepExit attribute to the wizard step environment, if you want to call a function every time a wizard step is exited either by pressing on a component with an awNextStep or awPreviousStep directive, or by a click on the navigation bar. stepExit, like stepEnter can call the given function with an argument of type MovingDirection that signalises in which direction the step was exited.

Parameter overview

Possible <aw-wizard-step> parameters:

Parameter name Possible Values Default Value
[stepId] string null
[stepTitle] string null
[navigationSymbol] {symbol: string, fontFamily?: string} {symbol: ''}
[canEnter] function(MovingDirection): boolean | function(MovingDirection): Promise<boolean> | boolean true
[canExit] function(MovingDirection): boolean | function(MovingDirection): Promise<boolean> | boolean true
(stepEnter) function(MovingDirection): void null
(stepExit) function(MovingDirection): void null

<aw-wizard-completion-step>

In addition to the "normal" step component <aw-wizard-step> it's also possible to define an optional <aw-wizard-completion-step>. The aw-wizard-completion-step is meant as the final wizard step, which signalises the user, that he or she successfully completed the wizard. When an aw-wizard-completion-step has been entered by the user, all wizard steps, including the optional steps belonging to the wizard, are marked as completed. In addition the user is prevented from leaving the aw-wizard-completion-step to another step, once it has been entered.

The given parameters for the wizard completion step are identical to the normal wizard step. The only difference is, that it isn't possible to pass a (stepExit) and [canExit] parameter to the aw-wizard-completion-step, because it can't be exited.

Parameter overview

Possible <aw-wizard-completion-step> parameters:

Parameter name Possible Values Default Value
[stepId] string null
[stepTitle] string null
[navigationSymbol] {symbol: string, fontFamily?: string} {symbol: ''}
[canEnter] function(MovingDirection): boolean | function(MovingDirection): Promise<boolean> | boolean true
(stepEnter) function(MovingDirection): void null

Directives

[awNavigationMode]

By default angular-archwizard operates in a "strict" navigation mode. It requires users to navigate through the wizard steps in a linear fashion, where they can only enter the next step if all previous steps have been completed and the exit condition of the current step have been fulfilled. The only exception to this rule are optional steps, which a user can skip. Using the navigation bar, the user can navigate back to steps they already visited.

You can alter this behavior by applying to the <aw-wizard> element an additional [awNavigationMode] directive, which can be used in two ways. The easiest option is to tweak the default navigation mode with [navigateBackward] and/or [navigateForward] inputs which control the navigation bar and have the following options:

Parameter name Possible Values Default Value
[navigateBackward] 'allow' | 'deny' 'allow'
[navigateForward] 'allow' | 'deny' | 'visited' 'deny'

Take notice that the 'allow' and 'visited' options still respect step exit conditions. Also, the completion step still only becomes enterable after all previous steps are completed. Example usage:

<aw-wizard [awNavigationMode] navigateBackward="allow" navigateForward="allow">
  ...
</aw-wizard>

If changes you need are more radical, you can define your own navigation mode. In order to do this, create a class implementing the NavigationMode interface and pass an instance of this class into the [awNavigationMode] directive. This takes priority over [navigateBackward] and [navigateForward] inputs. Example usage:

custom-navigation-mode.ts:

import { NavigationMode } from 'angular-archwizard'

class CustomNavigationMode implements NavigationMode {

  // ...
}

my.component.ts:

@Component({
  // ...
})
class MyComponent {

  navigationMode = new CustomNavigationMode();
}

my.component.html:

<aw-wizard [awNavigationMode]="navigationMode">
  ...
</aw-wizard>

Instead of implementing the NavigationMode interface from scratch, you can extend one of the classes provided by angular-archwizard:

  • BaseNavigationMode: This class contains an abstract method called isNavigable, which you will have to override to define wizard's behavior towards navigation using the navigation bar.

  • ConfigurableNavigationMode: This class defines the default navigation mode used by angular-archwizard. In some cases, it might be more convenient to base your custom implementation on it.

This way of customizing the wizard is advanced, so be prepared to refer to documentation comments and source code for help.

Parameter overview

Possible awNavigationMode parameters:

Parameter name Possible Values Default Value
[awNavigationMode] NavigationMode null
[navigateBackward] 'allow' | 'deny' 'deny'
[navigateForward] 'allow' | 'deny' | 'visited' 'allow'

[awEnableBackLinks]

In some cases it may be required that the user is allowed to leave an entered aw-wizard-completion-step. In such a case you can enable this by adding the directive [awEnableBackLinks] to the aw-wizard-completion-step.

<aw-wizard-completion-step awEnableBackLinks>
  Final wizard step
</aw-wizard-completion-step>

Parameter overview

Possible awEnableBackLinks parameters:

Parameter name Possible Values Default Value
(stepExit) function(MovingDirection): void null

[awWizardStepTitle]

Sometimes it's not enough to define a title with the stepTitle attribute in <aw-wizard-step> and <aw-wizard-completion-step>. One example for such a case is, if the title should be written in another font. Another example would be if it's desired that the title should be chosen depending on the available width of your screen or window. In such cases you may want to specify the html for the title of a wizard step yourself. This can be achieved by using the [awWizardStepTitle] directive inside a wizard step on a ng-template component.

<aw-wizard-step (stepEnter)="enterStep($event)">
  <ng-template awWizardStepTitle>
    <span class="hidden-sm-down">Delivery address</span>
    <span class="hidden-md-up">Address</span>
  </ng-template>
</aw-wizard-step>

Additionally it is possible to inject the corresponding WizardStep object into the ng-template environment. This for example allows customization of the step title depending on the state of the wizard step, like on the completion and selection state:

<aw-wizard-step (stepEnter)="enterStep($event)">
  <ng-template awWizardStepTitle let-wizardStep="wizardStep">
    {{ wizardStep.completed ? "Delivery address (✔)" : "Delivery address" }}
  </ng-template>
</aw-wizard-step>

[awWizardStepSymbol]

In addition to the step title, the navigation symbol/step symbol can also be set via a directive. This is required, if the navigation step symbol is not a simple character or a symbol, but something more complex, like a html component. In such a case, the the navigation symbol can be specified using the [awWizardStepSymbol] directive, inside a wizard step on a ng-template component.

<aw-wizard-step (stepEnter)="enterStep($event)">
  <ng-template awWizardStepSymbol>
    <!-- use <i class="fa fa-file"></i> for fontawesome version 4 -->
    <i class="far fa-file"></i>
  </ng-template>
</aw-wizard-step>

Additionally it is possible to inject the corresponding WizardStep object into the ng-template environment. This for example allows customization of the navigation symbol depending on the state of the wizard step, like on the completion and selection state:

<aw-wizard-step (stepEnter)="enterStep($event)">
  <ng-template awWizardStepSymbol let-wizardStep="wizardStep">
    <!-- use <i *ngIf="!wizardStep.completed" class="fa fa-file"></i> for fontawesome version 4 -->
    <i *ngIf="!wizardStep.completed" class="far fa-file"></i>
    <!-- use <i *ngIf="wizardStep.completed" class="fa fa-check"></i> for fontawesome version 4 -->
    <i *ngIf="wizardStep.completed" class="far fa-check"></i>
  </ng-template>
</aw-wizard-step>

[awOptionalStep]

If you need to define an optional step, that doesn't need to be done to continue to the next steps, you can define an optional step by adding the awOptionalStep directive to the step you want to declare as optional:

<aw-wizard-step awOptionalStep>
  ...
</aw-wizard-step>

Sometimes a wizard step should only be marked as optional if some condition has been fulfilled. In such a case you can pass the condition to the awOptionalStep input parameter of the awOptionalStep directive to tell the wizard whether the step should be marked as optional:

<aw-wizard-step [awOptionalStep]="condition">
  ...
</aw-wizard-step>

It is important to note that the condition input value can not be changed after initialization.

[awCompletedStep]

In some cases it is required to specify a step as completed by default. This means that the step should be shown as completed directly after initialization. A step can be marked as completed by default by adding the awCompletedStep directive to the step you want to declare as completed:

<aw-wizard-step awCompletedStep>
  ...
</aw-wizard-step>

Sometimes a wizard step should only be marked as completed if some condition has been fulfilled. In such cases you can pass the condition to the awCompletedStep input parameter of the awCompletedStep directive to tell the wizard, whether the step should be marked as complete:

<aw-wizard-step [awCompletedStep]="condition">
  ...
</aw-wizard-step>

It is important to note that the condition input value can not be changed after initialization.

[awSelectedStep]

In some cases it may be a better choice to set the default wizard step not via a static number. Another way to set the default wizard step is by using the awSelectedStep directive. When attaching the awSelectedStep directive to an arbitrary wizard step, it will be marked as the default wizard step, which is shown directly after the wizard startup.

[awGoToStep]

angular-archwizard has three directives, which allow moving between steps. These directives are the awPreviousStep, asNextStep and awGoToStep directives.

The awGoToStep directive needs to receive an input, which tells the wizard, to which step it should navigate, when the element with the awGoToStep directive has been clicked.

This input accepts different arguments:

  • a destination step index: One possible argument for the input is a destination step index. A destination step index is always zero-based, i.e. the index of the first step inside the wizard is always zero.

    To pass a destination step index to an awGoToStep directive, you need to pass the following json object to the directive:

    <button [awGoToStep]="{ stepIndex: 2 }" (finalize)="finalizeStep()">Go directly to the third Step</button>
  • a destination step id: Another possible argument for the input is a the unique step id of the destination step. This step id can be set for all wizard steps through their input [stepId].

    To pass a unique destination step id to an awGoToStep directive, you need to pass the following json object to the directive:

    <button [awGoToStep]="{ stepId: 'unique id of the third step' }" (finalize)="finalizeStep()">Go directly to the third Step</button>
  • a step offset between the current step and the destination step: Alternatively to an absolute step index or an unique step id, it's also possible to set the destination wizard step as an offset to the source step:

    <button [awGoToStep]="{ stepOffset: 1 }" (finalize)="finalizeStep()">Go to the third Step</button>

In all above examples a click on the "Go to the third Step" button will move the user to the next step (the third step) compared to the step the button belongs to (the second step). If the button is part of the second step, a click on it will move the user to the third step.

In all above cases it's important to use [] around the awGoToStep directive to tell angular that the argument is to be interpreted as javascript.

In addition to a static value you can also pass a local variable from your component typescript class, that contains to which step a click on the element should change the current step of the wizard. This can be useful if your step transitions depend on some application dependent logic, that changes depending on the user input. Here again it's important to use [] around the awGoToStep directive to tell angular that the argument is to be interpreted as javascript.

(preFinalize)

Sometimes it's required to bind an event emitter to a specific element, which can perform a step transition. Such an event emitter can be bound to the (preFinalize) output of the element, which contains the awGoToStep directive. This event emitter is then called, directly before the wizard transitions to the given step.

(postFinalize)

Alternatively you can also bind an event emitter to (postFinalize), which is executed directly after the wizard transitions to the given step.

(finalize)

In case you don't really care when the finalization event emitter is called, you can also bind it simply to (finalize). finalize is a synonym for preFinalize.

Parameter overview

Possible parameters:

Parameter name Possible Values Default Value
[goToStep] WizardStep | StepOffset | StepIndex | StepId null
(preFinalize) function(): void null
(postFinalize) function(): void null
(finalize) function(): void null

[awNextStep]

By adding a awNextStep directive to a button or a link inside a step, you automatically add a onClick listener to the button or link, that leads to the next step. This listener will automatically change the currently selected wizard step to the next wizard step after a click on the component.

<button (finalize)="finalizeStep()" awNextStep>Next Step</button>

(finalize)

Like the awGoToStep directive the awNextStep directive provides a preFinalize, postFinalize and finalize output, which are called every time the current step is successfully exited, by clicking on the element containing the nextStep directive.

In the given code snipped above, a click on the button with the text Next Step leads to a call of the finalize function every time the button has been pressed.

Parameter overview

Possible parameters:

Parameter name Possible Values Default Value
(preFinalize) function(): void null
(postFinalize) function(): void null
(finalize) function(): void null

[awPreviousStep]

By adding a awPreviousStep directive to a button or a link, you automatically add a onClick listener to the button or link, that changes your wizard to the previous step. This listener will automatically change the currently selected wizard step to the previous wizard step after a click on the component.

<button (finalize)="finalizeStep()" awPreviousStep>Previous Step</button>

(finalize)

Like both the awGoToStep and awNextStep directives the awPreviousStep directives provides a preFinalize, postFinalize and finalize output, which are called every time the current step is successfully exited, by clicking on the element containing the awPreviousStep directive.

Parameter overview

Possible parameters:

Parameter name Possible Values Default Value
(preFinalize) function(): void null
(postFinalize) function(): void null
(finalize) function(): void null

[awWizardStep]

In some cases it may be a good idea to move a wizard step to a custom component. This can be done by defining adding the awWizardStep directive to the component that contains the wizard step.

<aw-wizard>
  <aw-wizard-step stepTitle="Steptitle 1">
    Step 1
  </aw-wizard-step>
  <custom-step awWizardStep stepTitle="Steptitle 2">
    ...
  </custom-step>
  <aw-wizard-step stepTitle="Steptitle 3">
    Step 3
  </aw-wizard-step>
</aw-wizard>

Parameter overview

Possible awWizardStep parameters:

Parameter name Possible Values Default Value
[stepId] string null
[stepTitle] string null
[navigationSymbol] {symbol: string, fontFamily?: string} {symbol: ''}
[canEnter] function(MovingDirection): boolean | function(MovingDirection): Promise<boolean> | boolean true
[canExit] function(MovingDirection): boolean | function(MovingDirection): Promise<boolean> | boolean true
(stepEnter) function(MovingDirection): void null
(stepExit) function(MovingDirection): void null

[awWizardCompletionStep]

In addition to the possibility of defining a normal wizard step in a custom component, it is also possible to define a wizard completion step in a custom component. To define a wizard completion step in a custom component you need to add the [awWizardCompletionStep] directive to the custom component that contains the wizard completion step.

<aw-wizard>
  <aw-wizard-step stepTitle="Steptitle 1">
    Step 1
  </aw-wizard-step>
  <custom-step awWizardCompletionStep stepTitle="Completion steptitle">
    ...
  </custom-step>
</aw-wizard>

Parameter overview

Possible awWizardCompletionStep parameters:

Parameter name Possible Values Default Value
[stepId] string null
[stepTitle] string null
[navigationSymbol] {symbol: string, fontFamily?: string} {symbol: ''}
[canEnter] function(MovingDirection): boolean | function(MovingDirection): Promise<boolean> | boolean true
(stepEnter) function(MovingDirection): void null

[awResetWizard]

Sometimes it's also required to reset the wizard to its initial state. In such a case you can use the awResetWizard directive. This directive can be added to a button or a link for example. When clicking on this element, the wizard will automatically reset to its defaultStepIndex.

In addition it's possible to define an EventEmitter, that is called when the wizard is being reset. This EventEmitter can be bound to the (finalize) input of the awResetWizard directive.

Parameter overview

Possible awResetWizard parameters:

Parameter name Possible Values Default Value
(finalize) function(): void null

Accessing the wizard component instance

Sometimes it's required to access the wizard component directly. In such a case you can get the instance of the used wizard component in your own component via:

@ViewChild(WizardComponent)
public wizard: WizardComponent;

Navigating the wizard programmatically

In addition to letting the user navigate the wizard with awNextStep, awPreviousStep and awGoToStep directives, you can trigger navigation programmatically. Use navigation methods exposed by the WizardComponent class:

wizard.goToNextStep();
wizard.goToPreviousStep();
wizard.goToStep(desinationIndex);

Customizing the wizard stylesheets

Sometimes you like to use your own custom CSS for some parts of the wizard like its navigation bar. This is quite easy to do. Different ways are possible:

  1. Either use a wrapper around the wizard:

    <div class="my-custom-css-wrapper">
      <aw-wizard>
        ...
      </aw-wizard>
    </div>
  2. Or add your css wrapper class directly to the wizard element:

    <aw-wizard class="my-custom-css-wrapper">
      ...
    </aw-wizard>

When overriding css properties already defined in the existing navigation bar layouts, it is required to use !important. In addition it is required to add encapsulation: ViewEncapsulation.None to the component, that defines the wizard and overrides its layout. For additional information about how to write your own navigation bar please take a look at the existing navigation bar layouts, which can be found in the archwizard.scss file.

Working with dynamically inserted and removed steps

In some cases it may be required to remove or insert one or multiple steps after the wizard initialization. For example after a user does some interaction with the wizard, it may be required to add or remove a later step. In such situations the wizard supports the removal and insertion of steps in the DOM.

If an earlier step, compared to the current step, has been removed or inserted, the wizard will adjust the current step to ensure that the changed state is valid again.

When removing a step be sure to not remove the step the wizard is currently displaying, because otherwise the wizard will be inside an invalid state, which may lead to strange and unexpected behavior.

Styles Customization

If you are using SCSS, you can customize the wizard's global styles and color theme using SCSS variables:

  1. Import node_modules/angular-archwizard/styles/archwizard.scss into your styles.scss file as described in the Installation section.

  2. Re-define any of the variables you can find at the top of node_modules/angular-archwizard/styles/variables.scss.

In the following example, we configure a simple color theme which only defines styles for two step states: 'default' and 'current'.

// styles.scss

$aw-colors: (
  '_': (
    'default': (
      'border-color-default': #76b900,
      'background-color-default': null,
      'symbol-color-default': #68aa20,
      'border-color-hover': #569700,
      'background-color-hover': null,
      'symbol-color-hover': #569700,
    ),
    'current': (
      'border-color-default': #bbdc80,
      'background-color-default': #bbdc80,
      'symbol-color-default': #808080,
      'border-color-hover': #76b900,
      'background-color-hover': #76b900,
      'symbol-color-hover': #808080,
    )
  )
);

@import '../node_modules/angular-archwizard/styles/archwizard.scss';

Please don't hesitate to look inside node_modules/angular-archwizard/styles/variables.scss for documentation on the $aw-colors variable and other variables you can tweak to tune the wizard to your needs.

Example

You can find an basic example project using angular-archwizard here. The sources for the example can be found in the angular-archwizard-demo repository. It illustrates how the wizard looks like and how the different settings can change its layout and behavior.

angular-archwizard's People

Contributors

achimha avatar adekoder avatar danielruf avatar dependabot[bot] avatar domrich avatar earshinov avatar hugoj-goncalves avatar karimtayie avatar madoar avatar tomaszcz avatar zachrhale avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

angular-archwizard's Issues

Reset wizard

Is it possible to reset wizard as soon as it was finished?
I did not find this functionality in documentation. Thank you

Default step

Hi,

Is there a way to easily set the default step to be selected upon page load?
I would like to not have to click through steps to get to the one I'm currently developing.

I think it could be a nice development feature (disregarding step validation could make it easier I guess)!

Example (selected attribute):
<wizard-step data-title="General" navigationSymbol="1" selected>

Thanks

Support an initially empty wizard

Hello, I hope the following makes sense. In my use case I dynamically construct a wizard based on 4 checkboxes on the page, with each check box corresponding to a wizard step using ngIf to show it.

The issue is, when the page first loads nothing is checked yet and I get this message:
"The wizard doesn't contain a step with index 0"

I have 'hacked' this by going into free-navigation-mode.js line 109 and adding a check for empty wizard steps
FreeNavigationMode.prototype.reset = function () {
if(this.wizardState.wizardSteps.length==0)
return;

If you dont plan to support this Id like to know if there's an alternate way , as Im not crazy about changing the source every time we take an update to the wizard. Thanks for you consideration.

Support RTL steps direction

Hi, I've started using the wizard for a POC and it's amazing, first of all.

Only thing I'm missing is the option to reverse the order of the steps, so that the progression will be from right to left (we're writing in hebrew).

The preffered API would look something like:

<wizard dir="rtl"> <!-- or ltr -->
...
</wizard>

this way it keeps the existing html API of dir="rtl"

Wizard and Wizard-step not getting recognised when used in Modules

screen_shot
Hi ,
I have one Main AppModule and inside that I have one sub Module Subscription Module which I am loading through Routes.

The Wizard and Wizard-step is not getting rendered properly.

If I put the HTML and CSS together in any of the component in the Main App Module. It works.
But I want it to be in Subscription Module only.

I imported WizardModule in Subscription Module and added it in the Providers section also.

Kindly help me with this Issue.

Thanks
Manish Pandit

CSS styles

Hi Wizards Makers

(I am new to Angular so I have limited knowledge if everything is this easy but) so far using your wizard has been great!

I see you are developing external CSS capabilities for the wizard's nav steps. It would be very useful to get a new release with that functionality.

Thanks very much
Aisling

[2.1.0] WizardComponent.navigation undefined

I'm trying to use goToStep in code and have followed previous suggestions but the navigation property seems to be undefined. Let me know what other information I can provide to help.

Aside: Trying to jump to a specific step from a remote page. Is there a good way to use routing with wizard steps? The below example code gives console error: ERROR TypeError: Cannot read property 'goToStep' of undefined

import { Component, OnInit, ViewChild } from '@angular/core';
import { ActivatedRoute } from '@angular/router';

import { WizardComponent } from 'ng2-archwizard';

@Component({
  selector: 'app-my-custom-wizard',
  templateUrl: './my-custom-wizard.component.html',
  styleUrls: ['./my-custom-wizard.component.css']
})
export class MyCustomWizardComponent implements OnInit {
  @ViewChild(WizardComponent)
  public wizard: WizardComponent;

  constructor(private route: ActivatedRoute) {
  }

  ngOnInit() {
    this.route
      .queryParams
      .subscribe((params) => this.wizard.navigation.goToStep(+params.step));
  }

}

Remove selected as alternative to selectedStep. Selected is valid html

Say there are 10 components in a module and one uses the ng2-archwizard. All other modules will fail at runtime if they use selected in a select/option html component.

ERROR Error: Uncaught (in promise): Error: Template parse errors:
No provider for WizardStep ("ustomer:
                        <select disabled class="form-control">
                            [ERROR ->]<option selected>{{specified.customerName}}</option>
                        </select>
              "): ng:///CommissionModule/NewLocationComponent.html@27:28
Error: Template parse errors:

Flexbox in wizard step

In this image the wizard-step does not get set to 100% of the wizard (which is set to 100% of its container in my app). So "space-between" does not have the desired effect.

image

code:

<wizard style="height: 100%;">
    <wizard-step style="
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 100%;"
                 title="Establish Focus Component">
      <app-establish-focus></app-establish-focus>
      <div>
        <hr>
        <button class="btn btn-primary"
                type="button"
                previousStep
                disabled>Back</button>
        <button class="btn btn-primary"
                type="button"
                nextStep>Continue</button>
      </div>
    </wizard-step>
  </wizard>

Basically I want the component to start directly under the navigation and the HR to be at the bottom of the page.

Add index.ts to not have to import from /dist

The WizardModule is exported by the package from ng2-archwizard/dist. That is a bit unusual and no necessary. If you put an index.ts in the root with

export * from ./dist;

it should work without referring to the subdirectory.

[help wanted] How to proceed to next step only after successful http service call / dispatched action with ngrx store

I'm wondering if anyone can offer some suggestions on how to accomplish the following behavior:

My Wizard is a form broken up over multiple steps. There is an http service call when pressing the next button on each wizard step. I want to only proceed to the next step if the service call is successful, otherwise display the error returned by the service.

If using plain injected Angular services I imagine I can import the WizardComponent and use the navigation methods programmatically instead of using the nextStep directive.

pseudo-code:

onProceedToNextStep() {
    this.myService.myServiceMethod()
        .then(() => this.wizard.goToNextStep())
        .catch((err) => { this.error_message = 'There was an error: ' + err; });
}

Would you recommend this approach?

How would I accomplish this if I'm using ngrx store (a reactive state management system) which uses RxJS observables and triggers the service call as a side effect of a dispatched action?:

onProceedToNextStep() {
    this.store$.dispatch(new TriggersCallToMyServiceMethodAction());
    // I want only proceed to next step if the service called as an effect of dispatching this action returns a success, otherwise display error on current wizard step
}

Style the li navigation links

Hi,

My application has a gray-blackish theme.
When I added the wizard control it seems that the current step is disabled and the second step is the active one (Due to the default style provided by the control).

Is there a way to provide my style to the control? (I tried to add a class attribute but it doesn't seems to work).

Thanks,
TMaster

UPDATE

I did dig a bit in the code and I think I have a solution.

according to the less file there are 5 basic colors to use.

I think it would be best if I could supply the colors according to my theme.

What do you think?

need example for form submit using wizard

Wizard standalone works great. with info and some html. Iam struck when trying to wrap it up with some form tags like text box. My goal is to get inputs of user and submit.

<wizard #wizard>

    <!-- Validation Checks for Fullname. (hasError or errors can be used) -->
    <div class="sign-up-error" *ngIf="responsemsg?.length >0 &&
            responsemsg === 'Username does not exist'                
            ">{{responsemsg}}</div>

  </div>

Wizard step lazy loading

Hi, is there a way to lazy load components inside a wizard-step?

For example, I have 2 wizard-step each one with a custom component inside. The first time that the wizard shows in the screen, those 2 components call the ngOnInit() function. Instead I need the second component to initialize just when the user reaches the second step.

Meanwhile I'm hadling this by using a *ngIf in every component with an index that stores the current step,
but I believe this is a feature that must come with the wizard itself, isn't it?

perform goToStep programatically

Hi @madoar,

I'm trying to change the step from the program using

@ViewChild(WizardComponent)
public wizard: WizardComponent;

but when I try to call, for example, this.wizard.goToStep (1); I always get the error that goToStep is not defined in wizard.

what am I doing wrong ?
would not you have an example to show?

Thanks in advance.

Clickable Wizard Step

Is there any chance for you to make wizard steps clickable? For example I want to click on the title or icon or number of any wizard step?

This is very nice plugin but lacking this only feature which is much needed for my project.

Navigation Bar Color issues

Hello

When I make a step optional its color automatically green I need a way to programmatically change a step color

e.g if I am on step 1 and all the steps are optional now at start step 1 color should be customizable if step 1 is completed then step color should be green.

ng2-archwizard module can't import with "strict": true flag

Hi,
Congrats for awesome component! I am facing issues when i update the latest version 2.0.0 and above. If i import ng2-archwizard module set with "strict":true in tsconfig.json.
import { ArchwizardModule } from 'ng2-archwizard';
Error throws like
[ts] Could not find a declaration file for module 'ng2-archwizard'. '/mydir/node_modules/ng2-archwizard/index.js' implicitly has an 'any' type.

programmatically calling a goToStep Issue

Hello!

I am facing an issue when programmatically call a goToStep method on my component it says.

ERROR TypeError: this.wizard.goToStep is not a function.

I followed the exact same step that you specified on a ticket no #17

I m using a version "ng2-archwizard": ",2.0.0".

Question - GoToStep Programmatically

Hello!

First of all, congratulations for the great work here, this is a wonderfull component for angular.

I have a simple question about moving from onestep to another.

Is there any way to do it at the typescript side ?

For example, at Step1 I must perform a confirmation message before going on, If the user click on "Ok" it triggers a function on the typescript, and at that function I should move the user to Step2 or Step3.

I tried to implement that by setting a boolean variable and setting it to "canExit", but because of the proccess of the confirmation it doesn't worked as expected.

reset wizard on defined step index

I have followed this issue fix #8

but i got another error

core.es5.js:1020 ERROR Error: Uncaught (in promise): TypeError: _this.wizard.reset is not a function TypeError: _this.wizard.reset is not a function

it seems function reset was not found in WizardComponent

can someone explain about this ?

Allow canExit functions to return promises

Upon resolving, the step would exit if resolved to something truthy, or not if something falsey. A trivial example I can think of would be checking a proposed username against the server before you leave the step. One I am dealing with in my app is getting a Stripe token from CC fields when we leave the step.

Or maybe there is a better pattern I should be using for these kinds of checks?

Expose the wizard as Service

Expose the wizard as a service so that it can be operated dynamically as well.
Current use case that I am dealing with is the introduction of a step dynamically in forward direction into the wizard based on certain condition.

perform goToStep programatically

I should be able to use the goToStep or be able to go to specific step upon initialization of the component based on some condition or based on a route params.

this would be so helpful.

Thanks a lot!

Dynamically Change Navigation Mode

So my application starts off the navigation mode on strict. Depending on what my function returns, I may want to set the navigation mode to free. I have tried to change it dynamically and the wizard doesn't seem to respond correctly. Is this functionality possible?

Not able to override Style

Hi,
Congratulations for creating such a great wizard!
But I am facing issue while trying to write custom css.

  1. the custom style is not reflected until I use ::ng-deep.
  2. The custom style doesn't get preference if I not use !important

My main concern is, we can't use !important, as our project can be use by other projects as dependency. So adding Important at our level will reduce our platforms capability to be customized.

for better understanding please see the snippet below-

::ng-deep .horizontal.large-filled ul.steps-indicator li.current:after { background-color: red; }

Ability to wrap <wizard-step> in own component

Found your library, which seems to be the only one to support Angular 4, so props to you for this awesome thing!
I started implementing some wizard steps and wanted to extract the wizard-steps in their own components.
However when I did this, the controls didn't show up in the wizard.

Libraries used:

  • @angular/*: ^4.2.3
  • typescript: 2.4.0
  • ng2-archwizard= ^1.6.0

Consider this example:

<wizard navBarLocation="top" class="width-80">
    <app-wizard-details></app-wizard-details>
/* more steps here */
  <wizard-completion-step title="Conclusion" navigationSymbol="3">
  </wizard-completion-step>
</wizard>

/* app-wizard-details */
<wizard-step  title="First step" navigationSymbol="1">
  <form [formGroup]="detailsForm" >
    <md-input-container>
      <input mdInput formControlName="name" type="text">
    </md-input-container>
    <md-input-container>
      <input mdInput formControlName="offerNumber" type="text">
    </md-input-container>
  </form>
  <button md-raised-button (finalize)="storeDetails()" nextStep>Next</button>
</wizard-step>

What works is the following, but then I cannot make use of your triggers like canExit and stepEnter, since the callbacks might be defined in the child components, not in the root component:

<wizard-step title="First step" navigationSymbol="1">
    <app-wizard-details></app-wizard-details> /* has the <form> tag as root element now */
</wizard-step>

I'd love to see the support of wrapped wizard-steps implemented. That way, you'd be able to build complex wizards without having everything in one single file.

Oh, and: Sorry for not providing a Plunker, for some reason it won't load your library from unpkg (guess due to proxy issues)

Not able to know the current index and total index after a step enter.

If the wizard step is programmatically added, and then enter a specific step how I get which step I am in and what total step index is?

I think this feature is better to add on event emitter in (postFinalize)
considering each wizard step is programmed and determined by what value was submitted in the previous step.

this.wizard.reset() no longer working

It seems the this.wizard.reset() no longer works.

I receive the error - this.wizard.reset is not a function. I tried the examples provided in another issue post but to no avail. I'm able to access the Wizard component using:

@ViewChild(WizardComponent) public wizard: WizardComponent;

But seems as though there's no reset method any more.

Disable Navigation Bar not working

Disable Navigation Bar is not working or I did not write correctly? I tried True,true and TRUE with and without quote but none of this worked.

image

[canExit]="checkForm()" keep on getting called

Hi ,

I have kept this function to check whether STEP one form is Valid ( as user might do an inspect element and remove disabled from the button) to recheck.

But now the checkForm function keep getting called n number of times even though I have not initiated any action.

Please help me.

Thanks
Manish Pandit

Hide/show an optional step

@madoar
I need your kind support to show me how I can hide/show an optional step using typescript.
I went through your code, I discovered that there is a [hidden()] function in wizard-step.interface.ts
()
However, it only allow get, therefore, I can't set the step hidden proparty.

thank you

Changing Symbol Color

This isn't really an issue, but I didn't find any other way to contact you. This is perfect for what I am trying to do, but I can't find any way to change the color of the symbol (green, red, gray) to something that better fits my project. Is there any way to modify that CSS? Thanks!

ArchWizard Documentation

I included the wizard like the example:

`import { ArchwizardModule } from 'ng2-archwizard';

@NgModule({
imports: [
ArchwizardModule
],
})
export class Module { }`

Unfortunately now is in my component.ts file no documentation to the tool included, normaly the intellisense of visual studio gives me the possible attributes and functions of the included components.

.html file
<wizard #wizard navBarLocation="top" navBarLayout="large-filled-symbols">

.ts file
@ViewChild("wizard") wizard: ArchwizardModule;

import { ArchwizardModule } from 'ng2-archwizard'; gives only the Module and nothing more.

Wizard not loading components for second time

Am getting following error when calling the wizard component second time

Console Error

ERROR Error: The default step index 2 is located after a non optional step
    at StrictNavigationMode.webpackJsonp.../../../../ng2-archwizard/dist/navigation/strict-navigation-mode.js.StrictNavigationMode.reset (vendor.bundle.js:68023)
    at WizardState.webpackJsonp.../../../../ng2-archwizard/dist/navigation/wizard-state.model.js.WizardState.initialize (vendor.bundle.js:68168)
    at WizardComponent.webpackJsonp.../../../../ng2-archwizard/dist/components/wizard.component.js.WizardComponent.ngAfterContentInit (vendor.bundle.js:66545)
    at callProviderLifecycles (vendor.bundle.js:147388)
    at callElementProvidersLifecycles (vendor.bundle.js:147369)
    at callLifecycleHooksChildrenFirst (vendor.bundle.js:147353)
    at checkAndUpdateView (vendor.bundle.js:148465)
    at callViewAction (vendor.bundle.js:148830)
    at execEmbeddedViewsAction (vendor.bundle.js:148788)
    at checkAndUpdateView (vendor.bundle.js:148463)

Issue importing 'ng2-archwizard' from Angular Quickstart

There must be something trivial I'm overlooking, but I'm having trouble importing 'ng2-archwizard' from within a barebones, official Angular Quickstart.

If I begin with the official import instructions - import { WizardModule } from 'ng2-archwizard'; - after doing npm install --save ng2-archwizard, I get the following error:

zone.js:2622 GET http://localhost:3000/ng2-archwizard 404 (Not Found)

Then, if I add the following line - 'ng2-archwizard': 'npm:ng2-archwizard/dist/index.js' - to systemjs.config.js, I get the following error:

zone.js:2622 GET http://localhost:3000/traceur 404 (Not Found)

Then, if I add reference to traceur inside index.html, the error slightly changes, but persists nonetheless:

zone.js:2622 GET http://localhost:3000/node_modules/ng2-archwizard/dist/components/ 404 (Not Found)

Is there something obvious I'm missing either in the way I reference the library or inside the boilerplate Angular Quickstart?

Customize css

Hi @madoar,

congratulations for this job! It's really nice!
I would to use this component instead the component that we are using now. I'd like to know your opinion about the css customization. For example, I would like to customize the layout as is showed on the attached image.
steps

Thank you

Rename project

ng2-archwizard is not really a suitable name anymore as it targets Angular 4 and there will soon be Angular 4.

What about ngx-archwizard or ng-archwizard? Both are available in npm.

The upcoming 2.0 would be a good opportunity to make this change.

Global configurations with forRoot(_options)

I want to change the defaults for my project to fit the need and currently, I have to do everywhere in the project to keep all wizard symmetric. I think there should be an option in forRoot where the user can overwrite all defaults for wizard and wizard-steps globally.

Dynamically add selectedStep to wizard-step

How can I add selectedStep dynamically to wizard step?. for example I want the second wizard step to be selected by default.
here is my code

<wizard> <wizard-step stepTitle="{{question.name}}" *ngFor="let question of questions"> // code </wizard-step> </wizard>

Layout issue with titles

The steps indicator should probably provide support for situations where the screen is not wide enough to fit all step titles.

screen shot 2017-05-27 at 16 25 51

Any suggestions how to do this?

Add Wizard Step Validation

Hi there,

Is it possible to add "Wizard Step Form Validation"? Simply disable "Next" button until all required form fields filled?

Thanks,

Webpack Build Failed

ERROR in ./node_modules/ng2-archwizard/index.ts
Module build failed: Error: Typescript emitted no output for /home/test/apps/test-webpack/node_modules/ng2-archwizard/index.ts.
You should not need to recompile .ts files in node_modules.
Please contact the package author to advise them to use --declaration --outDir.
More microsoft/TypeScript#12358

This is the error I am getting while doing a webpack build with the plugin. Any ideas ?

Thanks.

'wizard-step' is not a known element

Hello,

I'm using Angular 4 in my project. I added ng2-archwizard to my project like in the manual. I'm getting a lot of errors starting with

'wizard-step' is not a known element

Where am I wrong?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.