refs #5206 implemented general search, missing tests
gitea/salix/pipeline/head There was a failure building this commit
Details
gitea/salix/pipeline/head There was a failure building this commit
Details
This commit is contained in:
parent
dbe42e3bf4
commit
ed5208c9e4
|
@ -9,8 +9,7 @@
|
|||
vn-id="model"
|
||||
url="Travels/filter"
|
||||
limit="20"
|
||||
order="shipped DESC, landed DESC"
|
||||
auto-load="true">
|
||||
order="shipped DESC, landed DESC">
|
||||
</vn-crud-model>
|
||||
<vn-data-viewer
|
||||
model="model"
|
||||
|
|
|
@ -2,9 +2,6 @@ import ngModule from '../module';
|
|||
import ModuleMain from 'salix/components/module-main';
|
||||
|
||||
export default class Travel extends ModuleMain {
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
|
||||
ngModule.vnComponent('vnTravel', {
|
||||
|
|
|
@ -5,30 +5,11 @@ import './style.scss';
|
|||
class Controller extends SearchPanel {
|
||||
constructor($, $element) {
|
||||
super($, $element);
|
||||
this.filter = {};
|
||||
this.filterParams = {
|
||||
scopeDays: 1
|
||||
this.filter = {
|
||||
scopeDays: 1,
|
||||
};
|
||||
}
|
||||
|
||||
fetchParams($params) {
|
||||
if (!Object.entries($params).length)
|
||||
$params.scopeDays = 1;
|
||||
|
||||
if (typeof $params.scopeDays === 'number') {
|
||||
const shippedFrom = Date.vnNew();
|
||||
shippedFrom.setHours(0, 0, 0, 0);
|
||||
|
||||
const shippedTo = new Date(shippedFrom.getTime());
|
||||
shippedTo.setDate(shippedTo.getDate() + $params.scopeDays);
|
||||
shippedTo.setHours(23, 59, 59, 999);
|
||||
|
||||
Object.assign($params, {shippedFrom, shippedTo});
|
||||
}
|
||||
|
||||
return $params;
|
||||
}
|
||||
|
||||
changeShipped() {
|
||||
this.filter.scopeDays = null;
|
||||
this.addFilters();
|
||||
|
@ -40,8 +21,12 @@ class Controller extends SearchPanel {
|
|||
this.addFilters();
|
||||
}
|
||||
|
||||
addFilters() {
|
||||
this.model.addFilter({}, this.filter);
|
||||
addFilters(param) {
|
||||
this.model.addFilter({}, this.filter)
|
||||
.then(() => {
|
||||
if (param)
|
||||
this.checkJustOneResult();
|
||||
});
|
||||
}
|
||||
|
||||
removeParamFilter(param) {
|
||||
|
@ -51,12 +36,16 @@ class Controller extends SearchPanel {
|
|||
}
|
||||
|
||||
onKeyPress($event, param) {
|
||||
console.log('event');
|
||||
if ($event.key === 'Enter') {
|
||||
this.filter[param] = this[param];
|
||||
this.addFilters();
|
||||
this.addFilters(param === 'search');
|
||||
}
|
||||
}
|
||||
|
||||
checkJustOneResult() {
|
||||
if (this.model._orgData.length === 1)
|
||||
this.$state.go('travel.card.summary', {id: this.model._orgData[0].id});
|
||||
}
|
||||
}
|
||||
|
||||
ngModule.vnComponent('vnTravelSearchPanel', {
|
||||
|
|
Loading…
Reference in New Issue