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-07-23 10:13:20 +04:00
|
|
|
var 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-09-23 17:04:49 +04:00
|
|
|
var UsersIndexRoute = Ember.Route.extend(SimpleAuth.AuthenticatedRouteMixin, styleBody, PaginationRouteMixin, {
|
|
|
|
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')) {
|
|
|
|
return user.get('isAuthor');
|
|
|
|
}
|
|
|
|
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;
|