import { Pipe , PipeTransform } from '@angular/core' ; import { GtConfigField } from '../interfaces/gt-config-field' ; @ Pipe ( { name : 'gtRowClass' } ) export class GtRowClassPipe implements PipeTransform { transform ( array , gtFields ) { if ( array ) { const COLUMNS_WITH_CLASS = gtFields . map ( column => column ) . filter ( column => column . rowClass ) ; COLUMNS_WITH_CLASS . map ( column => { array . map ( row => { if ( typeof column . rowClass === 'function' ) { try { if ( row . $$gtRowClass ) { row . $$gtRowClass = row . $$gtRowClass . concat ( ' ' + column . rowClass ( row , column ) ) ; } else { row . $$gtRowClass = column . rowClass ( row , column ) ; } } catch ( error ) { console . log ( 'Error when trying to get row class name using formula.' , error ) ; } } else { if ( row . $$gtRowClass ) { row . $$gtRowClass = row . $$gtRowClass . concat ( ' ' + column . rowClass ) ; } else { row . $$gtRowClass = column . rowClass ; } } } ) ; } ) ; } return array ; } }