mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-30 14:22:07 +03:00
82d6d38b3f
The tier visibility is now handled by visibility property on object, this change ensures portal preview is updated on a tier archive to show the correct Portal UI.
87 lines
1.8 KiB
JavaScript
87 lines
1.8 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';
|
|
this.args.updatePortalPreview();
|
|
}
|
|
|
|
@action
|
|
async onArchive() {
|
|
this.args.updatePortalPreview();
|
|
}
|
|
|
|
@action
|
|
async openNewProduct() {
|
|
this.productModel = this.store.createRecord('product');
|
|
this.showProductModal = true;
|
|
}
|
|
|
|
@action
|
|
closeProductModal() {
|
|
this.showProductModal = false;
|
|
}
|
|
|
|
@action
|
|
confirmProductSave() {
|
|
this.args.confirmProductSave();
|
|
}
|
|
}
|