diff --git a/CHANGELOG.md b/CHANGELOG.md index 7fa0e4f..0fc45e5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,22 @@ + +## 0.5.5 (2017-07-20) + +#### Bug Fixes +* Ensuring that nesting only starts from current navigated to id closes [#159] - Bug on this change below + + + +## 0.5.2 (2017-07-20) + +#### Bug Fixes +* Ensuring that nesting only starts from current navigated to id closes [#159] - Bug on this change below + + +## 0.5.1 (2017-07-20) + +#### Bug Fixes +* Ensuring that nesting only starts from current navigated to id closes [#159] + ## 0.5.0 (2016-11-14) diff --git a/bower.json b/bower.json index 96b52f5..b1dbf88 100644 --- a/bower.json +++ b/bower.json @@ -1,7 +1,7 @@ { "name": "angular-breadcrumb", "description": "AngularJS module that generates a breadcrumb from ui-router's states", - "version": "0.5.0", + "version": "0.5.5", "main": "release/angular-breadcrumb.js", "ignore": [ "sample", diff --git a/dist/angular-breadcrumb.js b/dist/angular-breadcrumb.js index 53d025d..184a3e7 100644 --- a/dist/angular-breadcrumb.js +++ b/dist/angular-breadcrumb.js @@ -1,4 +1,4 @@ -/*! angular-breadcrumb - v0.4.1-dev-2016-04-12 +/*! angular-breadcrumb - v0.5.5 * http://ncuillery.github.io/angular-breadcrumb * Copyright (c) 2016 Nicolas Cuillery; Licensed MIT */ @@ -37,7 +37,8 @@ function $Breadcrumb() { templateUrl: null, templateLast: 'default', templateLastUrl: null, - includeAbstract : false + includeAbstract: false, + useRootParams: false }; this.setOptions = function(options) { @@ -148,12 +149,47 @@ function $Breadcrumb() { return $$options.templateLastUrl; }, - getStatesChain: function(exitOnFirst) { // Deliberately undocumented param, see getLastStep + getStatesChain: function (exitOnFirst, $routeParams) { // Deliberately undocumented param, see getLastStep var chain = []; + //Ensuring that nesting only starts from current navigated to id + var startInsertingChain = false; + // From current state to the root - for(var stateRef = $state.$current.self.name; stateRef; stateRef=$$breadcrumbParentState(stateRef)) { - $$addStateInChain(chain, stateRef); + for (var stateRef = $state.$current.self.name; stateRef; stateRef = $$breadcrumbParentState(stateRef)) { + + if ($routeParams && $routeParams.id && $$options.useRootParams && !$routeParams.external) { + + //Ensuring that nesting only starts from current navigated to id + + var ref = parseStateRef(stateRef), + conf = $state.get(ref.state); + + var getCurrentURLState = $state.get('myReportsNew.' + $routeParams.id); + + if (conf) { + if (conf.ncyBreadcrumb && conf.ncyBreadcrumb.parent) { + + if (conf.ncyBreadcrumb.parent == getCurrentURLState.ncyBreadcrumb.parent) { + startInsertingChain = true; + } + + if (startInsertingChain) { + $$addStateInChain(chain, stateRef); + } + } + else { + $$addStateInChain(chain, stateRef); + } + } + else { + $$addStateInChain(chain, stateRef); + } + } + else { + $$addStateInChain(chain, stateRef); + } + if(exitOnFirst && chain.length) { return chain; } @@ -168,7 +204,7 @@ function $Breadcrumb() { }, getLastStep: function() { - var chain = this.getStatesChain(true); + var chain = this.getStatesChain(true, $routeParams); return chain.length ? chain[0] : undefined; }, @@ -210,7 +246,7 @@ var deregisterWatchers = function(labelWatcherArray) { }); }; -function BreadcrumbDirective($interpolate, $breadcrumb, $rootScope) { +function BreadcrumbDirective($interpolate, $breadcrumb, $rootScope, $routeParams) { var $$templates = { bootstrap2: '