Dynamic counts include all pages, hide for "Any"

This commit is contained in:
shamoon
2023-05-05 01:01:57 -07:00
parent ccba2e32e1
commit bd1f9acc62
6 changed files with 31 additions and 10 deletions

View File

@@ -34,7 +34,7 @@
<div *ngIf="selectionModel.items" class="items" #buttonItems>
<ng-container *ngFor="let item of selectionModel.itemsSorted | filter: filterText; let i = index">
<app-toggleable-dropdown-button
*ngIf="allowSelectNone || item.id" [item]="item" [state]="selectionModel.get(item.id)" [count]="getUpdatedDocumentCount(item.id)" (toggle)="selectionModel.toggle(item.id)" (exclude)="excludeClicked(item.id)" (click)="setButtonItemIndex(i)" [disabled]="disabled">
*ngIf="allowSelectNone || item.id" [item]="item" [hideCount]="hideCount(item)" [state]="selectionModel.get(item.id)" [count]="getUpdatedDocumentCount(item.id)" (toggle)="selectionModel.toggle(item.id)" (exclude)="excludeClicked(item.id)" (click)="setButtonItemIndex(i)" [disabled]="disabled">
</app-toggleable-dropdown-button>
</ng-container>
</div>

View File

@@ -12,6 +12,7 @@ import { ToggleableItemState } from './toggleable-dropdown-button/toggleable-dro
import { MatchingModel } from 'src/app/data/matching-model'
import { Subject } from 'rxjs'
import { SelectionDataItem } from 'src/app/services/rest/document.service'
import { ObjectWithPermissions } from 'src/app/data/object-with-permissions'
export interface ChangedItems {
itemsToAdd: MatchingModel[]
@@ -552,4 +553,13 @@ export class FilterableDropdownComponent {
// just track the index in case user uses arrows
this.keyboardIndex = index
}
hideCount(item: ObjectWithPermissions) {
// counts are pointless when clicking item would add to the set of docs
return (
this.selectionModel.logicalOperator === LogicalOperator.Or &&
this.manyToOne &&
this.selectionModel.get(item.id) !== ToggleableItemState.Selected
)
}
}

View File

@@ -20,5 +20,5 @@
<app-tag *ngIf="isTag; else displayName" [tag]="item" [clickable]="false"></app-tag>
<ng-template #displayName><small>{{item.name}}</small></ng-template>
</div>
<div class="badge bg-light text-dark rounded-pill ms-auto me-1">{{count ?? item.document_count}}</div>
<div *ngIf="!hideCount" class="badge bg-light text-dark rounded-pill ms-auto me-1">{{count ?? item.document_count}}</div>
</button>

View File

@@ -26,6 +26,9 @@ export class ToggleableDropdownButtonComponent {
@Input()
disabled: boolean = false
@Input()
hideCount: boolean = false
@Output()
toggle = new EventEmitter()