2019-03-22 10:10:23 +00:00
|
|
|
import ngModule from '../module';
|
2020-03-17 14:24:55 +00:00
|
|
|
import Section from 'salix/components/section';
|
2019-03-22 10:10:23 +00:00
|
|
|
import './style.scss';
|
|
|
|
|
2020-03-17 14:24:55 +00:00
|
|
|
class Controller extends Section {
|
2019-03-22 10:10:23 +00:00
|
|
|
set route(value) {
|
|
|
|
this._route = value;
|
|
|
|
if (value && value.id)
|
|
|
|
this.getSummary();
|
|
|
|
}
|
|
|
|
|
|
|
|
sumPackages() {
|
|
|
|
this.packagesTotal = 0;
|
2019-03-25 12:16:34 +00:00
|
|
|
this.summary.tickets.forEach(ticket => {
|
2019-03-22 10:10:23 +00:00
|
|
|
this.packagesTotal += ticket.packages;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
get route() {
|
|
|
|
return this._route;
|
|
|
|
}
|
|
|
|
|
|
|
|
getSummary() {
|
2019-10-24 22:53:53 +00:00
|
|
|
this.$http.get(`Routes/${this.route.id}/summary`).then(response => {
|
2019-03-22 10:10:23 +00:00
|
|
|
this.summary = response.data;
|
2019-03-25 12:16:34 +00:00
|
|
|
if (response.data && response.data.tickets)
|
2019-03-22 10:10:23 +00:00
|
|
|
this.sumPackages();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-24 12:22:30 +00:00
|
|
|
ngModule.vnComponent('vnRouteSummary', {
|
2019-03-22 10:10:23 +00:00
|
|
|
template: require('./index.html'),
|
|
|
|
controller: Controller,
|
|
|
|
bindings: {
|
|
|
|
route: '<'
|
|
|
|
}
|
|
|
|
});
|