Skip to content

MrmWarehouseScrapComponent

reference
2 min readUpdated

Kind: Class

Source: Pams/Web/Pams.Web/Client/app/components/dashboard/dashboard-libary/widgets/mrm-warehouse-scrap/mrm-warehouse-scrap.component.ts (line 90)

Part of: Pams

MrmWarehouseScrapComponent is an Angular dashboard widget for loading, preparing, and displaying warehouse scrap data. It checks authorization, responds to lifecycle changes, calculates monthly totals, formats month and price values, and saves dashboard state.

Methods

MethodSignatureReturns
GetAuthorizationAccessGetAuthorizationAccess(url: string)void
ngOnInitngOnInit()void
ngOnChangesngOnChanges()void
ngOnDestroyngOnDestroy()void
getDashboardDatagetDashboardData()void
initalizingDatainitalizingData(value: BranchData[])void
saveDashboardDatasaveDashboardData()void
calculateSumByMonthcalculateSumByMonth(monthIndex: number)void
translateMonthNametranslateMonthName(month: MonthData)string
getpriceFormattedgetpriceFormatted(x: undefined)string
onResizeonResize()void
setChachingsetChaching()void
getChachinggetChaching()void
switchChartTypeHandlerswitchChartTypeHandler()void
switchBasedOnTendencyHandlerswitchBasedOnTendencyHandler()void
comparingWithPrevMonthcomparingWithPrevMonth(month: MonthData, bIndex: number, index: number, propertyName: string)string
comparingBookingWithPrevSummcomparingBookingWithPrevSumm(month: MonthsSum, index: number, propertyName: string)string
isCurrentMonthisCurrentMonth(month: MonthData)boolean
getpriceForecastAmountgetpriceForecastAmount(month: MonthData)number
expectedCurrencyChangeexpectedCurrencyChange(e: undefined)void
selectTextselectText(e: undefined)void
editSelectedMonthPrepareeditSelectedMonthPrepare(month: MonthData, supplierId: number)void
copyValueFromPrevMonthcopyValueFromPrevMonth(month: MonthData, monthIndex: number)void
sortingsorting(propertyName: string, propertyType: string, monthIndex: number)void
openPopupopenPopup(n: string, t: string, i: string, btnTxt: string)void
savePopupsavePopup()void
ClosewithDonotSaveClosewithDonotSave()void
OnOpenedPopupOnOpenedPopup()void
closePopupclosePopup()void

Properties

PropertyType
sharedPopupSharedPopupComponent
_widgetWidget
_widgetTypestring
withoutOptionBarboolean
editModeboolean
bookingOrSalesnumber
withNominalboolean
selectedTeamnumber
forecastRuleIdnumber
allowedtoEditboolean
allowedtoEnableEdtingboolean
widgetEditRequestany
widgetEditEndany
forecastRulesany[]
selectedYearnumber
numYearsDatasourceany[]
todayWidgetsEnumany
cachingWidgetDataCachingWidgetData
dataBranchData[]
originalDataBranchData[]
selectedDataBranchData[]
branchCurrencyany
basedOnTendencyboolean
subscriptionSubscription
SeriseRangeany[]
echartsIntanceany
totalBookingMonthsMonthsSum[]
tempMonthSumMonthsSum
totalTargetsnumber
yearBookingnumber
totalForecastsnumber
tempTotalTargetTotalTargets
popupany
searchTextstring
isModeOfInsertFromPrevMonthActiveboolean
sortingDirectionnumber

Where it refuses work

  • MrmWarehouseScrapComponent stops the work with an early return when a[propertyName] < b[propertyName], in 2 places.
  • MrmWarehouseScrapComponent stops the work with an early return when a[propertyName] > b[propertyName], in 2 places.
  • MrmWarehouseScrapComponent stops the work with an early return when month.MonthId == 12.
  • MrmWarehouseScrapComponent stops the work with an early return when month[propertyName] < this.data[bIndex].MRMScrap[index - 1][propertyName].
  • MrmWarehouseScrapComponent stops the work with an early return when month[propertyName] < this.totalBookingMonths[index - 1][propertyName].
  • MrmWarehouseScrapComponent stops the work with an early return when this.allowedtoEnableEdting.

Diagram

mermaid
graph LR
  Init[ngOnInit] --> Auth[GetAuthorizationAccess]
  Auth --> Load[getDashboardData]
  Load --> Initialize[initalizingData]
  Initialize --> Sum[calculateSumByMonth]
  Sum --> Month[translateMonthName]
  Sum --> Price[getpriceFormatted]
  Changes[ngOnChanges] --> Load
  Initialize --> Save[saveDashboardData]
  Destroy[ngOnDestroy] --> Cleanup[Release subscriptions or state]

Usage

ts
import { ComponentRef } from '@angular/core';
import { MrmWarehouseScrapComponent } from './mrm-warehouse-scrap.component';

function refreshWarehouseScrapWidget(
  componentRef: ComponentRef<MrmWarehouseScrapComponent>
): void {
  const widget = componentRef.instance;

  // Angular runs ngOnInit during initial change detection.
  componentRef.changeDetectorRef.detectChanges();

  // Reload data after an external dashboard filter or refresh action.
  widget.getDashboardData();

  const monthLabel = widget.translateMonthName();
  const formattedPrice = widget.getpriceFormatted();

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

AI Coding Instructions

  • Let Angular invoke ngOnInit, ngOnChanges, and ngOnDestroy; do not call lifecycle hooks from application code.
  • Call GetAuthorizationAccess() before exposing or loading dashboard scrap data.
  • Keep data preparation in initalizingData() and monthly aggregation in calculateSumByMonth() rather than duplicating calculations in templates.
  • Preserve the existing initalizingData method spelling when calling or modifying it.
  • Use saveDashboardData() for dashboard-state persistence and getDashboardData() when widget data must be refreshed.

Used by

3 references from 3 files. Each is a place in this repository where the symbol is actually used — go read one rather than trusting an example.

Imported by (3)

  • TranslateHandlerPams/Web/Pams.Web/Client/app/app.module.ts:1
  • DashboardTabComponentPams/Web/Pams.Web/Client/app/components/dashboard/dashboard-libary/dashboard-tab/dashboard-tab.component.ts:1
  • ReportsTabComponentPams/Web/Pams.Web/Client/app/components/dashboard/reports-library/reports-tab/reports-tab.component.ts:1

Was this page helpful?

Download as PDF