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

42 lines
1.1 KiB
JavaScript

import ngModule from '../module';
import Summary from 'salix/components/summary';
import './style.scss';
class Controller extends Summary {
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();
}
save() {
this.$http.post(`Orders/${this.order.id}/confirm`).then(() => {
this.vnApp.showSuccess(this.$t('Order confirmed'));
this.$state.go(`ticket.index`, {
q: JSON.stringify({clientFk: this.order.clientFk})
});
});
}
}
ngModule.vnComponent('vnOrderSummary', {
template: require('./index.html'),
controller: Controller,
bindings: {
order: '<'
}
});