mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-07-28 18:24:38 -05:00
some refactoring.
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
<div class="text-muted mt-1">Filter by:</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<input class="form-control form-control-sm" type="text" [(ngModel)]="filterText" placeholder="Title">
|
||||
<input class="form-control form-control-sm" type="text" [(ngModel)]="titleFilter" placeholder="Title">
|
||||
</div>
|
||||
|
||||
<app-filter-dropdown class="col-auto" [(items)]="filterEditorService.tags" [itemsSelected]="filterEditorService.selectedTags" [title]="'Tags'" (toggle)="onToggleTag($event)"></app-filter-dropdown>
|
||||
|
@@ -25,29 +25,31 @@ export class FilterEditorComponent implements OnInit, OnDestroy {
|
||||
@Output()
|
||||
apply = new EventEmitter()
|
||||
|
||||
get filterText() {
|
||||
return this.filterEditorService.filterText
|
||||
get titleFilter() {
|
||||
return this.filterEditorService.titleFilter
|
||||
}
|
||||
|
||||
set filterText(value) {
|
||||
this.filterTextDebounce.next(value)
|
||||
set titleFilter(value) {
|
||||
this.titleFilterDebounce.next(value)
|
||||
}
|
||||
|
||||
filterTextDebounce: Subject<string>
|
||||
titleFilterDebounce: Subject<string>
|
||||
subscription: Subscription
|
||||
|
||||
ngOnInit() {
|
||||
this.filterTextDebounce = new Subject<string>()
|
||||
this.subscription = this.filterTextDebounce.pipe(
|
||||
this.titleFilterDebounce = new Subject<string>()
|
||||
this.subscription = this.titleFilterDebounce.pipe(
|
||||
debounceTime(400),
|
||||
distinctUntilChanged()
|
||||
).subscribe(title => {
|
||||
this.filterEditorService.filterText = title
|
||||
this.filterEditorService.titleFilter = title
|
||||
this.applyFilters()
|
||||
})
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.titleFilterDebounce.complete()
|
||||
// TODO: not sure if both is necessary
|
||||
this.subscription.unsubscribe()
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user