salix/modules/travel/front/index/index.js

46 lines
1.2 KiB
JavaScript
Raw Normal View History

2018-11-13 06:44:03 +00:00
import ngModule from '../module';
export default class Controller {
constructor($scope) {
2019-10-24 10:49:18 +00:00
this.$ = $scope;
2018-11-13 06:44:03 +00:00
this.ticketSelected = null;
}
2019-10-24 10:49:18 +00:00
preview(event, travel) {
this.travelSelected = travel;
this.$.summary.show();
event.preventDefault();
event.stopImmediatePropagation();
}
2019-12-20 06:55:00 +00:00
getScopeDates(days) {
const today = new Date();
today.setHours(0, 0, 0, 0);
const daysOnward = new Date(today);
daysOnward.setDate(today.getDate() + days);
daysOnward.setHours(23, 59, 59, 999);
return {shippedFrom: today, shippedTo: daysOnward};
}
onSearch(params) {
if (params) {
let newParams = params;
if (params.scopeDays) {
const scopeDates = this.getScopeDates(params.scopeDays);
Object.assign(newParams, scopeDates);
} else if (Object.entries(params).length == 0)
newParams = this.getScopeDates(1);
this.$.model.applyFilter(null, newParams);
} else
this.$.model.clear();
}
2018-11-13 06:44:03 +00:00
}
Controller.$inject = ['$scope'];
ngModule.component('vnTravelIndex', {
template: require('./index.html'),
controller: Controller
});