From 08436feb88e8382f63f59860acd76f3c7a821ce8 Mon Sep 17 00:00:00 2001 From: Rehili Ghazwa Date: Sat, 7 Feb 2026 20:10:17 +0100 Subject: [PATCH 1/4] add regulationTypeText to prefilled columns config spreadsheet --- .../tabular/generation/prefillable-columns-config.ts | 6 ++++++ .../tabular/generation/utils.ts | 4 ++-- src/components/utils/field-constants.ts | 1 + src/redux/reducer.ts | 1 + src/utils/spreadsheet-equipments-mapper.ts | 12 ------------ 5 files changed, 10 insertions(+), 14 deletions(-) diff --git a/src/components/dialogs/network-modifications/tabular/generation/prefillable-columns-config.ts b/src/components/dialogs/network-modifications/tabular/generation/prefillable-columns-config.ts index 6a44d46906..745b7d2ba8 100644 --- a/src/components/dialogs/network-modifications/tabular/generation/prefillable-columns-config.ts +++ b/src/components/dialogs/network-modifications/tabular/generation/prefillable-columns-config.ts @@ -75,6 +75,7 @@ import { REACTIVE_CAPABILITY_CURVE_P_MAX, REACTIVE_CAPABILITY_CURVE_Q_MIN_P_MAX, REACTIVE_CAPABILITY_CURVE_Q_MAX_P_MAX, + REGULATION_TYPE_TEXT, } from 'components/utils/field-constants'; /** @@ -348,6 +349,11 @@ export const PREFILLED_COLUMNS_CONFIG: Record = csvColumns: [TARGET_V], networkFields: ['targetV'], }, + { + labelId: REGULATION_TYPE_TEXT, + csvColumns: [REGULATION_TYPE_TEXT], + networkFields: ['regulationTypeText'], + }, { labelId: REGULATING_TERMINAL_ID, csvColumns: [REGULATING_TERMINAL_ID], diff --git a/src/components/dialogs/network-modifications/tabular/generation/utils.ts b/src/components/dialogs/network-modifications/tabular/generation/utils.ts index dab84e3ccf..12ab69ca11 100644 --- a/src/components/dialogs/network-modifications/tabular/generation/utils.ts +++ b/src/components/dialogs/network-modifications/tabular/generation/utils.ts @@ -22,7 +22,7 @@ import { REACTIVE_CAPABILITY_CURVE_Q_MIN_P_MAX, REACTIVE_CAPABILITY_CURVE_Q_MIN_P_MIN, } from 'components/utils/field-constants'; -import { mapGeneratorDataForTable, mapTwtDataForTable } from 'utils/spreadsheet-equipments-mapper'; +import { mapTwtDataForTable } from 'utils/spreadsheet-equipments-mapper'; export const styles = { dialogContent: { @@ -188,7 +188,7 @@ export const mapPrefilledEquipments = (equipmentType: EQUIPMENT_TYPES, equipment case EQUIPMENT_TYPES.TWO_WINDINGS_TRANSFORMER: return equipments.map(mapTwtDataForTable); case EQUIPMENT_TYPES.GENERATOR: - return equipments.map((eq) => mapReactiveCapabilityCurvePointsToFormFields(mapGeneratorDataForTable(eq))); + return equipments.map((eq) => mapReactiveCapabilityCurvePointsToFormFields(eq)); case EQUIPMENT_TYPES.SHUNT_COMPENSATOR: return equipments.map(mapShuntCompensatorToFormFields); case EQUIPMENT_TYPES.BATTERY: diff --git a/src/components/utils/field-constants.ts b/src/components/utils/field-constants.ts index 32b0d3a41b..dbc2e08029 100644 --- a/src/components/utils/field-constants.ts +++ b/src/components/utils/field-constants.ts @@ -285,6 +285,7 @@ export const ACTIVATED = 'activated'; //generator export const VOLTAGE_REGULATION_ON = 'voltageRegulationOn'; export const STEP_UP_TRANSFORMER_REACTANCE = 'stepUpTransformerX'; +export const REGULATION_TYPE_TEXT = 'regulationTypeText'; export const REGULATING_TERMINAL_ID = 'regulatingTerminalId'; export const REGULATING_TERMINAL_VOLTAGE_LEVEL_ID = 'regulatingTerminalVlId'; export const REGULATING_TERMINAL_TYPE = 'regulatingTerminalType'; diff --git a/src/redux/reducer.ts b/src/redux/reducer.ts index 3f66aa3e30..2482e75257 100644 --- a/src/redux/reducer.ts +++ b/src/redux/reducer.ts @@ -1534,6 +1534,7 @@ export const reducer = createReducer(initialState, (builder) => { switch (action.equipmentType) { case SpreadsheetEquipmentType.GENERATOR: propsToClean = { + regulationTypeText: undefined, regulatingTerminalVlName: undefined, regulatingTerminalConnectableId: undefined, regulatingTerminalConnectableType: undefined, diff --git a/src/utils/spreadsheet-equipments-mapper.ts b/src/utils/spreadsheet-equipments-mapper.ts index 7b72e8d813..bab88bbf36 100644 --- a/src/utils/spreadsheet-equipments-mapper.ts +++ b/src/utils/spreadsheet-equipments-mapper.ts @@ -74,16 +74,6 @@ export const mapPhaseTapChanger = (twt: any) => { export const mapTwtDataForTable = (twt: any) => mapPhaseTapChanger(mapRatioTapChanger(twt)); -export const mapGeneratorDataForTable = (generator: any) => { - const formattedGenerator = { ...generator }; - const hasDistantRegulation = - formattedGenerator.regulatingTerminalVlId || formattedGenerator.regulatingTerminalConnectableId; - formattedGenerator.RegulationTypeText = - formattedGenerator.RegulationTypeText || - (hasDistantRegulation ? REGULATION_TYPES.DISTANT.id : REGULATION_TYPES.LOCAL.id); - return formattedGenerator; -}; - export const mapShuntCompensatorDataForTable = (shuntCompensator: any) => { const formattedCompensator = { ...shuntCompensator }; @@ -102,8 +92,6 @@ const mapSpreadsheetEquipment = (equipmentType: SpreadsheetEquipmentType, equipm case SpreadsheetEquipmentType.TWO_WINDINGS_TRANSFORMER: case SpreadsheetEquipmentType.BRANCH: // can do it because mappers test if field present before modifying return mapTwtDataForTable(equipment); - case SpreadsheetEquipmentType.GENERATOR: - return mapGeneratorDataForTable(equipment); case SpreadsheetEquipmentType.SHUNT_COMPENSATOR: return mapShuntCompensatorDataForTable(equipment); default: From 8a90453dc02f445a383725acdc32c2e99dc1155b Mon Sep 17 00:00:00 2001 From: Rehili Ghazwa Date: Tue, 10 Feb 2026 15:50:22 +0100 Subject: [PATCH 2/4] code review remarks --- .../network-modifications/tabular/generation/utils.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/components/dialogs/network-modifications/tabular/generation/utils.ts b/src/components/dialogs/network-modifications/tabular/generation/utils.ts index 12ab69ca11..2426e041e6 100644 --- a/src/components/dialogs/network-modifications/tabular/generation/utils.ts +++ b/src/components/dialogs/network-modifications/tabular/generation/utils.ts @@ -4,7 +4,7 @@ * 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 { Identifiable, yupConfig as yup, type MuiStyles, type UseStateBooleanReturn } from '@gridsuite/commons-ui'; +import { Identifiable, type MuiStyles, type UseStateBooleanReturn, yupConfig as yup } from '@gridsuite/commons-ui'; import { ReactiveCapabilityCurvePoints } from 'components/dialogs/reactive-limits/reactive-limits.type'; import { SHUNT_COMPENSATOR_TYPES } from 'components/network/constants'; import { EQUIPMENT_TYPES } from 'components/utils/equipment-types'; @@ -187,10 +187,9 @@ export const mapPrefilledEquipments = (equipmentType: EQUIPMENT_TYPES, equipment switch (equipmentType) { case EQUIPMENT_TYPES.TWO_WINDINGS_TRANSFORMER: return equipments.map(mapTwtDataForTable); - case EQUIPMENT_TYPES.GENERATOR: - return equipments.map((eq) => mapReactiveCapabilityCurvePointsToFormFields(eq)); case EQUIPMENT_TYPES.SHUNT_COMPENSATOR: return equipments.map(mapShuntCompensatorToFormFields); + case EQUIPMENT_TYPES.GENERATOR: case EQUIPMENT_TYPES.BATTERY: return equipments.map(mapReactiveCapabilityCurvePointsToFormFields); default: From 0270813c6342ecba04c0a739ce52a4c8f31cf394 Mon Sep 17 00:00:00 2001 From: Rehili Ghazwa Date: Wed, 11 Feb 2026 08:52:19 +0100 Subject: [PATCH 3/4] rename to regulationType --- .../tabular/generation/prefillable-columns-config.ts | 8 ++++---- src/components/utils/field-constants.ts | 1 - 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/components/dialogs/network-modifications/tabular/generation/prefillable-columns-config.ts b/src/components/dialogs/network-modifications/tabular/generation/prefillable-columns-config.ts index 745b7d2ba8..d10ee00361 100644 --- a/src/components/dialogs/network-modifications/tabular/generation/prefillable-columns-config.ts +++ b/src/components/dialogs/network-modifications/tabular/generation/prefillable-columns-config.ts @@ -75,7 +75,7 @@ import { REACTIVE_CAPABILITY_CURVE_P_MAX, REACTIVE_CAPABILITY_CURVE_Q_MIN_P_MAX, REACTIVE_CAPABILITY_CURVE_Q_MAX_P_MAX, - REGULATION_TYPE_TEXT, + REGULATION_TYPE, } from 'components/utils/field-constants'; /** @@ -350,9 +350,9 @@ export const PREFILLED_COLUMNS_CONFIG: Record = networkFields: ['targetV'], }, { - labelId: REGULATION_TYPE_TEXT, - csvColumns: [REGULATION_TYPE_TEXT], - networkFields: ['regulationTypeText'], + labelId: REGULATION_TYPE, + csvColumns: [REGULATION_TYPE], + networkFields: ['regulationType'], }, { labelId: REGULATING_TERMINAL_ID, diff --git a/src/components/utils/field-constants.ts b/src/components/utils/field-constants.ts index dbc2e08029..32b0d3a41b 100644 --- a/src/components/utils/field-constants.ts +++ b/src/components/utils/field-constants.ts @@ -285,7 +285,6 @@ export const ACTIVATED = 'activated'; //generator export const VOLTAGE_REGULATION_ON = 'voltageRegulationOn'; export const STEP_UP_TRANSFORMER_REACTANCE = 'stepUpTransformerX'; -export const REGULATION_TYPE_TEXT = 'regulationTypeText'; export const REGULATING_TERMINAL_ID = 'regulatingTerminalId'; export const REGULATING_TERMINAL_VOLTAGE_LEVEL_ID = 'regulatingTerminalVlId'; export const REGULATING_TERMINAL_TYPE = 'regulatingTerminalType'; From 674f340bd34be499086114152da21faeaca5def1 Mon Sep 17 00:00:00 2001 From: Rehili Ghazwa Date: Wed, 11 Feb 2026 10:03:57 +0100 Subject: [PATCH 4/4] remove text from regulationtype --- src/redux/reducer.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/redux/reducer.ts b/src/redux/reducer.ts index 9a09e4666a..efcbbafd45 100644 --- a/src/redux/reducer.ts +++ b/src/redux/reducer.ts @@ -1517,7 +1517,7 @@ export const reducer = createReducer(initialState, (builder) => { switch (action.equipmentType) { case SpreadsheetEquipmentType.GENERATOR: propsToClean = { - regulationTypeText: undefined, + regulationType: undefined, regulatingTerminalVlName: undefined, regulatingTerminalConnectableId: undefined, regulatingTerminalConnectableType: undefined,