2022-01-17 13:05:27 +03:00
|
|
|
import AdminRoute from 'ghost-admin/routes/admin';
|
2019-01-22 19:23:26 +03:00
|
|
|
import {inject as service} from '@ember/service';
|
|
|
|
|
2022-01-17 13:05:27 +03:00
|
|
|
export default class MembersRoute extends AdminRoute {
|
2020-05-22 14:47:03 +03:00
|
|
|
@service store;
|
2021-08-12 18:53:49 +03:00
|
|
|
@service feature;
|
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},
|
2021-08-04 09:50:34 +03:00
|
|
|
orderParam: {refreshModel: true},
|
2023-05-04 12:11:08 +03:00
|
|
|
filterParam: {refreshModel: true},
|
|
|
|
postAnalytics: {refreshModel: false}
|
2020-05-20 16:55:41 +03:00
|
|
|
};
|
2020-02-14 12:34:01 +03:00
|
|
|
|
2019-01-22 19:23:26 +03:00
|
|
|
beforeModel() {
|
2020-05-20 16:55:41 +03:00
|
|
|
super.beforeModel(...arguments);
|
2022-01-17 13:05:27 +03:00
|
|
|
// - TODO: redirect if members is disabled?
|
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) {
|
2021-09-09 21:43:31 +03:00
|
|
|
this.controllerFor('members').resetFilters(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
|
2023-05-04 12:11:08 +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();
|
2022-10-25 17:21:10 +03:00
|
|
|
}
|
|
|
|
|
2023-05-04 12:11:08 +03:00
|
|
|
resetController(controller, _isExiting, transition) {
|
2022-10-25 17:21:10 +03:00
|
|
|
super.resetController(...arguments);
|
2023-05-04 12:11:08 +03:00
|
|
|
|
|
|
|
if (controller.postAnalytics) {
|
|
|
|
controller.set('postAnalytics', null);
|
|
|
|
// Only reset filters if we are not going to member route
|
|
|
|
// Otherwise the filters will be gone if we return
|
|
|
|
if (!transition?.to?.name?.startsWith('member')) {
|
|
|
|
controller.set('filterParam', null);
|
|
|
|
}
|
|
|
|
}
|
2020-05-20 16:55:41 +03:00
|
|
|
}
|
|
|
|
|
2019-05-20 18:16:19 +03:00
|
|
|
buildRouteInfoMetadata() {
|
2021-10-01 13:04:56 +03:00
|
|
|
return {
|
|
|
|
titleToken: 'Members',
|
2023-05-04 12:11:08 +03:00
|
|
|
mainClasses: ['gh-main-fullwidth']
|
2021-10-01 13:04:56 +03:00
|
|
|
};
|
2019-01-22 19:23:26 +03:00
|
|
|
}
|
2020-05-20 16:55:41 +03:00
|
|
|
}
|