salix/modules/order/front/summary/index.js

45 lines
1.1 KiB
JavaScript

import ngModule from '../module';
import Section from 'salix/components/section';
import './style.scss';
class Controller extends Section {
setSummary() {
this.$http.get(`Orders/${this.order.id}/summary`).then(res => {
if (res && res.data)
this.summary = res.data;
});
}
get formattedAddress() {
if (!this.summary) return null;
let address = this.summary.address;
let province = address.province ? `(${address.province.name})` : '';
return `${address.street} - ${address.city} ${province}`;
}
$onChanges() {
if (this.order && this.order.id)
this.setSummary();
}
showDescriptor(event, itemFk) {
this.$.descriptor.itemFk = itemFk;
this.$.descriptor.parent = event.target;
this.$.descriptor.show();
}
onDescriptorLoad() {
this.$.popover.relocate();
}
}
ngModule.component('vnOrderSummary', {
template: require('./index.html'),
controller: Controller,
bindings: {
order: '<'
}
});