@gridsuite/commons-ui 0.194.0 → 0.196.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.
Files changed (51) hide show
  1. package/dist/components/index.d.ts +1 -0
  2. package/dist/components/index.js +53 -0
  3. package/dist/components/network-modification-table/columns-definition.d.ts +26 -0
  4. package/dist/components/network-modification-table/columns-definition.js +36 -0
  5. package/dist/components/network-modification-table/index.d.ts +13 -0
  6. package/dist/components/network-modification-table/index.js +55 -0
  7. package/dist/components/network-modification-table/network-modification-table-styles.d.ts +210 -0
  8. package/dist/components/network-modification-table/network-modification-table-styles.js +333 -0
  9. package/dist/components/network-modification-table/network-modifications-table.d.ts +20 -0
  10. package/dist/components/network-modification-table/network-modifications-table.js +166 -0
  11. package/dist/components/network-modification-table/renderers/depth-box.d.ts +6 -0
  12. package/dist/components/network-modification-table/renderers/depth-box.js +21 -0
  13. package/dist/components/network-modification-table/renderers/drag-handle-cell.d.ts +5 -0
  14. package/dist/components/network-modification-table/renderers/drag-handle-cell.js +10 -0
  15. package/dist/components/network-modification-table/renderers/index.d.ts +12 -0
  16. package/dist/components/network-modification-table/renderers/index.js +14 -0
  17. package/dist/components/network-modification-table/renderers/name-cell.d.ts +7 -0
  18. package/dist/components/network-modification-table/renderers/name-cell.js +84 -0
  19. package/dist/components/network-modification-table/renderers/network-modification-node-editor-name-header.d.ts +14 -0
  20. package/dist/components/network-modification-table/renderers/network-modification-node-editor-name-header.js +40 -0
  21. package/dist/components/network-modification-table/renderers/select-cell.d.ts +8 -0
  22. package/dist/components/network-modification-table/renderers/select-cell.js +60 -0
  23. package/dist/components/network-modification-table/renderers/select-header-cell.d.ts +7 -0
  24. package/dist/components/network-modification-table/renderers/select-header-cell.js +26 -0
  25. package/dist/components/network-modification-table/row/drag-row-clone.d.ts +7 -0
  26. package/dist/components/network-modification-table/row/drag-row-clone.js +35 -0
  27. package/dist/components/network-modification-table/row/index.d.ts +8 -0
  28. package/dist/components/network-modification-table/row/index.js +6 -0
  29. package/dist/components/network-modification-table/row/modification-row.d.ts +12 -0
  30. package/dist/components/network-modification-table/row/modification-row.js +117 -0
  31. package/dist/components/network-modification-table/use-modifications-drag-and-drop.d.ts +21 -0
  32. package/dist/components/network-modification-table/use-modifications-drag-and-drop.js +170 -0
  33. package/dist/components/network-modification-table/utils.d.ts +40 -0
  34. package/dist/components/network-modification-table/utils.js +164 -0
  35. package/dist/components/network-modifications/by-filter/assignment/assignment/assignment-form.js +72 -53
  36. package/dist/components/network-modifications/by-filter/assignment/assignment/assignment-utils.d.ts +1 -0
  37. package/dist/components/network-modifications/by-filter/assignment/assignment/assignment-utils.js +8 -5
  38. package/dist/components/network-modifications/by-filter/assignment/modificationByAssignment.utils.js +5 -5
  39. package/dist/components/parameters/common/parameter-table-field/parameter-table-field.js +1 -1
  40. package/dist/components/parameters/dynamic-margin-calculation/loads-variations-parameters.js +1 -2
  41. package/dist/hooks/useModificationLabelComputer.d.ts +1 -12
  42. package/dist/index.js +59 -1
  43. package/dist/module-tanstack.d.js +1 -0
  44. package/dist/services/index.js +6 -1
  45. package/dist/services/networkModification.d.ts +21 -0
  46. package/dist/services/networkModification.js +34 -0
  47. package/dist/utils/types/index.d.ts +1 -0
  48. package/dist/utils/types/network-modification-metadata.d.ts +15 -0
  49. package/dist/utils/types/network-modification-metadata.js +1 -0
  50. package/dist/utils/types/network-modification-types.d.ts +5 -6
  51. package/package.json +3 -1
