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

33 lines
792 B
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 => this.summary = res.data);
2018-10-10 10:55:04 +00:00
}
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();
}
2018-07-18 12:38:43 +00:00
}
ngModule.component('vnOrderSummary', {
template: require('./index.html'),
controller: Controller,
bindings: {
order: '<'
}
});