2021-05-07 12:02:19 +03:00
|
|
|
import Component from '@glimmer/component';
|
|
|
|
import {action} from '@ember/object';
|
|
|
|
import {inject as service} from '@ember/service';
|
|
|
|
import {tracked} from '@glimmer/tracking';
|
|
|
|
|
|
|
|
export default class SettingsDefaultEmailRecipientsComponent extends Component {
|
|
|
|
@service settings;
|
|
|
|
|
|
|
|
@tracked segmentSelected = false;
|
|
|
|
|
|
|
|
get isDisabled() {
|
|
|
|
return this.settings.get('membersSignupAccess') === 'none';
|
|
|
|
}
|
|
|
|
|
|
|
|
get isDisabledSelected() {
|
|
|
|
return this.isDisabled ||
|
|
|
|
this.settings.get('editorDefaultEmailRecipients') === 'disabled';
|
|
|
|
}
|
|
|
|
|
|
|
|
get isVisibilitySelected() {
|
|
|
|
return !this.isDisabled &&
|
|
|
|
this.settings.get('editorDefaultEmailRecipients') === 'visibility';
|
|
|
|
}
|
|
|
|
|
|
|
|
get isNobodySelected() {
|
|
|
|
return !this.isDisabled &&
|
|
|
|
!this.segmentSelected &&
|
|
|
|
this.settings.get('editorDefaultEmailRecipients') === 'filter' &&
|
|
|
|
this.settings.get('editorDefaultEmailRecipientsFilter') === null;
|
|
|
|
}
|
|
|
|
|
|
|
|
get isSegmentSelected() {
|
|
|
|
const isCustomSegment = this.settings.get('editorDefaultEmailRecipients') === 'filter' &&
|
2021-05-08 14:21:22 +03:00
|
|
|
!this.isNobodySelected;
|
2021-05-07 12:02:19 +03:00
|
|
|
return !this.isDisabled && (this.segmentSelected || isCustomSegment);
|
|
|
|
}
|
|
|
|
|
|
|
|
@action
|
|
|
|
setDefaultEmailRecipients(value) {
|
2021-05-07 13:58:05 +03:00
|
|
|
this.segmentSelected = false;
|
|
|
|
|
2021-05-07 12:02:19 +03:00
|
|
|
if (['disabled', 'visibility'].includes(value)) {
|
|
|
|
this.settings.set('editorDefaultEmailRecipients', value);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (value === 'none') {
|
|
|
|
this.settings.set('editorDefaultEmailRecipientsFilter', null);
|
|
|
|
}
|
|
|
|
|
2021-05-07 13:58:05 +03:00
|
|
|
if (value === 'segment') {
|
|
|
|
this.segmentSelected = true;
|
|
|
|
}
|
|
|
|
|
2021-05-07 12:02:19 +03:00
|
|
|
this.settings.set('editorDefaultEmailRecipients', 'filter');
|
|
|
|
}
|
2021-05-07 13:58:05 +03:00
|
|
|
|
|
|
|
@action
|
|
|
|
setDefaultEmailRecipientsFilter(filter) {
|
|
|
|
this.settings.set('editorDefaultEmailRecipientsFilter', filter);
|
|
|
|
}
|
2021-05-07 12:02:19 +03:00
|
|
|
}
|