@@ -0,0 +1,164 @@
1
+ import "../../utils/conversionUtils.js";
2
+ import "../../utils/types/equipmentType.js";
3
+ import { MODIFICATION_TYPES } from "../../utils/types/modificationType.js";
4
+ import "react/jsx-runtime";
5
+ import "@mui/icons-material";
6
+ import "../../utils/yupConfig.js";
7
+ import { getNetworkModificationsFromComposite } from "../../services/networkModification.js";
8
+ const formatToComposedModification = (modifications) => {
9
+ return modifications.map((modification) => ({ ...modification, subModifications: [] }));
10
+ };
11
+ function isCompositeModification(modification) {
12
+ return modification?.messageType === MODIFICATION_TYPES.COMPOSITE_MODIFICATION.type;
13
+ }
14
+ function findAllLoadedCompositeModifications(modifications, composites) {
15
+ modifications.forEach((modification) => {
16
+ if (isCompositeModification(modification) && modification.subModifications.length > 0) {
17
+ composites.push(modification);
18
+ findAllLoadedCompositeModifications(modification.subModifications, composites);
19
+ }
20
+ });
21
+ }
22
+ function findModificationInTree(uuid, mods) {
23
+ for (const mod of mods) {
24
+ if (mod.uuid === uuid) {
25
+ return mod;
26
+ }
27
+ const found = findModificationInTree(uuid, mod.subModifications);
28
+ if (found) {
29
+ return found;
30
+ }
31
+ }
32
+ return void 0;
33
+ }
34
+ function updateSubModificationsOfACompositeInTree(parentModUuid, subModifications, tree) {
35
+ return tree.map((m) => {
36
+ if (m.uuid === parentModUuid) {
37
+ return { ...m, subModifications };
38
+ }
39
+ if (m.subModifications.length > 0) {
40
+ return {
41
+ ...m,
42
+ subModifications: updateSubModificationsOfACompositeInTree(
43
+ parentModUuid,
44
+ subModifications,
45
+ m.subModifications
46
+ )
47
+ };
48
+ }
49
+ return m;
50
+ });
51
+ }
52
+ function mergeSubModificationsIntoTree(nextMods, prevMods) {
53
+ return nextMods.map((nextMod) => {
54
+ const prevMod = prevMods.find((m) => m.uuid === nextMod.uuid);
55
+ if (!prevMod || prevMod.subModifications.length === 0) {
56
+ return nextMod;
57
+ }
58
+ return {
59
+ ...nextMod,
60
+ subModifications: mergeSubModificationsIntoTree(
61
+ nextMod.subModifications.length > 0 ? nextMod.subModifications : prevMod.subModifications,
62
+ prevMod.subModifications
63
+ )
64
+ };
65
+ });
66
+ }
67
+ function updateModificationFieldInTree(uuid, fields, mods) {
68
+ return mods.map((m) => {
69
+ if (m.uuid === uuid) {
70
+ return { ...m, ...fields };
71
+ }
72
+ if (m.subModifications.length > 0) {
73
+ return { ...m, subModifications: updateModificationFieldInTree(uuid, fields, m.subModifications) };
74
+ }
75
+ return m;
76
+ });
77
+ }
78
+ function getModificationInTree(modUuid, sourceParentUuid, mods) {
79
+ if (sourceParentUuid) {
80
+ const sourceMod = findModificationInTree(sourceParentUuid, mods);
81
+ if (!sourceMod) {
82
+ return void 0;
83
+ }
84
+ return sourceMod.subModifications.find((m) => m.uuid === modUuid);
85
+ }
86
+ return mods.find((m) => m.uuid === modUuid);
87
+ }
88
+ function moveSubModificationInTree(movingUuid, sourceParentUuid, targetParentUuid, beforeUuid, mods) {
89
+ const movedMod = getModificationInTree(
90
+ movingUuid,
91
+ sourceParentUuid,
92
+ mods
93
+ );
94
+ if (!movedMod) {
95
+ console.error(`Can't find the ${movingUuid} modification that should be moved`);
96
+ return mods;
97
+ }
98
+ let modsWithoutTheMovedModification;
99
+ if (sourceParentUuid) {
100
+ const sourceMod = findModificationInTree(sourceParentUuid, mods);
101
+ if (!sourceMod) {
102
+ return mods;
103
+ }
104
+ const newSourceSubs = sourceMod.subModifications.filter((m) => m.uuid !== movingUuid);
105
+ modsWithoutTheMovedModification = updateSubModificationsOfACompositeInTree(
106
+ sourceParentUuid,
107
+ newSourceSubs,
108
+ mods
109
+ );
110
+ } else {
111
+ modsWithoutTheMovedModification = mods.filter((m) => m.uuid !== movingUuid);
112
+ }
113
+ if (targetParentUuid) {
114
+ const targetMod = findModificationInTree(targetParentUuid, modsWithoutTheMovedModification);
115
+ if (!targetMod) {
116
+ return mods;
117
+ }
118
+ const newTargetSubs = [...targetMod.subModifications];
119
+ const insertIdx2 = beforeUuid ? newTargetSubs.findIndex((m) => m.uuid === beforeUuid) : -1;
120
+ newTargetSubs.splice(insertIdx2 === -1 ? newTargetSubs.length : insertIdx2, 0, movedMod);
121
+ return updateSubModificationsOfACompositeInTree(
122
+ targetParentUuid,
123
+ newTargetSubs,
124
+ modsWithoutTheMovedModification
125
+ );
126
+ }
127
+ const insertIdx = beforeUuid ? modsWithoutTheMovedModification.findIndex((m) => m.uuid === beforeUuid) : -1;
128
+ const result = [...modsWithoutTheMovedModification];
129
+ result.splice(insertIdx === -1 ? result.length : insertIdx, 0, movedMod);
130
+ return result;
131
+ }
132
+ function fetchSubModificationsForExpandedRows(expandedIds, mods, setMods, force = false) {
133
+ const uuidsToFetch = expandedIds.filter((id) => {
134
+ const mod = findModificationInTree(id, mods);
135
+ return isCompositeModification(mod) && (force || mod?.subModifications.length === 0);
136
+ });
137
+ if (uuidsToFetch.length === 0) {
138
+ return;
139
+ }
140
+ getNetworkModificationsFromComposite(uuidsToFetch).then((subModsByUuid) => {
141
+ setMods(
142
+ (prev) => Object.entries(subModsByUuid).reduce((tree, [uuid, subMods]) => {
143
+ const liveModifications = formatToComposedModification(subMods.filter((m) => !m.stashed));
144
+ const existingMod = findModificationInTree(uuid, tree);
145
+ const mergedSubs = mergeSubModificationsIntoTree(
146
+ liveModifications,
147
+ existingMod?.subModifications ?? []
148
+ );
149
+ return updateSubModificationsOfACompositeInTree(uuid, mergedSubs, tree);
150
+ }, prev)
151
+ );
152
+ });
153
+ }
154
+ export {
155
+ fetchSubModificationsForExpandedRows,
156
+ findAllLoadedCompositeModifications,
157
+ findModificationInTree,
158
+ formatToComposedModification,
159
+ isCompositeModification,
160
+ mergeSubModificationsIntoTree,
161
+ moveSubModificationInTree,
162
+ updateModificationFieldInTree,
163
+ updateSubModificationsOfACompositeInTree
164
+ };
@@ -1,5 +1,5 @@
1
1
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
- import { useMemo, useCallback } from "react";
2
+ import { useMemo, useRef, useState, useEffect, useCallback } from "react";
3
3
  import { DensityLarge } from "@mui/icons-material";
