From eefa4b9f5b550bdaff2fd0a4f19f117ae36a3c7b Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Fri, 12 Jul 2019 12:56:00 +0200 Subject: [PATCH] apply default filters --- modules/ticket/front/index/index.js | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/modules/ticket/front/index/index.js b/modules/ticket/front/index/index.js index e431db7ef..95711dd0c 100644 --- a/modules/ticket/front/index/index.js +++ b/modules/ticket/front/index/index.js @@ -18,6 +18,20 @@ export default class Controller { this.$.balanceCreateDialog.show(); }, name: 'Payment on account...', always: true} ]; + + if (!$stateParams.q) + this.setDefaultFilter(); + } + + setDefaultFilter() { + const today = new Date(); + today.setHours(0, 0, 0, 0); + + const tomorrow = new Date(); + tomorrow.setDate(tomorrow.getDate() + 1); + tomorrow.setHours(23, 59, 59, 999); + + this.filter = {from: today, to: tomorrow}; } setBalanceCreateDialog() { @@ -55,17 +69,7 @@ export default class Controller { this.scopeDays = params.scopeDays; this.buildFilterDates(); params = Object.assign(params, {from: this.today, to: this.daysOnward}); - } else if (!params.from && !params.to) { - const today = new Date(); - today.setHours(0, 0, 0, 0); - - const tomorrow = new Date(); - tomorrow.setDate(tomorrow.getDate() + 1); - tomorrow.setHours(23, 59, 59, 999); - - params = Object.assign(params, {from: today, to: tomorrow}); } - this.$.model.applyFilter(null, params); } else this.$.model.clear();