2021-06-04 10:37:47 +03:00
|
|
|
import Component from '@glimmer/component';
|
|
|
|
import {action} from '@ember/object';
|
|
|
|
import {inject as service} from '@ember/service';
|
|
|
|
import {tracked} from '@glimmer/tracking';
|
|
|
|
|
2022-01-31 21:26:12 +03:00
|
|
|
const TYPES = [{
|
|
|
|
name: 'Active',
|
|
|
|
value: 'active'
|
|
|
|
},{
|
|
|
|
name: 'Archived',
|
|
|
|
value: 'archived'
|
|
|
|
}];
|
|
|
|
|
2021-06-04 10:37:47 +03:00
|
|
|
export default class extends Component {
|
|
|
|
@service membersUtils;
|
|
|
|
@service ghostPaths;
|
|
|
|
@service ajax;
|
|
|
|
@service store;
|
|
|
|
@service config;
|
|
|
|
|
2022-05-11 20:11:54 +03:00
|
|
|
@tracked showTierModal = false;
|
|
|
|
@tracked tierModel = null;
|
2022-01-31 21:26:12 +03:00
|
|
|
@tracked type = 'active';
|
2021-06-04 10:37:47 +03:00
|
|
|
|
2022-05-11 20:11:54 +03:00
|
|
|
get tiers() {
|
|
|
|
return this.args.tiers.filter((tier) => {
|
2022-01-31 21:26:12 +03:00
|
|
|
if (this.type === 'active') {
|
2022-05-11 20:11:54 +03:00
|
|
|
return !!tier.active;
|
2022-01-31 21:26:12 +03:00
|
|
|
} else if (this.type === 'archived') {
|
2022-05-11 20:11:54 +03:00
|
|
|
return !tier.active;
|
2022-01-31 21:26:12 +03:00
|
|
|
}
|
2022-08-03 14:21:16 +03:00
|
|
|
|
|
|
|
return true;
|
2022-01-31 21:26:12 +03:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
get availableTypes() {
|
|
|
|
return TYPES;
|
|
|
|
}
|
|
|
|
|
|
|
|
get selectedType() {
|
|
|
|
return this.type ? TYPES.find((d) => {
|
|
|
|
return this.type === d.value;
|
|
|
|
}) : TYPES[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
get isEmptyList() {
|
2022-05-11 20:11:54 +03:00
|
|
|
return this.tiers.length === 0;
|
2022-01-31 21:26:12 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
@action
|
|
|
|
onTypeChange(type) {
|
|
|
|
this.type = type.value;
|
2021-06-04 10:37:47 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
@action
|
2022-05-11 20:11:54 +03:00
|
|
|
async openEditTier(tier) {
|
|
|
|
this.tierModel = tier;
|
|
|
|
this.showTierModal = true;
|
2021-06-04 10:37:47 +03:00
|
|
|
}
|
|
|
|
|
2022-02-02 13:51:21 +03:00
|
|
|
@action
|
|
|
|
async onUnarchive() {
|
|
|
|
this.type = 'active';
|
2022-03-09 10:35:07 +03:00
|
|
|
this.args.updatePortalPreview();
|
|
|
|
}
|
|
|
|
|
|
|
|
@action
|
|
|
|
async onArchive() {
|
|
|
|
this.args.updatePortalPreview();
|
2022-02-02 13:51:21 +03:00
|
|
|
}
|
|
|
|
|
2021-06-04 10:37:47 +03:00
|
|
|
@action
|
2022-05-11 20:11:54 +03:00
|
|
|
async openNewTier() {
|
|
|
|
this.tierModel = this.store.createRecord('tier');
|
|
|
|
this.showTierModal = true;
|
2021-06-04 10:37:47 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
@action
|
2022-05-11 20:11:54 +03:00
|
|
|
closeTierModal() {
|
|
|
|
this.showTierModal = false;
|
2021-06-04 10:37:47 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
@action
|
2022-05-11 20:11:54 +03:00
|
|
|
confirmTierSave() {
|
|
|
|
this.args.confirmTierSave();
|
2021-06-04 10:37:47 +03:00
|
|
|
}
|
|
|
|
}
|