2014-10-28 08:29:42 -06:00
|
|
|
import AuthenticatedRoute from 'ghost/routes/authenticated';
|
2014-07-20 12:42:03 -04:00
|
|
|
import PaginationRouteMixin from 'ghost/mixins/pagination-route';
|
2014-09-23 13:04:49 +00:00
|
|
|
import styleBody from 'ghost/mixins/style-body';
|
2014-07-20 12:42:03 -04:00
|
|
|
|
2014-10-24 21:09:50 +00:00
|
|
|
var paginationSettings,
|
|
|
|
UsersIndexRoute;
|
|
|
|
|
|
|
|
paginationSettings = {
|
2014-07-20 12:42:03 -04:00
|
|
|
page: 1,
|
2014-07-23 06:13:20 +00:00
|
|
|
limit: 20,
|
2014-10-16 15:28:51 +00:00
|
|
|
status: 'active'
|
2014-07-20 12:42:03 -04:00
|
|
|
};
|
|
|
|
|
2014-10-28 08:29:42 -06:00
|
|
|
UsersIndexRoute = AuthenticatedRoute.extend(styleBody, PaginationRouteMixin, {
|
2014-11-25 12:56:08 -08:00
|
|
|
titleToken: 'Users',
|
|
|
|
|
2014-09-23 13:04:49 +00:00
|
|
|
classNames: ['settings-view-users'],
|
|
|
|
|
2014-07-20 12:42:03 -04:00
|
|
|
setupController: function (controller, model) {
|
2014-07-23 06:13:20 +00:00
|
|
|
this._super(controller, model);
|
|
|
|
this.setupPagination(paginationSettings);
|
2014-07-20 12:42:03 -04:00
|
|
|
},
|
2014-07-01 23:44:39 -04:00
|
|
|
|
|
|
|
model: function () {
|
2014-07-31 09:29:05 +01:00
|
|
|
var self = this;
|
2014-10-16 15:28:51 +00:00
|
|
|
|
|
|
|
return self.store.find('user', {limit: 'all', status: 'invited'}).then(function () {
|
|
|
|
return self.store.find('user', 'me').then(function (currentUser) {
|
2014-07-31 09:29:05 +01:00
|
|
|
if (currentUser.get('isEditor')) {
|
2014-10-16 15:28:51 +00:00
|
|
|
// Editors only see authors in the list
|
|
|
|
paginationSettings.role = 'Author';
|
2014-07-31 09:29:05 +01:00
|
|
|
}
|
2014-10-16 15:28:51 +00:00
|
|
|
|
|
|
|
return self.store.filter('user', paginationSettings, function (user) {
|
|
|
|
if (currentUser.get('isEditor')) {
|
2014-11-16 09:36:37 -07:00
|
|
|
return user.get('isAuthor') || user === currentUser;
|
2014-10-16 15:28:51 +00:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
});
|
2014-07-31 09:29:05 +01:00
|
|
|
});
|
2014-07-20 12:42:03 -04:00
|
|
|
});
|
2014-08-02 20:49:56 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
actions: {
|
|
|
|
reload: function () {
|
|
|
|
this.refresh();
|
|
|
|
}
|
2014-07-01 23:44:39 -04:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
export default UsersIndexRoute;
|