import { DecimalPipe } from '@angular/common'; import { Component, Input, OnInit } from '@angular/core'; import { AdHocReportingUI } from '@core/typings/ui/ad-hoc-reporting.typing'; import { AdHocReportingMappingService } from '@features/reporting/services/ad-hoc-reporting-mapping.service'; import { GetNestedPipe } from '@yourcause/common'; @Component({ selector: 'gc-ad-hoc-report-cell', templateUrl: './ad-hoc-report-cell.component.html', styleUrls: ['./ad-hoc-report-cell.component.scss'] }) export class AdHocReportCellComponent implements OnInit { @Input() column: AdHocReportingUI.ColumnImplementation; @Input() row: AdHocReportingUI.ReportResponseRow; private _masked: boolean; @Input() get masked (): boolean { return this._masked; } set masked (value: boolean) { this._masked = value; this.setValue(); } getNested = new GetNestedPipe(); decimal = new DecimalPipe('en-US'); value: any; constructor ( private adHocReportingMapper: AdHocReportingMappingService ) { } ngOnInit () { this.setValue(); } private setValue () { this.value = this.adHocReportingMapper.getValueForColumnFromRow( this.column.definition, this.row, this.masked ); } }