@gridsuite/commons-ui 0.189.0 → 0.191.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/dialogs/elementSaveDialog/ElementSaveDialog.js +1 -0
- package/dist/components/dnd-table/dnd-table-add-rows-dialog.js +1 -0
- package/dist/components/dnd-table/dnd-table.js +72 -34
- package/dist/components/filter/HeaderFilterForm.js +1 -0
- package/dist/components/filter/expert/ExpertFilterForm.js +1 -0
- package/dist/components/filter/explicitNaming/ExplicitNamingFilterForm.js +1 -0
- package/dist/components/index.js +16 -6
- package/dist/components/inputs/index.js +2 -0
- package/dist/components/inputs/reactHookForm/expandableInput/ExpandableInput.d.ts +5 -5
- package/dist/components/inputs/reactHookForm/expandableInput/ExpandableInput.js +66 -54
- 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 +218 -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/deletion/ByFilterDeletionForm.js +1 -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/common/connectivity/ConnectivityForm.js +1 -0
- package/dist/components/network-modifications/common/measurements/PowerWithValidityForm.js +1 -0
- package/dist/components/network-modifications/common/properties/PropertyForm.js +1 -0
- package/dist/components/network-modifications/common/setpoints/SetPointsForm.js +1 -0
- package/dist/components/network-modifications/equipmentDeletion/EquipmentDeletionForm.js +1 -0
- package/dist/components/network-modifications/equipmentDeletion/equipmentDeletion.utils.js +1 -0
- package/dist/components/network-modifications/equipmentDeletion/hvdcLccDeletion/ShuntCompensatorSelectionForm.js +1 -0
- 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 +15 -6
- package/dist/components/network-modifications/load/common/LoadDialogHeader.js +1 -0
- 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/creation/loadCreation.utils.js +1 -0
- package/dist/components/network-modifications/load/index.js +2 -1
- package/dist/components/network-modifications/load/modification/loadModification.utils.js +1 -0
- package/dist/components/network-modifications/substation/creation/SubstationCreationForm.js +1 -0
- package/dist/components/network-modifications/substation/modification/SubstationModificationForm.js +1 -0
- package/dist/components/network-modifications/voltageLevel/creation/VoltageLevelCreationForm.js +10 -29
- package/dist/components/network-modifications/voltageLevel/creation/index.js +2 -5
- package/dist/components/network-modifications/voltageLevel/creation/tabs/characteristicsTab/CharacteristicsTab.js +1 -0
- package/dist/components/network-modifications/voltageLevel/creation/tabs/structureTab/StructureTab.js +1 -0
- package/dist/components/network-modifications/voltageLevel/creation/tabs/structureTab/switchesBetweenSections/SwitchesBetweenSections.js +1 -0
- package/dist/components/network-modifications/voltageLevel/creation/tabs/structureTab/switchesBetweenSections/creation/CreateSwitchesDialog.js +1 -0
- package/dist/components/network-modifications/voltageLevel/creation/tabs/structureTab/switchesBetweenSections/creation/CreateSwitchesForm.js +1 -0
- package/dist/components/network-modifications/voltageLevel/creation/tabs/substationTab/SubstationCreationSection.js +1 -0
- package/dist/components/network-modifications/voltageLevel/creation/tabs/substationTab/SubstationTab.js +1 -0
- 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 +1 -16
- package/dist/components/network-modifications/voltageLevel/index.js +2 -5
- package/dist/components/network-modifications/voltageLevel/modification/VoltageLevelModificationForm.js +1 -0
- package/dist/components/parameters/common/ProviderParam.js +1 -0
- package/dist/components/parameters/common/contingency-table/columns-definitions.js +1 -0
- package/dist/components/parameters/common/limitreductions/limit-reduction-table-cell.js +1 -0
- package/dist/components/parameters/common/limitreductions/limit-reductions-table-form.js +1 -0
- package/dist/components/parameters/common/name-element-editor/name-element-editor-utils.js +1 -0
- package/dist/components/parameters/common/parameter-dnd-table-field.js +1 -0
- package/dist/components/parameters/common/parameter-field.js +1 -0
- package/dist/components/parameters/common/parameter-table/table-cell.js +1 -0
- package/dist/components/parameters/common/voltage-level-table/custom-voltage-level-table-cell.js +1 -0
- package/dist/components/parameters/common/widget/parameter-float.js +1 -0
- package/dist/components/parameters/common/widget/parameter-line-directory-items-input.js +1 -0
- package/dist/components/parameters/common/widget/parameter-line-slider.js +1 -0
- package/dist/components/parameters/dynamic-margin-calculation/dynamic-margin-calculation-form.js +1 -0
- package/dist/components/parameters/dynamic-margin-calculation/dynamic-margin-calculation-inline.js +1 -0
- package/dist/components/parameters/dynamic-margin-calculation/loads-variations-parameters.js +2 -0
- package/dist/components/parameters/dynamic-margin-calculation/use-dynamic-margin-calculation-parameters-form.js +1 -0
- package/dist/components/parameters/dynamic-security-analysis/contingency-parameters.js +1 -0
- package/dist/components/parameters/dynamic-security-analysis/dynamic-security-analysis-inline.js +1 -0
- package/dist/components/parameters/dynamic-security-analysis/dynamic-security-analysis-parameters-form.js +1 -0
- package/dist/components/parameters/dynamic-security-analysis/use-dynamic-security-analysis-parameters-form.js +1 -0
- package/dist/components/parameters/loadflow/load-flow-general-parameters.js +1 -0
- package/dist/components/parameters/loadflow/load-flow-parameters-content.js +1 -0
- package/dist/components/parameters/loadflow/load-flow-parameters-dialog.js +1 -0
- package/dist/components/parameters/loadflow/load-flow-parameters-form.js +1 -0
- package/dist/components/parameters/loadflow/load-flow-parameters-header.js +1 -0
- package/dist/components/parameters/loadflow/load-flow-parameters-inline.js +1 -0
- package/dist/components/parameters/loadflow/load-flow-parameters-utils.js +1 -0
- package/dist/components/parameters/loadflow/use-load-flow-parameters-form.js +1 -0
- package/dist/components/parameters/network-visualizations/map-parameters.js +1 -0
- package/dist/components/parameters/network-visualizations/network-area-diagram-parameters.js +1 -0
- package/dist/components/parameters/network-visualizations/network-visualizations-form.js +1 -0
- package/dist/components/parameters/network-visualizations/network-visualizations-parameters-dialog.js +1 -0
- package/dist/components/parameters/network-visualizations/network-visualizations-parameters-inline.js +1 -0
- package/dist/components/parameters/network-visualizations/single-line-diagram-parameters.js +1 -0
- package/dist/components/parameters/network-visualizations/use-network-visualizations-parameters-form.js +1 -0
- package/dist/components/parameters/pcc-min/pcc-min-form-utils.js +1 -0
- package/dist/components/parameters/pcc-min/pcc-min-parameters-dialog.js +1 -0
- package/dist/components/parameters/pcc-min/pcc-min-parameters-form.js +1 -0
- package/dist/components/parameters/pcc-min/pcc-min-parameters-inline.js +1 -0
- package/dist/components/parameters/pcc-min/use-pcc-min-parameters-form.js +1 -0
- package/dist/components/parameters/security-analysis/columns-definitions.js +1 -0
- package/dist/components/parameters/security-analysis/security-analysis-parameters-dialog.js +1 -0
- package/dist/components/parameters/security-analysis/security-analysis-parameters-form.js +1 -0
- package/dist/components/parameters/security-analysis/security-analysis-parameters-inline.js +1 -0
- package/dist/components/parameters/security-analysis/security-analysis-parameters-selector.js +1 -0
- package/dist/components/parameters/security-analysis/security-analysis-violations-hiding.js +1 -0
- package/dist/components/parameters/security-analysis/use-security-analysis-parameters-form.js +1 -0
- package/dist/components/parameters/sensi/columns-definitions.js +1 -0
- package/dist/components/parameters/sensi/sensitivity-Flow-parameters.js +1 -0
- package/dist/components/parameters/sensi/sensitivity-analysis-parameters-dialog.js +1 -0
- package/dist/components/parameters/sensi/sensitivity-analysis-parameters-form.js +1 -0
- package/dist/components/parameters/sensi/sensitivity-analysis-parameters-inline.js +1 -0
- package/dist/components/parameters/sensi/sensitivity-parameters-selector.js +1 -0
- package/dist/components/parameters/sensi/use-sensitivity-analysis-parameters.js +1 -0
- package/dist/components/parameters/sensi/utils.js +1 -0
- package/dist/components/parameters/short-circuit/short-circuit-general-tab-panel.js +1 -0
- package/dist/components/parameters/short-circuit/short-circuit-icc-cluster-table-cell.js +1 -0
- package/dist/components/parameters/short-circuit/short-circuit-icc-material-table-cell.js +1 -0
- package/dist/components/parameters/short-circuit/short-circuit-parameters-content.js +1 -0
- package/dist/components/parameters/short-circuit/short-circuit-parameters-dialog.js +1 -0
- package/dist/components/parameters/short-circuit/short-circuit-parameters-form.js +1 -0
- package/dist/components/parameters/short-circuit/short-circuit-parameters-inline.js +1 -0
- package/dist/components/parameters/short-circuit/short-circuit-parameters-utils.js +1 -0
- package/dist/components/parameters/short-circuit/short-circuit-power-electronics-tab-panel.js +1 -0
- package/dist/components/parameters/short-circuit/short-circuit-study-area-tab-panel.js +1 -0
- package/dist/components/parameters/short-circuit/use-short-circuit-parameters-form.js +1 -0
- package/dist/components/parameters/util/make-component-utils.js +1 -0
- package/dist/components/parameters/voltage-init/equipment-selection-parameters.js +1 -0
- package/dist/components/parameters/voltage-init/general-parameters.js +1 -0
- package/dist/components/parameters/voltage-init/use-voltage-init-parameters-form.js +2 -0
- package/dist/components/parameters/voltage-init/voltage-init-form-utils.js +2 -0
- package/dist/components/parameters/voltage-init/voltage-init-parameters-dialog.js +1 -0
- package/dist/components/parameters/voltage-init/voltage-init-parameters-form.js +1 -0
- package/dist/components/parameters/voltage-init/voltage-init-parameters-inline.js +1 -0
- package/dist/components/parameters/voltage-init/voltage-limits-parameters.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-form.js
ADDED
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo, useCallback } from "react";
|
|
3
|
+
import { DensityLarge } from "@mui/icons-material";
|
|
4
|
+
import { useFormContext, useWatch } from "react-hook-form";
|
|
5
|
+
import { useIntl } from "react-intl";
|
|
6
|
+
import { FieldConstants } from "../../../../../utils/constants/fieldConstants.js";
|
|
7
|
+
import "../../../../../utils/conversionUtils.js";
|
|
8
|
+
import { ElementType } from "../../../../../utils/types/elementType.js";
|
|
9
|
+
import "../../../../../utils/types/equipmentType.js";
|
|
10
|
+
import { FieldType } from "../../../../../utils/types/fieldType.js";
|
|
11
|
+
import { areIdsEqual, getIdOrValue } from "../../../../../utils/ts-utils.js";
|
|
12
|
+
import "../../../../../utils/yupConfig.js";
|
|
13
|
+
import "@mui/material";
|
|
14
|
+
import "localized-countries";
|
|
15
|
+
import "localized-countries/data/fr";
|
|
16
|
+
import "localized-countries/data/en";
|
|
17
|
+
import { usePredefinedProperties } from "../../../../../hooks/usePredefinedProperties.js";
|
|
18
|
+
import { usePrevious } from "../../../../../hooks/usePrevious.js";
|
|
19
|
+
import "notistack";
|
|
20
|
+
import { useFormatLabelWithUnit } from "../../../../../hooks/useFormatLabelWithUnit.js";
|
|
21
|
+
import "../../../../overflowableText/OverflowableText.js";
|
|
22
|
+
import "../../../../inputs/reactHookForm/provider/CustomFormProvider.js";
|
|
23
|
+
import "yup";
|
|
24
|
+
import { DirectoryItemsInput } from "../../../../inputs/reactHookForm/DirectoryItemsInput.js";
|
|
25
|
+
import "../../../../inputs/reactHookForm/agGridTable/BottomRightButtons.js";
|
|
26
|
+
import "../../../../customAGGrid/customAggrid.js";
|
|
27
|
+
import "ag-grid-community";
|
|
28
|
+
import "react-papaparse";
|
|
29
|
+
import "react-csv-downloader";
|
|
30
|
+
import { AutocompleteInput } from "../../../../inputs/reactHookForm/autocompleteInputs/AutocompleteInput.js";
|
|
31
|
+
import { SwitchInput } from "../../../../inputs/reactHookForm/booleans/SwitchInput.js";
|
|
32
|
+
import { FloatInput } from "../../../../inputs/reactHookForm/numbers/FloatInput.js";
|
|
33
|
+
import { IntegerInput } from "../../../../inputs/reactHookForm/numbers/IntegerInput.js";
|
|
34
|
+
import "../../../../inputs/reactHookForm/numbers/RangeInput.js";
|
|
35
|
+
import { SelectInput } from "../../../../inputs/reactHookForm/selectInputs/SelectInput.js";
|
|
36
|
+
import { TextInput } from "../../../../inputs/reactHookForm/text/TextInput.js";
|
|
37
|
+
import "@material-symbols/svg-400/outlined/left_panel_open.svg?react";
|
|
38
|
+
import "@material-symbols/svg-400/outlined/arrows_output.svg?react";
|
|
39
|
+
import "@material-symbols/svg-400/outlined/left_panel_close.svg?react";
|
|
40
|
+
import "@material-symbols/svg-400/outlined/add_notes.svg?react";
|
|
41
|
+
import "../../../../dialogs/descriptionModificationDialog/DescriptionModificationDialog.js";
|
|
42
|
+
import "../../../../inputs/reactHookForm/expandableInput/ExpandableInput.js";
|
|
43
|
+
import "@react-querybuilder/material";
|
|
44
|
+
import "../../../../filter/expert/expertFilterConstants.js";
|
|
45
|
+
import "../../../../inputs/reactQueryBuilder/CustomReactQueryBuilder.js";
|
|
46
|
+
import "uuid";
|
|
47
|
+
import "../../../../inputs/reactQueryBuilder/PropertyValueEditor.js";
|
|
48
|
+
import "react-querybuilder";
|
|
49
|
+
import { DataType } from "./assignment.type.js";
|
|
50
|
+
import GridItem from "../../../../grid/grid-item.js";
|
|
51
|
+
import { EQUIPMENTS_FIELDS } from "./assignment-constants.js";
|
|
52
|
+
const comparatorStrIgnoreCase = (str1, str2) => {
|
|
53
|
+
return str1?.toLowerCase()?.localeCompare(str2?.toLowerCase());
|
|
54
|
+
};
|
|
55
|
+
function AssignmentForm(props) {
|
|
56
|
+
const { name, index } = props;
|
|
57
|
+
const { setError, setValue } = useFormContext();
|
|
58
|
+
const intl = useIntl();
|
|
59
|
+
const watchEditedField = useWatch({
|
|
60
|
+
name: `${name}.${index}.${FieldConstants.EDITED_FIELD}`
|
|
61
|
+
});
|
|
62
|
+
const watchEquipmentType = useWatch({
|
|
63
|
+
name: FieldConstants.EQUIPMENT_TYPE
|
|
64
|
+
});
|
|
65
|
+
const equipmentFields = useMemo(
|
|
66
|
+
() => Object.values(EQUIPMENTS_FIELDS[watchEquipmentType] ?? []),
|
|
67
|
+
[watchEquipmentType]
|
|
68
|
+
);
|
|
69
|
+
const networkEquipmentType = useMemo(() => {
|
|
70
|
+
if ([
|
|
71
|
+
FieldType.OPERATIONAL_LIMITS_GROUP_1_WITH_PROPERTIES,
|
|
72
|
+
FieldType.OPERATIONAL_LIMITS_GROUP_2_WITH_PROPERTIES
|
|
73
|
+
].includes(watchEditedField)) {
|
|
74
|
+
return "limitsGroup";
|
|
75
|
+
}
|
|
76
|
+
return watchEquipmentType;
|
|
77
|
+
}, [watchEquipmentType, watchEditedField]);
|
|
78
|
+
const [predefinedProperties] = usePredefinedProperties(networkEquipmentType);
|
|
79
|
+
const dataType = useMemo(() => {
|
|
80
|
+
return equipmentFields?.find((fieldOption) => fieldOption?.id === watchEditedField)?.dataType;
|
|
81
|
+
}, [watchEditedField, equipmentFields]);
|
|
82
|
+
const settableToNone = useMemo(() => {
|
|
83
|
+
return equipmentFields?.find((fieldOption) => fieldOption?.id === watchEditedField)?.settableToNone ?? false;
|
|
84
|
+
}, [watchEditedField, equipmentFields]);
|
|
85
|
+
const watchPropertyName = useWatch({
|
|
86
|
+
name: `${name}.${index}.${FieldConstants.PROPERTY_NAME}`
|
|
87
|
+
});
|
|
88
|
+
const predefinedPropertiesNames = useMemo(() => {
|
|
89
|
+
return Object.keys(predefinedProperties ?? {}).sort(comparatorStrIgnoreCase);
|
|
90
|
+
}, [predefinedProperties]);
|
|
91
|
+
const predefinedPropertiesValues = useMemo(() => {
|
|
92
|
+
return [...predefinedProperties?.[watchPropertyName] ?? []].sort(comparatorStrIgnoreCase);
|
|
93
|
+
}, [watchPropertyName, predefinedProperties]);
|
|
94
|
+
const options = useMemo(() => {
|
|
95
|
+
return equipmentFields?.find((fieldOption) => fieldOption?.id === watchEditedField)?.values ?? [];
|
|
96
|
+
}, [watchEditedField, equipmentFields]);
|
|
97
|
+
const prevDataType = usePrevious(dataType);
|
|
98
|
+
if (prevDataType && prevDataType !== dataType) {
|
|
99
|
+
setValue(`${name}.${index}.${FieldConstants.VALUE}`, dataType === DataType.BOOLEAN ? false : null);
|
|
100
|
+
}
|
|
101
|
+
const emptyValueStr = useMemo(() => {
|
|
102
|
+
return intl.formatMessage({ id: "EmptyField" });
|
|
103
|
+
}, [intl]);
|
|
104
|
+
const formatLabelWithUnit = useFormatLabelWithUnit();
|
|
105
|
+
const renderAutoCompleteSettableToNone = useCallback(
|
|
106
|
+
(numberOnly) => /* @__PURE__ */ jsx(
|
|
107
|
+
AutocompleteInput,
|
|
108
|
+
{
|
|
109
|
+
name: `${name}.${index}.${FieldConstants.VALUE}`,
|
|
110
|
+
label: "ValueOrEmptyField",
|
|
111
|
+
options: [emptyValueStr],
|
|
112
|
+
size: "small",
|
|
113
|
+
onCheckNewValue: numberOnly ? (option) => {
|
|
114
|
+
if (option && option !== emptyValueStr && Number.isNaN(Number(option))) {
|
|
115
|
+
setError(`${name}.${index}.${FieldConstants.VALUE}`, {
|
|
116
|
+
message: "NumericValueOrEmptyField"
|
|
117
|
+
});
|
|
118
|
+
} else {
|
|
119
|
+
setError(`${name}.${index}.${FieldConstants.VALUE}`, {
|
|
120
|
+
message: ""
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
return true;
|
|
124
|
+
} : void 0,
|
|
125
|
+
getOptionLabel: (option) => typeof option !== "string" ? option?.label ?? option : option,
|
|
126
|
+
allowNewValue: true
|
|
127
|
+
}
|
|
128
|
+
),
|
|
129
|
+
[emptyValueStr, index, name, setError]
|
|
130
|
+
);
|
|
131
|
+
const filtersField = /* @__PURE__ */ jsx(
|
|
132
|
+
DirectoryItemsInput,
|
|
133
|
+
{
|
|
134
|
+
name: `${name}.${index}.${FieldConstants.FILTERS}`,
|
|
135
|
+
equipmentTypes: [watchEquipmentType],
|
|
136
|
+
elementType: ElementType.FILTER,
|
|
137
|
+
label: "filter",
|
|
138
|
+
titleId: "FiltersListsSelection",
|
|
139
|
+
disable: !watchEquipmentType
|
|
140
|
+
}
|
|
141
|
+
);
|
|
142
|
+
const editedField = /* @__PURE__ */ jsx(
|
|
143
|
+
AutocompleteInput,
|
|
144
|
+
{
|
|
145
|
+
name: `${name}.${index}.${FieldConstants.EDITED_FIELD}`,
|
|
146
|
+
options: equipmentFields,
|
|
147
|
+
label: "EditedField",
|
|
148
|
+
size: "small",
|
|
149
|
+
inputTransform: (value) => equipmentFields.find((option) => option?.id === value) || value,
|
|
150
|
+
outputTransform: (option) => getIdOrValue(option) ?? null,
|
|
151
|
+
getOptionLabel: (option) => formatLabelWithUnit(option),
|
|
152
|
+
isOptionEqualToValue: areIdsEqual
|
|
153
|
+
}
|
|
154
|
+
);
|
|
155
|
+
const propertyNameField = /* @__PURE__ */ jsx(
|
|
156
|
+
AutocompleteInput,
|
|
157
|
+
{
|
|
158
|
+
name: `${name}.${index}.${FieldConstants.PROPERTY_NAME}`,
|
|
159
|
+
options: predefinedPropertiesNames,
|
|
160
|
+
label: "PropertyName",
|
|
161
|
+
size: "small",
|
|
162
|
+
allowNewValue: true
|
|
163
|
+
}
|
|
164
|
+
);
|
|
165
|
+
const valueField = useMemo(() => {
|
|
166
|
+
if (dataType === DataType.PROPERTY) {
|
|
167
|
+
return /* @__PURE__ */ jsx(
|
|
168
|
+
AutocompleteInput,
|
|
169
|
+
{
|
|
170
|
+
name: `${name}.${index}.${FieldConstants.VALUE}`,
|
|
171
|
+
label: "PropertyValue",
|
|
172
|
+
options: predefinedPropertiesValues,
|
|
173
|
+
size: "small",
|
|
174
|
+
allowNewValue: true
|
|
175
|
+
}
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
if (dataType === DataType.INTEGER) {
|
|
179
|
+
return /* @__PURE__ */ jsx(IntegerInput, { name: `${name}.${index}.${FieldConstants.VALUE}`, label: "Value" });
|
|
180
|
+
}
|
|
181
|
+
if (dataType === DataType.BOOLEAN) {
|
|
182
|
+
return /* @__PURE__ */ jsx(SwitchInput, { name: `${name}.${index}.${FieldConstants.VALUE}`, formProps: { value: false } });
|
|
183
|
+
}
|
|
184
|
+
if (dataType === DataType.ENUM) {
|
|
185
|
+
return /* @__PURE__ */ jsx(
|
|
186
|
+
SelectInput,
|
|
187
|
+
{
|
|
188
|
+
name: `${name}.${index}.${FieldConstants.VALUE}`,
|
|
189
|
+
label: "Value",
|
|
190
|
+
options,
|
|
191
|
+
size: "small"
|
|
192
|
+
}
|
|
193
|
+
);
|
|
194
|
+
}
|
|
195
|
+
if (dataType === DataType.STRING && settableToNone) {
|
|
196
|
+
return renderAutoCompleteSettableToNone();
|
|
197
|
+
}
|
|
198
|
+
if (dataType === DataType.STRING) {
|
|
199
|
+
return /* @__PURE__ */ jsx(TextInput, { name: `${name}.${index}.${FieldConstants.VALUE}`, label: "Value", clearable: true });
|
|
200
|
+
}
|
|
201
|
+
if (dataType === DataType.DOUBLE && settableToNone) {
|
|
202
|
+
return renderAutoCompleteSettableToNone(true);
|
|
203
|
+
}
|
|
204
|
+
return /* @__PURE__ */ jsx(FloatInput, { name: `${name}.${index}.${FieldConstants.VALUE}`, label: "Value" });
|
|
205
|
+
}, [dataType, settableToNone, name, index, predefinedPropertiesValues, options, renderAutoCompleteSettableToNone]);
|
|
206
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
207
|
+
/* @__PURE__ */ jsx(GridItem, { size: 3.25, children: filtersField }),
|
|
208
|
+
/* @__PURE__ */ jsx(GridItem, { size: 3, children: editedField }),
|
|
209
|
+
/* @__PURE__ */ jsxs(Fragment, { children: [
|
|
210
|
+
dataType === DataType.PROPERTY && /* @__PURE__ */ jsx(GridItem, { size: 2, children: propertyNameField }),
|
|
211
|
+
/* @__PURE__ */ jsx(GridItem, { size: 0.25, children: /* @__PURE__ */ jsx(DensityLarge, { fontSize: "small", sx: { marginTop: 1 } }) })
|
|
212
|
+
] }),
|
|
213
|
+
/* @__PURE__ */ jsx(GridItem, { size: dataType === DataType.PROPERTY ? 2.25 : 4.25, children: valueField })
|
|
214
|
+
] });
|
|
215
|
+
}
|
|
216
|
+
export {
|
|
217
|
+
AssignmentForm as default
|
|
218
|
+
};
|
package/dist/components/network-modifications/by-filter/assignment/assignment/assignment-utils.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { yupConfig as yup } from '../../../../../utils';
|
|
2
|
+
import { Assignment, DataType, FieldOptionType, FieldValue } from './assignment.type';
|
|
3
|
+
export declare const getFieldOption: (fieldName?: string | null) => FieldOptionType | undefined;
|
|
4
|
+
export declare const getDataType: (fieldName?: string | null) => DataType | undefined;
|
|
5
|
+
export declare const getUnsettable: (fieldName?: string | null) => boolean | undefined;
|
|
6
|
+
export declare const getAssignmentInitialValue: () => {
|
|
7
|
+
filters: never[];
|
|
8
|
+
editedField: null;
|
|
9
|
+
propertyName: null;
|
|
10
|
+
value: null;
|
|
11
|
+
};
|
|
12
|
+
export declare function getAssignmentsSchema(emptyValueStr: string): yup.ArraySchema<{
|
|
13
|
+
propertyName?: string | undefined;
|
|
14
|
+
editedField: string;
|
|
15
|
+
filters: {
|
|
16
|
+
id: string;
|
|
17
|
+
name: string;
|
|
18
|
+
}[];
|
|
19
|
+
value: NonNullable<FieldValue | undefined>;
|
|
20
|
+
}[], yup.AnyObject, "", "">;
|
|
21
|
+
export declare function getAssignmentFromEditData(assignment: Assignment): Assignment;
|
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
|
+
};
|
|
@@ -31,6 +31,7 @@ import "@material-symbols/svg-400/outlined/arrows_output.svg?react";
|
|
|
31
31
|
import "@material-symbols/svg-400/outlined/left_panel_close.svg?react";
|
|
32
32
|
import "@material-symbols/svg-400/outlined/add_notes.svg?react";
|
|
33
33
|
import "../../../dialogs/descriptionModificationDialog/DescriptionModificationDialog.js";
|
|
34
|
+
import "../../../inputs/reactHookForm/expandableInput/ExpandableInput.js";
|
|
34
35
|
import "@react-querybuilder/material";
|
|
35
36
|
import "../../../filter/expert/expertFilterConstants.js";
|
|
36
37
|
import "../../../inputs/reactQueryBuilder/CustomReactQueryBuilder.js";
|
|
@@ -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
|
};
|
|
@@ -36,6 +36,7 @@ import "@material-symbols/svg-400/outlined/arrows_output.svg?react";
|
|
|
36
36
|
import "@material-symbols/svg-400/outlined/left_panel_close.svg?react";
|
|
37
37
|
import "@material-symbols/svg-400/outlined/add_notes.svg?react";
|
|
38
38
|
import "../../../dialogs/descriptionModificationDialog/DescriptionModificationDialog.js";
|
|
39
|
+
import "../../../inputs/reactHookForm/expandableInput/ExpandableInput.js";
|
|
39
40
|
import { CheckboxNullableInput } from "../../../inputs/reactHookForm/CheckboxNullableInput.js";
|
|
40
41
|
import "@react-querybuilder/material";
|
|
41
42
|
import "../../../filter/expert/expertFilterConstants.js";
|
|
@@ -32,6 +32,7 @@ import "@material-symbols/svg-400/outlined/arrows_output.svg?react";
|
|
|
32
32
|
import "@material-symbols/svg-400/outlined/left_panel_close.svg?react";
|
|
33
33
|
import "@material-symbols/svg-400/outlined/add_notes.svg?react";
|
|
34
34
|
import "../../../dialogs/descriptionModificationDialog/DescriptionModificationDialog.js";
|
|
35
|
+
import "../../../inputs/reactHookForm/expandableInput/ExpandableInput.js";
|
|
35
36
|
import "@react-querybuilder/material";
|
|
36
37
|
import "../../../filter/expert/expertFilterConstants.js";
|
|
37
38
|
import "../../../inputs/reactQueryBuilder/CustomReactQueryBuilder.js";
|
|
@@ -30,6 +30,7 @@ import "@material-symbols/svg-400/outlined/arrows_output.svg?react";
|
|
|
30
30
|
import "@material-symbols/svg-400/outlined/left_panel_close.svg?react";
|
|
31
31
|
import "@material-symbols/svg-400/outlined/add_notes.svg?react";
|
|
32
32
|
import "../../../dialogs/descriptionModificationDialog/DescriptionModificationDialog.js";
|
|
33
|
+
import "../../../inputs/reactHookForm/expandableInput/ExpandableInput.js";
|
|
33
34
|
import "@react-querybuilder/material";
|
|
34
35
|
import "../../../filter/expert/expertFilterConstants.js";
|
|
35
36
|
import "../../../inputs/reactQueryBuilder/CustomReactQueryBuilder.js";
|