@gridsuite/commons-ui 0.183.0 → 0.184.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/network-modifications/common/connectivity/ConnectivityForm.d.ts +1 -4
- package/dist/components/network-modifications/common/connectivity/ConnectivityForm.js +33 -22
- package/dist/components/network-modifications/common/connectivity/connectivity.type.d.ts +12 -2
- package/dist/components/network-modifications/voltage-level/creation/coupling-omnibus/CouplingOmnibusForm.js +53 -27
- package/package.json +1 -1
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { GridDirection } from '@mui/material';
|
|
2
2
|
import { ConnectablePositionFormInfos, ConnectivityNetworkProps } from './connectivity.type';
|
|
3
|
-
import { Option } from '../../../../utils';
|
|
4
3
|
/**
|
|
5
4
|
* Hook to handle a 'connectivity value' (voltage level, bus or bus bar section)
|
|
6
5
|
* @param id optional id that has to be defined if the component is used more than once in a form
|
|
@@ -8,7 +7,6 @@ import { Option } from '../../../../utils';
|
|
|
8
7
|
* @param direction direction of placement. Either 'row' or 'column', 'row' by default.
|
|
9
8
|
* @param withDirectionsInfos
|
|
10
9
|
* @param withPosition
|
|
11
|
-
* @param newBusOrBusbarSectionOptions list of bus or bus bar sections for the newly created voltage level
|
|
12
10
|
* @param onVoltageLevelChangeCallback callback to be called when the voltage level changes
|
|
13
11
|
* @param isEquipmentModification connectivity form is used in a modification form or not
|
|
14
12
|
* @param previousValues previous values of connectivity form's fields
|
|
@@ -23,7 +21,6 @@ interface ConnectivityFormProps extends ConnectivityNetworkProps {
|
|
|
23
21
|
direction?: GridDirection;
|
|
24
22
|
withDirectionsInfos?: boolean;
|
|
25
23
|
withPosition: boolean;
|
|
26
|
-
newBusOrBusbarSectionOptions?: Option[];
|
|
27
24
|
onVoltageLevelChangeCallback?: () => void;
|
|
28
25
|
isEquipmentModification?: boolean;
|
|
29
26
|
previousValues?: {
|
|
@@ -33,5 +30,5 @@ interface ConnectivityFormProps extends ConnectivityNetworkProps {
|
|
|
33
30
|
terminalConnected?: boolean | null;
|
|
34
31
|
};
|
|
35
32
|
}
|
|
36
|
-
export declare function ConnectivityForm({ id, voltageLevelSelectLabel, direction, withDirectionsInfos, withPosition,
|
|
33
|
+
export declare function ConnectivityForm({ id, voltageLevelSelectLabel, direction, withDirectionsInfos, withPosition, onVoltageLevelChangeCallback, isEquipmentModification, previousValues, voltageLevelOptions, PositionDiagramPane, fetchBusesOrBusbarSections, }: Readonly<ConnectivityFormProps>): import("react/jsx-runtime").JSX.Element;
|
|
37
34
|
export {};
|
|
@@ -5,6 +5,7 @@ import { useState, useRef, useMemo, useEffect, useCallback } from "react";
|
|
|
5
5
|
import { useWatch } from "react-hook-form";
|
|
6
6
|
import { useIntl } from "react-intl";
|
|
7
7
|
import { getConnectivityVoltageLevelData, getConnectivityBusBarSectionData } from "./connectivityForm.utils.js";
|
|
8
|
+
import { fetchBusBarSectionsForNewCoupler } from "../../../../services/networkModification.js";
|
|
8
9
|
import { FieldConstants } from "../../../../utils/constants/fieldConstants.js";
|
|
9
10
|
import "../../../../utils/conversionUtils.js";
|
|
10
11
|
import { getConnectionDirectionLabel, CONNECTION_DIRECTIONS } from "../../../../utils/types/equipmentType.js";
|
|
@@ -48,7 +49,6 @@ function ConnectivityForm({
|
|
|
48
49
|
direction = "row",
|
|
49
50
|
withDirectionsInfos = true,
|
|
50
51
|
withPosition = false,
|
|
51
|
-
newBusOrBusbarSectionOptions = [],
|
|
52
52
|
onVoltageLevelChangeCallback = void 0,
|
|
53
53
|
isEquipmentModification = false,
|
|
54
54
|
previousValues,
|
|
@@ -67,26 +67,42 @@ function ConnectivityForm({
|
|
|
67
67
|
const vlOptions = useMemo(
|
|
68
68
|
() => voltageLevelOptions.map((item) => ({
|
|
69
69
|
id: item.id,
|
|
70
|
-
label: item.name ?? ""
|
|
70
|
+
label: item.name ?? "",
|
|
71
|
+
exist: item.exist
|
|
71
72
|
})),
|
|
72
73
|
[voltageLevelOptions]
|
|
73
74
|
);
|
|
74
75
|
useEffect(() => {
|
|
75
|
-
if (!fetchBusesOrBusbarSections) {
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
76
|
if (watchVoltageLevelId) {
|
|
79
|
-
const
|
|
80
|
-
if (
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
77
|
+
const selectedOption = voltageLevelOptions.find((option) => option.id === watchVoltageLevelId);
|
|
78
|
+
if (selectedOption) {
|
|
79
|
+
if (selectedOption.exist === false) {
|
|
80
|
+
fetchBusBarSectionsForNewCoupler(
|
|
81
|
+
watchVoltageLevelId,
|
|
82
|
+
selectedOption.busbarCount,
|
|
83
|
+
selectedOption.sectionCount,
|
|
84
|
+
selectedOption.switchKinds
|
|
85
|
+
).then((ids) => {
|
|
86
|
+
lastFetchedBusesVlIds.current = watchVoltageLevelId;
|
|
87
|
+
setBusOrBusbarSectionOptions(ids.map((bbsId) => ({ id: bbsId, label: "" })));
|
|
88
|
+
}).catch((error) => {
|
|
89
|
+
console.error("Failed to fetch busbar sections for new coupler:", error);
|
|
90
|
+
setBusOrBusbarSectionOptions([]);
|
|
91
|
+
});
|
|
92
|
+
} else if (fetchBusesOrBusbarSections) {
|
|
93
|
+
fetchBusesOrBusbarSections(watchVoltageLevelId).then((busesOrbusbarSections) => {
|
|
94
|
+
lastFetchedBusesVlIds.current = watchVoltageLevelId;
|
|
95
|
+
setBusOrBusbarSectionOptions(
|
|
96
|
+
busesOrbusbarSections?.map((busesOrbusbarSection) => ({
|
|
97
|
+
id: busesOrbusbarSection.id,
|
|
98
|
+
label: busesOrbusbarSection?.name ?? ""
|
|
99
|
+
})) || []
|
|
100
|
+
);
|
|
101
|
+
}).catch((error) => {
|
|
102
|
+
console.error("Failed to fetch buses or busbar sections:", error);
|
|
103
|
+
setBusOrBusbarSectionOptions([]);
|
|
104
|
+
});
|
|
105
|
+
}
|
|
90
106
|
}
|
|
91
107
|
if (watchVoltageLevelId !== lastFetchedBusesVlIds.current) {
|
|
92
108
|
setBusOrBusbarSectionOptions([]);
|
|
@@ -94,12 +110,7 @@ function ConnectivityForm({
|
|
|
94
110
|
} else {
|
|
95
111
|
setBusOrBusbarSectionOptions([]);
|
|
96
112
|
}
|
|
97
|
-
}, [
|
|
98
|
-
useEffect(() => {
|
|
99
|
-
if (newBusOrBusbarSectionOptions?.length > 0) {
|
|
100
|
-
setBusOrBusbarSectionOptions(newBusOrBusbarSectionOptions);
|
|
101
|
-
}
|
|
102
|
-
}, [newBusOrBusbarSectionOptions]);
|
|
113
|
+
}, [fetchBusesOrBusbarSections, voltageLevelOptions, watchVoltageLevelId]);
|
|
103
114
|
const handleChangeVoltageLevel = useCallback(() => {
|
|
104
115
|
onVoltageLevelChangeCallback?.();
|
|
105
116
|
setValue(`${id}.${FieldConstants.BUS_OR_BUSBAR_SECTION}`, null);
|
|
@@ -26,9 +26,19 @@ type PositionDiagramPaneType = React.ComponentType<{
|
|
|
26
26
|
onClose: () => void;
|
|
27
27
|
voltageLevelId: string;
|
|
28
28
|
}>;
|
|
29
|
+
interface NewVoltageLevelOption extends Identifiable {
|
|
30
|
+
exist: false;
|
|
31
|
+
busbarCount: number;
|
|
32
|
+
sectionCount: number;
|
|
33
|
+
switchKinds: string[];
|
|
34
|
+
}
|
|
35
|
+
interface ExistingVoltageLevelOption extends Identifiable {
|
|
36
|
+
exist?: true;
|
|
37
|
+
}
|
|
38
|
+
export type VoltageLevelOption = NewVoltageLevelOption | ExistingVoltageLevelOption;
|
|
29
39
|
export interface ConnectivityNetworkProps {
|
|
30
|
-
voltageLevelOptions
|
|
40
|
+
voltageLevelOptions: VoltageLevelOption[];
|
|
31
41
|
PositionDiagramPane?: PositionDiagramPaneType;
|
|
32
|
-
fetchBusesOrBusbarSections
|
|
42
|
+
fetchBusesOrBusbarSections: (voltageLevelId: string) => Promise<Identifiable[]>;
|
|
33
43
|
}
|
|
34
44
|
export {};
|
|
@@ -1,14 +1,41 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useState, useEffect } from "react";
|
|
2
|
+
import { useState, useCallback, useEffect } from "react";
|
|
3
3
|
import { useFormContext } from "react-hook-form";
|
|
4
4
|
import { CouplingOmnibusCreation } from "./CouplingOmnibusCreation.js";
|
|
5
|
-
import
|
|
5
|
+
import "react-intl";
|
|
6
|
+
import "@mui/material";
|
|
7
|
+
import "../../../../overflowableText/OverflowableText.js";
|
|
6
8
|
import { FieldConstants } from "../../../../../utils/constants/fieldConstants.js";
|
|
7
9
|
import "../../../../../utils/conversionUtils.js";
|
|
8
10
|
import "../../../../../utils/types/equipmentType.js";
|
|
9
11
|
import "@mui/icons-material";
|
|
10
12
|
import "../../../../../utils/yupConfig.js";
|
|
11
13
|
import { fetchBusBarSectionsForNewCoupler } from "../../../../../services/networkModification.js";
|
|
14
|
+
import "localized-countries";
|
|
15
|
+
import "localized-countries/data/fr";
|
|
16
|
+
import "localized-countries/data/en";
|
|
17
|
+
import "notistack";
|
|
18
|
+
import "../../../../inputs/reactHookForm/provider/CustomFormProvider.js";
|
|
19
|
+
import "yup";
|
|
20
|
+
import "../../../../treeViewFinder/TreeViewFinder.js";
|
|
21
|
+
import "../../../../inputs/reactHookForm/agGridTable/BottomRightButtons.js";
|
|
22
|
+
import "../../../../customAGGrid/customAggrid.js";
|
|
23
|
+
import "ag-grid-community";
|
|
24
|
+
import "react-papaparse";
|
|
25
|
+
import "react-csv-downloader";
|
|
26
|
+
import "../../../../inputs/reactHookForm/numbers/RangeInput.js";
|
|
27
|
+
import "@material-symbols/svg-400/outlined/left_panel_open.svg?react";
|
|
28
|
+
import "@material-symbols/svg-400/outlined/arrows_output.svg?react";
|
|
29
|
+
import "@material-symbols/svg-400/outlined/left_panel_close.svg?react";
|
|
30
|
+
import "@material-symbols/svg-400/outlined/add_notes.svg?react";
|
|
31
|
+
import "../../../../dialogs/descriptionModificationDialog/DescriptionModificationDialog.js";
|
|
32
|
+
import { ExpandableInput } from "../../../../inputs/reactHookForm/expandableInput/ExpandableInput.js";
|
|
33
|
+
import "@react-querybuilder/material";
|
|
34
|
+
import "../../../../filter/expert/expertFilterConstants.js";
|
|
35
|
+
import "../../../../inputs/reactQueryBuilder/CustomReactQueryBuilder.js";
|
|
36
|
+
import "uuid";
|
|
37
|
+
import "../../../../inputs/reactQueryBuilder/PropertyValueEditor.js";
|
|
38
|
+
import "react-querybuilder";
|
|
12
39
|
function CouplingOmnibusForm() {
|
|
13
40
|
const { setValue, subscribe, trigger, getValues, formState } = useFormContext();
|
|
14
41
|
const couplingOmnibusCreation = {
|
|
@@ -16,19 +43,29 @@ function CouplingOmnibusForm() {
|
|
|
16
43
|
[FieldConstants.BUS_BAR_SECTION_ID2]: null
|
|
17
44
|
};
|
|
18
45
|
const [sectionOptions, setSectionOptions] = useState([]);
|
|
46
|
+
const setBbsOptions = useCallback(
|
|
47
|
+
(onFetchSuccess) => {
|
|
48
|
+
const equipmentId = getValues(FieldConstants.EQUIPMENT_ID);
|
|
49
|
+
const busBarCount = getValues(FieldConstants.BUS_BAR_COUNT);
|
|
50
|
+
const sectionCount = getValues(FieldConstants.SECTION_COUNT);
|
|
51
|
+
if (!equipmentId || !busBarCount || !sectionCount) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const switchKinds = getValues(FieldConstants.SWITCH_KINDS).map(
|
|
55
|
+
(value) => value.switchKind
|
|
56
|
+
);
|
|
57
|
+
fetchBusBarSectionsForNewCoupler(equipmentId, busBarCount, sectionCount, switchKinds).then((bbsIds) => {
|
|
58
|
+
setSectionOptions(bbsIds);
|
|
59
|
+
if (onFetchSuccess) {
|
|
60
|
+
onFetchSuccess({ sectionOptions: bbsIds });
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
},
|
|
64
|
+
[getValues]
|
|
65
|
+
);
|
|
19
66
|
useEffect(() => {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
);
|
|
23
|
-
fetchBusBarSectionsForNewCoupler(
|
|
24
|
-
getValues(FieldConstants.EQUIPMENT_ID),
|
|
25
|
-
getValues(FieldConstants.BUS_BAR_COUNT),
|
|
26
|
-
getValues(FieldConstants.SECTION_COUNT),
|
|
27
|
-
switchKinds
|
|
28
|
-
).then((bbsIds) => {
|
|
29
|
-
setSectionOptions(bbsIds);
|
|
30
|
-
});
|
|
31
|
-
}, [getValues]);
|
|
67
|
+
setBbsOptions();
|
|
68
|
+
}, [setBbsOptions]);
|
|
32
69
|
useEffect(() => {
|
|
33
70
|
const unsubscribe = subscribe({
|
|
34
71
|
name: [
|
|
@@ -41,22 +78,11 @@ function CouplingOmnibusForm() {
|
|
|
41
78
|
values: true
|
|
42
79
|
},
|
|
43
80
|
callback: () => {
|
|
44
|
-
|
|
45
|
-
(value) => value.switchKind
|
|
46
|
-
);
|
|
47
|
-
fetchBusBarSectionsForNewCoupler(
|
|
48
|
-
getValues(FieldConstants.EQUIPMENT_ID),
|
|
49
|
-
getValues(FieldConstants.BUS_BAR_COUNT),
|
|
50
|
-
getValues(FieldConstants.SECTION_COUNT),
|
|
51
|
-
switchKinds
|
|
52
|
-
).then((bbsIds) => {
|
|
53
|
-
setValue(FieldConstants.COUPLING_OMNIBUS, []);
|
|
54
|
-
setSectionOptions(bbsIds);
|
|
55
|
-
});
|
|
81
|
+
setBbsOptions(() => setValue(FieldConstants.COUPLING_OMNIBUS, []));
|
|
56
82
|
}
|
|
57
83
|
});
|
|
58
84
|
return () => unsubscribe();
|
|
59
|
-
}, [subscribe, trigger,
|
|
85
|
+
}, [subscribe, trigger, setValue, formState, setBbsOptions]);
|
|
60
86
|
return /* @__PURE__ */ jsx(
|
|
61
87
|
ExpandableInput,
|
|
62
88
|
{
|