diff --git a/src-ui/src/app/components/document-list/document-list.component.html b/src-ui/src/app/components/document-list/document-list.component.html
index 8f4ae1b6c..8ba77a815 100644
--- a/src-ui/src/app/components/document-list/document-list.component.html
+++ b/src-ui/src/app/components/document-list/document-list.component.html
@@ -5,7 +5,7 @@
Select
-
+
@@ -78,7 +78,7 @@
diff --git a/src-ui/src/app/components/document-list/document-list.component.ts b/src-ui/src/app/components/document-list/document-list.component.ts
index 84daf7e22..9b88c13b4 100644
--- a/src-ui/src/app/components/document-list/document-list.component.ts
+++ b/src-ui/src/app/components/document-list/document-list.component.ts
@@ -30,9 +30,11 @@ export class DocumentListComponent implements OnInit {
private filterEditor: FilterEditorComponent
@ViewChildren(SortableDirective) headers: QueryList
;
-
+
displayMode = 'smallCards' // largeCards, smallCards, details
+ filterRulesModified: boolean = false
+
get isFiltered() {
return this.list.filterRules?.length > 0
}
@@ -69,18 +71,20 @@ export class DocumentListComponent implements OnInit {
this.router.navigate(["404"])
return
}
-
this.list.savedView = view
this.list.reload()
+ this.rulesChanged()
})
} else {
this.list.savedView = null
this.list.reload()
+ this.rulesChanged()
}
})
}
loadViewConfig(view: PaperlessSavedView) {
+ this.filterRulesModified = false
this.list.load(view)
this.list.reload()
}
@@ -105,6 +109,7 @@ export class DocumentListComponent implements OnInit {
sort_reverse: this.list.sortReverse,
sort_field: this.list.sortField
}
+
this.savedViewService.create(savedView).subscribe(() => {
modal.close()
this.toastService.showInfo($localize`View "${savedView.name}" created successfully.`)
@@ -115,6 +120,46 @@ export class DocumentListComponent implements OnInit {
})
}
+ resetFilters(): void {
+ this.filterRulesModified = false
+ if (this.list.savedViewId) {
+ this.savedViewService.getCached(this.list.savedViewId).subscribe(viewUntouched => {
+ this.list.filterRules = viewUntouched.filter_rules
+ this.list.reload()
+ })
+ } else {
+ this.list.filterRules = []
+ this.list.reload()
+ }
+ }
+
+ rulesChanged() {
+ let modified = false
+ if (this.list.savedView == null) {
+ modified = this.list.filterRules.length > 0 // documents list is modified if it has any filters
+ } else {
+ // compare savedView current filters vs original
+ this.savedViewService.getCached(this.list.savedViewId).subscribe(view => {
+ let filterRulesInitial = view.filter_rules
+
+ if (this.list.filterRules.length !== filterRulesInitial.length) modified = true
+ else {
+ modified = this.list.filterRules.some(rule => {
+ return (filterRulesInitial.find(fri => fri.rule_type == rule.rule_type && fri.value == rule.value) == undefined)
+ })
+
+ if (!modified) {
+ // only check other direction if we havent already determined is modified
+ modified = filterRulesInitial.some(rule => {
+ this.list.filterRules.find(fr => fr.rule_type == rule.rule_type && fr.value == rule.value) == undefined
+ })
+ }
+ }
+ })
+ }
+ this.filterRulesModified = modified
+ }
+
clickTag(tagID: number) {
this.list.selectNone()
setTimeout(() => {
diff --git a/src-ui/src/app/components/document-list/filter-editor/filter-editor.component.html b/src-ui/src/app/components/document-list/filter-editor/filter-editor.component.html
index efbf6ce7e..02a51238d 100644
--- a/src-ui/src/app/components/document-list/filter-editor/filter-editor.component.html
+++ b/src-ui/src/app/components/document-list/filter-editor/filter-editor.component.html
@@ -41,11 +41,11 @@
-
diff --git a/src-ui/src/app/components/document-list/filter-editor/filter-editor.component.ts b/src-ui/src/app/components/document-list/filter-editor/filter-editor.component.ts
index e6565beac..febb9dd84 100644
--- a/src-ui/src/app/components/document-list/filter-editor/filter-editor.component.ts
+++ b/src-ui/src/app/components/document-list/filter-editor/filter-editor.component.ts
@@ -40,7 +40,7 @@ export class FilterEditorComponent implements OnInit, OnDestroy {
case FILTER_HAS_TAG:
return $localize`Tag: ${this.tags.find(t => t.id == +rule.value)?.name}`
-
+
case FILTER_HAS_ANY_TAG:
if (rule.value == "false") {
return $localize`Without any tag`
@@ -127,7 +127,7 @@ export class FilterEditorComponent implements OnInit, OnDestroy {
} else {
this.tagSelectionModel.getSelectedItems().filter(tag => tag.id).forEach(tag => {
filterRules.push({rule_type: FILTER_HAS_TAG, value: tag.id?.toString()})
- })
+ })
}
this.correspondentSelectionModel.getSelectedItems().forEach(correspondent => {
filterRules.push({rule_type: FILTER_CORRESPONDENT, value: correspondent.id?.toString()})
@@ -153,16 +153,16 @@ export class FilterEditorComponent implements OnInit, OnDestroy {
@Output()
filterRulesChange = new EventEmitter()
+ @Output()
+ reset = new EventEmitter()
+
+ @Input()
+ rulesModified: boolean = false
+
updateRules() {
this.filterRulesChange.next(this.filterRules)
}
- hasFilters() {
- return this._titleFilter ||
- this.dateAddedAfter || this.dateAddedBefore || this.dateCreatedAfter || this.dateCreatedBefore ||
- this.tagSelectionModel.selectionSize() || this.correspondentSelectionModel.selectionSize() || this.documentTypeSelectionModel.selectionSize()
- }
-
get titleFilter() {
return this._titleFilter
}
@@ -194,16 +194,8 @@ export class FilterEditorComponent implements OnInit, OnDestroy {
this.titleFilterDebounce.complete()
}
- clearSelected() {
- this._titleFilter = ""
- this.tagSelectionModel.clear(false)
- this.documentTypeSelectionModel.clear(false)
- this.correspondentSelectionModel.clear(false)
- this.dateAddedBefore = null
- this.dateAddedAfter = null
- this.dateCreatedBefore = null
- this.dateCreatedAfter = null
- this.updateRules()
+ resetSelected() {
+ this.reset.next()
}
toggleTag(tagId: number) {