Adds quick filters from document detail

This commit is contained in:
shamoon
2023-05-27 23:16:33 -07:00
parent 5a52957aa9
commit 42a45075db
13 changed files with 2647 additions and 51 deletions

View File

@@ -1,6 +1,6 @@
<div class="mb-3 paperless-input-select" [class.disabled]="disabled">
<label *ngIf="title" class="form-label" [for]="inputId">{{title}}</label>
<div [class.input-group]="allowCreateNew">
<div [class.input-group]="allowCreateNew || showFilter">
<ng-select name="inputId" [(ngModel)]="value"
[disabled]="disabled"
[style.color]="textColor"
@@ -26,6 +26,11 @@
<use xlink:href="assets/bootstrap-icons.svg#plus" />
</svg>
</button>
<button *ngIf="showFilter" class="btn btn-outline-secondary" type="button" (click)="onFilterDocuments()" [disabled]="isPrivate || this.value === null" i18n-title title="Filter documents with this {{title}}">
<svg class="buttonicon" fill="currentColor">
<use xlink:href="assets/bootstrap-icons.svg#filter" />
</svg>
</button>
</div>
<small *ngIf="hint" class="form-text text-muted">{{hint}}</small>
<small *ngIf="getSuggestions().length > 0">

View File

@@ -85,9 +85,15 @@ export class SelectComponent extends AbstractInputComponent<number> {
@Input()
bindLabel: string = 'name'
@Input()
showFilter: boolean = false
@Output()
createNew = new EventEmitter<string>()
@Output()
filterDocuments = new EventEmitter<any[]>()
public addItemRef: (name) => void
private _lastSearchTerm: string
@@ -134,4 +140,8 @@ export class SelectComponent extends AbstractInputComponent<number> {
this.clearLastSearchTerm()
}, 3000)
}
onFilterDocuments() {
this.filterDocuments.emit([this.items.find((i) => i.id === this.value)])
}
}