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