2014-07-20 12:42:03 -04:00
|
|
|
import PaginationRouteMixin from 'ghost/mixins/pagination-route';
|
|
|
|
|
2014-07-23 06:13:20 +00:00
|
|
|
var paginationSettings = {
|
2014-07-20 12:42:03 -04:00
|
|
|
page: 1,
|
2014-07-23 06:13:20 +00:00
|
|
|
limit: 20,
|
|
|
|
status: 'all'
|
2014-07-20 12:42:03 -04:00
|
|
|
};
|
|
|
|
|
2014-07-25 15:38:13 +02:00
|
|
|
var UsersIndexRoute = Ember.Route.extend(SimpleAuth.AuthenticatedRouteMixin, PaginationRouteMixin, {
|
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;
|
|
|
|
return this.store.find('user', 'me').then(function (currentUser) {
|
|
|
|
if (currentUser.get('isEditor')) {
|
|
|
|
// Editors only see authors in the list
|
|
|
|
paginationSettings.role = 'Author';
|
|
|
|
}
|
|
|
|
return self.store.filter('user', paginationSettings, function (user) {
|
|
|
|
if (currentUser.get('isEditor')) {
|
|
|
|
return user.get('isAuthor');
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
});
|
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;
|