Newer
Older
import { Component, Input, ChangeDetectionStrategy, Output, EventEmitter } from '@angular/core';
import { Attribute } from 'src/app/metamodel/model';
interface ModalData {
isOpen: boolean;
type: string;
data: object;
}
@Component({
selector: 'app-datatable',
templateUrl: 'datatable.component.html',
changeDetection: ChangeDetectionStrategy.OnPush
})
export class DatatableComponent {
@Input() searchMeta: SearchMeta;
@Input() searchData: any[];
@Output() initSearchMeta: EventEmitter<{}> = new EventEmitter();
@Output() getSearchData: EventEmitter<number> = new EventEmitter();
this.initSearchMeta.emit();
this.getSearchData.emit(1);
}
getAttributeRenderer(attributeName: string): string {
const attribute = this.datasetAttributeList.find(a => a.name === attributeName);
return attribute.renderer;
}
getAttributeUriAction(attributeName: string, datum: string): string {
const attribute = this.datasetAttributeList.find(a => a.name === attributeName);
openModal(type: string, attributeName: string, value: string) {
this.modalData.type = type;
if (type === 'thumbnail') {
this.modalData.data = {
title: value,
srcImage: this.getAttributeUriAction(attributeName, value)
};
} else if (type === 'fancybox') {
this.modalData.data = {
title: value,
closeModal(event: null) {
this.modalData.isOpen = false;
this.modalData.type = null;
this.modalData.data = null;