diff --git a/modules/route/front/main/index.html b/modules/route/front/main/index.html index 16243be03..7be7153af 100644 --- a/modules/route/front/main/index.html +++ b/modules/route/front/main/index.html @@ -9,7 +9,8 @@ vn-focus panel="vn-route-search-panel" info="Search routes by id" - filter="$ctrl.filterParams" + fetch-params="$ctrl.fetchParams($params)" + suggested-filter="$ctrl.filterParams" model="model"> diff --git a/modules/route/front/main/index.js b/modules/route/front/main/index.js index a6d5bedd1..0f30707e9 100644 --- a/modules/route/front/main/index.js +++ b/modules/route/front/main/index.js @@ -2,16 +2,30 @@ import ngModule from '../module'; import ModuleMain from 'salix/components/module-main'; export default class Route extends ModuleMain { - $postLink() { - let to = new Date(); - to.setDate(to.getDate() + 1); - to.setHours(0, 0, 0, 0); + constructor() { + super(); - let from = new Date(); - from.setHours(0, 0, 0, 0); + this.filterParams = { + scopeDays: 1 + }; + } - this.filterParams = {from, to, warehouseFk: this.vnConfig.warehouseFk}; - this.$.model.applyFilter(null, this.filterParams); + fetchParams($params) { + if (!Object.entries($params).length) + $params.scopeDays = 1; + + if (typeof $params.scopeDays === 'number') { + const from = new Date(); + from.setHours(0, 0, 0, 0); + + const to = new Date(from.getTime()); + to.setDate(to.getDate() + $params.scopeDays); + to.setHours(23, 59, 59, 999); + + Object.assign($params, {from, to}); + } + + return $params; } } diff --git a/modules/route/front/search-panel/index.html b/modules/route/front/search-panel/index.html index 2c7dd93b2..dc41e95fd 100644 --- a/modules/route/front/search-panel/index.html +++ b/modules/route/front/search-panel/index.html @@ -1,6 +1,6 @@