ticket.index filters
gitea/salix/master This commit looks good Details

This commit is contained in:
Joan Sanchez 2019-07-12 14:00:32 +02:00
parent eefa4b9f5b
commit c21532e5f7
1 changed files with 14 additions and 27 deletions

View File

@ -18,20 +18,6 @@ export default class Controller {
this.$.balanceCreateDialog.show(); this.$.balanceCreateDialog.show();
}, name: 'Payment on account...', always: true} }, 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() { setBalanceCreateDialog() {
@ -51,26 +37,27 @@ export default class Controller {
this.$.balanceCreateDialog.description += description.join(', '); this.$.balanceCreateDialog.description += description.join(', ');
} }
buildFilterDates() { getScopeDates(days) {
let today = new Date(); const today = new Date();
this.today = today.setHours(0, 0, 0, 0); today.setHours(0, 0, 0, 0);
let buildDate = new Date(today); const daysOnward = new Date(today);
buildDate.setDate(today.getDate() + this.scopeDays); daysOnward.setDate(today.getDate() + days);
buildDate.setHours(23, 59, 59, 999); daysOnward.setHours(23, 59, 59, 999);
this.daysOnward = buildDate; return {from: today, to: daysOnward};
} }
onSearch(params) { onSearch(params) {
if (params) { if (params) {
let newParams = params;
if (params.scopeDays) { if (params.scopeDays) {
params.scopeDays = parseInt(params.scopeDays); const scopeDates = this.getScopeDates(params.scopeDays);
this.scopeDays = params.scopeDays; Object.assign(newParams, scopeDates);
this.buildFilterDates(); } else if (Object.entries(params).length == 0)
params = Object.assign(params, {from: this.today, to: this.daysOnward}); newParams = this.getScopeDates(1);
}
this.$.model.applyFilter(null, params); this.$.model.applyFilter(null, newParams);
} else } else
this.$.model.clear(); this.$.model.clear();
} }