Git Product home page Git Product logo

angular-wizard's Introduction

Angular-Wizard

Build Status Codacy Badge Coverage Status npm version PayPal donate button Donate on Gratipay

Angular-wizard is a component that will make it easy for you to create wizards in your app. You can check a running example of the wizard by clicking here

How do I add this to my project?

You can download this by:

  • Using bower and running bower install angular-wizard
  • Using npm and running npm install angular-wizard
  • Downloading it manually by getting the files from the dist folder
  • Using JsDelivr CDN files:
<!-- Use LATEST folder to always get the latest version-->
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/angular-wizard@latest/dist/angular-wizard.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/angular-wizard@latest/dist/angular-wizard.min.css">

<!-- Or use TAG number for specific version -->
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/[email protected]/dist/angular-wizard.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/angular-wizard.min.css">

The dist folder contains the following files:

  • JS files needed for the directives and services
  • CSS files with default styles for the directive
  • LESS file with styles for the directive. If you have less in your project, I recommend using the less instead of the CSS since it has variables to configure Wizard colors.

Dependencies

Angular-wizard depends on Angular.

Starter Guide

First example

The first thing we need to do is add a dependency to angular-wizard module which is called mgo-angular-wizard.

We can do this simply by doing:

angular.module('your-app', ['mgo-angular-wizard']);

Now, in some HTML for a controller, you can just add a wizard as follows:

<wizard on-finish="finishedWizard()" on-cancel="cancelledWizard()"> 
    <wz-step wz-title="Starting">
        <h1>This is the first step</h1>
        <p>Here you can use whatever you want. You can use other directives, binding, etc.</p>
        <input type="submit" wz-next value="Continue" />
    </wz-step>
    <wz-step wz-title="Continuing">
        <h1>Continuing</h1>
        <p>You have continued here!</p>
        <input type="submit" wz-next value="Go on" />
    </wz-step>
    <wz-step wz-title="More steps">
        <p>Even more steps!!</p>
        <input type="submit" wz-next value="Finish now" />
    </wz-step>
</wizard>

This will look like the following when you're in the second step:

Looks like

Let's go step by step to see how this works.

  1. You need to declare a master wizard directive. This wizard directive, has the following options as attributes:
  • on-finish: Here you can put a function to be called when the wizard is finished. The syntax here is very similar to ng-click
  • on-cancel: Here you can put a function to be called when the wizard is cancelled. The syntax here is very similar to ng-click
  • name: The name of the wizard. By default, it's called "Default wizard". It's used for the WizardHandler which we'll explain later.
  • edit-mode: If set to true, this will set the wizard as edit mode. Edit mode means that all steps have been completed and the user can now navigate to and modify any step. Defaults to false.
  • hide-indicators: If set to true, the indicators in the bottom of the page showing the current page and allowing navigation for the wizard will be hidden. Defaults to false.
  • current-step: You need to set here a property from your scope (similar to ng-model) and that property will always have the name of the current step being shown on the screen.
  • template: Path to a custom template.
  • indicators-position: Can use "top" or "bottom" to specify default position for steps.
  1. Inside the wizard, we can have as many steps as we want. Each step MUST have a title which is going to be used to identify it. Inside each step, we can put whatever we want. Other directives, bindings, controls, forms, etc. Each step can have the following attributes (we will go into detail on each further below):
  • wz-title: A unique title used for identifying each step.
  • wz-heading-title A heading title display above step indicators
  • canenter
  • canexit
  • wz-disabled
  • description: A description available to use in each step's UI.
  • wz-data Data you wish to make available to the steps scope.
  • wz-order The order in which the steps should be in. If no order or duplicated order it will add the step to the end.
  1. Inside the step, we now see a button which has a wz-next attribute. That means that clicking that button will send the user to the next step of wizard. Similar to wz-next, we have the following attributes:
  • wz-previous: Goes to the previous step
  • wz-cancel: Calls on-cancel if defined, otherwise the default action is to go back to the first step
  • wz-finish: Finishes the wizard and calls the on-finish later on. It's important to note that if we're in the last step and we put wz-next it'll be the same as putting wz-finish as the wizard will know we're at the last screen.
  • wz-reset: This will reset the wizard meaning bring the user to the first step and reset each step to being incomplete.

