AC-595 stop translating object name in breadcrumbs.

This commit is contained in:
Chris Houseknecht
2014-02-03 14:59:17 -05:00
parent df9be04a20
commit 7ecc382a71
7 changed files with 54 additions and 38 deletions

View File

@@ -10,7 +10,7 @@ angular.module('InventoryGroupsDefinition', [])
name: 'groups', name: 'groups',
iterator: 'group', iterator: 'group',
editTitle: '{{ inventory_name | capitalize }}', editTitle: '{{ inventory_name }}',
showTitle: false, showTitle: false,
well: true, well: true,
index: false, index: false,

View File

@@ -75,8 +75,8 @@ angular.module('StreamWidget', ['RestServices', 'Utilities', 'StreamListDefiniti
$rootScope.breadcrumbs = []; $rootScope.breadcrumbs = [];
var paths = $location.path().split('/'); var paths = $location.path().split('/');
paths.splice(0,1); paths.splice(0,1);
var path, title, j; var path, title, i, j;
for (var i=0; i < paths.length; i++) { for (i=0; i < paths.length; i++) {
if (/^\d+/.test(paths[i])) { if (/^\d+/.test(paths[i])) {
path=''; path='';
title=''; title='';
@@ -91,7 +91,8 @@ angular.module('StreamWidget', ['RestServices', 'Utilities', 'StreamListDefiniti
} }
if (!title) { if (!title) {
title = paths[i - 1].substr(0,paths[i - 1].length - 1); title = paths[i - 1].substr(0,paths[i - 1].length - 1);
title = (title == 'inventorie') ? 'inventory' : title; title = title.charAt(0).toUpperCase() + title.slice(1);
title = (title == 'Inventorie') ? 'Inventory' : title;
} }
} }
else { else {
@@ -106,6 +107,7 @@ angular.module('StreamWidget', ['RestServices', 'Utilities', 'StreamListDefiniti
path = '/' + paths[i]; path = '/' + paths[i];
} }
title = paths[i]; title = paths[i];
title = title.charAt(0).toUpperCase() + title.slice(1);
} }
$rootScope.breadcrumbs.push({ path: path, title: title, ngClick: "closeStream('" + path + "')" }); $rootScope.breadcrumbs.push({ path: path, title: title, ngClick: "closeStream('" + path + "')" });
} }
@@ -345,7 +347,7 @@ angular.module('StreamWidget', ['RestServices', 'Utilities', 'StreamListDefiniti
} }
// Add a container for the stream widget // Add a container for the stream widget
$('#tab-content-container').append('<div id="stream-container"><div id=\"stream-content\"></div></div><!-- Stream widget -->'); $('#tab-content-container').append("<div id=\"stream-container\"><div id=\"stream-content\"></div></div><!-- Stream widget -->");
StreamBreadCrumbs(); StreamBreadCrumbs();

View File

@@ -226,7 +226,8 @@ hr {
.help-auto-off { .help-auto-off {
margin-top: 15px; margin-top: 15px;
margin-bottom: 15px; margin-bottom: 15px;
margin-left: 10px;
label { label {
font-weight: normal; font-weight: normal;
} }

View File

@@ -41,6 +41,20 @@ angular.module('Utilities',['RestServices', 'Utilities'])
} }
}]) }])
/* Empty()
*
* Test if a value is 'empty'. Returns true if val is null | '' | undefined.
* Only works on non-Ojbect types.
*
*/
.factory('Empty', [ function() {
return function(val) {
return (val === null || val === undefined || val === '') ? true : false;
}
}])
.factory('ToggleClass', function() { .factory('ToggleClass', function() {
return function(selector, cssClass) { return function(selector, cssClass) {
// Toggles the existance of a css class on a given element // Toggles the existance of a css class on a given element
@@ -53,6 +67,7 @@ angular.module('Utilities',['RestServices', 'Utilities'])
} }
}) })
.factory('Alert', ['$rootScope', '$location', function($rootScope, $location) { .factory('Alert', ['$rootScope', '$location', function($rootScope, $location) {
return function(hdr, msg, cls, action, secondAlert, disableButtons) { return function(hdr, msg, cls, action, secondAlert, disableButtons) {
// Pass in the header and message you want displayed on TB modal dialog found in index.html. // Pass in the header and message you want displayed on TB modal dialog found in index.html.
@@ -104,6 +119,7 @@ angular.module('Utilities',['RestServices', 'Utilities'])
} }
}]) }])
.factory('ProcessErrors', ['$rootScope', '$cookieStore', '$log', '$location', 'Alert', 'Wait', .factory('ProcessErrors', ['$rootScope', '$cookieStore', '$log', '$location', 'Alert', 'Wait',
function($rootScope, $cookieStore, $log, $location, Alert, Wait) { function($rootScope, $cookieStore, $log, $location, Alert, Wait) {
return function(scope, data, status, form, defaultMsg) { return function(scope, data, status, form, defaultMsg) {
@@ -180,21 +196,25 @@ angular.module('Utilities',['RestServices', 'Utilities'])
} }
}]) }])
.factory('LoadBreadCrumbs', ['$rootScope', '$routeParams', '$location', function($rootScope, $routeParams, $location, Rest) {
.factory('LoadBreadCrumbs', ['$rootScope', '$routeParams', '$location', 'Empty',
function($rootScope, $routeParams, $location, Empty) {
return function(crumb) { return function(crumb) {
var title, found, j, i;
//Keep a list of path/title mappings. When we see /organizations/XX in the path, for example, //Keep a list of path/title mappings. When we see /organizations/XX in the path, for example,
//we'll know the actual organization name it maps to. //we'll know the actual organization name it maps to.
if (crumb !== null && crumb !== undefined) { if (!Empty(crumb)) {
var found = false; found = false;
for (var i=0; i < $rootScope.crumbCache.length; i++) { //crumb.title = crumb.title.charAt(0).toUpperCase() + crumb.title.slice(1);
for (i=0; i < $rootScope.crumbCache.length; i++) {
if ($rootScope.crumbCache[i].path == crumb.path) { if ($rootScope.crumbCache[i].path == crumb.path) {
found = true; found = true;
$rootScope.crumbCache[i] = crumb; $rootScope.crumbCache[i] = crumb;
break; break;
} }
} }
if (found == false) { if (!found) {
$rootScope.crumbCache.push(crumb); $rootScope.crumbCache.push(crumb);
} }
} }
@@ -207,42 +227,48 @@ angular.module('Utilities',['RestServices', 'Utilities'])
if (i > 0 && paths[i].match(/\d+/)) { if (i > 0 && paths[i].match(/\d+/)) {
parent = paths[i-1]; parent = paths[i-1];
if (parent == 'inventories') { if (parent == 'inventories') {
child = 'inventory'; child = 'Inventory';
} }
else { else {
child = parent.substring(0,parent.length - 1); //assumes parent ends with 's' child = parent.substring(0,parent.length - 1); //assumes parent ends with 's'
child = child.charAt(0).toUpperCase() + child.slice(1);
} }
// find the correct title // find the correct title
found = false;
for (var j=0; j < $rootScope.crumbCache.length; j++) { for (var j=0; j < $rootScope.crumbCache.length; j++) {
if ($rootScope.crumbCache[j].path == '/' + parent + '/' + paths[i]) { if ($rootScope.crumbCache[j].path == '/' + parent + '/' + paths[i]) {
child = $rootScope.crumbCache[j].title; child = $rootScope.crumbCache[j].title;
found = true;
break; break;
} }
} }
if ($rootScope.crumbCache[j] && $rootScope.crumbCache[j]['altPath'] !== undefined) {
if (found && $rootScope.crumbCache[j]['altPath'] !== undefined) {
// Use altPath to override default path construction // Use altPath to override default path construction
$rootScope.breadcrumbs.push({ title: child, path: $rootScope.crumbCache[j].altPath }); $rootScope.breadcrumbs.push({ title: child, path: $rootScope.crumbCache[j].altPath });
} }
else { else {
if (paths[i - 1] == 'hosts') { $rootScope.breadcrumbs.push({ title: child, path: ppath + '/' + paths[i] });
/*if (paths[i - 1] == 'hosts') {
// For hosts, there is no /hosts, so we need to link back to the inventory // For hosts, there is no /hosts, so we need to link back to the inventory
// We end up here when user has clicked refresh and the crumbcache is missing // We end up here when user has clicked refresh and the crumbcache is missing
$rootScope.breadcrumbs.push({ title: child, $rootScope.breadcrumbs.push({ title: child,
path: '/inventories/' + $routeParams.inventory + '/hosts' }); path: '/inventories/' + $routeParams.inventory + '/hosts' });
} }
else { else { */
$rootScope.breadcrumbs.push({ title: child, path: ppath + '/' + paths[i] });
} //}
} }
} }
else { else {
if (paths[i] == 'hosts') { title = paths[i].charAt(0).toUpperCase() + paths[i].slice(1);
$rootScope.breadcrumbs.push({ title: title, path: ppath + '/' + paths[i] });
/*if (paths[i] == 'hosts') {
$rootScope.breadcrumbs.push({ title: paths[i], path: '/inventories/' + $routeParams.inventory + $rootScope.breadcrumbs.push({ title: paths[i], path: '/inventories/' + $routeParams.inventory +
'/hosts' }); '/hosts' });
} }
else { else {*/
$rootScope.breadcrumbs.push({ title: paths[i], path: ppath + '/' + paths[i] }); //}
}
} }
ppath += '/' + paths[i]; ppath += '/' + paths[i];
} }
@@ -564,19 +590,6 @@ angular.module('Utilities',['RestServices', 'Utilities'])
console.log('form valid: ' + scope[form.name + '_form'].$valid); console.log('form valid: ' + scope[form.name + '_form'].$valid);
} }
}]) }])
/* Empty()
*
* Test if a value is 'empty'. Returns true if val is null | '' | undefined.
* Only works on non-Ojbect types.
*
*/
.factory('Empty', [ function() {
return function(val) {
return (val === null || val === undefined || val === '') ? true : false;
}
}])
/* Store /* Store

View File

@@ -1025,7 +1025,7 @@ angular.module('FormGenerator', ['GeneratorHelpers', 'ngCookies', 'Utilities'])
var html = ''; var html = '';
html += "<div class=\"nav-path\">\n"; html += "<div class=\"nav-path\">\n";
html += "<ul class=\"breadcrumb\">\n"; html += "<ul class=\"breadcrumb\">\n";
html += "<li ng-repeat=\"crumb in breadcrumbs\"><a href=\"{{ '#' + crumb.path }}\">{{ crumb.title | capitalize }}</a></li>\n"; html += "<li ng-repeat=\"crumb in breadcrumbs\"><a href=\"{{ '#' + crumb.path }}\">{{ crumb.title }}</a></li>\n";
if (navigation) { if (navigation) {

View File

@@ -375,7 +375,7 @@ angular.module('GeneratorHelpers', ['GeneratorHelpers'])
html += "<div class=\"nav-path\">\n"; html += "<div class=\"nav-path\">\n";
html += "<ul class=\"breadcrumb\" id=\"breadcrumb-list\">\n"; html += "<ul class=\"breadcrumb\" id=\"breadcrumb-list\">\n";
html += "<li ng-repeat=\"crumb in breadcrumbs\"><a href=\"\{\{ \'#\' + crumb.path \}\}\">\{\{ crumb.title \| capitalize \}\}</a></li>\n"; html += "<li ng-repeat=\"crumb in breadcrumbs\"><a href=\"{{ '#' + crumb.path }}\">{{ crumb.title }}</a></li>\n";
if (list.navigationLinks) { if (list.navigationLinks) {
var navigation = list.navigationLinks; var navigation = list.navigationLinks;

View File

@@ -126,7 +126,7 @@ angular.module('ListGenerator', ['GeneratorHelpers'])
// before navigation // before navigation
html += "<div class=\"nav-path\">\n"; html += "<div class=\"nav-path\">\n";
html += "<ul class=\"breadcrumb\">\n"; html += "<ul class=\"breadcrumb\">\n";
html += "<li ng-repeat=\"crumb in breadcrumbs\"><a href=\"\" ng-click=\"\{\{ crumb.ngClick \}\}\">{{ crumb.title | capitalize }}</a></li>\n"; html += "<li ng-repeat=\"crumb in breadcrumbs\"><a href=\"\" ng-click=\"\{\{ crumb.ngClick \}\}\">{{ crumb.title }}</a></li>\n";
html += "<li class=\"active\">"; html += "<li class=\"active\">";
html += list.editTitle; html += list.editTitle;
html += "</li>\n</ul>\n</div>\n"; html += "</li>\n</ul>\n</div>\n";