4
4
  import { useFormContext, useWatch } from "react-hook-form";
5
5
  import { useIntl } from "react-intl";
@@ -8,14 +8,13 @@ import "../../../../../utils/conversionUtils.js";
8
8
  import { ElementType } from "../../../../../utils/types/elementType.js";
9
9
  import "../../../../../utils/types/equipmentType.js";
10
10
  import { FieldType } from "../../../../../utils/types/fieldType.js";
11
- import { areIdsEqual, getIdOrValue } from "../../../../../utils/ts-utils.js";
11
+ import { getIdOrValue, areIdsEqual } from "../../../../../utils/ts-utils.js";
12
12
  import "../../../../../utils/yupConfig.js";
13
13
  import "@mui/material";
14
14
  import "localized-countries";
15
15
  import "localized-countries/data/fr";
16
16
  import "localized-countries/data/en";
17
17
  import { usePredefinedProperties } from "../../../../../hooks/usePredefinedProperties.js";
18
- import { usePrevious } from "../../../../../hooks/usePrevious.js";
19
18
  import "notistack";
20
19
  import { useFormatLabelWithUnit } from "../../../../../hooks/useFormatLabelWithUnit.js";
21
20
  import "../../../../overflowableText/OverflowableText.js";
@@ -49,6 +48,7 @@ import "react-querybuilder";
49
48
  import { DataType } from "./assignment.type.js";
