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

45 lines
1.1 KiB
JavaScript
Raw Normal View History

2018-07-18 12:38:43 +00:00
import ngModule from '../module';
2020-03-17 14:18:02 +00:00
import Section from 'salix/components/section';
2018-10-10 10:55:04 +00:00
import './style.scss';
2018-07-18 12:38:43 +00:00
2020-03-17 14:18:02 +00:00
class Controller extends Section {
2018-10-10 10:55:04 +00:00
setSummary() {
this.$http.get(`Orders/${this.order.id}/summary`).then(res => {
2019-01-17 10:11:45 +00:00
if (res && res.data)
2018-10-10 10:55:04 +00:00
this.summary = res.data;
});
}
get formattedAddress() {
2020-03-17 14:18:02 +00:00
if (!this.summary) return null;
2018-10-10 10:55:04 +00:00
let address = this.summary.address;
let province = address.province ? `(${address.province.name})` : '';
return `${address.street} - ${address.city} ${province}`;
}
2018-10-10 12:03:56 +00:00
$onChanges() {
if (this.order && this.order.id)
this.setSummary();
}
2019-01-17 10:11:45 +00:00
showDescriptor(event, itemFk) {
2020-03-17 14:18:02 +00:00
this.$.descriptor.itemFk = itemFk;
this.$.descriptor.parent = event.target;
this.$.descriptor.show();
2018-10-10 10:55:04 +00:00
}
onDescriptorLoad() {
2020-03-17 14:18:02 +00:00
this.$.popover.relocate();
2018-10-10 12:03:56 +00:00
}
2018-07-18 12:38:43 +00:00
}
ngModule.component('vnOrderSummary', {
template: require('./index.html'),
controller: Controller,
bindings: {
order: '<'
}
});