2019-10-24 10:49:18 +00:00
|
|
|
import ngModule from '../module';
|
|
|
|
import './style.scss';
|
|
|
|
|
|
|
|
class Controller {
|
|
|
|
constructor($scope, $http) {
|
|
|
|
this.$ = $scope;
|
|
|
|
this.$http = $http;
|
2020-01-08 12:52:04 +00:00
|
|
|
this.entries = [];
|
2019-10-24 10:49:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
get travel() {
|
|
|
|
return this._travel;
|
|
|
|
}
|
|
|
|
|
|
|
|
set travel(value) {
|
|
|
|
this._travel = value;
|
|
|
|
|
|
|
|
if (value && value.id) {
|
|
|
|
this.getTravel();
|
|
|
|
this.getEntries();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
getTravel() {
|
|
|
|
return this.$http.get(`/api/Travels/${this.travel.id}/getTravel`).then(response => {
|
|
|
|
this.travelData = response.data;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
getEntries() {
|
|
|
|
return this.$http.get(`/api/Travels/${this.travel.id}/getEntries`).then(response => {
|
|
|
|
this.entries = response.data;
|
|
|
|
});
|
|
|
|
}
|
2020-01-08 12:52:04 +00:00
|
|
|
|
|
|
|
total(field) {
|
|
|
|
let total = 0;
|
|
|
|
|
|
|
|
for (let entry of this.entries)
|
|
|
|
total += entry[field];
|
|
|
|
|
|
|
|
return total;
|
|
|
|
}
|
2019-10-24 10:49:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Controller.$inject = ['$scope', '$http'];
|
|
|
|
|
|
|
|
ngModule.component('vnTravelSummary', {
|
|
|
|
template: require('./index.html'),
|
|
|
|
controller: Controller,
|
|
|
|
bindings: {
|
|
|
|
travel: '<'
|
|
|
|
}
|
|
|
|
});
|