mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-30 01:42:29 +03:00
498efd00cb
refs https://github.com/TryGhost/Team/issues/1252 - on unarchiving a tier, we switch back to active tier list instead of staying back on archived list
81 lines
1.7 KiB
JavaScript
81 lines
1.7 KiB
JavaScript
import Component from '@glimmer/component';
|
|
import {action} from '@ember/object';
|
|
import {inject as service} from '@ember/service';
|
|
import {tracked} from '@glimmer/tracking';
|
|
|
|
const TYPES = [{
|
|
name: 'Active',
|
|
value: 'active'
|
|
},{
|
|
name: 'Archived',
|
|
value: 'archived'
|
|
}];
|
|
|
|
export default class extends Component {
|
|
@service membersUtils;
|
|
@service ghostPaths;
|
|
@service ajax;
|
|
@service store;
|
|
@service config;
|
|
|
|
@tracked showProductModal = false;
|
|
@tracked productModel = null;
|
|
@tracked type = 'active';
|
|
|
|
get products() {
|
|
return this.args.products.filter((product) => {
|
|
if (this.type === 'active') {
|
|
return !!product.active;
|
|
} else if (this.type === 'archived') {
|
|
return !product.active;
|
|
}
|
|
});
|
|
}
|
|
|
|
get availableTypes() {
|
|
return TYPES;
|
|
}
|
|
|
|
get selectedType() {
|
|
return this.type ? TYPES.find((d) => {
|
|
return this.type === d.value;
|
|
}) : TYPES[0];
|
|
}
|
|
|
|
get isEmptyList() {
|
|
return this.products.length === 0;
|
|
}
|
|
|
|
@action
|
|
onTypeChange(type) {
|
|
this.type = type.value;
|
|
}
|
|
|
|
@action
|
|
async openEditProduct(product) {
|
|
this.productModel = product;
|
|
this.showProductModal = true;
|
|
}
|
|
|
|
@action
|
|
async onUnarchive() {
|
|
this.type = 'active';
|
|
}
|
|
|
|
@action
|
|
async openNewProduct() {
|
|
this.productModel = this.store.createRecord('product');
|
|
this.showProductModal = true;
|
|
}
|
|
|
|
@action
|
|
closeProductModal() {
|
|
this.showProductModal = false;
|
|
}
|
|
|
|
@action
|
|
confirmProductSave() {
|
|
this.args.confirmProductSave();
|
|
}
|
|
}
|