mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-07-28 18:24:38 -05:00
Clear date filter buttons
This commit is contained in:
@@ -155,23 +155,27 @@ export class FilterEditorViewService {
|
||||
} : undefined
|
||||
}
|
||||
|
||||
setDateCreatedBefore(date: NgbDateStruct) {
|
||||
this.setDate(date, FILTER_CREATED_BEFORE)
|
||||
setDateCreatedBefore(date?: NgbDateStruct) {
|
||||
if (date) this.setDateFilter(date, FILTER_CREATED_BEFORE)
|
||||
else this.clearDateFilter(FILTER_CREATED_BEFORE)
|
||||
}
|
||||
|
||||
setDateCreatedAfter(date: NgbDateStruct) {
|
||||
this.setDate(date, FILTER_CREATED_AFTER)
|
||||
setDateCreatedAfter(date?: NgbDateStruct) {
|
||||
if (date) this.setDateFilter(date, FILTER_CREATED_AFTER)
|
||||
else this.clearDateFilter(FILTER_CREATED_AFTER)
|
||||
}
|
||||
|
||||
setDateAddedBefore(date: NgbDateStruct) {
|
||||
this.setDate(date, FILTER_ADDED_BEFORE)
|
||||
setDateAddedBefore(date?: NgbDateStruct) {
|
||||
if (date) this.setDateFilter(date, FILTER_ADDED_BEFORE)
|
||||
else this.clearDateFilter(FILTER_ADDED_BEFORE)
|
||||
}
|
||||
|
||||
setDateAddedAfter(date: NgbDateStruct) {
|
||||
this.setDate(date, FILTER_ADDED_AFTER)
|
||||
setDateAddedAfter(date?: NgbDateStruct) {
|
||||
if (date) this.setDateFilter(date, FILTER_ADDED_AFTER)
|
||||
else this.clearDateFilter(FILTER_ADDED_AFTER)
|
||||
}
|
||||
|
||||
setDate(date: NgbDateStruct, dateRuleTypeID: number) {
|
||||
setDateFilter(date: NgbDateStruct, dateRuleTypeID: number) {
|
||||
let filterRules = this.filterRules
|
||||
let existingRule = filterRules.find(rule => rule.type.id == dateRuleTypeID)
|
||||
let newValue = `${date.year}-${date.month.toString().padStart(2,'0')}-${date.day.toString().padStart(2,'0')}` // YYYY-MM-DD
|
||||
@@ -184,4 +188,11 @@ export class FilterEditorViewService {
|
||||
|
||||
this.filterRules = filterRules
|
||||
}
|
||||
|
||||
clearDateFilter(dateRuleTypeID: number) {
|
||||
let filterRules = this.filterRules
|
||||
let existingRule = filterRules.find(rule => rule.type.id == dateRuleTypeID)
|
||||
filterRules.splice(filterRules.indexOf(existingRule), 1)
|
||||
this.filterRules = filterRules
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user