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