Skip to content

MrmPmShipmentComponent

reference
2 min readUpdated

Kind: Class

Source: Frontend/src/app/components/dashboard/dashboard-libary/widgets/mrm-pm-shipment/mrm-pm-shipment.component.ts (line 43)

Part of: Frontend

MrmPmShipmentComponent is an Angular dashboard widget for presenting MRM PM shipment data. It checks feature subscription access, loads and initializes dashboard data, calculates performance percentages, formats display values, handles resize events, and manages cached state.

Extends: BaseWidgetComponent

Methods

MethodSignatureReturns
checkFeatureSubscriptioncheckFeatureSubscription()boolean
ngOnInitngOnInit()void
ngOnChangesngOnChanges()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
comparingWithPrevMonthcomparingWithPrevMonth(month: MonthData, bIndex: number, index: number)string
comparingBookingWithPrevSummcomparingBookingWithPrevSumm(month: TotalBookingMonths, index: number)string
comparingForecastWithPrevSummcomparingForecastWithPrevSumm(month: TotalBookingMonths, index: number)string
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
_widgetWidget
_widgetTypestring
yearIdnumber
periodIdnumber
countOfEditablePrevMonthsnumber
withoutOptionBarboolean
bookingOrSalesnumber
withNominalboolean
selectedTeamnumber
forecastRuleIdnumber
allowedtoEditboolean
allowedtoEnableEdtingboolean
forecastRulesany[]
selectedYearnumber
numYearsDatasourceany[]
todayWidgetsEnumany
cachingWidgetDataCachingWidgetData
dataBranchData[]
originalDataBranchData[]
singleMonthsMonthData
branchCurrencyany
basedOnTendencyboolean
SeriseRangeany[]
echartsIntanceany
totalBookingMonthsTotalBookingMonths[]
tempTotalMonthTotalBookingMonths
totalTargetsnumber
yearBookingnumber
totalForecastsnumber
tempTotalTargetTotalTargets
pastDiffnumber
urrenFeaturenumber

Where it refuses work

  • MrmPmShipmentComponent stops the work with an early return when this.dashboardLibraryService.checkFeatureSubscription(this.widget.chartEnumId).
  • MrmPmShipmentComponent stops the work with an early return when month.MonthId == 12.
  • MrmPmShipmentComponent stops the work with an early return when month.TotalValue < this.data[bIndex].MrmBooking[index - 1].TotalValue.
  • MrmPmShipmentComponent stops the work with an early return when month.TotalBookingMonth < this.totalBookingMonths[index - 1].TotalBookingMonth.
  • MrmPmShipmentComponent stops the work with an early return when month.TotalForecastMonth < this.totalBookingMonths[index - 1].TotalForecastMonth.
  • MrmPmShipmentComponent stops the work with an early return when month.MonthId >= new Date().getMonth() + 1.

Diagram

mermaid
graph LR
    Dashboard[Dashboard Container] --> Component[MrmPmShipmentComponent]
    Component --> Subscription[checkFeatureSubscription]
    Component --> Lifecycle[ngOnInit / ngOnChanges]
    Lifecycle --> Data[getDashboardData]
    Data --> Initialize[initalizingData]
    Initialize --> Performance[calculatePerformancePer]
    Initialize --> Formatting[translateMonthName / getpriceFormatted]
    Component --> Resize[onResize]
    Component --> Cache[setChaching]

Usage

ts
import { Component, ViewChild } from '@angular/core';
import { MrmPmShipmentComponent } from './mrm-pm-shipment.component';

@Component({
  selector: 'app-dashboard-page',
  template: `
    <!-- Render the shipment widget through its existing dashboard template. -->
  `,
})
export class DashboardPageComponent {
  @ViewChild(MrmPmShipmentComponent)
  shipmentWidget?: MrmPmShipmentComponent;

  refreshShipmentData(): void {
    const widget = this.shipmentWidget;

    if (!widget?.checkFeatureSubscription()) {
      return;
    }

    widget.getDashboardData();

    const performancePercentage = widget.calculatePerformancePer();
    const formattedPrice = widget.getpriceFormatted();

    console.log({ performancePercentage, formattedPrice });
  }
}

AI Coding Instructions

  • Keep data loading behind checkFeatureSubscription() so shipment data is not requested when the feature is unavailable.
  • Let Angular invoke ngOnInit() and ngOnChanges(); call getDashboardData() only for explicit refresh behavior.
  • Update initialization logic through initalizingData() after changing shipment-data inputs or response mapping.
  • Preserve formatting through translateMonthName() and getpriceFormatted() instead of formatting month or price values in templates.
  • Review setChaching() when changing dashboard refresh behavior so cached shipment data remains consistent.

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)

  • DashboardWidgetsModuleFrontend/src/app/components/dashboard/dashboard-widgets.module.ts:1

Was this page helpful?

Download as PDF