Ghost/ghost/admin/app/components/modal-product-price.js
Rishabh Garg a544005c1f Wired products data to Product settings screen (#1927)
refs https://github.com/TryGhost/Team/issues/627

Wires the real Products data from API to the mock Product settings screen including Product Prices list as well as opening of edit/new price modals. The new Product setting is still behind the developer experiment flag as is under active development, the changes in this commit only allows readonly data but not save/edit upstream.

Co-authored-by: Fabien O'Carroll <fabien@allou.is>
2021-04-22 22:17:19 +05:30

55 lines
1.2 KiB
JavaScript

import ModalBase from 'ghost-admin/components/modal-base';
import classic from 'ember-classic-decorator';
import {action} from '@ember/object';
import {tracked} from '@glimmer/tracking';
// TODO: update modals to work fully with Glimmer components
@classic
export default class ModalProductPrice extends ModalBase {
@tracked model;
get title() {
if (this.isExistingPrice) {
return `Price - ${this.price.nickname || 'No Name'}`;
}
return 'New Price';
}
get price() {
return this.model.price || {};
}
get isExistingPrice() {
return !!this.model.price;
}
// TODO: rename to confirm() when modals have full Glimmer support
@action
confirmAction() {
this.confirm(this.role);
this.close();
}
@action
close(event) {
event?.preventDefault?.();
this.closeModal();
}
// @action
// setRoleFromModel() {
// this.role = this.model;
// }
actions = {
confirm() {
this.confirmAction(...arguments);
},
// needed because ModalBase uses .send() for keyboard events
closeModal() {
this.close();
}
}
}