diff --git a/packages/common/src/grouping-formatters/avgTotalsDollarFormatter.ts b/packages/common/src/grouping-formatters/avgTotalsDollarFormatter.ts index f12017df3..17cea0145 100644 --- a/packages/common/src/grouping-formatters/avgTotalsDollarFormatter.ts +++ b/packages/common/src/grouping-formatters/avgTotalsDollarFormatter.ts @@ -1,13 +1,13 @@ -import { Column, GroupTotalsFormatter } from './../interfaces/index'; +import { Column, GroupTotalsFormatter, SlickGrid } from './../interfaces/index'; import { formatNumber } from './../services/utilities'; import { getValueFromParamsOrFormatterOptions } from '../formatters/formatterUtilities'; -export const avgTotalsDollarFormatter: GroupTotalsFormatter = (totals: any, columnDef: Column, grid?: any) => { - const field = columnDef.field || ''; - const val = totals.avg && totals.avg[field]; - const params = columnDef && columnDef.params; - const prefix = params && params.groupFormatterPrefix || ''; - const suffix = params && params.groupFormatterSuffix || ''; +export const avgTotalsDollarFormatter: GroupTotalsFormatter = (totals: any, columnDef: Column, grid: SlickGrid) => { + const field = columnDef.field ?? ''; + const val = totals.avg?.[field]; + const params = columnDef?.params; + const prefix = params?.groupFormatterPrefix || ''; + const suffix = params?.groupFormatterSuffix || ''; const minDecimal = getValueFromParamsOrFormatterOptions('minDecimal', columnDef, grid, 2); const maxDecimal = getValueFromParamsOrFormatterOptions('maxDecimal', columnDef, grid, 4); const decimalSeparator = getValueFromParamsOrFormatterOptions('decimalSeparator', columnDef, grid, '.'); diff --git a/packages/common/src/grouping-formatters/avgTotalsFormatter.ts b/packages/common/src/grouping-formatters/avgTotalsFormatter.ts index 85b88a723..0b3e4e54d 100644 --- a/packages/common/src/grouping-formatters/avgTotalsFormatter.ts +++ b/packages/common/src/grouping-formatters/avgTotalsFormatter.ts @@ -1,13 +1,13 @@ -import { Column, GroupTotalsFormatter } from './../interfaces/index'; +import { Column, GroupTotalsFormatter, SlickGrid } from './../interfaces/index'; import { decimalFormatted, thousandSeparatorFormatted } from '../services/utilities'; import { getValueFromParamsOrFormatterOptions } from '../formatters/formatterUtilities'; -export const avgTotalsFormatter: GroupTotalsFormatter = (totals: any, columnDef: Column, grid?: any) => { - const field = columnDef.field || ''; - let val = totals.avg && totals.avg[field]; - const params = columnDef && columnDef.params; - let prefix = params && params.groupFormatterPrefix || ''; - const suffix = params && params.groupFormatterSuffix || ''; +export const avgTotalsFormatter: GroupTotalsFormatter = (totals: any, columnDef: Column, grid: SlickGrid) => { + const field = columnDef.field ?? ''; + let val = totals.avg?.[field]; + const params = columnDef?.params; + let prefix = params?.groupFormatterPrefix || ''; + const suffix = params?.groupFormatterSuffix || ''; const minDecimal = getValueFromParamsOrFormatterOptions('minDecimal', columnDef, grid); const maxDecimal = getValueFromParamsOrFormatterOptions('maxDecimal', columnDef, grid); const decimalSeparator = getValueFromParamsOrFormatterOptions('decimalSeparator', columnDef, grid, '.'); diff --git a/packages/common/src/grouping-formatters/avgTotalsPercentageFormatter.ts b/packages/common/src/grouping-formatters/avgTotalsPercentageFormatter.ts index 33c3398d5..e15a2c6f8 100644 --- a/packages/common/src/grouping-formatters/avgTotalsPercentageFormatter.ts +++ b/packages/common/src/grouping-formatters/avgTotalsPercentageFormatter.ts @@ -1,13 +1,13 @@ -import { Column, GroupTotalsFormatter } from './../interfaces/index'; +import { Column, GroupTotalsFormatter, SlickGrid } from './../interfaces/index'; import { decimalFormatted, thousandSeparatorFormatted } from '../services/utilities'; import { getValueFromParamsOrFormatterOptions } from '../formatters/formatterUtilities'; -export const avgTotalsPercentageFormatter: GroupTotalsFormatter = (totals: any, columnDef: Column, grid?: any) => { - const field = columnDef.field || ''; - let val = totals.avg && totals.avg[field]; - const params = columnDef && columnDef.params; - let prefix = params && params.groupFormatterPrefix || ''; - const suffix = params && params.groupFormatterSuffix || ''; +export const avgTotalsPercentageFormatter: GroupTotalsFormatter = (totals: any, columnDef: Column, grid: SlickGrid) => { + const field = columnDef.field ?? ''; + let val = totals.avg?.[field]; + const params = columnDef?.params; + let prefix = params?.groupFormatterPrefix || ''; + const suffix = params?.groupFormatterSuffix || ''; const minDecimal = getValueFromParamsOrFormatterOptions('minDecimal', columnDef, grid); const maxDecimal = getValueFromParamsOrFormatterOptions('maxDecimal', columnDef, grid); const decimalSeparator = getValueFromParamsOrFormatterOptions('decimalSeparator', columnDef, grid, '.'); diff --git a/packages/common/src/grouping-formatters/maxTotalsFormatter.ts b/packages/common/src/grouping-formatters/maxTotalsFormatter.ts index 3ccccf463..63eb7bfa3 100644 --- a/packages/common/src/grouping-formatters/maxTotalsFormatter.ts +++ b/packages/common/src/grouping-formatters/maxTotalsFormatter.ts @@ -1,13 +1,13 @@ -import { Column, GroupTotalsFormatter } from './../interfaces/index'; +import { Column, GroupTotalsFormatter, SlickGrid } from './../interfaces/index'; import { formatNumber } from '../services/utilities'; import { getValueFromParamsOrFormatterOptions } from '../formatters/formatterUtilities'; -export const maxTotalsFormatter: GroupTotalsFormatter = (totals: any, columnDef: Column, grid?: any) => { - const field = columnDef.field || ''; - const val = totals.max && totals.max[field]; - const params = columnDef && columnDef.params; - const prefix = params && params.groupFormatterPrefix || ''; - const suffix = params && params.groupFormatterSuffix || ''; +export const maxTotalsFormatter: GroupTotalsFormatter = (totals: any, columnDef: Column, grid: SlickGrid) => { + const field = columnDef.field ?? ''; + const val = totals.max?.[field]; + const params = columnDef?.params; + const prefix = params?.groupFormatterPrefix || ''; + const suffix = params?.groupFormatterSuffix || ''; const minDecimal = getValueFromParamsOrFormatterOptions('minDecimal', columnDef, grid); const maxDecimal = getValueFromParamsOrFormatterOptions('maxDecimal', columnDef, grid); const decimalSeparator = getValueFromParamsOrFormatterOptions('decimalSeparator', columnDef, grid, '.'); diff --git a/packages/common/src/grouping-formatters/minTotalsFormatter.ts b/packages/common/src/grouping-formatters/minTotalsFormatter.ts index 8072d4a51..875ff44e6 100644 --- a/packages/common/src/grouping-formatters/minTotalsFormatter.ts +++ b/packages/common/src/grouping-formatters/minTotalsFormatter.ts @@ -1,13 +1,13 @@ -import { Column, GroupTotalsFormatter } from './../interfaces/index'; +import { Column, GroupTotalsFormatter, SlickGrid } from './../interfaces/index'; import { formatNumber } from '../services/utilities'; import { getValueFromParamsOrFormatterOptions } from '../formatters/formatterUtilities'; -export const minTotalsFormatter: GroupTotalsFormatter = (totals: any, columnDef: Column, grid?: any) => { - const field = columnDef.field || ''; - const val = totals.min && totals.min[field]; - const params = columnDef && columnDef.params; - const prefix = params && params.groupFormatterPrefix || ''; - const suffix = params && params.groupFormatterSuffix || ''; +export const minTotalsFormatter: GroupTotalsFormatter = (totals: any, columnDef: Column, grid: SlickGrid) => { + const field = columnDef.field ?? ''; + const val = totals.min?.[field]; + const params = columnDef?.params; + const prefix = params?.groupFormatterPrefix || ''; + const suffix = params?.groupFormatterSuffix || ''; const minDecimal = getValueFromParamsOrFormatterOptions('minDecimal', columnDef, grid); const maxDecimal = getValueFromParamsOrFormatterOptions('maxDecimal', columnDef, grid); const decimalSeparator = getValueFromParamsOrFormatterOptions('decimalSeparator', columnDef, grid, '.'); diff --git a/packages/common/src/grouping-formatters/sumTotalsBoldFormatter.ts b/packages/common/src/grouping-formatters/sumTotalsBoldFormatter.ts index df5ec7a73..044a7f0dc 100644 --- a/packages/common/src/grouping-formatters/sumTotalsBoldFormatter.ts +++ b/packages/common/src/grouping-formatters/sumTotalsBoldFormatter.ts @@ -1,13 +1,13 @@ -import { Column, GroupTotalsFormatter } from './../interfaces/index'; +import { Column, GroupTotalsFormatter, SlickGrid } from './../interfaces/index'; import { formatNumber } from '../services/utilities'; import { getValueFromParamsOrFormatterOptions } from '../formatters/formatterUtilities'; -export const sumTotalsBoldFormatter: GroupTotalsFormatter = (totals: any, columnDef: Column, grid?: any) => { - const field = columnDef.field || ''; - const val = totals.sum && totals.sum[field]; - const params = columnDef && columnDef.params; - const prefix = params && params.groupFormatterPrefix || ''; - const suffix = params && params.groupFormatterSuffix || ''; +export const sumTotalsBoldFormatter: GroupTotalsFormatter = (totals: any, columnDef: Column, grid: SlickGrid) => { + const field = columnDef.field ?? ''; + const val = totals.sum?.[field]; + const params = columnDef?.params; + const prefix = params?.groupFormatterPrefix || ''; + const suffix = params?.groupFormatterSuffix || ''; const minDecimal = getValueFromParamsOrFormatterOptions('minDecimal', columnDef, grid); const maxDecimal = getValueFromParamsOrFormatterOptions('maxDecimal', columnDef, grid); const decimalSeparator = getValueFromParamsOrFormatterOptions('decimalSeparator', columnDef, grid, '.'); diff --git a/packages/common/src/grouping-formatters/sumTotalsColoredFormatter.ts b/packages/common/src/grouping-formatters/sumTotalsColoredFormatter.ts index c5408e6b5..2c7bacc75 100644 --- a/packages/common/src/grouping-formatters/sumTotalsColoredFormatter.ts +++ b/packages/common/src/grouping-formatters/sumTotalsColoredFormatter.ts @@ -1,13 +1,13 @@ -import { Column, GroupTotalsFormatter } from './../interfaces/index'; +import { Column, GroupTotalsFormatter, SlickGrid } from './../interfaces/index'; import { formatNumber } from '../services/utilities'; import { getValueFromParamsOrFormatterOptions } from '../formatters/formatterUtilities'; -export const sumTotalsColoredFormatter: GroupTotalsFormatter = (totals: any, columnDef: Column, grid?: any) => { - const field = columnDef.field || ''; - const val = totals.sum && totals.sum[field]; - const params = columnDef && columnDef.params; - const prefix = params && params.groupFormatterPrefix || ''; - const suffix = params && params.groupFormatterSuffix || ''; +export const sumTotalsColoredFormatter: GroupTotalsFormatter = (totals: any, columnDef: Column, grid: SlickGrid) => { + const field = columnDef.field ?? ''; + const val = totals.sum?.[field]; + const params = columnDef?.params; + const prefix = params?.groupFormatterPrefix || ''; + const suffix = params?.groupFormatterSuffix || ''; const minDecimal = getValueFromParamsOrFormatterOptions('minDecimal', columnDef, grid); const maxDecimal = getValueFromParamsOrFormatterOptions('maxDecimal', columnDef, grid); const decimalSeparator = getValueFromParamsOrFormatterOptions('decimalSeparator', columnDef, grid, '.'); diff --git a/packages/common/src/grouping-formatters/sumTotalsDollarBoldFormatter.ts b/packages/common/src/grouping-formatters/sumTotalsDollarBoldFormatter.ts index 8e2235800..6e44f9e04 100644 --- a/packages/common/src/grouping-formatters/sumTotalsDollarBoldFormatter.ts +++ b/packages/common/src/grouping-formatters/sumTotalsDollarBoldFormatter.ts @@ -1,13 +1,13 @@ -import { Column, GroupTotalsFormatter } from './../interfaces/index'; +import { Column, GroupTotalsFormatter, SlickGrid } from './../interfaces/index'; import { formatNumber } from './../services/utilities'; import { getValueFromParamsOrFormatterOptions } from '../formatters/formatterUtilities'; -export const sumTotalsDollarBoldFormatter: GroupTotalsFormatter = (totals: any, columnDef: Column, grid?: any) => { - const field = columnDef.field || ''; - const val = totals.sum && totals.sum[field]; - const params = columnDef && columnDef.params; - const prefix = params && params.groupFormatterPrefix || ''; - const suffix = params && params.groupFormatterSuffix || ''; +export const sumTotalsDollarBoldFormatter: GroupTotalsFormatter = (totals: any, columnDef: Column, grid: SlickGrid) => { + const field = columnDef.field ?? ''; + const val = totals.sum?.[field]; + const params = columnDef?.params; + const prefix = params?.groupFormatterPrefix || ''; + const suffix = params?.groupFormatterSuffix || ''; const minDecimal = getValueFromParamsOrFormatterOptions('minDecimal', columnDef, grid, 2); const maxDecimal = getValueFromParamsOrFormatterOptions('maxDecimal', columnDef, grid, 4); const decimalSeparator = getValueFromParamsOrFormatterOptions('decimalSeparator', columnDef, grid, '.'); diff --git a/packages/common/src/grouping-formatters/sumTotalsDollarColoredBoldFormatter.ts b/packages/common/src/grouping-formatters/sumTotalsDollarColoredBoldFormatter.ts index 9200b601a..bddc96455 100644 --- a/packages/common/src/grouping-formatters/sumTotalsDollarColoredBoldFormatter.ts +++ b/packages/common/src/grouping-formatters/sumTotalsDollarColoredBoldFormatter.ts @@ -1,13 +1,13 @@ -import { Column, GroupTotalsFormatter } from './../interfaces/index'; +import { Column, GroupTotalsFormatter, SlickGrid } from './../interfaces/index'; import { formatNumber } from './../services/utilities'; import { getValueFromParamsOrFormatterOptions } from '../formatters/formatterUtilities'; -export const sumTotalsDollarColoredBoldFormatter: GroupTotalsFormatter = (totals: any, columnDef: Column, grid?: any) => { - const field = columnDef.field || ''; - const val = totals.sum && totals.sum[field]; - const params = columnDef && columnDef.params; - const prefix = params && params.groupFormatterPrefix || ''; - const suffix = params && params.groupFormatterSuffix || ''; +export const sumTotalsDollarColoredBoldFormatter: GroupTotalsFormatter = (totals: any, columnDef: Column, grid: SlickGrid) => { + const field = columnDef.field ?? ''; + const val = totals.sum?.[field]; + const params = columnDef?.params; + const prefix = params?.groupFormatterPrefix || ''; + const suffix = params?.groupFormatterSuffix || ''; const minDecimal = getValueFromParamsOrFormatterOptions('minDecimal', columnDef, grid, 2); const maxDecimal = getValueFromParamsOrFormatterOptions('maxDecimal', columnDef, grid, 4); const decimalSeparator = getValueFromParamsOrFormatterOptions('decimalSeparator', columnDef, grid, '.'); diff --git a/packages/common/src/grouping-formatters/sumTotalsDollarColoredFormatter.ts b/packages/common/src/grouping-formatters/sumTotalsDollarColoredFormatter.ts index 701e52070..b5644329c 100644 --- a/packages/common/src/grouping-formatters/sumTotalsDollarColoredFormatter.ts +++ b/packages/common/src/grouping-formatters/sumTotalsDollarColoredFormatter.ts @@ -1,13 +1,13 @@ -import { Column, GroupTotalsFormatter } from './../interfaces/index'; +import { Column, GroupTotalsFormatter, SlickGrid } from './../interfaces/index'; import { formatNumber } from './../services/utilities'; import { getValueFromParamsOrFormatterOptions } from '../formatters/formatterUtilities'; -export const sumTotalsDollarColoredFormatter: GroupTotalsFormatter = (totals: any, columnDef: Column, grid?: any) => { - const field = columnDef.field || ''; - const val = totals.sum && totals.sum[field]; - const params = columnDef && columnDef.params; - const prefix = params && params.groupFormatterPrefix || ''; - const suffix = params && params.groupFormatterSuffix || ''; +export const sumTotalsDollarColoredFormatter: GroupTotalsFormatter = (totals: any, columnDef: Column, grid: SlickGrid) => { + const field = columnDef.field ?? ''; + const val = totals.sum?.[field]; + const params = columnDef?.params; + const prefix = params?.groupFormatterPrefix || ''; + const suffix = params?.groupFormatterSuffix || ''; const minDecimal = getValueFromParamsOrFormatterOptions('minDecimal', columnDef, grid, 2); const maxDecimal = getValueFromParamsOrFormatterOptions('maxDecimal', columnDef, grid, 4); const decimalSeparator = getValueFromParamsOrFormatterOptions('decimalSeparator', columnDef, grid, '.'); diff --git a/packages/common/src/grouping-formatters/sumTotalsDollarFormatter.ts b/packages/common/src/grouping-formatters/sumTotalsDollarFormatter.ts index b13f04892..edbbee213 100644 --- a/packages/common/src/grouping-formatters/sumTotalsDollarFormatter.ts +++ b/packages/common/src/grouping-formatters/sumTotalsDollarFormatter.ts @@ -1,13 +1,13 @@ -import { Column, GroupTotalsFormatter } from './../interfaces/index'; +import { Column, GroupTotalsFormatter, SlickGrid } from './../interfaces/index'; import { formatNumber } from './../services/utilities'; import { getValueFromParamsOrFormatterOptions } from '../formatters/formatterUtilities'; -export const sumTotalsDollarFormatter: GroupTotalsFormatter = (totals: any, columnDef: Column, grid?: any) => { - const field = columnDef.field || ''; - const val = totals.sum && totals.sum[field]; - const params = columnDef && columnDef.params; - const prefix = params && params.groupFormatterPrefix || ''; - const suffix = params && params.groupFormatterSuffix || ''; +export const sumTotalsDollarFormatter: GroupTotalsFormatter = (totals: any, columnDef: Column, grid: SlickGrid) => { + const field = columnDef.field ?? ''; + const val = totals.sum?.[field]; + const params = columnDef?.params; + const prefix = params?.groupFormatterPrefix || ''; + const suffix = params?.groupFormatterSuffix || ''; const minDecimal = getValueFromParamsOrFormatterOptions('minDecimal', columnDef, grid, 2); const maxDecimal = getValueFromParamsOrFormatterOptions('maxDecimal', columnDef, grid, 4); const decimalSeparator = getValueFromParamsOrFormatterOptions('decimalSeparator', columnDef, grid, '.'); diff --git a/packages/common/src/grouping-formatters/sumTotalsFormatter.ts b/packages/common/src/grouping-formatters/sumTotalsFormatter.ts index 7868a4c31..859d00db0 100644 --- a/packages/common/src/grouping-formatters/sumTotalsFormatter.ts +++ b/packages/common/src/grouping-formatters/sumTotalsFormatter.ts @@ -1,13 +1,13 @@ -import { Column, GroupTotalsFormatter } from './../interfaces/index'; +import { Column, GroupTotalsFormatter, SlickGrid } from './../interfaces/index'; import { formatNumber } from '../services/utilities'; import { getValueFromParamsOrFormatterOptions } from '../formatters/formatterUtilities'; -export const sumTotalsFormatter: GroupTotalsFormatter = (totals: any, columnDef: Column, grid?: any) => { - const field = columnDef.field || ''; - const val = totals.sum && totals.sum[field]; - const params = columnDef && columnDef.params; - const prefix = params && params.groupFormatterPrefix || ''; - const suffix = params && params.groupFormatterSuffix || ''; +export const sumTotalsFormatter: GroupTotalsFormatter = (totals: any, columnDef: Column, grid: SlickGrid) => { + const field = columnDef.field ?? ''; + const val = totals.sum?.[field]; + const params = columnDef?.params; + const prefix = params?.groupFormatterPrefix || ''; + const suffix = params?.groupFormatterSuffix || ''; const minDecimal = getValueFromParamsOrFormatterOptions('minDecimal', columnDef, grid); const maxDecimal = getValueFromParamsOrFormatterOptions('maxDecimal', columnDef, grid); const decimalSeparator = getValueFromParamsOrFormatterOptions('decimalSeparator', columnDef, grid, '.'); diff --git a/packages/common/src/interfaces/aggregator.interface.ts b/packages/common/src/interfaces/aggregator.interface.ts index 39c0854c2..df76e2665 100644 --- a/packages/common/src/interfaces/aggregator.interface.ts +++ b/packages/common/src/interfaces/aggregator.interface.ts @@ -1,16 +1,16 @@ export interface Aggregator { - /** Aggregator associated Field Id */ - field?: number | string; + /** Column definition field Id of the associated Aggregator */ + field: number | string; - /** Aggregator associated type */ - type?: string; + /** Type of Aggregator (sum, avg, ...) */ + type: string; /** Aggregator initialize method */ init: () => void; - /** Mathod to accumulate the result with different logic depending on each aggregator type */ + /** Method to accumulate the result which will be different for each Aggregator type */ accumulate?: (item: any) => void; - /** Method to store the result into the given group total argument provided */ - storeResult?: (groupTotals: any | undefined) => void; + /** Method to store the result into the given group total object provided as argument */ + storeResult: (groupTotals: any | undefined) => void; } diff --git a/packages/common/src/interfaces/groupTotalsFormatter.interface.ts b/packages/common/src/interfaces/groupTotalsFormatter.interface.ts index 517be07fc..ce919fb10 100644 --- a/packages/common/src/interfaces/groupTotalsFormatter.interface.ts +++ b/packages/common/src/interfaces/groupTotalsFormatter.interface.ts @@ -1,3 +1,4 @@ import { Column } from './column.interface'; +import { SlickGrid } from './slickGrid.interface'; -export type GroupTotalsFormatter = (totals: any, columnDef: Column, grid?: any) => string; +export type GroupTotalsFormatter = (totals: any, columnDef: Column, grid: SlickGrid) => string;