From ad568107051304c72ffbf2d6b7c06d78b4b67fa9 Mon Sep 17 00:00:00 2001 From: TOURI ANIS Date: Wed, 11 Dec 2024 17:59:32 +0100 Subject: [PATCH 01/10] use aggrid filter and sort --- .../custom-aggrid-header-utils.ts | 2 +- .../spreadsheet/config/column-aggrid-utils.ts | 27 +++++ .../config/column-type-flter-config.ts | 58 ++++++++++ .../config/common/column-properties.tsx | 5 +- .../spreadsheet/config/equipment/battery.ts | 39 +++---- .../spreadsheet/config/equipment/bus.ts | 24 ++-- .../config/equipment/busbar-section.ts | 7 +- .../config/equipment/common-config.ts | 3 +- .../config/equipment/dangling-line.ts | 32 +++--- .../spreadsheet/config/equipment/generator.ts | 54 ++++----- .../spreadsheet/config/equipment/hvdc-line.ts | 50 ++++---- .../config/equipment/lcc-converter-station.ts | 32 +++--- .../spreadsheet/config/equipment/line.ts | 55 +++++---- .../spreadsheet/config/equipment/load.ts | 33 ++---- .../config/equipment/shunt-compensator.ts | 37 +++--- .../equipment/static-var-compensator.ts | 31 ++--- .../config/equipment/substation.ts | 14 +-- .../equipment/three-windings-transformer.ts | 98 +++++++--------- .../spreadsheet/config/equipment/tie-line.ts | 51 ++++----- .../equipment/two-windings-transformer.ts | 72 ++++++------ .../config/equipment/voltage-level.ts | 26 ++--- .../config/equipment/vsc-converter-station.ts | 37 +++--- .../spreadsheet/config/spreadsheet.type.ts | 29 ++++- .../spreadsheet/equipment-table.tsx | 3 + src/components/spreadsheet/table-wrapper.tsx | 107 ++++++------------ src/components/spreadsheet/utils/constants.ts | 6 + 26 files changed, 468 insertions(+), 464 deletions(-) create mode 100644 src/components/spreadsheet/config/column-aggrid-utils.ts create mode 100644 src/components/spreadsheet/config/column-type-flter-config.ts diff --git a/src/components/custom-aggrid/custom-aggrid-header-utils.ts b/src/components/custom-aggrid/custom-aggrid-header-utils.ts index c437f733c3..5da12b42ea 100644 --- a/src/components/custom-aggrid/custom-aggrid-header-utils.ts +++ b/src/components/custom-aggrid/custom-aggrid-header-utils.ts @@ -72,7 +72,7 @@ export const makeAgGridCustomHeaderColumn = ({ isCustomColumn: isCustomColumn, Menu: Menu, }, - filterParams: props?.agGridFilterParams || undefined, + //filterParams: props?.agGridFilterParams || undefined, ...props, }; }; diff --git a/src/components/spreadsheet/config/column-aggrid-utils.ts b/src/components/spreadsheet/config/column-aggrid-utils.ts new file mode 100644 index 0000000000..00e64ba6bf --- /dev/null +++ b/src/components/spreadsheet/config/column-aggrid-utils.ts @@ -0,0 +1,27 @@ +/** + * Copyright (c) 2023, RTE (http://www.rte-france.com) + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +import { CustomColDef } from 'components/custom-aggrid/custom-aggrid-header.type'; + +export const makeAgGridColumn = ({ + forceDisplayFilterIcon, + tabIndex, + isCustomColumn, + Menu, + ...props // agGrid column props +}: CustomColDef) => { + const { headerName, fractionDigits, numeric } = props; + + let minWidth = 75; + + return { + headerTooltip: headerName, + minWidth, + fractionDigits: numeric && !fractionDigits ? 2 : fractionDigits, + ...props, + }; +}; diff --git a/src/components/spreadsheet/config/column-type-flter-config.ts b/src/components/spreadsheet/config/column-type-flter-config.ts new file mode 100644 index 0000000000..dac9c66104 --- /dev/null +++ b/src/components/spreadsheet/config/column-type-flter-config.ts @@ -0,0 +1,58 @@ +/** + * Copyright (c) 2024, RTE (http://www.rte-france.com) + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +import { FILTER_NUMBER_COMPARATORS, FILTER_TEXT_COMPARATORS } from 'components/custom-aggrid/custom-aggrid-header.type'; +import { EnumOption } from 'components/utils/utils-type'; + +function contains(target: string, lookingFor: string) { + return target && target?.toLowerCase().indexOf(lookingFor.toLowerCase()) >= 0; +} + +export const getEnumFilterConfig = (enumOption: EnumOption[]) => { + return { + enumFilter: { + filter: 'agTextColumnFilter', + filterParams: { + caseSensitive: false, + maxNumConditions: 1, + filterOptions: [FILTER_TEXT_COMPARATORS.CONTAINS], + textMatcher: ({ value, filterText }: { value: string; filterText: string }) => { + if (value) { + /* const label = + getEnumLabelById(Object.values(enumOption) as EnumOption[], value?.toUpperCase()) || + value; + const text = label ? intl.formatMessage({ id: label }) : value; */ + return contains(value, filterText || ''); + } + return false; + }, + debounceMs: 200, + }, + }, + }; +}; + +export const defaultColumnType = { + textFilter: { + filter: 'agTextColumnFilter', + filterParams: { + caseSensitive: false, + filterOptions: [FILTER_TEXT_COMPARATORS.STARTS_WITH, FILTER_TEXT_COMPARATORS.CONTAINS], + }, + sortable: true, + resizable: true, + }, + numericFilter: { + filter: 'agNumberColumnFilter', + filterParams: { + filterOptions: Object.values(FILTER_NUMBER_COMPARATORS), + debounceMs: 200, + }, + sortable: false, + resizable: true, + }, +}; diff --git a/src/components/spreadsheet/config/common/column-properties.tsx b/src/components/spreadsheet/config/common/column-properties.tsx index 7c6a4642e9..25d3aa4c3e 100644 --- a/src/components/spreadsheet/config/common/column-properties.tsx +++ b/src/components/spreadsheet/config/common/column-properties.tsx @@ -8,7 +8,8 @@ import { PropertiesCellRenderer } from '../../utils/cell-renderers'; import { SitePropertiesEditor } from '../../utils/equipement-table-popup-editors'; import type { ValueGetterFunc, ValueSetterParams } from 'ag-grid-community'; -import { defaultTextFilterConfig, editableColumnConfig, excludeFromGlobalFilter } from '../equipment/common-config'; +import { editableColumnConfig, excludeFromGlobalFilter } from '../equipment/common-config'; +import { TEXT_FILTER } from 'components/spreadsheet/utils/constants'; const propertiesGetter: ValueGetterFunc = (params) => { const properties = params?.data?.properties; @@ -29,7 +30,7 @@ export const genericColumnOfPropertiesReadonly = { cellRenderer: PropertiesCellRenderer, minWidth: 300, getQuickFilterText: excludeFromGlobalFilter, - ...defaultTextFilterConfig, + type: TEXT_FILTER, }; export const genericColumnOfProperties = { diff --git a/src/components/spreadsheet/config/equipment/battery.ts b/src/components/spreadsheet/config/equipment/battery.ts index 27f4f9ff99..5e51f95684 100644 --- a/src/components/spreadsheet/config/equipment/battery.ts +++ b/src/components/spreadsheet/config/equipment/battery.ts @@ -9,18 +9,11 @@ import type { ReadonlyDeep } from 'type-fest'; import { EQUIPMENT_TYPES } from '../../../utils/equipment-types'; import CountryCellRenderer from '../../utils/country-cell-render'; import { BooleanCellRenderer } from '../../utils/cell-renderers'; -import { - countryEnumFilterConfig, - defaultBooleanFilterConfig, - defaultNumericFilterConfig, - defaultTextFilterConfig, - editableColumnConfig, - excludeFromGlobalFilter, - typeAndFetchers, -} from './common-config'; +import { editableColumnConfig, excludeFromGlobalFilter, typeAndFetchers } from './common-config'; import type { SpreadsheetTabDefinition } from '../spreadsheet.type'; import { genericColumnOfPropertiesEditPopup } from '../common/column-properties'; import { booleanCellEditorConfig, numericalCellEditorConfig } from '../common/cell-editors'; +import { COUNTRY_FILTER, NUMERIC_FILTER, TEXT_FILTER } from 'components/spreadsheet/utils/constants'; export const BATTERY_TAB_DEF = { index: 9, @@ -31,30 +24,30 @@ export const BATTERY_TAB_DEF = { id: 'ID', field: 'id', isDefaultSort: true, - ...defaultTextFilterConfig, + type: TEXT_FILTER, }, { id: 'Name', field: 'name', - ...defaultTextFilterConfig, + type: TEXT_FILTER, ...editableColumnConfig, }, { id: 'VoltageLevelId', field: 'voltageLevelId', - ...defaultTextFilterConfig, + type: TEXT_FILTER, }, { id: 'Country', field: 'country', - ...countryEnumFilterConfig, + type: COUNTRY_FILTER, cellRenderer: CountryCellRenderer, }, { id: 'NominalV', field: 'nominalVoltage', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 0, }, { @@ -62,7 +55,7 @@ export const BATTERY_TAB_DEF = { field: 'p', numeric: true, fractionDigits: 1, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, canBeInvalidated: true, withFluxConvention: true, getQuickFilterText: excludeFromGlobalFilter, @@ -72,7 +65,7 @@ export const BATTERY_TAB_DEF = { field: 'q', numeric: true, fractionDigits: 1, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, canBeInvalidated: true, withFluxConvention: true, getQuickFilterText: excludeFromGlobalFilter, @@ -81,7 +74,7 @@ export const BATTERY_TAB_DEF = { id: 'ActivePowerControl', field: 'activePowerControl.participate', cellRenderer: BooleanCellRenderer, - ...defaultBooleanFilterConfig, + type: TEXT_FILTER, ...editableColumnConfig, valueSetter: (params) => { params.data.activePowerControl = { @@ -97,7 +90,7 @@ export const BATTERY_TAB_DEF = { id: 'DroopColumnName', field: 'activePowerControl.droop', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 1, ...editableColumnConfig, ...numericalCellEditorConfig((params) => params.data.activePowerControl?.droop), @@ -121,7 +114,7 @@ export const BATTERY_TAB_DEF = { id: 'minP', field: 'minP', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 1, ...editableColumnConfig, ...numericalCellEditorConfig((params) => params.data.minP), @@ -134,7 +127,7 @@ export const BATTERY_TAB_DEF = { id: 'maxP', field: 'maxP', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 1, ...editableColumnConfig, ...numericalCellEditorConfig((params) => params.data.maxP), @@ -147,7 +140,7 @@ export const BATTERY_TAB_DEF = { id: 'activePowerSetpoint', field: 'targetP', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 1, ...editableColumnConfig, ...numericalCellEditorConfig((params) => params.data.targetP), @@ -162,7 +155,7 @@ export const BATTERY_TAB_DEF = { id: 'reactivePowerSetpoint', field: 'targetQ', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 1, ...editableColumnConfig, ...numericalCellEditorConfig((params) => params.data.targetQ), @@ -173,7 +166,7 @@ export const BATTERY_TAB_DEF = { field: 'terminalConnected', boolean: true, cellRenderer: BooleanCellRenderer, - ...defaultBooleanFilterConfig, + type: TEXT_FILTER, getQuickFilterText: excludeFromGlobalFilter, }, genericColumnOfPropertiesEditPopup, diff --git a/src/components/spreadsheet/config/equipment/bus.ts b/src/components/spreadsheet/config/equipment/bus.ts index df4e9d7adc..da38a0fa5f 100644 --- a/src/components/spreadsheet/config/equipment/bus.ts +++ b/src/components/spreadsheet/config/equipment/bus.ts @@ -9,13 +9,9 @@ import type { ReadonlyDeep } from 'type-fest'; import type { SpreadsheetTabDefinition } from '../spreadsheet.type'; import { EQUIPMENT_TYPES } from '../../../utils/equipment-types'; import CountryCellRenderer from '../../utils/country-cell-render'; -import { - countryEnumFilterConfig, - defaultNumericFilterConfig, - defaultTextFilterConfig, - typeAndFetchers, -} from './common-config'; +import { typeAndFetchers } from './common-config'; import { genericColumnOfProperties } from '../common/column-properties'; +import { COUNTRY_FILTER, NUMERIC_FILTER, TEXT_FILTER } from 'components/spreadsheet/utils/constants'; export const BUS_TAB_DEF = { index: 14, @@ -26,7 +22,7 @@ export const BUS_TAB_DEF = { id: 'ID', field: 'id', isDefaultSort: true, - ...defaultTextFilterConfig, + type: TEXT_FILTER, }, { id: 'Magnitude', @@ -34,7 +30,7 @@ export const BUS_TAB_DEF = { numeric: true, fractionDigits: 1, canBeInvalidated: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, }, { id: 'Angle', @@ -42,27 +38,27 @@ export const BUS_TAB_DEF = { numeric: true, fractionDigits: 1, canBeInvalidated: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, }, { id: 'ConnectedComponent', field: 'connectedComponentNum', - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, }, { id: 'SynchronousComponent', field: 'synchronousComponentNum', - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, }, { id: 'VoltageLevelId', field: 'voltageLevelId', - ...defaultTextFilterConfig, + type: TEXT_FILTER, }, { id: 'Country', field: 'country', - ...countryEnumFilterConfig, + type: COUNTRY_FILTER, cellRenderer: CountryCellRenderer, }, { @@ -70,7 +66,7 @@ export const BUS_TAB_DEF = { field: 'nominalVoltage', numeric: true, fractionDigits: 0, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, }, genericColumnOfProperties, ], diff --git a/src/components/spreadsheet/config/equipment/busbar-section.ts b/src/components/spreadsheet/config/equipment/busbar-section.ts index 0e5a2daab5..8d11a4578d 100644 --- a/src/components/spreadsheet/config/equipment/busbar-section.ts +++ b/src/components/spreadsheet/config/equipment/busbar-section.ts @@ -7,8 +7,9 @@ import { SpreadsheetTabDefinition } from '../spreadsheet.type'; import { EQUIPMENT_TYPES } from '../../../utils/equipment-types'; -import { defaultTextFilterConfig, typeAndFetchers } from './common-config'; +import { typeAndFetchers } from './common-config'; import type { ReadonlyDeep } from 'type-fest'; +import { TEXT_FILTER } from 'components/spreadsheet/utils/constants'; export const BUSBAR_SECTION_TAB_DEF = { index: 16, @@ -19,12 +20,12 @@ export const BUSBAR_SECTION_TAB_DEF = { id: 'ID', field: 'id', isDefaultSort: true, - ...defaultTextFilterConfig, + type: TEXT_FILTER, }, { id: 'VoltageLevelId', field: 'voltageLevelId', - ...defaultTextFilterConfig, + type: TEXT_FILTER, }, ], } as const satisfies ReadonlyDeep; diff --git a/src/components/spreadsheet/config/equipment/common-config.ts b/src/components/spreadsheet/config/equipment/common-config.ts index fa89deeba2..b6456403e4 100644 --- a/src/components/spreadsheet/config/equipment/common-config.ts +++ b/src/components/spreadsheet/config/equipment/common-config.ts @@ -38,6 +38,7 @@ import { } from '../../../../services/study/network'; import { EquipmentFetcher, SpreadsheetEquipmentType } from '../spreadsheet.type'; import { BooleanFilterValue } from '../../../custom-aggrid/custom-aggrid-filters/custom-aggrid-boolean-filter'; +import { getEnumFilterConfig } from '../column-type-flter-config'; type TapPositionsType = { lowTapPosition: number; @@ -183,7 +184,7 @@ export const defaultBooleanFilterConfig = { // It generates configuration for filtering, sorting and rendering export const getDefaultEnumConfig = (enumOptions: Readonly) => ({ - ...defaultEnumFilterConfig, + ...getEnumFilterConfig(enumOptions as EnumOption[]), cellRenderer: EnumCellRenderer, cellRendererParams: { enumOptions: enumOptions as Writable, diff --git a/src/components/spreadsheet/config/equipment/dangling-line.ts b/src/components/spreadsheet/config/equipment/dangling-line.ts index 5242bafede..2e1ce0cc9b 100644 --- a/src/components/spreadsheet/config/equipment/dangling-line.ts +++ b/src/components/spreadsheet/config/equipment/dangling-line.ts @@ -10,16 +10,10 @@ import type { SpreadsheetTabDefinition } from '../spreadsheet.type'; import { EQUIPMENT_TYPES } from '../../../utils/equipment-types'; import CountryCellRenderer from '../../utils/country-cell-render'; import { BooleanCellRenderer } from '../../utils/cell-renderers'; -import { - countryEnumFilterConfig, - defaultBooleanFilterConfig, - defaultNumericFilterConfig, - defaultTextFilterConfig, - excludeFromGlobalFilter, - typeAndFetchers, -} from './common-config'; +import { excludeFromGlobalFilter, typeAndFetchers } from './common-config'; import { NOMINAL_V } from '../../../utils/field-constants'; import { genericColumnOfProperties } from '../common/column-properties'; +import { COUNTRY_FILTER, NUMERIC_FILTER, TEXT_FILTER } from 'components/spreadsheet/utils/constants'; export const DANGLING_LINE_TAB_DEF = { index: 13, @@ -30,42 +24,42 @@ export const DANGLING_LINE_TAB_DEF = { id: 'ID', field: 'id', isDefaultSort: true, - ...defaultTextFilterConfig, + type: TEXT_FILTER, }, { id: 'Name', field: 'name', - ...defaultTextFilterConfig, + type: TEXT_FILTER, }, { id: 'VoltageLevelId', field: 'voltageLevelId', - ...defaultTextFilterConfig, + type: TEXT_FILTER, }, { id: 'Country', field: 'country', - ...countryEnumFilterConfig, + type: COUNTRY_FILTER, cellRenderer: CountryCellRenderer, }, { id: 'NominalV', field: NOMINAL_V, numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 0, }, { id: 'PairingKey', field: 'pairingKey', getQuickFilterText: excludeFromGlobalFilter, - ...defaultTextFilterConfig, + type: TEXT_FILTER, }, { id: 'activePower', field: 'p', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 1, canBeInvalidated: true, getQuickFilterText: excludeFromGlobalFilter, @@ -74,7 +68,7 @@ export const DANGLING_LINE_TAB_DEF = { id: 'ReactivePower', field: 'q', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 1, canBeInvalidated: true, getQuickFilterText: excludeFromGlobalFilter, @@ -83,7 +77,7 @@ export const DANGLING_LINE_TAB_DEF = { id: 'p0', field: 'p0', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 1, getQuickFilterText: excludeFromGlobalFilter, }, @@ -91,7 +85,7 @@ export const DANGLING_LINE_TAB_DEF = { id: 'q0', field: 'q0', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 1, getQuickFilterText: excludeFromGlobalFilter, }, @@ -100,7 +94,7 @@ export const DANGLING_LINE_TAB_DEF = { field: 'terminalConnected', boolean: true, cellRenderer: BooleanCellRenderer, - ...defaultBooleanFilterConfig, + type: TEXT_FILTER, getQuickFilterText: excludeFromGlobalFilter, }, genericColumnOfProperties, diff --git a/src/components/spreadsheet/config/equipment/generator.ts b/src/components/spreadsheet/config/equipment/generator.ts index e4885914ed..d35edb3f96 100644 --- a/src/components/spreadsheet/config/equipment/generator.ts +++ b/src/components/spreadsheet/config/equipment/generator.ts @@ -16,17 +16,13 @@ import CountryCellRenderer from '../../utils/country-cell-render'; import type { EditableCallback, ValueGetterFunc } from 'ag-grid-community'; import { BooleanCellRenderer } from '../../utils/cell-renderers'; import { - countryEnumFilterConfig, - defaultBooleanFilterConfig, - defaultNumericFilterConfig, - defaultTextFilterConfig, editableCellStyle, editableColumnConfig, excludeFromGlobalFilter, getDefaultEnumConfig, typeAndFetchers, } from './common-config'; -import { MEDIUM_COLUMN_WIDTH } from '../../utils/constants'; +import { COUNTRY_FILTER, MEDIUM_COLUMN_WIDTH, NUMERIC_FILTER, TEXT_FILTER } from '../../utils/constants'; import { ENERGY_SOURCES, REGULATION_TYPES } from '../../../network/constants'; import { genericColumnOfPropertiesEditPopup } from '../common/column-properties'; import { @@ -72,30 +68,30 @@ export const GENERATOR_TAB_DEF = { field: 'id', columnWidth: MEDIUM_COLUMN_WIDTH, isDefaultSort: true, - ...defaultTextFilterConfig, + type: TEXT_FILTER, }, { id: 'Name', field: 'name', - ...defaultTextFilterConfig, + type: TEXT_FILTER, ...editableColumnConfig, }, { id: 'VoltageLevelId', field: 'voltageLevelId', - ...defaultTextFilterConfig, + type: TEXT_FILTER, }, { id: 'Country', field: 'country', - ...countryEnumFilterConfig, + type: COUNTRY_FILTER, cellRenderer: CountryCellRenderer, }, { id: 'NominalV', field: 'nominalVoltage', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 0, }, { @@ -110,7 +106,7 @@ export const GENERATOR_TAB_DEF = { field: 'p', numeric: true, fractionDigits: 1, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, canBeInvalidated: true, withFluxConvention: true, getQuickFilterText: excludeFromGlobalFilter, @@ -120,7 +116,7 @@ export const GENERATOR_TAB_DEF = { field: 'q', numeric: true, fractionDigits: 1, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, canBeInvalidated: true, withFluxConvention: true, getQuickFilterText: excludeFromGlobalFilter, @@ -129,7 +125,7 @@ export const GENERATOR_TAB_DEF = { id: 'ActivePowerControl', field: 'activePowerControl.participate', cellRenderer: BooleanCellRenderer, - ...defaultBooleanFilterConfig, + type: TEXT_FILTER, ...editableColumnConfig, valueSetter: (params) => { params.data.activePowerControl = { @@ -146,7 +142,7 @@ export const GENERATOR_TAB_DEF = { id: 'ActivePowerRegulationDroop', field: 'activePowerControl.droop', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 1, ...editableColumnConfig, ...numericalCellEditorConfig((params) => params.data.activePowerControl?.droop), @@ -170,7 +166,7 @@ export const GENERATOR_TAB_DEF = { id: 'minP', field: 'minP', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 1, ...editableColumnConfig, ...numericalCellEditorConfig((params) => params.data.minP), @@ -183,7 +179,7 @@ export const GENERATOR_TAB_DEF = { id: 'maxP', field: 'maxP', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 1, ...editableColumnConfig, ...numericalCellEditorConfig((params) => params.data.maxP), @@ -196,7 +192,7 @@ export const GENERATOR_TAB_DEF = { id: 'activePowerSetpoint', field: 'targetP', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, ...editableColumnConfig, ...numericalCellEditorConfig((params) => params.data.targetP), fractionDigits: 1, @@ -211,7 +207,7 @@ export const GENERATOR_TAB_DEF = { id: 'reactivePowerSetpoint', field: 'targetQ', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 1, ...editableColumnConfig, ...numericalCellEditorConfig((params) => params.data.targetQ), @@ -227,7 +223,7 @@ export const GENERATOR_TAB_DEF = { id: 'voltageRegulationOn', field: 'voltageRegulatorOn', cellRenderer: BooleanCellRenderer, - ...defaultBooleanFilterConfig, + type: TEXT_FILTER, ...editableColumnConfig, ...booleanCellEditorConfig((params) => params.data?.voltageRegulatorOn ?? false), getQuickFilterText: excludeFromGlobalFilter, @@ -236,7 +232,7 @@ export const GENERATOR_TAB_DEF = { id: 'voltageSetpoint', field: 'targetV', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 1, ...editableColumnConfig, ...numericalCellEditorConfig((params) => params.data.targetV), @@ -251,7 +247,7 @@ export const GENERATOR_TAB_DEF = { { id: 'ReactivePercentageVoltageRegulation', field: 'coordinatedReactiveControl.qPercent', - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, getQuickFilterText: excludeFromGlobalFilter, ...editableColumnConfig, numeric: true, @@ -279,7 +275,7 @@ export const GENERATOR_TAB_DEF = { id: 'directTransX', field: 'generatorShortCircuit.directTransX', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 1, getQuickFilterText: excludeFromGlobalFilter, ...editableColumnConfig, @@ -300,7 +296,7 @@ export const GENERATOR_TAB_DEF = { id: 'stepUpTransformerX', field: 'generatorShortCircuit.stepUpTransformerX', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 1, getQuickFilterText: excludeFromGlobalFilter, ...editableColumnConfig, @@ -321,7 +317,7 @@ export const GENERATOR_TAB_DEF = { id: 'plannedActivePowerSetPoint', field: 'generatorStartup.plannedActivePowerSetPoint', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 1, getQuickFilterText: excludeFromGlobalFilter, ...editableColumnConfig, @@ -344,7 +340,7 @@ export const GENERATOR_TAB_DEF = { ...editableColumnConfig, ...numericalCellEditorConfig((params) => params.data?.generatorStartup?.marginalCost), numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 1, getQuickFilterText: excludeFromGlobalFilter, valueGetter: (params) => params.data?.generatorStartup?.marginalCost, @@ -363,7 +359,7 @@ export const GENERATOR_TAB_DEF = { id: 'plannedOutageRate', field: 'generatorStartup.plannedOutageRate', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 2, getQuickFilterText: excludeFromGlobalFilter, ...editableColumnConfig, @@ -386,7 +382,7 @@ export const GENERATOR_TAB_DEF = { id: 'forcedOutageRate', field: 'generatorStartup.forcedOutageRate', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 2, getQuickFilterText: excludeFromGlobalFilter, ...editableColumnConfig, @@ -410,7 +406,7 @@ export const GENERATOR_TAB_DEF = { field: 'terminalConnected', boolean: true, cellRenderer: BooleanCellRenderer, - ...defaultBooleanFilterConfig, + type: TEXT_FILTER, getQuickFilterText: excludeFromGlobalFilter, }, { @@ -423,7 +419,7 @@ export const GENERATOR_TAB_DEF = { { id: 'RegulatingTerminalGenerator', field: 'RegulatingTerminalGenerator', - ...defaultTextFilterConfig, + type: TEXT_FILTER, valueGetter: RegulatingTerminalCellGetter, cellStyle: (params) => (isEditableRegulatingTerminalCell(params) ? editableCellStyle(params) : {}), editable: isEditableRegulatingTerminalCell, diff --git a/src/components/spreadsheet/config/equipment/hvdc-line.ts b/src/components/spreadsheet/config/equipment/hvdc-line.ts index 62fa9b6751..05a8cc66f7 100644 --- a/src/components/spreadsheet/config/equipment/hvdc-line.ts +++ b/src/components/spreadsheet/config/equipment/hvdc-line.ts @@ -10,16 +10,14 @@ import type { SpreadsheetTabDefinition } from '../spreadsheet.type'; import { EQUIPMENT_TYPES } from '../../../utils/equipment-types'; import CountryCellRenderer from '../../utils/country-cell-render'; import { BooleanCellRenderer } from '../../utils/cell-renderers'; +import { excludeFromGlobalFilter, typeAndFetchers } from './common-config'; import { - countryEnumFilterConfig, - defaultBooleanFilterConfig, - defaultEnumFilterConfig, - defaultNumericFilterConfig, - defaultTextFilterConfig, - excludeFromGlobalFilter, - typeAndFetchers, -} from './common-config'; -import { LARGE_COLUMN_WIDTH, MEDIUM_COLUMN_WIDTH } from '../../utils/constants'; + COUNTRY_FILTER, + LARGE_COLUMN_WIDTH, + MEDIUM_COLUMN_WIDTH, + NUMERIC_FILTER, + TEXT_FILTER, +} from '../../utils/constants'; import { genericColumnOfProperties } from '../common/column-properties'; export const HVDC_LINE_TAB_DEF = { @@ -32,60 +30,60 @@ export const HVDC_LINE_TAB_DEF = { field: 'id', columnWidth: MEDIUM_COLUMN_WIDTH, isDefaultSort: true, - ...defaultTextFilterConfig, + type: TEXT_FILTER, }, { id: 'Name', field: 'name', columnWidth: MEDIUM_COLUMN_WIDTH, - ...defaultTextFilterConfig, + type: TEXT_FILTER, }, { id: 'VoltageLevelIdSide1', field: 'voltageLevelId1', - ...defaultTextFilterConfig, + type: TEXT_FILTER, }, { id: 'VoltageLevelIdSide2', field: 'voltageLevelId2', - ...defaultTextFilterConfig, + type: TEXT_FILTER, }, { id: 'ConvertersMode', field: 'convertersMode', columnWidth: LARGE_COLUMN_WIDTH, getQuickFilterText: excludeFromGlobalFilter, - ...defaultEnumFilterConfig, + type: TEXT_FILTER, }, { id: 'ConverterStationId1', field: 'converterStationId1', columnWidth: LARGE_COLUMN_WIDTH, - ...defaultTextFilterConfig, + type: TEXT_FILTER, }, { id: 'ConverterStationId2', field: 'converterStationId2', columnWidth: LARGE_COLUMN_WIDTH, - ...defaultTextFilterConfig, + type: TEXT_FILTER, }, { id: 'Country1', field: 'country1', - ...countryEnumFilterConfig, + type: COUNTRY_FILTER, cellRenderer: CountryCellRenderer, }, { id: 'Country2', field: 'country2', - ...countryEnumFilterConfig, + type: COUNTRY_FILTER, cellRenderer: CountryCellRenderer, }, { id: 'R', field: 'r', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 1, getQuickFilterText: excludeFromGlobalFilter, }, @@ -93,7 +91,7 @@ export const HVDC_LINE_TAB_DEF = { id: 'ActivePowerSetpoint', field: 'activePowerSetpoint', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 1, getQuickFilterText: excludeFromGlobalFilter, }, @@ -101,7 +99,7 @@ export const HVDC_LINE_TAB_DEF = { id: 'maxActivePower', field: 'maxP', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 1, getQuickFilterText: excludeFromGlobalFilter, }, @@ -109,7 +107,7 @@ export const HVDC_LINE_TAB_DEF = { id: 'OprFromCS1toCS2', field: 'hvdcOperatorActivePowerRange.oprFromCS1toCS2', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 1, columnWidth: LARGE_COLUMN_WIDTH, getQuickFilterText: excludeFromGlobalFilter, @@ -118,7 +116,7 @@ export const HVDC_LINE_TAB_DEF = { id: 'OprFromCS2toCS1', field: 'hvdcOperatorActivePowerRange.oprFromCS2toCS1', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 1, columnWidth: LARGE_COLUMN_WIDTH, getQuickFilterText: excludeFromGlobalFilter, @@ -128,14 +126,14 @@ export const HVDC_LINE_TAB_DEF = { field: 'hvdcAngleDroopActivePowerControl.isEnabled', boolean: true, cellRenderer: BooleanCellRenderer, - ...defaultBooleanFilterConfig, + type: TEXT_FILTER, getQuickFilterText: excludeFromGlobalFilter, }, { id: 'K', field: 'hvdcAngleDroopActivePowerControl.droop', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 1, getQuickFilterText: excludeFromGlobalFilter, }, @@ -143,7 +141,7 @@ export const HVDC_LINE_TAB_DEF = { id: 'P0', field: 'hvdcAngleDroopActivePowerControl.p0', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 1, getQuickFilterText: excludeFromGlobalFilter, }, diff --git a/src/components/spreadsheet/config/equipment/lcc-converter-station.ts b/src/components/spreadsheet/config/equipment/lcc-converter-station.ts index 35cd1c14d7..c72fbfe228 100644 --- a/src/components/spreadsheet/config/equipment/lcc-converter-station.ts +++ b/src/components/spreadsheet/config/equipment/lcc-converter-station.ts @@ -10,15 +10,9 @@ import type { SpreadsheetTabDefinition } from '../spreadsheet.type'; import { EQUIPMENT_TYPES } from '../../../utils/equipment-types'; import CountryCellRenderer from '../../utils/country-cell-render'; import { BooleanCellRenderer } from '../../utils/cell-renderers'; -import { - countryEnumFilterConfig, - defaultBooleanFilterConfig, - defaultNumericFilterConfig, - defaultTextFilterConfig, - excludeFromGlobalFilter, - typeAndFetchers, -} from './common-config'; +import { excludeFromGlobalFilter, typeAndFetchers } from './common-config'; import { genericColumnOfProperties } from '../common/column-properties'; +import { COUNTRY_FILTER, NUMERIC_FILTER, TEXT_FILTER } from 'components/spreadsheet/utils/constants'; export const LCC_CONVERTER_STATION_TAB_DEF = { index: 11, @@ -29,41 +23,41 @@ export const LCC_CONVERTER_STATION_TAB_DEF = { id: 'ID', field: 'id', isDefaultSort: true, - ...defaultTextFilterConfig, + type: TEXT_FILTER, }, { id: 'Name', field: 'name', - ...defaultTextFilterConfig, + type: TEXT_FILTER, }, { id: 'VoltageLevelId', field: 'voltageLevelId', - ...defaultTextFilterConfig, + type: TEXT_FILTER, }, { id: 'Country', field: 'country', - ...countryEnumFilterConfig, + type: COUNTRY_FILTER, cellRenderer: CountryCellRenderer, }, { id: 'NominalV', field: 'nominalV', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 0, }, { id: 'HvdcLineId', field: 'hvdcLineId', - ...defaultTextFilterConfig, + type: TEXT_FILTER, }, { id: 'activePower', field: 'p', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 1, canBeInvalidated: true, getQuickFilterText: excludeFromGlobalFilter, @@ -72,7 +66,7 @@ export const LCC_CONVERTER_STATION_TAB_DEF = { id: 'ReactivePower', field: 'q', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 1, canBeInvalidated: true, getQuickFilterText: excludeFromGlobalFilter, @@ -81,7 +75,7 @@ export const LCC_CONVERTER_STATION_TAB_DEF = { id: 'PowerFactor', field: 'powerFactor', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 1, getQuickFilterText: excludeFromGlobalFilter, }, @@ -89,7 +83,7 @@ export const LCC_CONVERTER_STATION_TAB_DEF = { id: 'LossFactor', field: 'lossFactor', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 1, getQuickFilterText: excludeFromGlobalFilter, }, @@ -98,7 +92,7 @@ export const LCC_CONVERTER_STATION_TAB_DEF = { field: 'terminalConnected', boolean: true, cellRenderer: BooleanCellRenderer, - ...defaultBooleanFilterConfig, + type: TEXT_FILTER, getQuickFilterText: excludeFromGlobalFilter, }, genericColumnOfProperties, diff --git a/src/components/spreadsheet/config/equipment/line.ts b/src/components/spreadsheet/config/equipment/line.ts index 6585d2dfdc..055847067c 100644 --- a/src/components/spreadsheet/config/equipment/line.ts +++ b/src/components/spreadsheet/config/equipment/line.ts @@ -10,15 +10,14 @@ import type { SpreadsheetTabDefinition } from '../spreadsheet.type'; import { EQUIPMENT_TYPES } from '../../../utils/equipment-types'; import CountryCellRenderer from '../../utils/country-cell-render'; import { BooleanCellRenderer } from '../../utils/cell-renderers'; +import { excludeFromGlobalFilter, typeAndFetchers } from './common-config'; import { - countryEnumFilterConfig, - defaultBooleanFilterConfig, - defaultNumericFilterConfig, - defaultTextFilterConfig, - excludeFromGlobalFilter, - typeAndFetchers, -} from './common-config'; -import { MEDIUM_COLUMN_WIDTH } from '../../utils/constants'; + BOOLEAN_FILTER, + COUNTRY_FILTER, + MEDIUM_COLUMN_WIDTH, + NUMERIC_FILTER, + TEXT_FILTER, +} from '../../utils/constants'; import { unitToMicroUnit } from '../../../../utils/unit-converter'; import { genericColumnOfProperties } from '../common/column-properties'; @@ -32,55 +31,55 @@ export const LINE_TAB_DEF = { field: 'id', columnWidth: MEDIUM_COLUMN_WIDTH, isDefaultSort: true, - ...defaultTextFilterConfig, + type: TEXT_FILTER, }, { id: 'Name', field: 'name', columnWidth: MEDIUM_COLUMN_WIDTH, - ...defaultTextFilterConfig, + type: TEXT_FILTER, }, { id: 'VoltageLevelIdSide1', field: 'voltageLevelId1', - ...defaultTextFilterConfig, + type: TEXT_FILTER, }, { id: 'VoltageLevelIdSide2', field: 'voltageLevelId2', - ...defaultTextFilterConfig, + type: TEXT_FILTER, }, { id: 'Country1', field: 'country1', - ...countryEnumFilterConfig, + type: COUNTRY_FILTER, cellRenderer: CountryCellRenderer, }, { id: 'Country2', field: 'country2', - ...countryEnumFilterConfig, + type: COUNTRY_FILTER, cellRenderer: CountryCellRenderer, }, { id: 'nominalVoltage1KV', field: 'nominalVoltage1', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 0, }, { id: 'nominalVoltage2KV', field: 'nominalVoltage2', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 0, }, { id: 'ActivePowerSide1', field: 'p1', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 1, canBeInvalidated: true, getQuickFilterText: excludeFromGlobalFilter, @@ -89,7 +88,7 @@ export const LINE_TAB_DEF = { id: 'ActivePowerSide2', field: 'p2', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 1, canBeInvalidated: true, getQuickFilterText: excludeFromGlobalFilter, @@ -98,7 +97,7 @@ export const LINE_TAB_DEF = { id: 'ReactivePowerSide1', field: 'q1', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 1, canBeInvalidated: true, getQuickFilterText: excludeFromGlobalFilter, @@ -107,7 +106,7 @@ export const LINE_TAB_DEF = { id: 'ReactivePowerSide2', field: 'q2', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 1, canBeInvalidated: true, getQuickFilterText: excludeFromGlobalFilter, @@ -116,7 +115,7 @@ export const LINE_TAB_DEF = { id: 'r', field: 'r', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 1, getQuickFilterText: excludeFromGlobalFilter, }, @@ -124,7 +123,7 @@ export const LINE_TAB_DEF = { id: 'x', field: 'x', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 1, getQuickFilterText: excludeFromGlobalFilter, }, @@ -132,7 +131,7 @@ export const LINE_TAB_DEF = { id: 'g1', field: 'g1', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 1, valueGetter: (params) => unitToMicroUnit(params.data.g1), getQuickFilterText: excludeFromGlobalFilter, @@ -141,7 +140,7 @@ export const LINE_TAB_DEF = { id: 'g2', field: 'g2', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 1, valueGetter: (params) => unitToMicroUnit(params.data.g2), getQuickFilterText: excludeFromGlobalFilter, @@ -150,7 +149,7 @@ export const LINE_TAB_DEF = { id: 'b1', field: 'b1', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 1, valueGetter: (params) => unitToMicroUnit(params.data.b1), getQuickFilterText: excludeFromGlobalFilter, @@ -159,7 +158,7 @@ export const LINE_TAB_DEF = { id: 'b2', field: 'b2', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 1, valueGetter: (params) => unitToMicroUnit(params.data.b2), getQuickFilterText: excludeFromGlobalFilter, @@ -169,7 +168,7 @@ export const LINE_TAB_DEF = { field: 'terminal1Connected', boolean: true, cellRenderer: BooleanCellRenderer, - ...defaultBooleanFilterConfig, + type: BOOLEAN_FILTER, getQuickFilterText: excludeFromGlobalFilter, }, { @@ -177,7 +176,7 @@ export const LINE_TAB_DEF = { field: 'terminal2Connected', boolean: true, cellRenderer: BooleanCellRenderer, - ...defaultBooleanFilterConfig, + type: BOOLEAN_FILTER, getQuickFilterText: excludeFromGlobalFilter, }, genericColumnOfProperties, diff --git a/src/components/spreadsheet/config/equipment/load.ts b/src/components/spreadsheet/config/equipment/load.ts index f11528fcc7..477a536163 100644 --- a/src/components/spreadsheet/config/equipment/load.ts +++ b/src/components/spreadsheet/config/equipment/load.ts @@ -10,17 +10,8 @@ import type { SpreadsheetTabDefinition } from '../spreadsheet.type'; import { EQUIPMENT_TYPES } from '../../../utils/equipment-types'; import CountryCellRenderer from '../../utils/country-cell-render'; import { BooleanCellRenderer } from '../../utils/cell-renderers'; -import { - countryEnumFilterConfig, - defaultBooleanFilterConfig, - defaultNumericFilterConfig, - defaultTextFilterConfig, - editableColumnConfig, - excludeFromGlobalFilter, - getDefaultEnumConfig, - typeAndFetchers, -} from './common-config'; -import { MEDIUM_COLUMN_WIDTH } from '../../utils/constants'; +import { editableColumnConfig, excludeFromGlobalFilter, getDefaultEnumConfig, typeAndFetchers } from './common-config'; +import { COUNTRY_FILTER, MEDIUM_COLUMN_WIDTH, NUMERIC_FILTER, TEXT_FILTER } from '../../utils/constants'; import { LOAD_TYPES } from '../../../network/constants'; import { genericColumnOfPropertiesEditPopup } from '../common/column-properties'; import { enumCellEditorConfig, numericalCellEditorConfig } from '../common/cell-editors'; @@ -35,12 +26,12 @@ export const LOAD_TAB_DEF = { field: 'id', columnWidth: MEDIUM_COLUMN_WIDTH, isDefaultSort: true, - ...defaultTextFilterConfig, + type: TEXT_FILTER, }, { id: 'Name', field: 'name', - ...defaultTextFilterConfig, + type: TEXT_FILTER, columnWidth: MEDIUM_COLUMN_WIDTH, ...editableColumnConfig, }, @@ -57,26 +48,26 @@ export const LOAD_TAB_DEF = { { id: 'VoltageLevelId', field: 'voltageLevelId', - ...defaultTextFilterConfig, + type: TEXT_FILTER, }, { id: 'Country', field: 'country', - ...countryEnumFilterConfig, + type: COUNTRY_FILTER, cellRenderer: CountryCellRenderer, }, { id: 'NominalV', field: 'nominalVoltage', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 0, }, { id: 'activePower', field: 'p', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 1, canBeInvalidated: true, getQuickFilterText: excludeFromGlobalFilter, @@ -85,7 +76,7 @@ export const LOAD_TAB_DEF = { id: 'ReactivePower', field: 'q', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 1, canBeInvalidated: true, getQuickFilterText: excludeFromGlobalFilter, @@ -94,7 +85,7 @@ export const LOAD_TAB_DEF = { id: 'p0', field: 'p0', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 1, ...editableColumnConfig, ...numericalCellEditorConfig((params) => params.data.p0), @@ -104,7 +95,7 @@ export const LOAD_TAB_DEF = { id: 'q0', field: 'q0', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 1, ...editableColumnConfig, ...numericalCellEditorConfig((params) => params.data.q0), @@ -115,7 +106,7 @@ export const LOAD_TAB_DEF = { field: 'terminalConnected', boolean: true, cellRenderer: BooleanCellRenderer, - ...defaultBooleanFilterConfig, + type: TEXT_FILTER, getQuickFilterText: excludeFromGlobalFilter, }, genericColumnOfPropertiesEditPopup, diff --git a/src/components/spreadsheet/config/equipment/shunt-compensator.ts b/src/components/spreadsheet/config/equipment/shunt-compensator.ts index 0bdd172528..9620c81945 100644 --- a/src/components/spreadsheet/config/equipment/shunt-compensator.ts +++ b/src/components/spreadsheet/config/equipment/shunt-compensator.ts @@ -11,16 +11,19 @@ import { EQUIPMENT_TYPES } from '../../../utils/equipment-types'; import CountryCellRenderer from '../../utils/country-cell-render'; import { BooleanCellRenderer } from '../../utils/cell-renderers'; import { - countryEnumFilterConfig, - defaultBooleanFilterConfig, defaultNumericFilterConfig, - defaultTextFilterConfig, editableColumnConfig, excludeFromGlobalFilter, getDefaultEnumConfig, typeAndFetchers, } from './common-config'; -import { MEDIUM_COLUMN_WIDTH, MIN_COLUMN_WIDTH } from '../../utils/constants'; +import { + COUNTRY_FILTER, + MEDIUM_COLUMN_WIDTH, + MIN_COLUMN_WIDTH, + NUMERIC_FILTER, + TEXT_FILTER, +} from '../../utils/constants'; import { SHUNT_COMPENSATOR_TYPES } from '../../../network/constants'; import { genericColumnOfPropertiesEditPopup } from '../common/column-properties'; import { enumCellEditorConfig, numericalCellEditorConfig } from '../common/cell-editors'; @@ -35,24 +38,24 @@ export const SHUNT_COMPENSATOR_TAB_DEF = { field: 'id', columnWidth: MEDIUM_COLUMN_WIDTH, isDefaultSort: true, - ...defaultTextFilterConfig, + type: TEXT_FILTER, }, { id: 'Name', field: 'name', - ...defaultTextFilterConfig, + type: TEXT_FILTER, ...editableColumnConfig, columnWidth: MIN_COLUMN_WIDTH, }, { id: 'VoltageLevelId', field: 'voltageLevelId', - ...defaultTextFilterConfig, + type: TEXT_FILTER, }, { id: 'Country', field: 'country', - ...countryEnumFilterConfig, + type: COUNTRY_FILTER, cellRenderer: CountryCellRenderer, }, { @@ -67,7 +70,7 @@ export const SHUNT_COMPENSATOR_TAB_DEF = { field: 'q', numeric: true, fractionDigits: 1, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, canBeInvalidated: true, withFluxConvention: true, getQuickFilterText: excludeFromGlobalFilter, @@ -78,7 +81,7 @@ export const SHUNT_COMPENSATOR_TAB_DEF = { ...editableColumnConfig, numeric: true, ...numericalCellEditorConfig((params) => params.data.maximumSectionCount), - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, getQuickFilterText: excludeFromGlobalFilter, crossValidation: { minExpression: 1, @@ -90,7 +93,7 @@ export const SHUNT_COMPENSATOR_TAB_DEF = { ...editableColumnConfig, numeric: true, ...numericalCellEditorConfig((params) => params.data.sectionCount), - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, getQuickFilterText: excludeFromGlobalFilter, crossValidation: { minExpression: 0, @@ -110,7 +113,7 @@ export const SHUNT_COMPENSATOR_TAB_DEF = { ...editableColumnConfig, numeric: true, ...numericalCellEditorConfig((params) => params.data.maxQAtNominalV), - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 1, getQuickFilterText: excludeFromGlobalFilter, crossValidation: { @@ -123,7 +126,7 @@ export const SHUNT_COMPENSATOR_TAB_DEF = { numeric: true, valueGetter: (params) => (params?.data?.maxQAtNominalV / params?.data?.maximumSectionCount) * params?.data?.sectionCount, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 1, getQuickFilterText: excludeFromGlobalFilter, }, @@ -133,7 +136,7 @@ export const SHUNT_COMPENSATOR_TAB_DEF = { field: 'maxSusceptance', numeric: true, ...numericalCellEditorConfig((params) => params.data.maxSusceptance), - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 5, getQuickFilterText: excludeFromGlobalFilter, }, @@ -143,7 +146,7 @@ export const SHUNT_COMPENSATOR_TAB_DEF = { numeric: true, valueGetter: (params) => (params?.data?.maxSusceptance / params?.data?.maximumSectionCount) * params?.data?.sectionCount, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 5, getQuickFilterText: excludeFromGlobalFilter, }, @@ -151,7 +154,7 @@ export const SHUNT_COMPENSATOR_TAB_DEF = { id: 'voltageSetpoint', field: 'targetV', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 1, getQuickFilterText: excludeFromGlobalFilter, }, @@ -160,7 +163,7 @@ export const SHUNT_COMPENSATOR_TAB_DEF = { field: 'terminalConnected', boolean: true, cellRenderer: BooleanCellRenderer, - ...defaultBooleanFilterConfig, + type: TEXT_FILTER, getQuickFilterText: excludeFromGlobalFilter, }, genericColumnOfPropertiesEditPopup, diff --git a/src/components/spreadsheet/config/equipment/static-var-compensator.ts b/src/components/spreadsheet/config/equipment/static-var-compensator.ts index 2889d9cb29..1b696b1c90 100644 --- a/src/components/spreadsheet/config/equipment/static-var-compensator.ts +++ b/src/components/spreadsheet/config/equipment/static-var-compensator.ts @@ -10,15 +10,8 @@ import type { SpreadsheetTabDefinition } from '../spreadsheet.type'; import { EQUIPMENT_TYPES } from '../../../utils/equipment-types'; import CountryCellRenderer from '../../utils/country-cell-render'; import { BooleanCellRenderer } from '../../utils/cell-renderers'; -import { - countryEnumFilterConfig, - defaultBooleanFilterConfig, - defaultNumericFilterConfig, - defaultTextFilterConfig, - excludeFromGlobalFilter, - typeAndFetchers, -} from './common-config'; -import { MEDIUM_COLUMN_WIDTH } from '../../utils/constants'; +import { excludeFromGlobalFilter, typeAndFetchers } from './common-config'; +import { COUNTRY_FILTER, MEDIUM_COLUMN_WIDTH, NUMERIC_FILTER, TEXT_FILTER } from '../../utils/constants'; import { NOMINAL_V } from '../../../utils/field-constants'; import { genericColumnOfProperties } from '../common/column-properties'; @@ -31,36 +24,36 @@ export const STATIC_VAR_COMPENSATOR_TAB_DEF = { id: 'ID', field: 'id', isDefaultSort: true, - ...defaultTextFilterConfig, + type: TEXT_FILTER, }, { id: 'Name', field: 'name', - ...defaultTextFilterConfig, + type: TEXT_FILTER, }, { id: 'VoltageLevelId', field: 'voltageLevelId', - ...defaultTextFilterConfig, + type: TEXT_FILTER, }, { id: 'Country', field: 'country', - ...countryEnumFilterConfig, + type: COUNTRY_FILTER, cellRenderer: CountryCellRenderer, }, { id: 'NominalV', field: NOMINAL_V, numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 0, }, { id: 'activePower', field: 'p', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 1, canBeInvalidated: true, getQuickFilterText: excludeFromGlobalFilter, @@ -69,7 +62,7 @@ export const STATIC_VAR_COMPENSATOR_TAB_DEF = { id: 'ReactivePower', field: 'q', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 1, canBeInvalidated: true, getQuickFilterText: excludeFromGlobalFilter, @@ -78,7 +71,7 @@ export const STATIC_VAR_COMPENSATOR_TAB_DEF = { id: 'VoltageSetpointKV', field: 'voltageSetpoint', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 1, getQuickFilterText: excludeFromGlobalFilter, }, @@ -86,7 +79,7 @@ export const STATIC_VAR_COMPENSATOR_TAB_DEF = { id: 'ReactivePowerSetpointMVAR', field: 'reactivePowerSetpoint', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 1, columnWidth: MEDIUM_COLUMN_WIDTH, getQuickFilterText: excludeFromGlobalFilter, @@ -96,7 +89,7 @@ export const STATIC_VAR_COMPENSATOR_TAB_DEF = { field: 'terminalConnected', boolean: true, cellRenderer: BooleanCellRenderer, - ...defaultBooleanFilterConfig, + type: TEXT_FILTER, getQuickFilterText: excludeFromGlobalFilter, }, genericColumnOfProperties, diff --git a/src/components/spreadsheet/config/equipment/substation.ts b/src/components/spreadsheet/config/equipment/substation.ts index 5a0981f8e7..eadcd3e1b7 100644 --- a/src/components/spreadsheet/config/equipment/substation.ts +++ b/src/components/spreadsheet/config/equipment/substation.ts @@ -10,13 +10,9 @@ import type { SpreadsheetTabDefinition } from '../spreadsheet.type'; import { EQUIPMENT_TYPES } from '../../../utils/equipment-types'; import { SelectCountryField } from '../../utils/equipment-table-editors'; import CountryCellRenderer from '../../utils/country-cell-render'; -import { - countryEnumFilterConfig, - defaultTextFilterConfig, - editableColumnConfig, - typeAndFetchers, -} from './common-config'; +import { editableColumnConfig, typeAndFetchers } from './common-config'; import { genericColumnOfPropertiesEditPopup } from '../common/column-properties'; +import { COUNTRY_FILTER, TEXT_FILTER } from 'components/spreadsheet/utils/constants'; export const SUBSTATION_TAB_DEF = { index: 0, @@ -26,14 +22,14 @@ export const SUBSTATION_TAB_DEF = { { id: 'ID', field: 'id', - ...defaultTextFilterConfig, + type: TEXT_FILTER, isDefaultSort: true, }, { id: 'Name', field: 'name', ...editableColumnConfig, - ...defaultTextFilterConfig, + type: TEXT_FILTER, }, { id: 'Country', @@ -45,7 +41,7 @@ export const SUBSTATION_TAB_DEF = { params.data.country = params?.newValue; return true; }, - ...countryEnumFilterConfig, + type: COUNTRY_FILTER, }, genericColumnOfPropertiesEditPopup, // FIXME try valueFormatter? ], diff --git a/src/components/spreadsheet/config/equipment/three-windings-transformer.ts b/src/components/spreadsheet/config/equipment/three-windings-transformer.ts index a078bbdcec..895628fba3 100644 --- a/src/components/spreadsheet/config/equipment/three-windings-transformer.ts +++ b/src/components/spreadsheet/config/equipment/three-windings-transformer.ts @@ -10,18 +10,8 @@ import type { SpreadsheetTabDefinition } from '../spreadsheet.type'; import { EQUIPMENT_TYPES } from '../../../utils/equipment-types'; import CountryCellRenderer from '../../utils/country-cell-render'; import { BooleanCellRenderer } from '../../utils/cell-renderers'; -import { - countryEnumFilterConfig, - defaultBooleanFilterConfig, - defaultEnumFilterConfig, - defaultNumericFilterConfig, - defaultTextFilterConfig, - editableColumnConfig, - excludeFromGlobalFilter, - generateTapPositions, - typeAndFetchers, -} from './common-config'; -import { MEDIUM_COLUMN_WIDTH } from '../../utils/constants'; +import { editableColumnConfig, excludeFromGlobalFilter, generateTapPositions, typeAndFetchers } from './common-config'; +import { COUNTRY_FILTER, MEDIUM_COLUMN_WIDTH, NUMERIC_FILTER, TEXT_FILTER } from '../../utils/constants'; import { genericColumnOfProperties } from '../common/column-properties'; import { standardSelectCellEditorConfig } from '../common/cell-editors'; @@ -48,60 +38,60 @@ export const THREE_WINDINGS_TRANSFORMER_TAB_DEF = { id: 'ID', field: 'id', isDefaultSort: true, - ...defaultTextFilterConfig, + type: TEXT_FILTER, }, { id: 'Name', field: 'name', - ...defaultTextFilterConfig, + type: TEXT_FILTER, }, { id: 'VoltageLevelIdT3WSide1', field: 'voltageLevelId1', - ...defaultTextFilterConfig, + type: TEXT_FILTER, }, { id: 'VoltageLevelIdT3WSide2', field: 'voltageLevelId2', - ...defaultTextFilterConfig, + type: TEXT_FILTER, }, { id: 'VoltageLevelIdT3WSide3', field: 'voltageLevelId3', - ...defaultTextFilterConfig, + type: TEXT_FILTER, }, { id: 'Country', field: 'country', - ...countryEnumFilterConfig, + type: COUNTRY_FILTER, cellRenderer: CountryCellRenderer, }, { id: 'NominalVT3WSide1', field: 'nominalV1', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 0, }, { id: 'NominalVT3WSide2', field: 'nominalV2', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 0, }, { id: 'NominalVT3WSide3', field: 'nominalV3', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 0, }, { id: 'ActivePowerT3WSide1', field: 'p1', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 1, canBeInvalidated: true, getQuickFilterText: excludeFromGlobalFilter, @@ -110,7 +100,7 @@ export const THREE_WINDINGS_TRANSFORMER_TAB_DEF = { id: 'ActivePowerT3WSide2', field: 'p2', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 1, canBeInvalidated: true, getQuickFilterText: excludeFromGlobalFilter, @@ -119,7 +109,7 @@ export const THREE_WINDINGS_TRANSFORMER_TAB_DEF = { id: 'ActivePowerT3WSide3', field: 'p3', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 1, canBeInvalidated: true, getQuickFilterText: excludeFromGlobalFilter, @@ -128,7 +118,7 @@ export const THREE_WINDINGS_TRANSFORMER_TAB_DEF = { id: 'ReactivePowerT3WSide1', field: 'q1', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 1, canBeInvalidated: true, getQuickFilterText: excludeFromGlobalFilter, @@ -137,7 +127,7 @@ export const THREE_WINDINGS_TRANSFORMER_TAB_DEF = { id: 'ReactivePowerT3WSide2', field: 'q2', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 1, canBeInvalidated: true, getQuickFilterText: excludeFromGlobalFilter, @@ -146,7 +136,7 @@ export const THREE_WINDINGS_TRANSFORMER_TAB_DEF = { id: 'ReactivePowerT3WSide3', field: 'q3', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 1, canBeInvalidated: true, getQuickFilterText: excludeFromGlobalFilter, @@ -156,7 +146,7 @@ export const THREE_WINDINGS_TRANSFORMER_TAB_DEF = { field: 'hasLoadTapChanging1Capabilities', boolean: true, cellRenderer: BooleanCellRenderer, - ...defaultBooleanFilterConfig, + type: TEXT_FILTER, getQuickFilterText: excludeFromGlobalFilter, }, { @@ -164,21 +154,21 @@ export const THREE_WINDINGS_TRANSFORMER_TAB_DEF = { field: 'isRegulatingRatio1', boolean: true, cellRenderer: BooleanCellRenderer, - ...defaultBooleanFilterConfig, + type: TEXT_FILTER, getQuickFilterText: excludeFromGlobalFilter, }, { id: 'TargetVPoint1', field: 'targetV1', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 1, getQuickFilterText: excludeFromGlobalFilter, }, { id: 'RatioTap1', field: 'ratioTapChanger1', - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, changeCmd: generateTapRequest('Ratio', 1), fractionDigits: 0, valueGetter: (params) => params?.data?.ratioTapChanger1?.tapPosition, @@ -198,7 +188,7 @@ export const THREE_WINDINGS_TRANSFORMER_TAB_DEF = { field: 'hasLoadTapChanging2Capabilities', boolean: true, cellRenderer: BooleanCellRenderer, - ...defaultBooleanFilterConfig, + type: TEXT_FILTER, getQuickFilterText: excludeFromGlobalFilter, }, { @@ -206,21 +196,21 @@ export const THREE_WINDINGS_TRANSFORMER_TAB_DEF = { field: 'isRegulatingRatio2', boolean: true, cellRenderer: BooleanCellRenderer, - ...defaultBooleanFilterConfig, + type: TEXT_FILTER, getQuickFilterText: excludeFromGlobalFilter, }, { id: 'TargetVPoint2', field: 'targetV2', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 1, getQuickFilterText: excludeFromGlobalFilter, }, { id: 'RatioTap2', field: 'ratioTapChanger2', - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, changeCmd: generateTapRequest('Ratio', 2), fractionDigits: 0, valueGetter: (params) => params?.data?.ratioTapChanger2?.tapPosition, @@ -240,7 +230,7 @@ export const THREE_WINDINGS_TRANSFORMER_TAB_DEF = { field: 'hasLoadTapChanging3Capabilities', boolean: true, cellRenderer: BooleanCellRenderer, - ...defaultBooleanFilterConfig, + type: TEXT_FILTER, getQuickFilterText: excludeFromGlobalFilter, }, { @@ -248,21 +238,21 @@ export const THREE_WINDINGS_TRANSFORMER_TAB_DEF = { field: 'isRegulatingRatio3', boolean: true, cellRenderer: BooleanCellRenderer, - ...defaultBooleanFilterConfig, + type: TEXT_FILTER, getQuickFilterText: excludeFromGlobalFilter, }, { id: 'TargetVPoint3', field: 'targetV3', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 1, getQuickFilterText: excludeFromGlobalFilter, }, { id: 'RatioTap3', field: 'ratioTapChanger3', - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, changeCmd: generateTapRequest('Ratio', 3), fractionDigits: 0, valueGetter: (params) => params?.data?.ratioTapChanger3?.tapPosition, @@ -280,7 +270,7 @@ export const THREE_WINDINGS_TRANSFORMER_TAB_DEF = { { id: 'RegulatingMode1', field: 'regulationModeName1', - ...defaultEnumFilterConfig, + type: NUMERIC_FILTER, columnWidth: MEDIUM_COLUMN_WIDTH, getQuickFilterText: excludeFromGlobalFilter, }, @@ -289,13 +279,13 @@ export const THREE_WINDINGS_TRANSFORMER_TAB_DEF = { field: 'isRegulatingPhase1', boolean: true, cellRenderer: BooleanCellRenderer, - ...defaultBooleanFilterConfig, + type: TEXT_FILTER, getQuickFilterText: excludeFromGlobalFilter, }, { id: 'PhaseTap1', field: 'phaseTapChanger1', - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, changeCmd: generateTapRequest('Phase', 1), fractionDigits: 0, valueGetter: (params) => params?.data?.phaseTapChanger1?.tapPosition, @@ -314,7 +304,7 @@ export const THREE_WINDINGS_TRANSFORMER_TAB_DEF = { id: 'RegulatingValue1', field: 'regulatingValue1', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, columnWidth: MEDIUM_COLUMN_WIDTH, fractionDigits: 1, getQuickFilterText: excludeFromGlobalFilter, @@ -322,7 +312,7 @@ export const THREE_WINDINGS_TRANSFORMER_TAB_DEF = { { id: 'RegulatingMode2', field: 'regulationModeName2', - ...defaultEnumFilterConfig, + type: NUMERIC_FILTER, columnWidth: MEDIUM_COLUMN_WIDTH, getQuickFilterText: excludeFromGlobalFilter, }, @@ -331,13 +321,13 @@ export const THREE_WINDINGS_TRANSFORMER_TAB_DEF = { field: 'isRegulatingPhase2', boolean: true, cellRenderer: BooleanCellRenderer, - ...defaultBooleanFilterConfig, + type: TEXT_FILTER, getQuickFilterText: excludeFromGlobalFilter, }, { id: 'PhaseTap2', field: 'phaseTapChanger2', - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, changeCmd: generateTapRequest('Phase', 2), fractionDigits: 0, valueGetter: (params) => params?.data?.phaseTapChanger2?.tapPosition, @@ -356,7 +346,7 @@ export const THREE_WINDINGS_TRANSFORMER_TAB_DEF = { id: 'RegulatingValue2', field: 'regulatingValue2', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, columnWidth: MEDIUM_COLUMN_WIDTH, fractionDigits: 1, getQuickFilterText: excludeFromGlobalFilter, @@ -364,7 +354,7 @@ export const THREE_WINDINGS_TRANSFORMER_TAB_DEF = { { id: 'RegulatingMode3', field: 'regulationModeName3', - ...defaultEnumFilterConfig, + type: NUMERIC_FILTER, columnWidth: MEDIUM_COLUMN_WIDTH, getQuickFilterText: excludeFromGlobalFilter, }, @@ -373,13 +363,13 @@ export const THREE_WINDINGS_TRANSFORMER_TAB_DEF = { field: 'isRegulatingPhase3', boolean: true, cellRenderer: BooleanCellRenderer, - ...defaultBooleanFilterConfig, + type: TEXT_FILTER, getQuickFilterText: excludeFromGlobalFilter, }, { id: 'PhaseTap3', field: 'phaseTapChanger3', - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, changeCmd: generateTapRequest('Phase', 3), fractionDigits: 0, valueGetter: (params) => params?.data?.phaseTapChanger3?.tapPosition, @@ -398,7 +388,7 @@ export const THREE_WINDINGS_TRANSFORMER_TAB_DEF = { id: 'RegulatingValue3', field: 'regulatingValue3', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, columnWidth: MEDIUM_COLUMN_WIDTH, fractionDigits: 1, getQuickFilterText: excludeFromGlobalFilter, @@ -408,7 +398,7 @@ export const THREE_WINDINGS_TRANSFORMER_TAB_DEF = { field: 'terminal1Connected', boolean: true, cellRenderer: BooleanCellRenderer, - ...defaultBooleanFilterConfig, + type: TEXT_FILTER, getQuickFilterText: excludeFromGlobalFilter, }, { @@ -416,7 +406,7 @@ export const THREE_WINDINGS_TRANSFORMER_TAB_DEF = { field: 'terminal2Connected', boolean: true, cellRenderer: BooleanCellRenderer, - ...defaultBooleanFilterConfig, + type: TEXT_FILTER, getQuickFilterText: excludeFromGlobalFilter, }, { @@ -424,7 +414,7 @@ export const THREE_WINDINGS_TRANSFORMER_TAB_DEF = { field: 'terminal3Connected', boolean: true, cellRenderer: BooleanCellRenderer, - ...defaultBooleanFilterConfig, + type: TEXT_FILTER, getQuickFilterText: excludeFromGlobalFilter, }, genericColumnOfProperties, diff --git a/src/components/spreadsheet/config/equipment/tie-line.ts b/src/components/spreadsheet/config/equipment/tie-line.ts index 08e6cbe1f0..1c52b4f635 100644 --- a/src/components/spreadsheet/config/equipment/tie-line.ts +++ b/src/components/spreadsheet/config/equipment/tie-line.ts @@ -10,15 +10,8 @@ import type { SpreadsheetTabDefinition } from '../spreadsheet.type'; import { EQUIPMENT_TYPES } from '../../../utils/equipment-types'; import CountryCellRenderer from '../../utils/country-cell-render'; import { BooleanCellRenderer } from '../../utils/cell-renderers'; -import { - countryEnumFilterConfig, - defaultBooleanFilterConfig, - defaultNumericFilterConfig, - defaultTextFilterConfig, - excludeFromGlobalFilter, - typeAndFetchers, -} from './common-config'; -import { MEDIUM_COLUMN_WIDTH } from '../../utils/constants'; +import { excludeFromGlobalFilter, typeAndFetchers } from './common-config'; +import { COUNTRY_FILTER, MEDIUM_COLUMN_WIDTH, NUMERIC_FILTER, TEXT_FILTER } from '../../utils/constants'; import { unitToMicroUnit } from '../../../../utils/unit-converter'; import { genericColumnOfPropertiesReadonly } from '../common/column-properties'; @@ -32,55 +25,55 @@ export const TIE_LINE_TAB_DEF = { field: 'id', columnWidth: MEDIUM_COLUMN_WIDTH, isDefaultSort: true, - ...defaultTextFilterConfig, + type: TEXT_FILTER, }, { id: 'Name', field: 'name', columnWidth: MEDIUM_COLUMN_WIDTH, - ...defaultTextFilterConfig, + type: TEXT_FILTER, }, { id: 'VoltageLevelIdSide1', field: 'voltageLevelId1', - ...defaultTextFilterConfig, + type: TEXT_FILTER, }, { id: 'VoltageLevelIdSide2', field: 'voltageLevelId2', - ...defaultTextFilterConfig, + type: TEXT_FILTER, }, { id: 'Country1', field: 'country1', - ...countryEnumFilterConfig, + type: COUNTRY_FILTER, cellRenderer: CountryCellRenderer, }, { id: 'Country2', field: 'country2', - ...countryEnumFilterConfig, + type: COUNTRY_FILTER, cellRenderer: CountryCellRenderer, }, { id: 'nominalVoltage1KV', field: 'nominalVoltage1', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 0, }, { id: 'nominalVoltage2KV', field: 'nominalVoltage2', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 0, }, { id: 'ActivePowerSide1', field: 'p1', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 1, canBeInvalidated: true, getQuickFilterText: excludeFromGlobalFilter, @@ -89,7 +82,7 @@ export const TIE_LINE_TAB_DEF = { id: 'ActivePowerSide2', field: 'p2', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 1, canBeInvalidated: true, getQuickFilterText: excludeFromGlobalFilter, @@ -98,7 +91,7 @@ export const TIE_LINE_TAB_DEF = { id: 'ReactivePowerSide1', field: 'q1', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 1, canBeInvalidated: true, getQuickFilterText: excludeFromGlobalFilter, @@ -107,7 +100,7 @@ export const TIE_LINE_TAB_DEF = { id: 'ReactivePowerSide2', field: 'q2', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 1, canBeInvalidated: true, getQuickFilterText: excludeFromGlobalFilter, @@ -116,7 +109,7 @@ export const TIE_LINE_TAB_DEF = { id: 'r', field: 'r', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 1, getQuickFilterText: excludeFromGlobalFilter, }, @@ -124,7 +117,7 @@ export const TIE_LINE_TAB_DEF = { id: 'x', field: 'x', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 1, getQuickFilterText: excludeFromGlobalFilter, }, @@ -132,7 +125,7 @@ export const TIE_LINE_TAB_DEF = { id: 'g1', field: 'g1', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 1, valueGetter: (params) => unitToMicroUnit(params.data.g1), getQuickFilterText: excludeFromGlobalFilter, @@ -141,7 +134,7 @@ export const TIE_LINE_TAB_DEF = { id: 'g2', field: 'g2', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 1, valueGetter: (params) => unitToMicroUnit(params.data.g2), getQuickFilterText: excludeFromGlobalFilter, @@ -150,7 +143,7 @@ export const TIE_LINE_TAB_DEF = { id: 'b1', field: 'b1', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 1, valueGetter: (params) => unitToMicroUnit(params.data.b1), getQuickFilterText: excludeFromGlobalFilter, @@ -159,7 +152,7 @@ export const TIE_LINE_TAB_DEF = { id: 'b2', field: 'b2', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 1, valueGetter: (params) => unitToMicroUnit(params.data.b2), getQuickFilterText: excludeFromGlobalFilter, @@ -169,7 +162,7 @@ export const TIE_LINE_TAB_DEF = { field: 'terminal1Connected', boolean: true, cellRenderer: BooleanCellRenderer, - ...defaultBooleanFilterConfig, + type: TEXT_FILTER, getQuickFilterText: excludeFromGlobalFilter, }, { @@ -177,7 +170,7 @@ export const TIE_LINE_TAB_DEF = { field: 'terminal2Connected', boolean: true, cellRenderer: BooleanCellRenderer, - ...defaultBooleanFilterConfig, + type: TEXT_FILTER, getQuickFilterText: excludeFromGlobalFilter, }, genericColumnOfPropertiesReadonly, diff --git a/src/components/spreadsheet/config/equipment/two-windings-transformer.ts b/src/components/spreadsheet/config/equipment/two-windings-transformer.ts index 83e8ba90ae..21d2361f84 100644 --- a/src/components/spreadsheet/config/equipment/two-windings-transformer.ts +++ b/src/components/spreadsheet/config/equipment/two-windings-transformer.ts @@ -14,10 +14,6 @@ import CountryCellRenderer from '../../utils/country-cell-render'; import type { EditableCallback } from 'ag-grid-community'; import { BooleanCellRenderer } from '../../utils/cell-renderers'; import { - countryEnumFilterConfig, - defaultBooleanFilterConfig, - defaultNumericFilterConfig, - defaultTextFilterConfig, editableCellStyle, editableColumnConfig, excludeFromGlobalFilter, @@ -26,7 +22,7 @@ import { isEditable, typeAndFetchers, } from './common-config'; -import { MEDIUM_COLUMN_WIDTH } from '../../utils/constants'; +import { COUNTRY_FILTER, MEDIUM_COLUMN_WIDTH, NUMERIC_FILTER, TEXT_FILTER } from '../../utils/constants'; import { PHASE_REGULATION_MODES, RATIO_REGULATION_MODES, REGULATION_TYPES, SIDE } from '../../../network/constants'; import { computeHighTapPosition, getTapChangerRegulationTerminalValue } from '../../../utils/utils'; import { unitToMicroUnit } from '../../../../utils/unit-converter'; @@ -109,48 +105,48 @@ export const TWO_WINDINGS_TRANSFORMER_TAB_DEF = { id: 'ID', field: 'id', isDefaultSort: true, - ...defaultTextFilterConfig, + type: TEXT_FILTER, }, { id: 'Name', field: 'name', - ...defaultTextFilterConfig, + type: TEXT_FILTER, }, { id: 'VoltageLevelIdSide1', field: 'voltageLevelId1', - ...defaultTextFilterConfig, + type: TEXT_FILTER, }, { id: 'VoltageLevelIdSide2', field: 'voltageLevelId2', - ...defaultTextFilterConfig, + type: TEXT_FILTER, }, { id: 'Country', field: 'country', - ...countryEnumFilterConfig, + type: COUNTRY_FILTER, cellRenderer: CountryCellRenderer, }, { id: 'nominalVoltage1KV', field: 'nominalVoltage1', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 0, }, { id: 'nominalVoltage2KV', field: 'nominalVoltage2', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 0, }, { id: 'ratedVoltage1KV', field: 'ratedU1', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 0, ...editableColumnConfig, ...numericalCellEditorConfig((params) => params.data.ratedU1), @@ -160,7 +156,7 @@ export const TWO_WINDINGS_TRANSFORMER_TAB_DEF = { id: 'ratedVoltage2KV', field: 'ratedU2', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 0, ...editableColumnConfig, ...numericalCellEditorConfig((params) => params.data.ratedU2), @@ -170,7 +166,7 @@ export const TWO_WINDINGS_TRANSFORMER_TAB_DEF = { id: 'ActivePowerSide1', field: 'p1', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 1, canBeInvalidated: true, getQuickFilterText: excludeFromGlobalFilter, @@ -179,7 +175,7 @@ export const TWO_WINDINGS_TRANSFORMER_TAB_DEF = { id: 'ActivePowerSide2', field: 'p2', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 1, canBeInvalidated: true, getQuickFilterText: excludeFromGlobalFilter, @@ -188,7 +184,7 @@ export const TWO_WINDINGS_TRANSFORMER_TAB_DEF = { id: 'ReactivePowerSide1', field: 'q1', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 1, canBeInvalidated: true, getQuickFilterText: excludeFromGlobalFilter, @@ -197,7 +193,7 @@ export const TWO_WINDINGS_TRANSFORMER_TAB_DEF = { id: 'ReactivePowerSide2', field: 'q2', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 1, canBeInvalidated: true, getQuickFilterText: excludeFromGlobalFilter, @@ -207,7 +203,7 @@ export const TWO_WINDINGS_TRANSFORMER_TAB_DEF = { field: 'ratioTapChanger.hasLoadTapChangingCapabilities', valueGetter: (params) => params?.data?.ratioTapChanger?.hasLoadTapChangingCapabilities, cellRenderer: BooleanCellRenderer, - ...defaultBooleanFilterConfig, + type: TEXT_FILTER, editable: (params) => isEditable(params) && hasTwtRatioTapChanger(params), cellStyle: editableCellStyle, valueSetter: (params) => { @@ -255,7 +251,7 @@ export const TWO_WINDINGS_TRANSFORMER_TAB_DEF = { { id: 'TargetVPoint', field: 'ratioTapChanger.targetV', - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 1, editable: isTwtRatioOnloadAndEditable, cellStyle: editableCellStyle, @@ -272,7 +268,7 @@ export const TWO_WINDINGS_TRANSFORMER_TAB_DEF = { { id: 'RatioDeadBand', field: 'ratioTapChanger.targetDeadband', - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 1, editable: isTwtRatioOnloadAndEditable, cellStyle: editableCellStyle, @@ -333,7 +329,7 @@ export const TWO_WINDINGS_TRANSFORMER_TAB_DEF = { { id: 'RatioRegulatingTerminal', field: 'ratioTapChanger.ratioRegulatingTerminal', - ...defaultTextFilterConfig, + type: NUMERIC_FILTER, valueGetter: (params) => params.data?.ratioTapChanger?.ratioRegulatingTerminal, columnWidth: MEDIUM_COLUMN_WIDTH, getQuickFilterText: excludeFromGlobalFilter, @@ -351,7 +347,7 @@ export const TWO_WINDINGS_TRANSFORMER_TAB_DEF = { id: 'RatioLowTapPosition', field: 'ratioTapChanger.lowTapPosition', getQuickFilterText: excludeFromGlobalFilter, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, numeric: true, fractionDigits: 0, editable: (params) => isEditable(params) && params.data?.ratioTapChanger?.steps?.length > 0, @@ -373,14 +369,14 @@ export const TWO_WINDINGS_TRANSFORMER_TAB_DEF = { { id: 'RatioHighTapPosition', field: 'ratioTapChanger.highTapPosition', - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, valueGetter: (params) => computeHighTapPosition(params?.data?.ratioTapChanger?.steps), getQuickFilterText: excludeFromGlobalFilter, }, { id: 'RatioTap', field: 'ratioTapChanger.tapPosition', - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, numeric: true, fractionDigits: 0, valueGetter: (params) => params?.data?.ratioTapChanger?.tapPosition, @@ -426,7 +422,7 @@ export const TWO_WINDINGS_TRANSFORMER_TAB_DEF = { { id: 'RegulatingValue', field: 'phaseTapChanger.regulationValue', - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, columnWidth: MEDIUM_COLUMN_WIDTH, fractionDigits: 1, valueGetter: (params) => params?.data?.phaseTapChanger?.regulationValue, @@ -447,7 +443,7 @@ export const TWO_WINDINGS_TRANSFORMER_TAB_DEF = { { id: 'PhaseDeadBand', field: 'phaseTapChanger.targetDeadband', - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 1, getQuickFilterText: excludeFromGlobalFilter, editable: (params) => @@ -510,7 +506,7 @@ export const TWO_WINDINGS_TRANSFORMER_TAB_DEF = { { id: 'PhaseRegulatingTerminal', field: 'phaseTapChanger.phaseRegulatingTerminal', - ...defaultTextFilterConfig, + type: TEXT_FILTER, valueGetter: (params) => params.data?.phaseTapChanger?.phaseRegulatingTerminal, columnWidth: MEDIUM_COLUMN_WIDTH, getQuickFilterText: excludeFromGlobalFilter, @@ -528,7 +524,7 @@ export const TWO_WINDINGS_TRANSFORMER_TAB_DEF = { id: 'PhaseLowTapPosition', field: 'phaseTapChanger.lowTapPosition', getQuickFilterText: excludeFromGlobalFilter, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, numeric: true, fractionDigits: 0, editable: (params) => isEditable(params) && params.data?.phaseTapChanger?.steps?.length > 0, @@ -550,14 +546,14 @@ export const TWO_WINDINGS_TRANSFORMER_TAB_DEF = { { id: 'PhaseHighTapPosition', field: 'phaseTapChanger.highTapPosition', - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, valueGetter: (params) => computeHighTapPosition(params?.data?.phaseTapChanger?.steps), getQuickFilterText: excludeFromGlobalFilter, }, { id: 'PhaseTap', field: 'phaseTapChanger.tapPosition', - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, numeric: true, fractionDigits: 0, valueGetter: (params) => params?.data?.phaseTapChanger?.tapPosition, @@ -582,7 +578,7 @@ export const TWO_WINDINGS_TRANSFORMER_TAB_DEF = { id: 'r', field: 'r', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 1, getQuickFilterText: excludeFromGlobalFilter, }, @@ -590,7 +586,7 @@ export const TWO_WINDINGS_TRANSFORMER_TAB_DEF = { id: 'x', field: 'x', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 1, getQuickFilterText: excludeFromGlobalFilter, }, @@ -598,7 +594,7 @@ export const TWO_WINDINGS_TRANSFORMER_TAB_DEF = { id: 'g', field: 'g', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 1, valueGetter: (params) => unitToMicroUnit(params.data.g), getQuickFilterText: excludeFromGlobalFilter, @@ -607,7 +603,7 @@ export const TWO_WINDINGS_TRANSFORMER_TAB_DEF = { id: 'b', field: 'b', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 1, valueGetter: (params) => unitToMicroUnit(params.data.b), getQuickFilterText: excludeFromGlobalFilter, @@ -616,7 +612,7 @@ export const TWO_WINDINGS_TRANSFORMER_TAB_DEF = { id: 'ratedNominalPower', field: 'ratedS', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 1, getQuickFilterText: excludeFromGlobalFilter, }, @@ -625,7 +621,7 @@ export const TWO_WINDINGS_TRANSFORMER_TAB_DEF = { field: 'terminal1Connected', boolean: true, cellRenderer: BooleanCellRenderer, - ...defaultBooleanFilterConfig, + type: TEXT_FILTER, getQuickFilterText: excludeFromGlobalFilter, }, { @@ -633,7 +629,7 @@ export const TWO_WINDINGS_TRANSFORMER_TAB_DEF = { field: 'terminal2Connected', boolean: true, cellRenderer: BooleanCellRenderer, - ...defaultBooleanFilterConfig, + type: TEXT_FILTER, getQuickFilterText: excludeFromGlobalFilter, }, genericColumnOfPropertiesEditPopup, diff --git a/src/components/spreadsheet/config/equipment/voltage-level.ts b/src/components/spreadsheet/config/equipment/voltage-level.ts index 9728d292e8..e3301ee2dd 100644 --- a/src/components/spreadsheet/config/equipment/voltage-level.ts +++ b/src/components/spreadsheet/config/equipment/voltage-level.ts @@ -10,17 +10,11 @@ import type { SpreadsheetTabDefinition } from '../spreadsheet.type'; import type { CustomColDef } from '../../../custom-aggrid/custom-aggrid-header.type'; import { EQUIPMENT_TYPES } from '../../../utils/equipment-types'; import CountryCellRenderer from '../../utils/country-cell-render'; -import { - countryEnumFilterConfig, - defaultNumericFilterConfig, - defaultTextFilterConfig, - editableColumnConfig, - excludeFromGlobalFilter, - typeAndFetchers, -} from './common-config'; +import { editableColumnConfig, excludeFromGlobalFilter, typeAndFetchers } from './common-config'; import { kiloUnitToUnit, unitToKiloUnit } from '../../../../utils/unit-converter'; import { genericColumnOfPropertiesEditPopup } from '../common/column-properties'; import { numericalCellEditorConfig } from '../common/cell-editors'; +import { COUNTRY_FILTER, NUMERIC_FILTER, TEXT_FILTER } from 'components/spreadsheet/utils/constants'; function generateEditableNumericColumnDefinition< TId extends string, @@ -32,7 +26,7 @@ function generateEditableNumericColumnDefinition< id: id, field: field, numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 1, ...editableColumnConfig, ...numericalCellEditorConfig((params) => params.data[field]), @@ -54,30 +48,30 @@ export const VOLTAGE_LEVEL_TAB_DEF = { id: 'ID', field: 'id', isDefaultSort: true, - ...defaultTextFilterConfig, + type: TEXT_FILTER, }, { id: 'Name', field: 'name', ...editableColumnConfig, - ...defaultTextFilterConfig, + type: TEXT_FILTER, }, { id: 'SubstationId', field: 'substationId', - ...defaultTextFilterConfig, + type: TEXT_FILTER, }, { id: 'Country', field: 'country', - ...countryEnumFilterConfig, + type: COUNTRY_FILTER, cellRenderer: CountryCellRenderer, }, { id: 'NominalV', field: 'nominalV', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 0, ...editableColumnConfig, ...numericalCellEditorConfig((params) => params.data.nominalV), @@ -87,7 +81,7 @@ export const VOLTAGE_LEVEL_TAB_DEF = { { id: 'IpMin', field: 'identifiableShortCircuit.ipMin', - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 1, ...editableColumnConfig, numeric: true, @@ -108,7 +102,7 @@ export const VOLTAGE_LEVEL_TAB_DEF = { { id: 'IpMax', field: 'identifiableShortCircuit.ipMax', - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 1, ...editableColumnConfig, numeric: true, diff --git a/src/components/spreadsheet/config/equipment/vsc-converter-station.ts b/src/components/spreadsheet/config/equipment/vsc-converter-station.ts index cf3ad063d3..5579e1055c 100644 --- a/src/components/spreadsheet/config/equipment/vsc-converter-station.ts +++ b/src/components/spreadsheet/config/equipment/vsc-converter-station.ts @@ -10,15 +10,8 @@ import type { SpreadsheetTabDefinition } from '../spreadsheet.type'; import { EQUIPMENT_TYPES } from '../../../utils/equipment-types'; import CountryCellRenderer from '../../utils/country-cell-render'; import { BooleanCellRenderer } from '../../utils/cell-renderers'; -import { - countryEnumFilterConfig, - defaultBooleanFilterConfig, - defaultNumericFilterConfig, - defaultTextFilterConfig, - excludeFromGlobalFilter, - typeAndFetchers, -} from './common-config'; -import { MEDIUM_COLUMN_WIDTH } from '../../utils/constants'; +import { excludeFromGlobalFilter, typeAndFetchers } from './common-config'; +import { COUNTRY_FILTER, MEDIUM_COLUMN_WIDTH, NUMERIC_FILTER, TEXT_FILTER } from '../../utils/constants'; import { genericColumnOfProperties } from '../common/column-properties'; export const VSC_CONVERTER_STATION_TAB_DEF = { @@ -31,41 +24,41 @@ export const VSC_CONVERTER_STATION_TAB_DEF = { field: 'id', columnWidth: MEDIUM_COLUMN_WIDTH, isDefaultSort: true, - ...defaultTextFilterConfig, + type: TEXT_FILTER, }, { id: 'Name', field: 'name', - ...defaultTextFilterConfig, + type: TEXT_FILTER, }, { id: 'VoltageLevelId', field: 'voltageLevelId', - ...defaultTextFilterConfig, + type: TEXT_FILTER, }, { id: 'Country', field: 'country', - ...countryEnumFilterConfig, + type: COUNTRY_FILTER, cellRenderer: CountryCellRenderer, }, { id: 'NominalV', field: 'nominalV', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 0, }, { id: 'HvdcLineId', field: 'hvdcLineId', - ...defaultTextFilterConfig, + type: TEXT_FILTER, }, { id: 'activePower', field: 'p', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 1, canBeInvalidated: true, getQuickFilterText: excludeFromGlobalFilter, @@ -74,7 +67,7 @@ export const VSC_CONVERTER_STATION_TAB_DEF = { id: 'ReactivePower', field: 'q', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 1, canBeInvalidated: true, getQuickFilterText: excludeFromGlobalFilter, @@ -83,7 +76,7 @@ export const VSC_CONVERTER_STATION_TAB_DEF = { id: 'LossFactor', field: 'lossFactor', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 1, getQuickFilterText: excludeFromGlobalFilter, }, @@ -92,14 +85,14 @@ export const VSC_CONVERTER_STATION_TAB_DEF = { field: 'voltageRegulatorOn', boolean: true, cellRenderer: BooleanCellRenderer, - ...defaultBooleanFilterConfig, + type: TEXT_FILTER, getQuickFilterText: excludeFromGlobalFilter, }, { id: 'VoltageSetpointKV', field: 'voltageSetpoint', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 1, getQuickFilterText: excludeFromGlobalFilter, }, @@ -107,7 +100,7 @@ export const VSC_CONVERTER_STATION_TAB_DEF = { id: 'ReactivePowerSetpointMVAR', field: 'reactivePowerSetpoint', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 1, getQuickFilterText: excludeFromGlobalFilter, }, @@ -116,7 +109,7 @@ export const VSC_CONVERTER_STATION_TAB_DEF = { field: 'terminalConnected', boolean: true, cellRenderer: BooleanCellRenderer, - ...defaultBooleanFilterConfig, + type: TEXT_FILTER, getQuickFilterText: excludeFromGlobalFilter, }, genericColumnOfProperties, diff --git a/src/components/spreadsheet/config/spreadsheet.type.ts b/src/components/spreadsheet/config/spreadsheet.type.ts index 7424f7df75..be41cb80cd 100644 --- a/src/components/spreadsheet/config/spreadsheet.type.ts +++ b/src/components/spreadsheet/config/spreadsheet.type.ts @@ -7,7 +7,9 @@ import type { UUID } from 'crypto'; import type { EQUIPMENT_TYPES } from '../../utils/equipment-types'; -import type { CustomColDef } from '../../custom-aggrid/custom-aggrid-header.type'; +import { ColDef, ITextFilterParams } from 'ag-grid-community'; +import { CrossValidationOptions } from '../utils/equipment-table-utils'; +import { CustomColumnConfigProps } from '../custom-columns/custom-column-menu'; export type EquipmentFetcher = (studyUuid: UUID, currentNodeUuid: UUID, substationsIds: string[]) => Promise; @@ -24,6 +26,29 @@ export interface SpreadsheetTabDefinition { name: string; type: SpreadsheetEquipmentType; fetchers: EquipmentFetcher[]; - columns: CustomColDef[]; + columns: SpreadsheetColDef[]; groovyEquipmentGetter?: string; } + +export interface SpreadsheetColDef extends ColDef { + boolean?: boolean; + canBeInvalidated?: boolean; + changeCmd?: string; + columnWidth?: number; + crossValidation?: CrossValidationOptions; + type?: string; + filter?: string; + filterParams?: ITextFilterParams; + fractionDigits?: number; + getEnumLabel?: (value: string) => string | undefined; + id: string; + isCountry?: boolean; + isDefaultSort?: boolean; + isEnum?: boolean; + numeric?: boolean; + withFluxConvention?: boolean; + forceDisplayFilterIcon?: boolean; + tabIndex?: number; + isCustomColumn?: boolean; + Menu?: React.FC; +} diff --git a/src/components/spreadsheet/equipment-table.tsx b/src/components/spreadsheet/equipment-table.tsx index 8a550c0e46..355b9fb93c 100644 --- a/src/components/spreadsheet/equipment-table.tsx +++ b/src/components/spreadsheet/equipment-table.tsx @@ -51,6 +51,7 @@ interface EquipmentTableProps { handleRowDataUpdated: () => void; fetched: boolean; shouldHidePinnedHeaderRightBorder: boolean; + columnTypes: { [key: string]: ColDef }; } const loadingOverlayComponent = (props: { loadingMessage: string }) => <>{props.loadingMessage}; @@ -69,6 +70,7 @@ export const EquipmentTable: FunctionComponent = ({ handleRowDataUpdated, fetched, shouldHidePinnedHeaderRightBorder, + columnTypes, }) => { const theme = useTheme(); const intl = useIntl(); @@ -150,6 +152,7 @@ export const EquipmentTable: FunctionComponent = ({ loadingOverlayComponent={loadingOverlayComponent} loadingOverlayComponentParams={loadingOverlayComponentParams} showOverlay={true} + columnTypes={columnTypes} /> ); }; diff --git a/src/components/spreadsheet/table-wrapper.tsx b/src/components/spreadsheet/table-wrapper.tsx index ceda8c2113..a5bac8e7eb 100644 --- a/src/components/spreadsheet/table-wrapper.tsx +++ b/src/components/spreadsheet/table-wrapper.tsx @@ -52,7 +52,6 @@ import { } from 'components/utils/field-constants'; import { checkValidationsAndRefreshCells, - deepFindValue, formatFetchedEquipment, formatFetchedEquipments, updateGeneratorCells, @@ -60,16 +59,11 @@ import { updateTwtCells, } from './utils/equipment-table-utils'; import { fetchNetworkElementInfos } from 'services/study/network'; -import { toModificationOperation } from 'components/utils/utils'; import { sanitizeString } from 'components/dialogs/dialog-utils'; import { REGULATION_TYPES, SHUNT_COMPENSATOR_TYPES } from 'components/network/constants'; import ComputingType from 'components/computing-status/computing-type'; -import { makeAgGridCustomHeaderColumn } from 'components/custom-aggrid/custom-aggrid-header-utils'; -import { useAggridLocalRowFilter } from 'hooks/use-aggrid-local-row-filter'; -import { useAgGridSort } from 'hooks/use-aggrid-sort'; -import { setSpreadsheetFilter, updateEquipments } from 'redux/actions'; +import { updateEquipments } from 'redux/actions'; import { useLocalizedCountries } from 'components/utils/localized-countries-hook'; -import { SPREADSHEET_SORT_STORE, SPREADSHEET_STORE_FIELD } from 'utils/store-sort-filter-fields'; import { useCustomColumn } from './custom-columns/use-custom-column'; import CustomColumnsConfig from './custom-columns/custom-columns-config'; import { AppState, CurrentTreeNode, EquipmentUpdateType, getUpdateTypeFromEquipmentType } from '../../redux/reducer'; @@ -83,10 +77,17 @@ import { ICellRendererParams, } from 'ag-grid-community'; import { mergeSx } from '../utils/functions'; -import { CustomColDef, FILTER_NUMBER_COMPARATORS } from '../custom-aggrid/custom-aggrid-header.type'; +import { + CustomColDef, + FILTER_NUMBER_COMPARATORS, + FILTER_TEXT_COMPARATORS, +} from '../custom-aggrid/custom-aggrid-header.type'; import { FluxConventions } from '../dialogs/parameters/network-parameters'; import { SpreadsheetEquipmentType } from './config/spreadsheet.type'; import SpreadsheetSave from './spreadsheet-save'; +import { defaultColumnType } from './config/column-type-flter-config'; +import { makeAgGridColumn } from './config/column-aggrid-utils'; +import { toModificationOperation } from 'components/utils/utils'; const useEditBuffer = (): [Record, (field: string, value: unknown) => void, () => void] => { //the data is fed and read during the edition validation process so we don't need to rerender after a call to one of available methods thus useRef is more suited @@ -268,14 +269,6 @@ const TableWrapper: FunctionComponent = ({ ); }, [disabled, selectedColumnsNames, currentTabType, currentColumns]); - const { onSortChanged, sortConfig } = useAgGridSort(SPREADSHEET_SORT_STORE, currentTabName()); - - const { updateFilter, filterSelector } = useAggridLocalRowFilter(gridRef, { - filterType: SPREADSHEET_STORE_FIELD, - filterTab: currentTabName(), - filterStoreAction: setSpreadsheetFilter, - }); - const equipmentDefinition = useMemo( () => ({ type: currentTabType(), @@ -304,29 +297,29 @@ const TableWrapper: FunctionComponent = ({ formatFetchedEquipmentsHandler ); - // Function to get the columns that have isEnum filter set to true in customFilterParams - const getEnumFilterColumns = useCallback(() => { - return currentColumns().filter((c) => c.isEnum); - }, [currentColumns]); - - const generateEquipmentsFilterEnums = useCallback(() => { - if (!equipments) { - return {}; - } - const filterEnums: any = {}; - getEnumFilterColumns().forEach((column) => { - filterEnums[column.field ?? ''] = [ - ...new Set( - equipments - .map((equipment: any) => deepFindValue(equipment, column.field)) - .filter((value: any) => value != null) - ), - ]; - }); - return filterEnums; - }, [getEnumFilterColumns, equipments]); - - const filterEnums = useMemo(() => generateEquipmentsFilterEnums(), [generateEquipmentsFilterEnums]); + function contains(target: string, lookingFor: string) { + return target && target?.toLowerCase().indexOf(lookingFor.toLowerCase()) >= 0; + } + + const columnTypes = { + ...defaultColumnType, + countryFilter: { + filter: 'agTextColumnFilter', + filterParams: { + caseSensitive: false, + maxNumConditions: 1, + filterOptions: [FILTER_TEXT_COMPARATORS.CONTAINS], + textMatcher: ({ value, filterText }: { value: string; filterText: string }) => { + const countryCode = value?.toUpperCase(); + const countryName = translate(countryCode); + return contains(countryName, filterText || '') || contains(value, filterText); + }, + debounceMs: 200, + }, + sortable: true, + resizable: true, + }, + }; const enrichColumn = useCallback( (column: CustomColDef) => { @@ -426,36 +419,13 @@ const TableWrapper: FunctionComponent = ({ }; } - return makeAgGridCustomHeaderColumn({ + return makeAgGridColumn({ headerName: columnExtended.headerName, field: columnExtended.field, - sortProps: { - onSortChanged, - sortConfig, - }, - filterProps: { - updateFilter, - filterSelector, - }, - filterParams: { - ...columnExtended?.customFilterParams, - filterEnums, - }, ...columnExtended, }); }, - [ - intl, - lockedColumnsNames, - onSortChanged, - sortConfig, - updateFilter, - filterSelector, - loadFlowStatus, - applyFluxConvention, - filterEnums, - translate, - ] + [intl, lockedColumnsNames, loadFlowStatus, applyFluxConvention, translate] ); useEffect(() => { @@ -467,14 +437,6 @@ const TableWrapper: FunctionComponent = ({ } }, [errorMessage, snackError]); - // Ensure initial sort is applied by including mergedColumnData in dependencies - useEffect(() => { - gridRef.current?.api?.applyColumnState({ - state: sortConfig, - defaultState: { sort: null }, - }); - }, [sortConfig, mergedColumnData]); - useEffect(() => { if (disabled || !equipments) { return; @@ -1305,6 +1267,7 @@ const TableWrapper: FunctionComponent = ({ handleGridReady={handleGridReady} handleRowDataUpdated={handleRowDataUpdated} shouldHidePinnedHeaderRightBorder={isLockedColumnNamesEmpty} + columnTypes={columnTypes} /> )} diff --git a/src/components/spreadsheet/utils/constants.ts b/src/components/spreadsheet/utils/constants.ts index 5ebcdb6ae1..1200a7e221 100644 --- a/src/components/spreadsheet/utils/constants.ts +++ b/src/components/spreadsheet/utils/constants.ts @@ -14,3 +14,9 @@ export const EDIT_COLUMN = 'edit'; export const DISPLAYED_COLUMNS_PARAMETER_PREFIX_IN_DATABASE = 'displayedColumns.'; export const LOCKED_COLUMNS_PARAMETER_PREFIX_IN_DATABASE = 'lockedColumns.'; export const REORDERED_COLUMNS_PARAMETER_PREFIX_IN_DATABASE = 'reorderedColumns.'; + +export const TEXT_FILTER = 'textFilter'; +export const NUMERIC_FILTER = 'numericFilter'; +export const ENUM_FILTER = 'enumFilter'; +export const BOOLEAN_FILTER = 'booleanFilter'; +export const COUNTRY_FILTER = 'countryFilter'; From 44b1baf5dbd79c5c3fac0a1ded365bbef116539f Mon Sep 17 00:00:00 2001 From: TOURI ANIS Date: Wed, 11 Dec 2024 18:04:36 +0100 Subject: [PATCH 02/10] clean code --- src/components/custom-aggrid/custom-aggrid-header-utils.ts | 2 +- .../spreadsheet/config/column-type-flter-config.ts | 7 +------ .../spreadsheet/config/equipment/common-config.ts | 2 +- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/src/components/custom-aggrid/custom-aggrid-header-utils.ts b/src/components/custom-aggrid/custom-aggrid-header-utils.ts index 5da12b42ea..c437f733c3 100644 --- a/src/components/custom-aggrid/custom-aggrid-header-utils.ts +++ b/src/components/custom-aggrid/custom-aggrid-header-utils.ts @@ -72,7 +72,7 @@ export const makeAgGridCustomHeaderColumn = ({ isCustomColumn: isCustomColumn, Menu: Menu, }, - //filterParams: props?.agGridFilterParams || undefined, + filterParams: props?.agGridFilterParams || undefined, ...props, }; }; diff --git a/src/components/spreadsheet/config/column-type-flter-config.ts b/src/components/spreadsheet/config/column-type-flter-config.ts index dac9c66104..5515b72b40 100644 --- a/src/components/spreadsheet/config/column-type-flter-config.ts +++ b/src/components/spreadsheet/config/column-type-flter-config.ts @@ -6,13 +6,12 @@ */ import { FILTER_NUMBER_COMPARATORS, FILTER_TEXT_COMPARATORS } from 'components/custom-aggrid/custom-aggrid-header.type'; -import { EnumOption } from 'components/utils/utils-type'; function contains(target: string, lookingFor: string) { return target && target?.toLowerCase().indexOf(lookingFor.toLowerCase()) >= 0; } -export const getEnumFilterConfig = (enumOption: EnumOption[]) => { +export const getEnumFilterConfig = () => { return { enumFilter: { filter: 'agTextColumnFilter', @@ -22,10 +21,6 @@ export const getEnumFilterConfig = (enumOption: EnumOption[]) => { filterOptions: [FILTER_TEXT_COMPARATORS.CONTAINS], textMatcher: ({ value, filterText }: { value: string; filterText: string }) => { if (value) { - /* const label = - getEnumLabelById(Object.values(enumOption) as EnumOption[], value?.toUpperCase()) || - value; - const text = label ? intl.formatMessage({ id: label }) : value; */ return contains(value, filterText || ''); } return false; diff --git a/src/components/spreadsheet/config/equipment/common-config.ts b/src/components/spreadsheet/config/equipment/common-config.ts index b6456403e4..22662cfde0 100644 --- a/src/components/spreadsheet/config/equipment/common-config.ts +++ b/src/components/spreadsheet/config/equipment/common-config.ts @@ -184,7 +184,7 @@ export const defaultBooleanFilterConfig = { // It generates configuration for filtering, sorting and rendering export const getDefaultEnumConfig = (enumOptions: Readonly) => ({ - ...getEnumFilterConfig(enumOptions as EnumOption[]), + ...getEnumFilterConfig(), cellRenderer: EnumCellRenderer, cellRendererParams: { enumOptions: enumOptions as Writable, From 2939056daeeb62bd01a18c23809dc093dd371706 Mon Sep 17 00:00:00 2001 From: TOURI ANIS Date: Fri, 13 Dec 2024 14:06:04 +0100 Subject: [PATCH 03/10] improve aggrid filter --- .../spreadsheet/config/column-aggrid-utils.ts | 6 +- .../config/column-type-flter-config.ts | 79 +++++++++++++++---- .../spreadsheet/config/equipment/battery.ts | 6 +- .../config/equipment/common-config.ts | 6 +- .../config/equipment/dangling-line.ts | 4 +- .../spreadsheet/config/equipment/generator.ts | 14 +++- .../spreadsheet/config/equipment/hvdc-line.ts | 3 +- .../config/equipment/lcc-converter-station.ts | 4 +- .../spreadsheet/config/equipment/load.ts | 10 ++- .../config/equipment/shunt-compensator.ts | 3 +- .../equipment/static-var-compensator.ts | 10 ++- .../equipment/three-windings-transformer.ts | 32 +++++--- .../spreadsheet/config/equipment/tie-line.ts | 12 ++- .../equipment/two-windings-transformer.ts | 14 +++- .../config/equipment/vsc-converter-station.ts | 12 ++- .../spreadsheet/equipment-table.tsx | 6 +- src/components/spreadsheet/table-wrapper.tsx | 79 ++++--------------- 17 files changed, 171 insertions(+), 129 deletions(-) diff --git a/src/components/spreadsheet/config/column-aggrid-utils.ts b/src/components/spreadsheet/config/column-aggrid-utils.ts index 00e64ba6bf..87bec3d77c 100644 --- a/src/components/spreadsheet/config/column-aggrid-utils.ts +++ b/src/components/spreadsheet/config/column-aggrid-utils.ts @@ -5,15 +5,15 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { CustomColDef } from 'components/custom-aggrid/custom-aggrid-header.type'; +import { SpreadsheetColDef } from './spreadsheet.type'; -export const makeAgGridColumn = ({ +export const makeSpreadsheetAgGridColumn = ({ forceDisplayFilterIcon, tabIndex, isCustomColumn, Menu, ...props // agGrid column props -}: CustomColDef) => { +}: SpreadsheetColDef) => { const { headerName, fractionDigits, numeric } = props; let minWidth = 75; diff --git a/src/components/spreadsheet/config/column-type-flter-config.ts b/src/components/spreadsheet/config/column-type-flter-config.ts index 5515b72b40..4cbc9add71 100644 --- a/src/components/spreadsheet/config/column-type-flter-config.ts +++ b/src/components/spreadsheet/config/column-type-flter-config.ts @@ -6,27 +6,34 @@ */ import { FILTER_NUMBER_COMPARATORS, FILTER_TEXT_COMPARATORS } from 'components/custom-aggrid/custom-aggrid-header.type'; +import { getEnumLabelById } from 'components/utils/utils'; +import { EnumOption } from 'components/utils/utils-type'; -function contains(target: string, lookingFor: string) { - return target && target?.toLowerCase().indexOf(lookingFor.toLowerCase()) >= 0; -} +const contains = (target: string, lookingFor: string): boolean => { + if (target && lookingFor) { + return target?.toLowerCase().indexOf(lookingFor.toLowerCase()) >= 0; + } + return false; +}; -export const getEnumFilterConfig = () => { +export const getEnumFilterConfig = (enumOptions: EnumOption[]) => { return { - enumFilter: { - filter: 'agTextColumnFilter', - filterParams: { - caseSensitive: false, - maxNumConditions: 1, - filterOptions: [FILTER_TEXT_COMPARATORS.CONTAINS], - textMatcher: ({ value, filterText }: { value: string; filterText: string }) => { - if (value) { - return contains(value, filterText || ''); - } - return false; - }, - debounceMs: 200, + filter: 'agTextColumnFilter', + filterParams: { + caseSensitive: false, + maxNumConditions: 1, + filterOptions: [FILTER_TEXT_COMPARATORS.CONTAINS], + textMatcher: ({ value, filterText, context }: any): boolean => { + if (value) { + const label = enumOptions + ? getEnumLabelById(enumOptions as EnumOption[], value.toUpperCase()) + : value; + const displayedValue = label ? context.intl.formatMessage({ id: label }) : value; + return contains(displayedValue, filterText || ''); + } + return false; }, + debounceMs: 200, }, }; }; @@ -36,6 +43,7 @@ export const defaultColumnType = { filter: 'agTextColumnFilter', filterParams: { caseSensitive: false, + maxNumConditions: 1, filterOptions: [FILTER_TEXT_COMPARATORS.STARTS_WITH, FILTER_TEXT_COMPARATORS.CONTAINS], }, sortable: true, @@ -44,10 +52,47 @@ export const defaultColumnType = { numericFilter: { filter: 'agNumberColumnFilter', filterParams: { + maxNumConditions: 1, filterOptions: Object.values(FILTER_NUMBER_COMPARATORS), debounceMs: 200, }, sortable: false, resizable: true, }, + booleanFilter: { + filter: 'agTextColumnFilter', + filterParams: { + caseSensitive: false, + maxNumConditions: 1, + filterOptions: [FILTER_TEXT_COMPARATORS.EQUALS], + textMatcher: ({ value, filterText, context }: any): boolean => { + if (value) { + const displayedValue = context.intl.formatMessage({ id: value }) ?? value; + return contains(displayedValue, filterText || ''); + } + return false; + }, + }, + sortable: true, + resizable: true, + }, + countryFilter: { + filter: 'agTextColumnFilter', + filterParams: { + caseSensitive: false, + maxNumConditions: 1, + filterOptions: [FILTER_TEXT_COMPARATORS.CONTAINS], + textMatcher: ({ value, filterText, context }: { value: string; filterText: string; context: any }) => { + if (value) { + const countryCode = value?.toUpperCase(); + const countryName = context?.translateCountryCode(countryCode); + return contains(countryName, filterText || '') || contains(value, filterText); + } + return false; + }, + debounceMs: 200, + }, + sortable: true, + resizable: true, + }, }; diff --git a/src/components/spreadsheet/config/equipment/battery.ts b/src/components/spreadsheet/config/equipment/battery.ts index 5e51f95684..0f1529bf99 100644 --- a/src/components/spreadsheet/config/equipment/battery.ts +++ b/src/components/spreadsheet/config/equipment/battery.ts @@ -13,7 +13,7 @@ import { editableColumnConfig, excludeFromGlobalFilter, typeAndFetchers } from ' import type { SpreadsheetTabDefinition } from '../spreadsheet.type'; import { genericColumnOfPropertiesEditPopup } from '../common/column-properties'; import { booleanCellEditorConfig, numericalCellEditorConfig } from '../common/cell-editors'; -import { COUNTRY_FILTER, NUMERIC_FILTER, TEXT_FILTER } from 'components/spreadsheet/utils/constants'; +import { BOOLEAN_FILTER, COUNTRY_FILTER, NUMERIC_FILTER, TEXT_FILTER } from 'components/spreadsheet/utils/constants'; export const BATTERY_TAB_DEF = { index: 9, @@ -74,7 +74,7 @@ export const BATTERY_TAB_DEF = { id: 'ActivePowerControl', field: 'activePowerControl.participate', cellRenderer: BooleanCellRenderer, - type: TEXT_FILTER, + type: BOOLEAN_FILTER, ...editableColumnConfig, valueSetter: (params) => { params.data.activePowerControl = { @@ -166,7 +166,7 @@ export const BATTERY_TAB_DEF = { field: 'terminalConnected', boolean: true, cellRenderer: BooleanCellRenderer, - type: TEXT_FILTER, + type: BOOLEAN_FILTER, getQuickFilterText: excludeFromGlobalFilter, }, genericColumnOfPropertiesEditPopup, diff --git a/src/components/spreadsheet/config/equipment/common-config.ts b/src/components/spreadsheet/config/equipment/common-config.ts index 22662cfde0..57921a0ac3 100644 --- a/src/components/spreadsheet/config/equipment/common-config.ts +++ b/src/components/spreadsheet/config/equipment/common-config.ts @@ -36,7 +36,7 @@ import { fetchVoltageLevels, fetchVscConverterStations, } from '../../../../services/study/network'; -import { EquipmentFetcher, SpreadsheetEquipmentType } from '../spreadsheet.type'; +import { EquipmentFetcher, SpreadsheetColDef, SpreadsheetEquipmentType } from '../spreadsheet.type'; import { BooleanFilterValue } from '../../../custom-aggrid/custom-aggrid-filters/custom-aggrid-boolean-filter'; import { getEnumFilterConfig } from '../column-type-flter-config'; @@ -184,14 +184,14 @@ export const defaultBooleanFilterConfig = { // It generates configuration for filtering, sorting and rendering export const getDefaultEnumConfig = (enumOptions: Readonly) => ({ - ...getEnumFilterConfig(), + ...getEnumFilterConfig(enumOptions as EnumOption[]), cellRenderer: EnumCellRenderer, cellRendererParams: { enumOptions: enumOptions as Writable, // @ts-expect-error TODO TS1360: Property value is missing in type } satisfies EnumCellRendererProps, getEnumLabel: (value: string) => getEnumLabelById(enumOptions as Writable, value), - } as const satisfies Partial>); + } as const satisfies Partial>); export const countryEnumFilterConfig = { ...defaultEnumFilterConfig, diff --git a/src/components/spreadsheet/config/equipment/dangling-line.ts b/src/components/spreadsheet/config/equipment/dangling-line.ts index 2e1ce0cc9b..155d13a4b1 100644 --- a/src/components/spreadsheet/config/equipment/dangling-line.ts +++ b/src/components/spreadsheet/config/equipment/dangling-line.ts @@ -13,7 +13,7 @@ import { BooleanCellRenderer } from '../../utils/cell-renderers'; import { excludeFromGlobalFilter, typeAndFetchers } from './common-config'; import { NOMINAL_V } from '../../../utils/field-constants'; import { genericColumnOfProperties } from '../common/column-properties'; -import { COUNTRY_FILTER, NUMERIC_FILTER, TEXT_FILTER } from 'components/spreadsheet/utils/constants'; +import { BOOLEAN_FILTER, COUNTRY_FILTER, NUMERIC_FILTER, TEXT_FILTER } from 'components/spreadsheet/utils/constants'; export const DANGLING_LINE_TAB_DEF = { index: 13, @@ -94,7 +94,7 @@ export const DANGLING_LINE_TAB_DEF = { field: 'terminalConnected', boolean: true, cellRenderer: BooleanCellRenderer, - type: TEXT_FILTER, + type: BOOLEAN_FILTER, getQuickFilterText: excludeFromGlobalFilter, }, genericColumnOfProperties, diff --git a/src/components/spreadsheet/config/equipment/generator.ts b/src/components/spreadsheet/config/equipment/generator.ts index d35edb3f96..89a1237353 100644 --- a/src/components/spreadsheet/config/equipment/generator.ts +++ b/src/components/spreadsheet/config/equipment/generator.ts @@ -22,7 +22,13 @@ import { getDefaultEnumConfig, typeAndFetchers, } from './common-config'; -import { COUNTRY_FILTER, MEDIUM_COLUMN_WIDTH, NUMERIC_FILTER, TEXT_FILTER } from '../../utils/constants'; +import { + BOOLEAN_FILTER, + COUNTRY_FILTER, + MEDIUM_COLUMN_WIDTH, + NUMERIC_FILTER, + TEXT_FILTER, +} from '../../utils/constants'; import { ENERGY_SOURCES, REGULATION_TYPES } from '../../../network/constants'; import { genericColumnOfPropertiesEditPopup } from '../common/column-properties'; import { @@ -125,7 +131,7 @@ export const GENERATOR_TAB_DEF = { id: 'ActivePowerControl', field: 'activePowerControl.participate', cellRenderer: BooleanCellRenderer, - type: TEXT_FILTER, + type: BOOLEAN_FILTER, ...editableColumnConfig, valueSetter: (params) => { params.data.activePowerControl = { @@ -223,7 +229,7 @@ export const GENERATOR_TAB_DEF = { id: 'voltageRegulationOn', field: 'voltageRegulatorOn', cellRenderer: BooleanCellRenderer, - type: TEXT_FILTER, + type: BOOLEAN_FILTER, ...editableColumnConfig, ...booleanCellEditorConfig((params) => params.data?.voltageRegulatorOn ?? false), getQuickFilterText: excludeFromGlobalFilter, @@ -406,7 +412,7 @@ export const GENERATOR_TAB_DEF = { field: 'terminalConnected', boolean: true, cellRenderer: BooleanCellRenderer, - type: TEXT_FILTER, + type: BOOLEAN_FILTER, getQuickFilterText: excludeFromGlobalFilter, }, { diff --git a/src/components/spreadsheet/config/equipment/hvdc-line.ts b/src/components/spreadsheet/config/equipment/hvdc-line.ts index 05a8cc66f7..a113df7112 100644 --- a/src/components/spreadsheet/config/equipment/hvdc-line.ts +++ b/src/components/spreadsheet/config/equipment/hvdc-line.ts @@ -12,6 +12,7 @@ import CountryCellRenderer from '../../utils/country-cell-render'; import { BooleanCellRenderer } from '../../utils/cell-renderers'; import { excludeFromGlobalFilter, typeAndFetchers } from './common-config'; import { + BOOLEAN_FILTER, COUNTRY_FILTER, LARGE_COLUMN_WIDTH, MEDIUM_COLUMN_WIDTH, @@ -126,7 +127,7 @@ export const HVDC_LINE_TAB_DEF = { field: 'hvdcAngleDroopActivePowerControl.isEnabled', boolean: true, cellRenderer: BooleanCellRenderer, - type: TEXT_FILTER, + type: BOOLEAN_FILTER, getQuickFilterText: excludeFromGlobalFilter, }, { diff --git a/src/components/spreadsheet/config/equipment/lcc-converter-station.ts b/src/components/spreadsheet/config/equipment/lcc-converter-station.ts index c72fbfe228..bdb7142813 100644 --- a/src/components/spreadsheet/config/equipment/lcc-converter-station.ts +++ b/src/components/spreadsheet/config/equipment/lcc-converter-station.ts @@ -12,7 +12,7 @@ import CountryCellRenderer from '../../utils/country-cell-render'; import { BooleanCellRenderer } from '../../utils/cell-renderers'; import { excludeFromGlobalFilter, typeAndFetchers } from './common-config'; import { genericColumnOfProperties } from '../common/column-properties'; -import { COUNTRY_FILTER, NUMERIC_FILTER, TEXT_FILTER } from 'components/spreadsheet/utils/constants'; +import { BOOLEAN_FILTER, COUNTRY_FILTER, NUMERIC_FILTER, TEXT_FILTER } from 'components/spreadsheet/utils/constants'; export const LCC_CONVERTER_STATION_TAB_DEF = { index: 11, @@ -92,7 +92,7 @@ export const LCC_CONVERTER_STATION_TAB_DEF = { field: 'terminalConnected', boolean: true, cellRenderer: BooleanCellRenderer, - type: TEXT_FILTER, + type: BOOLEAN_FILTER, getQuickFilterText: excludeFromGlobalFilter, }, genericColumnOfProperties, diff --git a/src/components/spreadsheet/config/equipment/load.ts b/src/components/spreadsheet/config/equipment/load.ts index 477a536163..2aa9397c2a 100644 --- a/src/components/spreadsheet/config/equipment/load.ts +++ b/src/components/spreadsheet/config/equipment/load.ts @@ -11,7 +11,13 @@ import { EQUIPMENT_TYPES } from '../../../utils/equipment-types'; import CountryCellRenderer from '../../utils/country-cell-render'; import { BooleanCellRenderer } from '../../utils/cell-renderers'; import { editableColumnConfig, excludeFromGlobalFilter, getDefaultEnumConfig, typeAndFetchers } from './common-config'; -import { COUNTRY_FILTER, MEDIUM_COLUMN_WIDTH, NUMERIC_FILTER, TEXT_FILTER } from '../../utils/constants'; +import { + BOOLEAN_FILTER, + COUNTRY_FILTER, + MEDIUM_COLUMN_WIDTH, + NUMERIC_FILTER, + TEXT_FILTER, +} from '../../utils/constants'; import { LOAD_TYPES } from '../../../network/constants'; import { genericColumnOfPropertiesEditPopup } from '../common/column-properties'; import { enumCellEditorConfig, numericalCellEditorConfig } from '../common/cell-editors'; @@ -106,7 +112,7 @@ export const LOAD_TAB_DEF = { field: 'terminalConnected', boolean: true, cellRenderer: BooleanCellRenderer, - type: TEXT_FILTER, + type: BOOLEAN_FILTER, getQuickFilterText: excludeFromGlobalFilter, }, genericColumnOfPropertiesEditPopup, diff --git a/src/components/spreadsheet/config/equipment/shunt-compensator.ts b/src/components/spreadsheet/config/equipment/shunt-compensator.ts index 9620c81945..2427ebd2ab 100644 --- a/src/components/spreadsheet/config/equipment/shunt-compensator.ts +++ b/src/components/spreadsheet/config/equipment/shunt-compensator.ts @@ -18,6 +18,7 @@ import { typeAndFetchers, } from './common-config'; import { + BOOLEAN_FILTER, COUNTRY_FILTER, MEDIUM_COLUMN_WIDTH, MIN_COLUMN_WIDTH, @@ -163,7 +164,7 @@ export const SHUNT_COMPENSATOR_TAB_DEF = { field: 'terminalConnected', boolean: true, cellRenderer: BooleanCellRenderer, - type: TEXT_FILTER, + type: BOOLEAN_FILTER, getQuickFilterText: excludeFromGlobalFilter, }, genericColumnOfPropertiesEditPopup, diff --git a/src/components/spreadsheet/config/equipment/static-var-compensator.ts b/src/components/spreadsheet/config/equipment/static-var-compensator.ts index 1b696b1c90..d2fe7cfa61 100644 --- a/src/components/spreadsheet/config/equipment/static-var-compensator.ts +++ b/src/components/spreadsheet/config/equipment/static-var-compensator.ts @@ -11,7 +11,13 @@ import { EQUIPMENT_TYPES } from '../../../utils/equipment-types'; import CountryCellRenderer from '../../utils/country-cell-render'; import { BooleanCellRenderer } from '../../utils/cell-renderers'; import { excludeFromGlobalFilter, typeAndFetchers } from './common-config'; -import { COUNTRY_FILTER, MEDIUM_COLUMN_WIDTH, NUMERIC_FILTER, TEXT_FILTER } from '../../utils/constants'; +import { + BOOLEAN_FILTER, + COUNTRY_FILTER, + MEDIUM_COLUMN_WIDTH, + NUMERIC_FILTER, + TEXT_FILTER, +} from '../../utils/constants'; import { NOMINAL_V } from '../../../utils/field-constants'; import { genericColumnOfProperties } from '../common/column-properties'; @@ -89,7 +95,7 @@ export const STATIC_VAR_COMPENSATOR_TAB_DEF = { field: 'terminalConnected', boolean: true, cellRenderer: BooleanCellRenderer, - type: TEXT_FILTER, + type: BOOLEAN_FILTER, getQuickFilterText: excludeFromGlobalFilter, }, genericColumnOfProperties, diff --git a/src/components/spreadsheet/config/equipment/three-windings-transformer.ts b/src/components/spreadsheet/config/equipment/three-windings-transformer.ts index 895628fba3..4203fa8fc6 100644 --- a/src/components/spreadsheet/config/equipment/three-windings-transformer.ts +++ b/src/components/spreadsheet/config/equipment/three-windings-transformer.ts @@ -11,7 +11,13 @@ import { EQUIPMENT_TYPES } from '../../../utils/equipment-types'; import CountryCellRenderer from '../../utils/country-cell-render'; import { BooleanCellRenderer } from '../../utils/cell-renderers'; import { editableColumnConfig, excludeFromGlobalFilter, generateTapPositions, typeAndFetchers } from './common-config'; -import { COUNTRY_FILTER, MEDIUM_COLUMN_WIDTH, NUMERIC_FILTER, TEXT_FILTER } from '../../utils/constants'; +import { + BOOLEAN_FILTER, + COUNTRY_FILTER, + MEDIUM_COLUMN_WIDTH, + NUMERIC_FILTER, + TEXT_FILTER, +} from '../../utils/constants'; import { genericColumnOfProperties } from '../common/column-properties'; import { standardSelectCellEditorConfig } from '../common/cell-editors'; @@ -146,7 +152,7 @@ export const THREE_WINDINGS_TRANSFORMER_TAB_DEF = { field: 'hasLoadTapChanging1Capabilities', boolean: true, cellRenderer: BooleanCellRenderer, - type: TEXT_FILTER, + type: BOOLEAN_FILTER, getQuickFilterText: excludeFromGlobalFilter, }, { @@ -154,7 +160,7 @@ export const THREE_WINDINGS_TRANSFORMER_TAB_DEF = { field: 'isRegulatingRatio1', boolean: true, cellRenderer: BooleanCellRenderer, - type: TEXT_FILTER, + type: BOOLEAN_FILTER, getQuickFilterText: excludeFromGlobalFilter, }, { @@ -188,7 +194,7 @@ export const THREE_WINDINGS_TRANSFORMER_TAB_DEF = { field: 'hasLoadTapChanging2Capabilities', boolean: true, cellRenderer: BooleanCellRenderer, - type: TEXT_FILTER, + type: BOOLEAN_FILTER, getQuickFilterText: excludeFromGlobalFilter, }, { @@ -196,7 +202,7 @@ export const THREE_WINDINGS_TRANSFORMER_TAB_DEF = { field: 'isRegulatingRatio2', boolean: true, cellRenderer: BooleanCellRenderer, - type: TEXT_FILTER, + type: BOOLEAN_FILTER, getQuickFilterText: excludeFromGlobalFilter, }, { @@ -230,7 +236,7 @@ export const THREE_WINDINGS_TRANSFORMER_TAB_DEF = { field: 'hasLoadTapChanging3Capabilities', boolean: true, cellRenderer: BooleanCellRenderer, - type: TEXT_FILTER, + type: BOOLEAN_FILTER, getQuickFilterText: excludeFromGlobalFilter, }, { @@ -238,7 +244,7 @@ export const THREE_WINDINGS_TRANSFORMER_TAB_DEF = { field: 'isRegulatingRatio3', boolean: true, cellRenderer: BooleanCellRenderer, - type: TEXT_FILTER, + type: BOOLEAN_FILTER, getQuickFilterText: excludeFromGlobalFilter, }, { @@ -279,7 +285,7 @@ export const THREE_WINDINGS_TRANSFORMER_TAB_DEF = { field: 'isRegulatingPhase1', boolean: true, cellRenderer: BooleanCellRenderer, - type: TEXT_FILTER, + type: BOOLEAN_FILTER, getQuickFilterText: excludeFromGlobalFilter, }, { @@ -321,7 +327,7 @@ export const THREE_WINDINGS_TRANSFORMER_TAB_DEF = { field: 'isRegulatingPhase2', boolean: true, cellRenderer: BooleanCellRenderer, - type: TEXT_FILTER, + type: BOOLEAN_FILTER, getQuickFilterText: excludeFromGlobalFilter, }, { @@ -363,7 +369,7 @@ export const THREE_WINDINGS_TRANSFORMER_TAB_DEF = { field: 'isRegulatingPhase3', boolean: true, cellRenderer: BooleanCellRenderer, - type: TEXT_FILTER, + type: BOOLEAN_FILTER, getQuickFilterText: excludeFromGlobalFilter, }, { @@ -398,7 +404,7 @@ export const THREE_WINDINGS_TRANSFORMER_TAB_DEF = { field: 'terminal1Connected', boolean: true, cellRenderer: BooleanCellRenderer, - type: TEXT_FILTER, + type: BOOLEAN_FILTER, getQuickFilterText: excludeFromGlobalFilter, }, { @@ -406,7 +412,7 @@ export const THREE_WINDINGS_TRANSFORMER_TAB_DEF = { field: 'terminal2Connected', boolean: true, cellRenderer: BooleanCellRenderer, - type: TEXT_FILTER, + type: BOOLEAN_FILTER, getQuickFilterText: excludeFromGlobalFilter, }, { @@ -414,7 +420,7 @@ export const THREE_WINDINGS_TRANSFORMER_TAB_DEF = { field: 'terminal3Connected', boolean: true, cellRenderer: BooleanCellRenderer, - type: TEXT_FILTER, + type: BOOLEAN_FILTER, getQuickFilterText: excludeFromGlobalFilter, }, genericColumnOfProperties, diff --git a/src/components/spreadsheet/config/equipment/tie-line.ts b/src/components/spreadsheet/config/equipment/tie-line.ts index 1c52b4f635..25c7f4744c 100644 --- a/src/components/spreadsheet/config/equipment/tie-line.ts +++ b/src/components/spreadsheet/config/equipment/tie-line.ts @@ -11,7 +11,13 @@ import { EQUIPMENT_TYPES } from '../../../utils/equipment-types'; import CountryCellRenderer from '../../utils/country-cell-render'; import { BooleanCellRenderer } from '../../utils/cell-renderers'; import { excludeFromGlobalFilter, typeAndFetchers } from './common-config'; -import { COUNTRY_FILTER, MEDIUM_COLUMN_WIDTH, NUMERIC_FILTER, TEXT_FILTER } from '../../utils/constants'; +import { + BOOLEAN_FILTER, + COUNTRY_FILTER, + MEDIUM_COLUMN_WIDTH, + NUMERIC_FILTER, + TEXT_FILTER, +} from '../../utils/constants'; import { unitToMicroUnit } from '../../../../utils/unit-converter'; import { genericColumnOfPropertiesReadonly } from '../common/column-properties'; @@ -162,7 +168,7 @@ export const TIE_LINE_TAB_DEF = { field: 'terminal1Connected', boolean: true, cellRenderer: BooleanCellRenderer, - type: TEXT_FILTER, + type: BOOLEAN_FILTER, getQuickFilterText: excludeFromGlobalFilter, }, { @@ -170,7 +176,7 @@ export const TIE_LINE_TAB_DEF = { field: 'terminal2Connected', boolean: true, cellRenderer: BooleanCellRenderer, - type: TEXT_FILTER, + type: BOOLEAN_FILTER, getQuickFilterText: excludeFromGlobalFilter, }, genericColumnOfPropertiesReadonly, diff --git a/src/components/spreadsheet/config/equipment/two-windings-transformer.ts b/src/components/spreadsheet/config/equipment/two-windings-transformer.ts index 21d2361f84..81cf057c68 100644 --- a/src/components/spreadsheet/config/equipment/two-windings-transformer.ts +++ b/src/components/spreadsheet/config/equipment/two-windings-transformer.ts @@ -22,7 +22,13 @@ import { isEditable, typeAndFetchers, } from './common-config'; -import { COUNTRY_FILTER, MEDIUM_COLUMN_WIDTH, NUMERIC_FILTER, TEXT_FILTER } from '../../utils/constants'; +import { + BOOLEAN_FILTER, + COUNTRY_FILTER, + MEDIUM_COLUMN_WIDTH, + NUMERIC_FILTER, + TEXT_FILTER, +} from '../../utils/constants'; import { PHASE_REGULATION_MODES, RATIO_REGULATION_MODES, REGULATION_TYPES, SIDE } from '../../../network/constants'; import { computeHighTapPosition, getTapChangerRegulationTerminalValue } from '../../../utils/utils'; import { unitToMicroUnit } from '../../../../utils/unit-converter'; @@ -203,7 +209,7 @@ export const TWO_WINDINGS_TRANSFORMER_TAB_DEF = { field: 'ratioTapChanger.hasLoadTapChangingCapabilities', valueGetter: (params) => params?.data?.ratioTapChanger?.hasLoadTapChangingCapabilities, cellRenderer: BooleanCellRenderer, - type: TEXT_FILTER, + type: BOOLEAN_FILTER, editable: (params) => isEditable(params) && hasTwtRatioTapChanger(params), cellStyle: editableCellStyle, valueSetter: (params) => { @@ -621,7 +627,7 @@ export const TWO_WINDINGS_TRANSFORMER_TAB_DEF = { field: 'terminal1Connected', boolean: true, cellRenderer: BooleanCellRenderer, - type: TEXT_FILTER, + type: BOOLEAN_FILTER, getQuickFilterText: excludeFromGlobalFilter, }, { @@ -629,7 +635,7 @@ export const TWO_WINDINGS_TRANSFORMER_TAB_DEF = { field: 'terminal2Connected', boolean: true, cellRenderer: BooleanCellRenderer, - type: TEXT_FILTER, + type: BOOLEAN_FILTER, getQuickFilterText: excludeFromGlobalFilter, }, genericColumnOfPropertiesEditPopup, diff --git a/src/components/spreadsheet/config/equipment/vsc-converter-station.ts b/src/components/spreadsheet/config/equipment/vsc-converter-station.ts index 5579e1055c..7f50b9e390 100644 --- a/src/components/spreadsheet/config/equipment/vsc-converter-station.ts +++ b/src/components/spreadsheet/config/equipment/vsc-converter-station.ts @@ -11,7 +11,13 @@ import { EQUIPMENT_TYPES } from '../../../utils/equipment-types'; import CountryCellRenderer from '../../utils/country-cell-render'; import { BooleanCellRenderer } from '../../utils/cell-renderers'; import { excludeFromGlobalFilter, typeAndFetchers } from './common-config'; -import { COUNTRY_FILTER, MEDIUM_COLUMN_WIDTH, NUMERIC_FILTER, TEXT_FILTER } from '../../utils/constants'; +import { + BOOLEAN_FILTER, + COUNTRY_FILTER, + MEDIUM_COLUMN_WIDTH, + NUMERIC_FILTER, + TEXT_FILTER, +} from '../../utils/constants'; import { genericColumnOfProperties } from '../common/column-properties'; export const VSC_CONVERTER_STATION_TAB_DEF = { @@ -85,7 +91,7 @@ export const VSC_CONVERTER_STATION_TAB_DEF = { field: 'voltageRegulatorOn', boolean: true, cellRenderer: BooleanCellRenderer, - type: TEXT_FILTER, + type: BOOLEAN_FILTER, getQuickFilterText: excludeFromGlobalFilter, }, { @@ -109,7 +115,7 @@ export const VSC_CONVERTER_STATION_TAB_DEF = { field: 'terminalConnected', boolean: true, cellRenderer: BooleanCellRenderer, - type: TEXT_FILTER, + type: BOOLEAN_FILTER, getQuickFilterText: excludeFromGlobalFilter, }, genericColumnOfProperties, diff --git a/src/components/spreadsheet/equipment-table.tsx b/src/components/spreadsheet/equipment-table.tsx index 355b9fb93c..b1a1c696a8 100644 --- a/src/components/spreadsheet/equipment-table.tsx +++ b/src/components/spreadsheet/equipment-table.tsx @@ -21,6 +21,7 @@ import { } from 'ag-grid-community'; import { CurrentTreeNode } from '../../redux/reducer'; import { suppressEventsToPreventEditMode } from '../dialogs/commons/utils'; +import { useLocalizedCountries } from 'components/utils/localized-countries-hook'; const PINNED_ROW_HEIGHT = 42; const DEFAULT_ROW_HEIGHT = 28; @@ -74,6 +75,7 @@ export const EquipmentTable: FunctionComponent = ({ }) => { const theme = useTheme(); const intl = useIntl(); + const { translate } = useLocalizedCountries(); const getRowStyle = useCallback( (params: RowClassParams): RowStyle | undefined => { @@ -97,8 +99,10 @@ export const EquipmentTable: FunctionComponent = ({ dataToModify: topPinnedData ? JSON.parse(JSON.stringify(topPinnedData[0])) : {}, currentNode: currentNode, studyUuid: studyUuid, + intl: intl, + translateCountryCode: translate, }), - [currentNode, studyUuid, theme, topPinnedData] + [currentNode, intl, studyUuid, theme, topPinnedData, translate] ); const getRowHeight = useCallback( diff --git a/src/components/spreadsheet/table-wrapper.tsx b/src/components/spreadsheet/table-wrapper.tsx index a5bac8e7eb..179cf07742 100644 --- a/src/components/spreadsheet/table-wrapper.tsx +++ b/src/components/spreadsheet/table-wrapper.tsx @@ -14,7 +14,7 @@ import { Theme } from '@mui/material/styles'; import { EDIT_COLUMN, MIN_COLUMN_WIDTH, REORDERED_COLUMNS_PARAMETER_PREFIX_IN_DATABASE } from './utils/constants'; import { EquipmentTable } from './equipment-table'; import { Identifiable, useSnackMessage } from '@gridsuite/commons-ui'; -import { PARAM_DEVELOPER_MODE, PARAM_FLUX_CONVENTION } from '../../utils/config-params'; +import { PARAM_DEVELOPER_MODE, PARAM_FLUX_CONVENTION, PARAM_LANGUAGE } from '../../utils/config-params'; import { RunningStatus } from '../utils/running-status'; import { DefaultCellRenderer, @@ -77,17 +77,14 @@ import { ICellRendererParams, } from 'ag-grid-community'; import { mergeSx } from '../utils/functions'; -import { - CustomColDef, - FILTER_NUMBER_COMPARATORS, - FILTER_TEXT_COMPARATORS, -} from '../custom-aggrid/custom-aggrid-header.type'; +import { CustomColDef } from '../custom-aggrid/custom-aggrid-header.type'; import { FluxConventions } from '../dialogs/parameters/network-parameters'; -import { SpreadsheetEquipmentType } from './config/spreadsheet.type'; +import { SpreadsheetColDef, SpreadsheetEquipmentType } from './config/spreadsheet.type'; import SpreadsheetSave from './spreadsheet-save'; -import { defaultColumnType } from './config/column-type-flter-config'; -import { makeAgGridColumn } from './config/column-aggrid-utils'; +import { makeSpreadsheetAgGridColumn } from './config/column-aggrid-utils'; import { toModificationOperation } from 'components/utils/utils'; +import { defaultColumnType } from './config/column-type-flter-config'; +import { useParameterState } from 'components/dialogs/parameters/parameters'; const useEditBuffer = (): [Record, (field: string, value: unknown) => void, () => void] => { //the data is fed and read during the edition validation process so we don't need to rerender after a call to one of available methods thus useRef is more suited @@ -169,6 +166,7 @@ const TableWrapper: FunctionComponent = ({ const [tabIndex, setTabIndex] = useState(0); const loadFlowStatus = useSelector((state: AppState) => state.computingStatus[ComputingType.LOAD_FLOW]); + const [languageLocal] = useParameterState(PARAM_LANGUAGE); const allDisplayedColumnsNames = useSelector((state: AppState) => state.tables.columnsNamesJson); const allLockedColumnsNames = useSelector((state: AppState) => state.allLockedColumnsNames); @@ -297,32 +295,8 @@ const TableWrapper: FunctionComponent = ({ formatFetchedEquipmentsHandler ); - function contains(target: string, lookingFor: string) { - return target && target?.toLowerCase().indexOf(lookingFor.toLowerCase()) >= 0; - } - - const columnTypes = { - ...defaultColumnType, - countryFilter: { - filter: 'agTextColumnFilter', - filterParams: { - caseSensitive: false, - maxNumConditions: 1, - filterOptions: [FILTER_TEXT_COMPARATORS.CONTAINS], - textMatcher: ({ value, filterText }: { value: string; filterText: string }) => { - const countryCode = value?.toUpperCase(); - const countryName = translate(countryCode); - return contains(countryName, filterText || '') || contains(value, filterText); - }, - debounceMs: 200, - }, - sortable: true, - resizable: true, - }, - }; - const enrichColumn = useCallback( - (column: CustomColDef) => { + (column: SpreadsheetColDef) => { const columnExtended = { ...column }; columnExtended.headerName = intl.formatMessage({ id: columnExtended.id }); @@ -351,35 +325,6 @@ const TableWrapper: FunctionComponent = ({ } return 0; }; - // redefine agGrid predicates to possibly invert sign depending on flux convention (called when we use useAggridLocalRowFilter). - columnExtended.agGridFilterParams = { - filterOptions: [ - { - displayKey: FILTER_NUMBER_COMPARATORS.GREATER_THAN_OR_EQUAL, - displayName: FILTER_NUMBER_COMPARATORS.GREATER_THAN_OR_EQUAL, - predicate: (filterValues: number[], cellValue: number) => { - const filterValue = filterValues.at(0); - if (filterValue === undefined) { - return false; - } - const transformedValue = applyFluxConvention(cellValue); - return transformedValue != null ? transformedValue >= filterValue : false; - }, - }, - { - displayKey: FILTER_NUMBER_COMPARATORS.LESS_THAN_OR_EQUAL, - displayName: FILTER_NUMBER_COMPARATORS.LESS_THAN_OR_EQUAL, - predicate: (filterValues: number[], cellValue: number) => { - const filterValue = filterValues.at(0); - if (filterValue === undefined) { - return false; - } - const transformedValue = applyFluxConvention(cellValue); - return transformedValue != null ? transformedValue <= filterValue : false; - }, - }, - ], - }; } } @@ -419,7 +364,7 @@ const TableWrapper: FunctionComponent = ({ }; } - return makeAgGridColumn({ + return makeSpreadsheetAgGridColumn({ headerName: columnExtended.headerName, field: columnExtended.field, ...columnExtended, @@ -1197,6 +1142,10 @@ const TableWrapper: FunctionComponent = ({ setColumnData(generateTableColumns()); }, [generateTableColumns]); + useEffect(() => { + gridRef.current?.api?.setFilterModel(null); + }, [languageLocal]); + const topPinnedData = useMemo((): any[] | undefined => { if (editingData) { editingDataRef.current = { ...editingData }; @@ -1267,7 +1216,7 @@ const TableWrapper: FunctionComponent = ({ handleGridReady={handleGridReady} handleRowDataUpdated={handleRowDataUpdated} shouldHidePinnedHeaderRightBorder={isLockedColumnNamesEmpty} - columnTypes={columnTypes} + columnTypes={defaultColumnType} /> )} From 3bdede72f26412fea672d7f08ce427c1e5e30fdc Mon Sep 17 00:00:00 2001 From: TOURI ANIS Date: Fri, 13 Dec 2024 14:11:22 +0100 Subject: [PATCH 04/10] clean code --- .../config/equipment/common-config.ts | 70 ------------------- .../config/equipment/shunt-compensator.ts | 10 +-- 2 files changed, 2 insertions(+), 78 deletions(-) diff --git a/src/components/spreadsheet/config/equipment/common-config.ts b/src/components/spreadsheet/config/equipment/common-config.ts index 57921a0ac3..af37456ed5 100644 --- a/src/components/spreadsheet/config/equipment/common-config.ts +++ b/src/components/spreadsheet/config/equipment/common-config.ts @@ -10,7 +10,6 @@ import { getEnumLabelById } from '../../../utils/utils'; import { type CustomColDef, FILTER_DATA_TYPES, - FILTER_NUMBER_COMPARATORS, FILTER_TEXT_COMPARATORS, } from '../../../custom-aggrid/custom-aggrid-header.type'; import { EnumOption } from '../../../utils/utils-type'; @@ -37,7 +36,6 @@ import { fetchVscConverterStations, } from '../../../../services/study/network'; import { EquipmentFetcher, SpreadsheetColDef, SpreadsheetEquipmentType } from '../spreadsheet.type'; -import { BooleanFilterValue } from '../../../custom-aggrid/custom-aggrid-filters/custom-aggrid-boolean-filter'; import { getEnumFilterConfig } from '../column-type-flter-config'; type TapPositionsType = { @@ -125,61 +123,6 @@ export const defaultTextFilterConfig = { }, } as const satisfies Partial>; -/** - * Default configuration for an enum filter - * a new filter option is added to the default ag-grid filter - */ -export const defaultEnumFilterConfig = { - filter: 'agTextColumnFilter', - agGridFilterParams: { - filterOptions: [ - { - displayKey: 'customInRange', - displayName: 'customInRange', - predicate: (filterValues: string[], cellValue: string) => - // We receive here the filter enum values as a string (filterValue) - filterValues.at(0)?.includes(cellValue) ?? false, - }, - ], - }, - customFilterParams: { - filterDataType: FILTER_DATA_TYPES.TEXT, - }, - isEnum: true, -} as const satisfies Partial>; - -/** - * Default configuration for a boolean filter - */ -export const defaultBooleanFilterConfig = { - filter: 'agTextColumnFilter', - agGridFilterParams: { - filterOptions: [ - { - displayKey: 'booleanMatches', - displayName: 'booleanMatches', - predicate: (filterValues: string[], cellValue: boolean) => { - const filterValue = filterValues.at(0); - if (filterValue === undefined) { - return false; - } - // We receive here the filter boolean value as a string (filterValue) - // we check if the cellValue is not null neither undefined - if (cellValue != null) { - return filterValue === cellValue.toString(); - } - - // we return true if the filter chosen is undefinedValue - return filterValue === BooleanFilterValue.UNDEFINED; - }, - }, - ], - }, - customFilterParams: { - filterDataType: FILTER_DATA_TYPES.BOOLEAN, - }, -} as const satisfies Partial>; - // This function is used to generate the default configuration for an enum filter // It generates configuration for filtering, sorting and rendering export const getDefaultEnumConfig = (enumOptions: Readonly) => @@ -192,16 +135,3 @@ export const getDefaultEnumConfig = (enumOptions: Readonly) => } satisfies EnumCellRendererProps, getEnumLabel: (value: string) => getEnumLabelById(enumOptions as Writable, value), } as const satisfies Partial>); - -export const countryEnumFilterConfig = { - ...defaultEnumFilterConfig, - isCountry: true, -} as const satisfies Partial>; - -export const defaultNumericFilterConfig = { - filter: 'agNumberColumnFilter', - customFilterParams: { - filterDataType: FILTER_DATA_TYPES.NUMBER, - filterComparators: Object.values(FILTER_NUMBER_COMPARATORS), - }, -} as const satisfies Partial>; diff --git a/src/components/spreadsheet/config/equipment/shunt-compensator.ts b/src/components/spreadsheet/config/equipment/shunt-compensator.ts index 2427ebd2ab..f092edaeae 100644 --- a/src/components/spreadsheet/config/equipment/shunt-compensator.ts +++ b/src/components/spreadsheet/config/equipment/shunt-compensator.ts @@ -10,13 +10,7 @@ import type { SpreadsheetTabDefinition } from '../spreadsheet.type'; import { EQUIPMENT_TYPES } from '../../../utils/equipment-types'; import CountryCellRenderer from '../../utils/country-cell-render'; import { BooleanCellRenderer } from '../../utils/cell-renderers'; -import { - defaultNumericFilterConfig, - editableColumnConfig, - excludeFromGlobalFilter, - getDefaultEnumConfig, - typeAndFetchers, -} from './common-config'; +import { editableColumnConfig, excludeFromGlobalFilter, getDefaultEnumConfig, typeAndFetchers } from './common-config'; import { BOOLEAN_FILTER, COUNTRY_FILTER, @@ -63,7 +57,7 @@ export const SHUNT_COMPENSATOR_TAB_DEF = { id: 'NominalV', field: 'nominalVoltage', numeric: true, - ...defaultNumericFilterConfig, + type: NUMERIC_FILTER, fractionDigits: 0, }, { From a797d5cdac6f6c0baa1ef76be3b93a9910fc8046 Mon Sep 17 00:00:00 2001 From: TOURI ANIS Date: Fri, 13 Dec 2024 17:27:25 +0100 Subject: [PATCH 05/10] rename columnTypes --- ...config.ts => column-type-filter-config.ts} | 10 +- .../config/common/column-properties.tsx | 4 +- .../spreadsheet/config/equipment/battery.ts | 31 +++---- .../spreadsheet/config/equipment/bus.ts | 19 ++-- .../config/equipment/busbar-section.ts | 6 +- .../config/equipment/common-config.ts | 2 +- .../config/equipment/dangling-line.ts | 25 +++-- .../spreadsheet/config/equipment/generator.ts | 57 +++++------- .../spreadsheet/config/equipment/hvdc-line.ts | 44 +++++---- .../config/equipment/lcc-converter-station.ts | 25 +++-- .../spreadsheet/config/equipment/line.ts | 48 +++++----- .../spreadsheet/config/equipment/load.ts | 28 +++--- .../config/equipment/shunt-compensator.ts | 36 ++++---- .../equipment/static-var-compensator.ts | 28 +++--- .../config/equipment/substation.ts | 8 +- .../equipment/three-windings-transformer.ts | 92 +++++++++---------- .../spreadsheet/config/equipment/tie-line.ts | 48 +++++----- .../equipment/two-windings-transformer.ts | 74 +++++++-------- .../config/equipment/voltage-level.ts | 18 ++-- .../config/equipment/vsc-converter-station.ts | 34 +++---- src/components/spreadsheet/table-wrapper.tsx | 2 +- src/components/spreadsheet/utils/constants.ts | 10 +- 22 files changed, 298 insertions(+), 351 deletions(-) rename src/components/spreadsheet/config/{column-type-flter-config.ts => column-type-filter-config.ts} (95%) diff --git a/src/components/spreadsheet/config/column-type-flter-config.ts b/src/components/spreadsheet/config/column-type-filter-config.ts similarity index 95% rename from src/components/spreadsheet/config/column-type-flter-config.ts rename to src/components/spreadsheet/config/column-type-filter-config.ts index 4cbc9add71..92adcfc652 100644 --- a/src/components/spreadsheet/config/column-type-flter-config.ts +++ b/src/components/spreadsheet/config/column-type-filter-config.ts @@ -8,6 +8,7 @@ import { FILTER_NUMBER_COMPARATORS, FILTER_TEXT_COMPARATORS } from 'components/custom-aggrid/custom-aggrid-header.type'; import { getEnumLabelById } from 'components/utils/utils'; import { EnumOption } from 'components/utils/utils-type'; +import CountryCellRenderer from '../utils/country-cell-render'; const contains = (target: string, lookingFor: string): boolean => { if (target && lookingFor) { @@ -39,7 +40,7 @@ export const getEnumFilterConfig = (enumOptions: EnumOption[]) => { }; export const defaultColumnType = { - textFilter: { + textType: { filter: 'agTextColumnFilter', filterParams: { caseSensitive: false, @@ -49,7 +50,7 @@ export const defaultColumnType = { sortable: true, resizable: true, }, - numericFilter: { + numericType: { filter: 'agNumberColumnFilter', filterParams: { maxNumConditions: 1, @@ -59,7 +60,7 @@ export const defaultColumnType = { sortable: false, resizable: true, }, - booleanFilter: { + booleanType: { filter: 'agTextColumnFilter', filterParams: { caseSensitive: false, @@ -76,7 +77,7 @@ export const defaultColumnType = { sortable: true, resizable: true, }, - countryFilter: { + countryType: { filter: 'agTextColumnFilter', filterParams: { caseSensitive: false, @@ -94,5 +95,6 @@ export const defaultColumnType = { }, sortable: true, resizable: true, + cellRenderer: CountryCellRenderer, }, }; diff --git a/src/components/spreadsheet/config/common/column-properties.tsx b/src/components/spreadsheet/config/common/column-properties.tsx index 25d3aa4c3e..47238bc663 100644 --- a/src/components/spreadsheet/config/common/column-properties.tsx +++ b/src/components/spreadsheet/config/common/column-properties.tsx @@ -9,7 +9,7 @@ import { PropertiesCellRenderer } from '../../utils/cell-renderers'; import { SitePropertiesEditor } from '../../utils/equipement-table-popup-editors'; import type { ValueGetterFunc, ValueSetterParams } from 'ag-grid-community'; import { editableColumnConfig, excludeFromGlobalFilter } from '../equipment/common-config'; -import { TEXT_FILTER } from 'components/spreadsheet/utils/constants'; +import { TEXT_TYPE } from 'components/spreadsheet/utils/constants'; const propertiesGetter: ValueGetterFunc = (params) => { const properties = params?.data?.properties; @@ -30,7 +30,7 @@ export const genericColumnOfPropertiesReadonly = { cellRenderer: PropertiesCellRenderer, minWidth: 300, getQuickFilterText: excludeFromGlobalFilter, - type: TEXT_FILTER, + type: TEXT_TYPE, }; export const genericColumnOfProperties = { diff --git a/src/components/spreadsheet/config/equipment/battery.ts b/src/components/spreadsheet/config/equipment/battery.ts index 0f1529bf99..bec3b309b4 100644 --- a/src/components/spreadsheet/config/equipment/battery.ts +++ b/src/components/spreadsheet/config/equipment/battery.ts @@ -13,7 +13,7 @@ import { editableColumnConfig, excludeFromGlobalFilter, typeAndFetchers } from ' import type { SpreadsheetTabDefinition } from '../spreadsheet.type'; import { genericColumnOfPropertiesEditPopup } from '../common/column-properties'; import { booleanCellEditorConfig, numericalCellEditorConfig } from '../common/cell-editors'; -import { BOOLEAN_FILTER, COUNTRY_FILTER, NUMERIC_FILTER, TEXT_FILTER } from 'components/spreadsheet/utils/constants'; +import { BOOLEAN_TYPE, COUNTRY_TYPE, NUMERIC_TYPE, TEXT_TYPE } from 'components/spreadsheet/utils/constants'; export const BATTERY_TAB_DEF = { index: 9, @@ -24,30 +24,29 @@ export const BATTERY_TAB_DEF = { id: 'ID', field: 'id', isDefaultSort: true, - type: TEXT_FILTER, + type: TEXT_TYPE, }, { id: 'Name', field: 'name', - type: TEXT_FILTER, + type: TEXT_TYPE, ...editableColumnConfig, }, { id: 'VoltageLevelId', field: 'voltageLevelId', - type: TEXT_FILTER, + type: TEXT_TYPE, }, { id: 'Country', field: 'country', - type: COUNTRY_FILTER, - cellRenderer: CountryCellRenderer, + type: COUNTRY_TYPE, }, { id: 'NominalV', field: 'nominalVoltage', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 0, }, { @@ -55,7 +54,7 @@ export const BATTERY_TAB_DEF = { field: 'p', numeric: true, fractionDigits: 1, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, canBeInvalidated: true, withFluxConvention: true, getQuickFilterText: excludeFromGlobalFilter, @@ -65,7 +64,7 @@ export const BATTERY_TAB_DEF = { field: 'q', numeric: true, fractionDigits: 1, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, canBeInvalidated: true, withFluxConvention: true, getQuickFilterText: excludeFromGlobalFilter, @@ -74,7 +73,7 @@ export const BATTERY_TAB_DEF = { id: 'ActivePowerControl', field: 'activePowerControl.participate', cellRenderer: BooleanCellRenderer, - type: BOOLEAN_FILTER, + type: BOOLEAN_TYPE, ...editableColumnConfig, valueSetter: (params) => { params.data.activePowerControl = { @@ -90,7 +89,7 @@ export const BATTERY_TAB_DEF = { id: 'DroopColumnName', field: 'activePowerControl.droop', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 1, ...editableColumnConfig, ...numericalCellEditorConfig((params) => params.data.activePowerControl?.droop), @@ -114,7 +113,7 @@ export const BATTERY_TAB_DEF = { id: 'minP', field: 'minP', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 1, ...editableColumnConfig, ...numericalCellEditorConfig((params) => params.data.minP), @@ -127,7 +126,7 @@ export const BATTERY_TAB_DEF = { id: 'maxP', field: 'maxP', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 1, ...editableColumnConfig, ...numericalCellEditorConfig((params) => params.data.maxP), @@ -140,7 +139,7 @@ export const BATTERY_TAB_DEF = { id: 'activePowerSetpoint', field: 'targetP', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 1, ...editableColumnConfig, ...numericalCellEditorConfig((params) => params.data.targetP), @@ -155,7 +154,7 @@ export const BATTERY_TAB_DEF = { id: 'reactivePowerSetpoint', field: 'targetQ', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 1, ...editableColumnConfig, ...numericalCellEditorConfig((params) => params.data.targetQ), @@ -166,7 +165,7 @@ export const BATTERY_TAB_DEF = { field: 'terminalConnected', boolean: true, cellRenderer: BooleanCellRenderer, - type: BOOLEAN_FILTER, + type: BOOLEAN_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, genericColumnOfPropertiesEditPopup, diff --git a/src/components/spreadsheet/config/equipment/bus.ts b/src/components/spreadsheet/config/equipment/bus.ts index da38a0fa5f..ca0e4ddafd 100644 --- a/src/components/spreadsheet/config/equipment/bus.ts +++ b/src/components/spreadsheet/config/equipment/bus.ts @@ -11,7 +11,7 @@ import { EQUIPMENT_TYPES } from '../../../utils/equipment-types'; import CountryCellRenderer from '../../utils/country-cell-render'; import { typeAndFetchers } from './common-config'; import { genericColumnOfProperties } from '../common/column-properties'; -import { COUNTRY_FILTER, NUMERIC_FILTER, TEXT_FILTER } from 'components/spreadsheet/utils/constants'; +import { COUNTRY_TYPE, NUMERIC_TYPE, TEXT_TYPE } from 'components/spreadsheet/utils/constants'; export const BUS_TAB_DEF = { index: 14, @@ -22,7 +22,7 @@ export const BUS_TAB_DEF = { id: 'ID', field: 'id', isDefaultSort: true, - type: TEXT_FILTER, + type: TEXT_TYPE, }, { id: 'Magnitude', @@ -30,7 +30,7 @@ export const BUS_TAB_DEF = { numeric: true, fractionDigits: 1, canBeInvalidated: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, }, { id: 'Angle', @@ -38,35 +38,34 @@ export const BUS_TAB_DEF = { numeric: true, fractionDigits: 1, canBeInvalidated: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, }, { id: 'ConnectedComponent', field: 'connectedComponentNum', - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, }, { id: 'SynchronousComponent', field: 'synchronousComponentNum', - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, }, { id: 'VoltageLevelId', field: 'voltageLevelId', - type: TEXT_FILTER, + type: TEXT_TYPE, }, { id: 'Country', field: 'country', - type: COUNTRY_FILTER, - cellRenderer: CountryCellRenderer, + type: COUNTRY_TYPE, }, { id: 'NominalV', field: 'nominalVoltage', numeric: true, fractionDigits: 0, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, }, genericColumnOfProperties, ], diff --git a/src/components/spreadsheet/config/equipment/busbar-section.ts b/src/components/spreadsheet/config/equipment/busbar-section.ts index 8d11a4578d..55aa2f103b 100644 --- a/src/components/spreadsheet/config/equipment/busbar-section.ts +++ b/src/components/spreadsheet/config/equipment/busbar-section.ts @@ -9,7 +9,7 @@ import { SpreadsheetTabDefinition } from '../spreadsheet.type'; import { EQUIPMENT_TYPES } from '../../../utils/equipment-types'; import { typeAndFetchers } from './common-config'; import type { ReadonlyDeep } from 'type-fest'; -import { TEXT_FILTER } from 'components/spreadsheet/utils/constants'; +import { TEXT_TYPE } from 'components/spreadsheet/utils/constants'; export const BUSBAR_SECTION_TAB_DEF = { index: 16, @@ -20,12 +20,12 @@ export const BUSBAR_SECTION_TAB_DEF = { id: 'ID', field: 'id', isDefaultSort: true, - type: TEXT_FILTER, + type: TEXT_TYPE, }, { id: 'VoltageLevelId', field: 'voltageLevelId', - type: TEXT_FILTER, + type: TEXT_TYPE, }, ], } as const satisfies ReadonlyDeep; diff --git a/src/components/spreadsheet/config/equipment/common-config.ts b/src/components/spreadsheet/config/equipment/common-config.ts index af37456ed5..9dd8782fff 100644 --- a/src/components/spreadsheet/config/equipment/common-config.ts +++ b/src/components/spreadsheet/config/equipment/common-config.ts @@ -36,7 +36,7 @@ import { fetchVscConverterStations, } from '../../../../services/study/network'; import { EquipmentFetcher, SpreadsheetColDef, SpreadsheetEquipmentType } from '../spreadsheet.type'; -import { getEnumFilterConfig } from '../column-type-flter-config'; +import { getEnumFilterConfig } from '../column-type-filter-config'; type TapPositionsType = { lowTapPosition: number; diff --git a/src/components/spreadsheet/config/equipment/dangling-line.ts b/src/components/spreadsheet/config/equipment/dangling-line.ts index 155d13a4b1..2bf39c0a9b 100644 --- a/src/components/spreadsheet/config/equipment/dangling-line.ts +++ b/src/components/spreadsheet/config/equipment/dangling-line.ts @@ -13,7 +13,7 @@ import { BooleanCellRenderer } from '../../utils/cell-renderers'; import { excludeFromGlobalFilter, typeAndFetchers } from './common-config'; import { NOMINAL_V } from '../../../utils/field-constants'; import { genericColumnOfProperties } from '../common/column-properties'; -import { BOOLEAN_FILTER, COUNTRY_FILTER, NUMERIC_FILTER, TEXT_FILTER } from 'components/spreadsheet/utils/constants'; +import { BOOLEAN_TYPE, COUNTRY_TYPE, NUMERIC_TYPE, TEXT_TYPE } from 'components/spreadsheet/utils/constants'; export const DANGLING_LINE_TAB_DEF = { index: 13, @@ -24,42 +24,41 @@ export const DANGLING_LINE_TAB_DEF = { id: 'ID', field: 'id', isDefaultSort: true, - type: TEXT_FILTER, + type: TEXT_TYPE, }, { id: 'Name', field: 'name', - type: TEXT_FILTER, + type: TEXT_TYPE, }, { id: 'VoltageLevelId', field: 'voltageLevelId', - type: TEXT_FILTER, + type: TEXT_TYPE, }, { id: 'Country', field: 'country', - type: COUNTRY_FILTER, - cellRenderer: CountryCellRenderer, + type: COUNTRY_TYPE, }, { id: 'NominalV', field: NOMINAL_V, numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 0, }, { id: 'PairingKey', field: 'pairingKey', getQuickFilterText: excludeFromGlobalFilter, - type: TEXT_FILTER, + type: TEXT_TYPE, }, { id: 'activePower', field: 'p', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 1, canBeInvalidated: true, getQuickFilterText: excludeFromGlobalFilter, @@ -68,7 +67,7 @@ export const DANGLING_LINE_TAB_DEF = { id: 'ReactivePower', field: 'q', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 1, canBeInvalidated: true, getQuickFilterText: excludeFromGlobalFilter, @@ -77,7 +76,7 @@ export const DANGLING_LINE_TAB_DEF = { id: 'p0', field: 'p0', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 1, getQuickFilterText: excludeFromGlobalFilter, }, @@ -85,7 +84,7 @@ export const DANGLING_LINE_TAB_DEF = { id: 'q0', field: 'q0', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 1, getQuickFilterText: excludeFromGlobalFilter, }, @@ -94,7 +93,7 @@ export const DANGLING_LINE_TAB_DEF = { field: 'terminalConnected', boolean: true, cellRenderer: BooleanCellRenderer, - type: BOOLEAN_FILTER, + type: BOOLEAN_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, genericColumnOfProperties, diff --git a/src/components/spreadsheet/config/equipment/generator.ts b/src/components/spreadsheet/config/equipment/generator.ts index 89a1237353..6535549ac1 100644 --- a/src/components/spreadsheet/config/equipment/generator.ts +++ b/src/components/spreadsheet/config/equipment/generator.ts @@ -22,13 +22,7 @@ import { getDefaultEnumConfig, typeAndFetchers, } from './common-config'; -import { - BOOLEAN_FILTER, - COUNTRY_FILTER, - MEDIUM_COLUMN_WIDTH, - NUMERIC_FILTER, - TEXT_FILTER, -} from '../../utils/constants'; +import { BOOLEAN_TYPE, COUNTRY_TYPE, MEDIUM_COLUMN_WIDTH, NUMERIC_TYPE, TEXT_TYPE } from '../../utils/constants'; import { ENERGY_SOURCES, REGULATION_TYPES } from '../../../network/constants'; import { genericColumnOfPropertiesEditPopup } from '../common/column-properties'; import { @@ -74,30 +68,29 @@ export const GENERATOR_TAB_DEF = { field: 'id', columnWidth: MEDIUM_COLUMN_WIDTH, isDefaultSort: true, - type: TEXT_FILTER, + type: TEXT_TYPE, }, { id: 'Name', field: 'name', - type: TEXT_FILTER, + type: TEXT_TYPE, ...editableColumnConfig, }, { id: 'VoltageLevelId', field: 'voltageLevelId', - type: TEXT_FILTER, + type: TEXT_TYPE, }, { id: 'Country', field: 'country', - type: COUNTRY_FILTER, - cellRenderer: CountryCellRenderer, + type: COUNTRY_TYPE, }, { id: 'NominalV', field: 'nominalVoltage', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 0, }, { @@ -112,7 +105,7 @@ export const GENERATOR_TAB_DEF = { field: 'p', numeric: true, fractionDigits: 1, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, canBeInvalidated: true, withFluxConvention: true, getQuickFilterText: excludeFromGlobalFilter, @@ -122,7 +115,7 @@ export const GENERATOR_TAB_DEF = { field: 'q', numeric: true, fractionDigits: 1, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, canBeInvalidated: true, withFluxConvention: true, getQuickFilterText: excludeFromGlobalFilter, @@ -131,7 +124,7 @@ export const GENERATOR_TAB_DEF = { id: 'ActivePowerControl', field: 'activePowerControl.participate', cellRenderer: BooleanCellRenderer, - type: BOOLEAN_FILTER, + type: BOOLEAN_TYPE, ...editableColumnConfig, valueSetter: (params) => { params.data.activePowerControl = { @@ -148,7 +141,7 @@ export const GENERATOR_TAB_DEF = { id: 'ActivePowerRegulationDroop', field: 'activePowerControl.droop', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 1, ...editableColumnConfig, ...numericalCellEditorConfig((params) => params.data.activePowerControl?.droop), @@ -172,7 +165,7 @@ export const GENERATOR_TAB_DEF = { id: 'minP', field: 'minP', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 1, ...editableColumnConfig, ...numericalCellEditorConfig((params) => params.data.minP), @@ -185,7 +178,7 @@ export const GENERATOR_TAB_DEF = { id: 'maxP', field: 'maxP', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 1, ...editableColumnConfig, ...numericalCellEditorConfig((params) => params.data.maxP), @@ -198,7 +191,7 @@ export const GENERATOR_TAB_DEF = { id: 'activePowerSetpoint', field: 'targetP', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, ...editableColumnConfig, ...numericalCellEditorConfig((params) => params.data.targetP), fractionDigits: 1, @@ -213,7 +206,7 @@ export const GENERATOR_TAB_DEF = { id: 'reactivePowerSetpoint', field: 'targetQ', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 1, ...editableColumnConfig, ...numericalCellEditorConfig((params) => params.data.targetQ), @@ -229,7 +222,7 @@ export const GENERATOR_TAB_DEF = { id: 'voltageRegulationOn', field: 'voltageRegulatorOn', cellRenderer: BooleanCellRenderer, - type: BOOLEAN_FILTER, + type: BOOLEAN_TYPE, ...editableColumnConfig, ...booleanCellEditorConfig((params) => params.data?.voltageRegulatorOn ?? false), getQuickFilterText: excludeFromGlobalFilter, @@ -238,7 +231,7 @@ export const GENERATOR_TAB_DEF = { id: 'voltageSetpoint', field: 'targetV', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 1, ...editableColumnConfig, ...numericalCellEditorConfig((params) => params.data.targetV), @@ -253,7 +246,7 @@ export const GENERATOR_TAB_DEF = { { id: 'ReactivePercentageVoltageRegulation', field: 'coordinatedReactiveControl.qPercent', - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, getQuickFilterText: excludeFromGlobalFilter, ...editableColumnConfig, numeric: true, @@ -281,7 +274,7 @@ export const GENERATOR_TAB_DEF = { id: 'directTransX', field: 'generatorShortCircuit.directTransX', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 1, getQuickFilterText: excludeFromGlobalFilter, ...editableColumnConfig, @@ -302,7 +295,7 @@ export const GENERATOR_TAB_DEF = { id: 'stepUpTransformerX', field: 'generatorShortCircuit.stepUpTransformerX', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 1, getQuickFilterText: excludeFromGlobalFilter, ...editableColumnConfig, @@ -323,7 +316,7 @@ export const GENERATOR_TAB_DEF = { id: 'plannedActivePowerSetPoint', field: 'generatorStartup.plannedActivePowerSetPoint', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 1, getQuickFilterText: excludeFromGlobalFilter, ...editableColumnConfig, @@ -346,7 +339,7 @@ export const GENERATOR_TAB_DEF = { ...editableColumnConfig, ...numericalCellEditorConfig((params) => params.data?.generatorStartup?.marginalCost), numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 1, getQuickFilterText: excludeFromGlobalFilter, valueGetter: (params) => params.data?.generatorStartup?.marginalCost, @@ -365,7 +358,7 @@ export const GENERATOR_TAB_DEF = { id: 'plannedOutageRate', field: 'generatorStartup.plannedOutageRate', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 2, getQuickFilterText: excludeFromGlobalFilter, ...editableColumnConfig, @@ -388,7 +381,7 @@ export const GENERATOR_TAB_DEF = { id: 'forcedOutageRate', field: 'generatorStartup.forcedOutageRate', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 2, getQuickFilterText: excludeFromGlobalFilter, ...editableColumnConfig, @@ -412,7 +405,7 @@ export const GENERATOR_TAB_DEF = { field: 'terminalConnected', boolean: true, cellRenderer: BooleanCellRenderer, - type: BOOLEAN_FILTER, + type: BOOLEAN_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, { @@ -425,7 +418,7 @@ export const GENERATOR_TAB_DEF = { { id: 'RegulatingTerminalGenerator', field: 'RegulatingTerminalGenerator', - type: TEXT_FILTER, + type: TEXT_TYPE, valueGetter: RegulatingTerminalCellGetter, cellStyle: (params) => (isEditableRegulatingTerminalCell(params) ? editableCellStyle(params) : {}), editable: isEditableRegulatingTerminalCell, diff --git a/src/components/spreadsheet/config/equipment/hvdc-line.ts b/src/components/spreadsheet/config/equipment/hvdc-line.ts index a113df7112..07e41b3411 100644 --- a/src/components/spreadsheet/config/equipment/hvdc-line.ts +++ b/src/components/spreadsheet/config/equipment/hvdc-line.ts @@ -12,12 +12,12 @@ import CountryCellRenderer from '../../utils/country-cell-render'; import { BooleanCellRenderer } from '../../utils/cell-renderers'; import { excludeFromGlobalFilter, typeAndFetchers } from './common-config'; import { - BOOLEAN_FILTER, - COUNTRY_FILTER, + BOOLEAN_TYPE, + COUNTRY_TYPE, LARGE_COLUMN_WIDTH, MEDIUM_COLUMN_WIDTH, - NUMERIC_FILTER, - TEXT_FILTER, + NUMERIC_TYPE, + TEXT_TYPE, } from '../../utils/constants'; import { genericColumnOfProperties } from '../common/column-properties'; @@ -31,60 +31,58 @@ export const HVDC_LINE_TAB_DEF = { field: 'id', columnWidth: MEDIUM_COLUMN_WIDTH, isDefaultSort: true, - type: TEXT_FILTER, + type: TEXT_TYPE, }, { id: 'Name', field: 'name', columnWidth: MEDIUM_COLUMN_WIDTH, - type: TEXT_FILTER, + type: TEXT_TYPE, }, { id: 'VoltageLevelIdSide1', field: 'voltageLevelId1', - type: TEXT_FILTER, + type: TEXT_TYPE, }, { id: 'VoltageLevelIdSide2', field: 'voltageLevelId2', - type: TEXT_FILTER, + type: TEXT_TYPE, }, { id: 'ConvertersMode', field: 'convertersMode', columnWidth: LARGE_COLUMN_WIDTH, getQuickFilterText: excludeFromGlobalFilter, - type: TEXT_FILTER, + type: TEXT_TYPE, }, { id: 'ConverterStationId1', field: 'converterStationId1', columnWidth: LARGE_COLUMN_WIDTH, - type: TEXT_FILTER, + type: TEXT_TYPE, }, { id: 'ConverterStationId2', field: 'converterStationId2', columnWidth: LARGE_COLUMN_WIDTH, - type: TEXT_FILTER, + type: TEXT_TYPE, }, { id: 'Country1', field: 'country1', - type: COUNTRY_FILTER, - cellRenderer: CountryCellRenderer, + type: COUNTRY_TYPE, }, { id: 'Country2', field: 'country2', - type: COUNTRY_FILTER, - cellRenderer: CountryCellRenderer, + type: COUNTRY_TYPE, }, { id: 'R', field: 'r', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 1, getQuickFilterText: excludeFromGlobalFilter, }, @@ -92,7 +90,7 @@ export const HVDC_LINE_TAB_DEF = { id: 'ActivePowerSetpoint', field: 'activePowerSetpoint', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 1, getQuickFilterText: excludeFromGlobalFilter, }, @@ -100,7 +98,7 @@ export const HVDC_LINE_TAB_DEF = { id: 'maxActivePower', field: 'maxP', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 1, getQuickFilterText: excludeFromGlobalFilter, }, @@ -108,7 +106,7 @@ export const HVDC_LINE_TAB_DEF = { id: 'OprFromCS1toCS2', field: 'hvdcOperatorActivePowerRange.oprFromCS1toCS2', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 1, columnWidth: LARGE_COLUMN_WIDTH, getQuickFilterText: excludeFromGlobalFilter, @@ -117,7 +115,7 @@ export const HVDC_LINE_TAB_DEF = { id: 'OprFromCS2toCS1', field: 'hvdcOperatorActivePowerRange.oprFromCS2toCS1', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 1, columnWidth: LARGE_COLUMN_WIDTH, getQuickFilterText: excludeFromGlobalFilter, @@ -127,14 +125,14 @@ export const HVDC_LINE_TAB_DEF = { field: 'hvdcAngleDroopActivePowerControl.isEnabled', boolean: true, cellRenderer: BooleanCellRenderer, - type: BOOLEAN_FILTER, + type: BOOLEAN_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, { id: 'K', field: 'hvdcAngleDroopActivePowerControl.droop', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 1, getQuickFilterText: excludeFromGlobalFilter, }, @@ -142,7 +140,7 @@ export const HVDC_LINE_TAB_DEF = { id: 'P0', field: 'hvdcAngleDroopActivePowerControl.p0', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 1, getQuickFilterText: excludeFromGlobalFilter, }, diff --git a/src/components/spreadsheet/config/equipment/lcc-converter-station.ts b/src/components/spreadsheet/config/equipment/lcc-converter-station.ts index bdb7142813..aef6d7f14f 100644 --- a/src/components/spreadsheet/config/equipment/lcc-converter-station.ts +++ b/src/components/spreadsheet/config/equipment/lcc-converter-station.ts @@ -12,7 +12,7 @@ import CountryCellRenderer from '../../utils/country-cell-render'; import { BooleanCellRenderer } from '../../utils/cell-renderers'; import { excludeFromGlobalFilter, typeAndFetchers } from './common-config'; import { genericColumnOfProperties } from '../common/column-properties'; -import { BOOLEAN_FILTER, COUNTRY_FILTER, NUMERIC_FILTER, TEXT_FILTER } from 'components/spreadsheet/utils/constants'; +import { BOOLEAN_TYPE, COUNTRY_TYPE, NUMERIC_TYPE, TEXT_TYPE } from 'components/spreadsheet/utils/constants'; export const LCC_CONVERTER_STATION_TAB_DEF = { index: 11, @@ -23,41 +23,40 @@ export const LCC_CONVERTER_STATION_TAB_DEF = { id: 'ID', field: 'id', isDefaultSort: true, - type: TEXT_FILTER, + type: TEXT_TYPE, }, { id: 'Name', field: 'name', - type: TEXT_FILTER, + type: TEXT_TYPE, }, { id: 'VoltageLevelId', field: 'voltageLevelId', - type: TEXT_FILTER, + type: TEXT_TYPE, }, { id: 'Country', field: 'country', - type: COUNTRY_FILTER, - cellRenderer: CountryCellRenderer, + type: COUNTRY_TYPE, }, { id: 'NominalV', field: 'nominalV', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 0, }, { id: 'HvdcLineId', field: 'hvdcLineId', - type: TEXT_FILTER, + type: TEXT_TYPE, }, { id: 'activePower', field: 'p', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 1, canBeInvalidated: true, getQuickFilterText: excludeFromGlobalFilter, @@ -66,7 +65,7 @@ export const LCC_CONVERTER_STATION_TAB_DEF = { id: 'ReactivePower', field: 'q', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 1, canBeInvalidated: true, getQuickFilterText: excludeFromGlobalFilter, @@ -75,7 +74,7 @@ export const LCC_CONVERTER_STATION_TAB_DEF = { id: 'PowerFactor', field: 'powerFactor', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 1, getQuickFilterText: excludeFromGlobalFilter, }, @@ -83,7 +82,7 @@ export const LCC_CONVERTER_STATION_TAB_DEF = { id: 'LossFactor', field: 'lossFactor', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 1, getQuickFilterText: excludeFromGlobalFilter, }, @@ -92,7 +91,7 @@ export const LCC_CONVERTER_STATION_TAB_DEF = { field: 'terminalConnected', boolean: true, cellRenderer: BooleanCellRenderer, - type: BOOLEAN_FILTER, + type: BOOLEAN_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, genericColumnOfProperties, diff --git a/src/components/spreadsheet/config/equipment/line.ts b/src/components/spreadsheet/config/equipment/line.ts index 055847067c..2735e349ff 100644 --- a/src/components/spreadsheet/config/equipment/line.ts +++ b/src/components/spreadsheet/config/equipment/line.ts @@ -11,13 +11,7 @@ import { EQUIPMENT_TYPES } from '../../../utils/equipment-types'; import CountryCellRenderer from '../../utils/country-cell-render'; import { BooleanCellRenderer } from '../../utils/cell-renderers'; import { excludeFromGlobalFilter, typeAndFetchers } from './common-config'; -import { - BOOLEAN_FILTER, - COUNTRY_FILTER, - MEDIUM_COLUMN_WIDTH, - NUMERIC_FILTER, - TEXT_FILTER, -} from '../../utils/constants'; +import { BOOLEAN_TYPE, COUNTRY_TYPE, MEDIUM_COLUMN_WIDTH, NUMERIC_TYPE, TEXT_TYPE } from '../../utils/constants'; import { unitToMicroUnit } from '../../../../utils/unit-converter'; import { genericColumnOfProperties } from '../common/column-properties'; @@ -31,55 +25,55 @@ export const LINE_TAB_DEF = { field: 'id', columnWidth: MEDIUM_COLUMN_WIDTH, isDefaultSort: true, - type: TEXT_FILTER, + type: TEXT_TYPE, }, { id: 'Name', field: 'name', columnWidth: MEDIUM_COLUMN_WIDTH, - type: TEXT_FILTER, + type: TEXT_TYPE, }, { id: 'VoltageLevelIdSide1', field: 'voltageLevelId1', - type: TEXT_FILTER, + type: TEXT_TYPE, }, { id: 'VoltageLevelIdSide2', field: 'voltageLevelId2', - type: TEXT_FILTER, + type: TEXT_TYPE, }, { id: 'Country1', field: 'country1', - type: COUNTRY_FILTER, + type: COUNTRY_TYPE, cellRenderer: CountryCellRenderer, }, { id: 'Country2', field: 'country2', - type: COUNTRY_FILTER, + type: COUNTRY_TYPE, cellRenderer: CountryCellRenderer, }, { id: 'nominalVoltage1KV', field: 'nominalVoltage1', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 0, }, { id: 'nominalVoltage2KV', field: 'nominalVoltage2', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 0, }, { id: 'ActivePowerSide1', field: 'p1', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 1, canBeInvalidated: true, getQuickFilterText: excludeFromGlobalFilter, @@ -88,7 +82,7 @@ export const LINE_TAB_DEF = { id: 'ActivePowerSide2', field: 'p2', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 1, canBeInvalidated: true, getQuickFilterText: excludeFromGlobalFilter, @@ -97,7 +91,7 @@ export const LINE_TAB_DEF = { id: 'ReactivePowerSide1', field: 'q1', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 1, canBeInvalidated: true, getQuickFilterText: excludeFromGlobalFilter, @@ -106,7 +100,7 @@ export const LINE_TAB_DEF = { id: 'ReactivePowerSide2', field: 'q2', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 1, canBeInvalidated: true, getQuickFilterText: excludeFromGlobalFilter, @@ -115,7 +109,7 @@ export const LINE_TAB_DEF = { id: 'r', field: 'r', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 1, getQuickFilterText: excludeFromGlobalFilter, }, @@ -123,7 +117,7 @@ export const LINE_TAB_DEF = { id: 'x', field: 'x', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 1, getQuickFilterText: excludeFromGlobalFilter, }, @@ -131,7 +125,7 @@ export const LINE_TAB_DEF = { id: 'g1', field: 'g1', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 1, valueGetter: (params) => unitToMicroUnit(params.data.g1), getQuickFilterText: excludeFromGlobalFilter, @@ -140,7 +134,7 @@ export const LINE_TAB_DEF = { id: 'g2', field: 'g2', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 1, valueGetter: (params) => unitToMicroUnit(params.data.g2), getQuickFilterText: excludeFromGlobalFilter, @@ -149,7 +143,7 @@ export const LINE_TAB_DEF = { id: 'b1', field: 'b1', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 1, valueGetter: (params) => unitToMicroUnit(params.data.b1), getQuickFilterText: excludeFromGlobalFilter, @@ -158,7 +152,7 @@ export const LINE_TAB_DEF = { id: 'b2', field: 'b2', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 1, valueGetter: (params) => unitToMicroUnit(params.data.b2), getQuickFilterText: excludeFromGlobalFilter, @@ -168,7 +162,7 @@ export const LINE_TAB_DEF = { field: 'terminal1Connected', boolean: true, cellRenderer: BooleanCellRenderer, - type: BOOLEAN_FILTER, + type: BOOLEAN_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, { @@ -176,7 +170,7 @@ export const LINE_TAB_DEF = { field: 'terminal2Connected', boolean: true, cellRenderer: BooleanCellRenderer, - type: BOOLEAN_FILTER, + type: BOOLEAN_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, genericColumnOfProperties, diff --git a/src/components/spreadsheet/config/equipment/load.ts b/src/components/spreadsheet/config/equipment/load.ts index 2aa9397c2a..f66bf4ea09 100644 --- a/src/components/spreadsheet/config/equipment/load.ts +++ b/src/components/spreadsheet/config/equipment/load.ts @@ -11,13 +11,7 @@ import { EQUIPMENT_TYPES } from '../../../utils/equipment-types'; import CountryCellRenderer from '../../utils/country-cell-render'; import { BooleanCellRenderer } from '../../utils/cell-renderers'; import { editableColumnConfig, excludeFromGlobalFilter, getDefaultEnumConfig, typeAndFetchers } from './common-config'; -import { - BOOLEAN_FILTER, - COUNTRY_FILTER, - MEDIUM_COLUMN_WIDTH, - NUMERIC_FILTER, - TEXT_FILTER, -} from '../../utils/constants'; +import { BOOLEAN_TYPE, COUNTRY_TYPE, MEDIUM_COLUMN_WIDTH, NUMERIC_TYPE, TEXT_TYPE } from '../../utils/constants'; import { LOAD_TYPES } from '../../../network/constants'; import { genericColumnOfPropertiesEditPopup } from '../common/column-properties'; import { enumCellEditorConfig, numericalCellEditorConfig } from '../common/cell-editors'; @@ -32,12 +26,12 @@ export const LOAD_TAB_DEF = { field: 'id', columnWidth: MEDIUM_COLUMN_WIDTH, isDefaultSort: true, - type: TEXT_FILTER, + type: TEXT_TYPE, }, { id: 'Name', field: 'name', - type: TEXT_FILTER, + type: TEXT_TYPE, columnWidth: MEDIUM_COLUMN_WIDTH, ...editableColumnConfig, }, @@ -54,26 +48,26 @@ export const LOAD_TAB_DEF = { { id: 'VoltageLevelId', field: 'voltageLevelId', - type: TEXT_FILTER, + type: TEXT_TYPE, }, { id: 'Country', field: 'country', - type: COUNTRY_FILTER, + type: COUNTRY_TYPE, cellRenderer: CountryCellRenderer, }, { id: 'NominalV', field: 'nominalVoltage', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 0, }, { id: 'activePower', field: 'p', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 1, canBeInvalidated: true, getQuickFilterText: excludeFromGlobalFilter, @@ -82,7 +76,7 @@ export const LOAD_TAB_DEF = { id: 'ReactivePower', field: 'q', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 1, canBeInvalidated: true, getQuickFilterText: excludeFromGlobalFilter, @@ -91,7 +85,7 @@ export const LOAD_TAB_DEF = { id: 'p0', field: 'p0', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 1, ...editableColumnConfig, ...numericalCellEditorConfig((params) => params.data.p0), @@ -101,7 +95,7 @@ export const LOAD_TAB_DEF = { id: 'q0', field: 'q0', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 1, ...editableColumnConfig, ...numericalCellEditorConfig((params) => params.data.q0), @@ -112,7 +106,7 @@ export const LOAD_TAB_DEF = { field: 'terminalConnected', boolean: true, cellRenderer: BooleanCellRenderer, - type: BOOLEAN_FILTER, + type: BOOLEAN_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, genericColumnOfPropertiesEditPopup, diff --git a/src/components/spreadsheet/config/equipment/shunt-compensator.ts b/src/components/spreadsheet/config/equipment/shunt-compensator.ts index f092edaeae..67d199c97a 100644 --- a/src/components/spreadsheet/config/equipment/shunt-compensator.ts +++ b/src/components/spreadsheet/config/equipment/shunt-compensator.ts @@ -12,12 +12,12 @@ import CountryCellRenderer from '../../utils/country-cell-render'; import { BooleanCellRenderer } from '../../utils/cell-renderers'; import { editableColumnConfig, excludeFromGlobalFilter, getDefaultEnumConfig, typeAndFetchers } from './common-config'; import { - BOOLEAN_FILTER, - COUNTRY_FILTER, + BOOLEAN_TYPE, + COUNTRY_TYPE, MEDIUM_COLUMN_WIDTH, MIN_COLUMN_WIDTH, - NUMERIC_FILTER, - TEXT_FILTER, + NUMERIC_TYPE, + TEXT_TYPE, } from '../../utils/constants'; import { SHUNT_COMPENSATOR_TYPES } from '../../../network/constants'; import { genericColumnOfPropertiesEditPopup } from '../common/column-properties'; @@ -33,31 +33,31 @@ export const SHUNT_COMPENSATOR_TAB_DEF = { field: 'id', columnWidth: MEDIUM_COLUMN_WIDTH, isDefaultSort: true, - type: TEXT_FILTER, + type: TEXT_TYPE, }, { id: 'Name', field: 'name', - type: TEXT_FILTER, + type: TEXT_TYPE, ...editableColumnConfig, columnWidth: MIN_COLUMN_WIDTH, }, { id: 'VoltageLevelId', field: 'voltageLevelId', - type: TEXT_FILTER, + type: TEXT_TYPE, }, { id: 'Country', field: 'country', - type: COUNTRY_FILTER, + type: COUNTRY_TYPE, cellRenderer: CountryCellRenderer, }, { id: 'NominalV', field: 'nominalVoltage', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 0, }, { @@ -65,7 +65,7 @@ export const SHUNT_COMPENSATOR_TAB_DEF = { field: 'q', numeric: true, fractionDigits: 1, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, canBeInvalidated: true, withFluxConvention: true, getQuickFilterText: excludeFromGlobalFilter, @@ -76,7 +76,7 @@ export const SHUNT_COMPENSATOR_TAB_DEF = { ...editableColumnConfig, numeric: true, ...numericalCellEditorConfig((params) => params.data.maximumSectionCount), - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, getQuickFilterText: excludeFromGlobalFilter, crossValidation: { minExpression: 1, @@ -88,7 +88,7 @@ export const SHUNT_COMPENSATOR_TAB_DEF = { ...editableColumnConfig, numeric: true, ...numericalCellEditorConfig((params) => params.data.sectionCount), - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, getQuickFilterText: excludeFromGlobalFilter, crossValidation: { minExpression: 0, @@ -108,7 +108,7 @@ export const SHUNT_COMPENSATOR_TAB_DEF = { ...editableColumnConfig, numeric: true, ...numericalCellEditorConfig((params) => params.data.maxQAtNominalV), - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 1, getQuickFilterText: excludeFromGlobalFilter, crossValidation: { @@ -121,7 +121,7 @@ export const SHUNT_COMPENSATOR_TAB_DEF = { numeric: true, valueGetter: (params) => (params?.data?.maxQAtNominalV / params?.data?.maximumSectionCount) * params?.data?.sectionCount, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 1, getQuickFilterText: excludeFromGlobalFilter, }, @@ -131,7 +131,7 @@ export const SHUNT_COMPENSATOR_TAB_DEF = { field: 'maxSusceptance', numeric: true, ...numericalCellEditorConfig((params) => params.data.maxSusceptance), - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 5, getQuickFilterText: excludeFromGlobalFilter, }, @@ -141,7 +141,7 @@ export const SHUNT_COMPENSATOR_TAB_DEF = { numeric: true, valueGetter: (params) => (params?.data?.maxSusceptance / params?.data?.maximumSectionCount) * params?.data?.sectionCount, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 5, getQuickFilterText: excludeFromGlobalFilter, }, @@ -149,7 +149,7 @@ export const SHUNT_COMPENSATOR_TAB_DEF = { id: 'voltageSetpoint', field: 'targetV', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 1, getQuickFilterText: excludeFromGlobalFilter, }, @@ -158,7 +158,7 @@ export const SHUNT_COMPENSATOR_TAB_DEF = { field: 'terminalConnected', boolean: true, cellRenderer: BooleanCellRenderer, - type: BOOLEAN_FILTER, + type: BOOLEAN_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, genericColumnOfPropertiesEditPopup, diff --git a/src/components/spreadsheet/config/equipment/static-var-compensator.ts b/src/components/spreadsheet/config/equipment/static-var-compensator.ts index d2fe7cfa61..cac78e471a 100644 --- a/src/components/spreadsheet/config/equipment/static-var-compensator.ts +++ b/src/components/spreadsheet/config/equipment/static-var-compensator.ts @@ -11,13 +11,7 @@ import { EQUIPMENT_TYPES } from '../../../utils/equipment-types'; import CountryCellRenderer from '../../utils/country-cell-render'; import { BooleanCellRenderer } from '../../utils/cell-renderers'; import { excludeFromGlobalFilter, typeAndFetchers } from './common-config'; -import { - BOOLEAN_FILTER, - COUNTRY_FILTER, - MEDIUM_COLUMN_WIDTH, - NUMERIC_FILTER, - TEXT_FILTER, -} from '../../utils/constants'; +import { BOOLEAN_TYPE, COUNTRY_TYPE, MEDIUM_COLUMN_WIDTH, NUMERIC_TYPE, TEXT_TYPE } from '../../utils/constants'; import { NOMINAL_V } from '../../../utils/field-constants'; import { genericColumnOfProperties } from '../common/column-properties'; @@ -30,36 +24,36 @@ export const STATIC_VAR_COMPENSATOR_TAB_DEF = { id: 'ID', field: 'id', isDefaultSort: true, - type: TEXT_FILTER, + type: TEXT_TYPE, }, { id: 'Name', field: 'name', - type: TEXT_FILTER, + type: TEXT_TYPE, }, { id: 'VoltageLevelId', field: 'voltageLevelId', - type: TEXT_FILTER, + type: TEXT_TYPE, }, { id: 'Country', field: 'country', - type: COUNTRY_FILTER, + type: COUNTRY_TYPE, cellRenderer: CountryCellRenderer, }, { id: 'NominalV', field: NOMINAL_V, numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 0, }, { id: 'activePower', field: 'p', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 1, canBeInvalidated: true, getQuickFilterText: excludeFromGlobalFilter, @@ -68,7 +62,7 @@ export const STATIC_VAR_COMPENSATOR_TAB_DEF = { id: 'ReactivePower', field: 'q', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 1, canBeInvalidated: true, getQuickFilterText: excludeFromGlobalFilter, @@ -77,7 +71,7 @@ export const STATIC_VAR_COMPENSATOR_TAB_DEF = { id: 'VoltageSetpointKV', field: 'voltageSetpoint', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 1, getQuickFilterText: excludeFromGlobalFilter, }, @@ -85,7 +79,7 @@ export const STATIC_VAR_COMPENSATOR_TAB_DEF = { id: 'ReactivePowerSetpointMVAR', field: 'reactivePowerSetpoint', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 1, columnWidth: MEDIUM_COLUMN_WIDTH, getQuickFilterText: excludeFromGlobalFilter, @@ -95,7 +89,7 @@ export const STATIC_VAR_COMPENSATOR_TAB_DEF = { field: 'terminalConnected', boolean: true, cellRenderer: BooleanCellRenderer, - type: BOOLEAN_FILTER, + type: BOOLEAN_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, genericColumnOfProperties, diff --git a/src/components/spreadsheet/config/equipment/substation.ts b/src/components/spreadsheet/config/equipment/substation.ts index eadcd3e1b7..ff9452bf5f 100644 --- a/src/components/spreadsheet/config/equipment/substation.ts +++ b/src/components/spreadsheet/config/equipment/substation.ts @@ -12,7 +12,7 @@ import { SelectCountryField } from '../../utils/equipment-table-editors'; import CountryCellRenderer from '../../utils/country-cell-render'; import { editableColumnConfig, typeAndFetchers } from './common-config'; import { genericColumnOfPropertiesEditPopup } from '../common/column-properties'; -import { COUNTRY_FILTER, TEXT_FILTER } from 'components/spreadsheet/utils/constants'; +import { COUNTRY_TYPE, TEXT_TYPE } from 'components/spreadsheet/utils/constants'; export const SUBSTATION_TAB_DEF = { index: 0, @@ -22,14 +22,14 @@ export const SUBSTATION_TAB_DEF = { { id: 'ID', field: 'id', - type: TEXT_FILTER, + type: TEXT_TYPE, isDefaultSort: true, }, { id: 'Name', field: 'name', ...editableColumnConfig, - type: TEXT_FILTER, + type: TEXT_TYPE, }, { id: 'Country', @@ -41,7 +41,7 @@ export const SUBSTATION_TAB_DEF = { params.data.country = params?.newValue; return true; }, - type: COUNTRY_FILTER, + type: COUNTRY_TYPE, }, genericColumnOfPropertiesEditPopup, // FIXME try valueFormatter? ], diff --git a/src/components/spreadsheet/config/equipment/three-windings-transformer.ts b/src/components/spreadsheet/config/equipment/three-windings-transformer.ts index 4203fa8fc6..c27d0df8e8 100644 --- a/src/components/spreadsheet/config/equipment/three-windings-transformer.ts +++ b/src/components/spreadsheet/config/equipment/three-windings-transformer.ts @@ -11,13 +11,7 @@ import { EQUIPMENT_TYPES } from '../../../utils/equipment-types'; import CountryCellRenderer from '../../utils/country-cell-render'; import { BooleanCellRenderer } from '../../utils/cell-renderers'; import { editableColumnConfig, excludeFromGlobalFilter, generateTapPositions, typeAndFetchers } from './common-config'; -import { - BOOLEAN_FILTER, - COUNTRY_FILTER, - MEDIUM_COLUMN_WIDTH, - NUMERIC_FILTER, - TEXT_FILTER, -} from '../../utils/constants'; +import { BOOLEAN_TYPE, COUNTRY_TYPE, MEDIUM_COLUMN_WIDTH, NUMERIC_TYPE, TEXT_TYPE } from '../../utils/constants'; import { genericColumnOfProperties } from '../common/column-properties'; import { standardSelectCellEditorConfig } from '../common/cell-editors'; @@ -44,60 +38,60 @@ export const THREE_WINDINGS_TRANSFORMER_TAB_DEF = { id: 'ID', field: 'id', isDefaultSort: true, - type: TEXT_FILTER, + type: TEXT_TYPE, }, { id: 'Name', field: 'name', - type: TEXT_FILTER, + type: TEXT_TYPE, }, { id: 'VoltageLevelIdT3WSide1', field: 'voltageLevelId1', - type: TEXT_FILTER, + type: TEXT_TYPE, }, { id: 'VoltageLevelIdT3WSide2', field: 'voltageLevelId2', - type: TEXT_FILTER, + type: TEXT_TYPE, }, { id: 'VoltageLevelIdT3WSide3', field: 'voltageLevelId3', - type: TEXT_FILTER, + type: TEXT_TYPE, }, { id: 'Country', field: 'country', - type: COUNTRY_FILTER, + type: COUNTRY_TYPE, cellRenderer: CountryCellRenderer, }, { id: 'NominalVT3WSide1', field: 'nominalV1', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 0, }, { id: 'NominalVT3WSide2', field: 'nominalV2', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 0, }, { id: 'NominalVT3WSide3', field: 'nominalV3', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 0, }, { id: 'ActivePowerT3WSide1', field: 'p1', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 1, canBeInvalidated: true, getQuickFilterText: excludeFromGlobalFilter, @@ -106,7 +100,7 @@ export const THREE_WINDINGS_TRANSFORMER_TAB_DEF = { id: 'ActivePowerT3WSide2', field: 'p2', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 1, canBeInvalidated: true, getQuickFilterText: excludeFromGlobalFilter, @@ -115,7 +109,7 @@ export const THREE_WINDINGS_TRANSFORMER_TAB_DEF = { id: 'ActivePowerT3WSide3', field: 'p3', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 1, canBeInvalidated: true, getQuickFilterText: excludeFromGlobalFilter, @@ -124,7 +118,7 @@ export const THREE_WINDINGS_TRANSFORMER_TAB_DEF = { id: 'ReactivePowerT3WSide1', field: 'q1', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 1, canBeInvalidated: true, getQuickFilterText: excludeFromGlobalFilter, @@ -133,7 +127,7 @@ export const THREE_WINDINGS_TRANSFORMER_TAB_DEF = { id: 'ReactivePowerT3WSide2', field: 'q2', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 1, canBeInvalidated: true, getQuickFilterText: excludeFromGlobalFilter, @@ -142,7 +136,7 @@ export const THREE_WINDINGS_TRANSFORMER_TAB_DEF = { id: 'ReactivePowerT3WSide3', field: 'q3', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 1, canBeInvalidated: true, getQuickFilterText: excludeFromGlobalFilter, @@ -152,7 +146,7 @@ export const THREE_WINDINGS_TRANSFORMER_TAB_DEF = { field: 'hasLoadTapChanging1Capabilities', boolean: true, cellRenderer: BooleanCellRenderer, - type: BOOLEAN_FILTER, + type: BOOLEAN_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, { @@ -160,21 +154,21 @@ export const THREE_WINDINGS_TRANSFORMER_TAB_DEF = { field: 'isRegulatingRatio1', boolean: true, cellRenderer: BooleanCellRenderer, - type: BOOLEAN_FILTER, + type: BOOLEAN_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, { id: 'TargetVPoint1', field: 'targetV1', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 1, getQuickFilterText: excludeFromGlobalFilter, }, { id: 'RatioTap1', field: 'ratioTapChanger1', - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, changeCmd: generateTapRequest('Ratio', 1), fractionDigits: 0, valueGetter: (params) => params?.data?.ratioTapChanger1?.tapPosition, @@ -194,7 +188,7 @@ export const THREE_WINDINGS_TRANSFORMER_TAB_DEF = { field: 'hasLoadTapChanging2Capabilities', boolean: true, cellRenderer: BooleanCellRenderer, - type: BOOLEAN_FILTER, + type: BOOLEAN_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, { @@ -202,21 +196,21 @@ export const THREE_WINDINGS_TRANSFORMER_TAB_DEF = { field: 'isRegulatingRatio2', boolean: true, cellRenderer: BooleanCellRenderer, - type: BOOLEAN_FILTER, + type: BOOLEAN_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, { id: 'TargetVPoint2', field: 'targetV2', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 1, getQuickFilterText: excludeFromGlobalFilter, }, { id: 'RatioTap2', field: 'ratioTapChanger2', - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, changeCmd: generateTapRequest('Ratio', 2), fractionDigits: 0, valueGetter: (params) => params?.data?.ratioTapChanger2?.tapPosition, @@ -236,7 +230,7 @@ export const THREE_WINDINGS_TRANSFORMER_TAB_DEF = { field: 'hasLoadTapChanging3Capabilities', boolean: true, cellRenderer: BooleanCellRenderer, - type: BOOLEAN_FILTER, + type: BOOLEAN_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, { @@ -244,21 +238,21 @@ export const THREE_WINDINGS_TRANSFORMER_TAB_DEF = { field: 'isRegulatingRatio3', boolean: true, cellRenderer: BooleanCellRenderer, - type: BOOLEAN_FILTER, + type: BOOLEAN_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, { id: 'TargetVPoint3', field: 'targetV3', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 1, getQuickFilterText: excludeFromGlobalFilter, }, { id: 'RatioTap3', field: 'ratioTapChanger3', - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, changeCmd: generateTapRequest('Ratio', 3), fractionDigits: 0, valueGetter: (params) => params?.data?.ratioTapChanger3?.tapPosition, @@ -276,7 +270,7 @@ export const THREE_WINDINGS_TRANSFORMER_TAB_DEF = { { id: 'RegulatingMode1', field: 'regulationModeName1', - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, columnWidth: MEDIUM_COLUMN_WIDTH, getQuickFilterText: excludeFromGlobalFilter, }, @@ -285,13 +279,13 @@ export const THREE_WINDINGS_TRANSFORMER_TAB_DEF = { field: 'isRegulatingPhase1', boolean: true, cellRenderer: BooleanCellRenderer, - type: BOOLEAN_FILTER, + type: BOOLEAN_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, { id: 'PhaseTap1', field: 'phaseTapChanger1', - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, changeCmd: generateTapRequest('Phase', 1), fractionDigits: 0, valueGetter: (params) => params?.data?.phaseTapChanger1?.tapPosition, @@ -310,7 +304,7 @@ export const THREE_WINDINGS_TRANSFORMER_TAB_DEF = { id: 'RegulatingValue1', field: 'regulatingValue1', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, columnWidth: MEDIUM_COLUMN_WIDTH, fractionDigits: 1, getQuickFilterText: excludeFromGlobalFilter, @@ -318,7 +312,7 @@ export const THREE_WINDINGS_TRANSFORMER_TAB_DEF = { { id: 'RegulatingMode2', field: 'regulationModeName2', - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, columnWidth: MEDIUM_COLUMN_WIDTH, getQuickFilterText: excludeFromGlobalFilter, }, @@ -327,13 +321,13 @@ export const THREE_WINDINGS_TRANSFORMER_TAB_DEF = { field: 'isRegulatingPhase2', boolean: true, cellRenderer: BooleanCellRenderer, - type: BOOLEAN_FILTER, + type: BOOLEAN_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, { id: 'PhaseTap2', field: 'phaseTapChanger2', - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, changeCmd: generateTapRequest('Phase', 2), fractionDigits: 0, valueGetter: (params) => params?.data?.phaseTapChanger2?.tapPosition, @@ -352,7 +346,7 @@ export const THREE_WINDINGS_TRANSFORMER_TAB_DEF = { id: 'RegulatingValue2', field: 'regulatingValue2', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, columnWidth: MEDIUM_COLUMN_WIDTH, fractionDigits: 1, getQuickFilterText: excludeFromGlobalFilter, @@ -360,7 +354,7 @@ export const THREE_WINDINGS_TRANSFORMER_TAB_DEF = { { id: 'RegulatingMode3', field: 'regulationModeName3', - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, columnWidth: MEDIUM_COLUMN_WIDTH, getQuickFilterText: excludeFromGlobalFilter, }, @@ -369,13 +363,13 @@ export const THREE_WINDINGS_TRANSFORMER_TAB_DEF = { field: 'isRegulatingPhase3', boolean: true, cellRenderer: BooleanCellRenderer, - type: BOOLEAN_FILTER, + type: BOOLEAN_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, { id: 'PhaseTap3', field: 'phaseTapChanger3', - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, changeCmd: generateTapRequest('Phase', 3), fractionDigits: 0, valueGetter: (params) => params?.data?.phaseTapChanger3?.tapPosition, @@ -394,7 +388,7 @@ export const THREE_WINDINGS_TRANSFORMER_TAB_DEF = { id: 'RegulatingValue3', field: 'regulatingValue3', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, columnWidth: MEDIUM_COLUMN_WIDTH, fractionDigits: 1, getQuickFilterText: excludeFromGlobalFilter, @@ -404,7 +398,7 @@ export const THREE_WINDINGS_TRANSFORMER_TAB_DEF = { field: 'terminal1Connected', boolean: true, cellRenderer: BooleanCellRenderer, - type: BOOLEAN_FILTER, + type: BOOLEAN_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, { @@ -412,7 +406,7 @@ export const THREE_WINDINGS_TRANSFORMER_TAB_DEF = { field: 'terminal2Connected', boolean: true, cellRenderer: BooleanCellRenderer, - type: BOOLEAN_FILTER, + type: BOOLEAN_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, { @@ -420,7 +414,7 @@ export const THREE_WINDINGS_TRANSFORMER_TAB_DEF = { field: 'terminal3Connected', boolean: true, cellRenderer: BooleanCellRenderer, - type: BOOLEAN_FILTER, + type: BOOLEAN_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, genericColumnOfProperties, diff --git a/src/components/spreadsheet/config/equipment/tie-line.ts b/src/components/spreadsheet/config/equipment/tie-line.ts index 25c7f4744c..a021843dcd 100644 --- a/src/components/spreadsheet/config/equipment/tie-line.ts +++ b/src/components/spreadsheet/config/equipment/tie-line.ts @@ -11,13 +11,7 @@ import { EQUIPMENT_TYPES } from '../../../utils/equipment-types'; import CountryCellRenderer from '../../utils/country-cell-render'; import { BooleanCellRenderer } from '../../utils/cell-renderers'; import { excludeFromGlobalFilter, typeAndFetchers } from './common-config'; -import { - BOOLEAN_FILTER, - COUNTRY_FILTER, - MEDIUM_COLUMN_WIDTH, - NUMERIC_FILTER, - TEXT_FILTER, -} from '../../utils/constants'; +import { BOOLEAN_TYPE, COUNTRY_TYPE, MEDIUM_COLUMN_WIDTH, NUMERIC_TYPE, TEXT_TYPE } from '../../utils/constants'; import { unitToMicroUnit } from '../../../../utils/unit-converter'; import { genericColumnOfPropertiesReadonly } from '../common/column-properties'; @@ -31,55 +25,55 @@ export const TIE_LINE_TAB_DEF = { field: 'id', columnWidth: MEDIUM_COLUMN_WIDTH, isDefaultSort: true, - type: TEXT_FILTER, + type: TEXT_TYPE, }, { id: 'Name', field: 'name', columnWidth: MEDIUM_COLUMN_WIDTH, - type: TEXT_FILTER, + type: TEXT_TYPE, }, { id: 'VoltageLevelIdSide1', field: 'voltageLevelId1', - type: TEXT_FILTER, + type: TEXT_TYPE, }, { id: 'VoltageLevelIdSide2', field: 'voltageLevelId2', - type: TEXT_FILTER, + type: TEXT_TYPE, }, { id: 'Country1', field: 'country1', - type: COUNTRY_FILTER, + type: COUNTRY_TYPE, cellRenderer: CountryCellRenderer, }, { id: 'Country2', field: 'country2', - type: COUNTRY_FILTER, + type: COUNTRY_TYPE, cellRenderer: CountryCellRenderer, }, { id: 'nominalVoltage1KV', field: 'nominalVoltage1', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 0, }, { id: 'nominalVoltage2KV', field: 'nominalVoltage2', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 0, }, { id: 'ActivePowerSide1', field: 'p1', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 1, canBeInvalidated: true, getQuickFilterText: excludeFromGlobalFilter, @@ -88,7 +82,7 @@ export const TIE_LINE_TAB_DEF = { id: 'ActivePowerSide2', field: 'p2', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 1, canBeInvalidated: true, getQuickFilterText: excludeFromGlobalFilter, @@ -97,7 +91,7 @@ export const TIE_LINE_TAB_DEF = { id: 'ReactivePowerSide1', field: 'q1', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 1, canBeInvalidated: true, getQuickFilterText: excludeFromGlobalFilter, @@ -106,7 +100,7 @@ export const TIE_LINE_TAB_DEF = { id: 'ReactivePowerSide2', field: 'q2', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 1, canBeInvalidated: true, getQuickFilterText: excludeFromGlobalFilter, @@ -115,7 +109,7 @@ export const TIE_LINE_TAB_DEF = { id: 'r', field: 'r', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 1, getQuickFilterText: excludeFromGlobalFilter, }, @@ -123,7 +117,7 @@ export const TIE_LINE_TAB_DEF = { id: 'x', field: 'x', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 1, getQuickFilterText: excludeFromGlobalFilter, }, @@ -131,7 +125,7 @@ export const TIE_LINE_TAB_DEF = { id: 'g1', field: 'g1', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 1, valueGetter: (params) => unitToMicroUnit(params.data.g1), getQuickFilterText: excludeFromGlobalFilter, @@ -140,7 +134,7 @@ export const TIE_LINE_TAB_DEF = { id: 'g2', field: 'g2', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 1, valueGetter: (params) => unitToMicroUnit(params.data.g2), getQuickFilterText: excludeFromGlobalFilter, @@ -149,7 +143,7 @@ export const TIE_LINE_TAB_DEF = { id: 'b1', field: 'b1', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 1, valueGetter: (params) => unitToMicroUnit(params.data.b1), getQuickFilterText: excludeFromGlobalFilter, @@ -158,7 +152,7 @@ export const TIE_LINE_TAB_DEF = { id: 'b2', field: 'b2', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 1, valueGetter: (params) => unitToMicroUnit(params.data.b2), getQuickFilterText: excludeFromGlobalFilter, @@ -168,7 +162,7 @@ export const TIE_LINE_TAB_DEF = { field: 'terminal1Connected', boolean: true, cellRenderer: BooleanCellRenderer, - type: BOOLEAN_FILTER, + type: BOOLEAN_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, { @@ -176,7 +170,7 @@ export const TIE_LINE_TAB_DEF = { field: 'terminal2Connected', boolean: true, cellRenderer: BooleanCellRenderer, - type: BOOLEAN_FILTER, + type: BOOLEAN_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, genericColumnOfPropertiesReadonly, diff --git a/src/components/spreadsheet/config/equipment/two-windings-transformer.ts b/src/components/spreadsheet/config/equipment/two-windings-transformer.ts index 81cf057c68..54dc55a058 100644 --- a/src/components/spreadsheet/config/equipment/two-windings-transformer.ts +++ b/src/components/spreadsheet/config/equipment/two-windings-transformer.ts @@ -22,13 +22,7 @@ import { isEditable, typeAndFetchers, } from './common-config'; -import { - BOOLEAN_FILTER, - COUNTRY_FILTER, - MEDIUM_COLUMN_WIDTH, - NUMERIC_FILTER, - TEXT_FILTER, -} from '../../utils/constants'; +import { BOOLEAN_TYPE, COUNTRY_TYPE, MEDIUM_COLUMN_WIDTH, NUMERIC_TYPE, TEXT_TYPE } from '../../utils/constants'; import { PHASE_REGULATION_MODES, RATIO_REGULATION_MODES, REGULATION_TYPES, SIDE } from '../../../network/constants'; import { computeHighTapPosition, getTapChangerRegulationTerminalValue } from '../../../utils/utils'; import { unitToMicroUnit } from '../../../../utils/unit-converter'; @@ -111,48 +105,48 @@ export const TWO_WINDINGS_TRANSFORMER_TAB_DEF = { id: 'ID', field: 'id', isDefaultSort: true, - type: TEXT_FILTER, + type: TEXT_TYPE, }, { id: 'Name', field: 'name', - type: TEXT_FILTER, + type: TEXT_TYPE, }, { id: 'VoltageLevelIdSide1', field: 'voltageLevelId1', - type: TEXT_FILTER, + type: TEXT_TYPE, }, { id: 'VoltageLevelIdSide2', field: 'voltageLevelId2', - type: TEXT_FILTER, + type: TEXT_TYPE, }, { id: 'Country', field: 'country', - type: COUNTRY_FILTER, + type: COUNTRY_TYPE, cellRenderer: CountryCellRenderer, }, { id: 'nominalVoltage1KV', field: 'nominalVoltage1', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 0, }, { id: 'nominalVoltage2KV', field: 'nominalVoltage2', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 0, }, { id: 'ratedVoltage1KV', field: 'ratedU1', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 0, ...editableColumnConfig, ...numericalCellEditorConfig((params) => params.data.ratedU1), @@ -162,7 +156,7 @@ export const TWO_WINDINGS_TRANSFORMER_TAB_DEF = { id: 'ratedVoltage2KV', field: 'ratedU2', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 0, ...editableColumnConfig, ...numericalCellEditorConfig((params) => params.data.ratedU2), @@ -172,7 +166,7 @@ export const TWO_WINDINGS_TRANSFORMER_TAB_DEF = { id: 'ActivePowerSide1', field: 'p1', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 1, canBeInvalidated: true, getQuickFilterText: excludeFromGlobalFilter, @@ -181,7 +175,7 @@ export const TWO_WINDINGS_TRANSFORMER_TAB_DEF = { id: 'ActivePowerSide2', field: 'p2', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 1, canBeInvalidated: true, getQuickFilterText: excludeFromGlobalFilter, @@ -190,7 +184,7 @@ export const TWO_WINDINGS_TRANSFORMER_TAB_DEF = { id: 'ReactivePowerSide1', field: 'q1', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 1, canBeInvalidated: true, getQuickFilterText: excludeFromGlobalFilter, @@ -199,7 +193,7 @@ export const TWO_WINDINGS_TRANSFORMER_TAB_DEF = { id: 'ReactivePowerSide2', field: 'q2', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 1, canBeInvalidated: true, getQuickFilterText: excludeFromGlobalFilter, @@ -209,7 +203,7 @@ export const TWO_WINDINGS_TRANSFORMER_TAB_DEF = { field: 'ratioTapChanger.hasLoadTapChangingCapabilities', valueGetter: (params) => params?.data?.ratioTapChanger?.hasLoadTapChangingCapabilities, cellRenderer: BooleanCellRenderer, - type: BOOLEAN_FILTER, + type: BOOLEAN_TYPE, editable: (params) => isEditable(params) && hasTwtRatioTapChanger(params), cellStyle: editableCellStyle, valueSetter: (params) => { @@ -257,7 +251,7 @@ export const TWO_WINDINGS_TRANSFORMER_TAB_DEF = { { id: 'TargetVPoint', field: 'ratioTapChanger.targetV', - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 1, editable: isTwtRatioOnloadAndEditable, cellStyle: editableCellStyle, @@ -274,7 +268,7 @@ export const TWO_WINDINGS_TRANSFORMER_TAB_DEF = { { id: 'RatioDeadBand', field: 'ratioTapChanger.targetDeadband', - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 1, editable: isTwtRatioOnloadAndEditable, cellStyle: editableCellStyle, @@ -335,7 +329,7 @@ export const TWO_WINDINGS_TRANSFORMER_TAB_DEF = { { id: 'RatioRegulatingTerminal', field: 'ratioTapChanger.ratioRegulatingTerminal', - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, valueGetter: (params) => params.data?.ratioTapChanger?.ratioRegulatingTerminal, columnWidth: MEDIUM_COLUMN_WIDTH, getQuickFilterText: excludeFromGlobalFilter, @@ -353,7 +347,7 @@ export const TWO_WINDINGS_TRANSFORMER_TAB_DEF = { id: 'RatioLowTapPosition', field: 'ratioTapChanger.lowTapPosition', getQuickFilterText: excludeFromGlobalFilter, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, numeric: true, fractionDigits: 0, editable: (params) => isEditable(params) && params.data?.ratioTapChanger?.steps?.length > 0, @@ -375,14 +369,14 @@ export const TWO_WINDINGS_TRANSFORMER_TAB_DEF = { { id: 'RatioHighTapPosition', field: 'ratioTapChanger.highTapPosition', - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, valueGetter: (params) => computeHighTapPosition(params?.data?.ratioTapChanger?.steps), getQuickFilterText: excludeFromGlobalFilter, }, { id: 'RatioTap', field: 'ratioTapChanger.tapPosition', - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, numeric: true, fractionDigits: 0, valueGetter: (params) => params?.data?.ratioTapChanger?.tapPosition, @@ -428,7 +422,7 @@ export const TWO_WINDINGS_TRANSFORMER_TAB_DEF = { { id: 'RegulatingValue', field: 'phaseTapChanger.regulationValue', - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, columnWidth: MEDIUM_COLUMN_WIDTH, fractionDigits: 1, valueGetter: (params) => params?.data?.phaseTapChanger?.regulationValue, @@ -449,7 +443,7 @@ export const TWO_WINDINGS_TRANSFORMER_TAB_DEF = { { id: 'PhaseDeadBand', field: 'phaseTapChanger.targetDeadband', - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 1, getQuickFilterText: excludeFromGlobalFilter, editable: (params) => @@ -512,7 +506,7 @@ export const TWO_WINDINGS_TRANSFORMER_TAB_DEF = { { id: 'PhaseRegulatingTerminal', field: 'phaseTapChanger.phaseRegulatingTerminal', - type: TEXT_FILTER, + type: TEXT_TYPE, valueGetter: (params) => params.data?.phaseTapChanger?.phaseRegulatingTerminal, columnWidth: MEDIUM_COLUMN_WIDTH, getQuickFilterText: excludeFromGlobalFilter, @@ -530,7 +524,7 @@ export const TWO_WINDINGS_TRANSFORMER_TAB_DEF = { id: 'PhaseLowTapPosition', field: 'phaseTapChanger.lowTapPosition', getQuickFilterText: excludeFromGlobalFilter, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, numeric: true, fractionDigits: 0, editable: (params) => isEditable(params) && params.data?.phaseTapChanger?.steps?.length > 0, @@ -552,14 +546,14 @@ export const TWO_WINDINGS_TRANSFORMER_TAB_DEF = { { id: 'PhaseHighTapPosition', field: 'phaseTapChanger.highTapPosition', - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, valueGetter: (params) => computeHighTapPosition(params?.data?.phaseTapChanger?.steps), getQuickFilterText: excludeFromGlobalFilter, }, { id: 'PhaseTap', field: 'phaseTapChanger.tapPosition', - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, numeric: true, fractionDigits: 0, valueGetter: (params) => params?.data?.phaseTapChanger?.tapPosition, @@ -584,7 +578,7 @@ export const TWO_WINDINGS_TRANSFORMER_TAB_DEF = { id: 'r', field: 'r', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 1, getQuickFilterText: excludeFromGlobalFilter, }, @@ -592,7 +586,7 @@ export const TWO_WINDINGS_TRANSFORMER_TAB_DEF = { id: 'x', field: 'x', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 1, getQuickFilterText: excludeFromGlobalFilter, }, @@ -600,7 +594,7 @@ export const TWO_WINDINGS_TRANSFORMER_TAB_DEF = { id: 'g', field: 'g', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 1, valueGetter: (params) => unitToMicroUnit(params.data.g), getQuickFilterText: excludeFromGlobalFilter, @@ -609,7 +603,7 @@ export const TWO_WINDINGS_TRANSFORMER_TAB_DEF = { id: 'b', field: 'b', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 1, valueGetter: (params) => unitToMicroUnit(params.data.b), getQuickFilterText: excludeFromGlobalFilter, @@ -618,7 +612,7 @@ export const TWO_WINDINGS_TRANSFORMER_TAB_DEF = { id: 'ratedNominalPower', field: 'ratedS', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 1, getQuickFilterText: excludeFromGlobalFilter, }, @@ -627,7 +621,7 @@ export const TWO_WINDINGS_TRANSFORMER_TAB_DEF = { field: 'terminal1Connected', boolean: true, cellRenderer: BooleanCellRenderer, - type: BOOLEAN_FILTER, + type: BOOLEAN_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, { @@ -635,7 +629,7 @@ export const TWO_WINDINGS_TRANSFORMER_TAB_DEF = { field: 'terminal2Connected', boolean: true, cellRenderer: BooleanCellRenderer, - type: BOOLEAN_FILTER, + type: BOOLEAN_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, genericColumnOfPropertiesEditPopup, diff --git a/src/components/spreadsheet/config/equipment/voltage-level.ts b/src/components/spreadsheet/config/equipment/voltage-level.ts index e3301ee2dd..2792d5bdb9 100644 --- a/src/components/spreadsheet/config/equipment/voltage-level.ts +++ b/src/components/spreadsheet/config/equipment/voltage-level.ts @@ -14,7 +14,7 @@ import { editableColumnConfig, excludeFromGlobalFilter, typeAndFetchers } from ' import { kiloUnitToUnit, unitToKiloUnit } from '../../../../utils/unit-converter'; import { genericColumnOfPropertiesEditPopup } from '../common/column-properties'; import { numericalCellEditorConfig } from '../common/cell-editors'; -import { COUNTRY_FILTER, NUMERIC_FILTER, TEXT_FILTER } from 'components/spreadsheet/utils/constants'; +import { COUNTRY_TYPE, NUMERIC_TYPE, TEXT_TYPE } from 'components/spreadsheet/utils/constants'; function generateEditableNumericColumnDefinition< TId extends string, @@ -26,7 +26,7 @@ function generateEditableNumericColumnDefinition< id: id, field: field, numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 1, ...editableColumnConfig, ...numericalCellEditorConfig((params) => params.data[field]), @@ -48,30 +48,30 @@ export const VOLTAGE_LEVEL_TAB_DEF = { id: 'ID', field: 'id', isDefaultSort: true, - type: TEXT_FILTER, + type: TEXT_TYPE, }, { id: 'Name', field: 'name', ...editableColumnConfig, - type: TEXT_FILTER, + type: TEXT_TYPE, }, { id: 'SubstationId', field: 'substationId', - type: TEXT_FILTER, + type: TEXT_TYPE, }, { id: 'Country', field: 'country', - type: COUNTRY_FILTER, + type: COUNTRY_TYPE, cellRenderer: CountryCellRenderer, }, { id: 'NominalV', field: 'nominalV', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 0, ...editableColumnConfig, ...numericalCellEditorConfig((params) => params.data.nominalV), @@ -81,7 +81,7 @@ export const VOLTAGE_LEVEL_TAB_DEF = { { id: 'IpMin', field: 'identifiableShortCircuit.ipMin', - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 1, ...editableColumnConfig, numeric: true, @@ -102,7 +102,7 @@ export const VOLTAGE_LEVEL_TAB_DEF = { { id: 'IpMax', field: 'identifiableShortCircuit.ipMax', - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 1, ...editableColumnConfig, numeric: true, diff --git a/src/components/spreadsheet/config/equipment/vsc-converter-station.ts b/src/components/spreadsheet/config/equipment/vsc-converter-station.ts index 7f50b9e390..ff9714ea46 100644 --- a/src/components/spreadsheet/config/equipment/vsc-converter-station.ts +++ b/src/components/spreadsheet/config/equipment/vsc-converter-station.ts @@ -11,13 +11,7 @@ import { EQUIPMENT_TYPES } from '../../../utils/equipment-types'; import CountryCellRenderer from '../../utils/country-cell-render'; import { BooleanCellRenderer } from '../../utils/cell-renderers'; import { excludeFromGlobalFilter, typeAndFetchers } from './common-config'; -import { - BOOLEAN_FILTER, - COUNTRY_FILTER, - MEDIUM_COLUMN_WIDTH, - NUMERIC_FILTER, - TEXT_FILTER, -} from '../../utils/constants'; +import { BOOLEAN_TYPE, COUNTRY_TYPE, MEDIUM_COLUMN_WIDTH, NUMERIC_TYPE, TEXT_TYPE } from '../../utils/constants'; import { genericColumnOfProperties } from '../common/column-properties'; export const VSC_CONVERTER_STATION_TAB_DEF = { @@ -30,41 +24,41 @@ export const VSC_CONVERTER_STATION_TAB_DEF = { field: 'id', columnWidth: MEDIUM_COLUMN_WIDTH, isDefaultSort: true, - type: TEXT_FILTER, + type: TEXT_TYPE, }, { id: 'Name', field: 'name', - type: TEXT_FILTER, + type: TEXT_TYPE, }, { id: 'VoltageLevelId', field: 'voltageLevelId', - type: TEXT_FILTER, + type: TEXT_TYPE, }, { id: 'Country', field: 'country', - type: COUNTRY_FILTER, + type: COUNTRY_TYPE, cellRenderer: CountryCellRenderer, }, { id: 'NominalV', field: 'nominalV', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 0, }, { id: 'HvdcLineId', field: 'hvdcLineId', - type: TEXT_FILTER, + type: TEXT_TYPE, }, { id: 'activePower', field: 'p', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 1, canBeInvalidated: true, getQuickFilterText: excludeFromGlobalFilter, @@ -73,7 +67,7 @@ export const VSC_CONVERTER_STATION_TAB_DEF = { id: 'ReactivePower', field: 'q', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 1, canBeInvalidated: true, getQuickFilterText: excludeFromGlobalFilter, @@ -82,7 +76,7 @@ export const VSC_CONVERTER_STATION_TAB_DEF = { id: 'LossFactor', field: 'lossFactor', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 1, getQuickFilterText: excludeFromGlobalFilter, }, @@ -91,14 +85,14 @@ export const VSC_CONVERTER_STATION_TAB_DEF = { field: 'voltageRegulatorOn', boolean: true, cellRenderer: BooleanCellRenderer, - type: BOOLEAN_FILTER, + type: BOOLEAN_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, { id: 'VoltageSetpointKV', field: 'voltageSetpoint', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 1, getQuickFilterText: excludeFromGlobalFilter, }, @@ -106,7 +100,7 @@ export const VSC_CONVERTER_STATION_TAB_DEF = { id: 'ReactivePowerSetpointMVAR', field: 'reactivePowerSetpoint', numeric: true, - type: NUMERIC_FILTER, + type: NUMERIC_TYPE, fractionDigits: 1, getQuickFilterText: excludeFromGlobalFilter, }, @@ -115,7 +109,7 @@ export const VSC_CONVERTER_STATION_TAB_DEF = { field: 'terminalConnected', boolean: true, cellRenderer: BooleanCellRenderer, - type: BOOLEAN_FILTER, + type: BOOLEAN_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, genericColumnOfProperties, diff --git a/src/components/spreadsheet/table-wrapper.tsx b/src/components/spreadsheet/table-wrapper.tsx index 179cf07742..d3f0fbd01b 100644 --- a/src/components/spreadsheet/table-wrapper.tsx +++ b/src/components/spreadsheet/table-wrapper.tsx @@ -83,7 +83,7 @@ import { SpreadsheetColDef, SpreadsheetEquipmentType } from './config/spreadshee import SpreadsheetSave from './spreadsheet-save'; import { makeSpreadsheetAgGridColumn } from './config/column-aggrid-utils'; import { toModificationOperation } from 'components/utils/utils'; -import { defaultColumnType } from './config/column-type-flter-config'; +import { defaultColumnType } from './config/column-type-filter-config'; import { useParameterState } from 'components/dialogs/parameters/parameters'; const useEditBuffer = (): [Record, (field: string, value: unknown) => void, () => void] => { diff --git a/src/components/spreadsheet/utils/constants.ts b/src/components/spreadsheet/utils/constants.ts index 1200a7e221..0daa3ffe33 100644 --- a/src/components/spreadsheet/utils/constants.ts +++ b/src/components/spreadsheet/utils/constants.ts @@ -15,8 +15,8 @@ export const DISPLAYED_COLUMNS_PARAMETER_PREFIX_IN_DATABASE = 'displayedColumns. export const LOCKED_COLUMNS_PARAMETER_PREFIX_IN_DATABASE = 'lockedColumns.'; export const REORDERED_COLUMNS_PARAMETER_PREFIX_IN_DATABASE = 'reorderedColumns.'; -export const TEXT_FILTER = 'textFilter'; -export const NUMERIC_FILTER = 'numericFilter'; -export const ENUM_FILTER = 'enumFilter'; -export const BOOLEAN_FILTER = 'booleanFilter'; -export const COUNTRY_FILTER = 'countryFilter'; +export const TEXT_TYPE = 'textType'; +export const NUMERIC_TYPE = 'numericType'; +export const ENUM_TYPE = 'enumType'; +export const BOOLEAN_TYPE = 'booleanType'; +export const COUNTRY_TYPE = 'countryType'; From 7db3fb5262db2abe504ef1a0252d7d70c6770731 Mon Sep 17 00:00:00 2001 From: TOURI ANIS Date: Mon, 16 Dec 2024 20:30:26 +0100 Subject: [PATCH 06/10] generalize culumnType --- .../config/column-type-filter-config.ts | 150 ++++++++++++------ .../spreadsheet/config/equipment/battery.ts | 9 +- .../spreadsheet/config/equipment/bus.ts | 4 +- .../config/equipment/busbar-section.ts | 3 +- .../config/equipment/common-config.ts | 35 +--- .../config/equipment/dangling-line.ts | 7 +- .../spreadsheet/config/equipment/generator.ts | 22 +-- .../spreadsheet/config/equipment/hvdc-line.ts | 7 +- .../config/equipment/lcc-converter-station.ts | 7 +- .../spreadsheet/config/equipment/line.ts | 9 +- .../spreadsheet/config/equipment/load.ts | 13 +- .../config/equipment/shunt-compensator.ts | 13 +- .../equipment/static-var-compensator.ts | 8 +- .../config/equipment/substation.ts | 5 +- .../equipment/three-windings-transformer.ts | 30 +--- .../spreadsheet/config/equipment/tie-line.ts | 11 +- .../equipment/two-windings-transformer.ts | 22 ++- .../config/equipment/voltage-level.ts | 5 +- .../config/equipment/vsc-converter-station.ts | 10 +- .../spreadsheet/config/spreadsheet.type.ts | 2 +- .../spreadsheet/equipment-table.tsx | 10 +- src/components/spreadsheet/table-wrapper.tsx | 1 + 22 files changed, 166 insertions(+), 217 deletions(-) diff --git a/src/components/spreadsheet/config/column-type-filter-config.ts b/src/components/spreadsheet/config/column-type-filter-config.ts index 92adcfc652..90145f9e61 100644 --- a/src/components/spreadsheet/config/column-type-filter-config.ts +++ b/src/components/spreadsheet/config/column-type-filter-config.ts @@ -9,6 +9,9 @@ import { FILTER_NUMBER_COMPARATORS, FILTER_TEXT_COMPARATORS } from 'components/c import { getEnumLabelById } from 'components/utils/utils'; import { EnumOption } from 'components/utils/utils-type'; import CountryCellRenderer from '../utils/country-cell-render'; +import { BooleanCellRenderer, DefaultCellRenderer } from '../utils/cell-renderers'; +import EnumCellRenderer from '../utils/enum-cell-renderer'; +import { Writable } from 'type-fest'; const contains = (target: string, lookingFor: string): boolean => { if (target && lookingFor) { @@ -17,7 +20,7 @@ const contains = (target: string, lookingFor: string): boolean => { return false; }; -export const getEnumFilterConfig = (enumOptions: EnumOption[]) => { +export const getEnumConfig = (enumOptions: Readonly) => { return { filter: 'agTextColumnFilter', filterParams: { @@ -36,65 +39,110 @@ export const getEnumFilterConfig = (enumOptions: EnumOption[]) => { }, debounceMs: 200, }, + cellRenderer: EnumCellRenderer, + cellRendererParams: { + enumOptions: enumOptions as Writable, + // @ts-expect-error TODO TS1360: Property value is missing in type + } satisfies EnumCellRendererProps, + getEnumLabel: (value: string) => getEnumLabelById(enumOptions as Writable, value), }; }; -export const defaultColumnType = { - textType: { - filter: 'agTextColumnFilter', - filterParams: { - caseSensitive: false, - maxNumConditions: 1, - filterOptions: [FILTER_TEXT_COMPARATORS.STARTS_WITH, FILTER_TEXT_COMPARATORS.CONTAINS], - }, - sortable: true, - resizable: true, +const textType = { + filter: 'agTextColumnFilter', + filterParams: { + caseSensitive: false, + maxNumConditions: 1, + filterOptions: [FILTER_TEXT_COMPARATORS.STARTS_WITH, FILTER_TEXT_COMPARATORS.CONTAINS], }, - numericType: { - filter: 'agNumberColumnFilter', - filterParams: { - maxNumConditions: 1, - filterOptions: Object.values(FILTER_NUMBER_COMPARATORS), - debounceMs: 200, - }, - sortable: false, - resizable: true, + cellRendererSelector: (props: any) => { + return { + component: DefaultCellRenderer, + props: props, + }; }, - booleanType: { - filter: 'agTextColumnFilter', - filterParams: { - caseSensitive: false, - maxNumConditions: 1, - filterOptions: [FILTER_TEXT_COMPARATORS.EQUALS], - textMatcher: ({ value, filterText, context }: any): boolean => { - if (value) { - const displayedValue = context.intl.formatMessage({ id: value }) ?? value; - return contains(displayedValue, filterText || ''); - } - return false; + sortable: true, + resizable: true, +}; + +const numericType = { + filter: 'agNumberColumnFilter', + filterParams: { + maxNumConditions: 1, + filterOptions: Object.values(FILTER_NUMBER_COMPARATORS), + debounceMs: 200, + }, + cellRendererSelector: (props: any) => { + return { + component: DefaultCellRenderer, + props: { + isValueInvalid: props.colDef.cellRendererParams.colisValueInvalid, + applyFluxConvention: props.context.applyFluxConvention, + }, + }; + }, + sortable: true, + resizable: true, +}; + +const booleanType = { + cellRendererSelector: ({ value }: { value: string }) => { + return { + component: BooleanCellRenderer, + props: { + value, }, + }; + }, + filter: 'agTextColumnFilter', + filterParams: { + caseSensitive: false, + maxNumConditions: 1, + filterOptions: [FILTER_TEXT_COMPARATORS.EQUALS], + textMatcher: ({ value, filterText, context }: any): boolean => { + if (value) { + const displayedValue = context.intl.formatMessage({ id: value }) ?? value; + return contains(displayedValue, filterText || ''); + } + return false; }, - sortable: true, - resizable: true, + debounceMs: 200, }, - countryType: { - filter: 'agTextColumnFilter', - filterParams: { - caseSensitive: false, - maxNumConditions: 1, - filterOptions: [FILTER_TEXT_COMPARATORS.CONTAINS], - textMatcher: ({ value, filterText, context }: { value: string; filterText: string; context: any }) => { - if (value) { - const countryCode = value?.toUpperCase(); - const countryName = context?.translateCountryCode(countryCode); - return contains(countryName, filterText || '') || contains(value, filterText); - } - return false; + sortable: true, + resizable: true, +}; + +const countryType = { + cellRendererSelector: ({ value }: { value: string }) => { + return { + component: CountryCellRenderer, + params: { + value, }, - debounceMs: 200, + }; + }, + filter: 'agTextColumnFilter', + filterParams: { + caseSensitive: false, + maxNumConditions: 1, + filterOptions: [FILTER_TEXT_COMPARATORS.CONTAINS], + textMatcher: ({ value, filterText, context }: { value: string; filterText: string; context: any }) => { + if (value) { + const countryCode = value?.toUpperCase(); + const countryName = context?.translateCountryCode(countryCode); + return contains(countryName, filterText || '') || contains(value, filterText); + } + return false; }, - sortable: true, - resizable: true, - cellRenderer: CountryCellRenderer, + debounceMs: 200, }, + sortable: true, + resizable: true, +}; + +export const defaultColumnType = { + textType, + numericType, + booleanType, + countryType, }; diff --git a/src/components/spreadsheet/config/equipment/battery.ts b/src/components/spreadsheet/config/equipment/battery.ts index bec3b309b4..eb5ec93132 100644 --- a/src/components/spreadsheet/config/equipment/battery.ts +++ b/src/components/spreadsheet/config/equipment/battery.ts @@ -7,13 +7,12 @@ import type { ReadonlyDeep } from 'type-fest'; import { EQUIPMENT_TYPES } from '../../../utils/equipment-types'; -import CountryCellRenderer from '../../utils/country-cell-render'; -import { BooleanCellRenderer } from '../../utils/cell-renderers'; import { editableColumnConfig, excludeFromGlobalFilter, typeAndFetchers } from './common-config'; import type { SpreadsheetTabDefinition } from '../spreadsheet.type'; import { genericColumnOfPropertiesEditPopup } from '../common/column-properties'; import { booleanCellEditorConfig, numericalCellEditorConfig } from '../common/cell-editors'; import { BOOLEAN_TYPE, COUNTRY_TYPE, NUMERIC_TYPE, TEXT_TYPE } from 'components/spreadsheet/utils/constants'; +import { SortWay } from 'hooks/use-aggrid-sort'; export const BATTERY_TAB_DEF = { index: 9, @@ -23,8 +22,9 @@ export const BATTERY_TAB_DEF = { { id: 'ID', field: 'id', - isDefaultSort: true, + type: TEXT_TYPE, + sort: SortWay.ASC, }, { id: 'Name', @@ -72,7 +72,6 @@ export const BATTERY_TAB_DEF = { { id: 'ActivePowerControl', field: 'activePowerControl.participate', - cellRenderer: BooleanCellRenderer, type: BOOLEAN_TYPE, ...editableColumnConfig, valueSetter: (params) => { @@ -163,8 +162,6 @@ export const BATTERY_TAB_DEF = { { id: 'connected', field: 'terminalConnected', - boolean: true, - cellRenderer: BooleanCellRenderer, type: BOOLEAN_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, diff --git a/src/components/spreadsheet/config/equipment/bus.ts b/src/components/spreadsheet/config/equipment/bus.ts index ca0e4ddafd..ad38137800 100644 --- a/src/components/spreadsheet/config/equipment/bus.ts +++ b/src/components/spreadsheet/config/equipment/bus.ts @@ -8,10 +8,10 @@ import type { ReadonlyDeep } from 'type-fest'; import type { SpreadsheetTabDefinition } from '../spreadsheet.type'; import { EQUIPMENT_TYPES } from '../../../utils/equipment-types'; -import CountryCellRenderer from '../../utils/country-cell-render'; import { typeAndFetchers } from './common-config'; import { genericColumnOfProperties } from '../common/column-properties'; import { COUNTRY_TYPE, NUMERIC_TYPE, TEXT_TYPE } from 'components/spreadsheet/utils/constants'; +import { SortWay } from 'hooks/use-aggrid-sort'; export const BUS_TAB_DEF = { index: 14, @@ -21,8 +21,8 @@ export const BUS_TAB_DEF = { { id: 'ID', field: 'id', - isDefaultSort: true, type: TEXT_TYPE, + sort: SortWay.ASC, }, { id: 'Magnitude', diff --git a/src/components/spreadsheet/config/equipment/busbar-section.ts b/src/components/spreadsheet/config/equipment/busbar-section.ts index 55aa2f103b..fe219cb19e 100644 --- a/src/components/spreadsheet/config/equipment/busbar-section.ts +++ b/src/components/spreadsheet/config/equipment/busbar-section.ts @@ -10,6 +10,7 @@ import { EQUIPMENT_TYPES } from '../../../utils/equipment-types'; import { typeAndFetchers } from './common-config'; import type { ReadonlyDeep } from 'type-fest'; import { TEXT_TYPE } from 'components/spreadsheet/utils/constants'; +import { SortWay } from 'hooks/use-aggrid-sort'; export const BUSBAR_SECTION_TAB_DEF = { index: 16, @@ -19,8 +20,8 @@ export const BUSBAR_SECTION_TAB_DEF = { { id: 'ID', field: 'id', - isDefaultSort: true, type: TEXT_TYPE, + sort: SortWay.ASC, }, { id: 'VoltageLevelId', diff --git a/src/components/spreadsheet/config/equipment/common-config.ts b/src/components/spreadsheet/config/equipment/common-config.ts index 9dd8782fff..ddde5b3236 100644 --- a/src/components/spreadsheet/config/equipment/common-config.ts +++ b/src/components/spreadsheet/config/equipment/common-config.ts @@ -5,16 +5,9 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import type { ReadonlyDeep, Writable } from 'type-fest'; -import { getEnumLabelById } from '../../../utils/utils'; -import { - type CustomColDef, - FILTER_DATA_TYPES, - FILTER_TEXT_COMPARATORS, -} from '../../../custom-aggrid/custom-aggrid-header.type'; -import { EnumOption } from '../../../utils/utils-type'; +import type { ReadonlyDeep } from 'type-fest'; +import { type CustomColDef } from '../../../custom-aggrid/custom-aggrid-header.type'; import type { CellStyleFunc, EditableCallback } from 'ag-grid-community'; -import EnumCellRenderer, { type EnumCellRendererProps } from '../../utils/enum-cell-renderer'; import { EQUIPMENT_TYPES } from '../../../utils/equipment-types'; import { fetchBatteries, @@ -35,8 +28,7 @@ import { fetchVoltageLevels, fetchVscConverterStations, } from '../../../../services/study/network'; -import { EquipmentFetcher, SpreadsheetColDef, SpreadsheetEquipmentType } from '../spreadsheet.type'; -import { getEnumFilterConfig } from '../column-type-filter-config'; +import { EquipmentFetcher, SpreadsheetEquipmentType } from '../spreadsheet.type'; type TapPositionsType = { lowTapPosition: number; @@ -114,24 +106,3 @@ export const editableColumnConfig = { // The columns we want to include in the global filter at the date of this comment: ID (all), Name, Country, Type and Nominal Voltage (all). // All the others should be excluded. export const excludeFromGlobalFilter = () => '' as const; - -export const defaultTextFilterConfig = { - filter: 'agTextColumnFilter', - customFilterParams: { - filterDataType: FILTER_DATA_TYPES.TEXT, - filterComparators: [FILTER_TEXT_COMPARATORS.STARTS_WITH, FILTER_TEXT_COMPARATORS.CONTAINS], - }, -} as const satisfies Partial>; - -// This function is used to generate the default configuration for an enum filter -// It generates configuration for filtering, sorting and rendering -export const getDefaultEnumConfig = (enumOptions: Readonly) => - ({ - ...getEnumFilterConfig(enumOptions as EnumOption[]), - cellRenderer: EnumCellRenderer, - cellRendererParams: { - enumOptions: enumOptions as Writable, - // @ts-expect-error TODO TS1360: Property value is missing in type - } satisfies EnumCellRendererProps, - getEnumLabel: (value: string) => getEnumLabelById(enumOptions as Writable, value), - } as const satisfies Partial>); diff --git a/src/components/spreadsheet/config/equipment/dangling-line.ts b/src/components/spreadsheet/config/equipment/dangling-line.ts index 2bf39c0a9b..ed9c652fd8 100644 --- a/src/components/spreadsheet/config/equipment/dangling-line.ts +++ b/src/components/spreadsheet/config/equipment/dangling-line.ts @@ -8,12 +8,11 @@ import type { ReadonlyDeep } from 'type-fest'; import type { SpreadsheetTabDefinition } from '../spreadsheet.type'; import { EQUIPMENT_TYPES } from '../../../utils/equipment-types'; -import CountryCellRenderer from '../../utils/country-cell-render'; -import { BooleanCellRenderer } from '../../utils/cell-renderers'; import { excludeFromGlobalFilter, typeAndFetchers } from './common-config'; import { NOMINAL_V } from '../../../utils/field-constants'; import { genericColumnOfProperties } from '../common/column-properties'; import { BOOLEAN_TYPE, COUNTRY_TYPE, NUMERIC_TYPE, TEXT_TYPE } from 'components/spreadsheet/utils/constants'; +import { SortWay } from 'hooks/use-aggrid-sort'; export const DANGLING_LINE_TAB_DEF = { index: 13, @@ -23,8 +22,8 @@ export const DANGLING_LINE_TAB_DEF = { { id: 'ID', field: 'id', - isDefaultSort: true, type: TEXT_TYPE, + sort: SortWay.ASC, }, { id: 'Name', @@ -91,8 +90,6 @@ export const DANGLING_LINE_TAB_DEF = { { id: 'connected', field: 'terminalConnected', - boolean: true, - cellRenderer: BooleanCellRenderer, type: BOOLEAN_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, diff --git a/src/components/spreadsheet/config/equipment/generator.ts b/src/components/spreadsheet/config/equipment/generator.ts index 6535549ac1..be6862e515 100644 --- a/src/components/spreadsheet/config/equipment/generator.ts +++ b/src/components/spreadsheet/config/equipment/generator.ts @@ -12,16 +12,8 @@ import { type EquipmentTableDataEditorProps, GeneratorRegulatingTerminalEditor, } from '../../utils/equipment-table-editors'; -import CountryCellRenderer from '../../utils/country-cell-render'; import type { EditableCallback, ValueGetterFunc } from 'ag-grid-community'; -import { BooleanCellRenderer } from '../../utils/cell-renderers'; -import { - editableCellStyle, - editableColumnConfig, - excludeFromGlobalFilter, - getDefaultEnumConfig, - typeAndFetchers, -} from './common-config'; +import { editableCellStyle, editableColumnConfig, excludeFromGlobalFilter, typeAndFetchers } from './common-config'; import { BOOLEAN_TYPE, COUNTRY_TYPE, MEDIUM_COLUMN_WIDTH, NUMERIC_TYPE, TEXT_TYPE } from '../../utils/constants'; import { ENERGY_SOURCES, REGULATION_TYPES } from '../../../network/constants'; import { genericColumnOfPropertiesEditPopup } from '../common/column-properties'; @@ -31,6 +23,8 @@ import { type ICustomCellEditorParams, numericalCellEditorConfig, } from '../common/cell-editors'; +import { SortWay } from 'hooks/use-aggrid-sort'; +import { getEnumConfig } from '../column-type-filter-config'; const RegulatingTerminalCellGetter: ValueGetterFunc = (params) => { const { regulatingTerminalConnectableId, regulatingTerminalVlId, regulatingTerminalConnectableType } = @@ -67,8 +61,8 @@ export const GENERATOR_TAB_DEF = { id: 'ID', field: 'id', columnWidth: MEDIUM_COLUMN_WIDTH, - isDefaultSort: true, type: TEXT_TYPE, + sort: SortWay.ASC, }, { id: 'Name', @@ -96,7 +90,7 @@ export const GENERATOR_TAB_DEF = { { id: 'energySource', field: 'energySource', - ...getDefaultEnumConfig(ENERGY_SOURCES), + ...getEnumConfig(ENERGY_SOURCES), ...editableColumnConfig, ...enumCellEditorConfig((params) => params.data?.energySource, ENERGY_SOURCES), }, @@ -123,7 +117,6 @@ export const GENERATOR_TAB_DEF = { { id: 'ActivePowerControl', field: 'activePowerControl.participate', - cellRenderer: BooleanCellRenderer, type: BOOLEAN_TYPE, ...editableColumnConfig, valueSetter: (params) => { @@ -221,7 +214,6 @@ export const GENERATOR_TAB_DEF = { { id: 'voltageRegulationOn', field: 'voltageRegulatorOn', - cellRenderer: BooleanCellRenderer, type: BOOLEAN_TYPE, ...editableColumnConfig, ...booleanCellEditorConfig((params) => params.data?.voltageRegulatorOn ?? false), @@ -403,15 +395,13 @@ export const GENERATOR_TAB_DEF = { { id: 'connected', field: 'terminalConnected', - boolean: true, - cellRenderer: BooleanCellRenderer, type: BOOLEAN_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, { id: 'RegulationTypeText', field: 'RegulationTypeText', - ...getDefaultEnumConfig(Object.values(REGULATION_TYPES)), + ...getEnumConfig(Object.values(REGULATION_TYPES)), ...editableColumnConfig, ...enumCellEditorConfig((params) => params.data?.RegulationTypeText, Object.values(REGULATION_TYPES)), }, diff --git a/src/components/spreadsheet/config/equipment/hvdc-line.ts b/src/components/spreadsheet/config/equipment/hvdc-line.ts index 07e41b3411..9e6796acee 100644 --- a/src/components/spreadsheet/config/equipment/hvdc-line.ts +++ b/src/components/spreadsheet/config/equipment/hvdc-line.ts @@ -8,8 +8,6 @@ import type { ReadonlyDeep } from 'type-fest'; import type { SpreadsheetTabDefinition } from '../spreadsheet.type'; import { EQUIPMENT_TYPES } from '../../../utils/equipment-types'; -import CountryCellRenderer from '../../utils/country-cell-render'; -import { BooleanCellRenderer } from '../../utils/cell-renderers'; import { excludeFromGlobalFilter, typeAndFetchers } from './common-config'; import { BOOLEAN_TYPE, @@ -20,6 +18,7 @@ import { TEXT_TYPE, } from '../../utils/constants'; import { genericColumnOfProperties } from '../common/column-properties'; +import { SortWay } from 'hooks/use-aggrid-sort'; export const HVDC_LINE_TAB_DEF = { index: 10, @@ -30,8 +29,8 @@ export const HVDC_LINE_TAB_DEF = { id: 'ID', field: 'id', columnWidth: MEDIUM_COLUMN_WIDTH, - isDefaultSort: true, type: TEXT_TYPE, + sort: SortWay.ASC, }, { id: 'Name', @@ -123,8 +122,6 @@ export const HVDC_LINE_TAB_DEF = { { id: 'AcEmulation', field: 'hvdcAngleDroopActivePowerControl.isEnabled', - boolean: true, - cellRenderer: BooleanCellRenderer, type: BOOLEAN_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, diff --git a/src/components/spreadsheet/config/equipment/lcc-converter-station.ts b/src/components/spreadsheet/config/equipment/lcc-converter-station.ts index aef6d7f14f..40e05a61cf 100644 --- a/src/components/spreadsheet/config/equipment/lcc-converter-station.ts +++ b/src/components/spreadsheet/config/equipment/lcc-converter-station.ts @@ -8,11 +8,10 @@ import type { ReadonlyDeep } from 'type-fest'; import type { SpreadsheetTabDefinition } from '../spreadsheet.type'; import { EQUIPMENT_TYPES } from '../../../utils/equipment-types'; -import CountryCellRenderer from '../../utils/country-cell-render'; -import { BooleanCellRenderer } from '../../utils/cell-renderers'; import { excludeFromGlobalFilter, typeAndFetchers } from './common-config'; import { genericColumnOfProperties } from '../common/column-properties'; import { BOOLEAN_TYPE, COUNTRY_TYPE, NUMERIC_TYPE, TEXT_TYPE } from 'components/spreadsheet/utils/constants'; +import { SortWay } from 'hooks/use-aggrid-sort'; export const LCC_CONVERTER_STATION_TAB_DEF = { index: 11, @@ -22,8 +21,8 @@ export const LCC_CONVERTER_STATION_TAB_DEF = { { id: 'ID', field: 'id', - isDefaultSort: true, type: TEXT_TYPE, + sort: SortWay.ASC, }, { id: 'Name', @@ -89,8 +88,6 @@ export const LCC_CONVERTER_STATION_TAB_DEF = { { id: 'connected', field: 'terminalConnected', - boolean: true, - cellRenderer: BooleanCellRenderer, type: BOOLEAN_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, diff --git a/src/components/spreadsheet/config/equipment/line.ts b/src/components/spreadsheet/config/equipment/line.ts index 2735e349ff..d55afc06e5 100644 --- a/src/components/spreadsheet/config/equipment/line.ts +++ b/src/components/spreadsheet/config/equipment/line.ts @@ -9,11 +9,11 @@ import type { ReadonlyDeep } from 'type-fest'; import type { SpreadsheetTabDefinition } from '../spreadsheet.type'; import { EQUIPMENT_TYPES } from '../../../utils/equipment-types'; import CountryCellRenderer from '../../utils/country-cell-render'; -import { BooleanCellRenderer } from '../../utils/cell-renderers'; import { excludeFromGlobalFilter, typeAndFetchers } from './common-config'; import { BOOLEAN_TYPE, COUNTRY_TYPE, MEDIUM_COLUMN_WIDTH, NUMERIC_TYPE, TEXT_TYPE } from '../../utils/constants'; import { unitToMicroUnit } from '../../../../utils/unit-converter'; import { genericColumnOfProperties } from '../common/column-properties'; +import { SortWay } from 'hooks/use-aggrid-sort'; export const LINE_TAB_DEF = { index: 2, @@ -24,8 +24,8 @@ export const LINE_TAB_DEF = { id: 'ID', field: 'id', columnWidth: MEDIUM_COLUMN_WIDTH, - isDefaultSort: true, type: TEXT_TYPE, + sort: SortWay.ASC, }, { id: 'Name', @@ -47,7 +47,6 @@ export const LINE_TAB_DEF = { id: 'Country1', field: 'country1', type: COUNTRY_TYPE, - cellRenderer: CountryCellRenderer, }, { id: 'Country2', @@ -76,6 +75,7 @@ export const LINE_TAB_DEF = { type: NUMERIC_TYPE, fractionDigits: 1, canBeInvalidated: true, + withFluxConvention: true, getQuickFilterText: excludeFromGlobalFilter, }, { @@ -160,8 +160,6 @@ export const LINE_TAB_DEF = { { id: 'connected1', field: 'terminal1Connected', - boolean: true, - cellRenderer: BooleanCellRenderer, type: BOOLEAN_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, @@ -169,7 +167,6 @@ export const LINE_TAB_DEF = { id: 'connected2', field: 'terminal2Connected', boolean: true, - cellRenderer: BooleanCellRenderer, type: BOOLEAN_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, diff --git a/src/components/spreadsheet/config/equipment/load.ts b/src/components/spreadsheet/config/equipment/load.ts index f66bf4ea09..aa956a35a7 100644 --- a/src/components/spreadsheet/config/equipment/load.ts +++ b/src/components/spreadsheet/config/equipment/load.ts @@ -8,13 +8,13 @@ import type { ReadonlyDeep } from 'type-fest'; import type { SpreadsheetTabDefinition } from '../spreadsheet.type'; import { EQUIPMENT_TYPES } from '../../../utils/equipment-types'; -import CountryCellRenderer from '../../utils/country-cell-render'; -import { BooleanCellRenderer } from '../../utils/cell-renderers'; -import { editableColumnConfig, excludeFromGlobalFilter, getDefaultEnumConfig, typeAndFetchers } from './common-config'; +import { editableColumnConfig, excludeFromGlobalFilter, typeAndFetchers } from './common-config'; import { BOOLEAN_TYPE, COUNTRY_TYPE, MEDIUM_COLUMN_WIDTH, NUMERIC_TYPE, TEXT_TYPE } from '../../utils/constants'; import { LOAD_TYPES } from '../../../network/constants'; import { genericColumnOfPropertiesEditPopup } from '../common/column-properties'; import { enumCellEditorConfig, numericalCellEditorConfig } from '../common/cell-editors'; +import { SortWay } from 'hooks/use-aggrid-sort'; +import { getEnumConfig } from '../column-type-filter-config'; export const LOAD_TAB_DEF = { index: 6, @@ -25,8 +25,8 @@ export const LOAD_TAB_DEF = { id: 'ID', field: 'id', columnWidth: MEDIUM_COLUMN_WIDTH, - isDefaultSort: true, type: TEXT_TYPE, + sort: SortWay.ASC, }, { id: 'Name', @@ -38,7 +38,7 @@ export const LOAD_TAB_DEF = { { id: 'loadType', field: 'type', - ...getDefaultEnumConfig([...LOAD_TYPES, { id: 'UNDEFINED', label: 'Undefined' }]), + ...getEnumConfig([...LOAD_TYPES, { id: 'UNDEFINED', label: 'Undefined' }]), ...editableColumnConfig, ...enumCellEditorConfig( (params) => params.data?.type, @@ -54,7 +54,6 @@ export const LOAD_TAB_DEF = { id: 'Country', field: 'country', type: COUNTRY_TYPE, - cellRenderer: CountryCellRenderer, }, { id: 'NominalV', @@ -104,8 +103,6 @@ export const LOAD_TAB_DEF = { { id: 'connected', field: 'terminalConnected', - boolean: true, - cellRenderer: BooleanCellRenderer, type: BOOLEAN_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, diff --git a/src/components/spreadsheet/config/equipment/shunt-compensator.ts b/src/components/spreadsheet/config/equipment/shunt-compensator.ts index 67d199c97a..b0e5ac3395 100644 --- a/src/components/spreadsheet/config/equipment/shunt-compensator.ts +++ b/src/components/spreadsheet/config/equipment/shunt-compensator.ts @@ -8,9 +8,7 @@ import type { ReadonlyDeep } from 'type-fest'; import type { SpreadsheetTabDefinition } from '../spreadsheet.type'; import { EQUIPMENT_TYPES } from '../../../utils/equipment-types'; -import CountryCellRenderer from '../../utils/country-cell-render'; -import { BooleanCellRenderer } from '../../utils/cell-renderers'; -import { editableColumnConfig, excludeFromGlobalFilter, getDefaultEnumConfig, typeAndFetchers } from './common-config'; +import { editableColumnConfig, excludeFromGlobalFilter, typeAndFetchers } from './common-config'; import { BOOLEAN_TYPE, COUNTRY_TYPE, @@ -22,6 +20,8 @@ import { import { SHUNT_COMPENSATOR_TYPES } from '../../../network/constants'; import { genericColumnOfPropertiesEditPopup } from '../common/column-properties'; import { enumCellEditorConfig, numericalCellEditorConfig } from '../common/cell-editors'; +import { SortWay } from 'hooks/use-aggrid-sort'; +import { getEnumConfig } from '../column-type-filter-config'; export const SHUNT_COMPENSATOR_TAB_DEF = { index: 7, @@ -32,8 +32,8 @@ export const SHUNT_COMPENSATOR_TAB_DEF = { id: 'ID', field: 'id', columnWidth: MEDIUM_COLUMN_WIDTH, - isDefaultSort: true, type: TEXT_TYPE, + sort: SortWay.ASC, }, { id: 'Name', @@ -51,7 +51,6 @@ export const SHUNT_COMPENSATOR_TAB_DEF = { id: 'Country', field: 'country', type: COUNTRY_TYPE, - cellRenderer: CountryCellRenderer, }, { id: 'NominalV', @@ -98,7 +97,7 @@ export const SHUNT_COMPENSATOR_TAB_DEF = { { id: 'Type', field: 'type', - ...getDefaultEnumConfig(Object.values(SHUNT_COMPENSATOR_TYPES)), + ...getEnumConfig(Object.values(SHUNT_COMPENSATOR_TYPES)), ...editableColumnConfig, ...enumCellEditorConfig((params) => params.data?.type, Object.values(SHUNT_COMPENSATOR_TYPES)), }, @@ -156,8 +155,6 @@ export const SHUNT_COMPENSATOR_TAB_DEF = { { id: 'connected', field: 'terminalConnected', - boolean: true, - cellRenderer: BooleanCellRenderer, type: BOOLEAN_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, diff --git a/src/components/spreadsheet/config/equipment/static-var-compensator.ts b/src/components/spreadsheet/config/equipment/static-var-compensator.ts index cac78e471a..4be672b3ed 100644 --- a/src/components/spreadsheet/config/equipment/static-var-compensator.ts +++ b/src/components/spreadsheet/config/equipment/static-var-compensator.ts @@ -8,12 +8,11 @@ import type { ReadonlyDeep } from 'type-fest'; import type { SpreadsheetTabDefinition } from '../spreadsheet.type'; import { EQUIPMENT_TYPES } from '../../../utils/equipment-types'; -import CountryCellRenderer from '../../utils/country-cell-render'; -import { BooleanCellRenderer } from '../../utils/cell-renderers'; import { excludeFromGlobalFilter, typeAndFetchers } from './common-config'; import { BOOLEAN_TYPE, COUNTRY_TYPE, MEDIUM_COLUMN_WIDTH, NUMERIC_TYPE, TEXT_TYPE } from '../../utils/constants'; import { NOMINAL_V } from '../../../utils/field-constants'; import { genericColumnOfProperties } from '../common/column-properties'; +import { SortWay } from 'hooks/use-aggrid-sort'; export const STATIC_VAR_COMPENSATOR_TAB_DEF = { index: 8, @@ -23,8 +22,8 @@ export const STATIC_VAR_COMPENSATOR_TAB_DEF = { { id: 'ID', field: 'id', - isDefaultSort: true, type: TEXT_TYPE, + sort: SortWay.ASC, }, { id: 'Name', @@ -40,7 +39,6 @@ export const STATIC_VAR_COMPENSATOR_TAB_DEF = { id: 'Country', field: 'country', type: COUNTRY_TYPE, - cellRenderer: CountryCellRenderer, }, { id: 'NominalV', @@ -87,8 +85,6 @@ export const STATIC_VAR_COMPENSATOR_TAB_DEF = { { id: 'connected', field: 'terminalConnected', - boolean: true, - cellRenderer: BooleanCellRenderer, type: BOOLEAN_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, diff --git a/src/components/spreadsheet/config/equipment/substation.ts b/src/components/spreadsheet/config/equipment/substation.ts index ff9452bf5f..65e98e8d03 100644 --- a/src/components/spreadsheet/config/equipment/substation.ts +++ b/src/components/spreadsheet/config/equipment/substation.ts @@ -9,10 +9,10 @@ import type { ReadonlyDeep } from 'type-fest'; import type { SpreadsheetTabDefinition } from '../spreadsheet.type'; import { EQUIPMENT_TYPES } from '../../../utils/equipment-types'; import { SelectCountryField } from '../../utils/equipment-table-editors'; -import CountryCellRenderer from '../../utils/country-cell-render'; import { editableColumnConfig, typeAndFetchers } from './common-config'; import { genericColumnOfPropertiesEditPopup } from '../common/column-properties'; import { COUNTRY_TYPE, TEXT_TYPE } from 'components/spreadsheet/utils/constants'; +import { SortWay } from 'hooks/use-aggrid-sort'; export const SUBSTATION_TAB_DEF = { index: 0, @@ -23,7 +23,7 @@ export const SUBSTATION_TAB_DEF = { id: 'ID', field: 'id', type: TEXT_TYPE, - isDefaultSort: true, + sort: SortWay.ASC, }, { id: 'Name', @@ -36,7 +36,6 @@ export const SUBSTATION_TAB_DEF = { field: 'country', ...editableColumnConfig, cellEditor: SelectCountryField, - cellRenderer: CountryCellRenderer, valueSetter: (params) => { params.data.country = params?.newValue; return true; diff --git a/src/components/spreadsheet/config/equipment/three-windings-transformer.ts b/src/components/spreadsheet/config/equipment/three-windings-transformer.ts index c27d0df8e8..79a550d8d1 100644 --- a/src/components/spreadsheet/config/equipment/three-windings-transformer.ts +++ b/src/components/spreadsheet/config/equipment/three-windings-transformer.ts @@ -8,12 +8,11 @@ import type { ReadonlyDeep } from 'type-fest'; import type { SpreadsheetTabDefinition } from '../spreadsheet.type'; import { EQUIPMENT_TYPES } from '../../../utils/equipment-types'; -import CountryCellRenderer from '../../utils/country-cell-render'; -import { BooleanCellRenderer } from '../../utils/cell-renderers'; import { editableColumnConfig, excludeFromGlobalFilter, generateTapPositions, typeAndFetchers } from './common-config'; import { BOOLEAN_TYPE, COUNTRY_TYPE, MEDIUM_COLUMN_WIDTH, NUMERIC_TYPE, TEXT_TYPE } from '../../utils/constants'; import { genericColumnOfProperties } from '../common/column-properties'; import { standardSelectCellEditorConfig } from '../common/cell-editors'; +import { SortWay } from 'hooks/use-aggrid-sort'; function generateTapRequest(tapType: string, legNumber: number) { return ( @@ -37,8 +36,8 @@ export const THREE_WINDINGS_TRANSFORMER_TAB_DEF = { { id: 'ID', field: 'id', - isDefaultSort: true, type: TEXT_TYPE, + sort: SortWay.ASC, }, { id: 'Name', @@ -64,7 +63,6 @@ export const THREE_WINDINGS_TRANSFORMER_TAB_DEF = { id: 'Country', field: 'country', type: COUNTRY_TYPE, - cellRenderer: CountryCellRenderer, }, { id: 'NominalVT3WSide1', @@ -145,15 +143,11 @@ export const THREE_WINDINGS_TRANSFORMER_TAB_DEF = { id: 'HasLoadTapChanging1Capabilities', field: 'hasLoadTapChanging1Capabilities', boolean: true, - cellRenderer: BooleanCellRenderer, - type: BOOLEAN_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, { id: 'RegulatingRatio1', field: 'isRegulatingRatio1', - boolean: true, - cellRenderer: BooleanCellRenderer, type: BOOLEAN_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, @@ -186,16 +180,12 @@ export const THREE_WINDINGS_TRANSFORMER_TAB_DEF = { { id: 'HasLoadTapChanging2Capabilities', field: 'hasLoadTapChanging2Capabilities', - boolean: true, - cellRenderer: BooleanCellRenderer, type: BOOLEAN_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, { id: 'RegulatingRatio2', field: 'isRegulatingRatio2', - boolean: true, - cellRenderer: BooleanCellRenderer, type: BOOLEAN_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, @@ -228,16 +218,12 @@ export const THREE_WINDINGS_TRANSFORMER_TAB_DEF = { { id: 'HasLoadTapChanging3Capabilities', field: 'hasLoadTapChanging3Capabilities', - boolean: true, - cellRenderer: BooleanCellRenderer, type: BOOLEAN_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, { id: 'RegulatingRatio3', field: 'isRegulatingRatio3', - boolean: true, - cellRenderer: BooleanCellRenderer, type: BOOLEAN_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, @@ -277,8 +263,6 @@ export const THREE_WINDINGS_TRANSFORMER_TAB_DEF = { { id: 'RegulatingPhase1', field: 'isRegulatingPhase1', - boolean: true, - cellRenderer: BooleanCellRenderer, type: BOOLEAN_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, @@ -319,8 +303,6 @@ export const THREE_WINDINGS_TRANSFORMER_TAB_DEF = { { id: 'RegulatingPhase2', field: 'isRegulatingPhase2', - boolean: true, - cellRenderer: BooleanCellRenderer, type: BOOLEAN_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, @@ -361,8 +343,6 @@ export const THREE_WINDINGS_TRANSFORMER_TAB_DEF = { { id: 'RegulatingPhase3', field: 'isRegulatingPhase3', - boolean: true, - cellRenderer: BooleanCellRenderer, type: BOOLEAN_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, @@ -396,24 +376,18 @@ export const THREE_WINDINGS_TRANSFORMER_TAB_DEF = { { id: 'ConnectedT3WSide1', field: 'terminal1Connected', - boolean: true, - cellRenderer: BooleanCellRenderer, type: BOOLEAN_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, { id: 'ConnectedT3WSide2', field: 'terminal2Connected', - boolean: true, - cellRenderer: BooleanCellRenderer, type: BOOLEAN_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, { id: 'ConnectedT3WSide3', field: 'terminal3Connected', - boolean: true, - cellRenderer: BooleanCellRenderer, type: BOOLEAN_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, diff --git a/src/components/spreadsheet/config/equipment/tie-line.ts b/src/components/spreadsheet/config/equipment/tie-line.ts index a021843dcd..5a215117c2 100644 --- a/src/components/spreadsheet/config/equipment/tie-line.ts +++ b/src/components/spreadsheet/config/equipment/tie-line.ts @@ -8,12 +8,11 @@ import type { ReadonlyDeep } from 'type-fest'; import type { SpreadsheetTabDefinition } from '../spreadsheet.type'; import { EQUIPMENT_TYPES } from '../../../utils/equipment-types'; -import CountryCellRenderer from '../../utils/country-cell-render'; -import { BooleanCellRenderer } from '../../utils/cell-renderers'; import { excludeFromGlobalFilter, typeAndFetchers } from './common-config'; import { BOOLEAN_TYPE, COUNTRY_TYPE, MEDIUM_COLUMN_WIDTH, NUMERIC_TYPE, TEXT_TYPE } from '../../utils/constants'; import { unitToMicroUnit } from '../../../../utils/unit-converter'; import { genericColumnOfPropertiesReadonly } from '../common/column-properties'; +import { SortWay } from 'hooks/use-aggrid-sort'; export const TIE_LINE_TAB_DEF = { index: 15, @@ -24,8 +23,8 @@ export const TIE_LINE_TAB_DEF = { id: 'ID', field: 'id', columnWidth: MEDIUM_COLUMN_WIDTH, - isDefaultSort: true, type: TEXT_TYPE, + sort: SortWay.ASC, }, { id: 'Name', @@ -47,13 +46,11 @@ export const TIE_LINE_TAB_DEF = { id: 'Country1', field: 'country1', type: COUNTRY_TYPE, - cellRenderer: CountryCellRenderer, }, { id: 'Country2', field: 'country2', type: COUNTRY_TYPE, - cellRenderer: CountryCellRenderer, }, { id: 'nominalVoltage1KV', @@ -160,16 +157,12 @@ export const TIE_LINE_TAB_DEF = { { id: 'connected1', field: 'terminal1Connected', - boolean: true, - cellRenderer: BooleanCellRenderer, type: BOOLEAN_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, { id: 'connected2', field: 'terminal2Connected', - boolean: true, - cellRenderer: BooleanCellRenderer, type: BOOLEAN_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, diff --git a/src/components/spreadsheet/config/equipment/two-windings-transformer.ts b/src/components/spreadsheet/config/equipment/two-windings-transformer.ts index 54dc55a058..616fb86568 100644 --- a/src/components/spreadsheet/config/equipment/two-windings-transformer.ts +++ b/src/components/spreadsheet/config/equipment/two-windings-transformer.ts @@ -10,7 +10,6 @@ import type { SpreadsheetTabDefinition } from '../spreadsheet.type'; import type { CustomColDef } from '../../../custom-aggrid/custom-aggrid-header.type'; import { EQUIPMENT_TYPES } from '../../../utils/equipment-types'; import { type EquipmentTableDataEditorProps, TWTRegulatingTerminalEditor } from '../../utils/equipment-table-editors'; -import CountryCellRenderer from '../../utils/country-cell-render'; import type { EditableCallback } from 'ag-grid-community'; import { BooleanCellRenderer } from '../../utils/cell-renderers'; import { @@ -18,7 +17,6 @@ import { editableColumnConfig, excludeFromGlobalFilter, generateTapPositions, - getDefaultEnumConfig, isEditable, typeAndFetchers, } from './common-config'; @@ -35,6 +33,8 @@ import { numericalCellEditorConfig, standardSelectCellEditorConfig, } from '../common/cell-editors'; +import { SortWay } from 'hooks/use-aggrid-sort'; +import { getEnumConfig } from '../column-type-filter-config'; function getTwtRatioRegulationModeId(twt: any) { //regulationMode is set by the user (in edit mode) @@ -104,8 +104,8 @@ export const TWO_WINDINGS_TRANSFORMER_TAB_DEF = { { id: 'ID', field: 'id', - isDefaultSort: true, type: TEXT_TYPE, + sort: SortWay.ASC, }, { id: 'Name', @@ -126,7 +126,6 @@ export const TWO_WINDINGS_TRANSFORMER_TAB_DEF = { id: 'Country', field: 'country', type: COUNTRY_TYPE, - cellRenderer: CountryCellRenderer, }, { id: 'nominalVoltage1KV', @@ -202,7 +201,6 @@ export const TWO_WINDINGS_TRANSFORMER_TAB_DEF = { id: 'HasLoadTapChangingCapabilities', field: 'ratioTapChanger.hasLoadTapChangingCapabilities', valueGetter: (params) => params?.data?.ratioTapChanger?.hasLoadTapChangingCapabilities, - cellRenderer: BooleanCellRenderer, type: BOOLEAN_TYPE, editable: (params) => isEditable(params) && hasTwtRatioTapChanger(params), cellStyle: editableCellStyle, @@ -246,7 +244,7 @@ export const TWO_WINDINGS_TRANSFORMER_TAB_DEF = { columnValue: true, }, }, - ...getDefaultEnumConfig(Object.values(RATIO_REGULATION_MODES)), + ...getEnumConfig(Object.values(RATIO_REGULATION_MODES)), }, { id: 'TargetVPoint', @@ -301,12 +299,12 @@ export const TWO_WINDINGS_TRANSFORMER_TAB_DEF = { editable: isTwtRatioOnloadAndEditable, cellStyle: editableCellStyle, getQuickFilterText: excludeFromGlobalFilter, - ...getDefaultEnumConfig(Object.values(REGULATION_TYPES)), + ...getEnumConfig(Object.values(REGULATION_TYPES)), }, { id: 'RatioRegulatedSide', field: 'ratioTapChanger.regulationSide', - ...getDefaultEnumConfig(Object.values(SIDE)), + ...getEnumConfig(Object.values(SIDE)), valueGetter: (params) => params.data?.ratioTapChanger?.regulationSide, valueSetter: (params) => { params.data.ratioTapChanger = { @@ -401,7 +399,7 @@ export const TWO_WINDINGS_TRANSFORMER_TAB_DEF = { { id: 'RegulatingMode', field: 'phaseTapChanger.regulationMode', - ...getDefaultEnumConfig(Object.values(PHASE_REGULATION_MODES)), + ...getEnumConfig(Object.values(PHASE_REGULATION_MODES)), valueGetter: (params) => params?.data?.phaseTapChanger?.regulationMode, valueSetter: (params) => { params.data.phaseTapChanger = { @@ -462,7 +460,7 @@ export const TWO_WINDINGS_TRANSFORMER_TAB_DEF = { { id: 'PhaseRegulationTypeText', field: 'phaseTapChanger.regulationType', - ...getDefaultEnumConfig(Object.values(REGULATION_TYPES)), + ...getEnumConfig(Object.values(REGULATION_TYPES)), valueGetter: (params) => params.data?.phaseTapChanger?.regulationType, valueSetter: (params) => { params.data.phaseTapChanger = { @@ -483,7 +481,7 @@ export const TWO_WINDINGS_TRANSFORMER_TAB_DEF = { { id: 'PhaseRegulatedSide', field: 'phaseTapChanger.regulationSide', - ...getDefaultEnumConfig(Object.values(SIDE)), + ...getEnumConfig(Object.values(SIDE)), valueGetter: (params) => params.data?.phaseTapChanger?.regulationSide, valueSetter: (params) => { params.data.phaseTapChanger = { @@ -628,7 +626,7 @@ export const TWO_WINDINGS_TRANSFORMER_TAB_DEF = { id: 'connected2', field: 'terminal2Connected', boolean: true, - cellRenderer: BooleanCellRenderer, + //cellRenderer: BooleanCellRenderer, type: BOOLEAN_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, diff --git a/src/components/spreadsheet/config/equipment/voltage-level.ts b/src/components/spreadsheet/config/equipment/voltage-level.ts index 2792d5bdb9..8f37265e66 100644 --- a/src/components/spreadsheet/config/equipment/voltage-level.ts +++ b/src/components/spreadsheet/config/equipment/voltage-level.ts @@ -9,12 +9,12 @@ import type { ReadonlyDeep } from 'type-fest'; import type { SpreadsheetTabDefinition } from '../spreadsheet.type'; import type { CustomColDef } from '../../../custom-aggrid/custom-aggrid-header.type'; import { EQUIPMENT_TYPES } from '../../../utils/equipment-types'; -import CountryCellRenderer from '../../utils/country-cell-render'; import { editableColumnConfig, excludeFromGlobalFilter, typeAndFetchers } from './common-config'; import { kiloUnitToUnit, unitToKiloUnit } from '../../../../utils/unit-converter'; import { genericColumnOfPropertiesEditPopup } from '../common/column-properties'; import { numericalCellEditorConfig } from '../common/cell-editors'; import { COUNTRY_TYPE, NUMERIC_TYPE, TEXT_TYPE } from 'components/spreadsheet/utils/constants'; +import { SortWay } from 'hooks/use-aggrid-sort'; function generateEditableNumericColumnDefinition< TId extends string, @@ -47,8 +47,8 @@ export const VOLTAGE_LEVEL_TAB_DEF = { { id: 'ID', field: 'id', - isDefaultSort: true, type: TEXT_TYPE, + sort: SortWay.ASC, }, { id: 'Name', @@ -65,7 +65,6 @@ export const VOLTAGE_LEVEL_TAB_DEF = { id: 'Country', field: 'country', type: COUNTRY_TYPE, - cellRenderer: CountryCellRenderer, }, { id: 'NominalV', diff --git a/src/components/spreadsheet/config/equipment/vsc-converter-station.ts b/src/components/spreadsheet/config/equipment/vsc-converter-station.ts index ff9714ea46..8205edf015 100644 --- a/src/components/spreadsheet/config/equipment/vsc-converter-station.ts +++ b/src/components/spreadsheet/config/equipment/vsc-converter-station.ts @@ -8,11 +8,10 @@ import type { ReadonlyDeep } from 'type-fest'; import type { SpreadsheetTabDefinition } from '../spreadsheet.type'; import { EQUIPMENT_TYPES } from '../../../utils/equipment-types'; -import CountryCellRenderer from '../../utils/country-cell-render'; -import { BooleanCellRenderer } from '../../utils/cell-renderers'; import { excludeFromGlobalFilter, typeAndFetchers } from './common-config'; import { BOOLEAN_TYPE, COUNTRY_TYPE, MEDIUM_COLUMN_WIDTH, NUMERIC_TYPE, TEXT_TYPE } from '../../utils/constants'; import { genericColumnOfProperties } from '../common/column-properties'; +import { SortWay } from 'hooks/use-aggrid-sort'; export const VSC_CONVERTER_STATION_TAB_DEF = { index: 12, @@ -23,8 +22,8 @@ export const VSC_CONVERTER_STATION_TAB_DEF = { id: 'ID', field: 'id', columnWidth: MEDIUM_COLUMN_WIDTH, - isDefaultSort: true, type: TEXT_TYPE, + sort: SortWay.ASC, }, { id: 'Name', @@ -40,7 +39,6 @@ export const VSC_CONVERTER_STATION_TAB_DEF = { id: 'Country', field: 'country', type: COUNTRY_TYPE, - cellRenderer: CountryCellRenderer, }, { id: 'NominalV', @@ -83,8 +81,6 @@ export const VSC_CONVERTER_STATION_TAB_DEF = { { id: 'voltageRegulationOn', field: 'voltageRegulatorOn', - boolean: true, - cellRenderer: BooleanCellRenderer, type: BOOLEAN_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, @@ -107,8 +103,6 @@ export const VSC_CONVERTER_STATION_TAB_DEF = { { id: 'connected', field: 'terminalConnected', - boolean: true, - cellRenderer: BooleanCellRenderer, type: BOOLEAN_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, diff --git a/src/components/spreadsheet/config/spreadsheet.type.ts b/src/components/spreadsheet/config/spreadsheet.type.ts index be41cb80cd..871d7a462e 100644 --- a/src/components/spreadsheet/config/spreadsheet.type.ts +++ b/src/components/spreadsheet/config/spreadsheet.type.ts @@ -36,7 +36,7 @@ export interface SpreadsheetColDef extends ColDef number; } const loadingOverlayComponent = (props: { loadingMessage: string }) => <>{props.loadingMessage}; @@ -72,6 +76,7 @@ export const EquipmentTable: FunctionComponent = ({ fetched, shouldHidePinnedHeaderRightBorder, columnTypes, + applyFluxConvention, }) => { const theme = useTheme(); const intl = useIntl(); @@ -101,8 +106,9 @@ export const EquipmentTable: FunctionComponent = ({ studyUuid: studyUuid, intl: intl, translateCountryCode: translate, + applyFluxConvention: applyFluxConvention, }), - [currentNode, intl, studyUuid, theme, topPinnedData, translate] + [applyFluxConvention, currentNode, intl, studyUuid, theme, topPinnedData, translate] ); const getRowHeight = useCallback( diff --git a/src/components/spreadsheet/table-wrapper.tsx b/src/components/spreadsheet/table-wrapper.tsx index d3f0fbd01b..0abd525f8f 100644 --- a/src/components/spreadsheet/table-wrapper.tsx +++ b/src/components/spreadsheet/table-wrapper.tsx @@ -1217,6 +1217,7 @@ const TableWrapper: FunctionComponent = ({ handleRowDataUpdated={handleRowDataUpdated} shouldHidePinnedHeaderRightBorder={isLockedColumnNamesEmpty} columnTypes={defaultColumnType} + applyFluxConvention={applyFluxConvention} /> )} From 06ffdaf07a3c3e2fc44c7c6d44e3f2dbe6e9a9f0 Mon Sep 17 00:00:00 2001 From: TOURI ANIS Date: Tue, 17 Dec 2024 09:25:29 +0100 Subject: [PATCH 07/10] clean code --- src/components/spreadsheet/equipment-table.tsx | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/components/spreadsheet/equipment-table.tsx b/src/components/spreadsheet/equipment-table.tsx index 95d4898dfa..bf4e3a8230 100644 --- a/src/components/spreadsheet/equipment-table.tsx +++ b/src/components/spreadsheet/equipment-table.tsx @@ -19,12 +19,9 @@ import { RowHeightParams, RowStyle, } from 'ag-grid-community'; -import { AppState, CurrentTreeNode } from '../../redux/reducer'; +import { CurrentTreeNode } from '../../redux/reducer'; import { suppressEventsToPreventEditMode } from '../dialogs/commons/utils'; import { useLocalizedCountries } from 'components/utils/localized-countries-hook'; -import { FluxConventions } from 'components/dialogs/parameters/network-parameters'; -import { useSelector } from 'react-redux'; -import { PARAM_FLUX_CONVENTION } from 'utils/config-params'; const PINNED_ROW_HEIGHT = 42; const DEFAULT_ROW_HEIGHT = 28; From cfe4019f92e7e72bd74140b1cbb0577031f8677c Mon Sep 17 00:00:00 2001 From: TOURI ANIS Date: Tue, 17 Dec 2024 17:29:33 +0100 Subject: [PATCH 08/10] improve columnTypes --- .../config/column-type-filter-config.ts | 47 +++++++------- .../spreadsheet/config/equipment/battery.ts | 22 ++++--- .../spreadsheet/config/equipment/bus.ts | 13 ++-- .../config/equipment/dangling-line.ts | 14 +++-- .../spreadsheet/config/equipment/generator.ts | 24 +++++--- .../config/equipment/lcc-converter-station.ts | 14 +++-- .../spreadsheet/config/equipment/line.ts | 25 +++++--- .../spreadsheet/config/equipment/load.ts | 15 +++-- .../config/equipment/shunt-compensator.ts | 8 ++- .../equipment/static-var-compensator.ts | 15 +++-- .../equipment/three-windings-transformer.ts | 27 ++++---- .../spreadsheet/config/equipment/tie-line.ts | 21 ++++--- .../equipment/two-windings-transformer.ts | 25 ++++---- .../config/equipment/vsc-converter-station.ts | 15 +++-- .../spreadsheet/equipment-table.tsx | 5 +- src/components/spreadsheet/table-wrapper.tsx | 61 +------------------ .../spreadsheet/utils/cell-renderers.tsx | 6 +- src/components/spreadsheet/utils/constants.ts | 1 + 18 files changed, 176 insertions(+), 182 deletions(-) diff --git a/src/components/spreadsheet/config/column-type-filter-config.ts b/src/components/spreadsheet/config/column-type-filter-config.ts index 90145f9e61..7bc180e06b 100644 --- a/src/components/spreadsheet/config/column-type-filter-config.ts +++ b/src/components/spreadsheet/config/column-type-filter-config.ts @@ -12,6 +12,7 @@ import CountryCellRenderer from '../utils/country-cell-render'; import { BooleanCellRenderer, DefaultCellRenderer } from '../utils/cell-renderers'; import EnumCellRenderer from '../utils/enum-cell-renderer'; import { Writable } from 'type-fest'; +import RunningStatus from 'components/utils/running-status'; const contains = (target: string, lookingFor: string): boolean => { if (target && lookingFor) { @@ -55,12 +56,7 @@ const textType = { maxNumConditions: 1, filterOptions: [FILTER_TEXT_COMPARATORS.STARTS_WITH, FILTER_TEXT_COMPARATORS.CONTAINS], }, - cellRendererSelector: (props: any) => { - return { - component: DefaultCellRenderer, - props: props, - }; - }, + cellRenderer: DefaultCellRenderer, sortable: true, resizable: true, }; @@ -72,28 +68,32 @@ const numericType = { filterOptions: Object.values(FILTER_NUMBER_COMPARATORS), debounceMs: 200, }, - cellRendererSelector: (props: any) => { + cellRenderer: DefaultCellRenderer, + sortable: true, + resizable: true, +}; + +const numericCanBeInvalidatedType = { + filter: 'agNumberColumnFilter', + filterParams: { + maxNumConditions: 1, + filterOptions: Object.values(FILTER_NUMBER_COMPARATORS), + debounceMs: 200, + }, + cellRendererSelector: ({ context }: { context: any }) => { return { component: DefaultCellRenderer, - props: { - isValueInvalid: props.colDef.cellRendererParams.colisValueInvalid, - applyFluxConvention: props.context.applyFluxConvention, + params: { + isValueInvalid: context.loadFlowStatus !== RunningStatus.SUCCEED, }, }; }, + sortable: true, resizable: true, }; const booleanType = { - cellRendererSelector: ({ value }: { value: string }) => { - return { - component: BooleanCellRenderer, - props: { - value, - }, - }; - }, filter: 'agTextColumnFilter', filterParams: { caseSensitive: false, @@ -108,19 +108,12 @@ const booleanType = { }, debounceMs: 200, }, + cellRenderer: BooleanCellRenderer, sortable: true, resizable: true, }; const countryType = { - cellRendererSelector: ({ value }: { value: string }) => { - return { - component: CountryCellRenderer, - params: { - value, - }, - }; - }, filter: 'agTextColumnFilter', filterParams: { caseSensitive: false, @@ -136,6 +129,7 @@ const countryType = { }, debounceMs: 200, }, + cellRenderer: CountryCellRenderer, sortable: true, resizable: true, }; @@ -143,6 +137,7 @@ const countryType = { export const defaultColumnType = { textType, numericType, + numericCanBeInvalidatedType, booleanType, countryType, }; diff --git a/src/components/spreadsheet/config/equipment/battery.ts b/src/components/spreadsheet/config/equipment/battery.ts index eb5ec93132..5cad804404 100644 --- a/src/components/spreadsheet/config/equipment/battery.ts +++ b/src/components/spreadsheet/config/equipment/battery.ts @@ -11,7 +11,13 @@ import { editableColumnConfig, excludeFromGlobalFilter, typeAndFetchers } from ' import type { SpreadsheetTabDefinition } from '../spreadsheet.type'; import { genericColumnOfPropertiesEditPopup } from '../common/column-properties'; import { booleanCellEditorConfig, numericalCellEditorConfig } from '../common/cell-editors'; -import { BOOLEAN_TYPE, COUNTRY_TYPE, NUMERIC_TYPE, TEXT_TYPE } from 'components/spreadsheet/utils/constants'; +import { + BOOLEAN_TYPE, + COUNTRY_TYPE, + NUMERIC_CAN_BE_INVALIDATED_TYPE, + NUMERIC_TYPE, + TEXT_TYPE, +} from 'components/spreadsheet/utils/constants'; import { SortWay } from 'hooks/use-aggrid-sort'; export const BATTERY_TAB_DEF = { @@ -54,9 +60,10 @@ export const BATTERY_TAB_DEF = { field: 'p', numeric: true, fractionDigits: 1, - type: NUMERIC_TYPE, - canBeInvalidated: true, - withFluxConvention: true, + type: NUMERIC_CAN_BE_INVALIDATED_TYPE, + valueGetter: (params) => { + return params.context.applyFluxConvention(params.data.p); + }, getQuickFilterText: excludeFromGlobalFilter, }, { @@ -64,9 +71,10 @@ export const BATTERY_TAB_DEF = { field: 'q', numeric: true, fractionDigits: 1, - type: NUMERIC_TYPE, - canBeInvalidated: true, - withFluxConvention: true, + type: NUMERIC_CAN_BE_INVALIDATED_TYPE, + valueGetter: (params) => { + return params.context.applyFluxConvention(params.data.q); + }, getQuickFilterText: excludeFromGlobalFilter, }, { diff --git a/src/components/spreadsheet/config/equipment/bus.ts b/src/components/spreadsheet/config/equipment/bus.ts index ad38137800..bc5d17dcb4 100644 --- a/src/components/spreadsheet/config/equipment/bus.ts +++ b/src/components/spreadsheet/config/equipment/bus.ts @@ -10,7 +10,12 @@ import type { SpreadsheetTabDefinition } from '../spreadsheet.type'; import { EQUIPMENT_TYPES } from '../../../utils/equipment-types'; import { typeAndFetchers } from './common-config'; import { genericColumnOfProperties } from '../common/column-properties'; -import { COUNTRY_TYPE, NUMERIC_TYPE, TEXT_TYPE } from 'components/spreadsheet/utils/constants'; +import { + COUNTRY_TYPE, + NUMERIC_CAN_BE_INVALIDATED_TYPE, + NUMERIC_TYPE, + TEXT_TYPE, +} from 'components/spreadsheet/utils/constants'; import { SortWay } from 'hooks/use-aggrid-sort'; export const BUS_TAB_DEF = { @@ -29,16 +34,14 @@ export const BUS_TAB_DEF = { field: 'v', numeric: true, fractionDigits: 1, - canBeInvalidated: true, - type: NUMERIC_TYPE, + type: NUMERIC_CAN_BE_INVALIDATED_TYPE, }, { id: 'Angle', field: 'angle', numeric: true, fractionDigits: 1, - canBeInvalidated: true, - type: NUMERIC_TYPE, + type: NUMERIC_CAN_BE_INVALIDATED_TYPE, }, { id: 'ConnectedComponent', diff --git a/src/components/spreadsheet/config/equipment/dangling-line.ts b/src/components/spreadsheet/config/equipment/dangling-line.ts index ed9c652fd8..afaee6ea88 100644 --- a/src/components/spreadsheet/config/equipment/dangling-line.ts +++ b/src/components/spreadsheet/config/equipment/dangling-line.ts @@ -11,7 +11,13 @@ import { EQUIPMENT_TYPES } from '../../../utils/equipment-types'; import { excludeFromGlobalFilter, typeAndFetchers } from './common-config'; import { NOMINAL_V } from '../../../utils/field-constants'; import { genericColumnOfProperties } from '../common/column-properties'; -import { BOOLEAN_TYPE, COUNTRY_TYPE, NUMERIC_TYPE, TEXT_TYPE } from 'components/spreadsheet/utils/constants'; +import { + BOOLEAN_TYPE, + COUNTRY_TYPE, + NUMERIC_CAN_BE_INVALIDATED_TYPE, + NUMERIC_TYPE, + TEXT_TYPE, +} from 'components/spreadsheet/utils/constants'; import { SortWay } from 'hooks/use-aggrid-sort'; export const DANGLING_LINE_TAB_DEF = { @@ -57,18 +63,16 @@ export const DANGLING_LINE_TAB_DEF = { id: 'activePower', field: 'p', numeric: true, - type: NUMERIC_TYPE, + type: NUMERIC_CAN_BE_INVALIDATED_TYPE, fractionDigits: 1, - canBeInvalidated: true, getQuickFilterText: excludeFromGlobalFilter, }, { id: 'ReactivePower', field: 'q', numeric: true, - type: NUMERIC_TYPE, + type: NUMERIC_CAN_BE_INVALIDATED_TYPE, fractionDigits: 1, - canBeInvalidated: true, getQuickFilterText: excludeFromGlobalFilter, }, { diff --git a/src/components/spreadsheet/config/equipment/generator.ts b/src/components/spreadsheet/config/equipment/generator.ts index be6862e515..5cfcbe2571 100644 --- a/src/components/spreadsheet/config/equipment/generator.ts +++ b/src/components/spreadsheet/config/equipment/generator.ts @@ -14,7 +14,14 @@ import { } from '../../utils/equipment-table-editors'; import type { EditableCallback, ValueGetterFunc } from 'ag-grid-community'; import { editableCellStyle, editableColumnConfig, excludeFromGlobalFilter, typeAndFetchers } from './common-config'; -import { BOOLEAN_TYPE, COUNTRY_TYPE, MEDIUM_COLUMN_WIDTH, NUMERIC_TYPE, TEXT_TYPE } from '../../utils/constants'; +import { + BOOLEAN_TYPE, + COUNTRY_TYPE, + MEDIUM_COLUMN_WIDTH, + NUMERIC_CAN_BE_INVALIDATED_TYPE, + NUMERIC_TYPE, + TEXT_TYPE, +} from '../../utils/constants'; import { ENERGY_SOURCES, REGULATION_TYPES } from '../../../network/constants'; import { genericColumnOfPropertiesEditPopup } from '../common/column-properties'; import { @@ -99,9 +106,10 @@ export const GENERATOR_TAB_DEF = { field: 'p', numeric: true, fractionDigits: 1, - type: NUMERIC_TYPE, - canBeInvalidated: true, - withFluxConvention: true, + type: NUMERIC_CAN_BE_INVALIDATED_TYPE, + valueGetter: (params) => { + return params.context.applyFluxConvention(params.data.p); + }, getQuickFilterText: excludeFromGlobalFilter, }, { @@ -109,9 +117,11 @@ export const GENERATOR_TAB_DEF = { field: 'q', numeric: true, fractionDigits: 1, - type: NUMERIC_TYPE, - canBeInvalidated: true, - withFluxConvention: true, + + type: NUMERIC_CAN_BE_INVALIDATED_TYPE, + valueGetter: (params) => { + return params.context.applyFluxConvention(params.data.q); + }, getQuickFilterText: excludeFromGlobalFilter, }, { diff --git a/src/components/spreadsheet/config/equipment/lcc-converter-station.ts b/src/components/spreadsheet/config/equipment/lcc-converter-station.ts index 40e05a61cf..2acf8e9d70 100644 --- a/src/components/spreadsheet/config/equipment/lcc-converter-station.ts +++ b/src/components/spreadsheet/config/equipment/lcc-converter-station.ts @@ -10,7 +10,13 @@ import type { SpreadsheetTabDefinition } from '../spreadsheet.type'; import { EQUIPMENT_TYPES } from '../../../utils/equipment-types'; import { excludeFromGlobalFilter, typeAndFetchers } from './common-config'; import { genericColumnOfProperties } from '../common/column-properties'; -import { BOOLEAN_TYPE, COUNTRY_TYPE, NUMERIC_TYPE, TEXT_TYPE } from 'components/spreadsheet/utils/constants'; +import { + BOOLEAN_TYPE, + COUNTRY_TYPE, + NUMERIC_CAN_BE_INVALIDATED_TYPE, + NUMERIC_TYPE, + TEXT_TYPE, +} from 'components/spreadsheet/utils/constants'; import { SortWay } from 'hooks/use-aggrid-sort'; export const LCC_CONVERTER_STATION_TAB_DEF = { @@ -55,18 +61,16 @@ export const LCC_CONVERTER_STATION_TAB_DEF = { id: 'activePower', field: 'p', numeric: true, - type: NUMERIC_TYPE, + type: NUMERIC_CAN_BE_INVALIDATED_TYPE, fractionDigits: 1, - canBeInvalidated: true, getQuickFilterText: excludeFromGlobalFilter, }, { id: 'ReactivePower', field: 'q', numeric: true, - type: NUMERIC_TYPE, + type: NUMERIC_CAN_BE_INVALIDATED_TYPE, fractionDigits: 1, - canBeInvalidated: true, getQuickFilterText: excludeFromGlobalFilter, }, { diff --git a/src/components/spreadsheet/config/equipment/line.ts b/src/components/spreadsheet/config/equipment/line.ts index d55afc06e5..bf318b5a21 100644 --- a/src/components/spreadsheet/config/equipment/line.ts +++ b/src/components/spreadsheet/config/equipment/line.ts @@ -10,7 +10,14 @@ import type { SpreadsheetTabDefinition } from '../spreadsheet.type'; import { EQUIPMENT_TYPES } from '../../../utils/equipment-types'; import CountryCellRenderer from '../../utils/country-cell-render'; import { excludeFromGlobalFilter, typeAndFetchers } from './common-config'; -import { BOOLEAN_TYPE, COUNTRY_TYPE, MEDIUM_COLUMN_WIDTH, NUMERIC_TYPE, TEXT_TYPE } from '../../utils/constants'; +import { + BOOLEAN_TYPE, + COUNTRY_TYPE, + MEDIUM_COLUMN_WIDTH, + NUMERIC_CAN_BE_INVALIDATED_TYPE, + NUMERIC_TYPE, + TEXT_TYPE, +} from '../../utils/constants'; import { unitToMicroUnit } from '../../../../utils/unit-converter'; import { genericColumnOfProperties } from '../common/column-properties'; import { SortWay } from 'hooks/use-aggrid-sort'; @@ -72,37 +79,35 @@ export const LINE_TAB_DEF = { id: 'ActivePowerSide1', field: 'p1', numeric: true, - type: NUMERIC_TYPE, + type: NUMERIC_CAN_BE_INVALIDATED_TYPE, fractionDigits: 1, - canBeInvalidated: true, - withFluxConvention: true, + valueGetter: (params) => { + return params.context.applyFluxConvention(params.data.p1); + }, getQuickFilterText: excludeFromGlobalFilter, }, { id: 'ActivePowerSide2', field: 'p2', numeric: true, - type: NUMERIC_TYPE, + type: NUMERIC_CAN_BE_INVALIDATED_TYPE, fractionDigits: 1, - canBeInvalidated: true, getQuickFilterText: excludeFromGlobalFilter, }, { id: 'ReactivePowerSide1', field: 'q1', numeric: true, - type: NUMERIC_TYPE, + type: NUMERIC_CAN_BE_INVALIDATED_TYPE, fractionDigits: 1, - canBeInvalidated: true, getQuickFilterText: excludeFromGlobalFilter, }, { id: 'ReactivePowerSide2', field: 'q2', numeric: true, - type: NUMERIC_TYPE, + type: NUMERIC_CAN_BE_INVALIDATED_TYPE, fractionDigits: 1, - canBeInvalidated: true, getQuickFilterText: excludeFromGlobalFilter, }, { diff --git a/src/components/spreadsheet/config/equipment/load.ts b/src/components/spreadsheet/config/equipment/load.ts index aa956a35a7..3c4a35a27b 100644 --- a/src/components/spreadsheet/config/equipment/load.ts +++ b/src/components/spreadsheet/config/equipment/load.ts @@ -9,7 +9,14 @@ import type { ReadonlyDeep } from 'type-fest'; import type { SpreadsheetTabDefinition } from '../spreadsheet.type'; import { EQUIPMENT_TYPES } from '../../../utils/equipment-types'; import { editableColumnConfig, excludeFromGlobalFilter, typeAndFetchers } from './common-config'; -import { BOOLEAN_TYPE, COUNTRY_TYPE, MEDIUM_COLUMN_WIDTH, NUMERIC_TYPE, TEXT_TYPE } from '../../utils/constants'; +import { + BOOLEAN_TYPE, + COUNTRY_TYPE, + MEDIUM_COLUMN_WIDTH, + NUMERIC_CAN_BE_INVALIDATED_TYPE, + NUMERIC_TYPE, + TEXT_TYPE, +} from '../../utils/constants'; import { LOAD_TYPES } from '../../../network/constants'; import { genericColumnOfPropertiesEditPopup } from '../common/column-properties'; import { enumCellEditorConfig, numericalCellEditorConfig } from '../common/cell-editors'; @@ -66,18 +73,16 @@ export const LOAD_TAB_DEF = { id: 'activePower', field: 'p', numeric: true, - type: NUMERIC_TYPE, + type: NUMERIC_CAN_BE_INVALIDATED_TYPE, fractionDigits: 1, - canBeInvalidated: true, getQuickFilterText: excludeFromGlobalFilter, }, { id: 'ReactivePower', field: 'q', numeric: true, - type: NUMERIC_TYPE, + type: NUMERIC_CAN_BE_INVALIDATED_TYPE, fractionDigits: 1, - canBeInvalidated: true, getQuickFilterText: excludeFromGlobalFilter, }, { diff --git a/src/components/spreadsheet/config/equipment/shunt-compensator.ts b/src/components/spreadsheet/config/equipment/shunt-compensator.ts index b0e5ac3395..69c09718dc 100644 --- a/src/components/spreadsheet/config/equipment/shunt-compensator.ts +++ b/src/components/spreadsheet/config/equipment/shunt-compensator.ts @@ -14,6 +14,7 @@ import { COUNTRY_TYPE, MEDIUM_COLUMN_WIDTH, MIN_COLUMN_WIDTH, + NUMERIC_CAN_BE_INVALIDATED_TYPE, NUMERIC_TYPE, TEXT_TYPE, } from '../../utils/constants'; @@ -64,9 +65,10 @@ export const SHUNT_COMPENSATOR_TAB_DEF = { field: 'q', numeric: true, fractionDigits: 1, - type: NUMERIC_TYPE, - canBeInvalidated: true, - withFluxConvention: true, + type: NUMERIC_CAN_BE_INVALIDATED_TYPE, + valueGetter: (params) => { + return params.context.applyFluxConvention(params.data.q); + }, getQuickFilterText: excludeFromGlobalFilter, }, { diff --git a/src/components/spreadsheet/config/equipment/static-var-compensator.ts b/src/components/spreadsheet/config/equipment/static-var-compensator.ts index 4be672b3ed..cce31253e1 100644 --- a/src/components/spreadsheet/config/equipment/static-var-compensator.ts +++ b/src/components/spreadsheet/config/equipment/static-var-compensator.ts @@ -9,7 +9,14 @@ import type { ReadonlyDeep } from 'type-fest'; import type { SpreadsheetTabDefinition } from '../spreadsheet.type'; import { EQUIPMENT_TYPES } from '../../../utils/equipment-types'; import { excludeFromGlobalFilter, typeAndFetchers } from './common-config'; -import { BOOLEAN_TYPE, COUNTRY_TYPE, MEDIUM_COLUMN_WIDTH, NUMERIC_TYPE, TEXT_TYPE } from '../../utils/constants'; +import { + BOOLEAN_TYPE, + COUNTRY_TYPE, + MEDIUM_COLUMN_WIDTH, + NUMERIC_CAN_BE_INVALIDATED_TYPE, + NUMERIC_TYPE, + TEXT_TYPE, +} from '../../utils/constants'; import { NOMINAL_V } from '../../../utils/field-constants'; import { genericColumnOfProperties } from '../common/column-properties'; import { SortWay } from 'hooks/use-aggrid-sort'; @@ -51,18 +58,16 @@ export const STATIC_VAR_COMPENSATOR_TAB_DEF = { id: 'activePower', field: 'p', numeric: true, - type: NUMERIC_TYPE, + type: NUMERIC_CAN_BE_INVALIDATED_TYPE, fractionDigits: 1, - canBeInvalidated: true, getQuickFilterText: excludeFromGlobalFilter, }, { id: 'ReactivePower', field: 'q', numeric: true, - type: NUMERIC_TYPE, + type: NUMERIC_CAN_BE_INVALIDATED_TYPE, fractionDigits: 1, - canBeInvalidated: true, getQuickFilterText: excludeFromGlobalFilter, }, { diff --git a/src/components/spreadsheet/config/equipment/three-windings-transformer.ts b/src/components/spreadsheet/config/equipment/three-windings-transformer.ts index 79a550d8d1..200b57a35b 100644 --- a/src/components/spreadsheet/config/equipment/three-windings-transformer.ts +++ b/src/components/spreadsheet/config/equipment/three-windings-transformer.ts @@ -9,7 +9,14 @@ import type { ReadonlyDeep } from 'type-fest'; import type { SpreadsheetTabDefinition } from '../spreadsheet.type'; import { EQUIPMENT_TYPES } from '../../../utils/equipment-types'; import { editableColumnConfig, excludeFromGlobalFilter, generateTapPositions, typeAndFetchers } from './common-config'; -import { BOOLEAN_TYPE, COUNTRY_TYPE, MEDIUM_COLUMN_WIDTH, NUMERIC_TYPE, TEXT_TYPE } from '../../utils/constants'; +import { + BOOLEAN_TYPE, + COUNTRY_TYPE, + MEDIUM_COLUMN_WIDTH, + NUMERIC_CAN_BE_INVALIDATED_TYPE, + NUMERIC_TYPE, + TEXT_TYPE, +} from '../../utils/constants'; import { genericColumnOfProperties } from '../common/column-properties'; import { standardSelectCellEditorConfig } from '../common/cell-editors'; import { SortWay } from 'hooks/use-aggrid-sort'; @@ -89,54 +96,48 @@ export const THREE_WINDINGS_TRANSFORMER_TAB_DEF = { id: 'ActivePowerT3WSide1', field: 'p1', numeric: true, - type: NUMERIC_TYPE, + type: NUMERIC_CAN_BE_INVALIDATED_TYPE, fractionDigits: 1, - canBeInvalidated: true, getQuickFilterText: excludeFromGlobalFilter, }, { id: 'ActivePowerT3WSide2', field: 'p2', numeric: true, - type: NUMERIC_TYPE, + type: NUMERIC_CAN_BE_INVALIDATED_TYPE, fractionDigits: 1, - canBeInvalidated: true, getQuickFilterText: excludeFromGlobalFilter, }, { id: 'ActivePowerT3WSide3', field: 'p3', numeric: true, - type: NUMERIC_TYPE, + type: NUMERIC_CAN_BE_INVALIDATED_TYPE, fractionDigits: 1, - canBeInvalidated: true, getQuickFilterText: excludeFromGlobalFilter, }, { id: 'ReactivePowerT3WSide1', field: 'q1', numeric: true, - type: NUMERIC_TYPE, + type: NUMERIC_CAN_BE_INVALIDATED_TYPE, fractionDigits: 1, - canBeInvalidated: true, getQuickFilterText: excludeFromGlobalFilter, }, { id: 'ReactivePowerT3WSide2', field: 'q2', numeric: true, - type: NUMERIC_TYPE, + type: NUMERIC_CAN_BE_INVALIDATED_TYPE, fractionDigits: 1, - canBeInvalidated: true, getQuickFilterText: excludeFromGlobalFilter, }, { id: 'ReactivePowerT3WSide3', field: 'q3', numeric: true, - type: NUMERIC_TYPE, + type: NUMERIC_CAN_BE_INVALIDATED_TYPE, fractionDigits: 1, - canBeInvalidated: true, getQuickFilterText: excludeFromGlobalFilter, }, { diff --git a/src/components/spreadsheet/config/equipment/tie-line.ts b/src/components/spreadsheet/config/equipment/tie-line.ts index 5a215117c2..de15b38423 100644 --- a/src/components/spreadsheet/config/equipment/tie-line.ts +++ b/src/components/spreadsheet/config/equipment/tie-line.ts @@ -9,7 +9,14 @@ import type { ReadonlyDeep } from 'type-fest'; import type { SpreadsheetTabDefinition } from '../spreadsheet.type'; import { EQUIPMENT_TYPES } from '../../../utils/equipment-types'; import { excludeFromGlobalFilter, typeAndFetchers } from './common-config'; -import { BOOLEAN_TYPE, COUNTRY_TYPE, MEDIUM_COLUMN_WIDTH, NUMERIC_TYPE, TEXT_TYPE } from '../../utils/constants'; +import { + BOOLEAN_TYPE, + COUNTRY_TYPE, + MEDIUM_COLUMN_WIDTH, + NUMERIC_CAN_BE_INVALIDATED_TYPE, + NUMERIC_TYPE, + TEXT_TYPE, +} from '../../utils/constants'; import { unitToMicroUnit } from '../../../../utils/unit-converter'; import { genericColumnOfPropertiesReadonly } from '../common/column-properties'; import { SortWay } from 'hooks/use-aggrid-sort'; @@ -70,36 +77,32 @@ export const TIE_LINE_TAB_DEF = { id: 'ActivePowerSide1', field: 'p1', numeric: true, - type: NUMERIC_TYPE, + type: NUMERIC_CAN_BE_INVALIDATED_TYPE, fractionDigits: 1, - canBeInvalidated: true, getQuickFilterText: excludeFromGlobalFilter, }, { id: 'ActivePowerSide2', field: 'p2', numeric: true, - type: NUMERIC_TYPE, + type: NUMERIC_CAN_BE_INVALIDATED_TYPE, fractionDigits: 1, - canBeInvalidated: true, getQuickFilterText: excludeFromGlobalFilter, }, { id: 'ReactivePowerSide1', field: 'q1', numeric: true, - type: NUMERIC_TYPE, + type: NUMERIC_CAN_BE_INVALIDATED_TYPE, fractionDigits: 1, - canBeInvalidated: true, getQuickFilterText: excludeFromGlobalFilter, }, { id: 'ReactivePowerSide2', field: 'q2', numeric: true, - type: NUMERIC_TYPE, + type: NUMERIC_CAN_BE_INVALIDATED_TYPE, fractionDigits: 1, - canBeInvalidated: true, getQuickFilterText: excludeFromGlobalFilter, }, { diff --git a/src/components/spreadsheet/config/equipment/two-windings-transformer.ts b/src/components/spreadsheet/config/equipment/two-windings-transformer.ts index 616fb86568..67f5bb3f4f 100644 --- a/src/components/spreadsheet/config/equipment/two-windings-transformer.ts +++ b/src/components/spreadsheet/config/equipment/two-windings-transformer.ts @@ -20,7 +20,14 @@ import { isEditable, typeAndFetchers, } from './common-config'; -import { BOOLEAN_TYPE, COUNTRY_TYPE, MEDIUM_COLUMN_WIDTH, NUMERIC_TYPE, TEXT_TYPE } from '../../utils/constants'; +import { + BOOLEAN_TYPE, + COUNTRY_TYPE, + MEDIUM_COLUMN_WIDTH, + NUMERIC_CAN_BE_INVALIDATED_TYPE, + NUMERIC_TYPE, + TEXT_TYPE, +} from '../../utils/constants'; import { PHASE_REGULATION_MODES, RATIO_REGULATION_MODES, REGULATION_TYPES, SIDE } from '../../../network/constants'; import { computeHighTapPosition, getTapChangerRegulationTerminalValue } from '../../../utils/utils'; import { unitToMicroUnit } from '../../../../utils/unit-converter'; @@ -165,36 +172,32 @@ export const TWO_WINDINGS_TRANSFORMER_TAB_DEF = { id: 'ActivePowerSide1', field: 'p1', numeric: true, - type: NUMERIC_TYPE, + type: NUMERIC_CAN_BE_INVALIDATED_TYPE, fractionDigits: 1, - canBeInvalidated: true, getQuickFilterText: excludeFromGlobalFilter, }, { id: 'ActivePowerSide2', field: 'p2', numeric: true, - type: NUMERIC_TYPE, + type: NUMERIC_CAN_BE_INVALIDATED_TYPE, fractionDigits: 1, - canBeInvalidated: true, getQuickFilterText: excludeFromGlobalFilter, }, { id: 'ReactivePowerSide1', field: 'q1', numeric: true, - type: NUMERIC_TYPE, + type: NUMERIC_CAN_BE_INVALIDATED_TYPE, fractionDigits: 1, - canBeInvalidated: true, getQuickFilterText: excludeFromGlobalFilter, }, { id: 'ReactivePowerSide2', field: 'q2', numeric: true, - type: NUMERIC_TYPE, + type: NUMERIC_CAN_BE_INVALIDATED_TYPE, fractionDigits: 1, - canBeInvalidated: true, getQuickFilterText: excludeFromGlobalFilter, }, { @@ -617,16 +620,12 @@ export const TWO_WINDINGS_TRANSFORMER_TAB_DEF = { { id: 'connected1', field: 'terminal1Connected', - boolean: true, - cellRenderer: BooleanCellRenderer, type: BOOLEAN_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, { id: 'connected2', field: 'terminal2Connected', - boolean: true, - //cellRenderer: BooleanCellRenderer, type: BOOLEAN_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, diff --git a/src/components/spreadsheet/config/equipment/vsc-converter-station.ts b/src/components/spreadsheet/config/equipment/vsc-converter-station.ts index 8205edf015..a69f4ac816 100644 --- a/src/components/spreadsheet/config/equipment/vsc-converter-station.ts +++ b/src/components/spreadsheet/config/equipment/vsc-converter-station.ts @@ -9,7 +9,14 @@ import type { ReadonlyDeep } from 'type-fest'; import type { SpreadsheetTabDefinition } from '../spreadsheet.type'; import { EQUIPMENT_TYPES } from '../../../utils/equipment-types'; import { excludeFromGlobalFilter, typeAndFetchers } from './common-config'; -import { BOOLEAN_TYPE, COUNTRY_TYPE, MEDIUM_COLUMN_WIDTH, NUMERIC_TYPE, TEXT_TYPE } from '../../utils/constants'; +import { + BOOLEAN_TYPE, + COUNTRY_TYPE, + MEDIUM_COLUMN_WIDTH, + NUMERIC_CAN_BE_INVALIDATED_TYPE, + NUMERIC_TYPE, + TEXT_TYPE, +} from '../../utils/constants'; import { genericColumnOfProperties } from '../common/column-properties'; import { SortWay } from 'hooks/use-aggrid-sort'; @@ -56,18 +63,16 @@ export const VSC_CONVERTER_STATION_TAB_DEF = { id: 'activePower', field: 'p', numeric: true, - type: NUMERIC_TYPE, + type: NUMERIC_CAN_BE_INVALIDATED_TYPE, fractionDigits: 1, - canBeInvalidated: true, getQuickFilterText: excludeFromGlobalFilter, }, { id: 'ReactivePower', field: 'q', numeric: true, - type: NUMERIC_TYPE, + type: NUMERIC_CAN_BE_INVALIDATED_TYPE, fractionDigits: 1, - canBeInvalidated: true, getQuickFilterText: excludeFromGlobalFilter, }, { diff --git a/src/components/spreadsheet/equipment-table.tsx b/src/components/spreadsheet/equipment-table.tsx index bf4e3a8230..2b5533e89d 100644 --- a/src/components/spreadsheet/equipment-table.tsx +++ b/src/components/spreadsheet/equipment-table.tsx @@ -54,6 +54,7 @@ interface EquipmentTableProps { shouldHidePinnedHeaderRightBorder: boolean; columnTypes: { [key: string]: ColDef }; applyFluxConvention: (value: number) => number; + loadFlowStatus: string; } const loadingOverlayComponent = (props: { loadingMessage: string }) => <>{props.loadingMessage}; @@ -74,6 +75,7 @@ export const EquipmentTable: FunctionComponent = ({ shouldHidePinnedHeaderRightBorder, columnTypes, applyFluxConvention, + loadFlowStatus, }) => { const theme = useTheme(); const intl = useIntl(); @@ -104,8 +106,9 @@ export const EquipmentTable: FunctionComponent = ({ intl: intl, translateCountryCode: translate, applyFluxConvention: applyFluxConvention, + loadFlowStatus: loadFlowStatus, }), - [applyFluxConvention, currentNode, intl, studyUuid, theme, topPinnedData, translate] + [applyFluxConvention, currentNode, intl, loadFlowStatus, studyUuid, theme, topPinnedData, translate] ); const getRowHeight = useCallback( diff --git a/src/components/spreadsheet/table-wrapper.tsx b/src/components/spreadsheet/table-wrapper.tsx index 0abd525f8f..28ba8d3fe4 100644 --- a/src/components/spreadsheet/table-wrapper.tsx +++ b/src/components/spreadsheet/table-wrapper.tsx @@ -300,77 +300,19 @@ const TableWrapper: FunctionComponent = ({ const columnExtended = { ...column }; columnExtended.headerName = intl.formatMessage({ id: columnExtended.id }); - if (columnExtended.numeric) { - //numeric columns need the loadflow status in order to apply a specific css class in case the loadflow is invalid to highlight the value has not been computed - const isValueInvalid = loadFlowStatus !== RunningStatus.SUCCEED && columnExtended.canBeInvalidated; - - columnExtended.cellRendererParams = { - isValueInvalid: isValueInvalid, - }; - if (columnExtended.withFluxConvention) { - // We enrich "flux convention" properties here (and not in config-tables) because we use a hook - // to get the convention, which requires a component context. - columnExtended.cellRendererParams.applyFluxConvention = applyFluxConvention; - columnExtended.comparator = (valueA: number, valueB: number) => { - const normedValueA = valueA !== undefined ? applyFluxConvention(valueA) : undefined; - const normedValueB = valueB !== undefined ? applyFluxConvention(valueB) : undefined; - if (normedValueA !== undefined && normedValueB !== undefined) { - return normedValueA - normedValueB; - } else if (normedValueA === undefined && normedValueB === undefined) { - return 0; - } else if (normedValueA === undefined) { - return -1; - } else if (normedValueB === undefined) { - return 1; - } - return 0; - }; - } - } - - if (columnExtended.cellRenderer == null) { - columnExtended.cellRenderer = DefaultCellRenderer; - } - columnExtended.width = columnExtended.columnWidth || MIN_COLUMN_WIDTH; //if it is not the first render the column might already have a pinned value so we need to handle the case where it needs to be reseted to undefined //we reuse and mutate the column objects so we need to clear to undefined columnExtended.pinned = lockedColumnsNames.has(columnExtended.id) ? 'left' : undefined; - //Set sorting comparator for enum columns so it sorts the translated values instead of the enum values - if (columnExtended?.isEnum) { - columnExtended.comparator = (valueA: string, valueB: string) => { - const getTranslatedOrOriginalValue = (value: string) => { - if (value === undefined || value === null) { - return ''; - } - if (columnExtended.isCountry) { - return translate(value); - } else if (columnExtended.getEnumLabel) { - const labelId = columnExtended.getEnumLabel(value); - return intl.formatMessage({ - id: labelId || value, - defaultMessage: value, - }); - } - return value; - }; - - const translatedValueA = getTranslatedOrOriginalValue(valueA); - const translatedValueB = getTranslatedOrOriginalValue(valueB); - - return translatedValueA.localeCompare(translatedValueB); - }; - } - return makeSpreadsheetAgGridColumn({ headerName: columnExtended.headerName, field: columnExtended.field, ...columnExtended, }); }, - [intl, lockedColumnsNames, loadFlowStatus, applyFluxConvention, translate] + [intl, lockedColumnsNames] ); useEffect(() => { @@ -1218,6 +1160,7 @@ const TableWrapper: FunctionComponent = ({ shouldHidePinnedHeaderRightBorder={isLockedColumnNamesEmpty} columnTypes={defaultColumnType} applyFluxConvention={applyFluxConvention} + loadFlowStatus={loadFlowStatus} /> )} diff --git a/src/components/spreadsheet/utils/cell-renderers.tsx b/src/components/spreadsheet/utils/cell-renderers.tsx index 39e1df6a77..57c051f88c 100644 --- a/src/components/spreadsheet/utils/cell-renderers.tsx +++ b/src/components/spreadsheet/utils/cell-renderers.tsx @@ -142,6 +142,7 @@ export const convertDuration = (duration: number) => { export const DefaultCellRenderer = (props: any) => { const cellValue = formatCell(props); + return ( { title={cellValue.tooltip ? cellValue.tooltip : cellValue.value} > diff --git a/src/components/spreadsheet/utils/constants.ts b/src/components/spreadsheet/utils/constants.ts index 0daa3ffe33..23e8de1bc2 100644 --- a/src/components/spreadsheet/utils/constants.ts +++ b/src/components/spreadsheet/utils/constants.ts @@ -17,6 +17,7 @@ export const REORDERED_COLUMNS_PARAMETER_PREFIX_IN_DATABASE = 'reorderedColumns. export const TEXT_TYPE = 'textType'; export const NUMERIC_TYPE = 'numericType'; +export const NUMERIC_CAN_BE_INVALIDATED_TYPE = 'numericCanBeInvalidatedType'; export const ENUM_TYPE = 'enumType'; export const BOOLEAN_TYPE = 'booleanType'; export const COUNTRY_TYPE = 'countryType'; From a3d58eba8e6293eac299ead421adeadc86f2f48b Mon Sep 17 00:00:00 2001 From: TOURI ANIS Date: Thu, 19 Dec 2024 18:04:54 +0100 Subject: [PATCH 09/10] refactor columnTypes --- .../config/column-type-filter-config.ts | 244 ++++++++++-------- .../config/common/column-properties.tsx | 19 +- .../spreadsheet/config/equipment/battery.ts | 37 +-- .../spreadsheet/config/equipment/bus.ts | 14 +- .../config/equipment/dangling-line.ts | 22 +- .../spreadsheet/config/equipment/generator.ts | 81 ++---- .../spreadsheet/config/equipment/hvdc-line.ts | 30 +-- .../config/equipment/lcc-converter-station.ts | 23 +- .../spreadsheet/config/equipment/line.ts | 60 ++--- .../spreadsheet/config/equipment/load.ts | 27 +- .../config/equipment/shunt-compensator.ts | 40 +-- .../equipment/static-var-compensator.ts | 23 +- .../equipment/three-windings-transformer.ts | 69 ++--- .../spreadsheet/config/equipment/tie-line.ts | 56 ++-- .../equipment/two-windings-transformer.ts | 89 +++---- .../config/equipment/voltage-level.ts | 24 +- .../config/equipment/vsc-converter-station.ts | 27 +- .../spreadsheet/utils/cell-renderers.tsx | 39 ++- src/components/spreadsheet/utils/constants.ts | 20 ++ 19 files changed, 387 insertions(+), 557 deletions(-) diff --git a/src/components/spreadsheet/config/column-type-filter-config.ts b/src/components/spreadsheet/config/column-type-filter-config.ts index 7bc180e06b..ce6ca3476b 100644 --- a/src/components/spreadsheet/config/column-type-filter-config.ts +++ b/src/components/spreadsheet/config/column-type-filter-config.ts @@ -5,139 +5,179 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +import { ICellRendererParams } from 'ag-grid-community'; import { FILTER_NUMBER_COMPARATORS, FILTER_TEXT_COMPARATORS } from 'components/custom-aggrid/custom-aggrid-header.type'; -import { getEnumLabelById } from 'components/utils/utils'; +import { BooleanCellRenderer, DefaultSpreadsheetCellRenderer, PropertiesCellRenderer } from '../utils/cell-renderers'; import { EnumOption } from 'components/utils/utils-type'; -import CountryCellRenderer from '../utils/country-cell-render'; -import { BooleanCellRenderer, DefaultCellRenderer } from '../utils/cell-renderers'; -import EnumCellRenderer from '../utils/enum-cell-renderer'; +import { computeHighTapPosition, getEnumLabelById } from 'components/utils/utils'; import { Writable } from 'type-fest'; import RunningStatus from 'components/utils/running-status'; +import { + ENERGY_SOURCES, + LOAD_TYPES, + PHASE_REGULATION_MODES, + RATIO_REGULATION_MODES, + REGULATION_TYPES, + SHUNT_COMPENSATOR_TYPES, + SIDE, +} from 'components/network/constants'; +import { unitToKiloUnit, unitToMicroUnit } from 'utils/unit-converter'; -const contains = (target: string, lookingFor: string): boolean => { - if (target && lookingFor) { - return target?.toLowerCase().indexOf(lookingFor.toLowerCase()) >= 0; +const TEXT_FILTER_PARAMS = { + caseSensitive: false, + maxNumConditions: 1, + filterOptions: [FILTER_TEXT_COMPARATORS.STARTS_WITH, FILTER_TEXT_COMPARATORS.CONTAINS], + debounceMs: 200, +}; + +const NUMERIC_FILTER_PARAMS = { + maxNumConditions: 1, + filterOptions: Object.values(FILTER_NUMBER_COMPARATORS), + debounceMs: 200, +}; + +const formatCellValue = (value: any, decimalPlaces: number = 1) => { + if (value != null) { + return parseFloat(value.toFixed(decimalPlaces)); + } + + return null; +}; + +const propertiesGetter = (params: ICellRendererParams) => { + const properties = params?.data?.properties; + if (properties && Object.keys(properties).length) { + return Object.keys(properties) + .map((property) => `${property} : ${properties[property]}`) + .join(' | '); + } else { + return null; } - return false; }; -export const getEnumConfig = (enumOptions: Readonly) => { +const createTextColumnType = (cellRenderer: any, valueGetter?: (params: ICellRendererParams) => any) => ({ + filter: 'agTextColumnFilter', + filterParams: TEXT_FILTER_PARAMS, + cellRenderer, + valueGetter, + sortable: true, + resizable: true, +}); + +const createNumericColumnType = (valueGetter: (params: ICellRendererParams) => any) => ({ + filter: 'agNumberColumnFilter', + filterParams: NUMERIC_FILTER_PARAMS, + cellRenderer: DefaultSpreadsheetCellRenderer, + valueGetter, + sortable: true, + resizable: true, +}); + +const createEnumConfig = (enumOptions: Readonly) => { return { filter: 'agTextColumnFilter', filterParams: { caseSensitive: false, maxNumConditions: 1, filterOptions: [FILTER_TEXT_COMPARATORS.CONTAINS], - textMatcher: ({ value, filterText, context }: any): boolean => { - if (value) { - const label = enumOptions - ? getEnumLabelById(enumOptions as EnumOption[], value.toUpperCase()) - : value; - const displayedValue = label ? context.intl.formatMessage({ id: label }) : value; - return contains(displayedValue, filterText || ''); - } - return false; - }, debounceMs: 200, }, - cellRenderer: EnumCellRenderer, - cellRendererParams: { - enumOptions: enumOptions as Writable, - // @ts-expect-error TODO TS1360: Property value is missing in type - } satisfies EnumCellRendererProps, - getEnumLabel: (value: string) => getEnumLabelById(enumOptions as Writable, value), + + valueGetter: (params: any) => { + const value = params.data[params?.colDef?.field!]; + return value + ? params.context.intl.formatMessage({ + id: getEnumLabelById(enumOptions as Writable, value), + }) + : value; + }, }; }; -const textType = { - filter: 'agTextColumnFilter', - filterParams: { - caseSensitive: false, - maxNumConditions: 1, - filterOptions: [FILTER_TEXT_COMPARATORS.STARTS_WITH, FILTER_TEXT_COMPARATORS.CONTAINS], - }, - cellRenderer: DefaultCellRenderer, - sortable: true, - resizable: true, -}; +const textType = createTextColumnType(DefaultSpreadsheetCellRenderer); +const propertyType = createTextColumnType(PropertiesCellRenderer, propertiesGetter); -const numericType = { - filter: 'agNumberColumnFilter', - filterParams: { - maxNumConditions: 1, - filterOptions: Object.values(FILTER_NUMBER_COMPARATORS), - debounceMs: 200, - }, - cellRenderer: DefaultCellRenderer, - sortable: true, - resizable: true, -}; +const getNumericType = (fractionDigits?: number) => + createNumericColumnType((params) => { + const value = params.data[params?.colDef?.field!]; + return fractionDigits ? formatCellValue(value, fractionDigits) : value; + }); -const numericCanBeInvalidatedType = { - filter: 'agNumberColumnFilter', - filterParams: { - maxNumConditions: 1, - filterOptions: Object.values(FILTER_NUMBER_COMPARATORS), - debounceMs: 200, - }, - cellRendererSelector: ({ context }: { context: any }) => { - return { - component: DefaultCellRenderer, - params: { - isValueInvalid: context.loadFlowStatus !== RunningStatus.SUCCEED, - }, - }; - }, +const numericType = getNumericType(); +const numeric0FractionDigitsType = getNumericType(0); +const numeric1FractionDigitsType = getNumericType(1); +const numeric2FractionDigitsType = getNumericType(2); +const numeric5FractionDigitsType = getNumericType(5); - sortable: true, - resizable: true, -}; +const createNumericUnitConversionType = (conversionFunction: (value: any) => any) => + createNumericColumnType((params) => conversionFunction(params.data[params?.colDef?.field!])); -const booleanType = { - filter: 'agTextColumnFilter', - filterParams: { - caseSensitive: false, - maxNumConditions: 1, - filterOptions: [FILTER_TEXT_COMPARATORS.EQUALS], - textMatcher: ({ value, filterText, context }: any): boolean => { - if (value) { - const displayedValue = context.intl.formatMessage({ id: value }) ?? value; - return contains(displayedValue, filterText || ''); - } - return false; - }, - debounceMs: 200, - }, - cellRenderer: BooleanCellRenderer, - sortable: true, - resizable: true, -}; +const numericUnitToMicroUnitType = createNumericUnitConversionType(unitToMicroUnit); +const numericUnitToKiloUnitType = createNumericUnitConversionType(unitToKiloUnit); -const countryType = { - filter: 'agTextColumnFilter', - filterParams: { - caseSensitive: false, - maxNumConditions: 1, - filterOptions: [FILTER_TEXT_COMPARATORS.CONTAINS], - textMatcher: ({ value, filterText, context }: { value: string; filterText: string; context: any }) => { - if (value) { - const countryCode = value?.toUpperCase(); - const countryName = context?.translateCountryCode(countryCode); - return contains(countryName, filterText || '') || contains(value, filterText); - } - return false; +const numericHighTapPositionType = createNumericColumnType((params) => + computeHighTapPosition(params.data[params?.colDef?.field!]?.steps) +); + +const getNumericApplyFluxConventionType = (fractionDigits?: number) => + createNumericColumnType((params) => { + const value = params.context.applyFluxConvention(params.data[params?.colDef?.field!]); + return formatCellValue(value, fractionDigits); + }); + +const numericApplyFluxConventionType = getNumericApplyFluxConventionType(0); +const numericApplyFluxConvention1FractionDigitsType = getNumericApplyFluxConventionType(1); +const numericApplyFluxConvention2FractionDigitsType = getNumericApplyFluxConventionType(2); +const numericApplyFluxConvention5FractionDigitsType = getNumericApplyFluxConventionType(5); + +const numericCanBeInvalidatedType = { + cellRendererSelector: (params: ICellRendererParams) => ({ + component: DefaultSpreadsheetCellRenderer, + params: { + isValueInvalid: params.context.loadFlowStatus !== RunningStatus.SUCCEED, }, - debounceMs: 200, - }, - cellRenderer: CountryCellRenderer, - sortable: true, - resizable: true, + }), }; +const booleanType = createTextColumnType(BooleanCellRenderer); + +const countryType = createTextColumnType(DefaultSpreadsheetCellRenderer, (params: ICellRendererParams) => { + if (params.context?.translateCountryCode && params?.colDef?.field) { + return params.context.translateCountryCode(params.data[params.colDef.field]); + } +}); + +const energySourceEnumType = createEnumConfig(ENERGY_SOURCES); +const regulationEnumType = createEnumConfig(Object.values(REGULATION_TYPES)); +const loadEnumType = createEnumConfig([...LOAD_TYPES, { id: 'UNDEFINED', label: 'Undefined' }]); +const shuntCompensatorEnumType = createEnumConfig(Object.values(SHUNT_COMPENSATOR_TYPES)); +const ratioRegulationModesEnumType = createEnumConfig(Object.values(RATIO_REGULATION_MODES)); +const sideEnumType = createEnumConfig(Object.values(SIDE)); +const phaseRegulatingModeEnumType = createEnumConfig(Object.values(PHASE_REGULATION_MODES)); + export const defaultColumnType = { textType, + propertyType, numericType, + numeric0FractionDigitsType, + numeric1FractionDigitsType, + numeric2FractionDigitsType, + numeric5FractionDigitsType, + numericUnitToMicroUnitType, + numericUnitToKiloUnitType, + numericHighTapPositionType, numericCanBeInvalidatedType, + numericApplyFluxConventionType, + numericApplyFluxConvention1FractionDigitsType, + numericApplyFluxConvention2FractionDigitsType, + numericApplyFluxConvention5FractionDigitsType, booleanType, countryType, + energySourceEnumType, + regulationEnumType, + loadEnumType, + shuntCompensatorEnumType, + ratioRegulationModesEnumType, + sideEnumType, + phaseRegulatingModeEnumType, }; diff --git a/src/components/spreadsheet/config/common/column-properties.tsx b/src/components/spreadsheet/config/common/column-properties.tsx index 47238bc663..d52e48c84c 100644 --- a/src/components/spreadsheet/config/common/column-properties.tsx +++ b/src/components/spreadsheet/config/common/column-properties.tsx @@ -5,32 +5,17 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { PropertiesCellRenderer } from '../../utils/cell-renderers'; import { SitePropertiesEditor } from '../../utils/equipement-table-popup-editors'; -import type { ValueGetterFunc, ValueSetterParams } from 'ag-grid-community'; +import type { ValueSetterParams } from 'ag-grid-community'; import { editableColumnConfig, excludeFromGlobalFilter } from '../equipment/common-config'; -import { TEXT_TYPE } from 'components/spreadsheet/utils/constants'; - -const propertiesGetter: ValueGetterFunc = (params) => { - const properties = params?.data?.properties; - if (properties && Object.keys(properties).length) { - return Object.keys(properties) - .map((property) => `${property} : ${properties[property]}`) - .join(' | '); - } else { - return null; - } -}; //TODO only used in tie-line config, is "valueSetter" forgotten? export const genericColumnOfPropertiesReadonly = { id: 'Properties', field: 'properties', - valueGetter: propertiesGetter, - cellRenderer: PropertiesCellRenderer, minWidth: 300, getQuickFilterText: excludeFromGlobalFilter, - type: TEXT_TYPE, + type: 'propertyType', }; export const genericColumnOfProperties = { diff --git a/src/components/spreadsheet/config/equipment/battery.ts b/src/components/spreadsheet/config/equipment/battery.ts index 5cad804404..3e0f7f9321 100644 --- a/src/components/spreadsheet/config/equipment/battery.ts +++ b/src/components/spreadsheet/config/equipment/battery.ts @@ -14,6 +14,7 @@ import { booleanCellEditorConfig, numericalCellEditorConfig } from '../common/ce import { BOOLEAN_TYPE, COUNTRY_TYPE, + NUMERIC_1_FRACTION_DIGITS_TYPE, NUMERIC_CAN_BE_INVALIDATED_TYPE, NUMERIC_TYPE, TEXT_TYPE, @@ -51,30 +52,18 @@ export const BATTERY_TAB_DEF = { { id: 'NominalV', field: 'nominalVoltage', - numeric: true, type: NUMERIC_TYPE, - fractionDigits: 0, }, { id: 'activePower', field: 'p', - numeric: true, - fractionDigits: 1, - type: NUMERIC_CAN_BE_INVALIDATED_TYPE, - valueGetter: (params) => { - return params.context.applyFluxConvention(params.data.p); - }, + type: [NUMERIC_1_FRACTION_DIGITS_TYPE, NUMERIC_CAN_BE_INVALIDATED_TYPE], getQuickFilterText: excludeFromGlobalFilter, }, { id: 'ReactivePower', field: 'q', - numeric: true, - fractionDigits: 1, - type: NUMERIC_CAN_BE_INVALIDATED_TYPE, - valueGetter: (params) => { - return params.context.applyFluxConvention(params.data.q); - }, + type: [NUMERIC_1_FRACTION_DIGITS_TYPE, NUMERIC_CAN_BE_INVALIDATED_TYPE], getQuickFilterText: excludeFromGlobalFilter, }, { @@ -95,9 +84,7 @@ export const BATTERY_TAB_DEF = { { id: 'DroopColumnName', field: 'activePowerControl.droop', - numeric: true, - type: NUMERIC_TYPE, - fractionDigits: 1, + type: NUMERIC_1_FRACTION_DIGITS_TYPE, ...editableColumnConfig, ...numericalCellEditorConfig((params) => params.data.activePowerControl?.droop), valueGetter: (params) => params.data?.activePowerControl?.droop, @@ -119,9 +106,7 @@ export const BATTERY_TAB_DEF = { { id: 'minP', field: 'minP', - numeric: true, - type: NUMERIC_TYPE, - fractionDigits: 1, + type: NUMERIC_1_FRACTION_DIGITS_TYPE, ...editableColumnConfig, ...numericalCellEditorConfig((params) => params.data.minP), crossValidation: { @@ -132,9 +117,7 @@ export const BATTERY_TAB_DEF = { { id: 'maxP', field: 'maxP', - numeric: true, - type: NUMERIC_TYPE, - fractionDigits: 1, + type: NUMERIC_1_FRACTION_DIGITS_TYPE, ...editableColumnConfig, ...numericalCellEditorConfig((params) => params.data.maxP), crossValidation: { @@ -145,9 +128,7 @@ export const BATTERY_TAB_DEF = { { id: 'activePowerSetpoint', field: 'targetP', - numeric: true, - type: NUMERIC_TYPE, - fractionDigits: 1, + type: NUMERIC_1_FRACTION_DIGITS_TYPE, ...editableColumnConfig, ...numericalCellEditorConfig((params) => params.data.targetP), crossValidation: { @@ -160,9 +141,7 @@ export const BATTERY_TAB_DEF = { { id: 'reactivePowerSetpoint', field: 'targetQ', - numeric: true, - type: NUMERIC_TYPE, - fractionDigits: 1, + type: NUMERIC_1_FRACTION_DIGITS_TYPE, ...editableColumnConfig, ...numericalCellEditorConfig((params) => params.data.targetQ), getQuickFilterText: excludeFromGlobalFilter, diff --git a/src/components/spreadsheet/config/equipment/bus.ts b/src/components/spreadsheet/config/equipment/bus.ts index bc5d17dcb4..195a79566e 100644 --- a/src/components/spreadsheet/config/equipment/bus.ts +++ b/src/components/spreadsheet/config/equipment/bus.ts @@ -12,6 +12,8 @@ import { typeAndFetchers } from './common-config'; import { genericColumnOfProperties } from '../common/column-properties'; import { COUNTRY_TYPE, + NUMERIC_0_FRACTION_DIGITS_TYPE, + NUMERIC_1_FRACTION_DIGITS_TYPE, NUMERIC_CAN_BE_INVALIDATED_TYPE, NUMERIC_TYPE, TEXT_TYPE, @@ -32,16 +34,12 @@ export const BUS_TAB_DEF = { { id: 'Magnitude', field: 'v', - numeric: true, - fractionDigits: 1, - type: NUMERIC_CAN_BE_INVALIDATED_TYPE, + type: [NUMERIC_1_FRACTION_DIGITS_TYPE, NUMERIC_CAN_BE_INVALIDATED_TYPE], }, { id: 'Angle', field: 'angle', - numeric: true, - fractionDigits: 1, - type: NUMERIC_CAN_BE_INVALIDATED_TYPE, + type: [NUMERIC_1_FRACTION_DIGITS_TYPE, NUMERIC_CAN_BE_INVALIDATED_TYPE], }, { id: 'ConnectedComponent', @@ -66,9 +64,7 @@ export const BUS_TAB_DEF = { { id: 'NominalV', field: 'nominalVoltage', - numeric: true, - fractionDigits: 0, - type: NUMERIC_TYPE, + type: NUMERIC_0_FRACTION_DIGITS_TYPE, }, genericColumnOfProperties, ], diff --git a/src/components/spreadsheet/config/equipment/dangling-line.ts b/src/components/spreadsheet/config/equipment/dangling-line.ts index afaee6ea88..78fade11ad 100644 --- a/src/components/spreadsheet/config/equipment/dangling-line.ts +++ b/src/components/spreadsheet/config/equipment/dangling-line.ts @@ -14,8 +14,9 @@ import { genericColumnOfProperties } from '../common/column-properties'; import { BOOLEAN_TYPE, COUNTRY_TYPE, + NUMERIC_0_FRACTION_DIGITS_TYPE, + NUMERIC_1_FRACTION_DIGITS_TYPE, NUMERIC_CAN_BE_INVALIDATED_TYPE, - NUMERIC_TYPE, TEXT_TYPE, } from 'components/spreadsheet/utils/constants'; import { SortWay } from 'hooks/use-aggrid-sort'; @@ -49,9 +50,7 @@ export const DANGLING_LINE_TAB_DEF = { { id: 'NominalV', field: NOMINAL_V, - numeric: true, - type: NUMERIC_TYPE, - fractionDigits: 0, + type: NUMERIC_0_FRACTION_DIGITS_TYPE, }, { id: 'PairingKey', @@ -62,33 +61,26 @@ export const DANGLING_LINE_TAB_DEF = { { id: 'activePower', field: 'p', - numeric: true, - type: NUMERIC_CAN_BE_INVALIDATED_TYPE, - fractionDigits: 1, + type: [NUMERIC_1_FRACTION_DIGITS_TYPE, NUMERIC_CAN_BE_INVALIDATED_TYPE], getQuickFilterText: excludeFromGlobalFilter, }, { id: 'ReactivePower', field: 'q', numeric: true, - type: NUMERIC_CAN_BE_INVALIDATED_TYPE, - fractionDigits: 1, + type: [NUMERIC_1_FRACTION_DIGITS_TYPE, NUMERIC_CAN_BE_INVALIDATED_TYPE], getQuickFilterText: excludeFromGlobalFilter, }, { id: 'p0', field: 'p0', - numeric: true, - type: NUMERIC_TYPE, - fractionDigits: 1, + type: [NUMERIC_1_FRACTION_DIGITS_TYPE, NUMERIC_CAN_BE_INVALIDATED_TYPE], getQuickFilterText: excludeFromGlobalFilter, }, { id: 'q0', field: 'q0', - numeric: true, - type: NUMERIC_TYPE, - fractionDigits: 1, + type: NUMERIC_1_FRACTION_DIGITS_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, { diff --git a/src/components/spreadsheet/config/equipment/generator.ts b/src/components/spreadsheet/config/equipment/generator.ts index 5cfcbe2571..1e6024399b 100644 --- a/src/components/spreadsheet/config/equipment/generator.ts +++ b/src/components/spreadsheet/config/equipment/generator.ts @@ -17,10 +17,14 @@ import { editableCellStyle, editableColumnConfig, excludeFromGlobalFilter, typeA import { BOOLEAN_TYPE, COUNTRY_TYPE, + ENERGY_SOURCE_ENUM_TYPE, MEDIUM_COLUMN_WIDTH, + NUMERIC_APPLY_FLUX_CONVENTION_1_FRACTION_DIGITS_TYPE, NUMERIC_CAN_BE_INVALIDATED_TYPE, - NUMERIC_TYPE, + REGULATION_ENUM_TYPE, TEXT_TYPE, + NUMERIC_1_FRACTION_DIGITS_TYPE, + NUMERIC_2_FRACTION_DIGITS_TYPE, } from '../../utils/constants'; import { ENERGY_SOURCES, REGULATION_TYPES } from '../../../network/constants'; import { genericColumnOfPropertiesEditPopup } from '../common/column-properties'; @@ -31,7 +35,6 @@ import { numericalCellEditorConfig, } from '../common/cell-editors'; import { SortWay } from 'hooks/use-aggrid-sort'; -import { getEnumConfig } from '../column-type-filter-config'; const RegulatingTerminalCellGetter: ValueGetterFunc = (params) => { const { regulatingTerminalConnectableId, regulatingTerminalVlId, regulatingTerminalConnectableType } = @@ -90,38 +93,25 @@ export const GENERATOR_TAB_DEF = { { id: 'NominalV', field: 'nominalVoltage', - numeric: true, - type: NUMERIC_TYPE, - fractionDigits: 0, + type: NUMERIC_1_FRACTION_DIGITS_TYPE, }, { id: 'energySource', field: 'energySource', - ...getEnumConfig(ENERGY_SOURCES), + type: ENERGY_SOURCE_ENUM_TYPE, ...editableColumnConfig, ...enumCellEditorConfig((params) => params.data?.energySource, ENERGY_SOURCES), }, { id: 'activePower', field: 'p', - numeric: true, - fractionDigits: 1, - type: NUMERIC_CAN_BE_INVALIDATED_TYPE, - valueGetter: (params) => { - return params.context.applyFluxConvention(params.data.p); - }, + type: [NUMERIC_APPLY_FLUX_CONVENTION_1_FRACTION_DIGITS_TYPE, NUMERIC_CAN_BE_INVALIDATED_TYPE], getQuickFilterText: excludeFromGlobalFilter, }, { id: 'ReactivePower', field: 'q', - numeric: true, - fractionDigits: 1, - - type: NUMERIC_CAN_BE_INVALIDATED_TYPE, - valueGetter: (params) => { - return params.context.applyFluxConvention(params.data.q); - }, + type: [NUMERIC_APPLY_FLUX_CONVENTION_1_FRACTION_DIGITS_TYPE, NUMERIC_CAN_BE_INVALIDATED_TYPE], getQuickFilterText: excludeFromGlobalFilter, }, { @@ -143,9 +133,7 @@ export const GENERATOR_TAB_DEF = { { id: 'ActivePowerRegulationDroop', field: 'activePowerControl.droop', - numeric: true, - type: NUMERIC_TYPE, - fractionDigits: 1, + type: NUMERIC_1_FRACTION_DIGITS_TYPE, ...editableColumnConfig, ...numericalCellEditorConfig((params) => params.data.activePowerControl?.droop), valueGetter: (params) => params.data?.activePowerControl?.droop, @@ -167,9 +155,7 @@ export const GENERATOR_TAB_DEF = { { id: 'minP', field: 'minP', - numeric: true, - type: NUMERIC_TYPE, - fractionDigits: 1, + type: NUMERIC_1_FRACTION_DIGITS_TYPE, ...editableColumnConfig, ...numericalCellEditorConfig((params) => params.data.minP), getQuickFilterText: excludeFromGlobalFilter, @@ -180,9 +166,7 @@ export const GENERATOR_TAB_DEF = { { id: 'maxP', field: 'maxP', - numeric: true, - type: NUMERIC_TYPE, - fractionDigits: 1, + type: NUMERIC_1_FRACTION_DIGITS_TYPE, ...editableColumnConfig, ...numericalCellEditorConfig((params) => params.data.maxP), getQuickFilterText: excludeFromGlobalFilter, @@ -194,10 +178,9 @@ export const GENERATOR_TAB_DEF = { id: 'activePowerSetpoint', field: 'targetP', numeric: true, - type: NUMERIC_TYPE, + type: NUMERIC_1_FRACTION_DIGITS_TYPE, ...editableColumnConfig, ...numericalCellEditorConfig((params) => params.data.targetP), - fractionDigits: 1, getQuickFilterText: excludeFromGlobalFilter, crossValidation: { minExpression: 'minP', @@ -208,9 +191,7 @@ export const GENERATOR_TAB_DEF = { { id: 'reactivePowerSetpoint', field: 'targetQ', - numeric: true, - type: NUMERIC_TYPE, - fractionDigits: 1, + type: NUMERIC_1_FRACTION_DIGITS_TYPE, ...editableColumnConfig, ...numericalCellEditorConfig((params) => params.data.targetQ), crossValidation: { @@ -232,9 +213,7 @@ export const GENERATOR_TAB_DEF = { { id: 'voltageSetpoint', field: 'targetV', - numeric: true, - type: NUMERIC_TYPE, - fractionDigits: 1, + type: NUMERIC_1_FRACTION_DIGITS_TYPE, ...editableColumnConfig, ...numericalCellEditorConfig((params) => params.data.targetV), crossValidation: { @@ -248,11 +227,9 @@ export const GENERATOR_TAB_DEF = { { id: 'ReactivePercentageVoltageRegulation', field: 'coordinatedReactiveControl.qPercent', - type: NUMERIC_TYPE, + type: NUMERIC_1_FRACTION_DIGITS_TYPE, getQuickFilterText: excludeFromGlobalFilter, ...editableColumnConfig, - numeric: true, - fractionDigits: 1, ...numericalCellEditorConfig((params) => { const qPercent = params.data?.coordinatedReactiveControl?.qPercent; return isNaN(qPercent) ? 0 : qPercent; @@ -275,9 +252,7 @@ export const GENERATOR_TAB_DEF = { { id: 'directTransX', field: 'generatorShortCircuit.directTransX', - numeric: true, - type: NUMERIC_TYPE, - fractionDigits: 1, + type: NUMERIC_1_FRACTION_DIGITS_TYPE, getQuickFilterText: excludeFromGlobalFilter, ...editableColumnConfig, ...numericalCellEditorConfig((params) => params.data?.generatorShortCircuit?.directTransX || 0), @@ -296,9 +271,7 @@ export const GENERATOR_TAB_DEF = { { id: 'stepUpTransformerX', field: 'generatorShortCircuit.stepUpTransformerX', - numeric: true, - type: NUMERIC_TYPE, - fractionDigits: 1, + type: NUMERIC_1_FRACTION_DIGITS_TYPE, getQuickFilterText: excludeFromGlobalFilter, ...editableColumnConfig, ...numericalCellEditorConfig((params) => params.data?.generatorShortCircuit?.stepUpTransformerX || 0), @@ -317,9 +290,7 @@ export const GENERATOR_TAB_DEF = { { id: 'plannedActivePowerSetPoint', field: 'generatorStartup.plannedActivePowerSetPoint', - numeric: true, - type: NUMERIC_TYPE, - fractionDigits: 1, + type: NUMERIC_1_FRACTION_DIGITS_TYPE, getQuickFilterText: excludeFromGlobalFilter, ...editableColumnConfig, ...numericalCellEditorConfig((params) => params.data?.generatorStartup?.plannedActivePowerSetPoint), @@ -340,9 +311,7 @@ export const GENERATOR_TAB_DEF = { field: 'generatorStartup.marginalCost', ...editableColumnConfig, ...numericalCellEditorConfig((params) => params.data?.generatorStartup?.marginalCost), - numeric: true, - type: NUMERIC_TYPE, - fractionDigits: 1, + type: NUMERIC_1_FRACTION_DIGITS_TYPE, getQuickFilterText: excludeFromGlobalFilter, valueGetter: (params) => params.data?.generatorStartup?.marginalCost, valueSetter: (params) => { @@ -359,9 +328,7 @@ export const GENERATOR_TAB_DEF = { { id: 'plannedOutageRate', field: 'generatorStartup.plannedOutageRate', - numeric: true, - type: NUMERIC_TYPE, - fractionDigits: 2, + type: NUMERIC_2_FRACTION_DIGITS_TYPE, getQuickFilterText: excludeFromGlobalFilter, ...editableColumnConfig, ...numericalCellEditorConfig((params) => params.data?.generatorStartup?.plannedOutageRate || 0), @@ -382,9 +349,7 @@ export const GENERATOR_TAB_DEF = { { id: 'forcedOutageRate', field: 'generatorStartup.forcedOutageRate', - numeric: true, - type: NUMERIC_TYPE, - fractionDigits: 2, + type: NUMERIC_2_FRACTION_DIGITS_TYPE, getQuickFilterText: excludeFromGlobalFilter, ...editableColumnConfig, ...numericalCellEditorConfig((params) => params.data.generatorStartup?.forcedOutageRate), @@ -411,7 +376,7 @@ export const GENERATOR_TAB_DEF = { { id: 'RegulationTypeText', field: 'RegulationTypeText', - ...getEnumConfig(Object.values(REGULATION_TYPES)), + type: REGULATION_ENUM_TYPE, ...editableColumnConfig, ...enumCellEditorConfig((params) => params.data?.RegulationTypeText, Object.values(REGULATION_TYPES)), }, diff --git a/src/components/spreadsheet/config/equipment/hvdc-line.ts b/src/components/spreadsheet/config/equipment/hvdc-line.ts index 9e6796acee..ca0ce22c7f 100644 --- a/src/components/spreadsheet/config/equipment/hvdc-line.ts +++ b/src/components/spreadsheet/config/equipment/hvdc-line.ts @@ -14,7 +14,7 @@ import { COUNTRY_TYPE, LARGE_COLUMN_WIDTH, MEDIUM_COLUMN_WIDTH, - NUMERIC_TYPE, + NUMERIC_1_FRACTION_DIGITS_TYPE, TEXT_TYPE, } from '../../utils/constants'; import { genericColumnOfProperties } from '../common/column-properties'; @@ -80,42 +80,32 @@ export const HVDC_LINE_TAB_DEF = { { id: 'R', field: 'r', - numeric: true, - type: NUMERIC_TYPE, - fractionDigits: 1, + type: NUMERIC_1_FRACTION_DIGITS_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, { id: 'ActivePowerSetpoint', field: 'activePowerSetpoint', - numeric: true, - type: NUMERIC_TYPE, - fractionDigits: 1, + type: NUMERIC_1_FRACTION_DIGITS_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, { id: 'maxActivePower', field: 'maxP', - numeric: true, - type: NUMERIC_TYPE, - fractionDigits: 1, + type: NUMERIC_1_FRACTION_DIGITS_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, { id: 'OprFromCS1toCS2', field: 'hvdcOperatorActivePowerRange.oprFromCS1toCS2', - numeric: true, - type: NUMERIC_TYPE, - fractionDigits: 1, + type: NUMERIC_1_FRACTION_DIGITS_TYPE, columnWidth: LARGE_COLUMN_WIDTH, getQuickFilterText: excludeFromGlobalFilter, }, { id: 'OprFromCS2toCS1', field: 'hvdcOperatorActivePowerRange.oprFromCS2toCS1', - numeric: true, - type: NUMERIC_TYPE, - fractionDigits: 1, + type: NUMERIC_1_FRACTION_DIGITS_TYPE, columnWidth: LARGE_COLUMN_WIDTH, getQuickFilterText: excludeFromGlobalFilter, }, @@ -128,17 +118,13 @@ export const HVDC_LINE_TAB_DEF = { { id: 'K', field: 'hvdcAngleDroopActivePowerControl.droop', - numeric: true, - type: NUMERIC_TYPE, - fractionDigits: 1, + type: NUMERIC_1_FRACTION_DIGITS_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, { id: 'P0', field: 'hvdcAngleDroopActivePowerControl.p0', - numeric: true, - type: NUMERIC_TYPE, - fractionDigits: 1, + type: NUMERIC_1_FRACTION_DIGITS_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, genericColumnOfProperties, diff --git a/src/components/spreadsheet/config/equipment/lcc-converter-station.ts b/src/components/spreadsheet/config/equipment/lcc-converter-station.ts index 2acf8e9d70..bff3e80a2f 100644 --- a/src/components/spreadsheet/config/equipment/lcc-converter-station.ts +++ b/src/components/spreadsheet/config/equipment/lcc-converter-station.ts @@ -13,8 +13,9 @@ import { genericColumnOfProperties } from '../common/column-properties'; import { BOOLEAN_TYPE, COUNTRY_TYPE, + NUMERIC_0_FRACTION_DIGITS_TYPE, + NUMERIC_1_FRACTION_DIGITS_TYPE, NUMERIC_CAN_BE_INVALIDATED_TYPE, - NUMERIC_TYPE, TEXT_TYPE, } from 'components/spreadsheet/utils/constants'; import { SortWay } from 'hooks/use-aggrid-sort'; @@ -48,9 +49,7 @@ export const LCC_CONVERTER_STATION_TAB_DEF = { { id: 'NominalV', field: 'nominalV', - numeric: true, - type: NUMERIC_TYPE, - fractionDigits: 0, + type: NUMERIC_0_FRACTION_DIGITS_TYPE, }, { id: 'HvdcLineId', @@ -60,33 +59,25 @@ export const LCC_CONVERTER_STATION_TAB_DEF = { { id: 'activePower', field: 'p', - numeric: true, - type: NUMERIC_CAN_BE_INVALIDATED_TYPE, - fractionDigits: 1, + type: [NUMERIC_1_FRACTION_DIGITS_TYPE, NUMERIC_CAN_BE_INVALIDATED_TYPE], getQuickFilterText: excludeFromGlobalFilter, }, { id: 'ReactivePower', field: 'q', - numeric: true, - type: NUMERIC_CAN_BE_INVALIDATED_TYPE, - fractionDigits: 1, + type: [NUMERIC_1_FRACTION_DIGITS_TYPE, NUMERIC_CAN_BE_INVALIDATED_TYPE], getQuickFilterText: excludeFromGlobalFilter, }, { id: 'PowerFactor', field: 'powerFactor', - numeric: true, - type: NUMERIC_TYPE, - fractionDigits: 1, + type: NUMERIC_1_FRACTION_DIGITS_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, { id: 'LossFactor', field: 'lossFactor', - numeric: true, - type: NUMERIC_TYPE, - fractionDigits: 1, + type: NUMERIC_1_FRACTION_DIGITS_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, { diff --git a/src/components/spreadsheet/config/equipment/line.ts b/src/components/spreadsheet/config/equipment/line.ts index bf318b5a21..03c41aab7e 100644 --- a/src/components/spreadsheet/config/equipment/line.ts +++ b/src/components/spreadsheet/config/equipment/line.ts @@ -14,11 +14,12 @@ import { BOOLEAN_TYPE, COUNTRY_TYPE, MEDIUM_COLUMN_WIDTH, + NUMERIC_0_FRACTION_DIGITS_TYPE, + NUMERIC_1_FRACTION_DIGITS_TYPE, NUMERIC_CAN_BE_INVALIDATED_TYPE, - NUMERIC_TYPE, + NUMERIC_UNIT_TO_MICRO_UNIT_TYPE, TEXT_TYPE, } from '../../utils/constants'; -import { unitToMicroUnit } from '../../../../utils/unit-converter'; import { genericColumnOfProperties } from '../common/column-properties'; import { SortWay } from 'hooks/use-aggrid-sort'; @@ -64,102 +65,72 @@ export const LINE_TAB_DEF = { { id: 'nominalVoltage1KV', field: 'nominalVoltage1', - numeric: true, - type: NUMERIC_TYPE, - fractionDigits: 0, + type: NUMERIC_0_FRACTION_DIGITS_TYPE, }, { id: 'nominalVoltage2KV', field: 'nominalVoltage2', - numeric: true, - type: NUMERIC_TYPE, - fractionDigits: 0, + type: NUMERIC_0_FRACTION_DIGITS_TYPE, }, { id: 'ActivePowerSide1', field: 'p1', - numeric: true, - type: NUMERIC_CAN_BE_INVALIDATED_TYPE, - fractionDigits: 1, - valueGetter: (params) => { - return params.context.applyFluxConvention(params.data.p1); - }, + type: [NUMERIC_1_FRACTION_DIGITS_TYPE, NUMERIC_CAN_BE_INVALIDATED_TYPE], getQuickFilterText: excludeFromGlobalFilter, }, { id: 'ActivePowerSide2', field: 'p2', - numeric: true, - type: NUMERIC_CAN_BE_INVALIDATED_TYPE, - fractionDigits: 1, + type: [NUMERIC_1_FRACTION_DIGITS_TYPE, NUMERIC_CAN_BE_INVALIDATED_TYPE], getQuickFilterText: excludeFromGlobalFilter, }, { id: 'ReactivePowerSide1', field: 'q1', numeric: true, - type: NUMERIC_CAN_BE_INVALIDATED_TYPE, - fractionDigits: 1, + getQuickFilterText: excludeFromGlobalFilter, }, { id: 'ReactivePowerSide2', field: 'q2', - numeric: true, - type: NUMERIC_CAN_BE_INVALIDATED_TYPE, - fractionDigits: 1, + type: [NUMERIC_1_FRACTION_DIGITS_TYPE, NUMERIC_CAN_BE_INVALIDATED_TYPE], getQuickFilterText: excludeFromGlobalFilter, }, { id: 'r', field: 'r', - numeric: true, - type: NUMERIC_TYPE, - fractionDigits: 1, + type: NUMERIC_1_FRACTION_DIGITS_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, { id: 'x', field: 'x', - numeric: true, - type: NUMERIC_TYPE, - fractionDigits: 1, + type: NUMERIC_1_FRACTION_DIGITS_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, { id: 'g1', field: 'g1', - numeric: true, - type: NUMERIC_TYPE, - fractionDigits: 1, - valueGetter: (params) => unitToMicroUnit(params.data.g1), + type: NUMERIC_UNIT_TO_MICRO_UNIT_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, { id: 'g2', field: 'g2', - numeric: true, - type: NUMERIC_TYPE, - fractionDigits: 1, - valueGetter: (params) => unitToMicroUnit(params.data.g2), + type: NUMERIC_UNIT_TO_MICRO_UNIT_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, { id: 'b1', field: 'b1', - numeric: true, - type: NUMERIC_TYPE, - fractionDigits: 1, - valueGetter: (params) => unitToMicroUnit(params.data.b1), + type: NUMERIC_UNIT_TO_MICRO_UNIT_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, { id: 'b2', field: 'b2', - numeric: true, - type: NUMERIC_TYPE, - fractionDigits: 1, - valueGetter: (params) => unitToMicroUnit(params.data.b2), + type: NUMERIC_UNIT_TO_MICRO_UNIT_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, { @@ -171,7 +142,6 @@ export const LINE_TAB_DEF = { { id: 'connected2', field: 'terminal2Connected', - boolean: true, type: BOOLEAN_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, diff --git a/src/components/spreadsheet/config/equipment/load.ts b/src/components/spreadsheet/config/equipment/load.ts index 3c4a35a27b..be61b68e5e 100644 --- a/src/components/spreadsheet/config/equipment/load.ts +++ b/src/components/spreadsheet/config/equipment/load.ts @@ -12,16 +12,17 @@ import { editableColumnConfig, excludeFromGlobalFilter, typeAndFetchers } from ' import { BOOLEAN_TYPE, COUNTRY_TYPE, + LOAD_ENUM_TYPE, MEDIUM_COLUMN_WIDTH, + NUMERIC_0_FRACTION_DIGITS_TYPE, + NUMERIC_1_FRACTION_DIGITS_TYPE, NUMERIC_CAN_BE_INVALIDATED_TYPE, - NUMERIC_TYPE, TEXT_TYPE, } from '../../utils/constants'; import { LOAD_TYPES } from '../../../network/constants'; import { genericColumnOfPropertiesEditPopup } from '../common/column-properties'; import { enumCellEditorConfig, numericalCellEditorConfig } from '../common/cell-editors'; import { SortWay } from 'hooks/use-aggrid-sort'; -import { getEnumConfig } from '../column-type-filter-config'; export const LOAD_TAB_DEF = { index: 6, @@ -45,7 +46,7 @@ export const LOAD_TAB_DEF = { { id: 'loadType', field: 'type', - ...getEnumConfig([...LOAD_TYPES, { id: 'UNDEFINED', label: 'Undefined' }]), + type: LOAD_ENUM_TYPE, ...editableColumnConfig, ...enumCellEditorConfig( (params) => params.data?.type, @@ -65,32 +66,24 @@ export const LOAD_TAB_DEF = { { id: 'NominalV', field: 'nominalVoltage', - numeric: true, - type: NUMERIC_TYPE, - fractionDigits: 0, + type: NUMERIC_0_FRACTION_DIGITS_TYPE, }, { id: 'activePower', field: 'p', - numeric: true, - type: NUMERIC_CAN_BE_INVALIDATED_TYPE, - fractionDigits: 1, + type: [NUMERIC_1_FRACTION_DIGITS_TYPE, NUMERIC_CAN_BE_INVALIDATED_TYPE], getQuickFilterText: excludeFromGlobalFilter, }, { id: 'ReactivePower', field: 'q', - numeric: true, - type: NUMERIC_CAN_BE_INVALIDATED_TYPE, - fractionDigits: 1, + type: [NUMERIC_1_FRACTION_DIGITS_TYPE, NUMERIC_CAN_BE_INVALIDATED_TYPE], getQuickFilterText: excludeFromGlobalFilter, }, { id: 'p0', field: 'p0', - numeric: true, - type: NUMERIC_TYPE, - fractionDigits: 1, + type: NUMERIC_1_FRACTION_DIGITS_TYPE, ...editableColumnConfig, ...numericalCellEditorConfig((params) => params.data.p0), getQuickFilterText: excludeFromGlobalFilter, @@ -98,9 +91,7 @@ export const LOAD_TAB_DEF = { { id: 'q0', field: 'q0', - numeric: true, - type: NUMERIC_TYPE, - fractionDigits: 1, + type: NUMERIC_1_FRACTION_DIGITS_TYPE, ...editableColumnConfig, ...numericalCellEditorConfig((params) => params.data.q0), getQuickFilterText: excludeFromGlobalFilter, diff --git a/src/components/spreadsheet/config/equipment/shunt-compensator.ts b/src/components/spreadsheet/config/equipment/shunt-compensator.ts index 69c09718dc..f38260f370 100644 --- a/src/components/spreadsheet/config/equipment/shunt-compensator.ts +++ b/src/components/spreadsheet/config/equipment/shunt-compensator.ts @@ -14,15 +14,18 @@ import { COUNTRY_TYPE, MEDIUM_COLUMN_WIDTH, MIN_COLUMN_WIDTH, + NUMERIC_0_FRACTION_DIGITS_TYPE, + NUMERIC_1_FRACTION_DIGITS_TYPE, + NUMERIC_5_FRACTION_DIGITS_TYPE, NUMERIC_CAN_BE_INVALIDATED_TYPE, NUMERIC_TYPE, + SHUNT_COMPENSATOR_ENUM_TYPE, TEXT_TYPE, } from '../../utils/constants'; import { SHUNT_COMPENSATOR_TYPES } from '../../../network/constants'; import { genericColumnOfPropertiesEditPopup } from '../common/column-properties'; import { enumCellEditorConfig, numericalCellEditorConfig } from '../common/cell-editors'; import { SortWay } from 'hooks/use-aggrid-sort'; -import { getEnumConfig } from '../column-type-filter-config'; export const SHUNT_COMPENSATOR_TAB_DEF = { index: 7, @@ -56,26 +59,18 @@ export const SHUNT_COMPENSATOR_TAB_DEF = { { id: 'NominalV', field: 'nominalVoltage', - numeric: true, - type: NUMERIC_TYPE, - fractionDigits: 0, + type: NUMERIC_0_FRACTION_DIGITS_TYPE, }, { id: 'ReactivePower', field: 'q', - numeric: true, - fractionDigits: 1, - type: NUMERIC_CAN_BE_INVALIDATED_TYPE, - valueGetter: (params) => { - return params.context.applyFluxConvention(params.data.q); - }, + type: [NUMERIC_1_FRACTION_DIGITS_TYPE, NUMERIC_CAN_BE_INVALIDATED_TYPE], getQuickFilterText: excludeFromGlobalFilter, }, { id: 'maximumSectionCount', field: 'maximumSectionCount', ...editableColumnConfig, - numeric: true, ...numericalCellEditorConfig((params) => params.data.maximumSectionCount), type: NUMERIC_TYPE, getQuickFilterText: excludeFromGlobalFilter, @@ -87,7 +82,6 @@ export const SHUNT_COMPENSATOR_TAB_DEF = { id: 'sectionCount', field: 'sectionCount', ...editableColumnConfig, - numeric: true, ...numericalCellEditorConfig((params) => params.data.sectionCount), type: NUMERIC_TYPE, getQuickFilterText: excludeFromGlobalFilter, @@ -99,7 +93,7 @@ export const SHUNT_COMPENSATOR_TAB_DEF = { { id: 'Type', field: 'type', - ...getEnumConfig(Object.values(SHUNT_COMPENSATOR_TYPES)), + type: SHUNT_COMPENSATOR_ENUM_TYPE, ...editableColumnConfig, ...enumCellEditorConfig((params) => params.data?.type, Object.values(SHUNT_COMPENSATOR_TYPES)), }, @@ -107,10 +101,8 @@ export const SHUNT_COMPENSATOR_TAB_DEF = { id: 'maxQAtNominalV', field: 'maxQAtNominalV', ...editableColumnConfig, - numeric: true, ...numericalCellEditorConfig((params) => params.data.maxQAtNominalV), - type: NUMERIC_TYPE, - fractionDigits: 1, + type: NUMERIC_1_FRACTION_DIGITS_TYPE, getQuickFilterText: excludeFromGlobalFilter, crossValidation: { minExpression: 0, @@ -119,39 +111,31 @@ export const SHUNT_COMPENSATOR_TAB_DEF = { { id: 'SwitchedOnMaxQAtNominalV', field: 'switchedOnQAtNominalV', - numeric: true, valueGetter: (params) => (params?.data?.maxQAtNominalV / params?.data?.maximumSectionCount) * params?.data?.sectionCount, - type: NUMERIC_TYPE, - fractionDigits: 1, + type: NUMERIC_0_FRACTION_DIGITS_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, { id: 'maxSusceptance', ...editableColumnConfig, field: 'maxSusceptance', - numeric: true, ...numericalCellEditorConfig((params) => params.data.maxSusceptance), - type: NUMERIC_TYPE, - fractionDigits: 5, + type: NUMERIC_5_FRACTION_DIGITS_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, { id: 'SwitchedOnMaxSusceptance', field: 'switchedOnSusceptance', - numeric: true, valueGetter: (params) => (params?.data?.maxSusceptance / params?.data?.maximumSectionCount) * params?.data?.sectionCount, - type: NUMERIC_TYPE, - fractionDigits: 5, + type: NUMERIC_5_FRACTION_DIGITS_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, { id: 'voltageSetpoint', field: 'targetV', - numeric: true, - type: NUMERIC_TYPE, - fractionDigits: 1, + type: NUMERIC_1_FRACTION_DIGITS_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, { diff --git a/src/components/spreadsheet/config/equipment/static-var-compensator.ts b/src/components/spreadsheet/config/equipment/static-var-compensator.ts index cce31253e1..0d3d076536 100644 --- a/src/components/spreadsheet/config/equipment/static-var-compensator.ts +++ b/src/components/spreadsheet/config/equipment/static-var-compensator.ts @@ -13,8 +13,9 @@ import { BOOLEAN_TYPE, COUNTRY_TYPE, MEDIUM_COLUMN_WIDTH, + NUMERIC_0_FRACTION_DIGITS_TYPE, + NUMERIC_1_FRACTION_DIGITS_TYPE, NUMERIC_CAN_BE_INVALIDATED_TYPE, - NUMERIC_TYPE, TEXT_TYPE, } from '../../utils/constants'; import { NOMINAL_V } from '../../../utils/field-constants'; @@ -50,40 +51,30 @@ export const STATIC_VAR_COMPENSATOR_TAB_DEF = { { id: 'NominalV', field: NOMINAL_V, - numeric: true, - type: NUMERIC_TYPE, - fractionDigits: 0, + type: NUMERIC_0_FRACTION_DIGITS_TYPE, }, { id: 'activePower', field: 'p', - numeric: true, - type: NUMERIC_CAN_BE_INVALIDATED_TYPE, - fractionDigits: 1, + type: [NUMERIC_1_FRACTION_DIGITS_TYPE, NUMERIC_CAN_BE_INVALIDATED_TYPE], getQuickFilterText: excludeFromGlobalFilter, }, { id: 'ReactivePower', field: 'q', - numeric: true, - type: NUMERIC_CAN_BE_INVALIDATED_TYPE, - fractionDigits: 1, + type: [NUMERIC_1_FRACTION_DIGITS_TYPE, NUMERIC_CAN_BE_INVALIDATED_TYPE], getQuickFilterText: excludeFromGlobalFilter, }, { id: 'VoltageSetpointKV', field: 'voltageSetpoint', - numeric: true, - type: NUMERIC_TYPE, - fractionDigits: 1, + type: NUMERIC_1_FRACTION_DIGITS_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, { id: 'ReactivePowerSetpointMVAR', field: 'reactivePowerSetpoint', - numeric: true, - type: NUMERIC_TYPE, - fractionDigits: 1, + type: NUMERIC_1_FRACTION_DIGITS_TYPE, columnWidth: MEDIUM_COLUMN_WIDTH, getQuickFilterText: excludeFromGlobalFilter, }, diff --git a/src/components/spreadsheet/config/equipment/three-windings-transformer.ts b/src/components/spreadsheet/config/equipment/three-windings-transformer.ts index 200b57a35b..5c25e25b72 100644 --- a/src/components/spreadsheet/config/equipment/three-windings-transformer.ts +++ b/src/components/spreadsheet/config/equipment/three-windings-transformer.ts @@ -13,6 +13,8 @@ import { BOOLEAN_TYPE, COUNTRY_TYPE, MEDIUM_COLUMN_WIDTH, + NUMERIC_0_FRACTION_DIGITS_TYPE, + NUMERIC_1_FRACTION_DIGITS_TYPE, NUMERIC_CAN_BE_INVALIDATED_TYPE, NUMERIC_TYPE, TEXT_TYPE, @@ -74,76 +76,62 @@ export const THREE_WINDINGS_TRANSFORMER_TAB_DEF = { { id: 'NominalVT3WSide1', field: 'nominalV1', - numeric: true, - type: NUMERIC_TYPE, - fractionDigits: 0, + type: NUMERIC_0_FRACTION_DIGITS_TYPE, }, { id: 'NominalVT3WSide2', field: 'nominalV2', - numeric: true, - type: NUMERIC_TYPE, - fractionDigits: 0, + type: NUMERIC_0_FRACTION_DIGITS_TYPE, }, { id: 'NominalVT3WSide3', field: 'nominalV3', - numeric: true, - type: NUMERIC_TYPE, - fractionDigits: 0, + type: NUMERIC_0_FRACTION_DIGITS_TYPE, }, { id: 'ActivePowerT3WSide1', field: 'p1', - numeric: true, - type: NUMERIC_CAN_BE_INVALIDATED_TYPE, - fractionDigits: 1, + type: [NUMERIC_1_FRACTION_DIGITS_TYPE, NUMERIC_CAN_BE_INVALIDATED_TYPE], getQuickFilterText: excludeFromGlobalFilter, }, { id: 'ActivePowerT3WSide2', field: 'p2', numeric: true, - type: NUMERIC_CAN_BE_INVALIDATED_TYPE, - fractionDigits: 1, + type: [NUMERIC_1_FRACTION_DIGITS_TYPE, NUMERIC_CAN_BE_INVALIDATED_TYPE], getQuickFilterText: excludeFromGlobalFilter, }, { id: 'ActivePowerT3WSide3', field: 'p3', numeric: true, - type: NUMERIC_CAN_BE_INVALIDATED_TYPE, - fractionDigits: 1, + type: [NUMERIC_1_FRACTION_DIGITS_TYPE, NUMERIC_CAN_BE_INVALIDATED_TYPE], getQuickFilterText: excludeFromGlobalFilter, }, { id: 'ReactivePowerT3WSide1', field: 'q1', numeric: true, - type: NUMERIC_CAN_BE_INVALIDATED_TYPE, - fractionDigits: 1, + type: [NUMERIC_1_FRACTION_DIGITS_TYPE, NUMERIC_CAN_BE_INVALIDATED_TYPE], getQuickFilterText: excludeFromGlobalFilter, }, { id: 'ReactivePowerT3WSide2', field: 'q2', numeric: true, - type: NUMERIC_CAN_BE_INVALIDATED_TYPE, - fractionDigits: 1, + type: [NUMERIC_1_FRACTION_DIGITS_TYPE, NUMERIC_CAN_BE_INVALIDATED_TYPE], getQuickFilterText: excludeFromGlobalFilter, }, { id: 'ReactivePowerT3WSide3', field: 'q3', numeric: true, - type: NUMERIC_CAN_BE_INVALIDATED_TYPE, - fractionDigits: 1, + type: [NUMERIC_1_FRACTION_DIGITS_TYPE, NUMERIC_CAN_BE_INVALIDATED_TYPE], getQuickFilterText: excludeFromGlobalFilter, }, { id: 'HasLoadTapChanging1Capabilities', field: 'hasLoadTapChanging1Capabilities', - boolean: true, getQuickFilterText: excludeFromGlobalFilter, }, { @@ -156,8 +144,7 @@ export const THREE_WINDINGS_TRANSFORMER_TAB_DEF = { id: 'TargetVPoint1', field: 'targetV1', numeric: true, - type: NUMERIC_TYPE, - fractionDigits: 1, + type: NUMERIC_1_FRACTION_DIGITS_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, { @@ -193,9 +180,7 @@ export const THREE_WINDINGS_TRANSFORMER_TAB_DEF = { { id: 'TargetVPoint2', field: 'targetV2', - numeric: true, - type: NUMERIC_TYPE, - fractionDigits: 1, + type: NUMERIC_1_FRACTION_DIGITS_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, { @@ -231,17 +216,14 @@ export const THREE_WINDINGS_TRANSFORMER_TAB_DEF = { { id: 'TargetVPoint3', field: 'targetV3', - numeric: true, - type: NUMERIC_TYPE, - fractionDigits: 1, + type: NUMERIC_1_FRACTION_DIGITS_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, { id: 'RatioTap3', field: 'ratioTapChanger3', - type: NUMERIC_TYPE, + type: NUMERIC_1_FRACTION_DIGITS_TYPE, changeCmd: generateTapRequest('Ratio', 3), - fractionDigits: 0, valueGetter: (params) => params?.data?.ratioTapChanger3?.tapPosition, valueSetter: (params) => { params.data.ratioTapChanger3 = { @@ -270,9 +252,8 @@ export const THREE_WINDINGS_TRANSFORMER_TAB_DEF = { { id: 'PhaseTap1', field: 'phaseTapChanger1', - type: NUMERIC_TYPE, + type: NUMERIC_0_FRACTION_DIGITS_TYPE, changeCmd: generateTapRequest('Phase', 1), - fractionDigits: 0, valueGetter: (params) => params?.data?.phaseTapChanger1?.tapPosition, valueSetter: (params) => { params.data.phaseTapChanger1 = { @@ -288,10 +269,8 @@ export const THREE_WINDINGS_TRANSFORMER_TAB_DEF = { { id: 'RegulatingValue1', field: 'regulatingValue1', - numeric: true, - type: NUMERIC_TYPE, + type: NUMERIC_1_FRACTION_DIGITS_TYPE, columnWidth: MEDIUM_COLUMN_WIDTH, - fractionDigits: 1, getQuickFilterText: excludeFromGlobalFilter, }, { @@ -310,9 +289,8 @@ export const THREE_WINDINGS_TRANSFORMER_TAB_DEF = { { id: 'PhaseTap2', field: 'phaseTapChanger2', - type: NUMERIC_TYPE, + type: NUMERIC_0_FRACTION_DIGITS_TYPE, changeCmd: generateTapRequest('Phase', 2), - fractionDigits: 0, valueGetter: (params) => params?.data?.phaseTapChanger2?.tapPosition, valueSetter: (params) => { params.data.phaseTapChanger2 = { @@ -328,10 +306,8 @@ export const THREE_WINDINGS_TRANSFORMER_TAB_DEF = { { id: 'RegulatingValue2', field: 'regulatingValue2', - numeric: true, - type: NUMERIC_TYPE, + type: NUMERIC_1_FRACTION_DIGITS_TYPE, columnWidth: MEDIUM_COLUMN_WIDTH, - fractionDigits: 1, getQuickFilterText: excludeFromGlobalFilter, }, { @@ -350,9 +326,8 @@ export const THREE_WINDINGS_TRANSFORMER_TAB_DEF = { { id: 'PhaseTap3', field: 'phaseTapChanger3', - type: NUMERIC_TYPE, + type: NUMERIC_0_FRACTION_DIGITS_TYPE, changeCmd: generateTapRequest('Phase', 3), - fractionDigits: 0, valueGetter: (params) => params?.data?.phaseTapChanger3?.tapPosition, valueSetter: (params) => { params.data.phaseTapChanger3 = { @@ -368,10 +343,8 @@ export const THREE_WINDINGS_TRANSFORMER_TAB_DEF = { { id: 'RegulatingValue3', field: 'regulatingValue3', - numeric: true, - type: NUMERIC_TYPE, + type: NUMERIC_1_FRACTION_DIGITS_TYPE, columnWidth: MEDIUM_COLUMN_WIDTH, - fractionDigits: 1, getQuickFilterText: excludeFromGlobalFilter, }, { diff --git a/src/components/spreadsheet/config/equipment/tie-line.ts b/src/components/spreadsheet/config/equipment/tie-line.ts index de15b38423..6af0d658e5 100644 --- a/src/components/spreadsheet/config/equipment/tie-line.ts +++ b/src/components/spreadsheet/config/equipment/tie-line.ts @@ -13,11 +13,12 @@ import { BOOLEAN_TYPE, COUNTRY_TYPE, MEDIUM_COLUMN_WIDTH, + NUMERIC_0_FRACTION_DIGITS_TYPE, + NUMERIC_1_FRACTION_DIGITS_TYPE, NUMERIC_CAN_BE_INVALIDATED_TYPE, - NUMERIC_TYPE, + NUMERIC_UNIT_TO_MICRO_UNIT_TYPE, TEXT_TYPE, } from '../../utils/constants'; -import { unitToMicroUnit } from '../../../../utils/unit-converter'; import { genericColumnOfPropertiesReadonly } from '../common/column-properties'; import { SortWay } from 'hooks/use-aggrid-sort'; @@ -62,99 +63,72 @@ export const TIE_LINE_TAB_DEF = { { id: 'nominalVoltage1KV', field: 'nominalVoltage1', - numeric: true, - type: NUMERIC_TYPE, - fractionDigits: 0, + type: NUMERIC_0_FRACTION_DIGITS_TYPE, }, { id: 'nominalVoltage2KV', field: 'nominalVoltage2', - numeric: true, - type: NUMERIC_TYPE, - fractionDigits: 0, + type: NUMERIC_0_FRACTION_DIGITS_TYPE, }, { id: 'ActivePowerSide1', field: 'p1', - numeric: true, - type: NUMERIC_CAN_BE_INVALIDATED_TYPE, + type: [NUMERIC_1_FRACTION_DIGITS_TYPE, NUMERIC_CAN_BE_INVALIDATED_TYPE], fractionDigits: 1, getQuickFilterText: excludeFromGlobalFilter, }, { id: 'ActivePowerSide2', field: 'p2', - numeric: true, - type: NUMERIC_CAN_BE_INVALIDATED_TYPE, - fractionDigits: 1, + type: [NUMERIC_1_FRACTION_DIGITS_TYPE, NUMERIC_CAN_BE_INVALIDATED_TYPE], getQuickFilterText: excludeFromGlobalFilter, }, { id: 'ReactivePowerSide1', field: 'q1', - numeric: true, - type: NUMERIC_CAN_BE_INVALIDATED_TYPE, - fractionDigits: 1, + type: [NUMERIC_1_FRACTION_DIGITS_TYPE, NUMERIC_CAN_BE_INVALIDATED_TYPE], getQuickFilterText: excludeFromGlobalFilter, }, { id: 'ReactivePowerSide2', field: 'q2', - numeric: true, - type: NUMERIC_CAN_BE_INVALIDATED_TYPE, - fractionDigits: 1, + type: [NUMERIC_1_FRACTION_DIGITS_TYPE, NUMERIC_CAN_BE_INVALIDATED_TYPE], getQuickFilterText: excludeFromGlobalFilter, }, { id: 'r', field: 'r', - numeric: true, - type: NUMERIC_TYPE, - fractionDigits: 1, + type: NUMERIC_1_FRACTION_DIGITS_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, { id: 'x', field: 'x', - numeric: true, - type: NUMERIC_TYPE, - fractionDigits: 1, + type: NUMERIC_1_FRACTION_DIGITS_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, { id: 'g1', field: 'g1', - numeric: true, - type: NUMERIC_TYPE, - fractionDigits: 1, - valueGetter: (params) => unitToMicroUnit(params.data.g1), + type: NUMERIC_UNIT_TO_MICRO_UNIT_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, { id: 'g2', field: 'g2', - numeric: true, - type: NUMERIC_TYPE, - fractionDigits: 1, - valueGetter: (params) => unitToMicroUnit(params.data.g2), + type: NUMERIC_UNIT_TO_MICRO_UNIT_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, { id: 'b1', field: 'b1', - numeric: true, - type: NUMERIC_TYPE, - fractionDigits: 1, - valueGetter: (params) => unitToMicroUnit(params.data.b1), + type: NUMERIC_UNIT_TO_MICRO_UNIT_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, { id: 'b2', field: 'b2', - numeric: true, - type: NUMERIC_TYPE, - fractionDigits: 1, - valueGetter: (params) => unitToMicroUnit(params.data.b2), + type: NUMERIC_UNIT_TO_MICRO_UNIT_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, { diff --git a/src/components/spreadsheet/config/equipment/two-windings-transformer.ts b/src/components/spreadsheet/config/equipment/two-windings-transformer.ts index b90d3c20cf..8dadd24d91 100644 --- a/src/components/spreadsheet/config/equipment/two-windings-transformer.ts +++ b/src/components/spreadsheet/config/equipment/two-windings-transformer.ts @@ -23,8 +23,16 @@ import { BOOLEAN_TYPE, COUNTRY_TYPE, MEDIUM_COLUMN_WIDTH, + NUMERIC_0_FRACTION_DIGITS_TYPE, + NUMERIC_1_FRACTION_DIGITS_TYPE, NUMERIC_CAN_BE_INVALIDATED_TYPE, + NUMERIC_HIGH_TAP_POSITION_TYPE, NUMERIC_TYPE, + NUMERIC_UNIT_TO_MICRO_UNIT_TYPE, + PHASE_REGULATING_MODE_ENUM_TYPE, + RATIO_REGULATION_MODES_ENUM_TYPE, + REGULATION_ENUM_TYPE, + SIDE_ENUM_TYPE, TEXT_TYPE, } from '../../utils/constants'; import { PHASE_REGULATION_MODES, RATIO_REGULATION_MODES, REGULATION_TYPES, SIDE } from '../../../network/constants'; @@ -40,7 +48,6 @@ import { standardSelectCellEditorConfig, } from '../common/cell-editors'; import { SortWay } from 'hooks/use-aggrid-sort'; -import { getEnumConfig } from '../column-type-filter-config'; function getTwtRatioRegulationModeId(twt: any) { //regulationMode is set by the user (in edit mode) @@ -136,23 +143,17 @@ export const TWO_WINDINGS_TRANSFORMER_TAB_DEF = { { id: 'nominalVoltage1KV', field: 'nominalVoltage1', - numeric: true, - type: NUMERIC_TYPE, - fractionDigits: 0, + type: NUMERIC_0_FRACTION_DIGITS_TYPE, }, { id: 'nominalVoltage2KV', field: 'nominalVoltage2', - numeric: true, - type: NUMERIC_TYPE, - fractionDigits: 0, + type: NUMERIC_0_FRACTION_DIGITS_TYPE, }, { id: 'ratedVoltage1KV', field: 'ratedU1', - numeric: true, - type: NUMERIC_TYPE, - fractionDigits: 0, + type: NUMERIC_0_FRACTION_DIGITS_TYPE, ...editableColumnConfig, ...numericalCellEditorConfig((params) => params.data.ratedU1), getQuickFilterText: excludeFromGlobalFilter, @@ -160,9 +161,7 @@ export const TWO_WINDINGS_TRANSFORMER_TAB_DEF = { { id: 'ratedVoltage2KV', field: 'ratedU2', - numeric: true, - type: NUMERIC_TYPE, - fractionDigits: 0, + type: NUMERIC_0_FRACTION_DIGITS_TYPE, ...editableColumnConfig, ...numericalCellEditorConfig((params) => params.data.ratedU2), getQuickFilterText: excludeFromGlobalFilter, @@ -170,33 +169,25 @@ export const TWO_WINDINGS_TRANSFORMER_TAB_DEF = { { id: 'ActivePowerSide1', field: 'p1', - numeric: true, - type: NUMERIC_CAN_BE_INVALIDATED_TYPE, - fractionDigits: 1, + type: [NUMERIC_1_FRACTION_DIGITS_TYPE, NUMERIC_CAN_BE_INVALIDATED_TYPE], getQuickFilterText: excludeFromGlobalFilter, }, { id: 'ActivePowerSide2', field: 'p2', - numeric: true, - type: NUMERIC_CAN_BE_INVALIDATED_TYPE, - fractionDigits: 1, + type: [NUMERIC_1_FRACTION_DIGITS_TYPE, NUMERIC_CAN_BE_INVALIDATED_TYPE], getQuickFilterText: excludeFromGlobalFilter, }, { id: 'ReactivePowerSide1', field: 'q1', - numeric: true, - type: NUMERIC_CAN_BE_INVALIDATED_TYPE, - fractionDigits: 1, + type: [NUMERIC_1_FRACTION_DIGITS_TYPE, NUMERIC_CAN_BE_INVALIDATED_TYPE], getQuickFilterText: excludeFromGlobalFilter, }, { id: 'ReactivePowerSide2', field: 'q2', - numeric: true, - type: NUMERIC_CAN_BE_INVALIDATED_TYPE, - fractionDigits: 1, + type: [NUMERIC_1_FRACTION_DIGITS_TYPE, NUMERIC_CAN_BE_INVALIDATED_TYPE], getQuickFilterText: excludeFromGlobalFilter, }, { @@ -246,13 +237,12 @@ export const TWO_WINDINGS_TRANSFORMER_TAB_DEF = { columnValue: true, }, }, - ...getEnumConfig(Object.values(RATIO_REGULATION_MODES)), + type: RATIO_REGULATION_MODES_ENUM_TYPE, }, { id: 'TargetVPoint', field: 'ratioTapChanger.targetV', - type: NUMERIC_TYPE, - fractionDigits: 1, + type: NUMERIC_1_FRACTION_DIGITS_TYPE, editable: isTwtRatioOnloadAndEditable, cellStyle: editableCellStyle, ...numericalCellEditorConfig((params) => params.data?.ratioTapChanger?.targetV), @@ -268,8 +258,7 @@ export const TWO_WINDINGS_TRANSFORMER_TAB_DEF = { { id: 'RatioDeadBand', field: 'ratioTapChanger.targetDeadband', - type: NUMERIC_TYPE, - fractionDigits: 1, + type: NUMERIC_1_FRACTION_DIGITS_TYPE, editable: isTwtRatioOnloadAndEditable, cellStyle: editableCellStyle, ...numericalCellEditorConfig((params) => params.data.ratioTapChanger.targetDeadband), @@ -301,12 +290,12 @@ export const TWO_WINDINGS_TRANSFORMER_TAB_DEF = { editable: isTwtRatioOnloadAndEditable, cellStyle: editableCellStyle, getQuickFilterText: excludeFromGlobalFilter, - ...getEnumConfig(Object.values(REGULATION_TYPES)), + type: REGULATION_ENUM_TYPE, }, { id: 'RatioRegulatedSide', field: 'ratioTapChanger.regulationSide', - ...getEnumConfig(Object.values(SIDE)), + type: SIDE_ENUM_TYPE, valueGetter: (params) => params.data?.ratioTapChanger?.regulationSide, valueSetter: (params) => { params.data.ratioTapChanger = { @@ -348,8 +337,6 @@ export const TWO_WINDINGS_TRANSFORMER_TAB_DEF = { field: 'ratioTapChanger.lowTapPosition', getQuickFilterText: excludeFromGlobalFilter, type: NUMERIC_TYPE, - numeric: true, - fractionDigits: 0, editable: (params) => isEditable(params) && params.data?.ratioTapChanger?.steps?.length > 0, cellStyle: editableCellStyle, ...standardSelectCellEditorConfig((params) => generateTapPositions(params.data?.ratioTapChanger)), @@ -401,7 +388,7 @@ export const TWO_WINDINGS_TRANSFORMER_TAB_DEF = { { id: 'RegulatingMode', field: 'phaseTapChanger.regulationMode', - ...getEnumConfig(Object.values(PHASE_REGULATION_MODES)), + type: PHASE_REGULATING_MODE_ENUM_TYPE, valueGetter: (params) => params?.data?.phaseTapChanger?.regulationMode, valueSetter: (params) => { params.data.phaseTapChanger = { @@ -462,7 +449,7 @@ export const TWO_WINDINGS_TRANSFORMER_TAB_DEF = { { id: 'PhaseRegulationTypeText', field: 'phaseTapChanger.regulationType', - ...getEnumConfig(Object.values(REGULATION_TYPES)), + type: REGULATION_ENUM_TYPE, valueGetter: (params) => params.data?.phaseTapChanger?.regulationType, valueSetter: (params) => { params.data.phaseTapChanger = { @@ -483,7 +470,7 @@ export const TWO_WINDINGS_TRANSFORMER_TAB_DEF = { { id: 'PhaseRegulatedSide', field: 'phaseTapChanger.regulationSide', - ...getEnumConfig(Object.values(SIDE)), + type: SIDE_ENUM_TYPE, valueGetter: (params) => params.data?.phaseTapChanger?.regulationSide, valueSetter: (params) => { params.data.phaseTapChanger = { @@ -546,16 +533,13 @@ export const TWO_WINDINGS_TRANSFORMER_TAB_DEF = { { id: 'PhaseHighTapPosition', field: 'phaseTapChanger.highTapPosition', - type: NUMERIC_TYPE, - valueGetter: (params) => computeHighTapPosition(params?.data?.phaseTapChanger?.steps), + type: NUMERIC_HIGH_TAP_POSITION_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, { id: 'PhaseTap', field: 'phaseTapChanger.tapPosition', - type: NUMERIC_TYPE, - numeric: true, - fractionDigits: 0, + type: NUMERIC_0_FRACTION_DIGITS_TYPE, valueGetter: (params) => params?.data?.phaseTapChanger?.tapPosition, valueSetter: (params) => { params.data.phaseTapChanger = { @@ -578,42 +562,31 @@ export const TWO_WINDINGS_TRANSFORMER_TAB_DEF = { id: 'r', field: 'r', numeric: true, - type: NUMERIC_TYPE, - fractionDigits: 1, + type: NUMERIC_1_FRACTION_DIGITS_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, { id: 'x', field: 'x', - numeric: true, - type: NUMERIC_TYPE, - fractionDigits: 1, + type: NUMERIC_1_FRACTION_DIGITS_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, { id: 'g', field: 'g', - numeric: true, - type: NUMERIC_TYPE, - fractionDigits: 1, - valueGetter: (params) => unitToMicroUnit(params.data.g), + type: NUMERIC_UNIT_TO_MICRO_UNIT_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, { id: 'b', field: 'b', - numeric: true, - type: NUMERIC_TYPE, - fractionDigits: 1, - valueGetter: (params) => unitToMicroUnit(params.data.b), + type: NUMERIC_UNIT_TO_MICRO_UNIT_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, { id: 'ratedNominalPower', field: 'ratedS', - numeric: true, - type: NUMERIC_TYPE, - fractionDigits: 1, + type: NUMERIC_1_FRACTION_DIGITS_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, { diff --git a/src/components/spreadsheet/config/equipment/voltage-level.ts b/src/components/spreadsheet/config/equipment/voltage-level.ts index 8f37265e66..c0653b6248 100644 --- a/src/components/spreadsheet/config/equipment/voltage-level.ts +++ b/src/components/spreadsheet/config/equipment/voltage-level.ts @@ -13,7 +13,13 @@ import { editableColumnConfig, excludeFromGlobalFilter, typeAndFetchers } from ' import { kiloUnitToUnit, unitToKiloUnit } from '../../../../utils/unit-converter'; import { genericColumnOfPropertiesEditPopup } from '../common/column-properties'; import { numericalCellEditorConfig } from '../common/cell-editors'; -import { COUNTRY_TYPE, NUMERIC_TYPE, TEXT_TYPE } from 'components/spreadsheet/utils/constants'; +import { + COUNTRY_TYPE, + NUMERIC_1_FRACTION_DIGITS_TYPE, + NUMERIC_TYPE, + NUMERIC_UNIT_TO_KILO_UNIT_TYPE, + TEXT_TYPE, +} from 'components/spreadsheet/utils/constants'; import { SortWay } from 'hooks/use-aggrid-sort'; function generateEditableNumericColumnDefinition< @@ -25,9 +31,7 @@ function generateEditableNumericColumnDefinition< return { id: id, field: field, - numeric: true, - type: NUMERIC_TYPE, - fractionDigits: 1, + type: NUMERIC_1_FRACTION_DIGITS_TYPE, ...editableColumnConfig, ...numericalCellEditorConfig((params) => params.data[field]), crossValidation: { @@ -69,9 +73,7 @@ export const VOLTAGE_LEVEL_TAB_DEF = { { id: 'NominalV', field: 'nominalV', - numeric: true, type: NUMERIC_TYPE, - fractionDigits: 0, ...editableColumnConfig, ...numericalCellEditorConfig((params) => params.data.nominalV), }, @@ -80,12 +82,9 @@ export const VOLTAGE_LEVEL_TAB_DEF = { { id: 'IpMin', field: 'identifiableShortCircuit.ipMin', - type: NUMERIC_TYPE, - fractionDigits: 1, + type: NUMERIC_UNIT_TO_KILO_UNIT_TYPE, ...editableColumnConfig, - numeric: true, ...numericalCellEditorConfig((params) => unitToKiloUnit(params.data?.identifiableShortCircuit?.ipMin)), - valueGetter: (params) => unitToKiloUnit(params.data?.identifiableShortCircuit?.ipMin), valueSetter: (params) => { params.data.identifiableShortCircuit = { ...params.data.identifiableShortCircuit, @@ -101,12 +100,9 @@ export const VOLTAGE_LEVEL_TAB_DEF = { { id: 'IpMax', field: 'identifiableShortCircuit.ipMax', - type: NUMERIC_TYPE, - fractionDigits: 1, + type: NUMERIC_UNIT_TO_KILO_UNIT_TYPE, ...editableColumnConfig, - numeric: true, ...numericalCellEditorConfig((params) => unitToKiloUnit(params.data?.identifiableShortCircuit?.ipMax)), - valueGetter: (params) => unitToKiloUnit(params.data?.identifiableShortCircuit?.ipMax), valueSetter: (params) => { params.data.identifiableShortCircuit = { ...params.data.identifiableShortCircuit, diff --git a/src/components/spreadsheet/config/equipment/vsc-converter-station.ts b/src/components/spreadsheet/config/equipment/vsc-converter-station.ts index a69f4ac816..fc84fda167 100644 --- a/src/components/spreadsheet/config/equipment/vsc-converter-station.ts +++ b/src/components/spreadsheet/config/equipment/vsc-converter-station.ts @@ -13,8 +13,9 @@ import { BOOLEAN_TYPE, COUNTRY_TYPE, MEDIUM_COLUMN_WIDTH, + NUMERIC_0_FRACTION_DIGITS_TYPE, + NUMERIC_1_FRACTION_DIGITS_TYPE, NUMERIC_CAN_BE_INVALIDATED_TYPE, - NUMERIC_TYPE, TEXT_TYPE, } from '../../utils/constants'; import { genericColumnOfProperties } from '../common/column-properties'; @@ -50,9 +51,7 @@ export const VSC_CONVERTER_STATION_TAB_DEF = { { id: 'NominalV', field: 'nominalV', - numeric: true, - type: NUMERIC_TYPE, - fractionDigits: 0, + type: NUMERIC_0_FRACTION_DIGITS_TYPE, }, { id: 'HvdcLineId', @@ -62,25 +61,19 @@ export const VSC_CONVERTER_STATION_TAB_DEF = { { id: 'activePower', field: 'p', - numeric: true, - type: NUMERIC_CAN_BE_INVALIDATED_TYPE, - fractionDigits: 1, + type: [NUMERIC_1_FRACTION_DIGITS_TYPE, NUMERIC_CAN_BE_INVALIDATED_TYPE], getQuickFilterText: excludeFromGlobalFilter, }, { id: 'ReactivePower', field: 'q', - numeric: true, - type: NUMERIC_CAN_BE_INVALIDATED_TYPE, - fractionDigits: 1, + type: [NUMERIC_1_FRACTION_DIGITS_TYPE, NUMERIC_CAN_BE_INVALIDATED_TYPE], getQuickFilterText: excludeFromGlobalFilter, }, { id: 'LossFactor', field: 'lossFactor', - numeric: true, - type: NUMERIC_TYPE, - fractionDigits: 1, + type: NUMERIC_1_FRACTION_DIGITS_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, { @@ -92,17 +85,13 @@ export const VSC_CONVERTER_STATION_TAB_DEF = { { id: 'VoltageSetpointKV', field: 'voltageSetpoint', - numeric: true, - type: NUMERIC_TYPE, - fractionDigits: 1, + type: NUMERIC_1_FRACTION_DIGITS_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, { id: 'ReactivePowerSetpointMVAR', field: 'reactivePowerSetpoint', - numeric: true, - type: NUMERIC_TYPE, - fractionDigits: 1, + type: NUMERIC_1_FRACTION_DIGITS_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, { diff --git a/src/components/spreadsheet/utils/cell-renderers.tsx b/src/components/spreadsheet/utils/cell-renderers.tsx index 57c051f88c..2cb29c79a3 100644 --- a/src/components/spreadsheet/utils/cell-renderers.tsx +++ b/src/components/spreadsheet/utils/cell-renderers.tsx @@ -107,9 +107,27 @@ export const formatCell = (props: any) => { ? props.colDef.valueGetter(props, props.context.network) : props.colDef.valueGetter(props); } - if (props.applyFluxConvention) { - value = props.applyFluxConvention(value); + + if (value != null && props.colDef.numeric && props.colDef.fractionDigits) { + // only numeric rounded cells have a tooltip (their raw numeric value) + tooltipValue = value; + value = parseFloat(value).toFixed(props.colDef.fractionDigits); + } + if (props.colDef.numeric && isNaN(value)) { + value = null; + } + return { value: value, tooltip: tooltipValue }; +}; + +export const formatNumericCell = (props: any) => { + let value = props?.valueFormatted || props.value; + let tooltipValue = undefined; + if (props.colDef.valueGetter) { + value = props?.context?.network + ? props.colDef.valueGetter(props, props.context.network) + : props.colDef.valueGetter(props); } + if (value != null && props.colDef.numeric && props.colDef.fractionDigits) { // only numeric rounded cells have a tooltip (their raw numeric value) tooltipValue = value; @@ -159,6 +177,23 @@ export const DefaultCellRenderer = (props: any) => { ); }; +export const DefaultSpreadsheetCellRenderer = (params: any) => { + return ( + + + + + + ); +}; + export const MessageLogCellRenderer = ({ param, highlightColor, diff --git a/src/components/spreadsheet/utils/constants.ts b/src/components/spreadsheet/utils/constants.ts index 23e8de1bc2..891fc31d1d 100644 --- a/src/components/spreadsheet/utils/constants.ts +++ b/src/components/spreadsheet/utils/constants.ts @@ -17,7 +17,27 @@ export const REORDERED_COLUMNS_PARAMETER_PREFIX_IN_DATABASE = 'reorderedColumns. export const TEXT_TYPE = 'textType'; export const NUMERIC_TYPE = 'numericType'; +export const NUMERIC_0_FRACTION_DIGITS_TYPE = 'numeric0FractionDigitsType'; +export const NUMERIC_1_FRACTION_DIGITS_TYPE = 'numeric1FractionDigitsType'; +export const NUMERIC_2_FRACTION_DIGITS_TYPE = 'numeric2FractionDigitsType'; +export const NUMERIC_5_FRACTION_DIGITS_TYPE = 'numeric5FractionDigitsType'; +export const NUMERIC_UNIT_TO_MICRO_UNIT_TYPE = 'numericUnitToMicroUnitType'; +export const NUMERIC_UNIT_TO_KILO_UNIT_TYPE = 'numericUnitToKiloUnitType'; + +export const NUMERIC_APPLY_FLUX_CONVENTION_TYPE = 'numericApplyFluxConventionType'; +export const NUMERIC_APPLY_FLUX_CONVENTION_1_FRACTION_DIGITS_TYPE = 'numericApplyFluxConvention1FractionDigitsType'; +export const NUMERIC_APPLY_FLUX_CONVENTION_2_FRACTION_DIGITS_TYPE = 'numericApplyFluxConvention2FractionDigitsType'; +export const NUMERIC_APPLY_FLUX_CONVENTION_5_FRACTION_DIGITS_TYPE = 'numericApplyFluxConvention5FractionDigitsType'; + export const NUMERIC_CAN_BE_INVALIDATED_TYPE = 'numericCanBeInvalidatedType'; export const ENUM_TYPE = 'enumType'; export const BOOLEAN_TYPE = 'booleanType'; export const COUNTRY_TYPE = 'countryType'; +export const ENERGY_SOURCE_ENUM_TYPE = 'energySourceEnumType'; +export const REGULATION_ENUM_TYPE = 'regulationEnumType'; +export const LOAD_ENUM_TYPE = 'loadEnumType'; +export const SHUNT_COMPENSATOR_ENUM_TYPE = 'shuntCompensatorEnumType'; +export const RATIO_REGULATION_MODES_ENUM_TYPE = 'ratioRegulationModesEnumType'; +export const SIDE_ENUM_TYPE = 'sideEnumType'; +export const PHASE_REGULATING_MODE_ENUM_TYPE = 'phaseRegulatingModeEnumType'; +export const NUMERIC_HIGH_TAP_POSITION_TYPE = 'numericHighTapPositionType'; From 256d488d172aac84feb47a04f39eedd7e2b92096 Mon Sep 17 00:00:00 2001 From: TOURI ANIS Date: Fri, 20 Dec 2024 16:57:06 +0100 Subject: [PATCH 10/10] remove valueGetter --- .../config/column-type-filter-config.ts | 27 ++++++++++++++++++- .../spreadsheet/config/equipment/battery.ts | 1 - .../spreadsheet/config/equipment/generator.ts | 15 ++--------- .../config/equipment/shunt-compensator.ts | 11 ++++---- .../equipment/three-windings-transformer.ts | 18 +++++-------- .../equipment/two-windings-transformer.ts | 25 +++-------------- src/components/spreadsheet/utils/constants.ts | 2 ++ 7 files changed, 45 insertions(+), 54 deletions(-) diff --git a/src/components/spreadsheet/config/column-type-filter-config.ts b/src/components/spreadsheet/config/column-type-filter-config.ts index ce6ca3476b..1c3b637ab2 100644 --- a/src/components/spreadsheet/config/column-type-filter-config.ts +++ b/src/components/spreadsheet/config/column-type-filter-config.ts @@ -22,6 +22,7 @@ import { SIDE, } from 'components/network/constants'; import { unitToKiloUnit, unitToMicroUnit } from 'utils/unit-converter'; +import { RegulatingTerminalCellGetter } from './equipment/generator'; const TEXT_FILTER_PARAMS = { caseSensitive: false, @@ -99,7 +100,16 @@ const propertyType = createTextColumnType(PropertiesCellRenderer, propertiesGett const getNumericType = (fractionDigits?: number) => createNumericColumnType((params) => { - const value = params.data[params?.colDef?.field!]; + let value = params.data[params?.colDef?.field!]; + if (params?.colDef?.field === 'coordinatedReactiveControl.qPercent') { + value = isNaN(value) ? 0 : value; + } + if (params?.colDef?.field === 'generatorShortCircuit.directTransX') { + value = value || 0; + } + if (params?.colDef?.field === 'RegulatingTerminalGenerator') { + return RegulatingTerminalCellGetter; + } return fractionDigits ? formatCellValue(value, fractionDigits) : value; }); @@ -118,6 +128,19 @@ const numericUnitToKiloUnitType = createNumericUnitConversionType(unitToKiloUnit const numericHighTapPositionType = createNumericColumnType((params) => computeHighTapPosition(params.data[params?.colDef?.field!]?.steps) ); +const numericSwitchedOnSusceptanceType = createNumericColumnType((params) => { + return formatCellValue( + (params?.data?.maxSusceptance / params?.data?.maximumSectionCount) * params?.data?.sectionCount, + 5 + ); +}); + +const numericSwitchedOnQAtNominalVType = createNumericColumnType((params) => { + return formatCellValue( + (params?.data?.maxQAtNominalV / params?.data?.maximumSectionCount) * params?.data?.sectionCount, + 5 + ); +}); const getNumericApplyFluxConventionType = (fractionDigits?: number) => createNumericColumnType((params) => { @@ -180,4 +203,6 @@ export const defaultColumnType = { ratioRegulationModesEnumType, sideEnumType, phaseRegulatingModeEnumType, + numericSwitchedOnSusceptanceType, + numericSwitchedOnQAtNominalVType, }; diff --git a/src/components/spreadsheet/config/equipment/battery.ts b/src/components/spreadsheet/config/equipment/battery.ts index 3e0f7f9321..822474dba1 100644 --- a/src/components/spreadsheet/config/equipment/battery.ts +++ b/src/components/spreadsheet/config/equipment/battery.ts @@ -87,7 +87,6 @@ export const BATTERY_TAB_DEF = { type: NUMERIC_1_FRACTION_DIGITS_TYPE, ...editableColumnConfig, ...numericalCellEditorConfig((params) => params.data.activePowerControl?.droop), - valueGetter: (params) => params.data?.activePowerControl?.droop, valueSetter: (params) => { params.data.activePowerControl = { ...(params.data.activePowerControl || {}), diff --git a/src/components/spreadsheet/config/equipment/generator.ts b/src/components/spreadsheet/config/equipment/generator.ts index 1e6024399b..b805dee88c 100644 --- a/src/components/spreadsheet/config/equipment/generator.ts +++ b/src/components/spreadsheet/config/equipment/generator.ts @@ -36,7 +36,7 @@ import { } from '../common/cell-editors'; import { SortWay } from 'hooks/use-aggrid-sort'; -const RegulatingTerminalCellGetter: ValueGetterFunc = (params) => { +export const RegulatingTerminalCellGetter: ValueGetterFunc = (params) => { const { regulatingTerminalConnectableId, regulatingTerminalVlId, regulatingTerminalConnectableType } = params?.data || {}; @@ -136,7 +136,6 @@ export const GENERATOR_TAB_DEF = { type: NUMERIC_1_FRACTION_DIGITS_TYPE, ...editableColumnConfig, ...numericalCellEditorConfig((params) => params.data.activePowerControl?.droop), - valueGetter: (params) => params.data?.activePowerControl?.droop, valueSetter: (params) => { params.data.activePowerControl = { ...(params.data.activePowerControl || {}), @@ -234,10 +233,7 @@ export const GENERATOR_TAB_DEF = { const qPercent = params.data?.coordinatedReactiveControl?.qPercent; return isNaN(qPercent) ? 0 : qPercent; }), - valueGetter: (params) => { - const qPercent = params.data?.coordinatedReactiveControl?.qPercent; - return isNaN(qPercent) ? 0 : qPercent; - }, + valueSetter: (params) => { params.data.coordinatedReactiveControl = { ...params.data.coordinatedReactiveControl, @@ -256,7 +252,6 @@ export const GENERATOR_TAB_DEF = { getQuickFilterText: excludeFromGlobalFilter, ...editableColumnConfig, ...numericalCellEditorConfig((params) => params.data?.generatorShortCircuit?.directTransX || 0), - valueGetter: (params) => params.data?.generatorShortCircuit?.directTransX, valueSetter: (params) => { params.data.generatorShortCircuit = { ...params.data.generatorShortCircuit, @@ -275,7 +270,6 @@ export const GENERATOR_TAB_DEF = { getQuickFilterText: excludeFromGlobalFilter, ...editableColumnConfig, ...numericalCellEditorConfig((params) => params.data?.generatorShortCircuit?.stepUpTransformerX || 0), - valueGetter: (params) => params.data?.generatorShortCircuit?.stepUpTransformerX, valueSetter: (params) => { params.data.generatorShortCircuit = { ...params.data.generatorShortCircuit, @@ -294,7 +288,6 @@ export const GENERATOR_TAB_DEF = { getQuickFilterText: excludeFromGlobalFilter, ...editableColumnConfig, ...numericalCellEditorConfig((params) => params.data?.generatorStartup?.plannedActivePowerSetPoint), - valueGetter: (params) => params.data?.generatorStartup?.plannedActivePowerSetPoint, valueSetter: (params) => { params.data.generatorStartup = { ...params.data?.generatorStartup, @@ -313,7 +306,6 @@ export const GENERATOR_TAB_DEF = { ...numericalCellEditorConfig((params) => params.data?.generatorStartup?.marginalCost), type: NUMERIC_1_FRACTION_DIGITS_TYPE, getQuickFilterText: excludeFromGlobalFilter, - valueGetter: (params) => params.data?.generatorStartup?.marginalCost, valueSetter: (params) => { params.data.generatorStartup = { ...params.data?.generatorStartup, @@ -337,7 +329,6 @@ export const GENERATOR_TAB_DEF = { maxExpression: 1, minExpression: 0, }, - valueGetter: (params) => params.data?.generatorStartup?.plannedOutageRate, valueSetter: (params) => { params.data.generatorStartup = { ...params.data?.generatorStartup, @@ -358,7 +349,6 @@ export const GENERATOR_TAB_DEF = { maxExpression: 1, minExpression: 0, }, - valueGetter: (params) => params.data?.generatorStartup?.forcedOutageRate, valueSetter: (params) => { params.data.generatorStartup = { ...params.data?.generatorStartup, @@ -384,7 +374,6 @@ export const GENERATOR_TAB_DEF = { id: 'RegulatingTerminalGenerator', field: 'RegulatingTerminalGenerator', type: TEXT_TYPE, - valueGetter: RegulatingTerminalCellGetter, cellStyle: (params) => (isEditableRegulatingTerminalCell(params) ? editableCellStyle(params) : {}), editable: isEditableRegulatingTerminalCell, crossValidation: { diff --git a/src/components/spreadsheet/config/equipment/shunt-compensator.ts b/src/components/spreadsheet/config/equipment/shunt-compensator.ts index f38260f370..9fb5623041 100644 --- a/src/components/spreadsheet/config/equipment/shunt-compensator.ts +++ b/src/components/spreadsheet/config/equipment/shunt-compensator.ts @@ -18,6 +18,8 @@ import { NUMERIC_1_FRACTION_DIGITS_TYPE, NUMERIC_5_FRACTION_DIGITS_TYPE, NUMERIC_CAN_BE_INVALIDATED_TYPE, + NUMERIC_SWITCHED_ON_Q_AT_NOMINAL_V_TYPE, + NUMERIC_SWITCHED_ON_SUSCEPTANCE_TYPE, NUMERIC_TYPE, SHUNT_COMPENSATOR_ENUM_TYPE, TEXT_TYPE, @@ -111,9 +113,7 @@ export const SHUNT_COMPENSATOR_TAB_DEF = { { id: 'SwitchedOnMaxQAtNominalV', field: 'switchedOnQAtNominalV', - valueGetter: (params) => - (params?.data?.maxQAtNominalV / params?.data?.maximumSectionCount) * params?.data?.sectionCount, - type: NUMERIC_0_FRACTION_DIGITS_TYPE, + type: NUMERIC_SWITCHED_ON_Q_AT_NOMINAL_V_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, { @@ -127,9 +127,8 @@ export const SHUNT_COMPENSATOR_TAB_DEF = { { id: 'SwitchedOnMaxSusceptance', field: 'switchedOnSusceptance', - valueGetter: (params) => - (params?.data?.maxSusceptance / params?.data?.maximumSectionCount) * params?.data?.sectionCount, - type: NUMERIC_5_FRACTION_DIGITS_TYPE, + + type: NUMERIC_SWITCHED_ON_SUSCEPTANCE_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, { diff --git a/src/components/spreadsheet/config/equipment/three-windings-transformer.ts b/src/components/spreadsheet/config/equipment/three-windings-transformer.ts index 5c25e25b72..288c81dca6 100644 --- a/src/components/spreadsheet/config/equipment/three-windings-transformer.ts +++ b/src/components/spreadsheet/config/equipment/three-windings-transformer.ts @@ -149,11 +149,10 @@ export const THREE_WINDINGS_TRANSFORMER_TAB_DEF = { }, { id: 'RatioTap1', - field: 'ratioTapChanger1', + field: 'ratioTapChanger1.tapPosition', type: NUMERIC_TYPE, changeCmd: generateTapRequest('Ratio', 1), fractionDigits: 0, - valueGetter: (params) => params?.data?.ratioTapChanger1?.tapPosition, valueSetter: (params) => { params.data.ratioTapChanger1 = { ...params.data.ratioTapChanger1, @@ -185,11 +184,10 @@ export const THREE_WINDINGS_TRANSFORMER_TAB_DEF = { }, { id: 'RatioTap2', - field: 'ratioTapChanger2', + field: 'ratioTapChanger2.tapPosition', type: NUMERIC_TYPE, changeCmd: generateTapRequest('Ratio', 2), fractionDigits: 0, - valueGetter: (params) => params?.data?.ratioTapChanger2?.tapPosition, valueSetter: (params) => { params.data.ratioTapChanger2 = { ...params.data.ratioTapChanger2, @@ -221,10 +219,9 @@ export const THREE_WINDINGS_TRANSFORMER_TAB_DEF = { }, { id: 'RatioTap3', - field: 'ratioTapChanger3', + field: 'ratioTapChanger3.tapPosition', type: NUMERIC_1_FRACTION_DIGITS_TYPE, changeCmd: generateTapRequest('Ratio', 3), - valueGetter: (params) => params?.data?.ratioTapChanger3?.tapPosition, valueSetter: (params) => { params.data.ratioTapChanger3 = { ...params.data.ratioTapChanger3, @@ -251,10 +248,9 @@ export const THREE_WINDINGS_TRANSFORMER_TAB_DEF = { }, { id: 'PhaseTap1', - field: 'phaseTapChanger1', + field: 'phaseTapChanger1.tapPosition', type: NUMERIC_0_FRACTION_DIGITS_TYPE, changeCmd: generateTapRequest('Phase', 1), - valueGetter: (params) => params?.data?.phaseTapChanger1?.tapPosition, valueSetter: (params) => { params.data.phaseTapChanger1 = { ...params.data.phaseTapChanger1, @@ -288,10 +284,9 @@ export const THREE_WINDINGS_TRANSFORMER_TAB_DEF = { }, { id: 'PhaseTap2', - field: 'phaseTapChanger2', + field: 'phaseTapChanger2.tapPosition', type: NUMERIC_0_FRACTION_DIGITS_TYPE, changeCmd: generateTapRequest('Phase', 2), - valueGetter: (params) => params?.data?.phaseTapChanger2?.tapPosition, valueSetter: (params) => { params.data.phaseTapChanger2 = { ...params.data.phaseTapChanger2, @@ -325,10 +320,9 @@ export const THREE_WINDINGS_TRANSFORMER_TAB_DEF = { }, { id: 'PhaseTap3', - field: 'phaseTapChanger3', + field: 'phaseTapChanger3.tapPosition', type: NUMERIC_0_FRACTION_DIGITS_TYPE, changeCmd: generateTapRequest('Phase', 3), - valueGetter: (params) => params?.data?.phaseTapChanger3?.tapPosition, valueSetter: (params) => { params.data.phaseTapChanger3 = { ...params.data.phaseTapChanger3, diff --git a/src/components/spreadsheet/config/equipment/two-windings-transformer.ts b/src/components/spreadsheet/config/equipment/two-windings-transformer.ts index 8dadd24d91..9c8490e1f8 100644 --- a/src/components/spreadsheet/config/equipment/two-windings-transformer.ts +++ b/src/components/spreadsheet/config/equipment/two-windings-transformer.ts @@ -36,8 +36,6 @@ import { TEXT_TYPE, } from '../../utils/constants'; import { PHASE_REGULATION_MODES, RATIO_REGULATION_MODES, REGULATION_TYPES, SIDE } from '../../../network/constants'; -import { computeHighTapPosition, getTapChangerRegulationTerminalValue } from '../../../utils/utils'; -import { unitToMicroUnit } from '../../../../utils/unit-converter'; import { getComputedRegulationMode } from '../../../dialogs/network-modifications/two-windings-transformer/tap-changer-pane/ratio-tap-changer-pane/ratio-tap-changer-pane-utils'; import { genericColumnOfPropertiesEditPopup } from '../common/column-properties'; import { @@ -193,7 +191,6 @@ export const TWO_WINDINGS_TRANSFORMER_TAB_DEF = { { id: 'HasLoadTapChangingCapabilities', field: 'ratioTapChanger.hasLoadTapChangingCapabilities', - valueGetter: (params) => params?.data?.ratioTapChanger?.hasLoadTapChangingCapabilities, type: BOOLEAN_TYPE, editable: (params) => isEditable(params) && hasTwtRatioTapChanger(params), cellStyle: editableCellStyle, @@ -215,7 +212,6 @@ export const TWO_WINDINGS_TRANSFORMER_TAB_DEF = { { id: 'RatioRegulationMode', field: 'ratioTapChanger.regulationMode', - valueGetter: (params) => params.data?.ratioTapChanger?.regulationMode, valueSetter: (params) => { params.data.ratioTapChanger = { ...(params.data?.ratioTapChanger || {}), @@ -274,7 +270,6 @@ export const TWO_WINDINGS_TRANSFORMER_TAB_DEF = { { id: 'RatioRegulationTypeText', field: 'ratioTapChanger.regulationType', - valueGetter: (params) => params.data?.ratioTapChanger?.regulationType, valueSetter: (params) => { params.data.ratioTapChanger = { ...(params.data?.ratioTapChanger || {}), @@ -296,7 +291,6 @@ export const TWO_WINDINGS_TRANSFORMER_TAB_DEF = { id: 'RatioRegulatedSide', field: 'ratioTapChanger.regulationSide', type: SIDE_ENUM_TYPE, - valueGetter: (params) => params.data?.ratioTapChanger?.regulationSide, valueSetter: (params) => { params.data.ratioTapChanger = { ...(params.data?.ratioTapChanger || {}), @@ -319,7 +313,6 @@ export const TWO_WINDINGS_TRANSFORMER_TAB_DEF = { id: 'RatioRegulatingTerminal', field: 'ratioTapChanger.ratioRegulatingTerminal', type: NUMERIC_TYPE, - valueGetter: (params) => params.data?.ratioTapChanger?.ratioRegulatingTerminal, columnWidth: MEDIUM_COLUMN_WIDTH, getQuickFilterText: excludeFromGlobalFilter, cellStyle: (params) => (isEditableTwtRatioRegulatingTerminalCell(params) ? editableCellStyle(params) : {}), @@ -355,18 +348,14 @@ export const TWO_WINDINGS_TRANSFORMER_TAB_DEF = { }, { id: 'RatioHighTapPosition', - field: 'ratioTapChanger.highTapPosition', - type: NUMERIC_TYPE, - valueGetter: (params) => computeHighTapPosition(params?.data?.ratioTapChanger?.steps), + field: 'ratioTapChanger', + type: NUMERIC_HIGH_TAP_POSITION_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, { id: 'RatioTap', field: 'ratioTapChanger.tapPosition', - type: NUMERIC_TYPE, - numeric: true, - fractionDigits: 0, - valueGetter: (params) => params?.data?.ratioTapChanger?.tapPosition, + type: NUMERIC_0_FRACTION_DIGITS_TYPE, valueSetter: (params) => { params.data.ratioTapChanger = { ...params.data.ratioTapChanger, @@ -389,7 +378,6 @@ export const TWO_WINDINGS_TRANSFORMER_TAB_DEF = { id: 'RegulatingMode', field: 'phaseTapChanger.regulationMode', type: PHASE_REGULATING_MODE_ENUM_TYPE, - valueGetter: (params) => params?.data?.phaseTapChanger?.regulationMode, valueSetter: (params) => { params.data.phaseTapChanger = { ...(params.data?.phaseTapChanger || {}), @@ -412,7 +400,6 @@ export const TWO_WINDINGS_TRANSFORMER_TAB_DEF = { type: NUMERIC_TYPE, columnWidth: MEDIUM_COLUMN_WIDTH, fractionDigits: 1, - valueGetter: (params) => params?.data?.phaseTapChanger?.regulationValue, getQuickFilterText: excludeFromGlobalFilter, editable: (params) => hasTwtPhaseTapChangerAndEditable(params) && @@ -450,7 +437,6 @@ export const TWO_WINDINGS_TRANSFORMER_TAB_DEF = { id: 'PhaseRegulationTypeText', field: 'phaseTapChanger.regulationType', type: REGULATION_ENUM_TYPE, - valueGetter: (params) => params.data?.phaseTapChanger?.regulationType, valueSetter: (params) => { params.data.phaseTapChanger = { ...(params.data?.phaseTapChanger || {}), @@ -471,7 +457,6 @@ export const TWO_WINDINGS_TRANSFORMER_TAB_DEF = { id: 'PhaseRegulatedSide', field: 'phaseTapChanger.regulationSide', type: SIDE_ENUM_TYPE, - valueGetter: (params) => params.data?.phaseTapChanger?.regulationSide, valueSetter: (params) => { params.data.phaseTapChanger = { ...(params.data?.phaseTapChanger || {}), @@ -494,7 +479,6 @@ export const TWO_WINDINGS_TRANSFORMER_TAB_DEF = { id: 'PhaseRegulatingTerminal', field: 'phaseTapChanger.phaseRegulatingTerminal', type: TEXT_TYPE, - valueGetter: (params) => params.data?.phaseTapChanger?.phaseRegulatingTerminal, columnWidth: MEDIUM_COLUMN_WIDTH, getQuickFilterText: excludeFromGlobalFilter, cellStyle: (params) => (isEditableTwtPhaseRegulatingTerminalCell(params) ? editableCellStyle(params) : {}), @@ -532,7 +516,7 @@ export const TWO_WINDINGS_TRANSFORMER_TAB_DEF = { }, { id: 'PhaseHighTapPosition', - field: 'phaseTapChanger.highTapPosition', + field: 'phaseTapChanger', type: NUMERIC_HIGH_TAP_POSITION_TYPE, getQuickFilterText: excludeFromGlobalFilter, }, @@ -540,7 +524,6 @@ export const TWO_WINDINGS_TRANSFORMER_TAB_DEF = { id: 'PhaseTap', field: 'phaseTapChanger.tapPosition', type: NUMERIC_0_FRACTION_DIGITS_TYPE, - valueGetter: (params) => params?.data?.phaseTapChanger?.tapPosition, valueSetter: (params) => { params.data.phaseTapChanger = { ...params.data.phaseTapChanger, diff --git a/src/components/spreadsheet/utils/constants.ts b/src/components/spreadsheet/utils/constants.ts index 891fc31d1d..fcbe9d56b5 100644 --- a/src/components/spreadsheet/utils/constants.ts +++ b/src/components/spreadsheet/utils/constants.ts @@ -41,3 +41,5 @@ export const RATIO_REGULATION_MODES_ENUM_TYPE = 'ratioRegulationModesEnumType'; export const SIDE_ENUM_TYPE = 'sideEnumType'; export const PHASE_REGULATING_MODE_ENUM_TYPE = 'phaseRegulatingModeEnumType'; export const NUMERIC_HIGH_TAP_POSITION_TYPE = 'numericHighTapPositionType'; +export const NUMERIC_SWITCHED_ON_SUSCEPTANCE_TYPE = 'numericSwitchedOnSusceptanceType'; +export const NUMERIC_SWITCHED_ON_Q_AT_NOMINAL_V_TYPE = 'numericSwitchedOnQAtNominalVType';