@gridsuite/commons-ui 0.255.0 → 0.256.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/composite/reactQueryBuilder/CustomReactQueryBuilder.js +7 -4
- package/dist/features/index.js +16 -0
- package/dist/features/network-modifications/battery/modification/BatteryDialogTabsContent.d.ts +5 -1
- package/dist/features/network-modifications/battery/modification/BatteryDialogTabsContent.js +50 -10
- package/dist/features/network-modifications/battery/modification/BatteryModificationForm.d.ts +5 -1
- package/dist/features/network-modifications/battery/modification/BatteryModificationForm.js +4 -2
- package/dist/features/network-modifications/battery/modification/batteryModification.types.d.ts +6 -0
- package/dist/features/network-modifications/battery/modification/batteryModification.utils.d.ts +32 -0
- package/dist/features/network-modifications/battery/modification/batteryModification.utils.js +21 -1
- package/dist/features/network-modifications/by-filter/formula/formula/formula-constants.d.ts +10 -0
- package/dist/features/network-modifications/by-filter/formula/formula/formula-constants.js +10 -0
- package/dist/features/network-modifications/by-filter/formula/formula/formula-form.d.ts +12 -0
- package/dist/features/network-modifications/by-filter/formula/formula/formula-form.js +139 -0
- package/dist/features/network-modifications/by-filter/formula/formula/formula-utils.d.ts +40 -0
- package/dist/features/network-modifications/by-filter/formula/formula/formula-utils.js +164 -0
- package/dist/features/network-modifications/by-filter/formula/formula/formula.type.d.ts +27 -0
- package/dist/features/network-modifications/by-filter/formula/formula/formula.type.js +1 -0
- package/dist/features/network-modifications/by-filter/formula/formula/reference-autocomplete-input.d.ts +15 -0
- package/dist/features/network-modifications/by-filter/formula/formula/reference-autocomplete-input.js +123 -0
- package/dist/features/network-modifications/by-filter/formula/index.d.ts +11 -0
- package/dist/features/network-modifications/by-filter/formula/index.js +18 -0
- package/dist/features/network-modifications/by-filter/formula/modification-by-formula-form.d.ts +1 -0
- package/dist/features/network-modifications/by-filter/formula/modification-by-formula-form.js +110 -0
- package/dist/features/network-modifications/by-filter/formula/modificationByFormula.utils.d.ts +32 -0
- package/dist/features/network-modifications/by-filter/formula/modificationByFormula.utils.js +126 -0
- package/dist/features/network-modifications/by-filter/index.d.ts +1 -0
- package/dist/features/network-modifications/by-filter/index.js +17 -1
- package/dist/features/network-modifications/common/voltageRegulation/VoltageRegulationForm.js +1 -1
- package/dist/features/network-modifications/index.js +16 -0
- package/dist/index.js +16 -0
- package/dist/translations/en/networkModificationsEn.d.ts +13 -0
- package/dist/translations/en/networkModificationsEn.js +13 -0
- package/dist/translations/fr/networkModificationsFr.d.ts +13 -0
- package/dist/translations/fr/networkModificationsFr.js +13 -0
- package/dist/utils/constants/fieldConstants.d.ts +1 -0
- package/dist/utils/constants/fieldConstants.js +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import * as yup from "yup";
|
|
2
|
+
import { OHM, MICRO_SIEMENS, KILO_VOLT, MEGA_VOLT_AMPERE, MEGA_WATT, MEGA_VAR, KILO_AMPERE, SIEMENS, PERCENTAGE } from "../../../../../utils/constants/unitsConstants.js";
|
|
3
|
+
import { FieldConstants } from "../../../../../utils/constants/fieldConstants.js";
|
|
4
|
+
import { FILTERS } from "../../../../../utils/constants/filterConstant.js";
|
|
5
|
+
import { YUP_REQUIRED } from "../../../../../utils/constants/translationKeys.js";
|
|
6
|
+
import "../../../../../utils/conversionUtils.js";
|
|
7
|
+
import { EquipmentType } from "../../../../../utils/types/equipmentType.js";
|
|
8
|
+
import "react/jsx-runtime";
|
|
9
|
+
import "@mui/icons-material";
|
|
10
|
+
import { REFERENCE_FIELD_OR_VALUE_2, OPERATOR, REFERENCE_FIELD_OR_VALUE_1 } from "./formula-constants.js";
|
|
11
|
+
const EQUIPMENTS_FIELDS = {
|
|
12
|
+
[EquipmentType.GENERATOR]: [
|
|
13
|
+
{ id: "RATED_NOMINAL_POWER", label: "RatedNominalPowerText", unit: MEGA_WATT },
|
|
14
|
+
{ id: "MINIMUM_ACTIVE_POWER", label: "MinimumActivePowerText", unit: MEGA_WATT },
|
|
15
|
+
{ id: "MAXIMUM_ACTIVE_POWER", label: "MaximumActivePowerText", unit: MEGA_WATT },
|
|
16
|
+
{ id: "ACTIVE_POWER_SET_POINT", label: "ActivePowerSetPointText", unit: MEGA_WATT },
|
|
17
|
+
{ id: "REACTIVE_POWER_SET_POINT", label: "ReactivePowerSetPointText", unit: MEGA_VAR },
|
|
18
|
+
{ id: "VOLTAGE_SET_POINT", label: "GeneratorTargetV", unit: KILO_VOLT },
|
|
19
|
+
{
|
|
20
|
+
id: "PLANNED_ACTIVE_POWER_SET_POINT",
|
|
21
|
+
label: "PlannedActivePowerSetPointForm",
|
|
22
|
+
unit: MEGA_WATT
|
|
23
|
+
},
|
|
24
|
+
{ id: "MARGINAL_COST", label: "MarginalCost" },
|
|
25
|
+
{ id: "PLANNED_OUTAGE_RATE", label: "plannedOutageRate" },
|
|
26
|
+
{ id: "FORCED_OUTAGE_RATE", label: "forcedOutageRate" },
|
|
27
|
+
{ id: "DROOP", label: "ActivePowerRegulationDroop", unit: PERCENTAGE },
|
|
28
|
+
{ id: "TRANSIENT_REACTANCE", label: "TransientReactanceForm", unit: OHM },
|
|
29
|
+
{
|
|
30
|
+
id: "STEP_UP_TRANSFORMER_REACTANCE",
|
|
31
|
+
label: "TransformerReactanceForm",
|
|
32
|
+
unit: OHM
|
|
33
|
+
},
|
|
34
|
+
{ id: "Q_PERCENT", label: "ReactivePercentageVoltageRegulation", unit: PERCENTAGE }
|
|
35
|
+
],
|
|
36
|
+
[EquipmentType.BATTERY]: [
|
|
37
|
+
{ id: "MINIMUM_ACTIVE_POWER", label: "MinimumActivePowerText", unit: MEGA_WATT },
|
|
38
|
+
{ id: "MAXIMUM_ACTIVE_POWER", label: "MaximumActivePowerText", unit: MEGA_WATT },
|
|
39
|
+
{ id: "ACTIVE_POWER_SET_POINT", label: "ActivePowerSetPointText", unit: MEGA_WATT },
|
|
40
|
+
{ id: "REACTIVE_POWER_SET_POINT", label: "ReactivePowerSetPointText", unit: MEGA_VAR },
|
|
41
|
+
{ id: "DROOP", label: "Droop", unit: PERCENTAGE },
|
|
42
|
+
{ id: "TRANSIENT_REACTANCE", label: "TransientReactanceForm", unit: OHM },
|
|
43
|
+
{
|
|
44
|
+
id: "STEP_UP_TRANSFORMER_REACTANCE",
|
|
45
|
+
label: "TransformerReactanceForm",
|
|
46
|
+
unit: OHM
|
|
47
|
+
}
|
|
48
|
+
],
|
|
49
|
+
[EquipmentType.SHUNT_COMPENSATOR]: [
|
|
50
|
+
{ id: "MAXIMUM_SECTION_COUNT", label: "maximumSectionCount" },
|
|
51
|
+
{ id: "SECTION_COUNT", label: "sectionCount" },
|
|
52
|
+
{ id: "MAX_SUSCEPTANCE", label: "maxSusceptance", unit: SIEMENS },
|
|
53
|
+
{ id: "MAX_Q_AT_NOMINAL_V", label: "maxQAtNominalV", unit: MEGA_VAR }
|
|
54
|
+
],
|
|
55
|
+
[EquipmentType.VOLTAGE_LEVEL]: [
|
|
56
|
+
{ id: "NOMINAL_VOLTAGE", label: "NominalVoltage", unit: KILO_VOLT },
|
|
57
|
+
{ id: "LOW_VOLTAGE_LIMIT", label: "LowVoltageLimit", unit: KILO_VOLT },
|
|
58
|
+
{ id: "HIGH_VOLTAGE_LIMIT", label: "HighVoltageLimit", unit: KILO_VOLT },
|
|
59
|
+
{
|
|
60
|
+
id: "LOW_SHORT_CIRCUIT_CURRENT_LIMIT",
|
|
61
|
+
label: "LowShortCircuitCurrentLimit",
|
|
62
|
+
unit: KILO_AMPERE
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
id: "HIGH_SHORT_CIRCUIT_CURRENT_LIMIT",
|
|
66
|
+
label: "HighShortCircuitCurrentLimit",
|
|
67
|
+
unit: KILO_AMPERE
|
|
68
|
+
}
|
|
69
|
+
],
|
|
70
|
+
[EquipmentType.LOAD]: [
|
|
71
|
+
{ id: "ACTIVE_POWER_SET_POINT", label: "ActivePowerSetPointText", unit: MEGA_WATT },
|
|
72
|
+
{ id: "REACTIVE_POWER_SET_POINT", label: "ReactivePowerSetPointText", unit: MEGA_VAR }
|
|
73
|
+
],
|
|
74
|
+
[EquipmentType.TWO_WINDINGS_TRANSFORMER]: [
|
|
75
|
+
{ id: "R", label: "SeriesResistanceText", unit: OHM },
|
|
76
|
+
{ id: "X", label: "SeriesReactanceText", unit: OHM },
|
|
77
|
+
{ id: "G", label: "G", unit: MICRO_SIEMENS },
|
|
78
|
+
{ id: "B", label: "B", unit: MICRO_SIEMENS },
|
|
79
|
+
{ id: "RATED_U1", label: "RatedU1", unit: KILO_VOLT },
|
|
80
|
+
{ id: "RATED_U2", label: "RatedU2", unit: KILO_VOLT },
|
|
81
|
+
{ id: "RATED_S", label: "RatedNominalPowerText", unit: MEGA_VOLT_AMPERE },
|
|
82
|
+
{ id: "TARGET_V", label: "RatioTargetV", unit: KILO_VOLT },
|
|
83
|
+
{ id: "RATIO_LOW_TAP_POSITION", label: "RatioLowTapPosition" },
|
|
84
|
+
{ id: "RATIO_HIGH_TAP_POSITION", label: "RatioHighTapPosition" },
|
|
85
|
+
{ id: "RATIO_TAP_POSITION", label: "RatioTapPosition" },
|
|
86
|
+
{ id: "RATIO_TARGET_DEADBAND", label: "RatioDeadBand", unit: KILO_VOLT },
|
|
87
|
+
{ id: "REGULATION_VALUE", label: "PhaseRegulatingValue" },
|
|
88
|
+
{ id: "PHASE_LOW_TAP_POSITION", label: "PhaseLowTapPosition" },
|
|
89
|
+
{ id: "PHASE_HIGH_TAP_POSITION", label: "PhaseHighTapPosition" },
|
|
90
|
+
{ id: "PHASE_TAP_POSITION", label: "PhaseTapPosition" },
|
|
91
|
+
{ id: "PHASE_TARGET_DEADBAND", label: "PhaseDeadBand" }
|
|
92
|
+
],
|
|
93
|
+
[EquipmentType.LINE]: [
|
|
94
|
+
{ id: "R", label: "SeriesResistanceText", unit: OHM },
|
|
95
|
+
{ id: "X", label: "SeriesReactanceText", unit: OHM },
|
|
96
|
+
{ id: "G1", label: "ShuntConductanceText1", unit: MICRO_SIEMENS },
|
|
97
|
+
{ id: "G2", label: "ShuntConductanceText2", unit: MICRO_SIEMENS },
|
|
98
|
+
{ id: "B1", label: "ShuntSusceptanceText1", unit: MICRO_SIEMENS },
|
|
99
|
+
{ id: "B2", label: "ShuntSusceptanceText2", unit: MICRO_SIEMENS }
|
|
100
|
+
]
|
|
101
|
+
};
|
|
102
|
+
function isValueInEquipmentFields(context, value) {
|
|
103
|
+
const parent = context.from?.at(-1);
|
|
104
|
+
const equipmentType = parent?.value?.[FieldConstants.EQUIPMENT_TYPE];
|
|
105
|
+
return parent ? (
|
|
106
|
+
// @ts-expect-error missing type in context
|
|
107
|
+
EQUIPMENTS_FIELDS[equipmentType]?.some((field) => field.id === value)
|
|
108
|
+
) : false;
|
|
109
|
+
}
|
|
110
|
+
const checkValueInEquipmentFieldsOrNumeric = (value, context) => {
|
|
111
|
+
const newValue = value.replace(",", ".");
|
|
112
|
+
if (!Number.isNaN(Number.parseFloat(newValue))) {
|
|
113
|
+
return true;
|
|
114
|
+
}
|
|
115
|
+
return isValueInEquipmentFields(context, value);
|
|
116
|
+
};
|
|
117
|
+
const checkValueInEquipmentFields = (value, context) => {
|
|
118
|
+
return isValueInEquipmentFields(context, value);
|
|
119
|
+
};
|
|
120
|
+
const getFormulaInitialValue = () => ({
|
|
121
|
+
[FILTERS]: [],
|
|
122
|
+
[FieldConstants.EDITED_FIELD]: null,
|
|
123
|
+
[REFERENCE_FIELD_OR_VALUE_1]: null,
|
|
124
|
+
[OPERATOR]: null,
|
|
125
|
+
[REFERENCE_FIELD_OR_VALUE_2]: null
|
|
126
|
+
});
|
|
127
|
+
function getFormulaSchema() {
|
|
128
|
+
return yup.array().of(
|
|
129
|
+
yup.object().shape({
|
|
130
|
+
[FILTERS]: yup.array().of(
|
|
131
|
+
yup.object().shape({
|
|
132
|
+
[FieldConstants.ID]: yup.string().required(),
|
|
133
|
+
[FieldConstants.NAME]: yup.string().required(),
|
|
134
|
+
[FieldConstants.SPECIFIC_METADATA]: yup.object().shape({
|
|
135
|
+
[FieldConstants.TYPE]: yup.string()
|
|
136
|
+
})
|
|
137
|
+
})
|
|
138
|
+
).required().min(1, YUP_REQUIRED),
|
|
139
|
+
[FieldConstants.EDITED_FIELD]: yup.string().required(),
|
|
140
|
+
[OPERATOR]: yup.string().required(),
|
|
141
|
+
[REFERENCE_FIELD_OR_VALUE_1]: yup.mixed().required().test("checkRefOrValue", "WrongRefOrValueError", checkValueInEquipmentFieldsOrNumeric).when([OPERATOR], {
|
|
142
|
+
is: "PERCENTAGE",
|
|
143
|
+
then: (schema) => schema.test(
|
|
144
|
+
"checkValueIsReference",
|
|
145
|
+
"ValueMustBeNumericWhenPercentageError",
|
|
146
|
+
(value) => !Number.isNaN(Number.parseFloat(value)) && Number.parseFloat(value) >= 0
|
|
147
|
+
)
|
|
148
|
+
}),
|
|
149
|
+
[REFERENCE_FIELD_OR_VALUE_2]: yup.mixed().required().test("checkRefOrValue", "WrongRefOrValueError", checkValueInEquipmentFieldsOrNumeric).when([OPERATOR], {
|
|
150
|
+
is: "PERCENTAGE",
|
|
151
|
+
then: (schema) => schema.test(
|
|
152
|
+
"checkValueIsReference",
|
|
153
|
+
"ValueMustBeRefWhenPercentageError",
|
|
154
|
+
checkValueInEquipmentFields
|
|
155
|
+
)
|
|
156
|
+
})
|
|
157
|
+
})
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
export {
|
|
161
|
+
EQUIPMENTS_FIELDS,
|
|
162
|
+
getFormulaInitialValue,
|
|
163
|
+
getFormulaSchema
|
|
164
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { UUID } from 'node:crypto';
|
|
2
|
+
import { ModificationType } from '../../../../../utils';
|
|
3
|
+
export interface FilterInfos {
|
|
4
|
+
id: UUID;
|
|
5
|
+
name: string;
|
|
6
|
+
specificMetadata: {
|
|
7
|
+
type?: string;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
export interface ReferenceFieldOrValue {
|
|
11
|
+
value: number | null;
|
|
12
|
+
equipmentField: string | null;
|
|
13
|
+
}
|
|
14
|
+
export interface FormulaInfos {
|
|
15
|
+
id?: UUID;
|
|
16
|
+
fieldOrValue1: ReferenceFieldOrValue;
|
|
17
|
+
fieldOrValue2: ReferenceFieldOrValue;
|
|
18
|
+
filters: FilterInfos[];
|
|
19
|
+
editedField: string;
|
|
20
|
+
operator: string;
|
|
21
|
+
}
|
|
22
|
+
export interface ModificationByFormulaDto {
|
|
23
|
+
type: ModificationType.BY_FORMULA_MODIFICATION;
|
|
24
|
+
uuid?: UUID;
|
|
25
|
+
identifiableType: string;
|
|
26
|
+
formulaInfosList: FormulaInfos[];
|
|
27
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026, RTE (http://www.rte-france.com)
|
|
3
|
+
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
4
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
5
|
+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
6
|
+
*/
|
|
7
|
+
interface ReferenceAutocompleteInputProps {
|
|
8
|
+
name: string;
|
|
9
|
+
options: {
|
|
10
|
+
id: string;
|
|
11
|
+
label: string;
|
|
12
|
+
}[];
|
|
13
|
+
}
|
|
14
|
+
declare function ReferenceAutocompleteInput({ name, options }: ReferenceAutocompleteInputProps): import("react").JSX.Element;
|
|
15
|
+
export default ReferenceAutocompleteInput;
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useCallback } from "react";
|
|
3
|
+
import { useController } from "react-hook-form";
|
|
4
|
+
import { useIntl } from "react-intl";
|
|
5
|
+
import "../../../../../utils/conversionUtils.js";
|
|
6
|
+
import "../../../../../utils/types/equipmentType.js";
|
|
7
|
+
import "@mui/icons-material";
|
|
8
|
+
import { areIdsEqual } from "../../../../../utils/ts-utils.js";
|
|
9
|
+
import "@mui/material";
|
|
10
|
+
import "../../../../../components/ui/overflowableText/OverflowableText.js";
|
|
11
|
+
import "localized-countries";
|
|
12
|
+
import "localized-countries/data/fr";
|
|
13
|
+
import "localized-countries/data/en";
|
|
14
|
+
import "notistack";
|
|
15
|
+
import "../../../../../components/ui/reactHookForm/provider/CustomFormProvider.js";
|
|
16
|
+
import "yup";
|
|
17
|
+
import "../../../../../components/ui/treeViewFinder/TreeViewFinder.js";
|
|
18
|
+
import { AutocompleteInput } from "../../../../../components/ui/reactHookForm/autocompleteInputs/AutocompleteInput.js";
|
|
19
|
+
import "../../../../../components/ui/reactHookForm/numbers/RangeInput.js";
|
|
20
|
+
import "@material-symbols/svg-400/outlined/left_panel_open.svg?react";
|
|
21
|
+
import "@material-symbols/svg-400/outlined/arrows_output.svg?react";
|
|
22
|
+
import "@material-symbols/svg-400/outlined/arrows_input.svg?react";
|
|
23
|
+
import "@material-symbols/svg-400/outlined/left_panel_close.svg?react";
|
|
24
|
+
import "@material-symbols/svg-400/outlined/add_notes.svg?react";
|
|
25
|
+
import "../../../../../components/ui/dialogs/descriptionModificationDialog/DescriptionModificationDialog.js";
|
|
26
|
+
import "../../../../../components/ui/reactHookForm/expandableInput/ExpandableInput.js";
|
|
27
|
+
import "../../../../../components/ui/reactHookForm/directory-item-input/directory-item-utils.js";
|
|
28
|
+
import "@hello-pangea/dnd";
|
|
29
|
+
import "../../../../../components/ui/dialogs/elementSaveDialog/ElementSaveDialog.js";
|
|
30
|
+
import "../../../../../components/ui/snackbarProvider/SnackbarProvider.js";
|
|
31
|
+
import "mui-nested-menu";
|
|
32
|
+
import "react-resizable-panels";
|
|
33
|
+
import "react-papaparse";
|
|
34
|
+
import "react-dom";
|
|
35
|
+
import "autosuggest-highlight/match";
|
|
36
|
+
import "autosuggest-highlight/parse";
|
|
37
|
+
import "clsx";
|
|
38
|
+
import "../../../../../components/composite/filter/FilterCreationDialog.js";
|
|
39
|
+
import "../../../../../components/composite/filter/HeaderFilterForm.js";
|
|
40
|
+
import "../../../../../components/composite/filter/explicitNaming/ExplicitNamingFilterForm.js";
|
|
41
|
+
import "../../../../../components/composite/filter/expert/ExpertFilterForm.js";
|
|
42
|
+
import "../../../../../components/composite/filter/expert/ExpertFilterEditionDialog.js";
|
|
43
|
+
import "../../../../../components/composite/filter/expert/expertFilterConstants.js";
|
|
44
|
+
import "react-querybuilder";
|
|
45
|
+
import "uuid";
|
|
46
|
+
import "../../../../../components/composite/filter/explicitNaming/ExplicitNamingFilterEditionDialog.js";
|
|
47
|
+
import "../../../../../components/composite/filter/utils/filterFormUtils.js";
|
|
48
|
+
import "@react-querybuilder/material";
|
|
49
|
+
import "../../../../../components/composite/reactQueryBuilder/CustomReactQueryBuilder.js";
|
|
50
|
+
import "../../../../../components/composite/reactQueryBuilder/PropertyValueEditor.js";
|
|
51
|
+
import "../../../../../components/composite/agGridTable/BottomTableButtons.js";
|
|
52
|
+
import "../../../../../components/composite/agGridTable/CustomAgGridTable.js";
|
|
53
|
+
import "ag-grid-community";
|
|
54
|
+
import "../../../../../components/composite/customAGGrid/customAggrid.js";
|
|
55
|
+
import "../../../../../components/composite/customAGGrid/context/custom-aggrid-context.js";
|
|
56
|
+
import "mathjs";
|
|
57
|
+
import "../../../../../components/composite/report/report-viewer/log-table/log-table.js";
|
|
58
|
+
import "react-window";
|
|
59
|
+
import "../../../../../components/composite/report/report-treeview/treeview-item.js";
|
|
60
|
+
import "../../../../../components/composite/report/report-viewer/context/report-viewer-context.js";
|
|
61
|
+
function ReferenceAutocompleteInput({ name, options }) {
|
|
62
|
+
const intl = useIntl();
|
|
63
|
+
const [displayOptions, setDisplayOptions] = useState(false);
|
|
64
|
+
const {
|
|
65
|
+
fieldState: { error },
|
|
66
|
+
field: { onChange }
|
|
67
|
+
} = useController({
|
|
68
|
+
name
|
|
69
|
+
});
|
|
70
|
+
const handleFilterOptions = useCallback(
|
|
71
|
+
(filteredOptions, state) => {
|
|
72
|
+
if (state.inputValue?.startsWith("#")) {
|
|
73
|
+
const keyword = state.inputValue?.substring(1);
|
|
74
|
+
if (!keyword) {
|
|
75
|
+
return filteredOptions;
|
|
76
|
+
}
|
|
77
|
+
return filteredOptions.filter(
|
|
78
|
+
(option) => intl.formatMessage({ id: state.getOptionLabel(option) }).toLowerCase().startsWith(keyword.toLowerCase())
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
return filteredOptions;
|
|
82
|
+
},
|
|
83
|
+
[intl]
|
|
84
|
+
);
|
|
85
|
+
const inputTransform = (value) => options.find((option) => option?.id === value) || value;
|
|
86
|
+
const outputTransform = (value) => {
|
|
87
|
+
return value?.id ?? value;
|
|
88
|
+
};
|
|
89
|
+
return /* @__PURE__ */ jsx(
|
|
90
|
+
AutocompleteInput,
|
|
91
|
+
{
|
|
92
|
+
name,
|
|
93
|
+
options,
|
|
94
|
+
isOptionEqualToValue: areIdsEqual,
|
|
95
|
+
getOptionLabel: (option) => {
|
|
96
|
+
return option?.label ? intl.formatMessage({ id: option.label }) : option;
|
|
97
|
+
},
|
|
98
|
+
inputTransform,
|
|
99
|
+
outputTransform,
|
|
100
|
+
label: "ReferenceFieldOrValue",
|
|
101
|
+
size: "small",
|
|
102
|
+
open: displayOptions,
|
|
103
|
+
onBlur: () => setDisplayOptions(false),
|
|
104
|
+
allowNewValue: true,
|
|
105
|
+
onInputChange: (event, value) => {
|
|
106
|
+
const displayOption = !!value?.trim()?.startsWith("#");
|
|
107
|
+
setDisplayOptions(displayOption);
|
|
108
|
+
if (value && !Number.isNaN(Number.parseFloat(value))) {
|
|
109
|
+
onChange(value);
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
filterOptions: (filteredOptions, state) => handleFilterOptions(filteredOptions, state),
|
|
113
|
+
formProps: {
|
|
114
|
+
helperText: intl.formatMessage({
|
|
115
|
+
id: error?.message ? error.message : "UseDashToSelectField"
|
|
116
|
+
})
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
export {
|
|
122
|
+
ReferenceAutocompleteInput as default
|
|
123
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026, RTE (http://www.rte-france.com)
|
|
3
|
+
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
4
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
5
|
+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
6
|
+
*/
|
|
7
|
+
export * from './modification-by-formula-form';
|
|
8
|
+
export * from './formula/formula-utils';
|
|
9
|
+
export * from './modificationByFormula.utils';
|
|
10
|
+
export * from './formula/formula-constants';
|
|
11
|
+
export * from './formula/formula.type';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ModificationByFormulaForm } from "./modification-by-formula-form.js";
|
|
2
|
+
import { EQUIPMENTS_FIELDS, getFormulaInitialValue, getFormulaSchema } from "./formula/formula-utils.js";
|
|
3
|
+
import { emptyModificationFormData, modificationByFormulaDtoToForm, modificationByFormulaFormSchema, modificationByFormulaFormToDto } from "./modificationByFormula.utils.js";
|
|
4
|
+
import { FORMULAS, OPERATOR, REFERENCE_FIELD_OR_VALUE_1, REFERENCE_FIELD_OR_VALUE_2 } from "./formula/formula-constants.js";
|
|
5
|
+
export {
|
|
6
|
+
EQUIPMENTS_FIELDS,
|
|
7
|
+
FORMULAS,
|
|
8
|
+
ModificationByFormulaForm,
|
|
9
|
+
OPERATOR,
|
|
10
|
+
REFERENCE_FIELD_OR_VALUE_1,
|
|
11
|
+
REFERENCE_FIELD_OR_VALUE_2,
|
|
12
|
+
emptyModificationFormData,
|
|
13
|
+
getFormulaInitialValue,
|
|
14
|
+
getFormulaSchema,
|
|
15
|
+
modificationByFormulaDtoToForm,
|
|
16
|
+
modificationByFormulaFormSchema,
|
|
17
|
+
modificationByFormulaFormToDto
|
|
18
|
+
};
|
package/dist/features/network-modifications/by-filter/formula/modification-by-formula-form.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function ModificationByFormulaForm(): import("react").JSX.Element;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useFormContext } from "react-hook-form";
|
|
3
|
+
import { Box, Grid2 } from "@mui/material";
|
|
4
|
+
import FormulaForm from "./formula/formula-form.js";
|
|
5
|
+
import { getFormulaInitialValue } from "./formula/formula-utils.js";
|
|
6
|
+
import { FieldConstants } from "../../../../utils/constants/fieldConstants.js";
|
|
7
|
+
import "../../../../utils/conversionUtils.js";
|
|
8
|
+
import { EquipmentType } from "../../../../utils/types/equipmentType.js";
|
|
9
|
+
import "@mui/icons-material";
|
|
10
|
+
import { mergeSx } from "../../../../utils/styles.js";
|
|
11
|
+
import "react-intl";
|
|
12
|
+
import "../../../../components/ui/overflowableText/OverflowableText.js";
|
|
13
|
+
import "react";
|
|
14
|
+
import "localized-countries";
|
|
15
|
+
import "localized-countries/data/fr";
|
|
16
|
+
import "localized-countries/data/en";
|
|
17
|
+
import "notistack";
|
|
18
|
+
import "../../../../components/ui/reactHookForm/provider/CustomFormProvider.js";
|
|
19
|
+
import "yup";
|
|
20
|
+
import "../../../../components/ui/treeViewFinder/TreeViewFinder.js";
|
|
21
|
+
import "../../../../components/ui/reactHookForm/numbers/RangeInput.js";
|
|
22
|
+
import { SelectWithConfirmationInput } from "../../../../components/ui/reactHookForm/selectInputs/SelectWithConfirmationInput.js";
|
|
23
|
+
import "@material-symbols/svg-400/outlined/left_panel_open.svg?react";
|
|
24
|
+
import "@material-symbols/svg-400/outlined/arrows_output.svg?react";
|
|
25
|
+
import "@material-symbols/svg-400/outlined/arrows_input.svg?react";
|
|
26
|
+
import "@material-symbols/svg-400/outlined/left_panel_close.svg?react";
|
|
27
|
+
import "@material-symbols/svg-400/outlined/add_notes.svg?react";
|
|
28
|
+
import "../../../../components/ui/dialogs/descriptionModificationDialog/DescriptionModificationDialog.js";
|
|
29
|
+
import { ExpandableInput } from "../../../../components/ui/reactHookForm/expandableInput/ExpandableInput.js";
|
|
30
|
+
import "../../../../components/ui/reactHookForm/directory-item-input/directory-item-utils.js";
|
|
31
|
+
import "@hello-pangea/dnd";
|
|
32
|
+
import { unscrollableDialogStyles } from "../../../../components/ui/dialogs/customMuiDialog/CustomMuiDialog.js";
|
|
33
|
+
import "../../../../components/ui/dialogs/elementSaveDialog/ElementSaveDialog.js";
|
|
34
|
+
import "../../../../components/ui/snackbarProvider/SnackbarProvider.js";
|
|
35
|
+
import "mui-nested-menu";
|
|
36
|
+
import "react-resizable-panels";
|
|
37
|
+
import "react-papaparse";
|
|
38
|
+
import "react-dom";
|
|
39
|
+
import "autosuggest-highlight/match";
|
|
40
|
+
import "autosuggest-highlight/parse";
|
|
41
|
+
import "clsx";
|
|
42
|
+
import "../../../../components/composite/filter/FilterCreationDialog.js";
|
|
43
|
+
import "../../../../components/composite/filter/HeaderFilterForm.js";
|
|
44
|
+
import "../../../../components/composite/filter/explicitNaming/ExplicitNamingFilterForm.js";
|
|
45
|
+
import "../../../../components/composite/filter/expert/ExpertFilterForm.js";
|
|
46
|
+
import "../../../../components/composite/filter/expert/ExpertFilterEditionDialog.js";
|
|
47
|
+
import "../../../../components/composite/filter/expert/expertFilterConstants.js";
|
|
48
|
+
import "react-querybuilder";
|
|
49
|
+
import "uuid";
|
|
50
|
+
import "../../../../components/composite/filter/explicitNaming/ExplicitNamingFilterEditionDialog.js";
|
|
51
|
+
import "../../../../components/composite/filter/utils/filterFormUtils.js";
|
|
52
|
+
import { GridItem } from "../../../../components/composite/grid/grid-item.js";
|
|
53
|
+
import "@react-querybuilder/material";
|
|
54
|
+
import "../../../../components/composite/reactQueryBuilder/CustomReactQueryBuilder.js";
|
|
55
|
+
import "../../../../components/composite/reactQueryBuilder/PropertyValueEditor.js";
|
|
56
|
+
import "../../../../components/composite/agGridTable/BottomTableButtons.js";
|
|
57
|
+
import "../../../../components/composite/agGridTable/CustomAgGridTable.js";
|
|
58
|
+
import "ag-grid-community";
|
|
59
|
+
import "../../../../components/composite/customAGGrid/customAggrid.js";
|
|
60
|
+
import "../../../../components/composite/customAGGrid/context/custom-aggrid-context.js";
|
|
61
|
+
import "mathjs";
|
|
62
|
+
import "../../../../components/composite/report/report-viewer/log-table/log-table.js";
|
|
63
|
+
import "react-window";
|
|
64
|
+
import "../../../../components/composite/report/report-treeview/treeview-item.js";
|
|
65
|
+
import "../../../../components/composite/report/report-viewer/context/report-viewer-context.js";
|
|
66
|
+
import { FORMULAS } from "./formula/formula-constants.js";
|
|
67
|
+
const EQUIPMENT_TYPE_OPTIONS = [
|
|
68
|
+
EquipmentType.GENERATOR,
|
|
69
|
+
EquipmentType.BATTERY,
|
|
70
|
+
EquipmentType.SHUNT_COMPENSATOR,
|
|
71
|
+
EquipmentType.VOLTAGE_LEVEL,
|
|
72
|
+
EquipmentType.LOAD,
|
|
73
|
+
EquipmentType.TWO_WINDINGS_TRANSFORMER,
|
|
74
|
+
EquipmentType.LINE
|
|
75
|
+
];
|
|
76
|
+
function ModificationByFormulaForm() {
|
|
77
|
+
const { setValue, getValues } = useFormContext();
|
|
78
|
+
const equipmentTypeField = /* @__PURE__ */ jsx(
|
|
79
|
+
SelectWithConfirmationInput,
|
|
80
|
+
{
|
|
81
|
+
name: FieldConstants.EQUIPMENT_TYPE,
|
|
82
|
+
label: "EquipmentType",
|
|
83
|
+
options: EQUIPMENT_TYPE_OPTIONS,
|
|
84
|
+
onValidate: () => {
|
|
85
|
+
setValue(
|
|
86
|
+
FORMULAS,
|
|
87
|
+
getValues(FORMULAS).map(() => ({
|
|
88
|
+
...getFormulaInitialValue()
|
|
89
|
+
}))
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
);
|
|
94
|
+
const formulasField = /* @__PURE__ */ jsx(
|
|
95
|
+
ExpandableInput,
|
|
96
|
+
{
|
|
97
|
+
name: FORMULAS,
|
|
98
|
+
Field: FormulaForm,
|
|
99
|
+
addButtonLabel: "addNewFormula",
|
|
100
|
+
initialValue: getFormulaInitialValue()
|
|
101
|
+
}
|
|
102
|
+
);
|
|
103
|
+
return /* @__PURE__ */ jsxs(Box, { sx: mergeSx(unscrollableDialogStyles.unscrollableContainer, { height: "100%" }), children: [
|
|
104
|
+
/* @__PURE__ */ jsx(Grid2, { container: true, sx: unscrollableDialogStyles.unscrollableHeader, children: /* @__PURE__ */ jsx(GridItem, { size: 2.15, children: equipmentTypeField }) }),
|
|
105
|
+
/* @__PURE__ */ jsx(Grid2, { container: true, sx: unscrollableDialogStyles.scrollableContent, children: /* @__PURE__ */ jsx(GridItem, { size: 12, children: formulasField }) })
|
|
106
|
+
] });
|
|
107
|
+
}
|
|
108
|
+
export {
|
|
109
|
+
ModificationByFormulaForm
|
|
110
|
+
};
|
package/dist/features/network-modifications/by-filter/formula/modificationByFormula.utils.d.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { DeepNullable } from '../../../../utils';
|
|
2
|
+
import { ModificationByFormulaDto } from './formula/formula.type';
|
|
3
|
+
/**
|
|
4
|
+
* Copyright (c) 2026, RTE (http://www.rte-france.com)
|
|
5
|
+
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
6
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
7
|
+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
8
|
+
*/
|
|
9
|
+
import * as yup from 'yup';
|
|
10
|
+
export declare const modificationByFormulaFormSchema: yup.ObjectSchema<{
|
|
11
|
+
equipmentType: string;
|
|
12
|
+
formulas: {
|
|
13
|
+
filters: {
|
|
14
|
+
id: string;
|
|
15
|
+
name: string;
|
|
16
|
+
specificMetadata: {
|
|
17
|
+
type?: string | undefined;
|
|
18
|
+
};
|
|
19
|
+
}[];
|
|
20
|
+
editedField: string;
|
|
21
|
+
operator: string;
|
|
22
|
+
referenceFieldOrValue1: {};
|
|
23
|
+
referenceFieldOrValue2: {};
|
|
24
|
+
}[] | undefined;
|
|
25
|
+
}, yup.AnyObject, {
|
|
26
|
+
equipmentType: undefined;
|
|
27
|
+
formulas: "";
|
|
28
|
+
}, "">;
|
|
29
|
+
export type ModificationByFormulaFormData = yup.InferType<typeof modificationByFormulaFormSchema>;
|
|
30
|
+
export declare const emptyModificationFormData: DeepNullable<ModificationByFormulaFormData>;
|
|
31
|
+
export declare const modificationByFormulaDtoToForm: (dto: ModificationByFormulaDto) => ModificationByFormulaFormData;
|
|
32
|
+
export declare const modificationByFormulaFormToDto: (formData: ModificationByFormulaFormData) => ModificationByFormulaDto;
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import * as yup from "yup";
|
|
2
|
+
import { FieldConstants } from "../../../../utils/constants/fieldConstants.js";
|
|
3
|
+
import { convertInputValue, convertOutputValue } from "../../../../utils/conversionUtils.js";
|
|
4
|
+
import "../../../../utils/types/equipmentType.js";
|
|
5
|
+
import { ModificationType } from "../../../../utils/types/modificationType.js";
|
|
6
|
+
import "react/jsx-runtime";
|
|
7
|
+
import "@mui/icons-material";
|
|
8
|
+
import { getFormulaSchema, getFormulaInitialValue } from "./formula/formula-utils.js";
|
|
9
|
+
import { FORMULAS, OPERATOR, REFERENCE_FIELD_OR_VALUE_2, REFERENCE_FIELD_OR_VALUE_1 } from "./formula/formula-constants.js";
|
|
10
|
+
const modificationByFormulaFormSchema = yup.object().shape({
|
|
11
|
+
[FieldConstants.EQUIPMENT_TYPE]: yup.string().required(),
|
|
12
|
+
[FORMULAS]: getFormulaSchema()
|
|
13
|
+
}).required();
|
|
14
|
+
const emptyModificationFormData = {
|
|
15
|
+
[FieldConstants.EQUIPMENT_TYPE]: "",
|
|
16
|
+
[FORMULAS]: [getFormulaInitialValue()]
|
|
17
|
+
};
|
|
18
|
+
function shouldConvert(isNumber1, isNumber2, operator) {
|
|
19
|
+
switch (operator) {
|
|
20
|
+
case "DIVISION":
|
|
21
|
+
if (isNumber1 && isNumber2) {
|
|
22
|
+
return { convertValue1: true, convertValue2: false };
|
|
23
|
+
}
|
|
24
|
+
return { convertValue1: false, convertValue2: false };
|
|
25
|
+
case "MULTIPLICATION":
|
|
26
|
+
case "PERCENTAGE":
|
|
27
|
+
if (isNumber1 && isNumber2) {
|
|
28
|
+
return { convertValue1: false, convertValue2: true };
|
|
29
|
+
}
|
|
30
|
+
return { convertValue1: false, convertValue2: false };
|
|
31
|
+
default:
|
|
32
|
+
return { convertValue1: true, convertValue2: true };
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function shouldConvertFromNumber(input1, input2, operator) {
|
|
36
|
+
const isNumber1 = input1 !== null && !Number.isNaN(input1);
|
|
37
|
+
const isNumber2 = input2 !== null && !Number.isNaN(input2);
|
|
38
|
+
return shouldConvert(isNumber1, isNumber2, operator);
|
|
39
|
+
}
|
|
40
|
+
function shouldConvertFromString(input1, input2, operator) {
|
|
41
|
+
const isNumber1 = input1 !== null && !Number.isNaN(Number.parseFloat(input1.replace(",", ".")));
|
|
42
|
+
const isNumber2 = input2 !== null && !Number.isNaN(Number.parseFloat(input2.replace(",", ".")));
|
|
43
|
+
return shouldConvert(isNumber1, isNumber2, operator);
|
|
44
|
+
}
|
|
45
|
+
const modificationByFormulaDtoToForm = (dto) => {
|
|
46
|
+
const formulas = dto.formulaInfosList?.map((formula) => {
|
|
47
|
+
const shouldConverts = shouldConvertFromNumber(
|
|
48
|
+
formula?.fieldOrValue1?.value,
|
|
49
|
+
formula?.fieldOrValue2?.value,
|
|
50
|
+
formula?.operator
|
|
51
|
+
);
|
|
52
|
+
const valueConverted1 = shouldConverts.convertValue1 ? convertInputValue(formula.editedField, formula?.fieldOrValue1?.value) : formula?.fieldOrValue1?.value;
|
|
53
|
+
const valueConverted2 = shouldConverts.convertValue2 ? convertInputValue(formula.editedField, formula?.fieldOrValue2?.value) : formula?.fieldOrValue2?.value;
|
|
54
|
+
const ref1 = valueConverted1?.toString() ?? formula?.fieldOrValue1?.equipmentField;
|
|
55
|
+
const ref2 = valueConverted2?.toString() ?? formula?.fieldOrValue2?.equipmentField;
|
|
56
|
+
return {
|
|
57
|
+
[REFERENCE_FIELD_OR_VALUE_1]: ref1,
|
|
58
|
+
[REFERENCE_FIELD_OR_VALUE_2]: ref2,
|
|
59
|
+
[FieldConstants.EDITED_FIELD]: formula.editedField,
|
|
60
|
+
[OPERATOR]: formula.operator,
|
|
61
|
+
[FieldConstants.FILTERS]: formula.filters
|
|
62
|
+
};
|
|
63
|
+
});
|
|
64
|
+
return {
|
|
65
|
+
[FieldConstants.EQUIPMENT_TYPE]: dto.identifiableType,
|
|
66
|
+
[FORMULAS]: formulas
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
function getFieldOrConvertedUnitValue(input, fieldType, convert) {
|
|
70
|
+
const value = input.replace(",", ".");
|
|
71
|
+
const isNumber = !Number.isNaN(Number.parseFloat(value));
|
|
72
|
+
if (isNumber) {
|
|
73
|
+
return {
|
|
74
|
+
value: convert ? convertOutputValue(fieldType, value) : value,
|
|
75
|
+
equipmentField: null
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
return {
|
|
79
|
+
value: null,
|
|
80
|
+
equipmentField: input
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
const modificationByFormulaFormToDto = (formData) => {
|
|
84
|
+
const formulas = formData[FORMULAS]?.map((formula) => {
|
|
85
|
+
const shouldConverts = shouldConvertFromString(
|
|
86
|
+
formula[REFERENCE_FIELD_OR_VALUE_1],
|
|
87
|
+
formula[REFERENCE_FIELD_OR_VALUE_2],
|
|
88
|
+
formula[OPERATOR]
|
|
89
|
+
);
|
|
90
|
+
const fieldOrValue1 = getFieldOrConvertedUnitValue(
|
|
91
|
+
formula[REFERENCE_FIELD_OR_VALUE_1],
|
|
92
|
+
formula[FieldConstants.EDITED_FIELD],
|
|
93
|
+
shouldConverts.convertValue1
|
|
94
|
+
);
|
|
95
|
+
const fieldOrValue2 = getFieldOrConvertedUnitValue(
|
|
96
|
+
formula[REFERENCE_FIELD_OR_VALUE_2],
|
|
97
|
+
formula[FieldConstants.EDITED_FIELD],
|
|
98
|
+
shouldConverts.convertValue2
|
|
99
|
+
);
|
|
100
|
+
const filters = formula[FieldConstants.FILTERS]?.map((filter) => {
|
|
101
|
+
return {
|
|
102
|
+
id: filter.id,
|
|
103
|
+
name: filter.name,
|
|
104
|
+
specificMetadata: filter.specificMetadata
|
|
105
|
+
};
|
|
106
|
+
});
|
|
107
|
+
return {
|
|
108
|
+
fieldOrValue1,
|
|
109
|
+
fieldOrValue2,
|
|
110
|
+
filters,
|
|
111
|
+
operator: formula.operator,
|
|
112
|
+
editedField: formula.editedField
|
|
113
|
+
};
|
|
114
|
+
});
|
|
115
|
+
return {
|
|
116
|
+
type: ModificationType.BY_FORMULA_MODIFICATION,
|
|
117
|
+
identifiableType: formData[FieldConstants.EQUIPMENT_TYPE],
|
|
118
|
+
formulaInfosList: formulas ?? []
|
|
119
|
+
};
|
|
120
|
+
};
|
|
121
|
+
export {
|
|
122
|
+
emptyModificationFormData,
|
|
123
|
+
modificationByFormulaDtoToForm,
|
|
124
|
+
modificationByFormulaFormSchema,
|
|
125
|
+
modificationByFormulaFormToDto
|
|
126
|
+
};
|