Cleanup dropdown button component

This commit is contained in:
Michael Shamoon 2020-12-19 21:56:31 -08:00
parent 6381093386
commit de6ba3489a
2 changed files with 6 additions and 12 deletions

View File

@ -5,8 +5,8 @@
</svg>
</div>
<div class="mr-1">
<app-tag *ngIf="isTag; else displayName" [tag]="item" [clickable]="true" linkTitle="Filter by tag"></app-tag>
<ng-template #displayName><small>{{item.name}}</small></ng-template>
<app-tag *ngIf="isTag; else displayName" [tag]="toggleableItem?.item" [clickable]="true" linkTitle="Filter by tag"></app-tag>
<ng-template #displayName><small>{{toggleableItem?.item.name}}</small></ng-template>
</div>
<div class="badge badge-light rounded-pill ml-auto mr-1">{{item.document_count}}</div>
<div class="badge badge-light rounded-pill ml-auto mr-1">{{toggleableItem?.item.document_count}}</div>
</button>

View File

@ -9,22 +9,16 @@ import { ToggleableItem, ToggleableItemState } from '../filterable-dropdown.comp
templateUrl: './filterable-dropdown-button.component.html',
styleUrls: ['./filterable-dropdown-button.component.scss']
})
export class FilterableDropdownButtonComponent implements OnInit {
export class FilterableDropdownButtonComponent {
@Input()
toggleableItem: ToggleableItem
get item(): PaperlessTag | PaperlessDocumentType | PaperlessCorrespondent {
return this.toggleableItem?.item
}
@Output()
toggle = new EventEmitter()
isTag: boolean
ngOnInit() {
this.isTag = 'is_inbox_tag' in this.item // ~ this.item instanceof PaperlessTag
get isTag(): boolean {
return 'is_inbox_tag' in this.toggleableItem?.item // ~ this.item instanceof PaperlessTag
}
toggleItem(): void {