2022-01-17 21:05:10 +03:00
|
|
|
import Controller from '@ember/controller';
|
2022-01-27 22:19:15 +03:00
|
|
|
import {EMAIL_EVENTS, NEWSLETTER_EVENTS} from 'ghost-admin/helpers/members-event-filter';
|
2022-01-24 20:31:24 +03:00
|
|
|
import {action} from '@ember/object';
|
|
|
|
import {inject as service} from '@ember/service';
|
2022-01-17 21:05:10 +03:00
|
|
|
import {tracked} from '@glimmer/tracking';
|
|
|
|
|
|
|
|
export default class MembersActivityController extends Controller {
|
2022-01-24 20:31:24 +03:00
|
|
|
@service router;
|
2022-01-27 22:19:15 +03:00
|
|
|
@service settings;
|
2022-01-25 19:34:18 +03:00
|
|
|
@service store;
|
2022-01-17 21:05:10 +03:00
|
|
|
|
2022-01-25 15:13:13 +03:00
|
|
|
queryParams = ['excludedEvents', 'member'];
|
2022-01-24 20:31:24 +03:00
|
|
|
|
|
|
|
@tracked excludedEvents = null;
|
2022-01-25 15:13:13 +03:00
|
|
|
@tracked member = null;
|
2022-01-24 20:31:24 +03:00
|
|
|
|
2022-01-27 22:19:15 +03:00
|
|
|
// we don't want to show or allow filtering of certain events in some situations
|
|
|
|
// - no member selected = don't show email events, they flood the list and the API can't paginate correctly
|
|
|
|
// - newsletter is disabled = don't show email or newletter events
|
|
|
|
get hiddenEvents() {
|
|
|
|
const hiddenEvents = [];
|
2022-01-25 15:13:13 +03:00
|
|
|
|
2022-01-27 22:19:15 +03:00
|
|
|
if (!this.member) {
|
|
|
|
hiddenEvents.push(...EMAIL_EVENTS);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.settings.get('editorDefaultEmailRecipients') === 'disabled') {
|
|
|
|
hiddenEvents.push(...EMAIL_EVENTS, ...NEWSLETTER_EVENTS);
|
|
|
|
}
|
2022-01-25 15:13:13 +03:00
|
|
|
|
2022-01-27 22:19:15 +03:00
|
|
|
return hiddenEvents;
|
|
|
|
}
|
|
|
|
|
|
|
|
get fullExcludedEvents() {
|
|
|
|
return (this.excludedEvents || '').split(',').concat(this.hiddenEvents);
|
2022-01-25 15:13:13 +03:00
|
|
|
}
|
|
|
|
|
2022-01-25 19:34:18 +03:00
|
|
|
get memberRecord() {
|
|
|
|
if (!this.member) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: {reload: true} here shouldn't be needed but without it
|
|
|
|
// the template renders nothing if the record is already in the store
|
|
|
|
return this.store.findRecord('member', this.member, {reload: true});
|
|
|
|
}
|
|
|
|
|
2022-01-25 15:13:13 +03:00
|
|
|
@action
|
2022-01-27 17:59:12 +03:00
|
|
|
changeExcludedEvents(newList) {
|
2022-01-25 15:13:13 +03:00
|
|
|
this.router.transitionTo({queryParams: {excludedEvents: newList}});
|
|
|
|
}
|
|
|
|
|
2022-01-27 17:59:12 +03:00
|
|
|
@action
|
|
|
|
changeMember(member) {
|
|
|
|
this.router.transitionTo({queryParams: {member: member?.id}});
|
|
|
|
}
|
2022-01-17 21:05:10 +03:00
|
|
|
}
|