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

33 lines
792 B
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 => 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();
}
}
ngModule.component('vnOrderSummary', {
template: require('./index.html'),
controller: Controller,
bindings: {
order: '<'
}
});