50
49
  import GridItem from "../../../../grid/grid-item.js";
51
50
  import { EQUIPMENTS_FIELDS } from "./assignment-constants.js";
51
+ import { EMPTY_FIELD_VALUE } from "./assignment-utils.js";
52
52
  const comparatorStrIgnoreCase = (str1, str2) => {
53
53
  return str1?.toLowerCase()?.localeCompare(str2?.toLowerCase());
54
54
  };
@@ -94,24 +94,31 @@ function AssignmentForm(props) {
94
94
  const options = useMemo(() => {
95
95
  return equipmentFields?.find((fieldOption) => fieldOption?.id === watchEditedField)?.values ?? [];
96
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(() => {
97
+ const emptyFieldLabel = useMemo(() => {
102
98
  return intl.formatMessage({ id: "EmptyField" });
103
99
  }, [intl]);
104
100
  const formatLabelWithUnit = useFormatLabelWithUnit();
101
+ const prevEditedField = useRef(watchEditedField);
102
+ const [editedFieldKey, setEditedFieldKey] = useState(watchEditedField);
103
+ useEffect(() => {
104
+ if (prevEditedField.current !== watchEditedField) {
105
+ prevEditedField.current = watchEditedField;
106
+ setValue(`${name}.${index}.${FieldConstants.VALUE}`, dataType === DataType.BOOLEAN ? false : null);
107
+ setValue(`${name}.${index}.${FieldConstants.PROPERTY_NAME}`, null);
108
+ setEditedFieldKey(watchEditedField);
109
+ }
110
+ }, [dataType, index, name, setValue, watchEditedField]);
105
111
  const renderAutoCompleteSettableToNone = useCallback(
106
112
  (numberOnly) => /* @__PURE__ */ jsx(
107
113
  AutocompleteInput,
108
114
  {
109
115
  name: `${name}.${index}.${FieldConstants.VALUE}`,
110
116
  label: "ValueOrEmptyField",
111
- options: [emptyValueStr],
117
+ options: [emptyFieldLabel],
112
118
  size: "small",
113
119
  onCheckNewValue: numberOnly ? (option) => {
114
- if (option && option !== emptyValueStr && Number.isNaN(Number(option))) {
120
+ const optionValue = getIdOrValue(option);
121
+ if (optionValue && optionValue !== emptyFieldLabel && optionValue !== EMPTY_FIELD_VALUE && Number.isNaN(Number(optionValue))) {
115
122
  setError(`${name}.${index}.${FieldConstants.VALUE}`, {
116
123
  message: "NumericValueOrEmptyField"
117
124
  });
@@ -123,10 +130,19 @@ function AssignmentForm(props) {
123
130
  return true;
124
131
  } : void 0,
125
132
  getOptionLabel: (option) => typeof option !== "string" ? option?.label ?? option : option,
133
+ inputTransform: (value) => value === EMPTY_FIELD_VALUE ? emptyFieldLabel : value,
134
+ outputTransform: (value) => {
135
+ const optionValue = getIdOrValue(value);
136
+ if (optionValue === emptyFieldLabel) {
137
+ return EMPTY_FIELD_VALUE;
138
+ }
139
+ return optionValue ?? null;
140
+ },
126
141
  allowNewValue: true
127
- }
142
+ },
143
+ editedFieldKey
128
144
  ),
129
- [emptyValueStr, index, name, setError]
145
+ [emptyFieldLabel, index, name, setError, editedFieldKey]
130
146
  );
131
147
  const filtersField = /* @__PURE__ */ jsx(
132
148
  DirectoryItemsInput,
@@ -162,47 +178,50 @@ function AssignmentForm(props) {
162
178
  allowNewValue: true
163
179
  }
164
180
  );
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]);
181
+ let valueField;
182
+ if (dataType === DataType.PROPERTY) {
183
+ valueField = /* @__PURE__ */ jsx(
184
+ AutocompleteInput,
185
+ {
186
+ name: `${name}.${index}.${FieldConstants.VALUE}`,
187
+ label: "PropertyValue",
188
+ options: predefinedPropertiesValues,
189
+ size: "small",
190
+ allowNewValue: true
191
+ },
192
+ editedFieldKey
193
+ );
194
+ } else if (dataType === DataType.INTEGER) {
195
+ valueField = /* @__PURE__ */ jsx(IntegerInput, { name: `${name}.${index}.${FieldConstants.VALUE}`, label: "Value" }, editedFieldKey);
196
+ } else if (dataType === DataType.BOOLEAN) {
197
+ valueField = /* @__PURE__ */ jsx(
198
+ SwitchInput,
199
+ {
200
+ name: `${name}.${index}.${FieldConstants.VALUE}`,
201
+ formProps: { value: false }
202
+ },
203
+ editedFieldKey
204
+ );
205
+ } else if (dataType === DataType.ENUM) {
206
+ valueField = /* @__PURE__ */ jsx(
207
+ SelectInput,
208
+ {
209
+ name: `${name}.${index}.${FieldConstants.VALUE}`,
210
+ label: "Value",
211
+ options,
212
+ size: "small"
213
+ },
214
+ editedFieldKey
215
+ );
216
+ } else if (dataType === DataType.STRING && settableToNone) {
217
+ valueField = renderAutoCompleteSettableToNone();
218
+ } else if (dataType === DataType.STRING) {
219
+ valueField = /* @__PURE__ */ jsx(TextInput, { name: `${name}.${index}.${FieldConstants.VALUE}`, label: "Value", clearable: true }, editedFieldKey);
220
+ } else if (dataType === DataType.DOUBLE && settableToNone) {
221
+ valueField = renderAutoCompleteSettableToNone(true);
222
+ } else {
223
+ valueField = /* @__PURE__ */ jsx(FloatInput, { name: `${name}.${index}.${FieldConstants.VALUE}`, label: "Value" }, editedFieldKey);
224
+ }
206
225
  return /* @__PURE__ */ jsxs(Fragment, { children: [
207
226
  /* @__PURE__ */ jsx(GridItem, { size: 3.25, children: filtersField }),
208
227
  /* @__PURE__ */ jsx(GridItem, { size: 3, children: editedField }),
@@ -1,5 +1,6 @@
1
1
  import { yupConfig as yup } from '../../../../../utils';
2
2
  import { Assignment, DataType, FieldOptionType, FieldValue } from './assignment.type';
3
+ export declare const EMPTY_FIELD_VALUE = "\u2014";
3
4
  export declare const getFieldOption: (fieldName?: string | null) => FieldOptionType | undefined;
4
5
  export declare const getDataType: (fieldName?: string | null) => DataType | undefined;
5
6
  export declare const getUnsettable: (fieldName?: string | null) => boolean | undefined;
@@ -1,4 +1,5 @@
1
1
  import { FieldConstants } from "../../../../../utils/constants/fieldConstants.js";
2
+ import { YUP_REQUIRED } from "../../../../../utils/constants/translationKeys.js";
2
3
  import "../../../../../utils/conversionUtils.js";
3
4
  import "../../../../../utils/types/equipmentType.js";
4
5
  import "react/jsx-runtime";
@@ -7,6 +8,7 @@ import "../../../../../utils/yupConfig.js";
7
8
  import { DataType } from "./assignment.type.js";
8
9
  import { FIELD_OPTIONS } from "./assignment-constants.js";
9
10
  import * as yup from "yup";
11
+ const EMPTY_FIELD_VALUE = "—";
10
12
  const getFieldOption = (fieldName) => {
11
13
  return Object.values(FIELD_OPTIONS).find((fieldOption) => fieldOption.id === fieldName);
12
14
  };
@@ -40,7 +42,7 @@ function getValueSchema(emptyValueStr, dataType, settable_to_none) {
40
42
  default:
41
43
  schema = yup.number();
42
44
  }
43
- return schema.required();
45
+ return schema.required(YUP_REQUIRED);
44
46
  }
45
47
  const getAssignmentInitialValue = () => ({
46
48
  [FieldConstants.FILTERS]: [],
@@ -56,12 +58,12 @@ function getAssignmentsSchema(emptyValueStr) {
56
58
  [FieldConstants.ID]: yup.string().required(),
57
59
  [FieldConstants.NAME]: yup.string().required()
58
60
  })
59
- ).required().min(1, "YupRequired"),
60
- [FieldConstants.EDITED_FIELD]: yup.string().required(),
61
+ ).required().min(1, YUP_REQUIRED),
62
+ [FieldConstants.EDITED_FIELD]: yup.string().required(YUP_REQUIRED),
61
63
  [FieldConstants.PROPERTY_NAME]: yup.string().when([FieldConstants.EDITED_FIELD], ([editedField], schema) => {
62
64
  const dataType = getDataType(editedField);
63
65
  if (dataType === DataType.PROPERTY) {
64
- return schema.required();
66
+ return schema.required(YUP_REQUIRED);
65
67
  }
66
68
  return schema.nullable();
67
69
  }),
@@ -69,7 +71,7 @@ function getAssignmentsSchema(emptyValueStr) {
69
71
  const dataType = getDataType(editedField);
70
72
  const unsettable = getUnsettable(editedField);
71
73
  return getValueSchema(emptyValueStr, dataType, unsettable);
72
- }).required()
74
+ }).required(YUP_REQUIRED)
73
75
  })
74
76
  ).required();
