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
|
|
|
|
2022-10-25 17:21:10 +03:00
|
|
|
fromAnalytics = false;
|
|
|
|
|
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},
|
2021-08-10 15:11:22 +03:00
|
|
|
filterParam: {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
|
|
|
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
|
2022-10-25 17:21:10 +03:00
|
|
|
setupController(controller, model, transition) {
|
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
|
|
|
|
|
|
|
if (transition.from?.name === 'posts.analytics') {
|
|
|
|
// Sadly transition.from.params is not reliable to use (not populated on transitions)
|
|
|
|
const oldParams = transition.router?.oldState?.params['posts.analytics'] ?? {};
|
|
|
|
|
|
|
|
// We need to store analytics in 'this' to have it accessible for the member route
|
|
|
|
this.fromAnalytics = Object.values(oldParams);
|
|
|
|
controller.fromAnalytics = this.fromAnalytics;
|
|
|
|
} else if (transition.from?.metadata?.fromAnalytics) {
|
|
|
|
// Handle returning from member route
|
|
|
|
const fromAnalytics = transition.from?.metadata.fromAnalytics ?? null;
|
|
|
|
controller.fromAnalytics = fromAnalytics;
|
|
|
|
this.fromAnalytics = fromAnalytics;
|
|
|
|
} else {
|
|
|
|
controller.fromAnalytics = null;
|
|
|
|
this.fromAnalytics = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
resetController() {
|
|
|
|
super.resetController(...arguments);
|
|
|
|
// don't reset fromAnalytics here, we need to reuse it. We reset it in setup
|
|
|
|
//controller.fromAnalytics = 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',
|
2022-10-25 17:21:10 +03:00
|
|
|
mainClasses: ['gh-main-fullwidth'],
|
|
|
|
fromAnalytics: this.fromAnalytics
|
2021-10-01 13:04:56 +03:00
|
|
|
};
|
2019-01-22 19:23:26 +03:00
|
|
|
}
|
2020-05-20 16:55:41 +03:00
|
|
|
}
|