Kavita/src/app/shared/card-item/card-item.component.ts
Joseph Milazzo ca46d137c4 Finished the skeleton code for navigating Kavita.
All UIs need to be reworked and major code cleanup.
2021-01-01 11:58:18 -06:00

44 lines
1.1 KiB
TypeScript

import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
export interface CardItemAction {
title: string;
callback: (data: any) => void;
}
@Component({
selector: 'app-card-item',
templateUrl: './card-item.component.html',
styleUrls: ['./card-item.component.scss']
})
export class CardItemComponent implements OnInit {
@Input() imageUrl = '';
@Input() title = '';
@Input() actions: CardItemAction[] = []; // TODO: Create a factory that generates actions based on if admin, etc. for each card type.
@Input() entity: any; // This is the entity we are representing. It will be returned if an action is executed.
@Output() clicked = new EventEmitter<string>();
placeholderImage = 'assets/images/image-placeholder.jpg';
constructor() { }
ngOnInit(): void {
}
handleClick() {
this.clicked.emit(this.title);
}
isNullOrEmpty(val: string) {
return val === null || val === undefined || val === '';
}
performAction(event: any, action: CardItemAction) {
event.stopPropagation();
if (typeof action.callback === 'function') {
action.callback(this.entity);
}
}
}