2019-03-22 10:07:44 +00:00
|
|
|
import ngModule from '../module';
|
2020-03-05 12:56:45 +00:00
|
|
|
import Component from 'core/lib/component';
|
|
|
|
|
|
|
|
class Controller extends Component {
|
2020-03-17 14:24:55 +00:00
|
|
|
constructor($element, $, $httpParamSerializer) {
|
|
|
|
super($element, $);
|
2019-03-22 10:07:44 +00:00
|
|
|
|
2019-11-06 07:20:45 +00:00
|
|
|
this.$httpParamSerializer = $httpParamSerializer;
|
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() {
|
2019-11-06 07:20:45 +00:00
|
|
|
const params = {
|
2020-03-05 12:56:45 +00:00
|
|
|
authorization: this.vnToken.token,
|
2020-03-16 11:32:26 +00:00
|
|
|
clientId: this.vnConfig.storage.currentUserWorkerId,
|
2019-11-06 07:20:45 +00:00
|
|
|
routeId: this.route.id
|
|
|
|
};
|
|
|
|
const serializedParams = this.$httpParamSerializer(params);
|
|
|
|
let url = `api/report/driver-route?${serializedParams}`;
|
2019-04-15 12:34:33 +00:00
|
|
|
window.open(url);
|
|
|
|
}
|
|
|
|
|
|
|
|
sendRouteReport() {
|
2019-11-06 07:20:45 +00:00
|
|
|
const params = {
|
|
|
|
recipient: user.emailUser.email,
|
2020-03-16 11:32:26 +00:00
|
|
|
clientId: this.vnConfig.storage.currentUserWorkerId,
|
2019-11-06 07:20:45 +00:00
|
|
|
routeId: this.route.id
|
|
|
|
};
|
2020-03-05 12:56:45 +00:00
|
|
|
this.$http.get(`email/driver-route`, {params}).then(() => {
|
2019-04-15 12:34:33 +00:00
|
|
|
this.vnApp.showSuccess(this.$translate.instant('Report sent'));
|
|
|
|
});
|
|
|
|
}
|
2019-06-05 11:51:34 +00:00
|
|
|
|
|
|
|
showUpdateVolumeDialog() {
|
|
|
|
this.$.updateVolumeConfirmation.show();
|
|
|
|
}
|
|
|
|
|
|
|
|
updateVolume(response) {
|
2019-10-30 15:57:14 +00:00
|
|
|
if (response === 'accept') {
|
2019-10-24 22:53:53 +00:00
|
|
|
let url = `Routes/${this.route.id}/updateVolume`;
|
2019-06-05 11:51:34 +00:00
|
|
|
this.$http.post(url).then(() => {
|
|
|
|
this.vnApp.showSuccess(this.$translate.instant('Volume updated'));
|
2020-02-07 06:43:22 +00:00
|
|
|
this.cardReload();
|
2019-06-05 11:51:34 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
2019-03-22 10:07:44 +00:00
|
|
|
}
|
|
|
|
|
2020-03-05 12:56:45 +00:00
|
|
|
Controller.$inject = ['$element', '$scope', '$httpParamSerializer'];
|
2019-03-22 10:07:44 +00:00
|
|
|
|
|
|
|
ngModule.component('vnRouteDescriptor', {
|
|
|
|
template: require('./index.html'),
|
|
|
|
bindings: {
|
|
|
|
route: '<',
|
2020-02-07 06:43:22 +00:00
|
|
|
cardReload: '&?',
|
2019-03-22 10:07:44 +00:00
|
|
|
quicklinks: '<'
|
|
|
|
},
|
|
|
|
controller: Controller
|
|
|
|
});
|