2022-01-17 21:05:10 +03:00
|
|
|
import Controller from '@ember/controller';
|
2022-10-17 16:28:34 +03:00
|
|
|
import MemberFetcher from 'ghost-admin/helpers/member-fetcher';
|
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';
|
2022-10-17 16:28:34 +03:00
|
|
|
import {use} from 'ember-could-get-used-to-this';
|
2022-01-17 21:05:10 +03:00
|
|
|
|
|
|
|
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-10-17 16:28:34 +03:00
|
|
|
@use memberRecord = new MemberFetcher(() => [this.member]);
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2022-10-07 16:23:21 +03:00
|
|
|
if (this.settings.editorDefaultEmailRecipients === 'disabled') {
|
2022-01-27 22:19:15 +03:00
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
@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
|
|
|
}
|