@gridsuite/commons-ui 0.279.0 → 0.281.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/customAGGrid/separatorCellRenderer.d.ts +7 -2
- package/dist/components/composite/customAGGrid/separatorCellRenderer.js +2 -2
- package/dist/components/ui/dialogs/elementSaveDialog/ElementSaveDialog.d.ts +6 -1
- package/dist/components/ui/dialogs/elementSaveDialog/ElementSaveDialog.js +29 -5
- package/dist/components/ui/reactHookForm/booleans/RadioInput.d.ts +1 -0
- package/dist/components/ui/reactHookForm/booleans/RadioInput.js +2 -1
- package/dist/features/index.js +93 -3
- package/dist/features/network-modifications/index.d.ts +1 -0
- package/dist/features/network-modifications/index.js +91 -3
- package/dist/features/network-modifications/tabular/TabularForm.d.ts +22 -0
- package/dist/features/network-modifications/tabular/TabularForm.js +536 -0
- package/dist/features/network-modifications/tabular/index.d.ts +7 -0
- package/dist/features/network-modifications/tabular/index.js +65 -0
- package/dist/features/network-modifications/tabular/properties/DefineTabularPropertiesDialog.d.ts +12 -0
- package/dist/features/network-modifications/tabular/properties/DefineTabularPropertiesDialog.js +123 -0
- package/dist/features/network-modifications/tabular/properties/TabularPropertiesForm.d.ts +1 -0
- package/dist/features/network-modifications/tabular/properties/TabularPropertiesForm.js +87 -0
- package/dist/features/network-modifications/tabular/properties/TabularPropertyForm.d.ts +5 -0
- package/dist/features/network-modifications/tabular/properties/TabularPropertyForm.js +91 -0
- package/dist/features/network-modifications/tabular/properties/index.d.ts +4 -0
- package/dist/features/network-modifications/tabular/properties/index.js +13 -0
- package/dist/features/network-modifications/tabular/properties/tabularProperty.utils.d.ts +26 -0
- package/dist/features/network-modifications/tabular/properties/tabularProperty.utils.js +50 -0
- package/dist/features/network-modifications/tabular/tabular.constants.d.ts +59 -0
- package/dist/features/network-modifications/tabular/tabular.constants.js +75 -0
- package/dist/features/network-modifications/tabular/tabular.types.d.ts +41 -0
- package/dist/features/network-modifications/tabular/tabular.types.js +8 -0
- package/dist/features/network-modifications/tabular/tabular.utils.d.ts +68 -0
- package/dist/features/network-modifications/tabular/tabular.utils.js +301 -0
- package/dist/features/network-modifications/tabular/tabularCreation.utils.d.ts +25 -0
- package/dist/features/network-modifications/tabular/tabularCreation.utils.js +276 -0
- package/dist/features/network-modifications/tabular/tabularModification.utils.d.ts +43 -0
- package/dist/features/network-modifications/tabular/tabularModification.utils.js +406 -0
- package/dist/features/network-modifications/voltageLevel/common/HeaderWithTooltip.d.ts +8 -0
- package/dist/features/network-modifications/voltageLevel/common/HeaderWithTooltip.js +119 -0
- package/dist/features/network-modifications/voltageLevel/common/index.d.ts +1 -0
- package/dist/features/network-modifications/voltageLevel/common/index.js +4 -0
- package/dist/features/network-modifications/voltageLevel/index.d.ts +4 -1
- package/dist/features/network-modifications/voltageLevel/index.js +28 -3
- package/dist/features/network-modifications/voltageLevel/moveFeederBays/MoveVoltageLevelFeederBaysForm.d.ts +8 -0
- package/dist/features/network-modifications/voltageLevel/moveFeederBays/MoveVoltageLevelFeederBaysForm.js +387 -0
- package/dist/features/network-modifications/voltageLevel/moveFeederBays/feederBay/FeederBayDirectionCellRender.d.ts +6 -0
- package/dist/features/network-modifications/voltageLevel/moveFeederBays/feederBay/FeederBayDirectionCellRender.js +64 -0
- package/dist/features/network-modifications/voltageLevel/moveFeederBays/feederBay/FeederBayPositionCellRender.d.ts +6 -0
- package/dist/features/network-modifications/voltageLevel/moveFeederBays/feederBay/FeederBayPositionCellRender.js +102 -0
- package/dist/features/network-modifications/voltageLevel/moveFeederBays/feederBay/index.d.ts +2 -0
- package/dist/features/network-modifications/voltageLevel/moveFeederBays/feederBay/index.js +6 -0
- package/dist/features/network-modifications/voltageLevel/moveFeederBays/index.d.ts +4 -0
- package/dist/features/network-modifications/voltageLevel/moveFeederBays/index.js +13 -0
- package/dist/features/network-modifications/voltageLevel/moveFeederBays/moveVoltageLevelFeederBays.type.d.ts +36 -0
- package/dist/features/network-modifications/voltageLevel/moveFeederBays/moveVoltageLevelFeederBays.utils.d.ts +37 -0
- package/dist/features/network-modifications/voltageLevel/moveFeederBays/moveVoltageLevelFeederBays.utils.js +86 -0
- package/dist/features/network-modifications/voltageLevel/topology/{CreateVoltageLevelTopologyForm.d.ts → creation/CreateVoltageLevelTopologyForm.d.ts} +1 -1
- package/dist/features/network-modifications/voltageLevel/topology/{CreateVoltageLevelTopologyForm.js → creation/CreateVoltageLevelTopologyForm.js} +38 -38
- package/dist/features/network-modifications/voltageLevel/topology/{voltageLevelTopologyCreation.types.d.ts → creation/voltageLevelTopologyCreation.types.d.ts} +1 -1
- package/dist/features/network-modifications/voltageLevel/topology/creation/voltageLevelTopologyCreation.types.js +1 -0
- package/dist/features/network-modifications/voltageLevel/topology/{voltageLevelTopologyCreation.utils.d.ts → creation/voltageLevelTopologyCreation.utils.d.ts} +1 -1
- package/dist/features/network-modifications/voltageLevel/topology/{voltageLevelTopologyCreation.utils.js → creation/voltageLevelTopologyCreation.utils.js} +5 -5
- package/dist/features/network-modifications/voltageLevel/topology/modification/ConnectionCellRender.d.ts +6 -0
- package/dist/features/network-modifications/voltageLevel/topology/modification/ConnectionCellRender.js +80 -0
- package/dist/features/network-modifications/voltageLevel/topology/modification/VoltageLevelTopologyModificationForm.d.ts +10 -0
- package/dist/features/network-modifications/voltageLevel/topology/modification/VoltageLevelTopologyModificationForm.js +284 -0
- package/dist/features/network-modifications/voltageLevel/topology/modification/constants.d.ts +10 -0
- package/dist/features/network-modifications/voltageLevel/topology/modification/constants.js +10 -0
- package/dist/features/network-modifications/voltageLevel/topology/modification/index.d.ts +10 -0
- package/dist/features/network-modifications/voltageLevel/topology/modification/index.js +14 -0
- package/dist/features/network-modifications/voltageLevel/topology/modification/voltageLevelTopologyModification.types.d.ts +28 -0
- package/dist/features/network-modifications/voltageLevel/topology/modification/voltageLevelTopologyModification.types.js +1 -0
- package/dist/features/network-modifications/voltageLevel/topology/modification/voltageLevelTopologyModification.utils.d.ts +29 -0
- package/dist/features/network-modifications/voltageLevel/topology/modification/voltageLevelTopologyModification.utils.js +124 -0
- package/dist/features/parameters/common/index.d.ts +1 -0
- package/dist/features/parameters/common/index.js +2 -0
- package/dist/features/parameters/common/parameter-field.d.ts +2 -2
- package/dist/features/parameters/common/parameter-field.js +1 -1
- package/dist/features/parameters/dynamic-margin-calculation/dynamic-margin-calculation-form.js +1 -1
- package/dist/features/parameters/dynamic-margin-calculation/dynamic-margin-calculation-inline.js +6 -6
- package/dist/features/parameters/dynamic-margin-calculation/loads-variations-parameters.js +1 -1
- package/dist/features/parameters/dynamic-margin-calculation/time-delay-parameters.js +1 -1
- package/dist/features/parameters/dynamic-security-analysis/contingency-parameters.js +1 -1
- package/dist/features/parameters/dynamic-security-analysis/dynamic-security-analysis-inline.js +6 -6
- package/dist/features/parameters/dynamic-security-analysis/dynamic-security-analysis-parameters-form.js +1 -1
- package/dist/features/parameters/dynamic-security-analysis/scenario-parameters.js +1 -1
- package/dist/features/parameters/dynamic-simulation/dynamic-simulation-inline.js +6 -6
- package/dist/features/parameters/dynamic-simulation/dynamic-simulation-parameters-form.js +1 -1
- package/dist/features/parameters/dynamic-simulation/network/network-parameters.js +1 -1
- package/dist/features/parameters/dynamic-simulation/solver/common-solver/common-solver-parameters.js +1 -1
- package/dist/features/parameters/dynamic-simulation/solver/ida-solver/ida-solver-parameters.js +1 -1
- package/dist/features/parameters/dynamic-simulation/solver/sim-solver/simplified-solver-parameters.js +1 -1
- package/dist/features/parameters/dynamic-simulation/solver/solver-parameters.js +1 -1
- package/dist/features/parameters/dynamic-simulation/time-delay/time-delay-parameters.js +1 -1
- package/dist/features/parameters/index.js +2 -0
- package/dist/features/parameters/loadflow/load-flow-advanced-parameters.js +1 -1
- package/dist/features/parameters/loadflow/load-flow-general-parameters.js +1 -1
- package/dist/features/parameters/loadflow/load-flow-parameters-inline.js +5 -5
- package/dist/features/parameters/loadflow/load-flow-provider-specific-parameters.js +1 -1
- package/dist/features/parameters/network-visualizations/network-visualizations-parameters-inline.js +5 -5
- package/dist/features/parameters/pcc-min/pcc-min-parameters-inline.js +5 -5
- package/dist/features/parameters/security-analysis/security-analysis-parameters-inline.js +6 -6
- package/dist/features/parameters/sensi/sensitivity-analysis-parameters-inline.js +6 -6
- package/dist/features/parameters/short-circuit/short-circuit-parameters-inline.js +5 -5
- package/dist/features/parameters/voltage-init/voltage-init-parameters-inline.js +5 -5
- package/dist/features/side-bar/AppSideBarHeader.js +20 -5
- package/dist/features/side-bar/EnvironmentChip.d.ts +13 -0
- package/dist/features/side-bar/EnvironmentChip.js +49 -0
- package/dist/index.js +97 -5
- package/dist/services/appsMetadata.d.ts +2 -0
- package/dist/services/directory.d.ts +1 -1
- package/dist/services/directory.js +6 -2
- package/dist/services/index.js +2 -1
- package/dist/services/userAdmin.d.ts +2 -1
- package/dist/services/userAdmin.js +9 -1
- package/dist/translations/en/businessErrorsEn.d.ts +1 -0
- package/dist/translations/en/businessErrorsEn.js +1 -0
- package/dist/translations/en/networkModificationsEn.d.ts +97 -0
- package/dist/translations/en/networkModificationsEn.js +103 -1
- package/dist/translations/fr/businessErrorsFr.d.ts +1 -0
- package/dist/translations/fr/businessErrorsFr.js +1 -0
- package/dist/translations/fr/networkModificationsFr.d.ts +97 -0
- package/dist/translations/fr/networkModificationsFr.js +103 -1
- package/dist/utils/constants/fieldConstants.d.ts +7 -1
- package/dist/utils/constants/fieldConstants.js +6 -0
- package/dist/utils/constants/index.js +2 -1
- package/dist/utils/constants/notificationsProvider.d.ts +1 -0
- package/dist/utils/constants/notificationsProvider.js +1 -0
- package/dist/utils/constants/translationKeys.d.ts +1 -0
- package/dist/utils/constants/translationKeys.js +2 -0
- package/dist/utils/index.js +2 -1
- package/dist/utils/types/types.d.ts +4 -0
- package/package.json +1 -1
- /package/dist/features/network-modifications/voltageLevel/{topology/voltageLevelTopologyCreation.types.js → moveFeederBays/moveVoltageLevelFeederBays.type.js} +0 -0
- /package/dist/features/network-modifications/voltageLevel/topology/{index.d.ts → creation/index.d.ts} +0 -0
- /package/dist/features/network-modifications/voltageLevel/topology/{index.js → creation/index.js} +0 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { IntlShape } from 'react-intl';
|
|
2
|
+
import { Property, ReactiveCapabilityCurvePoints } from '../common';
|
|
3
|
+
import { TabularFieldConstants } from './tabular.constants';
|
|
4
|
+
import { TabularProperty } from './properties/tabularProperty.utils';
|
|
5
|
+
import { TabularModificationType, PredefinedEquipmentProperties, TabularField, TabularModificationRow } from './tabular.types';
|
|
6
|
+
import * as yup from 'yup';
|
|
7
|
+
export declare const tabularFormSchema: yup.ObjectSchema<NonNullable<{
|
|
8
|
+
type: string;
|
|
9
|
+
modificationsTable: any[];
|
|
10
|
+
csvFilename: string | undefined;
|
|
11
|
+
} & {
|
|
12
|
+
properties: {
|
|
13
|
+
name: string;
|
|
14
|
+
selected: NonNullable<boolean | undefined>;
|
|
15
|
+
predefined: NonNullable<boolean | undefined>;
|
|
16
|
+
}[] | undefined;
|
|
17
|
+
}>, yup.AnyObject, {
|
|
18
|
+
type: undefined;
|
|
19
|
+
modificationsTable: undefined;
|
|
20
|
+
csvFilename: undefined;
|
|
21
|
+
properties: "";
|
|
22
|
+
}, "">;
|
|
23
|
+
export type TabularFormType = yup.InferType<typeof tabularFormSchema>;
|
|
24
|
+
export declare const getEmptyTabularFormData: (equipmentType: string) => {
|
|
25
|
+
type: string;
|
|
26
|
+
modificationsTable: never[];
|
|
27
|
+
properties: never[];
|
|
28
|
+
csvFilename: undefined;
|
|
29
|
+
};
|
|
30
|
+
export declare const formatModification: (modification: TabularModificationRow) => {
|
|
31
|
+
[key: string]: any;
|
|
32
|
+
};
|
|
33
|
+
export declare const addPropertiesFromBack: (modification: TabularModificationRow, tabularProperties: Property[] | null) => TabularModificationRow;
|
|
34
|
+
export declare const convertReactiveCapabilityCurvePointsFromBackToFront: (value: ReactiveCapabilityCurvePoints[]) => {
|
|
35
|
+
key: TabularFieldConstants;
|
|
36
|
+
value: number | null;
|
|
37
|
+
}[];
|
|
38
|
+
export declare const convertReactiveCapabilityCurvePointsFromFrontToBack: (modification: TabularModificationRow) => void;
|
|
39
|
+
export declare const setFieldTypeError: (fieldTypeInError: string, expectedTypeForFieldInError: string, tableName: string, setError: (tableName: string, error: {
|
|
40
|
+
type: string;
|
|
41
|
+
message?: string;
|
|
42
|
+
}) => void, intl: IntlShape, expectedValues?: string[]) => void;
|
|
43
|
+
export declare const isFieldTypeOk: (value: any, fieldDefinition: {
|
|
44
|
+
type?: string;
|
|
45
|
+
options?: any[];
|
|
46
|
+
} | undefined) => boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Sanitize a CSV cell value before injecting it into the table:
|
|
49
|
+
* - a mandatory boolean (checkbox) cell with no/invalid value defaults to `false`
|
|
50
|
+
* (an empty checkbox cannot be distinguished from `false`),
|
|
51
|
+
* - any other value with a wrong format is dropped (replaced by `null`) so invalid data
|
|
52
|
+
* is never injected,
|
|
53
|
+
* - otherwise the value is kept as-is (including non-typed `property_*` columns).
|
|
54
|
+
*/
|
|
55
|
+
export declare const sanitizeRowValue: (value: any, fieldDefinition: TabularField | undefined) => any;
|
|
56
|
+
interface CommentLinesConfig {
|
|
57
|
+
fields: TabularField[] | null;
|
|
58
|
+
selectedProperties: string[];
|
|
59
|
+
intl: IntlShape;
|
|
60
|
+
equipmentType: string;
|
|
61
|
+
language: string;
|
|
62
|
+
formType: TabularModificationType;
|
|
63
|
+
predefinedEquipmentProperties?: PredefinedEquipmentProperties;
|
|
64
|
+
}
|
|
65
|
+
export declare const generateCommentLines: ({ fields, selectedProperties, intl, equipmentType, language, formType, predefinedEquipmentProperties, }: CommentLinesConfig) => string[][];
|
|
66
|
+
export declare const transformProperties: (row: TabularModificationRow) => Property[];
|
|
67
|
+
export declare const getSelectedTabularPropertyNames: (tabularProperties: TabularProperty[] | undefined) => string[];
|
|
68
|
+
export {};
|
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
import * as yup from "yup";
|
|
2
|
+
import { FieldConstants } from "../../../utils/constants/fieldConstants.js";
|
|
3
|
+
import { MODIFICATIONS_REQUIRED_TAB_ERROR } from "../../../utils/constants/translationKeys.js";
|
|
4
|
+
import "../../../utils/conversionUtils.js";
|
|
5
|
+
import "../../../utils/types/equipmentType.js";
|
|
6
|
+
import { getCsvDelimiter } from "../../../utils/langs.js";
|
|
7
|
+
import "react/jsx-runtime";
|
|
8
|
+
import "@mui/icons-material";
|
|
9
|
+
import { equipmentTypesForPredefinedPropertiesMapper } from "../../../utils/mapper/equipmentTypesForPredefinedPropertiesMapper.js";
|
|
10
|
+
import "react";
|
|
11
|
+
import "react-hook-form";
|
|
12
|
+
import { createPropertyModification } from "../common/properties/propertyUtils.js";
|
|
13
|
+
import "@mui/material";
|
|
14
|
+
import "react-intl";
|
|
15
|
+
import "../../../components/ui/overflowableText/OverflowableText.js";
|
|
16
|
+
import "localized-countries";
|
|
17
|
+
import "localized-countries/data/fr";
|
|
18
|
+
import "localized-countries/data/en";
|
|
19
|
+
import "notistack";
|
|
20
|
+
import "../../../components/ui/reactHookForm/provider/CustomFormProvider.js";
|
|
21
|
+
import "../../../components/ui/treeViewFinder/TreeViewFinder.js";
|
|
22
|
+
import "../../../components/ui/reactHookForm/numbers/RangeInput.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-fill.svg?react";
|
|
28
|
+
import "../../../components/ui/dialogs/descriptionModificationDialog/DescriptionModificationDialog.js";
|
|
29
|
+
import "../../../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 "../../../components/ui/dialogs/elementSaveDialog/ElementSaveDialog.js";
|
|
33
|
+
import "../../../components/ui/snackbarProvider/SnackbarProvider.js";
|
|
34
|
+
import "mui-nested-menu";
|
|
35
|
+
import "react-resizable-panels";
|
|
36
|
+
import "react-papaparse";
|
|
37
|
+
import "react-dom";
|
|
38
|
+
import "autosuggest-highlight/match";
|
|
39
|
+
import "autosuggest-highlight/parse";
|
|
40
|
+
import "clsx";
|
|
41
|
+
import "../../../components/composite/filter/FilterCreationDialog.js";
|
|
42
|
+
import "../../../components/composite/filter/HeaderFilterForm.js";
|
|
43
|
+
import "../../../components/composite/filter/explicitNaming/ExplicitNamingFilterForm.js";
|
|
44
|
+
import "../../../components/composite/filter/expert/ExpertFilterForm.js";
|
|
45
|
+
import "../../../components/composite/filter/expert/ExpertFilterEditionDialog.js";
|
|
46
|
+
import "../../../components/composite/filter/expert/expertFilterConstants.js";
|
|
47
|
+
import "react-querybuilder";
|
|
48
|
+
import "uuid";
|
|
49
|
+
import "../../../components/composite/filter/explicitNaming/ExplicitNamingFilterEditionDialog.js";
|
|
50
|
+
import "../../../components/composite/filter/utils/filterFormUtils.js";
|
|
51
|
+
import "@react-querybuilder/material";
|
|
52
|
+
import "../../../components/composite/reactQueryBuilder/CustomReactQueryBuilder.js";
|
|
53
|
+
import "../../../components/composite/reactQueryBuilder/PropertyValueEditor.js";
|
|
54
|
+
import "../../../components/composite/agGridTable/BottomTableButtons.js";
|
|
55
|
+
import "../../../components/composite/agGridTable/CustomAgGridTable.js";
|
|
56
|
+
import "ag-grid-community";
|
|
57
|
+
import "../../../components/composite/customAGGrid/customAggrid.js";
|
|
58
|
+
import "../../../components/composite/customAGGrid/context/custom-aggrid-context.js";
|
|
59
|
+
import "mathjs";
|
|
60
|
+
import "../../../components/composite/report/report-viewer/log-table/log-table.js";
|
|
61
|
+
import "react-window";
|
|
62
|
+
import "../../../components/composite/report/report-treeview/treeview-item.js";
|
|
63
|
+
import "../../../components/composite/report/report-viewer/context/report-viewer-context.js";
|
|
64
|
+
import "../common/regulatingTerminal/RegulatingTerminalForm.js";
|
|
65
|
+
import "@mui/material/colors";
|
|
66
|
+
import "@mui/x-charts";
|
|
67
|
+
import "../common/currentLimits/limitsPane.utils.js";
|
|
68
|
+
import { TabularFieldConstants, PROPERTY_CSV_COLUMN_PREFIX, TABULAR_ENUM, TABULAR_NUMBER, TABULAR_BOOLEAN } from "./tabular.constants.js";
|
|
69
|
+
import { tabularPropertiesSchema } from "./properties/tabularProperty.utils.js";
|
|
70
|
+
import { TabularModificationType } from "./tabular.types.js";
|
|
71
|
+
const tabularFormSchema = yup.object().shape({
|
|
72
|
+
[FieldConstants.TYPE]: yup.string().nullable().required(),
|
|
73
|
+
[TabularFieldConstants.MODIFICATIONS_TABLE]: yup.array().min(1, MODIFICATIONS_REQUIRED_TAB_ERROR).required(),
|
|
74
|
+
[TabularFieldConstants.CSV_FILENAME]: yup.string()
|
|
75
|
+
}).concat(tabularPropertiesSchema).required();
|
|
76
|
+
const getEmptyTabularFormData = (equipmentType) => {
|
|
77
|
+
return {
|
|
78
|
+
[FieldConstants.TYPE]: equipmentType,
|
|
79
|
+
[TabularFieldConstants.MODIFICATIONS_TABLE]: [],
|
|
80
|
+
[TabularFieldConstants.TABULAR_PROPERTIES]: [],
|
|
81
|
+
[TabularFieldConstants.CSV_FILENAME]: void 0
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
const formatModification = (modification) => {
|
|
85
|
+
const { type, date, uuid, ...rest } = modification;
|
|
86
|
+
return rest;
|
|
87
|
+
};
|
|
88
|
+
const addPropertiesFromBack = (modification, tabularProperties) => {
|
|
89
|
+
const updatedModification = { ...modification };
|
|
90
|
+
tabularProperties?.forEach((property) => {
|
|
91
|
+
updatedModification[PROPERTY_CSV_COLUMN_PREFIX + property.name] = property.value;
|
|
92
|
+
});
|
|
93
|
+
return updatedModification;
|
|
94
|
+
};
|
|
95
|
+
const convertReactiveCapabilityCurvePointsFromBackToFront = (value) => {
|
|
96
|
+
const curvePoint1 = value[0];
|
|
97
|
+
const curvePoint2 = value[1];
|
|
98
|
+
const curvePoint3 = value[2];
|
|
99
|
+
if (!curvePoint1) {
|
|
100
|
+
return [];
|
|
101
|
+
}
|
|
102
|
+
const result = [
|
|
103
|
+
{
|
|
104
|
+
key: TabularFieldConstants.REACTIVE_CAPABILITY_CURVE_P_MIN,
|
|
105
|
+
value: curvePoint1.p
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
key: TabularFieldConstants.REACTIVE_CAPABILITY_CURVE_Q_MAX_P_MIN,
|
|
109
|
+
value: curvePoint1.maxQ
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
key: TabularFieldConstants.REACTIVE_CAPABILITY_CURVE_Q_MIN_P_MIN,
|
|
113
|
+
value: curvePoint1.minQ
|
|
114
|
+
}
|
|
115
|
+
];
|
|
116
|
+
if (curvePoint2) {
|
|
117
|
+
const isLastPoint = !curvePoint3;
|
|
118
|
+
result.push(
|
|
119
|
+
{
|
|
120
|
+
key: isLastPoint ? TabularFieldConstants.REACTIVE_CAPABILITY_CURVE_P_MAX : TabularFieldConstants.REACTIVE_CAPABILITY_CURVE_P_0,
|
|
121
|
+
value: curvePoint2.p
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
key: isLastPoint ? TabularFieldConstants.REACTIVE_CAPABILITY_CURVE_Q_MAX_P_MAX : TabularFieldConstants.REACTIVE_CAPABILITY_CURVE_Q_MAX_P_0,
|
|
125
|
+
value: curvePoint2.maxQ
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
key: isLastPoint ? TabularFieldConstants.REACTIVE_CAPABILITY_CURVE_Q_MIN_P_MAX : TabularFieldConstants.REACTIVE_CAPABILITY_CURVE_Q_MIN_P_0,
|
|
129
|
+
value: curvePoint2.minQ
|
|
130
|
+
}
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
if (curvePoint3) {
|
|
134
|
+
result.push(
|
|
135
|
+
{ key: TabularFieldConstants.REACTIVE_CAPABILITY_CURVE_P_MAX, value: curvePoint3.p },
|
|
136
|
+
{ key: TabularFieldConstants.REACTIVE_CAPABILITY_CURVE_Q_MAX_P_MAX, value: curvePoint3.maxQ },
|
|
137
|
+
{ key: TabularFieldConstants.REACTIVE_CAPABILITY_CURVE_Q_MIN_P_MAX, value: curvePoint3.minQ }
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
return result;
|
|
141
|
+
};
|
|
142
|
+
const convertReactiveCapabilityCurvePointsFromFrontToBack = (modification) => {
|
|
143
|
+
if (modification[TabularFieldConstants.REACTIVE_CAPABILITY_CURVE]) {
|
|
144
|
+
const rccPoints = [];
|
|
145
|
+
if (modification[TabularFieldConstants.REACTIVE_CAPABILITY_CURVE_P_MIN] !== null) {
|
|
146
|
+
rccPoints.push({
|
|
147
|
+
p: modification[TabularFieldConstants.REACTIVE_CAPABILITY_CURVE_P_MIN],
|
|
148
|
+
maxQ: modification[TabularFieldConstants.REACTIVE_CAPABILITY_CURVE_Q_MAX_P_MIN],
|
|
149
|
+
minQ: modification[TabularFieldConstants.REACTIVE_CAPABILITY_CURVE_Q_MIN_P_MIN]
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
if (modification[TabularFieldConstants.REACTIVE_CAPABILITY_CURVE_P_0] !== null) {
|
|
153
|
+
rccPoints.push({
|
|
154
|
+
p: modification[TabularFieldConstants.REACTIVE_CAPABILITY_CURVE_P_0],
|
|
155
|
+
maxQ: modification[TabularFieldConstants.REACTIVE_CAPABILITY_CURVE_Q_MAX_P_0],
|
|
156
|
+
minQ: modification[TabularFieldConstants.REACTIVE_CAPABILITY_CURVE_Q_MIN_P_0]
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
if (modification[TabularFieldConstants.REACTIVE_CAPABILITY_CURVE_P_MAX] !== null) {
|
|
160
|
+
rccPoints.push({
|
|
161
|
+
p: modification[TabularFieldConstants.REACTIVE_CAPABILITY_CURVE_P_MAX],
|
|
162
|
+
maxQ: modification[TabularFieldConstants.REACTIVE_CAPABILITY_CURVE_Q_MAX_P_MAX],
|
|
163
|
+
minQ: modification[TabularFieldConstants.REACTIVE_CAPABILITY_CURVE_Q_MIN_P_MAX]
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
modification[TabularFieldConstants.REACTIVE_CAPABILITY_CURVE_POINTS] = rccPoints;
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
const setFieldTypeError = (fieldTypeInError, expectedTypeForFieldInError, tableName, setError, intl, expectedValues) => {
|
|
170
|
+
if (expectedTypeForFieldInError === TABULAR_ENUM) {
|
|
171
|
+
setError(tableName, {
|
|
172
|
+
type: "custom",
|
|
173
|
+
message: intl.formatMessage(
|
|
174
|
+
{ id: "WrongEnumValue" },
|
|
175
|
+
{
|
|
176
|
+
field: fieldTypeInError,
|
|
177
|
+
expectedValues: expectedValues?.join(", ") ?? ""
|
|
178
|
+
}
|
|
179
|
+
)
|
|
180
|
+
});
|
|
181
|
+
} else {
|
|
182
|
+
setError(tableName, {
|
|
183
|
+
type: "custom",
|
|
184
|
+
message: intl.formatMessage(
|
|
185
|
+
{ id: "WrongFieldType" },
|
|
186
|
+
{
|
|
187
|
+
field: fieldTypeInError,
|
|
188
|
+
type: intl.formatMessage({ id: `fieldType.${expectedTypeForFieldInError}` })
|
|
189
|
+
}
|
|
190
|
+
)
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
const isFieldTypeOk = (value, fieldDefinition) => {
|
|
195
|
+
if (!fieldDefinition?.type || value === null || value === void 0) {
|
|
196
|
+
return true;
|
|
197
|
+
}
|
|
198
|
+
switch (fieldDefinition.type) {
|
|
199
|
+
case TABULAR_BOOLEAN:
|
|
200
|
+
if (typeof value !== "boolean") {
|
|
201
|
+
return false;
|
|
202
|
+
}
|
|
203
|
+
break;
|
|
204
|
+
case TABULAR_NUMBER: {
|
|
205
|
+
const parsedNumber = Number.parseFloat(value);
|
|
206
|
+
if (Number.isNaN(parsedNumber)) {
|
|
207
|
+
return false;
|
|
208
|
+
}
|
|
209
|
+
break;
|
|
210
|
+
}
|
|
211
|
+
case TABULAR_ENUM:
|
|
212
|
+
if (!fieldDefinition?.options?.includes(value)) {
|
|
213
|
+
return false;
|
|
214
|
+
}
|
|
215
|
+
break;
|
|
216
|
+
default:
|
|
217
|
+
console.warn(`Unknown type "${fieldDefinition.type}" for value "${value}". Value will be returned as-is.`);
|
|
218
|
+
break;
|
|
219
|
+
}
|
|
220
|
+
return true;
|
|
221
|
+
};
|
|
222
|
+
const sanitizeRowValue = (value, fieldDefinition) => {
|
|
223
|
+
if (fieldDefinition?.type === TABULAR_BOOLEAN && fieldDefinition.required && typeof value !== "boolean") {
|
|
224
|
+
return false;
|
|
225
|
+
}
|
|
226
|
+
if (!isFieldTypeOk(value, fieldDefinition)) {
|
|
227
|
+
return null;
|
|
228
|
+
}
|
|
229
|
+
return value;
|
|
230
|
+
};
|
|
231
|
+
const appendPredefinedPropertyValues = (skeletonComment, predefinedProperties, selectedProperties, separator, columnCount) => {
|
|
232
|
+
let commentLine = skeletonComment.length === 0 ? separator.repeat(columnCount - 1 - selectedProperties.length) : skeletonComment;
|
|
233
|
+
selectedProperties.forEach((propertyName) => {
|
|
234
|
+
const possibleValues = predefinedProperties[propertyName]?.toSorted((a, b) => a.localeCompare(b)) ?? [];
|
|
235
|
+
commentLine += separator + possibleValues.join(" | ");
|
|
236
|
+
});
|
|
237
|
+
return commentLine;
|
|
238
|
+
};
|
|
239
|
+
const generateCommentLines = ({
|
|
240
|
+
fields,
|
|
241
|
+
selectedProperties,
|
|
242
|
+
intl,
|
|
243
|
+
equipmentType,
|
|
244
|
+
language,
|
|
245
|
+
formType,
|
|
246
|
+
predefinedEquipmentProperties
|
|
247
|
+
}) => {
|
|
248
|
+
const csvTranslatedColumns = fields?.map((field) => intl.formatMessage({ id: field.id }) + (field.required ? " (*)" : ""))?.concat(selectedProperties);
|
|
249
|
+
if (!csvTranslatedColumns) {
|
|
250
|
+
return [];
|
|
251
|
+
}
|
|
252
|
+
const separator = getCsvDelimiter(language);
|
|
253
|
+
const commentData = [
|
|
254
|
+
csvTranslatedColumns.map((column, index) => index === 0 ? `#${column}` : column)
|
|
255
|
+
];
|
|
256
|
+
const formTypeKeyPart = formType === TabularModificationType.CREATION ? "Creation" : "Modification";
|
|
257
|
+
const commentKey = `Tabular${formTypeKeyPart}SkeletonComment.${equipmentType}`;
|
|
258
|
+
let secondCommentLine = intl.messages[commentKey] ? intl.formatMessage({ id: commentKey }) : "";
|
|
259
|
+
const networkEquipmentType = equipmentTypesForPredefinedPropertiesMapper(equipmentType);
|
|
260
|
+
const predefinedProperties = networkEquipmentType ? predefinedEquipmentProperties?.[networkEquipmentType] : void 0;
|
|
261
|
+
if (selectedProperties.length && predefinedProperties) {
|
|
262
|
+
secondCommentLine = appendPredefinedPropertyValues(
|
|
263
|
+
secondCommentLine,
|
|
264
|
+
predefinedProperties,
|
|
265
|
+
selectedProperties,
|
|
266
|
+
separator,
|
|
267
|
+
csvTranslatedColumns.length
|
|
268
|
+
);
|
|
269
|
+
}
|
|
270
|
+
if (secondCommentLine.replaceAll(separator, "").length > 0) {
|
|
271
|
+
commentData.push(secondCommentLine.split(separator));
|
|
272
|
+
}
|
|
273
|
+
return commentData;
|
|
274
|
+
};
|
|
275
|
+
const transformProperties = (row) => {
|
|
276
|
+
const propertiesModifications = [];
|
|
277
|
+
Object.keys(row).forEach((key) => {
|
|
278
|
+
if (key.startsWith(PROPERTY_CSV_COLUMN_PREFIX) && row[key]?.length) {
|
|
279
|
+
propertiesModifications.push(
|
|
280
|
+
createPropertyModification(key.replace(PROPERTY_CSV_COLUMN_PREFIX, ""), row[key])
|
|
281
|
+
);
|
|
282
|
+
delete row[key];
|
|
283
|
+
}
|
|
284
|
+
});
|
|
285
|
+
return propertiesModifications;
|
|
286
|
+
};
|
|
287
|
+
const getSelectedTabularPropertyNames = (tabularProperties) => tabularProperties?.filter((property) => property.selected)?.map((property) => property.name) ?? [];
|
|
288
|
+
export {
|
|
289
|
+
addPropertiesFromBack,
|
|
290
|
+
convertReactiveCapabilityCurvePointsFromBackToFront,
|
|
291
|
+
convertReactiveCapabilityCurvePointsFromFrontToBack,
|
|
292
|
+
formatModification,
|
|
293
|
+
generateCommentLines,
|
|
294
|
+
getEmptyTabularFormData,
|
|
295
|
+
getSelectedTabularPropertyNames,
|
|
296
|
+
isFieldTypeOk,
|
|
297
|
+
sanitizeRowValue,
|
|
298
|
+
setFieldTypeError,
|
|
299
|
+
tabularFormSchema,
|
|
300
|
+
transformProperties
|
|
301
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { TabularFieldConstants } from './tabular.constants';
|
|
2
|
+
import { TabularFields, TabularFormDto, TabularModificationDto, TabularModificationRow } from './tabular.types';
|
|
3
|
+
import { TabularFormType } from './tabular.utils';
|
|
4
|
+
export declare const TABULAR_CREATION_FIELDS: TabularFields;
|
|
5
|
+
export declare const TABULAR_CREATION_TYPES: {
|
|
6
|
+
[key: string]: string;
|
|
7
|
+
};
|
|
8
|
+
export declare const convertCreationFieldFromBackToFront: (key: string, value: any) => {
|
|
9
|
+
key: TabularFieldConstants;
|
|
10
|
+
value: number | null;
|
|
11
|
+
}[] | {
|
|
12
|
+
key: string;
|
|
13
|
+
value: any;
|
|
14
|
+
};
|
|
15
|
+
export declare const convertCreationFieldFromFrontToBack: (key: string, value: string | number | boolean) => {
|
|
16
|
+
key: string;
|
|
17
|
+
value: string | number | boolean;
|
|
18
|
+
};
|
|
19
|
+
export declare const getEquipmentTypeFromCreationType: (type: string) => string | undefined;
|
|
20
|
+
export declare const convertCreations: (creations: TabularModificationRow[]) => TabularModificationRow[];
|
|
21
|
+
/** Convert a single form row into its back-end creation representation. */
|
|
22
|
+
export declare const transformRowToBackEndCreation: (row: TabularModificationRow, modificationType: string) => TabularModificationRow;
|
|
23
|
+
export declare const transformCreationsTable: (modificationType: string, creationsTable?: TabularModificationRow[]) => TabularModificationRow[];
|
|
24
|
+
export declare const tabularCreationDtoToForm: (dto: TabularModificationDto) => TabularFormType;
|
|
25
|
+
export declare const tabularCreationFormToDto: (form: TabularFormType) => TabularFormDto;
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
import { v4 } from "uuid";
|
|
2
|
+
import { FieldConstants } from "../../../utils/constants/fieldConstants.js";
|
|
3
|
+
import "../../../utils/conversionUtils.js";
|
|
4
|
+
import { CONNECTION_DIRECTIONS, ENERGY_SOURCES } from "../../../utils/types/equipmentType.js";
|
|
5
|
+
import { MODIFICATION_TYPES, ModificationType } from "../../../utils/types/modificationType.js";
|
|
6
|
+
import "react/jsx-runtime";
|
|
7
|
+
import "@mui/icons-material";
|
|
8
|
+
import { SHUNT_COMPENSATOR_TYPES } from "../shunt-compensator/common/shuntCompensator.utils.js";
|
|
9
|
+
import "@mui/material";
|
|
10
|
+
import "react-hook-form";
|
|
11
|
+
import "react";
|
|
12
|
+
import "react-intl";
|
|
13
|
+
import "../../../components/ui/overflowableText/OverflowableText.js";
|
|
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 "@material-symbols/svg-400/outlined/left_panel_open.svg?react";
|
|
23
|
+
import "@material-symbols/svg-400/outlined/arrows_output.svg?react";
|
|
24
|
+
import "@material-symbols/svg-400/outlined/arrows_input.svg?react";
|
|
25
|
+
import "@material-symbols/svg-400/outlined/left_panel_close.svg?react";
|
|
26
|
+
import "@material-symbols/svg-400/outlined/add_notes-fill.svg?react";
|
|
27
|
+
import "../../../components/ui/dialogs/descriptionModificationDialog/DescriptionModificationDialog.js";
|
|
28
|
+
import "../../../components/ui/reactHookForm/expandableInput/ExpandableInput.js";
|
|
29
|
+
import "../../../components/ui/reactHookForm/directory-item-input/directory-item-utils.js";
|
|
30
|
+
import "@hello-pangea/dnd";
|
|
31
|
+
import "../../../components/ui/dialogs/elementSaveDialog/ElementSaveDialog.js";
|
|
32
|
+
import "../../../components/ui/snackbarProvider/SnackbarProvider.js";
|
|
33
|
+
import "mui-nested-menu";
|
|
34
|
+
import "react-resizable-panels";
|
|
35
|
+
import "react-papaparse";
|
|
36
|
+
import "../common/properties/propertyUtils.js";
|
|
37
|
+
import "react-dom";
|
|
38
|
+
import "autosuggest-highlight/match";
|
|
39
|
+
import "autosuggest-highlight/parse";
|
|
40
|
+
import "clsx";
|
|
41
|
+
import "../../../components/composite/filter/FilterCreationDialog.js";
|
|
42
|
+
import "../../../components/composite/filter/HeaderFilterForm.js";
|
|
43
|
+
import "../../../components/composite/filter/explicitNaming/ExplicitNamingFilterForm.js";
|
|
44
|
+
import "../../../components/composite/filter/expert/ExpertFilterForm.js";
|
|
45
|
+
import "../../../components/composite/filter/expert/ExpertFilterEditionDialog.js";
|
|
46
|
+
import "../../../components/composite/filter/expert/expertFilterConstants.js";
|
|
47
|
+
import "react-querybuilder";
|
|
48
|
+
import "../../../components/composite/filter/explicitNaming/ExplicitNamingFilterEditionDialog.js";
|
|
49
|
+
import "../../../components/composite/filter/utils/filterFormUtils.js";
|
|
50
|
+
import "@react-querybuilder/material";
|
|
51
|
+
import "../../../components/composite/reactQueryBuilder/CustomReactQueryBuilder.js";
|
|
52
|
+
import "../../../components/composite/reactQueryBuilder/PropertyValueEditor.js";
|
|
53
|
+
import "../../../components/composite/agGridTable/BottomTableButtons.js";
|
|
54
|
+
import "../../../components/composite/agGridTable/CustomAgGridTable.js";
|
|
55
|
+
import "ag-grid-community";
|
|
56
|
+
import "../../../components/composite/customAGGrid/customAggrid.js";
|
|
57
|
+
import "../../../components/composite/customAGGrid/context/custom-aggrid-context.js";
|
|
58
|
+
import "mathjs";
|
|
59
|
+
import "../../../components/composite/report/report-viewer/log-table/log-table.js";
|
|
60
|
+
import "react-window";
|
|
61
|
+
import "../../../components/composite/report/report-treeview/treeview-item.js";
|
|
62
|
+
import "../../../components/composite/report/report-viewer/context/report-viewer-context.js";
|
|
63
|
+
import "../common/regulatingTerminal/RegulatingTerminalForm.js";
|
|
64
|
+
import "@mui/material/colors";
|
|
65
|
+
import "@mui/x-charts";
|
|
66
|
+
import "../common/currentLimits/limitsPane.utils.js";
|
|
67
|
+
import "../shunt-compensator/creation/shuntCompensatorCreation.utils.js";
|
|
68
|
+
import "../shunt-compensator/modification/shuntCompensatorModification.utils.js";
|
|
69
|
+
import { TABULAR_BOOLEAN, TabularFieldConstants, TABULAR_NUMBER, TABULAR_ENUM, REGULATING_TERMINAL_TYPES, LOAD_TYPES_FOR_LOAD_TABULAR_CREATION_MODIFICATION } from "./tabular.constants.js";
|
|
70
|
+
import { convertReactiveCapabilityCurvePointsFromBackToFront, formatModification, addPropertiesFromBack, transformProperties, convertReactiveCapabilityCurvePointsFromFrontToBack } from "./tabular.utils.js";
|
|
71
|
+
const REACTIVE_CAPABILITY_CURVE_FIELDS = [
|
|
72
|
+
{ id: TabularFieldConstants.REACTIVE_CAPABILITY_CURVE, required: true, type: TABULAR_BOOLEAN },
|
|
73
|
+
{ id: TabularFieldConstants.REACTIVE_CAPABILITY_CURVE_P_MIN, required: false, type: TABULAR_NUMBER },
|
|
74
|
+
{ id: TabularFieldConstants.REACTIVE_CAPABILITY_CURVE_Q_MIN_P_MIN, required: false, type: TABULAR_NUMBER },
|
|
75
|
+
{ id: TabularFieldConstants.REACTIVE_CAPABILITY_CURVE_Q_MAX_P_MIN, required: false, type: TABULAR_NUMBER },
|
|
76
|
+
{ id: TabularFieldConstants.REACTIVE_CAPABILITY_CURVE_P_0, required: false, type: TABULAR_NUMBER },
|
|
77
|
+
{ id: TabularFieldConstants.REACTIVE_CAPABILITY_CURVE_Q_MIN_P_0, required: false, type: TABULAR_NUMBER },
|
|
78
|
+
{ id: TabularFieldConstants.REACTIVE_CAPABILITY_CURVE_Q_MAX_P_0, required: false, type: TABULAR_NUMBER },
|
|
79
|
+
{ id: TabularFieldConstants.REACTIVE_CAPABILITY_CURVE_P_MAX, required: false, type: TABULAR_NUMBER },
|
|
80
|
+
{ id: TabularFieldConstants.REACTIVE_CAPABILITY_CURVE_Q_MIN_P_MAX, required: false, type: TABULAR_NUMBER },
|
|
81
|
+
{ id: TabularFieldConstants.REACTIVE_CAPABILITY_CURVE_Q_MAX_P_MAX, required: false, type: TABULAR_NUMBER }
|
|
82
|
+
];
|
|
83
|
+
const CONNECTION_FIELDS = [
|
|
84
|
+
{ id: FieldConstants.CONNECTED, required: true, type: TABULAR_BOOLEAN },
|
|
85
|
+
{ id: FieldConstants.CONNECTION_NAME, required: false },
|
|
86
|
+
{
|
|
87
|
+
id: FieldConstants.CONNECTION_DIRECTION,
|
|
88
|
+
required: false,
|
|
89
|
+
type: TABULAR_ENUM,
|
|
90
|
+
options: CONNECTION_DIRECTIONS.map((direction) => direction.id)
|
|
91
|
+
},
|
|
92
|
+
{ id: FieldConstants.CONNECTION_POSITION, required: false, type: TABULAR_NUMBER }
|
|
93
|
+
];
|
|
94
|
+
const VOLTAGE_REGULATION_FIELDS = [
|
|
95
|
+
{ id: TabularFieldConstants.VOLTAGE_REGULATION_ON, required: true, type: TABULAR_BOOLEAN },
|
|
96
|
+
{ id: FieldConstants.TARGET_V, required: false, type: TABULAR_NUMBER },
|
|
97
|
+
{ id: TabularFieldConstants.REGULATING_TERMINAL_ID, required: false },
|
|
98
|
+
{
|
|
99
|
+
id: TabularFieldConstants.REGULATING_TERMINAL_TYPE,
|
|
100
|
+
required: false,
|
|
101
|
+
type: TABULAR_ENUM,
|
|
102
|
+
options: REGULATING_TERMINAL_TYPES
|
|
103
|
+
},
|
|
104
|
+
{ id: FieldConstants.REGULATING_TERMINAL_VOLTAGE_LEVEL_ID, required: false }
|
|
105
|
+
];
|
|
106
|
+
const TABULAR_CREATION_FIELDS = {
|
|
107
|
+
GENERATOR: [
|
|
108
|
+
{ id: TabularFieldConstants.EQUIPMENT_ID, required: true },
|
|
109
|
+
{ id: FieldConstants.EQUIPMENT_NAME, required: false },
|
|
110
|
+
{
|
|
111
|
+
id: FieldConstants.ENERGY_SOURCE,
|
|
112
|
+
required: true,
|
|
113
|
+
type: TABULAR_ENUM,
|
|
114
|
+
options: ENERGY_SOURCES.map((energy) => energy.id)
|
|
115
|
+
},
|
|
116
|
+
{ id: FieldConstants.VOLTAGE_LEVEL_ID, required: true },
|
|
117
|
+
{ id: TabularFieldConstants.BUS_OR_BUSBAR_SECTION_ID, required: true },
|
|
118
|
+
...CONNECTION_FIELDS,
|
|
119
|
+
{ id: TabularFieldConstants.MIN_P, required: true, type: TABULAR_NUMBER },
|
|
120
|
+
{ id: TabularFieldConstants.MAX_P, required: true, type: TABULAR_NUMBER },
|
|
121
|
+
{ id: FieldConstants.RATED_S, required: false, type: TABULAR_NUMBER },
|
|
122
|
+
{ id: FieldConstants.MIN_Q, required: false, type: TABULAR_NUMBER },
|
|
123
|
+
{ id: FieldConstants.MAX_Q, required: false, type: TABULAR_NUMBER },
|
|
124
|
+
...REACTIVE_CAPABILITY_CURVE_FIELDS,
|
|
125
|
+
{ id: TabularFieldConstants.TARGET_P, required: true, type: TABULAR_NUMBER },
|
|
126
|
+
{ id: TabularFieldConstants.TARGET_Q, required: true, type: TABULAR_NUMBER },
|
|
127
|
+
...VOLTAGE_REGULATION_FIELDS,
|
|
128
|
+
{ id: FieldConstants.Q_PERCENT, required: false, type: TABULAR_NUMBER },
|
|
129
|
+
{ id: TabularFieldConstants.PARTICIPATE, required: true, type: TABULAR_BOOLEAN },
|
|
130
|
+
{ id: FieldConstants.DROOP, required: false, type: TABULAR_NUMBER },
|
|
131
|
+
{ id: FieldConstants.TRANSIENT_REACTANCE, required: false, type: TABULAR_NUMBER },
|
|
132
|
+
{ id: TabularFieldConstants.STEP_UP_TRANSFORMER_REACTANCE, required: false, type: TABULAR_NUMBER },
|
|
133
|
+
{ id: FieldConstants.PLANNED_ACTIVE_POWER_SET_POINT, required: false, type: TABULAR_NUMBER },
|
|
134
|
+
{ id: FieldConstants.MARGINAL_COST, required: false, type: TABULAR_NUMBER },
|
|
135
|
+
{ id: FieldConstants.PLANNED_OUTAGE_RATE, required: false, type: TABULAR_NUMBER },
|
|
136
|
+
{ id: FieldConstants.FORCED_OUTAGE_RATE, required: false, type: TABULAR_NUMBER }
|
|
137
|
+
],
|
|
138
|
+
LOAD: [
|
|
139
|
+
{ id: TabularFieldConstants.EQUIPMENT_ID, required: true },
|
|
140
|
+
{ id: FieldConstants.EQUIPMENT_NAME, required: false },
|
|
141
|
+
{
|
|
142
|
+
id: FieldConstants.LOAD_TYPE,
|
|
143
|
+
required: true,
|
|
144
|
+
type: TABULAR_ENUM,
|
|
145
|
+
options: LOAD_TYPES_FOR_LOAD_TABULAR_CREATION_MODIFICATION.map((load) => load.id)
|
|
146
|
+
},
|
|
147
|
+
{ id: FieldConstants.VOLTAGE_LEVEL_ID, required: true },
|
|
148
|
+
{ id: TabularFieldConstants.BUS_OR_BUSBAR_SECTION_ID, required: true },
|
|
149
|
+
...CONNECTION_FIELDS,
|
|
150
|
+
{ id: TabularFieldConstants.P0, required: true, type: TABULAR_NUMBER },
|
|
151
|
+
{ id: FieldConstants.Q0, required: true, type: TABULAR_NUMBER }
|
|
152
|
+
],
|
|
153
|
+
BATTERY: [
|
|
154
|
+
{ id: TabularFieldConstants.EQUIPMENT_ID, required: true },
|
|
155
|
+
{ id: FieldConstants.EQUIPMENT_NAME, required: false },
|
|
156
|
+
{ id: FieldConstants.VOLTAGE_LEVEL_ID, required: true },
|
|
157
|
+
{ id: TabularFieldConstants.BUS_OR_BUSBAR_SECTION_ID, required: true },
|
|
158
|
+
...CONNECTION_FIELDS,
|
|
159
|
+
{ id: TabularFieldConstants.MIN_P, required: true, type: TABULAR_NUMBER },
|
|
160
|
+
{ id: TabularFieldConstants.MAX_P, required: true, type: TABULAR_NUMBER },
|
|
161
|
+
{ id: FieldConstants.MIN_Q, required: false, type: TABULAR_NUMBER },
|
|
162
|
+
{ id: FieldConstants.MAX_Q, required: false, type: TABULAR_NUMBER },
|
|
163
|
+
...REACTIVE_CAPABILITY_CURVE_FIELDS,
|
|
164
|
+
{ id: TabularFieldConstants.TARGET_P, required: true, type: TABULAR_NUMBER },
|
|
165
|
+
{ id: TabularFieldConstants.TARGET_Q, required: true, type: TABULAR_NUMBER },
|
|
166
|
+
{ id: TabularFieldConstants.PARTICIPATE, required: true, type: TABULAR_BOOLEAN },
|
|
167
|
+
{ id: FieldConstants.DROOP, required: false, type: TABULAR_NUMBER },
|
|
168
|
+
...VOLTAGE_REGULATION_FIELDS
|
|
169
|
+
],
|
|
170
|
+
SHUNT_COMPENSATOR: [
|
|
171
|
+
{ id: TabularFieldConstants.EQUIPMENT_ID, required: true },
|
|
172
|
+
{ id: FieldConstants.EQUIPMENT_NAME, required: false },
|
|
173
|
+
{ id: FieldConstants.VOLTAGE_LEVEL_ID, required: true },
|
|
174
|
+
{ id: TabularFieldConstants.BUS_OR_BUSBAR_SECTION_ID, required: true },
|
|
175
|
+
...CONNECTION_FIELDS,
|
|
176
|
+
{ id: FieldConstants.MAXIMUM_SECTION_COUNT, required: true, type: TABULAR_NUMBER },
|
|
177
|
+
{ id: FieldConstants.SECTION_COUNT, required: true, type: TABULAR_NUMBER },
|
|
178
|
+
{
|
|
179
|
+
id: FieldConstants.SHUNT_COMPENSATOR_TYPE,
|
|
180
|
+
requiredIf: { id: FieldConstants.MAX_Q_AT_NOMINAL_V },
|
|
181
|
+
type: TABULAR_ENUM,
|
|
182
|
+
options: Object.keys(SHUNT_COMPENSATOR_TYPES)
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
id: FieldConstants.MAX_Q_AT_NOMINAL_V,
|
|
186
|
+
requiredIf: { id: FieldConstants.SHUNT_COMPENSATOR_TYPE },
|
|
187
|
+
type: TABULAR_NUMBER
|
|
188
|
+
},
|
|
189
|
+
{ id: FieldConstants.MAX_SUSCEPTANCE, required: false, type: TABULAR_NUMBER }
|
|
190
|
+
]
|
|
191
|
+
};
|
|
192
|
+
const TABULAR_CREATION_TYPES = {
|
|
193
|
+
GENERATOR: MODIFICATION_TYPES.GENERATOR_CREATION.type,
|
|
194
|
+
BATTERY: MODIFICATION_TYPES.BATTERY_CREATION.type,
|
|
195
|
+
LOAD: MODIFICATION_TYPES.LOAD_CREATION.type,
|
|
196
|
+
SHUNT_COMPENSATOR: MODIFICATION_TYPES.SHUNT_COMPENSATOR_CREATION.type
|
|
197
|
+
};
|
|
198
|
+
const convertCreationFieldFromBackToFront = (key, value) => {
|
|
199
|
+
if (key === TabularFieldConstants.REACTIVE_CAPABILITY_CURVE_POINTS) {
|
|
200
|
+
return convertReactiveCapabilityCurvePointsFromBackToFront(value);
|
|
201
|
+
}
|
|
202
|
+
return { key, value };
|
|
203
|
+
};
|
|
204
|
+
const convertCreationFieldFromFrontToBack = (key, value) => {
|
|
205
|
+
if (key === FieldConstants.CONNECTION_DIRECTION) {
|
|
206
|
+
return { key, value: value ?? "UNDEFINED" };
|
|
207
|
+
}
|
|
208
|
+
return { key, value };
|
|
209
|
+
};
|
|
210
|
+
const getEquipmentTypeFromCreationType = (type) => {
|
|
211
|
+
return Object.keys(TABULAR_CREATION_TYPES).find((key) => TABULAR_CREATION_TYPES[key] === type);
|
|
212
|
+
};
|
|
213
|
+
const convertCreations = (creations) => {
|
|
214
|
+
return creations.map((creat) => {
|
|
215
|
+
const creation = {};
|
|
216
|
+
Object.keys(formatModification(creat)).forEach((key) => {
|
|
217
|
+
const entry = convertCreationFieldFromBackToFront(key, creat[key]);
|
|
218
|
+
(Array.isArray(entry) ? entry : [entry]).forEach((item) => {
|
|
219
|
+
creation[item.key] = item.value;
|
|
220
|
+
});
|
|
221
|
+
});
|
|
222
|
+
return addPropertiesFromBack(creation, creat?.[TabularFieldConstants.TABULAR_PROPERTIES]);
|
|
223
|
+
});
|
|
224
|
+
};
|
|
225
|
+
const transformRowToBackEndCreation = (row, modificationType) => {
|
|
226
|
+
const creation = {
|
|
227
|
+
type: modificationType
|
|
228
|
+
};
|
|
229
|
+
const propertiesModifications = transformProperties(row);
|
|
230
|
+
Object.keys(row).forEach((key) => {
|
|
231
|
+
const entry = convertCreationFieldFromFrontToBack(key, row[key]);
|
|
232
|
+
creation[entry.key] = entry.value;
|
|
233
|
+
});
|
|
234
|
+
if (modificationType === ModificationType.GENERATOR_CREATION || modificationType === ModificationType.BATTERY_CREATION) {
|
|
235
|
+
convertReactiveCapabilityCurvePointsFromFrontToBack(creation);
|
|
236
|
+
}
|
|
237
|
+
if (propertiesModifications.length > 0) {
|
|
238
|
+
creation[TabularFieldConstants.TABULAR_PROPERTIES] = propertiesModifications;
|
|
239
|
+
}
|
|
240
|
+
return creation;
|
|
241
|
+
};
|
|
242
|
+
const transformCreationsTable = (modificationType, creationsTable = []) => creationsTable.map((row) => transformRowToBackEndCreation(row, modificationType));
|
|
243
|
+
const tabularCreationDtoToForm = (dto) => {
|
|
244
|
+
const creations = convertCreations(dto?.modifications ?? []).map((creation) => ({
|
|
245
|
+
[FieldConstants.AG_GRID_ROW_UUID]: v4(),
|
|
246
|
+
...creation
|
|
247
|
+
}));
|
|
248
|
+
return {
|
|
249
|
+
[FieldConstants.TYPE]: getEquipmentTypeFromCreationType(dto?.modificationType) ?? "",
|
|
250
|
+
[TabularFieldConstants.MODIFICATIONS_TABLE]: creations,
|
|
251
|
+
[TabularFieldConstants.TABULAR_PROPERTIES]: dto?.properties,
|
|
252
|
+
[TabularFieldConstants.CSV_FILENAME]: dto?.csvFilename
|
|
253
|
+
};
|
|
254
|
+
};
|
|
255
|
+
const tabularCreationFormToDto = (form) => {
|
|
256
|
+
const modificationType = TABULAR_CREATION_TYPES[form[FieldConstants.TYPE]];
|
|
257
|
+
return {
|
|
258
|
+
type: ModificationType.TABULAR_CREATION,
|
|
259
|
+
modificationType,
|
|
260
|
+
modifications: transformCreationsTable(modificationType, form[TabularFieldConstants.MODIFICATIONS_TABLE]),
|
|
261
|
+
csvFilename: form[TabularFieldConstants.CSV_FILENAME],
|
|
262
|
+
properties: form[TabularFieldConstants.TABULAR_PROPERTIES]
|
|
263
|
+
};
|
|
264
|
+
};
|
|
265
|
+
export {
|
|
266
|
+
TABULAR_CREATION_FIELDS,
|
|
267
|
+
TABULAR_CREATION_TYPES,
|
|
268
|
+
convertCreationFieldFromBackToFront,
|
|
269
|
+
convertCreationFieldFromFrontToBack,
|
|
270
|
+
convertCreations,
|
|
271
|
+
getEquipmentTypeFromCreationType,
|
|
272
|
+
tabularCreationDtoToForm,
|
|
273
|
+
tabularCreationFormToDto,
|
|
274
|
+
transformCreationsTable,
|
|
275
|
+
transformRowToBackEndCreation
|
|
276
|
+
};
|