Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
<a name="0.5.5"></a>
## 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


<a name="0.5.2"></a>
## 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

<a name="0.5.1"></a>
## 0.5.1 (2017-07-20)

#### Bug Fixes
* Ensuring that nesting only starts from current navigated to id closes [#159]

<a name="0.5.0"></a>
## 0.5.0 (2016-11-14)

Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
66 changes: 52 additions & 14 deletions dist/angular-breadcrumb.js
Original file line number Diff line number Diff line change
@@ -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 */

Expand Down Expand Up @@ -37,7 +37,8 @@ function $Breadcrumb() {
templateUrl: null,
templateLast: 'default',
templateLastUrl: null,
includeAbstract : false
includeAbstract: false,
useRootParams: false
};

this.setOptions = function(options) {
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
},

Expand Down Expand Up @@ -210,7 +246,7 @@ var deregisterWatchers = function(labelWatcherArray) {
});
};

function BreadcrumbDirective($interpolate, $breadcrumb, $rootScope) {
function BreadcrumbDirective($interpolate, $breadcrumb, $rootScope, $routeParams) {
var $$templates = {
bootstrap2: '<ul class="breadcrumb">' +
'<li ng-repeat="step in steps" ng-switch="$last || !!step.abstract" ng-class="{active: $last}">' +
Expand Down Expand Up @@ -242,7 +278,8 @@ function BreadcrumbDirective($interpolate, $breadcrumb, $rootScope) {
labelWatchers = [];

var viewScope = $breadcrumb.$getLastViewScope();
scope.steps = $breadcrumb.getStatesChain();

scope.steps = $breadcrumb.getStatesChain(false, $routeParams);
angular.forEach(scope.steps, function (step) {
if (step.ncyBreadcrumb && step.ncyBreadcrumb.label) {
var parseLabel = $interpolate(step.ncyBreadcrumb.label);
Expand All @@ -267,9 +304,10 @@ function BreadcrumbDirective($interpolate, $breadcrumb, $rootScope) {
}
};
}
BreadcrumbDirective.$inject = ['$interpolate', '$breadcrumb', '$rootScope'];

function BreadcrumbLastDirective($interpolate, $breadcrumb, $rootScope) {
BreadcrumbDirective.$inject = ['$interpolate', '$breadcrumb', '$rootScope', '$routeParams'];

function BreadcrumbLastDirective($interpolate, $breadcrumb, $rootScope, $routeParams) {
var $$templates = {
'default': '{{ncyBreadcrumbLabel}}'
};
Expand Down Expand Up @@ -327,9 +365,9 @@ function BreadcrumbLastDirective($interpolate, $breadcrumb, $rootScope) {
}
};
}
BreadcrumbLastDirective.$inject = ['$interpolate', '$breadcrumb', '$rootScope'];
BreadcrumbLastDirective.$inject = ['$interpolate', '$breadcrumb', '$rootScope', '$routeParams'];

function BreadcrumbTextDirective($interpolate, $breadcrumb, $rootScope) {
function BreadcrumbTextDirective($interpolate, $breadcrumb, $rootScope, $routeParams) {

return {
restrict: 'A',
Expand Down Expand Up @@ -365,7 +403,7 @@ function BreadcrumbTextDirective($interpolate, $breadcrumb, $rootScope) {
labelWatchers = [];

var viewScope = $breadcrumb.$getLastViewScope();
var steps = $breadcrumb.getStatesChain();
var steps = $breadcrumb.getStatesChain(false, $routeParams);
var combinedLabels = [];
angular.forEach(steps, function (step) {
if (step.ncyBreadcrumb && step.ncyBreadcrumb.label) {
Expand Down Expand Up @@ -395,7 +433,7 @@ function BreadcrumbTextDirective($interpolate, $breadcrumb, $rootScope) {
}
};
}
BreadcrumbTextDirective.$inject = ['$interpolate', '$breadcrumb', '$rootScope'];
BreadcrumbTextDirective.$inject = ['$interpolate', '$breadcrumb', '$rootScope', '$routeParams'];

angular.module('ncy-angular-breadcrumb', ['ui.router.state'])
.provider('$breadcrumb', $Breadcrumb)
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.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
"homepage": "http://ncuillery.github.io/angular-breadcrumb",
"author": {
"name": "Nicolas Cuillery",
Expand Down
Loading