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

42 lines
1.1 KiB
JavaScript
Raw Permalink Normal View History

2018-07-18 12:38:43 +00:00
import ngModule from '../module';
2020-11-23 12:41:51 +00:00
import Summary from 'salix/components/summary';
2018-10-10 10:55:04 +00:00
import './style.scss';
2018-07-18 12:38:43 +00:00
2020-11-23 12:41:51 +00:00
class Controller extends Summary {
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();
}
2020-06-30 06:32:04 +00:00
save() {
2020-07-09 09:21:06 +00:00
this.$http.post(`Orders/${this.order.id}/confirm`).then(() => {
2020-06-30 06:32:04 +00:00
this.vnApp.showSuccess(this.$t('Order confirmed'));
this.$state.go(`ticket.index`, {
q: JSON.stringify({clientFk: this.order.clientFk})
});
});
}
2018-07-18 12:38:43 +00:00
}
ngModule.vnComponent('vnOrderSummary', {
2018-07-18 12:38:43 +00:00
template: require('./index.html'),
controller: Controller,
bindings: {
order: '<'
}
});