import { Pipe , PipeTransform } from '@angular/core' ; import { GtConfigField } from '../interfaces/gt-config-field' ; import { GtRow } from '../interfaces/gt-row' ; @ Pipe ( { name : 'gtColumnClass' } ) export class GtColumnClassPipe implements PipeTransform { transform ( gtFields , column , row ? ) { const COLUMN_WITH_CLASS = gtFields . map ( field => field ) . filter ( field => field . columnClass && field . objectKey === column . objectKey ) [ 0 ] ; if ( ! COLUMN_WITH_CLASS ) { return ; } else if ( typeof COLUMN_WITH_CLASS . columnClass === 'function' ) { try { return COLUMN_WITH_CLASS . columnClass ( row , column ) ; } catch ( error ) { console . log ( 'Error when trying to get column class name using formula.' , error ) ; } } else { return COLUMN_WITH_CLASS . columnClass ; } } }