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

Commit

Permalink
feat(core): Enhancement page title directive (#1686)
Browse files Browse the repository at this point in the history
* fix(users): test for usernameOrEmail

* Add comment to remind  change for mongo replicaset connection

* clean comment ..

* Generic pageTitle concept

* Revert "Generic pageTitle concept"

This reverts commit ff00ec9.

* align on meanjs state

* fix atom beautify newline

* align to mean indent

* pageTitle directive

automatic pageTitle directive

fix loads add ..

clean lodash dependencies

clean code

clean code & indent

clean lodash

* pageTitle directive

automatic pageTitle directive

fix loads add ..

clean lodash dependencies

clean code

clean code & indent

clean lodash
  • Loading branch information
PierreBrisorgueil authored and mleanos committed Aug 10, 2017
1 parent f65d4b9 commit c69644d
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 25 deletions.
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
14 changes: 9 additions & 5 deletions modules/core/client/directives/page-title.client.directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,17 @@

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

toState.name.split('.').forEach(function(value, index) {
stateTitle = stateTitle + value.charAt(0).toUpperCase() + value.slice(1) + separator;
});
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 + separator)(($state.$current.locals.globals));
}
stateTitle = stateTitle.slice(0, 0 - separator.length);
element.text(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

2 comments on commit c69644d

@simison
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commit message went in a bit messy. Oh well. :-)

@mleanos
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops. That was my bad. I didn't check that before merging. I'll make sure to double check commit messages from now on.

Please sign in to comment.