Ghost/ghost/admin/app/routes/members.js
Kevin Ansfield 147943f3a3 Fixed members list/chart not updating after members import
no issue

- move members loading code into `members` controller so that it's more accessible to other areas of the app
- add `refreshData()` to the `members` controller which forces members list and stats to be re-fetched
- call `members.refreshData()` after successful upload of members import file
- store range/days in `membersStats` service so that it's remembered across refreshes and component renders
2020-06-01 15:48:46 +01:00

40 lines
1.1 KiB
JavaScript

import AuthenticatedRoute from 'ghost-admin/routes/authenticated';
import {inject as service} from '@ember/service';
export default class MembersRoute extends AuthenticatedRoute {
@service store;
queryParams = {
label: {refreshModel: true},
searchParam: {refreshModel: true, replace: true}
};
// redirect to posts screen if:
// - TODO: members is disabled?
// - logged in user isn't owner/admin
beforeModel() {
super.beforeModel(...arguments);
return this.session.user.then((user) => {
if (!user.isOwnerOrAdmin) {
return this.transitionTo('home');
}
});
}
model(params) {
return this.controllerFor('members').fetchMembersTask.perform(params);
}
// trigger a background load of members plus labels for filter dropdown
setupController(controller) {
super.setupController(...arguments);
controller.fetchLabelsTask.perform();
}
buildRouteInfoMetadata() {
return {
titleToken: 'Members'
};
}
}