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

62 lines
1.5 KiB
JavaScript
Raw Normal View History

2018-07-18 12:38:43 +00:00
import ngModule from '../module';
2018-10-10 10:55:04 +00:00
import './style.scss';
2018-07-18 12:38:43 +00:00
class Controller {
2018-10-10 10:55:04 +00:00
constructor($scope, $http, $state) {
this.$scope = $scope;
2018-07-18 12:38:43 +00:00
this.$http = $http;
2018-10-10 10:55:04 +00:00
this.$state = $state;
2018-10-10 12:03:56 +00:00
this.order = {};
2018-07-18 12:38:43 +00:00
}
2018-10-10 10:55:04 +00:00
setSummary() {
2018-10-10 12:03:56 +00:00
this.$http.get(`/order/api/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() {
if (!this.summary) return;
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) {
2018-10-10 10:55:04 +00:00
this.quicklinks = {
btnThree: {
icon: 'icon-transaction',
state: `item.card.diary({
2019-01-17 10:11:45 +00:00
id: ${itemFk},
2018-10-10 10:55:04 +00:00
})`,
tooltip: 'Item diary'
}
};
2019-01-17 10:11:45 +00:00
this.$scope.descriptor.itemFk = itemFk;
2018-10-10 10:55:04 +00:00
this.$scope.descriptor.parent = event.target;
this.$scope.descriptor.show();
}
onDescriptorLoad() {
this.$scope.popover.relocate();
2018-10-10 12:03:56 +00:00
}
2018-07-18 12:38:43 +00:00
}
2018-10-10 10:55:04 +00:00
Controller.$inject = ['$scope', '$http', '$state'];
2018-07-18 12:38:43 +00:00
ngModule.component('vnOrderSummary', {
template: require('./index.html'),
controller: Controller,
bindings: {
order: '<'
}
});