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> </svg>
</div> </div>
<div class="mr-1"> <div class="mr-1">
<app-tag *ngIf="isTag; else displayName" [tag]="item" [clickable]="true" linkTitle="Filter by tag"></app-tag> <app-tag *ngIf="isTag; else displayName" [tag]="toggleableItem?.item" [clickable]="true" linkTitle="Filter by tag"></app-tag>
<ng-template #displayName><small>{{item.name}}</small></ng-template> <ng-template #displayName><small>{{toggleableItem?.item.name}}</small></ng-template>
</div> </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> </button>

View File

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