Skip to content
This repository has been archived by the owner on Aug 30, 2021. It is now read-only.

Commit

Permalink
Generic pageTitle concept
Browse files Browse the repository at this point in the history
  • Loading branch information
PierreBrisorgueil committed Dec 22, 2016
1 parent 1af9ec0 commit ff00ec9
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 27 deletions.
3 changes: 2 additions & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"angular-ui-router": "~0.2.18",
"bootstrap": "~3.3.6",
"ng-file-upload": "~12.1.0",
"owasp-password-strength-test": "~1.3.0"
"owasp-password-strength-test": "~1.3.0",
"lodash": "^4.6.1"
},
"overrides": {
"bootstrap": {
Expand Down
1 change: 1 addition & 0 deletions config/assets/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ module.exports = {
'public/lib/angular-ui-notification/dist/angular-ui-notification.js',
'public/lib/angular-ui-router/release/angular-ui-router.js',
'public/lib/owasp-password-strength-test/owasp-password-strength-test.js',
'public/lib/lodash/dist/lodash.js',
// endbower
],
tests: ['public/lib/angular-mocks/angular-mocks.js']
Expand Down
1 change: 1 addition & 0 deletions config/assets/production.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ module.exports = {
'public/lib/angular-ui-router/release/angular-ui-router.min.js',
'public/lib/ng-file-upload/ng-file-upload.min.js',
'public/lib/owasp-password-strength-test/owasp-password-strength-test.js',
'public/lib/lodash/dist/lodash.min.js',
// endbower
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@
controller: 'ArticlesAdminController',
controllerAs: 'vm',
data: {
roles: ['admin']
roles: ['admin'],
pageTitle: '{{ articleResolve.title }}'
},
resolve: {
articleResolve: getArticle
Expand Down
7 changes: 2 additions & 5 deletions modules/articles/client/config/articles.client.routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@
url: '',
templateUrl: '/modules/articles/client/views/list-articles.client.view.html',
controller: 'ArticlesListController',
controllerAs: 'vm',
data: {
pageTitle: 'Articles List'
}
controllerAs: 'vm'
})
.state('articles.view', {
url: '/:articleId',
Expand All @@ -32,7 +29,7 @@
articleResolve: getArticle
},
data: {
pageTitle: 'Article {{ articleResolve.title }}'
pageTitle: '{{ articleResolve.title }}'
}
});
}
Expand Down
3 changes: 1 addition & 2 deletions modules/chat/client/config/chat.client.routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
controller: 'ChatController',
controllerAs: 'vm',
data: {
roles: ['user', 'admin'],
pageTitle: 'Chat'
roles: ['user', 'admin']
}
});
}
Expand Down
9 changes: 3 additions & 6 deletions modules/core/client/config/core.client.routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@
}
},
data: {
ignoreState: true,
pageTitle: 'Not Found'
ignoreState: true
}
})
.state('bad-request', {
Expand All @@ -59,16 +58,14 @@
}
},
data: {
ignoreState: true,
pageTitle: 'Bad Request'
ignoreState: true
}
})
.state('forbidden', {
url: '/forbidden',
templateUrl: '/modules/core/client/views/403.client.view.html',
data: {
ignoreState: true,
pageTitle: 'Forbidden'
ignoreState: true
}
});
}
Expand Down
16 changes: 10 additions & 6 deletions modules/core/client/directives/page-title.client.directive.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(function () {
(function() {
'use strict';

angular.module('core')
Expand All @@ -19,13 +19,17 @@

function listener(event, toState) {
var applicationCoreTitle = 'MEAN.js',
separeteBy = ' - ';
separeteBy = ' - ',
stateTitle = applicationCoreTitle + separeteBy;

_.forEach(toState.name.split('.'), function(value, index) {
stateTitle = stateTitle + _.capitalize(value) + separeteBy;
});
if (toState.data && toState.data.pageTitle) {
var stateTitle = $interpolate(toState.data.pageTitle)($state.$current.locals.globals);
element.html(applicationCoreTitle + separeteBy + stateTitle);
} else {
element.html(applicationCoreTitle);
stateTitle = $interpolate(stateTitle + toState.data.pageTitle + separeteBy)(($state.$current.locals.globals));
}
stateTitle = stateTitle.slice(0, -3);
element.html(stateTitle);
}
}
}
Expand Down
9 changes: 3 additions & 6 deletions modules/users/client/config/users-admin.client.routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@
url: '/users',
templateUrl: '/modules/users/client/views/admin/list-users.client.view.html',
controller: 'UserListController',
controllerAs: 'vm',
data: {
pageTitle: 'Users List'
}
controllerAs: 'vm'
})
.state('admin.user', {
url: '/users/:userId',
Expand All @@ -28,7 +25,7 @@
userResolve: getUser
},
data: {
pageTitle: 'Edit {{ userResolve.displayName }}'
pageTitle: '{{ userResolve.displayName }}'
}
})
.state('admin.user-edit', {
Expand All @@ -40,7 +37,7 @@
userResolve: getUser
},
data: {
pageTitle: 'Edit User {{ userResolve.displayName }}'
pageTitle: '{{ userResolve.displayName }}'
}
});

Expand Down

0 comments on commit ff00ec9

Please sign in to comment.