more refactoring and bug fixing.

This commit is contained in:
jonaswinkler 2020-12-15 03:29:23 +01:00
parent ff71b04848
commit 999b36473c

View File

@ -200,24 +200,21 @@ export class FilterEditorComponent implements OnInit, OnDestroy {
}
setDateFilter(date: NgbDateStruct, dateRuleTypeID: number) {
let filterRules = this.filterRules
let existingRule = filterRules.find(rule => rule.rule_type == dateRuleTypeID)
let existingRule = this.filterRules.find(rule => rule.rule_type == dateRuleTypeID)
let newValue = this.dateParser.format(date)
if (existingRule) {
existingRule.value = newValue
} else {
filterRules.push({rule_type: dateRuleTypeID, value: newValue})
this.filterRules.push({rule_type: dateRuleTypeID, value: newValue})
}
this.filterRules = filterRules
}
clearDateFilter(dateRuleTypeID: number) {
let filterRules = this.filterRules
let existingRule = filterRules.find(rule => rule.rule_type == dateRuleTypeID)
filterRules.splice(filterRules.indexOf(existingRule), 1)
this.filterRules = filterRules
let ruleIndex = this.filterRules.findIndex(rule => rule.rule_type == dateRuleTypeID)
if (ruleIndex != -1) {
this.filterRules.splice(ruleIndex, 1)
}
}
}