2019-03-22 10:07:44 +00:00
|
|
|
import ngModule from '../module';
|
2019-06-05 11:51:34 +00:00
|
|
|
import {createDecipher} from 'crypto';
|
2019-03-22 10:07:44 +00:00
|
|
|
|
|
|
|
class Controller {
|
2019-06-05 11:51:34 +00:00
|
|
|
constructor($, $http, vnApp, $translate, aclService) {
|
2019-04-15 12:34:33 +00:00
|
|
|
this.$http = $http;
|
|
|
|
this.vnApp = vnApp;
|
|
|
|
this.$translate = $translate;
|
|
|
|
this.$ = $;
|
2019-06-05 11:51:34 +00:00
|
|
|
this.aclService = aclService;
|
2019-04-15 12:34:33 +00:00
|
|
|
this.moreOptions = [
|
|
|
|
{callback: this.showRouteReport, name: 'Show route report'},
|
2019-06-05 11:51:34 +00:00
|
|
|
{callback: this.sendRouteReport, name: 'Send route report'},
|
|
|
|
{callback: this.showUpdateVolumeDialog, name: 'Update volume', acl: 'deliveryBoss'}
|
2019-04-15 12:34:33 +00:00
|
|
|
];
|
|
|
|
}
|
2019-06-05 11:51:34 +00:00
|
|
|
|
|
|
|
onMoreOpen() {
|
|
|
|
let options = this.moreOptions.filter(option => {
|
|
|
|
const hasAclProperty = Object.hasOwnProperty.call(option, 'acl');
|
|
|
|
|
|
|
|
return !hasAclProperty || (hasAclProperty && this.aclService.hasAny([option.acl]));
|
|
|
|
});
|
|
|
|
this.$.moreButton.data = options;
|
|
|
|
}
|
|
|
|
|
2019-03-22 10:07:44 +00:00
|
|
|
set quicklinks(value = {}) {
|
|
|
|
this._quicklinks = Object.assign(value, this._quicklinks);
|
|
|
|
}
|
|
|
|
|
|
|
|
get quicklinks() {
|
|
|
|
return this._quicklinks;
|
|
|
|
}
|
2019-04-15 12:34:33 +00:00
|
|
|
|
|
|
|
onMoreChange(callback) {
|
|
|
|
callback.call(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
showRouteReport() {
|
|
|
|
let url = `/api/report/rpt-route?routeFk=${this.route.id}`;
|
|
|
|
window.open(url);
|
|
|
|
}
|
|
|
|
|
|
|
|
sendRouteReport() {
|
|
|
|
let url = `/api/email/driver-route?routeFk=${this.route.id}`;
|
|
|
|
this.$http.post(url).then(() => {
|
|
|
|
this.vnApp.showSuccess(this.$translate.instant('Report sent'));
|
|
|
|
});
|
|
|
|
}
|
2019-06-05 11:51:34 +00:00
|
|
|
|
|
|
|
showUpdateVolumeDialog() {
|
|
|
|
this.$.updateVolumeConfirmation.show();
|
|
|
|
}
|
|
|
|
|
|
|
|
updateVolume(response) {
|
|
|
|
if (response === 'ACCEPT') {
|
|
|
|
let url = `/route/api/Routes/${this.route.id}/updateVolume`;
|
|
|
|
this.$http.post(url).then(() => {
|
|
|
|
this.vnApp.showSuccess(this.$translate.instant('Volume updated'));
|
|
|
|
this.card.reload();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
2019-03-22 10:07:44 +00:00
|
|
|
}
|
|
|
|
|
2019-06-05 11:51:34 +00:00
|
|
|
Controller.$inject = ['$scope', '$http', 'vnApp', '$translate', 'aclService'];
|
2019-03-22 10:07:44 +00:00
|
|
|
|
|
|
|
ngModule.component('vnRouteDescriptor', {
|
|
|
|
template: require('./index.html'),
|
|
|
|
bindings: {
|
|
|
|
route: '<',
|
|
|
|
quicklinks: '<'
|
|
|
|
},
|
2019-06-05 11:51:34 +00:00
|
|
|
require: {
|
|
|
|
card: '^vnRouteCard'
|
|
|
|
},
|
2019-03-22 10:07:44 +00:00
|
|
|
controller: Controller
|
|
|
|
});
|