mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-12-15 02:57:09 +01:00
some refactoring.
This commit is contained in:
parent
98ab79ad5a
commit
02c1d496d6
3 changed files with 24 additions and 31 deletions
|
|
@ -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()
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue