@gridsuite/commons-ui 0.116.4 → 0.118.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/directoryItemSelector/DirectoryItemSelector.js +22 -20
- package/dist/components/directoryItemSelector/utils.d.ts +8 -5
- package/dist/components/directoryItemSelector/utils.js +20 -14
- package/dist/components/dnd-table/dnd-table.d.ts +1 -0
- package/dist/components/dnd-table/dnd-table.js +6 -6
- package/dist/components/filter/expert/expertFilterConstants.d.ts +28 -0
- package/dist/components/filter/expert/expertFilterConstants.js +28 -0
- package/dist/components/inputs/reactHookForm/autocompleteInputs/AutocompleteInput.js +1 -1
- package/dist/components/inputs/reactHookForm/numbers/SliderInput.d.ts +1 -1
- package/dist/components/inputs/reactHookForm/numbers/SliderInput.js +4 -2
- package/dist/components/inputs/reactHookForm/text/UniqueNameInput.d.ts +1 -1
- package/dist/components/inputs/reactHookForm/text/UniqueNameInput.js +8 -77
- package/dist/components/parameters/common/limitreductions/columns-definitions.js +1 -5
- package/dist/hooks/use-unique-name-validation.d.ts +16 -0
- package/dist/hooks/use-unique-name-validation.js +92 -0
- package/dist/hooks/useModificationLabelComputer.js +1 -0
- package/dist/translations/en/filterExpertEn.d.ts +4 -0
- package/dist/translations/en/filterExpertEn.js +4 -0
- package/dist/translations/en/networkModificationsEn.d.ts +1 -0
- package/dist/translations/en/networkModificationsEn.js +2 -1
- package/dist/translations/fr/filterExpertFr.d.ts +4 -0
- package/dist/translations/fr/filterExpertFr.js +4 -0
- package/dist/translations/fr/networkModificationsFr.d.ts +1 -0
- package/dist/translations/fr/networkModificationsFr.js +2 -1
- package/dist/utils/types/fieldType.d.ts +4 -0
- package/dist/utils/types/fieldType.js +4 -0
- package/dist/utils/types/modificationType.d.ts +5 -1
- package/dist/utils/types/modificationType.js +5 -0
- package/package.json +1 -1
|
@@ -180,27 +180,27 @@ function DirectoryItemSelector({
|
|
|
180
180
|
const fetchDirectoryChildren = useCallback(
|
|
181
181
|
(nodeId) => {
|
|
182
182
|
const typeList = types.includes(ElementType.DIRECTORY) ? [] : types;
|
|
183
|
-
fetchDirectoryContent(nodeId, typeList).then((children) => {
|
|
183
|
+
return fetchDirectoryContent(nodeId, typeList).then((children) => {
|
|
184
184
|
const childrenMatchedTypes = children.filter(
|
|
185
185
|
(item) => contentFilter().has(item.type)
|
|
186
186
|
);
|
|
187
187
|
if (childrenMatchedTypes.length > 0 && equipmentTypes && equipmentTypes.length > 0) {
|
|
188
|
-
fetchElementsInfos(
|
|
188
|
+
return fetchElementsInfos(
|
|
189
189
|
childrenMatchedTypes.map((e) => e.elementUuid),
|
|
190
190
|
types,
|
|
191
191
|
equipmentTypes
|
|
192
192
|
).then((childrenWithMetadata) => {
|
|
193
|
-
const
|
|
193
|
+
const filteredChildren = itemFilter ? childrenWithMetadata.filter((val) => {
|
|
194
194
|
if (val.type === ElementType.DIRECTORY) {
|
|
195
195
|
return true;
|
|
196
196
|
}
|
|
197
197
|
return itemFilter(val);
|
|
198
198
|
}) : childrenWithMetadata;
|
|
199
|
-
addToDirectory(nodeId,
|
|
199
|
+
addToDirectory(nodeId, filteredChildren);
|
|
200
200
|
});
|
|
201
|
-
} else {
|
|
202
|
-
addToDirectory(nodeId, childrenMatchedTypes);
|
|
203
201
|
}
|
|
202
|
+
addToDirectory(nodeId, childrenMatchedTypes);
|
|
203
|
+
return Promise.resolve();
|
|
204
204
|
}).catch((error) => {
|
|
205
205
|
console.warn(`Could not update subs (and content) of '${nodeId}' : ${error.message}`);
|
|
206
206
|
});
|
|
@@ -208,13 +208,11 @@ function DirectoryItemSelector({
|
|
|
208
208
|
[types, equipmentTypes, itemFilter, contentFilter, addToDirectory]
|
|
209
209
|
);
|
|
210
210
|
const fetchNodeChildrenIfNeeded = useCallback(
|
|
211
|
-
(nodeId
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
}
|
|
217
|
-
}, delay);
|
|
211
|
+
async (nodeId) => {
|
|
212
|
+
const node = nodeMap.current[nodeId];
|
|
213
|
+
if (node && (!node.children || node.children.length === 0) && node.type === ElementType.DIRECTORY) {
|
|
214
|
+
await fetchDirectoryChildren(nodeId);
|
|
215
|
+
}
|
|
218
216
|
},
|
|
219
217
|
[fetchDirectoryChildren]
|
|
220
218
|
);
|
|
@@ -224,15 +222,15 @@ function DirectoryItemSelector({
|
|
|
224
222
|
}
|
|
225
223
|
const expandedArray = await getExpansionPathsForSelected(selected, expanded);
|
|
226
224
|
setAutoExpandedNodes(expandedArray);
|
|
227
|
-
fetchChildrenForExpandedNodes(expandedArray, fetchNodeChildrenIfNeeded);
|
|
225
|
+
await fetchChildrenForExpandedNodes(expandedArray, fetchNodeChildrenIfNeeded);
|
|
228
226
|
return true;
|
|
229
227
|
}, [selected, expanded, fetchNodeChildrenIfNeeded]);
|
|
230
|
-
const handleProvidedExpansion = useCallback(() => {
|
|
228
|
+
const handleProvidedExpansion = useCallback(async () => {
|
|
231
229
|
if (!expanded || expanded.length === 0) {
|
|
232
230
|
return false;
|
|
233
231
|
}
|
|
234
232
|
setAutoExpandedNodes(expanded);
|
|
235
|
-
fetchChildrenForExpandedNodes(expanded, fetchNodeChildrenIfNeeded);
|
|
233
|
+
await fetchChildrenForExpandedNodes(expanded, fetchNodeChildrenIfNeeded);
|
|
236
234
|
return true;
|
|
237
235
|
}, [expanded, fetchNodeChildrenIfNeeded]);
|
|
238
236
|
const handleLastSelectedExpansion = useCallback(async () => {
|
|
@@ -241,14 +239,18 @@ function DirectoryItemSelector({
|
|
|
241
239
|
return false;
|
|
242
240
|
}
|
|
243
241
|
setAutoExpandedNodes(expandPath);
|
|
244
|
-
fetchChildrenForExpandedNodes(expandPath, fetchNodeChildrenIfNeeded);
|
|
242
|
+
await fetchChildrenForExpandedNodes(expandPath, fetchNodeChildrenIfNeeded);
|
|
245
243
|
return true;
|
|
246
244
|
}, [fetchNodeChildrenIfNeeded]);
|
|
247
245
|
const initializeExpansion = useCallback(async () => {
|
|
248
246
|
const selectedSuccess = await handleSelectedExpansion();
|
|
249
|
-
if (selectedSuccess)
|
|
250
|
-
|
|
251
|
-
|
|
247
|
+
if (selectedSuccess) {
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
const expandedSuccess = await handleProvidedExpansion();
|
|
251
|
+
if (expandedSuccess) {
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
252
254
|
await handleLastSelectedExpansion();
|
|
253
255
|
}, [handleSelectedExpansion, handleProvidedExpansion, handleLastSelectedExpansion]);
|
|
254
256
|
useEffect(() => {
|
|
@@ -26,10 +26,14 @@ export declare function fetchDirectoryPathSafe(directoryId: UUID): Promise<Eleme
|
|
|
26
26
|
*/
|
|
27
27
|
export declare function initializeFromLastSelected(): Promise<UUID[] | null>;
|
|
28
28
|
/**
|
|
29
|
-
* Fetches expansion paths for multiple selected items
|
|
29
|
+
* Fetches expansion paths for multiple selected items, collecting unique parent directories
|
|
30
|
+
* (excluding the selected items themselves) and sorting them by their minimum depth across
|
|
31
|
+
* all paths. This ensures parents appear before their descendants in the returned array,
|
|
32
|
+
* which is crucial for sequential fetching to avoid loading children before parents are
|
|
33
|
+
* fully populated in the node map.
|
|
30
34
|
* @param selectedIds Array of selected item UUIDs
|
|
31
35
|
* @param expanded Optional existing expanded nodes
|
|
32
|
-
* @returns Promise resolving to combined expansion array
|
|
36
|
+
* @returns Promise resolving to combined expansion array sorted by depth
|
|
33
37
|
*/
|
|
34
38
|
export declare function getExpansionPathsForSelected(selectedIds: UUID[], expanded?: UUID[]): Promise<UUID[]>;
|
|
35
39
|
/**
|
|
@@ -44,9 +48,8 @@ export declare function saveLastSelectedDirectoryFromNode(node: {
|
|
|
44
48
|
}>;
|
|
45
49
|
}): Promise<void>;
|
|
46
50
|
/**
|
|
47
|
-
* Fetches children for expanded nodes
|
|
51
|
+
* Fetches children for expanded nodes sequentially to ensure parent nodes are loaded before children
|
|
48
52
|
* @param expandedNodes Array of node UUIDs to fetch children for
|
|
49
53
|
* @param fetchChildrenCallback Function to fetch children for a single node
|
|
50
|
-
* @param delayBetweenRequests Delay in milliseconds between requests (default: 100ms)
|
|
51
54
|
*/
|
|
52
|
-
export declare function fetchChildrenForExpandedNodes(expandedNodes: UUID[], fetchChildrenCallback: (nodeId: UUID
|
|
55
|
+
export declare function fetchChildrenForExpandedNodes(expandedNodes: UUID[], fetchChildrenCallback: (nodeId: UUID) => Promise<void>): Promise<void>;
|
|
@@ -54,18 +54,23 @@ async function initializeFromLastSelected() {
|
|
|
54
54
|
}
|
|
55
55
|
async function getExpansionPathsForSelected(selectedIds, expanded = []) {
|
|
56
56
|
const expandedSet = new Set(expanded);
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
57
|
+
const idToMinIndex = /* @__PURE__ */ new Map();
|
|
58
|
+
const paths = await Promise.all(selectedIds.map(fetchDirectoryPathSafe));
|
|
59
|
+
paths.filter((p) => !!p && p.length > 0).forEach((path) => {
|
|
60
|
+
path.forEach((element, index) => {
|
|
61
|
+
if (index < path.length - 1) {
|
|
62
|
+
const id = element.elementUuid;
|
|
63
|
+
expandedSet.add(id);
|
|
64
|
+
if (!idToMinIndex.has(id) || index < idToMinIndex.get(id)) {
|
|
65
|
+
idToMinIndex.set(id, index);
|
|
63
66
|
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
67
|
+
}
|
|
68
|
+
});
|
|
66
69
|
});
|
|
67
|
-
|
|
68
|
-
|
|
70
|
+
const expandedArray = Array.from(expandedSet).sort(
|
|
71
|
+
(a, b) => (idToMinIndex.get(a) ?? Infinity) - (idToMinIndex.get(b) ?? Infinity)
|
|
72
|
+
);
|
|
73
|
+
return expandedArray;
|
|
69
74
|
}
|
|
70
75
|
async function saveLastSelectedDirectoryFromNode(node) {
|
|
71
76
|
let lastSelectedDirId;
|
|
@@ -78,10 +83,11 @@ async function saveLastSelectedDirectoryFromNode(node) {
|
|
|
78
83
|
await saveLastSelectedDirectory(lastSelectedDirId);
|
|
79
84
|
}
|
|
80
85
|
}
|
|
81
|
-
function fetchChildrenForExpandedNodes(expandedNodes, fetchChildrenCallback
|
|
82
|
-
expandedNodes.
|
|
83
|
-
|
|
84
|
-
|
|
86
|
+
async function fetchChildrenForExpandedNodes(expandedNodes, fetchChildrenCallback) {
|
|
87
|
+
await expandedNodes.reduce(async (promise, nodeId) => {
|
|
88
|
+
await promise;
|
|
89
|
+
return fetchChildrenCallback(nodeId);
|
|
90
|
+
}, Promise.resolve());
|
|
85
91
|
}
|
|
86
92
|
export {
|
|
87
93
|
clearLastSelectedDirectory,
|
|
@@ -23,6 +23,7 @@ interface DndTableProps {
|
|
|
23
23
|
uploadButtonMessageId?: string;
|
|
24
24
|
handleResetButton?: () => void;
|
|
25
25
|
resetButtonMessageId?: string;
|
|
26
|
+
maxRows?: number;
|
|
26
27
|
}
|
|
27
28
|
export declare function DndTable(props: Readonly<DndTableProps>): import("react/jsx-runtime").JSX.Element;
|
|
28
29
|
export {};
|
|
@@ -5,7 +5,7 @@ import { Grid, TableContainer, Table, TableHead, TableRow, TableCell, Box, Table
|
|
|
5
5
|
import { DragIndicator } from "@mui/icons-material";
|
|
6
6
|
import { DragDropContext, Droppable, Draggable } from "@hello-pangea/dnd";
|
|
7
7
|
import { useIntl } from "react-intl";
|
|
8
|
-
import {
|
|
8
|
+
import { MAX_ROWS_NUMBER, SELECTED, DndColumnType } from "./dnd-table.type.js";
|
|
9
9
|
import { DndTableBottomLeftButtons } from "./dnd-table-bottom-left-buttons.js";
|
|
10
10
|
import { DndTableBottomRightButtons } from "./dnd-table-bottom-right-buttons.js";
|
|
11
11
|
import { DndTableAddRowsDialog } from "./dnd-table-add-rows-dialog.js";
|
|
@@ -29,9 +29,8 @@ import "localized-countries/data/fr";
|
|
|
29
29
|
import "localized-countries/data/en";
|
|
30
30
|
import { TableNumericalInput } from "../inputs/reactHookForm/tableInputs/table-numerical-input.js";
|
|
31
31
|
import { TableTextInput } from "../inputs/reactHookForm/tableInputs/table-text-input.js";
|
|
32
|
-
import "../../utils/types/equipmentType.js";
|
|
33
|
-
import "notistack";
|
|
34
32
|
import "../../utils/conversionUtils.js";
|
|
33
|
+
import "../../utils/types/equipmentType.js";
|
|
35
34
|
import "../../utils/yupConfig.js";
|
|
36
35
|
import "@react-querybuilder/material";
|
|
37
36
|
import "../filter/expert/expertFilterConstants.js";
|
|
@@ -163,7 +162,8 @@ function DndTable(props) {
|
|
|
163
162
|
handleUploadButton = void 0,
|
|
164
163
|
uploadButtonMessageId = void 0,
|
|
165
164
|
handleResetButton = void 0,
|
|
166
|
-
resetButtonMessageId = void 0
|
|
165
|
+
resetButtonMessageId = void 0,
|
|
166
|
+
maxRows = MAX_ROWS_NUMBER
|
|
167
167
|
} = props;
|
|
168
168
|
const intl = useIntl();
|
|
169
169
|
const { getValues, setValue, setError, clearErrors } = useFormContext();
|
|
@@ -192,7 +192,7 @@ function DndTable(props) {
|
|
|
192
192
|
);
|
|
193
193
|
}
|
|
194
194
|
const addNewRows = (numberOfRows) => {
|
|
195
|
-
if (currentRows.length + numberOfRows >
|
|
195
|
+
if (currentRows.length + numberOfRows > maxRows) {
|
|
196
196
|
setError(arrayFormName, {
|
|
197
197
|
type: "custom",
|
|
198
198
|
message: intl.formatMessage(
|
|
@@ -200,7 +200,7 @@ function DndTable(props) {
|
|
|
200
200
|
id: "MaximumRowNumberError"
|
|
201
201
|
},
|
|
202
202
|
{
|
|
203
|
-
value:
|
|
203
|
+
value: maxRows
|
|
204
204
|
}
|
|
205
205
|
)
|
|
206
206
|
});
|
|
@@ -219,6 +219,34 @@ export declare const FIELDS_OPTIONS: {
|
|
|
219
219
|
dataType: DataType;
|
|
220
220
|
inputType: string;
|
|
221
221
|
};
|
|
222
|
+
P: {
|
|
223
|
+
name: FieldType;
|
|
224
|
+
label: string;
|
|
225
|
+
unit: string;
|
|
226
|
+
dataType: DataType;
|
|
227
|
+
inputType: string;
|
|
228
|
+
};
|
|
229
|
+
Q: {
|
|
230
|
+
name: FieldType;
|
|
231
|
+
label: string;
|
|
232
|
+
unit: string;
|
|
233
|
+
dataType: DataType;
|
|
234
|
+
inputType: string;
|
|
235
|
+
};
|
|
236
|
+
P_ABSOLUTE: {
|
|
237
|
+
name: FieldType;
|
|
238
|
+
label: string;
|
|
239
|
+
unit: string;
|
|
240
|
+
dataType: DataType;
|
|
241
|
+
inputType: string;
|
|
242
|
+
};
|
|
243
|
+
Q_ABSOLUTE: {
|
|
244
|
+
name: FieldType;
|
|
245
|
+
label: string;
|
|
246
|
+
unit: string;
|
|
247
|
+
dataType: DataType;
|
|
248
|
+
inputType: string;
|
|
249
|
+
};
|
|
222
250
|
TARGET_P: {
|
|
223
251
|
name: FieldType;
|
|
224
252
|
label: string;
|
|
@@ -208,6 +208,34 @@ const FIELDS_OPTIONS = {
|
|
|
208
208
|
dataType: DataType.NUMBER,
|
|
209
209
|
inputType: "number"
|
|
210
210
|
},
|
|
211
|
+
P: {
|
|
212
|
+
name: FieldType.P,
|
|
213
|
+
label: "p",
|
|
214
|
+
unit: MEGA_WATT,
|
|
215
|
+
dataType: DataType.NUMBER,
|
|
216
|
+
inputType: "number"
|
|
217
|
+
},
|
|
218
|
+
Q: {
|
|
219
|
+
name: FieldType.Q,
|
|
220
|
+
label: "q",
|
|
221
|
+
unit: MEGA_WATT,
|
|
222
|
+
dataType: DataType.NUMBER,
|
|
223
|
+
inputType: "number"
|
|
224
|
+
},
|
|
225
|
+
P_ABSOLUTE: {
|
|
226
|
+
name: FieldType.P_ABSOLUTE,
|
|
227
|
+
label: "pAbsolute",
|
|
228
|
+
unit: MEGA_WATT,
|
|
229
|
+
dataType: DataType.NUMBER,
|
|
230
|
+
inputType: "number"
|
|
231
|
+
},
|
|
232
|
+
Q_ABSOLUTE: {
|
|
233
|
+
name: FieldType.Q_ABSOLUTE,
|
|
234
|
+
label: "qAbsolute",
|
|
235
|
+
unit: MEGA_WATT,
|
|
236
|
+
dataType: DataType.NUMBER,
|
|
237
|
+
inputType: "number"
|
|
238
|
+
},
|
|
211
239
|
TARGET_P: {
|
|
212
240
|
name: FieldType.TARGET_P,
|
|
213
241
|
label: "targetP",
|
|
@@ -37,7 +37,7 @@ function AutocompleteInput({
|
|
|
37
37
|
if ((currentValue == null ? void 0 : currentValue.id) === newValue) {
|
|
38
38
|
return;
|
|
39
39
|
}
|
|
40
|
-
if (
|
|
40
|
+
if (onCheckNewValue && !onCheckNewValue(newValue)) {
|
|
41
41
|
return;
|
|
42
42
|
}
|
|
43
43
|
onChangeCallback == null ? void 0 : onChangeCallback();
|
|
@@ -3,4 +3,4 @@ export interface SliderInputProps extends SliderProps {
|
|
|
3
3
|
name: string;
|
|
4
4
|
onValueChanged?: (value: number | number[]) => void;
|
|
5
5
|
}
|
|
6
|
-
export declare function SliderInput({ name, min, max, step, size, marks, valueLabelDisplay, valueLabelFormat, onValueChanged, }: SliderInputProps): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export declare function SliderInput({ name, min, max, step, size, marks, valueLabelDisplay, valueLabelFormat, onValueChanged, ...otherProps }: SliderInputProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -11,7 +11,8 @@ function SliderInput({
|
|
|
11
11
|
marks,
|
|
12
12
|
valueLabelDisplay,
|
|
13
13
|
valueLabelFormat,
|
|
14
|
-
onValueChanged = identity
|
|
14
|
+
onValueChanged = identity,
|
|
15
|
+
...otherProps
|
|
15
16
|
}) {
|
|
16
17
|
const {
|
|
17
18
|
field: { onChange, value }
|
|
@@ -31,7 +32,8 @@ function SliderInput({
|
|
|
31
32
|
onChange: handleValueChange,
|
|
32
33
|
marks,
|
|
33
34
|
valueLabelDisplay,
|
|
34
|
-
valueLabelFormat
|
|
35
|
+
valueLabelFormat,
|
|
36
|
+
...otherProps
|
|
35
37
|
}
|
|
36
38
|
);
|
|
37
39
|
}
|
|
@@ -14,6 +14,6 @@ export interface UniqueNameInputProps {
|
|
|
14
14
|
fullWidth?: boolean;
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
|
-
* Input component that constantly
|
|
17
|
+
* Input component that constantly checks if the field's value is available or not
|
|
18
18
|
*/
|
|
19
19
|
export declare function UniqueNameInput({ name, label, elementType, autoFocus, onManualChangeCallback, formProps, currentName, activeDirectory, sx, fullWidth, }: Readonly<UniqueNameInputProps>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,19 +1,9 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useCallback, useEffect } from "react";
|
|
3
2
|
import { FormattedMessage } from "react-intl";
|
|
4
3
|
import { TextField, InputAdornment, CircularProgress } from "@mui/material";
|
|
5
4
|
import { Check } from "@mui/icons-material";
|
|
6
|
-
import { useController
|
|
7
|
-
import "../../../../
|
|
8
|
-
import { elementAlreadyExists } from "../../../../services/directory.js";
|
|
9
|
-
import { useDebounce } from "../../../../hooks/useDebounce.js";
|
|
10
|
-
import "localized-countries";
|
|
11
|
-
import "localized-countries/data/fr";
|
|
12
|
-
import "localized-countries/data/en";
|
|
13
|
-
import "notistack";
|
|
14
|
-
import { FieldConstants } from "../../../../utils/constants/fieldConstants.js";
|
|
15
|
-
import "../../../../utils/conversionUtils.js";
|
|
16
|
-
import "../../../../utils/yupConfig.js";
|
|
5
|
+
import { useController } from "react-hook-form";
|
|
6
|
+
import { useUniqueNameValidation } from "../../../../hooks/use-unique-name-validation.js";
|
|
17
7
|
function UniqueNameInput({
|
|
18
8
|
name,
|
|
19
9
|
label,
|
|
@@ -26,77 +16,18 @@ function UniqueNameInput({
|
|
|
26
16
|
sx,
|
|
27
17
|
fullWidth = true
|
|
28
18
|
}) {
|
|
29
|
-
var _a;
|
|
30
19
|
const {
|
|
31
20
|
field: { onChange, onBlur, value, ref },
|
|
32
|
-
fieldState: { error
|
|
21
|
+
fieldState: { error }
|
|
33
22
|
} = useController({
|
|
34
23
|
name
|
|
35
24
|
});
|
|
36
|
-
const {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
25
|
+
const { isValidating } = useUniqueNameValidation({
|
|
26
|
+
name,
|
|
27
|
+
currentName,
|
|
28
|
+
elementType,
|
|
29
|
+
activeDirectory
|
|
40
30
|
});
|
|
41
|
-
const {
|
|
42
|
-
setError,
|
|
43
|
-
clearErrors,
|
|
44
|
-
trigger,
|
|
45
|
-
formState: { errors }
|
|
46
|
-
} = useFormContext();
|
|
47
|
-
const isValidating = (_a = errors.root) == null ? void 0 : _a.isValidating;
|
|
48
|
-
const directory = selectedDirectory || activeDirectory;
|
|
49
|
-
const handleCheckName = useCallback(
|
|
50
|
-
(nameValue) => {
|
|
51
|
-
if (nameValue !== currentName && directory) {
|
|
52
|
-
elementAlreadyExists(directory, nameValue, elementType).then((alreadyExist) => {
|
|
53
|
-
if (alreadyExist) {
|
|
54
|
-
setError(name, {
|
|
55
|
-
type: "validate",
|
|
56
|
-
message: "nameAlreadyUsed"
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
}).catch((e) => {
|
|
60
|
-
setError(name, {
|
|
61
|
-
type: "validate",
|
|
62
|
-
message: "nameValidityCheckErrorMsg"
|
|
63
|
-
});
|
|
64
|
-
console.error(e == null ? void 0 : e.message);
|
|
65
|
-
}).finally(() => {
|
|
66
|
-
clearErrors("root.isValidating");
|
|
67
|
-
trigger("root.isValidating");
|
|
68
|
-
});
|
|
69
|
-
} else {
|
|
70
|
-
trigger("root.isValidating");
|
|
71
|
-
}
|
|
72
|
-
},
|
|
73
|
-
[currentName, directory, elementType, setError, name, clearErrors, trigger]
|
|
74
|
-
);
|
|
75
|
-
const debouncedHandleCheckName = useDebounce(handleCheckName, 700);
|
|
76
|
-
useEffect(() => {
|
|
77
|
-
const trimmedValue = value.trim();
|
|
78
|
-
if (selectedDirectory) {
|
|
79
|
-
debouncedHandleCheckName(trimmedValue);
|
|
80
|
-
}
|
|
81
|
-
if (!isDirty) {
|
|
82
|
-
clearErrors(name);
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
if (trimmedValue) {
|
|
86
|
-
clearErrors(name);
|
|
87
|
-
setError("root.isValidating", {
|
|
88
|
-
type: "validate",
|
|
89
|
-
message: "cantSubmitWhileValidating"
|
|
90
|
-
});
|
|
91
|
-
debouncedHandleCheckName(trimmedValue);
|
|
92
|
-
} else {
|
|
93
|
-
clearErrors("root.isValidating");
|
|
94
|
-
setError(name, {
|
|
95
|
-
type: "validate",
|
|
96
|
-
message: "nameEmpty"
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
}, [debouncedHandleCheckName, setError, clearErrors, name, value, isDirty, selectedDirectory]);
|
|
100
31
|
const handleManualChange = (e) => {
|
|
101
32
|
onChange(e.target.value);
|
|
102
33
|
onManualChangeCallback == null ? void 0 : onManualChangeCallback();
|
|
@@ -8,12 +8,8 @@ import "@mui/icons-material";
|
|
|
8
8
|
import "react-hook-form";
|
|
9
9
|
import "../../../inputs/reactHookForm/provider/CustomFormProvider.js";
|
|
10
10
|
import * as yup from "yup";
|
|
11
|
-
import "../../../../utils/types/equipmentType.js";
|
|
12
|
-
import "localized-countries";
|
|
13
|
-
import "localized-countries/data/fr";
|
|
14
|
-
import "localized-countries/data/en";
|
|
15
|
-
import "notistack";
|
|
16
11
|
import "../../../../utils/conversionUtils.js";
|
|
12
|
+
import "../../../../utils/types/equipmentType.js";
|
|
17
13
|
import "../../../filter/HeaderFilterForm.js";
|
|
18
14
|
import { getNameElementEditorSchema } from "../name-element-editor/name-element-editor-utils.js";
|
|
19
15
|
const LIMIT_REDUCTIONS_FORM = "limitReductionsForm";
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { UUID } from 'crypto';
|
|
2
|
+
import { ElementType } from '../utils';
|
|
3
|
+
interface UseUniqueNameValidationParams {
|
|
4
|
+
name: string;
|
|
5
|
+
currentName?: string;
|
|
6
|
+
elementType: ElementType;
|
|
7
|
+
activeDirectory?: string;
|
|
8
|
+
elementExists?: (directory: UUID, name: string, type: ElementType) => Promise<boolean>;
|
|
9
|
+
}
|
|
10
|
+
export declare function useUniqueNameValidation({ name, currentName, elementType, activeDirectory, elementExists, }: UseUniqueNameValidationParams): {
|
|
11
|
+
isValidating: Partial<{
|
|
12
|
+
type: string | number;
|
|
13
|
+
message: import('react-hook-form').Message;
|
|
14
|
+
}> | undefined;
|
|
15
|
+
};
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { useCallback, useEffect } from "react";
|
|
2
|
+
import { useFormContext, useController } from "react-hook-form";
|
|
3
|
+
import { FieldConstants } from "../utils/constants/fieldConstants.js";
|
|
4
|
+
import "../utils/conversionUtils.js";
|
|
5
|
+
import "react/jsx-runtime";
|
|
6
|
+
import "@mui/icons-material";
|
|
7
|
+
import "../utils/types/equipmentType.js";
|
|
8
|
+
import "../utils/yupConfig.js";
|
|
9
|
+
import { useDebounce } from "./useDebounce.js";
|
|
10
|
+
import { elementAlreadyExists } from "../services/directory.js";
|
|
11
|
+
function useUniqueNameValidation({
|
|
12
|
+
name,
|
|
13
|
+
currentName = "",
|
|
14
|
+
elementType,
|
|
15
|
+
activeDirectory,
|
|
16
|
+
elementExists = elementAlreadyExists
|
|
17
|
+
}) {
|
|
18
|
+
var _a;
|
|
19
|
+
const {
|
|
20
|
+
setError,
|
|
21
|
+
clearErrors,
|
|
22
|
+
trigger,
|
|
23
|
+
formState: { errors, defaultValues }
|
|
24
|
+
} = useFormContext();
|
|
25
|
+
const {
|
|
26
|
+
field: { value },
|
|
27
|
+
fieldState: { isDirty }
|
|
28
|
+
} = useController({ name });
|
|
29
|
+
const {
|
|
30
|
+
field: { value: selectedDirectory }
|
|
31
|
+
} = useController({
|
|
32
|
+
name: FieldConstants.DIRECTORY
|
|
33
|
+
});
|
|
34
|
+
const defaultFieldValue = defaultValues == null ? void 0 : defaultValues[name];
|
|
35
|
+
const directory = selectedDirectory || activeDirectory;
|
|
36
|
+
const isValidating = (_a = errors.root) == null ? void 0 : _a.isValidating;
|
|
37
|
+
const handleCheckName = useCallback(
|
|
38
|
+
(nameValue) => {
|
|
39
|
+
if (nameValue !== currentName && directory) {
|
|
40
|
+
elementExists(directory, nameValue, elementType).then((alreadyExist) => {
|
|
41
|
+
if (alreadyExist) {
|
|
42
|
+
setError(name, {
|
|
43
|
+
type: "validate",
|
|
44
|
+
message: "nameAlreadyUsed"
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}).catch(() => {
|
|
48
|
+
setError(name, {
|
|
49
|
+
type: "validate",
|
|
50
|
+
message: "nameValidityCheckErrorMsg"
|
|
51
|
+
});
|
|
52
|
+
}).finally(() => {
|
|
53
|
+
clearErrors("root.isValidating");
|
|
54
|
+
trigger("root.isValidating");
|
|
55
|
+
});
|
|
56
|
+
} else {
|
|
57
|
+
trigger("root.isValidating");
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
[currentName, directory, elementType, name, setError, clearErrors, trigger, elementExists]
|
|
61
|
+
);
|
|
62
|
+
const debouncedHandleCheckName = useDebounce(handleCheckName, 700);
|
|
63
|
+
useEffect(() => {
|
|
64
|
+
var _a2, _b;
|
|
65
|
+
const trimmedValue = (_a2 = value == null ? void 0 : value.trim) == null ? void 0 : _a2.call(value);
|
|
66
|
+
if (!trimmedValue) {
|
|
67
|
+
clearErrors("root.isValidating");
|
|
68
|
+
setError(name, {
|
|
69
|
+
type: "validate",
|
|
70
|
+
message: "nameEmpty"
|
|
71
|
+
});
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
if (!isDirty || ((_b = defaultFieldValue == null ? void 0 : defaultFieldValue.trim) == null ? void 0 : _b.call(defaultFieldValue)) === trimmedValue) {
|
|
75
|
+
clearErrors(name);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
setError("root.isValidating", {
|
|
79
|
+
type: "validate",
|
|
80
|
+
message: "cantSubmitWhileValidating"
|
|
81
|
+
});
|
|
82
|
+
if (directory) {
|
|
83
|
+
debouncedHandleCheckName(trimmedValue);
|
|
84
|
+
}
|
|
85
|
+
}, [value, debouncedHandleCheckName, setError, clearErrors, name, isDirty, defaultFieldValue, directory]);
|
|
86
|
+
return {
|
|
87
|
+
isValidating
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
export {
|
|
91
|
+
useUniqueNameValidation
|
|
92
|
+
};
|
|
@@ -54,6 +54,7 @@ const useModificationLabelComputer = () => {
|
|
|
54
54
|
});
|
|
55
55
|
case MODIFICATION_TYPES.CREATE_COUPLING_DEVICE.type:
|
|
56
56
|
case MODIFICATION_TYPES.CREATE_VOLTAGE_LEVEL_TOPOLOGY.type:
|
|
57
|
+
case MODIFICATION_TYPES.CREATE_VOLTAGE_LEVEL_SECTION.type:
|
|
57
58
|
return modificationMetadata.voltageLevelId;
|
|
58
59
|
default:
|
|
59
60
|
return modificationMetadata.equipmentId || "";
|
|
@@ -7,6 +7,10 @@ const filterExpertEn = {
|
|
|
7
7
|
PlannedActivePowerSetPoint: "Planning active power set point",
|
|
8
8
|
minP: "Minimum active power",
|
|
9
9
|
maxP: "Maximum active power",
|
|
10
|
+
p: "Terminal active power",
|
|
11
|
+
q: "Terminal reactive power",
|
|
12
|
+
pAbsolute: "Terminal active power absolute value",
|
|
13
|
+
qAbsolute: "Terminal reactive power absolute value",
|
|
10
14
|
targetP: "Active power target",
|
|
11
15
|
targetV: "Voltage target",
|
|
12
16
|
targetQ: "Reactive power target",
|
|
@@ -69,4 +69,5 @@ export declare const networkModificationsEn: {
|
|
|
69
69
|
'network_modifications.CREATE_COUPLING_DEVICE': string;
|
|
70
70
|
'network_modifications.BALANCES_ADJUSTMENT_MODIFICATION': string;
|
|
71
71
|
'network_modifications.CREATE_VOLTAGE_LEVEL_TOPOLOGY': string;
|
|
72
|
+
'network_modifications.CREATE_VOLTAGE_LEVEL_SECTION': string;
|
|
72
73
|
};
|
|
@@ -62,7 +62,8 @@ const networkModificationsEn = {
|
|
|
62
62
|
"network_modifications.VOLTAGE_LEVEL_TOPOLOGY_MODIFICATION": "Modifying voltage level topology {computedLabel}",
|
|
63
63
|
"network_modifications.CREATE_COUPLING_DEVICE": "Creating a coupling device in voltage level {computedLabel}",
|
|
64
64
|
"network_modifications.BALANCES_ADJUSTMENT_MODIFICATION": "Balances adjustment modification",
|
|
65
|
-
"network_modifications.CREATE_VOLTAGE_LEVEL_TOPOLOGY": "Creating a bus bar in voltage level {computedLabel}"
|
|
65
|
+
"network_modifications.CREATE_VOLTAGE_LEVEL_TOPOLOGY": "Creating a bus bar in voltage level {computedLabel}",
|
|
66
|
+
"network_modifications.CREATE_VOLTAGE_LEVEL_SECTION": "Creating voltage level Busbar sections {computedLabel}"
|
|
66
67
|
};
|
|
67
68
|
export {
|
|
68
69
|
networkModificationsEn
|
|
@@ -7,6 +7,10 @@ const filterExpertFr = {
|
|
|
7
7
|
PlannedActivePowerSetPoint: "Puissance imposée",
|
|
8
8
|
minP: "Puissance active min",
|
|
9
9
|
maxP: "Puissance active max",
|
|
10
|
+
p: "Puissance active du terminal",
|
|
11
|
+
q: "Puissance reactive du terminal",
|
|
12
|
+
pAbsolute: "Puissance active du terminal en valeur absolue",
|
|
13
|
+
qAbsolute: "Puissance reactive du terminal en valeur absolue",
|
|
10
14
|
targetP: "Consigne puissance active",
|
|
11
15
|
targetV: "Consigne tension",
|
|
12
16
|
targetQ: "Consigne puissance réactive",
|
|
@@ -69,4 +69,5 @@ export declare const networkModificationsFr: {
|
|
|
69
69
|
'network_modifications.CREATE_COUPLING_DEVICE': string;
|
|
70
70
|
'network_modifications.BALANCES_ADJUSTMENT_MODIFICATION': string;
|
|
71
71
|
'network_modifications.CREATE_VOLTAGE_LEVEL_TOPOLOGY': string;
|
|
72
|
+
'network_modifications.CREATE_VOLTAGE_LEVEL_SECTION': string;
|
|
72
73
|
};
|
|
@@ -62,7 +62,8 @@ const networkModificationsFr = {
|
|
|
62
62
|
"network_modifications.VOLTAGE_LEVEL_TOPOLOGY_MODIFICATION": "Modification de la topologie du poste {computedLabel}",
|
|
63
63
|
"network_modifications.CREATE_COUPLING_DEVICE": "Création de couplage / omnibus dans le poste {computedLabel}",
|
|
64
64
|
"network_modifications.BALANCES_ADJUSTMENT_MODIFICATION": "Modification d'équilibrage bilan",
|
|
65
|
-
"network_modifications.CREATE_VOLTAGE_LEVEL_TOPOLOGY": "Ajout d'un jeu de barre dans le poste {computedLabel}"
|
|
65
|
+
"network_modifications.CREATE_VOLTAGE_LEVEL_TOPOLOGY": "Ajout d'un jeu de barre dans le poste {computedLabel}",
|
|
66
|
+
"network_modifications.CREATE_VOLTAGE_LEVEL_SECTION": "Création des Busbar sections dans le poste {computedLabel}"
|
|
66
67
|
};
|
|
67
68
|
export {
|
|
68
69
|
networkModificationsFr
|
|
@@ -11,6 +11,10 @@ export declare enum FieldType {
|
|
|
11
11
|
NOMINAL_VOLTAGE = "NOMINAL_VOLTAGE",
|
|
12
12
|
MIN_P = "MIN_P",
|
|
13
13
|
MAX_P = "MAX_P",
|
|
14
|
+
P = "P",
|
|
15
|
+
Q = "Q",
|
|
16
|
+
P_ABSOLUTE = "P_ABSOLUTE",
|
|
17
|
+
Q_ABSOLUTE = "Q_ABSOLUTE",
|
|
14
18
|
TARGET_V = "TARGET_V",
|
|
15
19
|
TARGET_P = "TARGET_P",
|
|
16
20
|
TARGET_Q = "TARGET_Q",
|
|
@@ -5,6 +5,10 @@ var FieldType = /* @__PURE__ */ ((FieldType2) => {
|
|
|
5
5
|
FieldType2["NOMINAL_VOLTAGE"] = "NOMINAL_VOLTAGE";
|
|
6
6
|
FieldType2["MIN_P"] = "MIN_P";
|
|
7
7
|
FieldType2["MAX_P"] = "MAX_P";
|
|
8
|
+
FieldType2["P"] = "P";
|
|
9
|
+
FieldType2["Q"] = "Q";
|
|
10
|
+
FieldType2["P_ABSOLUTE"] = "P_ABSOLUTE";
|
|
11
|
+
FieldType2["Q_ABSOLUTE"] = "Q_ABSOLUTE";
|
|
8
12
|
FieldType2["TARGET_V"] = "TARGET_V";
|
|
9
13
|
FieldType2["TARGET_P"] = "TARGET_P";
|
|
10
14
|
FieldType2["TARGET_Q"] = "TARGET_Q";
|
|
@@ -53,7 +53,8 @@ export declare enum ModificationType {
|
|
|
53
53
|
VOLTAGE_LEVEL_TOPOLOGY_MODIFICATION = "VOLTAGE_LEVEL_TOPOLOGY_MODIFICATION",
|
|
54
54
|
CREATE_COUPLING_DEVICE = "CREATE_COUPLING_DEVICE",
|
|
55
55
|
BALANCES_ADJUSTMENT = "BALANCES_ADJUSTMENT_MODIFICATION",
|
|
56
|
-
CREATE_VOLTAGE_LEVEL_TOPOLOGY = "CREATE_VOLTAGE_LEVEL_TOPOLOGY"
|
|
56
|
+
CREATE_VOLTAGE_LEVEL_TOPOLOGY = "CREATE_VOLTAGE_LEVEL_TOPOLOGY",
|
|
57
|
+
CREATE_VOLTAGE_LEVEL_SECTION = "CREATE_VOLTAGE_LEVEL_SECTION"
|
|
57
58
|
}
|
|
58
59
|
export declare const MODIFICATION_TYPES: {
|
|
59
60
|
GROOVY_SCRIPT: {
|
|
@@ -206,4 +207,7 @@ export declare const MODIFICATION_TYPES: {
|
|
|
206
207
|
CREATE_VOLTAGE_LEVEL_TOPOLOGY: {
|
|
207
208
|
type: ModificationType;
|
|
208
209
|
};
|
|
210
|
+
CREATE_VOLTAGE_LEVEL_SECTION: {
|
|
211
|
+
type: ModificationType;
|
|
212
|
+
};
|
|
209
213
|
};
|
|
@@ -48,6 +48,7 @@ var ModificationType = /* @__PURE__ */ ((ModificationType2) => {
|
|
|
48
48
|
ModificationType2["CREATE_COUPLING_DEVICE"] = "CREATE_COUPLING_DEVICE";
|
|
49
49
|
ModificationType2["BALANCES_ADJUSTMENT"] = "BALANCES_ADJUSTMENT_MODIFICATION";
|
|
50
50
|
ModificationType2["CREATE_VOLTAGE_LEVEL_TOPOLOGY"] = "CREATE_VOLTAGE_LEVEL_TOPOLOGY";
|
|
51
|
+
ModificationType2["CREATE_VOLTAGE_LEVEL_SECTION"] = "CREATE_VOLTAGE_LEVEL_SECTION";
|
|
51
52
|
return ModificationType2;
|
|
52
53
|
})(ModificationType || {});
|
|
53
54
|
const MODIFICATION_TYPES = {
|
|
@@ -248,6 +249,10 @@ const MODIFICATION_TYPES = {
|
|
|
248
249
|
CREATE_VOLTAGE_LEVEL_TOPOLOGY: {
|
|
249
250
|
type: "CREATE_VOLTAGE_LEVEL_TOPOLOGY"
|
|
250
251
|
/* CREATE_VOLTAGE_LEVEL_TOPOLOGY */
|
|
252
|
+
},
|
|
253
|
+
CREATE_VOLTAGE_LEVEL_SECTION: {
|
|
254
|
+
type: "CREATE_VOLTAGE_LEVEL_SECTION"
|
|
255
|
+
/* CREATE_VOLTAGE_LEVEL_SECTION */
|
|
251
256
|
}
|
|
252
257
|
};
|
|
253
258
|
export {
|