75
77
  }
@@ -80,6 +82,7 @@ function getAssignmentFromEditData(assignment) {
80
82
  };
81
83
  }
82
84
  export {
85
+ EMPTY_FIELD_VALUE,
83
86
  getAssignmentFromEditData,
84
87
  getAssignmentInitialValue,
85
88
  getAssignmentsSchema,
@@ -8,12 +8,11 @@ import { FieldType } from "../../../../utils/types/fieldType.js";
8
8
  import "react/jsx-runtime";
9
9
  import "@mui/icons-material";
10
10
  import "../../../../utils/yupConfig.js";
11
- import { getAssignmentsSchema, getAssignmentInitialValue, getAssignmentFromEditData, getDataType } from "./assignment/assignment-utils.js";
11
+ import { getAssignmentsSchema, getAssignmentInitialValue, getAssignmentFromEditData, getUnsettable, EMPTY_FIELD_VALUE, getDataType } from "./assignment/assignment-utils.js";
12
12
  import { DataType } from "./assignment/assignment.type.js";
13
- const emptyValueStr = "—";
14
13
  const modificationByAssignmentFormSchema = yup.object().shape({
15
14
  [FieldConstants.EQUIPMENT_TYPE]: mixed().oneOf(Object.values(EquipmentType)).required(),
16
- [FieldConstants.ASSIGNMENTS]: getAssignmentsSchema(emptyValueStr)
15
+ [FieldConstants.ASSIGNMENTS]: getAssignmentsSchema(EMPTY_FIELD_VALUE)
17
16
  }).required();
18
17
  const emptyModificationByAssignmentFormData = {
19
18
  [FieldConstants.EQUIPMENT_TYPE]: null,
@@ -27,9 +26,10 @@ const modificationByAssignmentDtoToForm = (dto) => ({
27
26
  const field = FieldType[fieldKey];
28
27
  const { value } = assignment;
29
28
  const valueConverted = convertInputValue(field, value);
29
+ const unsettable = getUnsettable(assignment.editedField);
30
30
  return {
31
31
  ...assignment,
32
- value: valueConverted !== 0 && !valueConverted ? emptyValueStr : valueConverted
32
+ value: unsettable && valueConverted !== 0 && !valueConverted ? EMPTY_FIELD_VALUE : valueConverted
33
33
  };
34
34
  }) ?? [getAssignmentInitialValue()]
35
35
  });
