#186 allow filtering for documents with no correspondents / tags / types

This commit is contained in:
jonaswinkler
2020-12-28 17:04:53 +01:00
parent e62a86ded5
commit afc95d2de6
4 changed files with 36 additions and 11 deletions

View File

@@ -21,7 +21,7 @@
</div>
<div *ngIf="selectionModel.items" class="items">
<ng-container *ngFor="let item of selectionModel.items | filter: filterText">
<app-toggleable-dropdown-button [item]="item" [state]="selectionModel.get(item.id)" (toggle)="selectionModel.toggle(item.id)"></app-toggleable-dropdown-button>
<app-toggleable-dropdown-button *ngIf="allowSelectNone || item.id" [item]="item" [state]="selectionModel.get(item.id)" (toggle)="selectionModel.toggle(item.id)"></app-toggleable-dropdown-button>
</ng-container>
</div>
<button *ngIf="editing" class="list-group-item list-group-item-action bg-light" (click)="applyClicked()" [disabled]="!selectionModel.isDirty()">

View File

@@ -53,6 +53,16 @@ export class FilterableDropdownSelectionModel {
}
}
if (!id) {
for (let key of this.temporarySelectionStates.keys()) {
if (key) {
this.temporarySelectionStates.delete(key)
}
}
} else {
this.temporarySelectionStates.delete(null)
}
if (fireEvent) {
this.changed.next(this)
}
@@ -84,6 +94,10 @@ export class FilterableDropdownSelectionModel {
}
}
isNoneSelected() {
return this.selectionSize() == 1 && this.get(null) == ToggleableItemState.Selected
}
init(map) {
this.temporarySelectionStates = map
this.apply()
@@ -126,7 +140,11 @@ export class FilterableDropdownComponent {
@Input()
set items(items: MatchingModel[]) {
if (items) {
this._selectionModel.items = items
this._selectionModel.items = Array.from(items)
this._selectionModel.items.unshift({
name: "None",
id: null
})
}
}
@@ -171,6 +189,9 @@ export class FilterableDropdownComponent {
@Input()
icon: string
@Input()
allowSelectNone: boolean = false
@Input()
editing = false