All of this attributes can receive an optional function to be called before changing the step. Something like:

<input type="button" wz-next="setMode(mode)" value="Next" />

In this case, the setMode function will be called before going to the next step.

Wizard Dynamic Steps

A step can be conditionally disabled and may change at any time either adding it or removing it from the wizard step flow.

Example

HTML

<wizard on-finish="finishedWizard()" on-cancel="cancelledWizard()"> 
    <wz-step wz-title="Starting" wz-disabled="{{disabled}}">
        <h1>This is the first step</h1>
        <p>Here you can use whatever you want. You can use other directives, binding, etc.</p>
        <input type="submit" wz-next value="Continue" />
    </wz-step>
    <wz-step wz-title="Continuing">
        <h1>Continuing</h1>
        <p>You have continued here!</p>
        <input type="submit" wz-next value="Go on" />
    </wz-step>
    <wz-step wz-title="More steps">
        <p>Even more steps!!</p>
        <input type="submit" wz-next value="Finish now" />
    </wz-step>
</wizard>

Controller

//this will cause the step to be hidden
$scope.disabled = 'true';

Wizard Step Validation

The wzStep directive has the following options as attributes:

  • canexit: Here you can reference a function from your controller. If this attribute is listed the function must return true in order for the wizard to move to the next step. Promises are supported but must resolve with a thruthy value. If it is ommitted no validation will be required.
  • canenter: Here you can reference a function from your controller. If this attribute is listed the function must return true in order for the wizard to move into this step. Promises are supported but must resolve with a thruthy value. If it is ommitted no validation will be required.

Example

HTML

<wizard on-finish="finishedWizard()" on-cancel="cancelledWizard()"> 
    <wz-step wz-title="Starting" canexit="exitValidation">
        <h1>This is the first step</h1>
        <p>Here you can use whatever you want. You can use other directives, binding, etc.</p>
        <input type="submit" wz-next value="Continue" />
    </wz-step>
    <wz-step wz-title="Continuing" canenter="enterValidation">
        <h1>Continuing</h1>
        <p>You have continued here!</p>
        <input type="submit" wz-next value="Go on" />
    </wz-step>
    <wz-step wz-title="More steps">
        <p>Even more steps!!</p>
        <input type="submit" wz-next value="Finish now" />
    </wz-step>
</wizard>

Controller

$scope.enterValidation = function(){
    return true;
};

$scope.exitValidation = function(){
    return true;
};
//example using context object
$scope.exitValidation = function(context){
    return context.firstName === "Jacob";
}
//example using promises
$scope.exitValidation = function(){
    var d = $q.defer()
    $timeout(function(){
        return d.resolve(true);
    }, 2000);
    return d.promise;
}

If a step requires information from a previous step to populate itself you can access this information through the context object. The context object is automatically passed in as an argument into your canexit and canenter methods. You can access the context objext from your controller via: WizardHandler.wizard().context

Manipulating the wizard from a service

There are some times where we actually want to manipulate the wizard from the controller instead of from the HTML.

For those cases, we can inject the WizardHandler to our controller.

The main function of this service is the wizard(name) which will let you get the wizard to manipulate it. If you have just one wizard in the screen and you didn't set a name to it, you can just call it as wizard(). Let's see an example:

<wz-step wz-title="Cool step">
    <input type="submit" ng-click="changeLabelAndGoNext()" />
</wz-step>
// In your controller
$scope.changeLabelAndGoNext = function() {
    $scope.model.label = "Hola Gonto";
    WizardHandler.wizard().next();
}

