Dropdown components now accept lists not observables

This commit is contained in:
Michael Shamoon 2020-12-13 10:24:20 -08:00
parent 7712230300
commit 6f684f8070
4 changed files with 8 additions and 13 deletions

View File

@ -3,7 +3,7 @@
<div class="dropdown-menu quick-filter shadow" ngbDropdownMenu attr.aria-labelledby="dropdown{{title}}">
<div class="list-group list-group-flush">
<input class="list-group-item form-control form-control-sm" type="text" [(ngModel)]="filterText" placeholder="Filter {{title}}" (keyup.enter)="listFilterEnter()" #listFilterTextInput>
<ng-container *ngIf="(items$ | async)?.results as items">
<ng-container *ngIf="items">
<ng-container *ngFor="let item of items | filter: filterText; let i = index">
<app-filter-dropdown-button [item]="item" [selected]="isItemSelected(item)" (toggle)="toggleItem($event)"></app-filter-dropdown-button>
</ng-container>

View File

@ -14,7 +14,7 @@ export class FilterDropdownComponent implements OnInit {
constructor(private filterPipe: FilterPipe) { }
@Input()
items$: Observable<Results<ObjectWithId>>
items: ObjectWithId[]
@Input()
itemsSelected: ObjectWithId[]
@ -31,11 +31,6 @@ export class FilterDropdownComponent implements OnInit {
@ViewChild('listFilterTextInput') listFilterTextInput: ElementRef
filterText: string
items: ObjectWithId[]
ngOnInit() {
this.items$.subscribe(result => this.items = result.results)
}
toggleItem(item: ObjectWithId): void {
this.toggle.emit(item)

View File

@ -6,9 +6,9 @@
<input class="form-control form-control-sm" type="text" [(ngModel)]="filterEditorService.filterText" placeholder="Title" #filterTextInput>
</div>
<app-filter-dropdown class="col-auto" [(items$)]="filterEditorService.tags$" [itemsSelected]="filterEditorService.selectedTags" [title]="'Tags'" [display]="'tag'" (toggle)="onToggleTag($event)"></app-filter-dropdown>
<app-filter-dropdown class="col-auto" [(items$)]="filterEditorService.correspondents$" [itemsSelected]="filterEditorService.selectedCorrespondents" [title]="'Correspondents'" (toggle)="onToggleCorrespondent($event)"></app-filter-dropdown>
<app-filter-dropdown class="col-auto" [(items$)]="filterEditorService.documentTypes$" [itemsSelected]="filterEditorService.selectedDocumentTypes" [title]="'Document Types'" (toggle)="onToggleDocumentType($event)"></app-filter-dropdown>
<app-filter-dropdown class="col-auto" [(items)]="filterEditorService.tags" [itemsSelected]="filterEditorService.selectedTags" [title]="'Tags'" [display]="'tag'" (toggle)="onToggleTag($event)"></app-filter-dropdown>
<app-filter-dropdown class="col-auto" [(items)]="filterEditorService.correspondents" [itemsSelected]="filterEditorService.selectedCorrespondents" [title]="'Correspondents'" (toggle)="onToggleCorrespondent($event)"></app-filter-dropdown>
<app-filter-dropdown class="col-auto" [(items)]="filterEditorService.documentTypes" [itemsSelected]="filterEditorService.selectedDocumentTypes" [title]="'Document Types'" (toggle)="onToggleDocumentType($event)"></app-filter-dropdown>
<app-filter-dropdown-date class="col-auto" [dateBefore]="filterEditorService.dateCreatedBefore" [dateAfter]="filterEditorService.dateCreatedAfter" [title]="'Created'" (dateBeforeSet)="onDateCreatedBeforeSet($event)" (dateAfterSet)="onDateCreatedAfterSet($event)"></app-filter-dropdown-date>
<app-filter-dropdown-date class="col-auto" [dateBefore]="filterEditorService.dateAddedBefore" [dateAfter]="filterEditorService.dateAddedAfter" [title]="'Added'" (dateBeforeSet)="onDateAddedBeforeSet($event)" (dateAfterSet)="onDateAddedAfterSet($event)"></app-filter-dropdown-date>

View File

@ -16,9 +16,9 @@ import { NgbDate, NgbDateStruct } from '@ng-bootstrap/ng-bootstrap';
providedIn: 'root'
})
export class FilterEditorViewService {
tags$: Observable<Results<PaperlessTag>>
correspondents$: Observable<Results<PaperlessCorrespondent>>
documentTypes$: Observable<Results<PaperlessDocumentType>>
private tags$: Observable<Results<PaperlessTag>>
private correspondents$: Observable<Results<PaperlessCorrespondent>>
private documentTypes$: Observable<Results<PaperlessDocumentType>>
tags: PaperlessTag[] = []
correspondents: PaperlessCorrespondent[]