2019-01-22 19:23:26 +03:00
|
|
|
import AuthenticatedRoute from 'ghost-admin/routes/authenticated';
|
|
|
|
import {inject as service} from '@ember/service';
|
|
|
|
|
2020-05-20 16:55:41 +03:00
|
|
|
export default class MembersRoute extends AuthenticatedRoute {
|
2020-05-22 14:47:03 +03:00
|
|
|
@service store;
|
2019-01-22 19:23:26 +03:00
|
|
|
|
2020-05-20 16:55:41 +03:00
|
|
|
queryParams = {
|
2020-05-28 12:15:17 +03:00
|
|
|
label: {refreshModel: true},
|
2020-06-12 14:12:27 +03:00
|
|
|
searchParam: {refreshModel: true, replace: true},
|
2020-12-08 22:23:57 +03:00
|
|
|
paidParam: {refreshModel: true},
|
|
|
|
orderParam: {refreshModel: true}
|
2020-05-20 16:55:41 +03:00
|
|
|
};
|
2020-02-14 12:34:01 +03:00
|
|
|
|
2019-01-22 19:23:26 +03:00
|
|
|
// redirect to posts screen if:
|
|
|
|
// - TODO: members is disabled?
|
|
|
|
// - logged in user isn't owner/admin
|
|
|
|
beforeModel() {
|
2020-05-20 16:55:41 +03:00
|
|
|
super.beforeModel(...arguments);
|
2021-07-08 16:37:31 +03:00
|
|
|
if (!this.session.user.isOwnerOrAdmin) {
|
|
|
|
return this.transitionTo('home');
|
|
|
|
}
|
2020-05-20 16:55:41 +03:00
|
|
|
}
|
2019-01-24 22:34:32 +03:00
|
|
|
|
2020-05-22 14:47:03 +03:00
|
|
|
model(params) {
|
2020-06-01 17:48:46 +03:00
|
|
|
return this.controllerFor('members').fetchMembersTask.perform(params);
|
2020-05-22 14:47:03 +03:00
|
|
|
}
|
|
|
|
|
2020-05-20 17:12:48 +03:00
|
|
|
// trigger a background load of members plus labels for filter dropdown
|
2019-01-24 22:34:32 +03:00
|
|
|
setupController(controller) {
|
2020-05-20 16:55:41 +03:00
|
|
|
super.setupController(...arguments);
|
2020-05-20 17:12:48 +03:00
|
|
|
controller.fetchLabelsTask.perform();
|
2020-05-20 16:55:41 +03:00
|
|
|
}
|
|
|
|
|
2019-05-20 18:16:19 +03:00
|
|
|
buildRouteInfoMetadata() {
|
|
|
|
return {
|
|
|
|
titleToken: 'Members'
|
|
|
|
};
|
2019-01-22 19:23:26 +03:00
|
|
|
}
|
2020-05-20 16:55:41 +03:00
|
|
|
}
|