In this case, we're changing a label and moving forward on the steps. The functions available in the wizard() are:

  • next: Goes to the next step.
  • previous: Goes to the previous step.
  • cancel: Goes to the previous step.
  • reset: Goes to the first step and resets all steps to incomplete.
  • finish: Finishes the wizard.
  • goTo(number|title): This goes to the indicated step. It can receive either the number of the step (starting from 0) or the title of the step to go to.
  • currentStepNumber(): This returns a Number which is the current step number you are on.
  • currentStepTitle(): This returns a String which is the title of the step you are on.
  • currentStepDescription(): This returns a String which is the description of the step you are on.
  • currentStep(): This returns an Object which is the current step you are on.
  • totalStepCount(): This returns an Number which is the total number of enabled steps.
  • getEnabledSteps(): This returns an Array which is the enabled steps.
  • setEditMode(boolean): 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.

Events

Angular Wizard emits the following events on the scope and pass an object with the step info and the index as argument:

  • wizard:stepChanged: When succeed changing the current step
  • wizard:stepChangeFailed: When changing step and either fails canexit of leaving step or canenter of arriving step.
$scope.$on('wizard:stepChanged',function(event, args) {
    console.log(args);
}

Navigation bar

Any changes you wish to make to the navigation bar can be done by overwritting the CSS. Because everyone wants the navigation bar in a different location and in a different style we have provided a default which you can change via your own HTML and CSS. The navigation bar shown below works in the following way:

  • Completed steps are painted as green
  • Current step is painted as dark grey
  • Future step is painted as light grey
  • Editing step (Modifying a step already completed in the past) is painted as red
  • You can click in any completed step to go back to that step. You can't click in the current step nor in the future ones unless you've already completed a future step before (for example in EditMode all steps are completed by default)

Color Definitions

All of those colors are variables in the angular-wizard.less. You can easily change them by importing the angular-wizard.less file into your own less file(s) and change the variables. The available variables are:

  • @wz-color-default
  • @wz-color-done
  • @wz-color-current
  • @wz-color-editing

Contributors

  • @sebazelonka helped me with all of the styles in the Wizard.
  • @jacobscarter is helping with manteinance, PRS merging and adding new features

Live sample

You can check out a live sample of the Wizard clicking here

Releases Notes

Releases notes are together with releases in GitHub at: https://github.com/angular-wizard/angular-wizard/releases

License

The MIT License

Copyright (c) 2013-2014 Martin Gontovnikas http://www.gon.to/

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Bitdeli Badge

angular-wizard's People

Contributors

bitdeli-chef avatar brendan6 avatar cspinetta avatar debiese avatar drmikecrowe avatar esteinborn avatar gmanriqueuy avatar graingert avatar jacobjust avatar jacobscarter avatar kaihenzler avatar kevalbhatt avatar maplesyrupghost avatar mgonto avatar morenoh149 avatar nathanil avatar pluswave avatar raykin avatar rtucker88 avatar starr0stealer avatar stevecd avatar tandibar avatar tanepiper avatar thematrimix avatar tybot204 avatar tylerlh avatar valentinfunk 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  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

angular-wizard's Issues

Navigation line renders incorrectly

I tried using angular-wizard 0.4.2 on my site but it rendered incorrectly with three nodes on all major browsers: the line draws ~10% too far to the right. To simplify the problem, I assembled a JSBin using 0.4.0. Right out of the box, the line renders incorrectly.

Are there plans to get this tool to work with Yeoman?

Currently, when I add the path to the angular-wizard.css files in my index.html file and then run the yeoman "grunt build" command, the path to the angular-wizard.css file is removed from index.html.

Not sure how exactly to integrate the two, but I wanted to ask if anyone was aware of how to make the two tools work together. Any ideas?

how can i i18n the step title?

hi mgonto, thanks for your wizard.
but i have a question.
i need to change the step title in mayn languages, but the title is the step id.
if i change it in other language it means i could not found the id in next().

could you add a $scope.displayTitle ?

and one more about the navigationbar.
i can use WizardHandler.wizard().next() move to the next step,
and add some check before it.
but how about the navigationbar?
if form have something wrong, and i click the nav bar, can i break the move behavior?

Running code when a step is shown

Is there a good way to run code when a specific wizard step is shown?

The best I thought of so far is catching the wizard-step-changed event, checking if the new step equals to the step I am running in and if so executing my code.

However, it seems a bit of a drag to run it in every step I have logic that should be run when it is shown.

Start at specific step

Is it possible to make the wizard start at a specific step. For example an application configuration wizard that has 5 steps and a user has only previously completed 3/5, so when they next load the page it goes straight to step 4/5.

I have the setup "status" in my controller that wraps the wizard, however when I run:

angular.module('hoarder.wizard')
        .controller('WizardController', ['SETUP_STATUS', 'WizardHandler',
            function (SETUP_STATUS, WizardHandler) {
                if (SETUP_STATUS.status !== 0) {
                   WizardHandler.wizard().goTo(SETUP_STATUS.status);
                }
}])
WizardHandler.wizard()

The above line returns undefined. Not sure what I am doing wrong/if this is possible?

Update bower

Looks like there are some useful new features that the current 0.3.0 version does not have. Possible to bump the version and update Bower in the process?

Use ng-if instead of ng-show to show/hide wizard steps

Today in step.html there is the following code: <section **ng-show**="selected"...

I have 2 issues with that:

  1. It makes it hard for me to write code that would run only when the step is shown. For example, I am using a focus directive in the steps, whose link functions runs when the directive is added to the DOM. However, since the code is rendered right away, all the focus code runs immediately and in effect, once you get to the right step, the focus is no longer there.
  2. Performance issue - Per this thread. Since ng-if actually removes HTML from the DOM, it has a great performance advantage, especially in big wizards.

I've tried to change ng-show to ng-if myself, but it didn't work. I didn't check too deeply to why it doesn't work.

Directive Names Conflicting With HTML5 Step Attribute

Hey,

I'm using the HTML5 step attribute and your wizard "step" directive is conflicting with it. Can we prefix your step directive with mgo- or something to fix this namespacing issue?

You can see the step attribute explained on MDN at https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Input.

This conflict resulted in the following error: Controller 'wizard', required by directive 'ngTransclude', can't be found.

I can open a PR for this if you'd like to proceed with this proposed fix.

how to validate all steps in edit-mode

hi all,
now canexit/canenter were added, but if i use editMode,
how can i validate all steps?
e.g.
i have a wizard for regist.
steps:
account, infos, options.
infos has error.
but i can jump to options from account, and then press finish button.

can i get all steps validate infos? if invalid, can i jump back to the first invalid step?

how can i get the steps

i can get the currentStep, but only currentStep's title is no use.
i dont have steps info, or tab index.

the first page , i can get the index from 'wizard:stepChanged', but the last page?
i have no idea.

IE issue in steps

Hi,
This wizard working exactly as described in all browsers except IE. All steps are click-able in internet explorer when wizard is not in edit mode.It should not be click-able in save mode[not edit mode] because it follow the next button not steps. I agree in edit mode all steps are click-able and working fine in IE too. I am using IE 9. So please help me on this ASAP.
Thanks Advance.

Validation rules

First, thanks for angular-wizard!
It would be interesting to add the possibility to use some validation rules in order to progress or not to the next step (something like in the Pines Steps project).
I think to something really simple: when you define a function on a wz-next attribute, why not return a boolean to authorize or not progression? Or perhaps, the use of another attribute?

Thanks.

Reset wizard for different entry

Is there any way to reset steps and return to first step? I want to use same wizard for multi entries. Maybe I need to have more wizards and switch between them ? Thanks !

Animations with NGAnimate?

I'm sorry, I didn't see in the documentation, does this support animation with ng-animate? If so, what is the syntax?

About using current-step

Hello,

Interesting by knowing the current step name, I tried the attribute current-step on the wizard directive, giving as value, a property name of my scope e.g. stepName.
I noticed that if I give an initial value different of '' or undefined, my scope variable is well updated, but not in the contrary case (or if I don't initialize the variable).

How am I supposed to intialize this scope property?

Thank you!

Bertrand.

step directive causing issues with input[type="number"]

When attempting to use the step attribute on an input with the type of number, I get errors for the angular-wizard directive.

Error: [$compile:ctreq] Controller 'wizard', required by directive 'ngTransclude', can't be found!
http://errors.angularjs.org/1.2.15/$compile/ctreq?p0=wizard&p1=ngTransclude
    at http://dclark.local:4000/assets/js/portal.js:6297:12
    at getControllers (http://dclark.local:4000/assets/js/portal.js:12399:19)
    at nodeLinkFn (http://dclark.local:4000/assets/js/portal.js:12570:35)
    at http://dclark.local:4000/assets/js/portal.js:12789:13
    at http://dclark.local:4000/assets/js/portal.js:13952:11
    at deferred.promise.then.wrappedCallback (http://dclark.local:4000/assets/js/portal.js:17319:81)
    at deferred.promise.then.wrappedCallback (http://dclark.local:4000/assets/js/portal.js:17319:81)
    at http://dclark.local:4000/assets/js/portal.js:17405:26
    at Scope.$get.Scope.$eval (http://dclark.local:4000/assets/js/portal.js:18394:28)
    at Scope.$get.Scope.$digest (http://dclark.local:4000/assets/js/portal.js:18223:31) <section ng-show="selected" ng-class="{current: selected, done: completed}" class="step ng-isolate-scope ng-pristine ng-valid" ng-transclude="" type="number" name="index_value" ng-model="index_value" step="0.1"> 

My HTML is as follows:

<input type="number" name="index_value" ng-model="index_value" step="0.1">

I suggest the step directive be renamed to wz-step or something that does not conflict with a native HTML attribute.

_ is not defined

when using this as an include through bower install angular-wizard and then doing an include of dist/angular-wizard.min.js -- it will throw an error about _ not being defined.

I included lodash.underscore.min.js (from another library) to fix this, I notice it says lodash is a dependency in the README file.

But perhaps you can make this more clear in the README that you are going to need to include both lodash & the core files?

Consider namespacing

Hey @mgonto !

Cool stuff here. However before it gets too popular I would like give you a tip that would introduce a breaking change though. I saw you have a directive next to step to the next step (obviously).

Just a little advice next is very generic and could also be used in any other module. How about prefixing your specific directive for this module?

Sth. like <ANY wz-next></ANY> or so..

Cheers!

angular-wizard won't work when used within a angular-ui modal window

I get the following error when trying to use the directives within a angular-ui modal:

ReferenceError: _ is not defined
at unselectAll (https://cdnjs.cloudflare.com/ajax/libs/angular-wizard/0.4.0/angular-wizard.js:111:17)
at Scope.$scope.goTo (https://cdnjs.cloudflare.com/ajax/libs/angular-wizard/0.4.0/angular-wizard.js:102:17)
at addStep (https://cdnjs.cloudflare.com/ajax/libs/angular-wizard/0.4.0/angular-wizard.js:97:28)
at link (https://cdnjs.cloudflare.com/ajax/libs/angular-wizard/0.4.0/angular-wizard.js:45:20)
at https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.0/angular.js:8105:44
at invokeLinkFn (https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.0/angular.js:8111:9)
at nodeLinkFn (https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.0/angular.js:7623:11)
at delayedNodeLinkFn (https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.0/angular.js:7872:11)
at compositeLinkFn (https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.0/angular.js:6991:13)
at publicLinkFn (https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.0/angular.js:6870:30)

The partial referenced by the modal controller is as follows:
(modal-theme.html)

    <div class="modal-header">
        <h3 class="modal-title">Theme Customization Wizard</h3>
    </div>
    <div class="modal-body">
      <div ng-controller="WizardCtrl">
            <wizard on-finish="finished()">
              <wz-step title="Start">
                <h1>Start</h1>
                <p>Hey guys, welcome to the wizard :).</p>
                <p>Otherwise, let's continue with the wizard. Please <a href="" wz-next>click here to continue</a></p>
                <input type="submit" wz-next value="Or click here"/>
              </wz-step>
              <wz-step title="Pane1">
                <h1>Pane1</h1>
                <p>Pane 1</p>
                <p>Otherwise, let's continue with the wizard. Please <a href="" wz-next>click here to continue</a></p>
                <input type="submit" wz-next value="click here"/>
              </wz-step>
              <wz-step title="Finish him">
                <h1>Finish</h1>
                <p>Finally this ends!</p>
                <input type="button" wz-next value="Click here to end" />
              </wz-step>
            </wizard>
        </div>
    </div>
    <div class="modal-footer">
        <button class="btn btn-primary" ng-click="ok()">OK</button>
        <button class="btn btn-warning" ng-click="cancel()">Cancel</button>
    </div>

This constitutes nested controllers and it appears angular-wizard scope is conflicting with the parent (modal controller) scope.

Clean all steps

Hi,

I have added the wizard in a popup. When i click on my create button, the popup is displayed and the wizard work fine. I filled all steps and on finish i do a HTTP request and the popup is hidden. When i click again on the create button, the popup is displayed with all the steps done, due to the previous creation.

There is a way to clean up all the steps ?

Dynamic Steps in a Wizard

Hi:
I would like to implement a wizard which would have dynamic steps, meaning a model value from one step would decide whether or not subsequent steps are required. How do I achieve this with the current version of angular-wizard?
Thanks in advance

When ng-hide is set on on a wz-step, it still shows in the progress bar.

One of the best things about Angular form validation, is it's easy to make conditional form flow, since it won't attempt to validate a hidden form.

When adding ng-hide/ng-show to a wizard step, Angular Wizard should hide/show it's corresponding dot on the progress, which would make a much easier flow for creating wizards for say, differing user types and such.

Mobile Keyboard and Navigation Line

If you use the wizard in a mobile device, when the keyboard appers the navigation line appears in the middle of the screen instead of the buttom.

I have just tested in Android with Galaxy S3, but I guess this problem will be identical in any device.

Additional custom data on step

Is it possible to have an additional property wz-data for example to put custom data in step. It could be nice to customize wizard header with data from state.

Bower Install Different From Github

Take a look at dist/angular-wizard.js. When i do bower install angular-wizard, I get a version of wz-step that is missing canexit and canenter.

The version on Github has these two callbacks on the scope object for the wz-step directive, but bower is giving me a version from 2014-04-25.

Could you please update the bower package?

Wizard step validators added in canenter/canexit unaware of wz-previous or wz-next direction

If you have some inputs on one of the steps that requires validation, it would most certainly be done via canexit callback. But canexit is called regardless of wz-next or wz-previous is pressed.

The weird problem I faced in my application is that I cannot return to the previous step unless all fields are filled up correctly, which is not the desirable effect. It would be perfect if canexit callback was aware of direction we are jumping to and take a decision whether to run validation or not.

The way I found to work around this problem is simply by moving validation logic to canenter of the next page (this allows to use wz-previous without any constraints). Of course, I am not using steps indicator and the switching between the steps is done without jumping, straightforward next or previous. As you can see, this is not too much convenient.

Take a quick look if you want to fix it, it should be very easy: I guess a matter of few-lines fix.
Thanks.

canexit and canenter as expression

Is it possible to have an expression instead a function in canexit and canenter attributes ?

I've put nested ng-form in each step. I'd like to have this syntax :

 <wz-step title="step1" ng-form="formStep" canexit="formStep.$valid">
 </wz-step>

Wrap wz-step in another directive

Hi how is it possible to do this:

<wizard on-finish="finishedWizard()" current-step="currentStep" hide-indicators="true">
  <wz-step title="step1" canexit="validateStep">
   step body
  </wz-step>
</wizard>

to:

<wizard on-finish="finishedWizard()" current-step="currentStep" hide-indicators="true">
  <step-one></step-one>
</wizard>

step-one directive contains the wz-step is it possible and how?

model not propagating between wzsteps

in the following code fragment....

      <wz-step title="Start">
        <h2>General Information</h2>
        Group Name:<input ng-model="groupName" type="text"/>
        <br>
        <br>
        <input type="submit" wz-next value="Continue..."/>
      </wz-step>
      <wz-step title="2" >
        <h2>Define your Group Structure for {{groupName}}</h2>
        <input type="submit" wz-next value="Continue..."/>
      </wz-step>

the model item groupName isn't available in the 2nd wzStep. I was expecting it to be populated with what was typed in the first step of the wizard. Any ideas?

Each step shows title on hover

Using the html title attribute causes this to show on a step, on hover. eg:

<wz-step title="myStep">

Instead, we could use data-title. It seems to work well:

<wz-step data-title="myStep">

Navigating with Step Indexes

I have added functionality to both emit the step and step index when the step changes as well as navigating to a step given an index. I am using this functionality to update the query string as to which step the user is currently on and jumping to that given step in the event of a page refresh.

If this is functionality you would like to have, I can send a pull request.

Add a method to mark the current step as completed

Hi,

And thank you for angular-wizard :)

It seems that currently the Wizard assumes that all steps are mandatory because the only way to mark a step as completed is to use the WizardHandler.wizard().next() method.

I'm building a Wizard with optionnal steps using the WizardHandler.wizard().goTo() method.

What do you think about adding a param to WizardHandler.wizard().goTo(step, completed) or adding a new method like:

this.completeSelectedStep = function() {
    $scope.selectedStep.completed = true;
};

Error when using wz-next directive

I am getting the following error:
TypeError: Object [object Object] has no method 'on'
at angular.module.directive.link (http://cdn.jsdelivr.net/angular.wizard/latest/angular-wizard.js:156:30)
at nodeLinkFn (https://ajax.googleapis.com/ajax/libs/angularjs/1.1.5/angular.js:4959:13)

for what i can see, the $element passed to the directive is a jqlight object and not the element itself. to get the element the line should be something like $element[0].on("click")....

any ideas why nobody else is experiencing this issue?

IE8 Support

Currently there is an error in IE8 that causes forms to not submit.

   Error: [$compile:ctreq] Controller 'wizard', required by directive 'wzNext', can't be found!
   Error: [$compile:ctreq] Controller 'wizard', required by directive 'wzFinish', can't be found!
  Error: [$compile:ctreq] Controller 'wizard', required by directive 'ngTransclude', can't be found!
   Error: [$compile:ctreq] Controller 'wizard', required by directive 'ngTransclude', can't be found!

I'll troubleshoot and if I find a fix I will post it here.

Step validation?!

Currently maybe It's just missing the documentation part, but is there an easy way to validate all the steps?
Currently we previously used https://github.com/VinceG/twitter-bootstrap-wizard but since that wizard isn't 'that' good we will change to the one you provide. But we need an easy way to validate all ours steps.
there should be a handler where we could inject a a function like _validate_steps().

Is this possible at all?

Edit:
I found out a way.
I just patched $scope.goTo = funcion(step) where it has an if like that:

$scope.goTo = function(step) {
                    var index = _.indexOf($scope.steps , step);
                    if (self._validate_step(step) || index == 0) {
                        unselectAll();
                        $scope.selectedStep = step;
                        if (!_.isUndefined($scope.currentStep)) {
                            $scope.currentStep = step.title || step.evTitle;
                        }
                        step.selected = true;
                        $scope.$emit('wizard:stepChanged', {step: step, index: index});
                    }
                };

now i've also added the _validate_step function:

                self._validate_step = function(step) {
                    var handler = WizardHandler.getValidation($scope.name || WizardHandler.defaultName);
                    var result = _.reduce(handler, function(result, fn) {
                        var ret = fn(step);
                        return result && (angular.isDefined(ret) ? ret : true);
                    }, true);
                    console.log(result);
                    return result
                }

and added two helper functions to the Handler:

       var _validation_methods = {}

       service.addValidation = function(name, fn) {
            var nameToUse = name;
            if(!fn) {
                nameToUse = service.defaultName;
                fn = name;
            }
            if (!_validation_methods.nameToUse) {
                _validation_methods[nameToUse] = [];
            }
            _validation_methods[nameToUse].push(fn);
       };

       service.getValidation = function(name) {
            var nameToUse = name;
            if(!name) {
                nameToUse = service.defaultName;
            }
            return _validation_methods[nameToUse];
       }

now you could add validation functions to the wizard as you want.

Edit2: Also it would be great that you change the license to the Apache License since I would contribute a patched version to your code to the Openstack Project and its way better to contribute APL2 Code instead of MIT Code (MIT is not permitted but the Rest of the Project ist mostly APL2)

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.