@@ -39,7 +39,7 @@ const modificationByAssignmentFormToDto = (formData) => ({
39
39
  assignmentInfosList: formData.assignments.map((assignment) => {
40
40
  const fieldKey = assignment.editedField;
41
41
  const field = FieldType[fieldKey];
42
- const value = assignment.value === emptyValueStr ? "" : assignment.value;
42
+ const value = assignment.value === EMPTY_FIELD_VALUE ? "" : assignment.value;
43
43
  return {
44
44
  ...assignment,
45
45
  dataType: getDataType(assignment.editedField) ?? DataType.STRING,
@@ -50,7 +50,7 @@ function ParameterTableField({
50
50
  });
51
51
  const { getValues } = useFormContext();
52
52
  const validRowCountRef = useRef(
53
- getValues(name).filter((row) => isValidRow ? isValidRow(row) : true).length
53
+ getValues(name)?.filter((row) => isValidRow ? isValidRow(row) : true).length
54
54
  );
55
55
  const newDefaultRowData = useMemo(() => {
56
56
  return getDefaultRowData(columnsDefinition);
@@ -145,8 +145,7 @@ function LoadsVariationsParameters({ path }) {
145
145
  label: "DynamicMarginCalculationLoadsVariations",
146
146
  tooltipProps: { title: "DynamicMarginCalculationLoadsVariations" },
147
147
  columnsDefinition,
148
- tableHeight: 270,
149
- disableDragAndDrop: true
148
+ tableHeight: 270
150
149
  }
151
150
  )
152
151
  ] });
@@ -1,15 +1,4 @@
1
- import { UUID } from 'node:crypto';
2
- import { ModificationType } from '../utils';
3
- export interface NetworkModificationMetadata {
4
- uuid: UUID;
5
- type: ModificationType;
6
- date: Date;
7
- stashed: boolean;
8
- activated: boolean;
9
- description: string;
10
- messageType: string;
11
- messageValues: string;
12
- }
1
+ import { NetworkModificationMetadata } from '../utils';
13
2
  export declare const useModificationLabelComputer: () => {
14
3
  computeLabel: (modif: NetworkModificationMetadata, formatBold?: boolean) => {
15
4
  action: string;