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';
|
2023-03-02 10:33:55 +00:00
|
|
|
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);
|
2023-03-02 14:10:17 +00:00
|
|
|
this.filter = {
|
|
|
|
scopeDays: 1,
|
2023-03-02 12:55:47 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2023-03-02 10:33:55 +00:00
|
|
|
changeShipped() {
|
2021-01-29 10:45:35 +00:00
|
|
|
this.filter.scopeDays = null;
|
2023-03-02 10:33:55 +00:00
|
|
|
this.addFilters();
|
2021-01-29 10:45:35 +00:00
|
|
|
}
|
|
|
|
|
2023-03-02 10:33:55 +00:00
|
|
|
changeScopeDays() {
|
|
|
|
this.filter.shippedFrom = null;
|
|
|
|
this.filter.shippedTo = null;
|
|
|
|
this.addFilters();
|
2021-01-29 10:45:35 +00:00
|
|
|
}
|
|
|
|
|
2023-03-02 14:10:17 +00:00
|
|
|
addFilters(param) {
|
|
|
|
this.model.addFilter({}, this.filter)
|
|
|
|
.then(() => {
|
|
|
|
if (param)
|
|
|
|
this.checkJustOneResult();
|
|
|
|
});
|
2021-01-29 10:45:35 +00:00
|
|
|
}
|
|
|
|
|
2023-03-02 10:33:55 +00:00
|
|
|
removeParamFilter(param) {
|
2023-03-02 12:55:47 +00:00
|
|
|
if (this[param]) this[param] = null;
|
2023-03-02 10:33:55 +00:00
|
|
|
this.filter[param] = null;
|
|
|
|
this.addFilters();
|
2021-01-29 10:45:35 +00:00
|
|
|
}
|
2023-03-02 12:55:47 +00:00
|
|
|
|
|
|
|
onKeyPress($event, param) {
|
|
|
|
if ($event.key === 'Enter') {
|
|
|
|
this.filter[param] = this[param];
|
2023-03-02 14:10:17 +00:00
|
|
|
this.addFilters(param === 'search');
|
2023-03-02 12:55:47 +00:00
|
|
|
}
|
|
|
|
}
|
2023-03-02 14:10:17 +00:00
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2020-07-24 12:22:30 +00:00
|
|
|
ngModule.vnComponent('vnTravelSearchPanel', {
|
2018-11-13 06:44:03 +00:00
|
|
|
template: require('./index.html'),
|
2023-03-02 10:33:55 +00:00
|
|
|
controller: Controller,
|
|
|
|
bindings: {
|
|
|
|
model: '<'
|
|
|
|
}
|
2018-11-13 06:44:03 +00:00
|
|
|
});
|