Skip to content

MrmDataTableComponent

reference
2 min readUpdated

Kind: Class

Source: Pams/Web/Pams.Web/Client/app/components/mrm/mrm-booking/mrm-data-table/mrm-data-table.component.ts (line 45)

Part of: Pams

MrmDataTableComponent manages data displayed in the MRM booking data table. It retrieves dashboard data, initializes table state, calculates performance values, formats month and price output, handles resize events, and stores cached data during its Angular lifecycle.

Implements: OnInit, OnChanges, OnDestroy

Methods

MethodSignatureReturns
ngOnInitngOnInit()void
ngOnChangesngOnChanges()void
ngOnDestroyngOnDestroy()void
getDashboardDatagetDashboardData()void
initalizingDatainitalizingData(value: BranchData[])void
calculatePerformancePercalculatePerformancePer(month: MonthData)number
translateMonthNametranslateMonthName(month: MonthData)string
getpriceFormattedgetpriceFormatted(x: undefined)string
onResizeonResize()void
setChachingsetChaching()void
getChachinggetChaching()void
onValueChangedonValueChanged(e: undefined)void
onChartInitonChartInit(e: any, index: number)void
switchChartTypeHandlerswitchChartTypeHandler()void
switchBasedOnTendencyHandlerswitchBasedOnTendencyHandler()void
setValuesetValue(value: number)void
setForecastValuesetForecastValue(value: number)void
setMarginAvaragesetMarginAvarage(value: number)void
isForecastisForecast(month: MonthData)boolean
isAchievedOrCurrentisAchievedOrCurrent(month: MonthData)boolean
getpriceForecastAmountgetpriceForecastAmount(month: MonthData)number
expectedCurrencyChangeexpectedCurrencyChange(e: undefined)void

Properties

PropertyType
triangleNeedleDxCircularGaugeComponent
_widgetWidget
_widgetTypestring
withoutOptionBarboolean
bookingOrSalesnumber
withNominalboolean
selectedTeamnumber
forecastRuleIdnumber
forecastRulesany[]
selectedYearnumber
numYearsDatasourceany[]
todayWidgetsEnumany
cachingWidgetDataCachingWidgetData
dataBranchData[]
originalDataBranchData[]
singleMonthsMonthData
branchCurrencyany
basedOnTendencyboolean
subscriptionSubscription
SeriseRangeany[]
echartsIntanceany
totalBookingMonthsTotalBookingMonths[]
tempTotalMonthTotalBookingMonths
totalTargetsnumber
yearBookingnumber
totalForecastsnumber
tempTotalTargetTotalTargets

Where it refuses work

  • MrmDataTableComponent stops the work with an early return when month.Month == 12.
  • MrmDataTableComponent stops the work with an early return when month.Month >= new Date().getMonth() + 1.
  • MrmDataTableComponent stops the work with an early return when month.Month <= new Date().getMonth() + 1.

Diagram

mermaid
graph LR
    Angular[Angular lifecycle] --> Init[ngOnInit]
    Angular --> Changes[ngOnChanges]
    Angular --> Destroy[ngOnDestroy]

    Init --> Dashboard[getDashboardData]
    Dashboard --> Initialize[initalizingData]
    Initialize --> Performance[calculatePerformancePer]
    Initialize --> Month[translateMonthName]
    Initialize --> Price[getpriceFormatted]

    Resize[onResize] --> Initialize
    Initialize --> Cache[setChaching]

Usage

ts
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { MrmDataTableComponent } from './mrm-data-table.component';

describe('MrmDataTableComponent', () => {
  let fixture: ComponentFixture<MrmDataTableComponent>;
  let component: MrmDataTableComponent;

  beforeEach(async () => {
    await TestBed.configureTestingModule({
      declarations: [MrmDataTableComponent],
    }).compileComponents();

    fixture = TestBed.createComponent(MrmDataTableComponent);
    component = fixture.componentInstance;
    fixture.detectChanges();
  });

  it('loads and formats dashboard table data', () => {
    component.getDashboardData();

    const performance = component.calculatePerformancePer();
    const monthName = component.translateMonthName();
    const formattedPrice = component.getpriceFormatted();

    expect(performance).toBeDefined();
    expect(monthName).toBeDefined();
    expect(formattedPrice).toBeDefined();
  });
});

AI Coding Instructions

  • Keep data loading and state preparation coordinated through getDashboardData() and initalizingData().
  • Preserve the existing initalizingData method name when calling or refactoring it, even though its spelling differs from initializing.
  • Recalculate display values through calculatePerformancePer(), translateMonthName(), and getpriceFormatted() rather than duplicating formatting logic in templates.
  • Handle viewport-dependent table updates through onResize() and clean up subscriptions or listeners in ngOnDestroy().
  • Review cache behavior in setChaching() when changing dashboard data sources or table refresh flows.

Used by

1 reference from 1 file. Each is a place in this repository where the symbol is actually used — go read one rather than trusting an example.

Imported by (1)

  • TranslateHandlerPams/Web/Pams.Web/Client/app/app.module.ts:1

Was this page helpful?

Download as PDF