Skip to content

Commit

Permalink
Merge branch 'KodeShark-showAbstract'
Browse files Browse the repository at this point in the history
  • Loading branch information
ncuillery committed Mar 27, 2015
2 parents f290ca3 + 0e8ecf2 commit 695764f
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 8 deletions.
13 changes: 10 additions & 3 deletions dist/angular-breadcrumb.js
@@ -1,4 +1,4 @@
/*! angular-breadcrumb - v0.3.3-dev-2015-03-21
/*! angular-breadcrumb - v0.3.3-dev-2015-03-27
* http://ncuillery.github.io/angular-breadcrumb
* Copyright (c) 2015 Nicolas Cuillery; Licensed MIT */

Expand Down Expand Up @@ -56,7 +56,9 @@ function $Breadcrumb() {
var $$addStateInChain = function(chain, stateRef) {
var conf,
parentParams,
ref = parseStateRef(stateRef);
ref = parseStateRef(stateRef),
force = false,
skip = false;

for(var i=0, l=chain.length; i<l; i+=1) {
if (chain[i].name === ref.state) {
Expand All @@ -65,7 +67,12 @@ function $Breadcrumb() {
}

conf = $state.get(ref.state);
if((!conf.abstract || $$options.includeAbstract) && !(conf.ncyBreadcrumb && conf.ncyBreadcrumb.skip)) {
// Get breadcrumb options
if(conf.ncyBreadcrumb) {
if(conf.ncyBreadcrumb.force){ force = true; }
if(conf.ncyBreadcrumb.skip){ skip = true; }
}
if((!conf.abstract || $$options.includeAbstract || force) && !skip) {
if(ref.paramExpr) {
parentParams = $lastViewScope.$eval(ref.paramExpr);
}
Expand Down
4 changes: 2 additions & 2 deletions dist/angular-breadcrumb.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 9 additions & 2 deletions src/angular-breadcrumb.js
Expand Up @@ -51,7 +51,9 @@ function $Breadcrumb() {
var $$addStateInChain = function(chain, stateRef) {
var conf,
parentParams,
ref = parseStateRef(stateRef);
ref = parseStateRef(stateRef),
force = false,
skip = false;

for(var i=0, l=chain.length; i<l; i+=1) {
if (chain[i].name === ref.state) {
Expand All @@ -60,7 +62,12 @@ function $Breadcrumb() {
}

conf = $state.get(ref.state);
if((!conf.abstract || $$options.includeAbstract) && !(conf.ncyBreadcrumb && conf.ncyBreadcrumb.skip)) {
// Get breadcrumb options
if(conf.ncyBreadcrumb) {
if(conf.ncyBreadcrumb.force){ force = true; }
if(conf.ncyBreadcrumb.skip){ skip = true; }
}
if((!conf.abstract || $$options.includeAbstract || force) && !skip) {
if(ref.paramExpr) {
parentParams = $lastViewScope.$eval(ref.paramExpr);
}
Expand Down
6 changes: 5 additions & 1 deletion test/mock/test-modules.js
Expand Up @@ -27,7 +27,11 @@ angular.module('ncy-abstract-conf', []).config(function($stateProvider) {
.state('D.E', {url: '/e', abstract: true, ncyBreadcrumb: {label: 'State E'}})
.state('D.E.F', {url: '/f', ncyBreadcrumb: {label: 'State F'}})
.state('G', {url: '/g', abstract: true, ncyBreadcrumb: {label: 'State G', skip: true}})
.state('G.H', {url: '/h', ncyBreadcrumb: {label: 'State H'}});
.state('G.H', {url: '/h', ncyBreadcrumb: {label: 'State H'}})
.state('I', {url: '/i', abstract: true, ncyBreadcrumb: {label: 'State I', force: true}})
.state('I.J', {url: '/j', ncyBreadcrumb: {label: 'State J'}})
.state('K', {url: '/k', abstract: true, ncyBreadcrumb: {label: 'State K', skip: true, force: true}})
.state('K.L', {url: '/l', ncyBreadcrumb: {label: 'State L'}});
});

/**
Expand Down
11 changes: 11 additions & 0 deletions test/spec/service-abstract-test.js
Expand Up @@ -26,6 +26,17 @@ describe('Service with abstract conf', function() {
expect(stringifyStateChain(statesChain)).toBe('G.H');
}));

it('should return a two step route to I.J', inject(function($breadcrumb) {
goToState('I.J');
var statesChain = $breadcrumb.getStatesChain();
expect(stringifyStateChain(statesChain)).toBe('I --> I.J');
}));

it('should return a one step chain to K.L', inject(function($breadcrumb) {
goToState('K.L');
var statesChain = $breadcrumb.getStatesChain();
expect(stringifyStateChain(statesChain)).toBe('K.L');
}));
});

describe('with abstract state inclusion', function() {
Expand Down

0 comments on commit 695764f

Please sign in to comment.