salix/modules/travel/front/search-panel/index.js

58 lines
1.3 KiB
JavaScript
Raw Normal View History

2018-11-13 06:44:03 +00:00
import ngModule from '../module';
2018-12-27 11:54:16 +00:00
import SearchPanel from 'core/components/searchbar/search-panel';
import './style.scss';
2018-11-13 06:44:03 +00:00
2021-01-29 10:45:35 +00:00
class Controller extends SearchPanel {
constructor($, $element) {
super($, $element);
this.filter = {
scopeDays: 1,
};
}
changeShipped() {
2021-01-29 10:45:35 +00:00
this.filter.scopeDays = null;
this.addFilters();
2021-01-29 10:45:35 +00:00
}
changeScopeDays() {
this.filter.shippedFrom = null;
this.filter.shippedTo = null;
this.addFilters();
2021-01-29 10:45:35 +00:00
}
addFilters(param) {
this.model.addFilter({}, this.filter)
.then(() => {
if (param)
this.checkJustOneResult();
});
2021-01-29 10:45:35 +00:00
}
removeParamFilter(param) {
if (this[param]) this[param] = null;
this.filter[param] = null;
this.addFilters();
2021-01-29 10:45:35 +00:00
}
onKeyPress($event, param) {
if ($event.key === 'Enter') {
this.filter[param] = this[param];
this.addFilters(param === 'search');
}
}
checkJustOneResult() {
if (this.model._orgData.length === 1)
this.$state.go('travel.card.summary', {id: this.model._orgData[0].id});
}
2021-01-29 10:45:35 +00:00
}
ngModule.vnComponent('vnTravelSearchPanel', {
2018-11-13 06:44:03 +00:00
template: require('./index.html'),
controller: Controller,
bindings: {
model: '<'
}
2018-11-13 06:44:03 +00:00
});