@gridsuite/commons-ui 0.189.0 → 0.190.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/customAGGrid/cell-renderers.js +28 -26
- package/dist/components/dnd-table/dnd-table.js +71 -34
- package/dist/components/index.js +16 -6
- package/dist/components/inputs/index.js +2 -0
- package/dist/components/inputs/reactHookForm/index.js +2 -0
- package/dist/components/inputs/reactHookForm/selectInputs/SelectWithConfirmationInput.d.ts +9 -0
- package/dist/components/inputs/reactHookForm/selectInputs/SelectWithConfirmationInput.js +64 -0
- package/dist/components/inputs/reactHookForm/selectInputs/index.d.ts +1 -0
- package/dist/components/inputs/reactHookForm/selectInputs/index.js +3 -1
- package/dist/components/network-modifications/by-filter/assignment/assignment/assignment-constants.d.ts +16 -0
- package/dist/components/network-modifications/by-filter/assignment/assignment/assignment-constants.js +402 -0
- package/dist/components/network-modifications/by-filter/assignment/assignment/assignment-form.d.ts +12 -0
- package/dist/components/network-modifications/by-filter/assignment/assignment/assignment-form.js +217 -0
- package/dist/components/network-modifications/by-filter/assignment/assignment/assignment-utils.d.ts +21 -0
- package/dist/components/network-modifications/by-filter/assignment/assignment/assignment-utils.js +89 -0
- package/dist/components/network-modifications/by-filter/assignment/assignment/assignment.type.d.ts +28 -0
- package/dist/components/network-modifications/by-filter/assignment/assignment/assignment.type.js +12 -0
- package/dist/components/network-modifications/by-filter/assignment/index.d.ts +10 -0
- package/dist/components/network-modifications/by-filter/assignment/index.js +11 -0
- package/dist/components/network-modifications/by-filter/assignment/modification-by-assignment-form.d.ts +7 -0
- package/dist/components/network-modifications/by-filter/assignment/modification-by-assignment-form.js +89 -0
- package/dist/components/network-modifications/by-filter/assignment/modificationByAssignment.types.d.ts +7 -0
- package/dist/components/network-modifications/by-filter/assignment/modificationByAssignment.types.js +1 -0
- package/dist/components/network-modifications/by-filter/assignment/modificationByAssignment.utils.d.ts +22 -0
- package/dist/components/network-modifications/by-filter/assignment/modificationByAssignment.utils.js +55 -0
- package/dist/components/network-modifications/by-filter/index.d.ts +1 -0
- package/dist/components/network-modifications/by-filter/index.js +10 -1
- package/dist/components/network-modifications/hooks/index.d.ts +7 -0
- package/dist/components/network-modifications/hooks/index.js +4 -0
- package/dist/components/network-modifications/hooks/useTabsWithError.d.ts +15 -0
- package/dist/components/network-modifications/hooks/useTabsWithError.js +28 -0
- package/dist/components/network-modifications/index.d.ts +1 -0
- package/dist/components/network-modifications/index.js +14 -6
- package/dist/components/network-modifications/load/common/LoadForm.d.ts +1 -1
- package/dist/components/network-modifications/load/common/LoadForm.js +7 -27
- package/dist/components/network-modifications/load/common/index.js +2 -1
- package/dist/components/network-modifications/load/common/load.utils.d.ts +7 -11
- package/dist/components/network-modifications/load/common/load.utils.js +30 -4
- package/dist/components/network-modifications/load/index.js +2 -1
- package/dist/components/network-modifications/voltageLevel/creation/VoltageLevelCreationForm.js +9 -29
- package/dist/components/network-modifications/voltageLevel/creation/index.js +1 -5
- package/dist/components/network-modifications/voltageLevel/creation/voltageLevel.constants.d.ts +8 -12
- package/dist/components/network-modifications/voltageLevel/creation/voltageLevel.constants.js +53 -5
- package/dist/components/network-modifications/voltageLevel/creation/voltageLevelCreation.utils.d.ts +0 -4
- package/dist/components/network-modifications/voltageLevel/creation/voltageLevelCreation.utils.js +0 -16
- package/dist/components/network-modifications/voltageLevel/index.js +1 -5
- package/dist/components/parameters/dynamic-margin-calculation/loads-variations-parameters.js +1 -0
- package/dist/components/parameters/voltage-init/use-voltage-init-parameters-form.js +1 -0
- package/dist/components/parameters/voltage-init/voltage-init-form-utils.js +1 -0
- package/dist/index.js +16 -6
- package/dist/translations/en/networkModificationsEn.d.ts +51 -0
- package/dist/translations/en/networkModificationsEn.js +51 -0
- package/dist/translations/fr/networkModificationsFr.d.ts +51 -0
- package/dist/translations/fr/networkModificationsFr.js +51 -0
- package/dist/utils/constants/fieldConstants.d.ts +2 -0
- package/dist/utils/constants/fieldConstants.js +2 -0
- package/package.json +1 -1
package/dist/components/network-modifications/by-filter/assignment/assignment/assignment-utils.js
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { FieldConstants } from "../../../../../utils/constants/fieldConstants.js";
|
|
2
|
+
import "../../../../../utils/conversionUtils.js";
|
|
3
|
+
import "../../../../../utils/types/equipmentType.js";
|
|
4
|
+
import "react/jsx-runtime";
|
|
5
|
+
import "@mui/icons-material";
|
|
6
|
+
import "../../../../../utils/yupConfig.js";
|
|
7
|
+
import { DataType } from "./assignment.type.js";
|
|
8
|
+
import { FIELD_OPTIONS } from "./assignment-constants.js";
|
|
9
|
+
import * as yup from "yup";
|
|
10
|
+
const getFieldOption = (fieldName) => {
|
|
11
|
+
return Object.values(FIELD_OPTIONS).find((fieldOption) => fieldOption.id === fieldName);
|
|
12
|
+
};
|
|
13
|
+
const getDataType = (fieldName) => {
|
|
14
|
+
return getFieldOption(fieldName)?.dataType;
|
|
15
|
+
};
|
|
16
|
+
const getUnsettable = (fieldName) => {
|
|
17
|
+
return getFieldOption(fieldName)?.settableToNone;
|
|
18
|
+
};
|
|
19
|
+
function getValueSchema(emptyValueStr, dataType, settable_to_none) {
|
|
20
|
+
let schema;
|
|
21
|
+
switch (dataType) {
|
|
22
|
+
case DataType.DOUBLE:
|
|
23
|
+
schema = settable_to_none ? yup.string().test("is-number-or-none", "NumericValueOrEmptyField", (value) => {
|
|
24
|
+
return value === emptyValueStr || !Number.isNaN(Number(value));
|
|
25
|
+
}) : yup.number();
|
|
26
|
+
break;
|
|
27
|
+
case DataType.INTEGER:
|
|
28
|
+
schema = yup.number().integer();
|
|
29
|
+
break;
|
|
30
|
+
case DataType.ENUM:
|
|
31
|
+
case DataType.PROPERTY:
|
|
32
|
+
schema = yup.string();
|
|
33
|
+
break;
|
|
34
|
+
case DataType.BOOLEAN:
|
|
35
|
+
schema = yup.boolean();
|
|
36
|
+
break;
|
|
37
|
+
case DataType.STRING:
|
|
38
|
+
schema = yup.string();
|
|
39
|
+
break;
|
|
40
|
+
default:
|
|
41
|
+
schema = yup.number();
|
|
42
|
+
}
|
|
43
|
+
return schema.required();
|
|
44
|
+
}
|
|
45
|
+
const getAssignmentInitialValue = () => ({
|
|
46
|
+
[FieldConstants.FILTERS]: [],
|
|
47
|
+
[FieldConstants.EDITED_FIELD]: null,
|
|
48
|
+
[FieldConstants.PROPERTY_NAME]: null,
|
|
49
|
+
[FieldConstants.VALUE]: null
|
|
50
|
+
});
|
|
51
|
+
function getAssignmentsSchema(emptyValueStr) {
|
|
52
|
+
return yup.array().of(
|
|
53
|
+
yup.object().shape({
|
|
54
|
+
[FieldConstants.FILTERS]: yup.array().of(
|
|
55
|
+
yup.object().shape({
|
|
56
|
+
[FieldConstants.ID]: yup.string().required(),
|
|
57
|
+
[FieldConstants.NAME]: yup.string().required()
|
|
58
|
+
})
|
|
59
|
+
).required().min(1, "YupRequired"),
|
|
60
|
+
[FieldConstants.EDITED_FIELD]: yup.string().required(),
|
|
61
|
+
[FieldConstants.PROPERTY_NAME]: yup.string().when([FieldConstants.EDITED_FIELD], ([editedField], schema) => {
|
|
62
|
+
const dataType = getDataType(editedField);
|
|
63
|
+
if (dataType === DataType.PROPERTY) {
|
|
64
|
+
return schema.required();
|
|
65
|
+
}
|
|
66
|
+
return schema.nullable();
|
|
67
|
+
}),
|
|
68
|
+
[FieldConstants.VALUE]: yup.mixed().when([FieldConstants.EDITED_FIELD], ([editedField]) => {
|
|
69
|
+
const dataType = getDataType(editedField);
|
|
70
|
+
const unsettable = getUnsettable(editedField);
|
|
71
|
+
return getValueSchema(emptyValueStr, dataType, unsettable);
|
|
72
|
+
}).required()
|
|
73
|
+
})
|
|
74
|
+
).required();
|
|
75
|
+
}
|
|
76
|
+
function getAssignmentFromEditData(assignment) {
|
|
77
|
+
return {
|
|
78
|
+
...assignment,
|
|
79
|
+
[FieldConstants.FILTERS]: assignment.filters.map((filter) => ({ ...filter }))
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
export {
|
|
83
|
+
getAssignmentFromEditData,
|
|
84
|
+
getAssignmentInitialValue,
|
|
85
|
+
getAssignmentsSchema,
|
|
86
|
+
getDataType,
|
|
87
|
+
getFieldOption,
|
|
88
|
+
getUnsettable
|
|
89
|
+
};
|
package/dist/components/network-modifications/by-filter/assignment/assignment/assignment.type.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Option } from '../../../../../utils';
|
|
2
|
+
import { Filter } from '../../commons/by-filter.type';
|
|
3
|
+
export declare enum DataType {
|
|
4
|
+
ENUM = "ENUM",
|
|
5
|
+
BOOLEAN = "BOOLEAN",
|
|
6
|
+
INTEGER = "INTEGER",
|
|
7
|
+
DOUBLE = "DOUBLE",
|
|
8
|
+
PROPERTY = "PROPERTY",
|
|
9
|
+
STRING = "STRING"
|
|
10
|
+
}
|
|
11
|
+
export type FieldOptionType = {
|
|
12
|
+
id: string;
|
|
13
|
+
label: string;
|
|
14
|
+
unit?: string;
|
|
15
|
+
dataType: DataType;
|
|
16
|
+
settableToNone?: boolean;
|
|
17
|
+
values?: Option[];
|
|
18
|
+
outputConverter?: (value: number) => number | undefined;
|
|
19
|
+
inputConverter?: (value: number) => number | undefined;
|
|
20
|
+
};
|
|
21
|
+
export type Assignment = {
|
|
22
|
+
filters: Filter[];
|
|
23
|
+
editedField: string;
|
|
24
|
+
dataType: DataType;
|
|
25
|
+
value: string | number | boolean;
|
|
26
|
+
propertyName?: string;
|
|
27
|
+
};
|
|
28
|
+
export type FieldValue = string | number | boolean;
|
package/dist/components/network-modifications/by-filter/assignment/assignment/assignment.type.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
var DataType = /* @__PURE__ */ ((DataType2) => {
|
|
2
|
+
DataType2["ENUM"] = "ENUM";
|
|
3
|
+
DataType2["BOOLEAN"] = "BOOLEAN";
|
|
4
|
+
DataType2["INTEGER"] = "INTEGER";
|
|
5
|
+
DataType2["DOUBLE"] = "DOUBLE";
|
|
6
|
+
DataType2["PROPERTY"] = "PROPERTY";
|
|
7
|
+
DataType2["STRING"] = "STRING";
|
|
8
|
+
return DataType2;
|
|
9
|
+
})(DataType || {});
|
|
10
|
+
export {
|
|
11
|
+
DataType
|
|
12
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
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-assignment-form';
|
|
8
|
+
export * from './modificationByAssignment.types';
|
|
9
|
+
export * from './modificationByAssignment.utils';
|
|
10
|
+
export { DataType as AssignmentDataType, type FieldValue as AssignmentFieldValue } from './assignment/assignment.type';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ModificationByAssignmentForm } from "./modification-by-assignment-form.js";
|
|
2
|
+
import { emptyModificationByAssignmentFormData, modificationByAssignmentDtoToForm, modificationByAssignmentFormSchema, modificationByAssignmentFormToDto } from "./modificationByAssignment.utils.js";
|
|
3
|
+
import { DataType } from "./assignment/assignment.type.js";
|
|
4
|
+
export {
|
|
5
|
+
DataType as AssignmentDataType,
|
|
6
|
+
ModificationByAssignmentForm,
|
|
7
|
+
emptyModificationByAssignmentFormData,
|
|
8
|
+
modificationByAssignmentDtoToForm,
|
|
9
|
+
modificationByAssignmentFormSchema,
|
|
10
|
+
modificationByAssignmentFormToDto
|
|
11
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
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 declare function ModificationByAssignmentForm(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Box, Grid } from "@mui/material";
|
|
3
|
+
import { useFormContext } from "react-hook-form";
|
|
4
|
+
import "react-intl";
|
|
5
|
+
import "../../../overflowableText/OverflowableText.js";
|
|
6
|
+
import { FieldConstants } from "../../../../utils/constants/fieldConstants.js";
|
|
7
|
+
import "../../../../utils/conversionUtils.js";
|
|
8
|
+
import "../../../../utils/types/equipmentType.js";
|
|
9
|
+
import "@mui/icons-material";
|
|
10
|
+
import { mergeSx } from "../../../../utils/styles.js";
|
|
11
|
+
import "../../../../utils/yupConfig.js";
|
|
12
|
+
import "react";
|
|
13
|
+
import "localized-countries";
|
|
14
|
+
import "localized-countries/data/fr";
|
|
15
|
+
import "localized-countries/data/en";
|
|
16
|
+
import "notistack";
|
|
17
|
+
import { useGetLabelEquipmentTypes } from "../../../../hooks/useGetLabelEquipmentTypes.js";
|
|
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 { SelectWithConfirmationInput } from "../../../inputs/reactHookForm/selectInputs/SelectWithConfirmationInput.js";
|
|
28
|
+
import "@material-symbols/svg-400/outlined/left_panel_open.svg?react";
|
|
29
|
+
import "@material-symbols/svg-400/outlined/arrows_output.svg?react";
|
|
30
|
+
import "@material-symbols/svg-400/outlined/left_panel_close.svg?react";
|
|
31
|
+
import "@material-symbols/svg-400/outlined/add_notes.svg?react";
|
|
32
|
+
import "../../../dialogs/descriptionModificationDialog/DescriptionModificationDialog.js";
|
|
33
|
+
import { ExpandableInput } from "../../../inputs/reactHookForm/expandableInput/ExpandableInput.js";
|
|
34
|
+
import "@react-querybuilder/material";
|
|
35
|
+
import "../../../filter/expert/expertFilterConstants.js";
|
|
36
|
+
import "../../../inputs/reactQueryBuilder/CustomReactQueryBuilder.js";
|
|
37
|
+
import "uuid";
|
|
38
|
+
import "../../../inputs/reactQueryBuilder/PropertyValueEditor.js";
|
|
39
|
+
import "react-querybuilder";
|
|
40
|
+
import { unscrollableDialogStyles } from "../../../dialogs/customMuiDialog/CustomMuiDialog.js";
|
|
41
|
+
import "../../../dialogs/elementSaveDialog/ElementSaveDialog.js";
|
|
42
|
+
import GridItem from "../../../grid/grid-item.js";
|
|
43
|
+
import AssignmentForm from "./assignment/assignment-form.js";
|
|
44
|
+
import { getAssignmentInitialValue } from "./assignment/assignment-utils.js";
|
|
45
|
+
import { EQUIPMENTS_FIELDS } from "./assignment/assignment-constants.js";
|
|
46
|
+
const EQUIPMENT_TYPE_OPTIONS = Object.keys(EQUIPMENTS_FIELDS);
|
|
47
|
+
function ModificationByAssignmentForm() {
|
|
48
|
+
const { setValue, getValues } = useFormContext();
|
|
49
|
+
const getOptionLabel = useGetLabelEquipmentTypes();
|
|
50
|
+
const getEquipmentTypeOptionLabel = (option) => {
|
|
51
|
+
if (!option || typeof option !== "string") {
|
|
52
|
+
return "";
|
|
53
|
+
}
|
|
54
|
+
return getOptionLabel(option);
|
|
55
|
+
};
|
|
56
|
+
const equipmentTypeField = /* @__PURE__ */ jsx(
|
|
57
|
+
SelectWithConfirmationInput,
|
|
58
|
+
{
|
|
59
|
+
name: FieldConstants.EQUIPMENT_TYPE,
|
|
60
|
+
label: "EquipmentType",
|
|
61
|
+
options: EQUIPMENT_TYPE_OPTIONS,
|
|
62
|
+
onValidate: () => {
|
|
63
|
+
setValue(
|
|
64
|
+
FieldConstants.ASSIGNMENTS,
|
|
65
|
+
getValues(FieldConstants.ASSIGNMENTS).map(() => ({
|
|
66
|
+
...getAssignmentInitialValue()
|
|
67
|
+
}))
|
|
68
|
+
);
|
|
69
|
+
},
|
|
70
|
+
getOptionLabel: getEquipmentTypeOptionLabel
|
|
71
|
+
}
|
|
72
|
+
);
|
|
73
|
+
const assignmentsField = /* @__PURE__ */ jsx(
|
|
74
|
+
ExpandableInput,
|
|
75
|
+
{
|
|
76
|
+
name: FieldConstants.ASSIGNMENTS,
|
|
77
|
+
Field: AssignmentForm,
|
|
78
|
+
addButtonLabel: "addNewAssignment",
|
|
79
|
+
initialValue: getAssignmentInitialValue()
|
|
80
|
+
}
|
|
81
|
+
);
|
|
82
|
+
return /* @__PURE__ */ jsxs(Box, { sx: mergeSx(unscrollableDialogStyles.unscrollableContainer, { height: "100%" }), children: [
|
|
83
|
+
/* @__PURE__ */ jsx(Grid, { container: true, sx: unscrollableDialogStyles.unscrollableHeader, children: /* @__PURE__ */ jsx(GridItem, { size: 3.15, children: equipmentTypeField }) }),
|
|
84
|
+
/* @__PURE__ */ jsx(Grid, { container: true, sx: unscrollableDialogStyles.scrollableContent, children: /* @__PURE__ */ jsx(GridItem, { size: 12, children: assignmentsField }) })
|
|
85
|
+
] });
|
|
86
|
+
}
|
|
87
|
+
export {
|
|
88
|
+
ModificationByAssignmentForm
|
|
89
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { EquipmentType, ModificationType } from '../../../../utils';
|
|
2
|
+
import { Assignment } from './assignment/assignment.type';
|
|
3
|
+
export interface ModificationByAssignmentDto {
|
|
4
|
+
type: ModificationType.MODIFICATION_BY_ASSIGNMENT;
|
|
5
|
+
equipmentType: EquipmentType;
|
|
6
|
+
assignmentInfosList: Assignment[];
|
|
7
|
+
}
|
package/dist/components/network-modifications/by-filter/assignment/modificationByAssignment.types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { InferType } from 'yup';
|
|
2
|
+
import { DeepNullable, EquipmentType, yupConfig as yup } from '../../../../utils';
|
|
3
|
+
import { ModificationByAssignmentDto } from './modificationByAssignment.types';
|
|
4
|
+
export declare const modificationByAssignmentFormSchema: yup.ObjectSchema<{
|
|
5
|
+
equipmentType: NonNullable<EquipmentType | undefined>;
|
|
6
|
+
assignments: {
|
|
7
|
+
propertyName?: string | undefined;
|
|
8
|
+
editedField: string;
|
|
9
|
+
filters: {
|
|
10
|
+
id: string;
|
|
11
|
+
name: string;
|
|
12
|
+
}[];
|
|
13
|
+
value: NonNullable<import('.').AssignmentFieldValue | undefined>;
|
|
14
|
+
}[];
|
|
15
|
+
}, yup.AnyObject, {
|
|
16
|
+
equipmentType: undefined;
|
|
17
|
+
assignments: "";
|
|
18
|
+
}, "">;
|
|
19
|
+
export type ModificationByAssignmentFormData = InferType<typeof modificationByAssignmentFormSchema>;
|
|
20
|
+
export declare const emptyModificationByAssignmentFormData: DeepNullable<ModificationByAssignmentFormData>;
|
|
21
|
+
export declare const modificationByAssignmentDtoToForm: (dto: ModificationByAssignmentDto) => ModificationByAssignmentFormData;
|
|
22
|
+
export declare const modificationByAssignmentFormToDto: (formData: ModificationByAssignmentFormData) => ModificationByAssignmentDto;
|
package/dist/components/network-modifications/by-filter/assignment/modificationByAssignment.utils.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import * as yup from "yup";
|
|
2
|
+
import { mixed } from "yup";
|
|
3
|
+
import { FieldConstants } from "../../../../utils/constants/fieldConstants.js";
|
|
4
|
+
import { convertInputValue, convertOutputValue } from "../../../../utils/conversionUtils.js";
|
|
5
|
+
import { EquipmentType } from "../../../../utils/types/equipmentType.js";
|
|
6
|
+
import { ModificationType } from "../../../../utils/types/modificationType.js";
|
|
7
|
+
import { FieldType } from "../../../../utils/types/fieldType.js";
|
|
8
|
+
import "react/jsx-runtime";
|
|
9
|
+
import "@mui/icons-material";
|
|
10
|
+
import "../../../../utils/yupConfig.js";
|
|
11
|
+
import { getAssignmentsSchema, getAssignmentInitialValue, getAssignmentFromEditData, getDataType } from "./assignment/assignment-utils.js";
|
|
12
|
+
import { DataType } from "./assignment/assignment.type.js";
|
|
13
|
+
const emptyValueStr = "—";
|
|
14
|
+
const modificationByAssignmentFormSchema = yup.object().shape({
|
|
15
|
+
[FieldConstants.EQUIPMENT_TYPE]: mixed().oneOf(Object.values(EquipmentType)).required(),
|
|
16
|
+
[FieldConstants.ASSIGNMENTS]: getAssignmentsSchema(emptyValueStr)
|
|
17
|
+
}).required();
|
|
18
|
+
const emptyModificationByAssignmentFormData = {
|
|
19
|
+
[FieldConstants.EQUIPMENT_TYPE]: null,
|
|
20
|
+
[FieldConstants.ASSIGNMENTS]: [getAssignmentInitialValue()]
|
|
21
|
+
};
|
|
22
|
+
const modificationByAssignmentDtoToForm = (dto) => ({
|
|
23
|
+
[FieldConstants.EQUIPMENT_TYPE]: dto.equipmentType,
|
|
24
|
+
[FieldConstants.ASSIGNMENTS]: dto.assignmentInfosList?.map((info) => {
|
|
25
|
+
const assignment = getAssignmentFromEditData(info);
|
|
26
|
+
const fieldKey = assignment.editedField;
|
|
27
|
+
const field = FieldType[fieldKey];
|
|
28
|
+
const { value } = assignment;
|
|
29
|
+
const valueConverted = convertInputValue(field, value);
|
|
30
|
+
return {
|
|
31
|
+
...assignment,
|
|
32
|
+
value: valueConverted !== 0 && !valueConverted ? emptyValueStr : valueConverted
|
|
33
|
+
};
|
|
34
|
+
}) ?? [getAssignmentInitialValue()]
|
|
35
|
+
});
|
|
36
|
+
const modificationByAssignmentFormToDto = (formData) => ({
|
|
37
|
+
type: ModificationType.MODIFICATION_BY_ASSIGNMENT,
|
|
38
|
+
equipmentType: formData.equipmentType,
|
|
39
|
+
assignmentInfosList: formData.assignments.map((assignment) => {
|
|
40
|
+
const fieldKey = assignment.editedField;
|
|
41
|
+
const field = FieldType[fieldKey];
|
|
42
|
+
const value = assignment.value === emptyValueStr ? "" : assignment.value;
|
|
43
|
+
return {
|
|
44
|
+
...assignment,
|
|
45
|
+
dataType: getDataType(assignment.editedField) ?? DataType.STRING,
|
|
46
|
+
value: convertOutputValue(field, value)
|
|
47
|
+
};
|
|
48
|
+
})
|
|
49
|
+
});
|
|
50
|
+
export {
|
|
51
|
+
emptyModificationByAssignmentFormData,
|
|
52
|
+
modificationByAssignmentDtoToForm,
|
|
53
|
+
modificationByAssignmentFormSchema,
|
|
54
|
+
modificationByAssignmentFormToDto
|
|
55
|
+
};
|
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
import { ByFilterDeletionForm } from "./deletion/ByFilterDeletionForm.js";
|
|
2
2
|
import { EQUIPMENT_TYPE_ORDER, byFilterDeletionDtoToForm, byFilterDeletionFormSchema, byFilterDeletionFormToDto, emptyFormData } from "./deletion/byFilterDeletion.utils.js";
|
|
3
|
+
import { ModificationByAssignmentForm } from "./assignment/modification-by-assignment-form.js";
|
|
4
|
+
import { emptyModificationByAssignmentFormData, modificationByAssignmentDtoToForm, modificationByAssignmentFormSchema, modificationByAssignmentFormToDto } from "./assignment/modificationByAssignment.utils.js";
|
|
5
|
+
import { DataType } from "./assignment/assignment/assignment.type.js";
|
|
3
6
|
export {
|
|
7
|
+
DataType as AssignmentDataType,
|
|
4
8
|
ByFilterDeletionForm,
|
|
5
9
|
EQUIPMENT_TYPE_ORDER,
|
|
10
|
+
ModificationByAssignmentForm,
|
|
6
11
|
byFilterDeletionDtoToForm,
|
|
7
12
|
byFilterDeletionFormSchema,
|
|
8
13
|
byFilterDeletionFormToDto,
|
|
9
|
-
emptyFormData
|
|
14
|
+
emptyFormData,
|
|
15
|
+
emptyModificationByAssignmentFormData,
|
|
16
|
+
modificationByAssignmentDtoToForm,
|
|
17
|
+
modificationByAssignmentFormSchema,
|
|
18
|
+
modificationByAssignmentFormToDto
|
|
10
19
|
};
|
|
@@ -0,0 +1,7 @@
|
|
|
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 './useTabsWithError';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { FieldConstants } from '../../../utils';
|
|
2
|
+
type TabFieldsMap<T extends number> = Readonly<Partial<Record<T, FieldConstants[]>>>;
|
|
3
|
+
/**
|
|
4
|
+
* Manages tab navigation with automatic error highlighting for react-hook-form-based tabbed forms.
|
|
5
|
+
*
|
|
6
|
+
* @param tabFields - Maps each tab index to the field names it owns. Must be a module-level
|
|
7
|
+
* constant to remain stable across renders.
|
|
8
|
+
* @param initialTab - The tab to show on first render.
|
|
9
|
+
*/
|
|
10
|
+
export declare function useTabsWithError<T extends number>(tabFields: TabFieldsMap<T>, initialTab: T): {
|
|
11
|
+
tabIndex: T;
|
|
12
|
+
setTabIndex: (tab: T) => void;
|
|
13
|
+
tabIndexesWithError: T[];
|
|
14
|
+
};
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { useState, useRef, useEffect, useCallback } from "react";
|
|
2
|
+
import { useFormState } from "react-hook-form";
|
|
3
|
+
function useTabsWithError(tabFields, initialTab) {
|
|
4
|
+
const { errors, submitCount } = useFormState();
|
|
5
|
+
const [tabIndex, setTabIndex] = useState(initialTab);
|
|
6
|
+
const tabIndexRef = useRef(tabIndex);
|
|
7
|
+
const tabIndexesWithError = Object.keys(tabFields).map(Number).filter(
|
|
8
|
+
(tab) => tabFields[tab].some((field) => errors[field] !== void 0)
|
|
9
|
+
);
|
|
10
|
+
const tabIndexesWithErrorRef = useRef(tabIndexesWithError);
|
|
11
|
+
tabIndexesWithErrorRef.current = tabIndexesWithError;
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
const tabs = tabIndexesWithErrorRef.current;
|
|
14
|
+
if (tabs.length > 0 && !tabs.includes(tabIndexRef.current)) {
|
|
15
|
+
const tab = tabs[0];
|
|
16
|
+
tabIndexRef.current = tab;
|
|
17
|
+
setTabIndex(tab);
|
|
18
|
+
}
|
|
19
|
+
}, [submitCount]);
|
|
20
|
+
const handleSetTabIndex = useCallback((tab) => {
|
|
21
|
+
tabIndexRef.current = tab;
|
|
22
|
+
setTabIndex(tab);
|
|
23
|
+
}, []);
|
|
24
|
+
return { tabIndex, setTabIndex: handleSetTabIndex, tabIndexesWithError };
|
|
25
|
+
}
|
|
26
|
+
export {
|
|
27
|
+
useTabsWithError
|
|
28
|
+
};
|
|
@@ -19,6 +19,7 @@ import { useHvdcLccDeletion } from "./equipmentDeletion/hvdcLccDeletion/useHvdcL
|
|
|
19
19
|
import { HvdcLccDeletionSpecificForm } from "./equipmentDeletion/hvdcLccDeletion/HvdcLccDeletionSpecificForm.js";
|
|
20
20
|
import { equipmentDeletionDtoToForm, equipmentDeletionEmptyFormData, equipmentDeletionFormSchema, equipmentDeletionFormToDto, newEquipmentDeletionDto } from "./equipmentDeletion/equipmentDeletion.utils.js";
|
|
21
21
|
import { EquipmentDeletionForm } from "./equipmentDeletion/EquipmentDeletionForm.js";
|
|
22
|
+
import { useTabsWithError } from "./hooks/useTabsWithError.js";
|
|
22
23
|
import { SubstationCreationForm } from "./substation/creation/SubstationCreationForm.js";
|
|
23
24
|
import { substationCreationDtoToForm, substationCreationEmptyFormData, substationCreationFormSchema, substationCreationFormToDto } from "./substation/creation/substationCreation.utils.js";
|
|
24
25
|
import { SubstationModificationForm } from "./substation/modification/SubstationModificationForm.js";
|
|
@@ -59,11 +60,11 @@ import "uuid";
|
|
|
59
60
|
import "../inputs/reactQueryBuilder/PropertyValueEditor.js";
|
|
60
61
|
import "react-querybuilder";
|
|
61
62
|
import { VoltageLevelCreationForm } from "./voltageLevel/creation/VoltageLevelCreationForm.js";
|
|
62
|
-
import { SWITCH_TYPE, buildNewBusbarSections, getCreateSwitchesEmptyFormData, getCreateSwitchesValidationSchema,
|
|
63
|
+
import { SWITCH_TYPE, buildNewBusbarSections, getCreateSwitchesEmptyFormData, getCreateSwitchesValidationSchema, translateSwitchKinds, voltageLevelCreationDtoToForm, voltageLevelCreationEmptyFormData, voltageLevelCreationFormSchema, voltageLevelCreationFormToDto } from "./voltageLevel/creation/voltageLevelCreation.utils.js";
|
|
63
64
|
import { SwitchKind } from "./voltageLevel/creation/voltageLevelCreation.types.js";
|
|
64
65
|
import { VoltageLevelModificationForm } from "./voltageLevel/modification/VoltageLevelModificationForm.js";
|
|
65
66
|
import { voltageLevelModificationDtoToForm, voltageLevelModificationEmptyFormData, voltageLevelModificationFormSchema, voltageLevelModificationFormToDto } from "./voltageLevel/modification/voltageLevelModification.utils.js";
|
|
66
|
-
import { LoadDialogTab } from "./load/common/load.utils.js";
|
|
67
|
+
import { LOAD_TAB_FIELDS, LoadDialogTab } from "./load/common/load.utils.js";
|
|
67
68
|
import { LoadDialogTabs } from "./load/common/LoadDialogTabs.js";
|
|
68
69
|
import { LoadDialogTabsContent } from "./load/common/LoadDialogTabsContent.js";
|
|
69
70
|
import { LoadDialogHeader } from "./load/common/LoadDialogHeader.js";
|
|
@@ -72,7 +73,11 @@ import { loadCreationDtoToForm, loadCreationEmptyFormData, loadCreationFormSchem
|
|
|
72
73
|
import { loadModificationDtoToForm, loadModificationEmptyFormData, loadModificationFormSchema, loadModificationFormToDto } from "./load/modification/loadModification.utils.js";
|
|
73
74
|
import { ByFilterDeletionForm } from "./by-filter/deletion/ByFilterDeletionForm.js";
|
|
74
75
|
import { EQUIPMENT_TYPE_ORDER, byFilterDeletionDtoToForm, byFilterDeletionFormSchema, byFilterDeletionFormToDto, emptyFormData } from "./by-filter/deletion/byFilterDeletion.utils.js";
|
|
76
|
+
import { ModificationByAssignmentForm } from "./by-filter/assignment/modification-by-assignment-form.js";
|
|
77
|
+
import { emptyModificationByAssignmentFormData, modificationByAssignmentDtoToForm, modificationByAssignmentFormSchema, modificationByAssignmentFormToDto } from "./by-filter/assignment/modificationByAssignment.utils.js";
|
|
78
|
+
import { DataType } from "./by-filter/assignment/assignment/assignment.type.js";
|
|
75
79
|
export {
|
|
80
|
+
DataType as AssignmentDataType,
|
|
76
81
|
BranchActiveReactivePowerMeasurementsForm,
|
|
77
82
|
BranchConnectivityForm,
|
|
78
83
|
ByFilterDeletionForm,
|
|
@@ -80,11 +85,13 @@ export {
|
|
|
80
85
|
EQUIPMENT_TYPE_ORDER,
|
|
81
86
|
EquipmentDeletionForm,
|
|
82
87
|
HvdcLccDeletionSpecificForm,
|
|
88
|
+
LOAD_TAB_FIELDS,
|
|
83
89
|
LoadDialogHeader,
|
|
84
90
|
LoadDialogTab,
|
|
85
91
|
LoadDialogTabs,
|
|
86
92
|
LoadDialogTabsContent,
|
|
87
93
|
LoadForm,
|
|
94
|
+
ModificationByAssignmentForm,
|
|
88
95
|
PowerMeasurementsForm,
|
|
89
96
|
PowerWithValidityForm,
|
|
90
97
|
PropertiesForm,
|
|
@@ -107,6 +114,7 @@ export {
|
|
|
107
114
|
createPropertyModification,
|
|
108
115
|
creationPropertiesSchema,
|
|
109
116
|
emptyFormData,
|
|
117
|
+
emptyModificationByAssignmentFormData,
|
|
110
118
|
emptyProperties,
|
|
111
119
|
equipmentDeletionDtoToForm,
|
|
112
120
|
equipmentDeletionEmptyFormData,
|
|
@@ -158,10 +166,6 @@ export {
|
|
|
158
166
|
getSetPointsEmptyFormData,
|
|
159
167
|
getSetPointsSchema,
|
|
160
168
|
initializedProperty,
|
|
161
|
-
isAdditionalInformationTabError,
|
|
162
|
-
isCharacteristicsTabError,
|
|
163
|
-
isStructureTabError,
|
|
164
|
-
isSubstationTabError,
|
|
165
169
|
italicFontTextField,
|
|
166
170
|
loadCreationDtoToForm,
|
|
167
171
|
loadCreationEmptyFormData,
|
|
@@ -172,6 +176,9 @@ export {
|
|
|
172
176
|
loadModificationFormSchema,
|
|
173
177
|
loadModificationFormToDto,
|
|
174
178
|
mergeModificationAndEquipmentProperties,
|
|
179
|
+
modificationByAssignmentDtoToForm,
|
|
180
|
+
modificationByAssignmentFormSchema,
|
|
181
|
+
modificationByAssignmentFormToDto,
|
|
175
182
|
modificationPropertiesSchema,
|
|
176
183
|
newEquipmentDeletionDto,
|
|
177
184
|
standardTextField,
|
|
@@ -187,6 +194,7 @@ export {
|
|
|
187
194
|
toModificationProperties,
|
|
188
195
|
translateSwitchKinds,
|
|
189
196
|
useHvdcLccDeletion,
|
|
197
|
+
useTabsWithError,
|
|
190
198
|
voltageLevelCreationDtoToForm,
|
|
191
199
|
voltageLevelCreationEmptyFormData,
|
|
192
200
|
voltageLevelCreationFormSchema,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { LoadDialogTabsContentProps } from './LoadDialogTabsContent';
|
|
2
1
|
import { LoadDialogHeaderProps } from './LoadDialogHeader';
|
|
2
|
+
import { LoadDialogTabsContentProps } from './LoadDialogTabsContent';
|
|
3
3
|
interface LoadFormProps extends LoadDialogHeaderProps, Omit<LoadDialogTabsContentProps, 'tabIndex' | 'isModification' | 'loadToModify'> {
|
|
4
4
|
}
|
|
5
5
|
export declare function LoadForm({ loadToModify, isModification, voltageLevelOptions, fetchBusesOrBusbarSections, PositionDiagramPane, }: Readonly<LoadFormProps>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,16 +1,10 @@
|
|
|
1
1
|
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useState, useEffect } from "react";
|
|
3
2
|
import { Grid } from "@mui/material";
|
|
4
|
-
import {
|
|
5
|
-
import { LoadDialogTabsContent } from "./LoadDialogTabsContent.js";
|
|
3
|
+
import { LoadDialogTab, LOAD_TAB_FIELDS } from "./load.utils.js";
|
|
6
4
|
import { LoadDialogHeader } from "./LoadDialogHeader.js";
|
|
7
|
-
import { LoadDialogTab } from "./load.utils.js";
|
|
8
|
-
import { FieldConstants } from "../../../../utils/constants/fieldConstants.js";
|
|
9
|
-
import "../../../../utils/conversionUtils.js";
|
|
10
|
-
import "../../../../utils/types/equipmentType.js";
|
|
11
|
-
import "@mui/icons-material";
|
|
12
|
-
import "../../../../utils/yupConfig.js";
|
|
13
5
|
import { LoadDialogTabs } from "./LoadDialogTabs.js";
|
|
6
|
+
import { LoadDialogTabsContent } from "./LoadDialogTabsContent.js";
|
|
7
|
+
import { useTabsWithError } from "../../hooks/useTabsWithError.js";
|
|
14
8
|
function LoadForm({
|
|
15
9
|
loadToModify,
|
|
16
10
|
isModification,
|
|
@@ -18,24 +12,10 @@ function LoadForm({
|
|
|
18
12
|
fetchBusesOrBusbarSections,
|
|
19
13
|
PositionDiagramPane
|
|
20
14
|
}) {
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const tabsInError = [];
|
|
26
|
-
if (errors?.[FieldConstants.CONNECTIVITY] !== void 0) {
|
|
27
|
-
tabsInError.push(LoadDialogTab.CONNECTIVITY_TAB);
|
|
28
|
-
}
|
|
29
|
-
if (errors?.[FieldConstants.ACTIVE_POWER_SET_POINT] !== void 0 || errors?.[FieldConstants.REACTIVE_POWER_SET_POINT] !== void 0 || errors?.[FieldConstants.ADDITIONAL_PROPERTIES] !== void 0) {
|
|
30
|
-
tabsInError.push(LoadDialogTab.CHARACTERISTICS_TAB);
|
|
31
|
-
}
|
|
32
|
-
if (tabsInError.length > 0) {
|
|
33
|
-
setTabIndex((currentTabIndex) => {
|
|
34
|
-
return tabsInError.includes(currentTabIndex) ? currentTabIndex : tabsInError[0];
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
setTabIndexesWithError(tabsInError);
|
|
38
|
-
}, [errors]);
|
|
15
|
+
const { tabIndex, setTabIndex, tabIndexesWithError } = useTabsWithError(
|
|
16
|
+
LOAD_TAB_FIELDS,
|
|
17
|
+
LoadDialogTab.CONNECTIVITY_TAB
|
|
18
|
+
);
|
|
39
19
|
return /* @__PURE__ */ jsxs(Grid, { container: true, direction: "column", spacing: 2, children: [
|
|
40
20
|
/* @__PURE__ */ jsx(Grid, { item: true, children: /* @__PURE__ */ jsx(LoadDialogHeader, { loadToModify, isModification }) }),
|
|
41
21
|
/* @__PURE__ */ jsx(Grid, { item: true, children: /* @__PURE__ */ jsx(
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { LoadDialogTab } from "./load.utils.js";
|
|
1
|
+
import { LOAD_TAB_FIELDS, LoadDialogTab } from "./load.utils.js";
|
|
2
2
|
import { LoadDialogTabs } from "./LoadDialogTabs.js";
|
|
3
3
|
import { LoadDialogTabsContent } from "./LoadDialogTabsContent.js";
|
|
4
4
|
import { LoadDialogHeader } from "./LoadDialogHeader.js";
|
|
5
5
|
import { LoadForm } from "./LoadForm.js";
|
|
6
6
|
export {
|
|
7
|
+
LOAD_TAB_FIELDS,
|
|
7
8
|
LoadDialogHeader,
|
|
8
9
|
LoadDialogTab,
|
|
9
10
|
LoadDialogTabs,
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export declare const
|
|
8
|
-
CONNECTIVITY_TAB: number;
|
|
9
|
-
CHARACTERISTICS_TAB: number;
|
|
10
|
-
STATE_ESTIMATION_TAB: number;
|
|
11
|
-
};
|
|
1
|
+
import { FieldConstants } from '../../../../utils';
|
|
2
|
+
export declare enum LoadDialogTab {
|
|
3
|
+
CONNECTIVITY_TAB = 0,
|
|
4
|
+
CHARACTERISTICS_TAB = 1,
|
|
5
|
+
STATE_ESTIMATION_TAB = 2
|
|
6
|
+
}
|
|
7
|
+
export declare const LOAD_TAB_FIELDS: Readonly<Partial<Record<LoadDialogTab, FieldConstants[]>>>;
|