@gridsuite/commons-ui 0.85.1 → 0.86.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 (32) hide show
  1. package/dist/components/contingencyList/criteriaBased/CriteriaBasedForm.js +1 -0
  2. package/dist/components/contingencyList/criteriaBased/criteriaBasedUtils.d.ts +4 -4
  3. package/dist/components/dialogs/elementCreationDialog/ElementCreationDialog.d.ts +29 -0
  4. package/dist/components/dialogs/elementCreationDialog/ElementCreationDialog.js +208 -0
  5. package/dist/components/dialogs/elementCreationDialog/index.d.ts +7 -0
  6. package/dist/components/dialogs/elementCreationDialog/index.js +4 -0
  7. package/dist/components/dialogs/index.d.ts +1 -0
  8. package/dist/components/dialogs/index.js +2 -0
  9. package/dist/components/filter/FilterCreationDialog.d.ts +1 -3
  10. package/dist/components/filter/FilterCreationDialog.js +0 -2
  11. package/dist/components/filter/FilterForm.d.ts +1 -1
  12. package/dist/components/filter/FilterForm.js +2 -3
  13. package/dist/components/filter/HeaderFilterForm.d.ts +1 -3
  14. package/dist/components/filter/HeaderFilterForm.js +1 -3
  15. package/dist/components/filter/expert/ExpertFilterEditionDialog.d.ts +1 -1
  16. package/dist/components/filter/expert/ExpertFilterEditionDialog.js +1 -2
  17. package/dist/components/filter/expert/ExpertFilterForm.js +1 -0
  18. package/dist/components/filter/explicitNaming/ExplicitNamingFilterEditionDialog.d.ts +1 -1
  19. package/dist/components/filter/explicitNaming/ExplicitNamingFilterEditionDialog.js +1 -2
  20. package/dist/components/filter/explicitNaming/ExplicitNamingFilterForm.js +1 -0
  21. package/dist/components/filter/filter.type.d.ts +1 -2
  22. package/dist/components/index.js +2 -0
  23. package/dist/components/inputs/reactHookForm/text/UniqueNameInput.d.ts +2 -3
  24. package/dist/components/inputs/reactHookForm/text/UniqueNameInput.js +11 -4
  25. package/dist/index.js +4 -1
  26. package/dist/services/directory.d.ts +2 -1
  27. package/dist/services/directory.js +11 -1
  28. package/dist/services/index.js +2 -1
  29. package/dist/utils/constants/fieldConstants.d.ts +31 -29
  30. package/dist/utils/constants/fieldConstants.js +31 -29
  31. package/dist/utils/types/elementType.d.ts +6 -3
  32. package/package.json +1 -1
@@ -8,6 +8,7 @@ import { InputWithPopupConfirmation } from "../../inputs/reactHookForm/selectInp
8
8
  import { useSnackMessage } from "../../../hooks/useSnackMessage.js";
9
9
  import { unscrollableDialogStyles } from "../../dialogs/customMuiDialog/CustomMuiDialog.js";
10
10
  import "../../dialogs/descriptionModificationDialog/DescriptionModificationDialog.js";
11
+ import "../../dialogs/elementCreationDialog/ElementCreationDialog.js";
11
12
  import "react-intl";
12
13
  import "@mui/icons-material";
13
14
  import "../../treeViewFinder/TreeViewFinder.js";
@@ -16,24 +16,24 @@ export type CriteriaBasedData = {
16
16
  export declare function getCriteriaBasedSchema(extraFields?: Record<string, yup.AnyObject | null>): {
17
17
  readonly criteriaBased: ObjectSchema<{
18
18
  nominalVoltage3: {
19
+ type: string;
19
20
  value1: number | null;
20
21
  value2: number | null;
21
- type: string;
22
22
  };
23
23
  nominalVoltage2: {
24
+ type: string;
24
25
  value1: number | null;
25
26
  value2: number | null;
26
- type: string;
27
27
  };
28
28
  nominalVoltage1: {
29
+ type: string;
29
30
  value1: number | null;
30
31
  value2: number | null;
31
- type: string;
32
32
  };
33
33
  nominalVoltage: {
34
+ type: string;
34
35
  value1: number | null;
35
36
  value2: number | null;
36
- type: string;
37
37
  };
38
38
  countries: string[] | undefined;
39
39
  countries1: string[] | undefined;
@@ -0,0 +1,29 @@
1
+ import { UUID } from 'crypto';
2
+ import { ElementAttributes, ElementType, FieldConstants } from '../../../utils';
3
+
4
+ interface FormData {
5
+ [FieldConstants.NAME]: string;
6
+ [FieldConstants.DESCRIPTION]: string;
7
+ }
8
+ export interface IElementCreationDialog extends FormData {
9
+ [FieldConstants.FOLDER_NAME]: string;
10
+ [FieldConstants.FOLDER_ID]: UUID;
11
+ }
12
+ export type ElementCreationDialogProps = {
13
+ open: boolean;
14
+ onSave: (data: IElementCreationDialog) => void;
15
+ onClose: () => void;
16
+ type: ElementType;
17
+ titleId: string;
18
+ prefixIdForGeneratedName?: string;
19
+ } & ({
20
+ /** starting directory can be the same as a given study */
21
+ studyUuid: UUID;
22
+ initDirectory?: never;
23
+ } | {
24
+ studyUuid?: never;
25
+ /** or directly a given directory */
26
+ initDirectory: ElementAttributes;
27
+ });
28
+ export declare function ElementCreationDialog({ open, onSave, onClose, type, titleId, prefixIdForGeneratedName, studyUuid, initDirectory, }: Readonly<ElementCreationDialogProps>): import("react/jsx-runtime").JSX.Element;
29
+ export {};
@@ -0,0 +1,208 @@
1
+ import { jsxs, jsx } from "react/jsx-runtime";
2
+ import { useIntl, FormattedMessage } from "react-intl";
3
+ import { useState, useCallback, useEffect } from "react";
4
+ import { Grid, Button, Typography, Box, CircularProgress } from "@mui/material";
5
+ import { useForm } from "react-hook-form";
6
+ import { yupResolver } from "@hookform/resolvers/yup";
7
+ import "../../../utils/yupConfig.js";
8
+ import { FieldConstants } from "../../../utils/constants/fieldConstants.js";
9
+ import { MAX_CHAR_DESCRIPTION } from "../../../utils/constants/uiConstants.js";
10
+ import "../../../utils/conversionUtils.js";
11
+ import "@mui/icons-material";
12
+ import { ElementType } from "../../../utils/types/elementType.js";
13
+ import { CustomMuiDialog } from "../customMuiDialog/CustomMuiDialog.js";
14
+ import "@mui/icons-material/Folder";
15
+ import "../../inputs/reactHookForm/provider/CustomFormProvider.js";
16
+ import * as yup from "yup";
17
+ import { useSnackMessage } from "../../../hooks/useSnackMessage.js";
18
+ import "../../overflowableText/OverflowableText.js";
19
+ import { DirectoryItemSelector } from "../../directoryItemSelector/DirectoryItemSelector.js";
20
+ import { fetchDirectoryElementPath } from "../../../services/directory.js";
21
+ import "../../inputs/reactHookForm/agGridTable/BottomRightButtons.js";
22
+ import "ag-grid-community/styles/ag-grid.css";
23
+ import "ag-grid-community/styles/ag-theme-alpine.css";
24
+ import "../../customAGGrid/customAggrid.js";
25
+ import "ag-grid-community";
26
+ import "@mui/material/Dialog";
27
+ import "@mui/material/DialogTitle";
28
+ import "@mui/material/DialogContent";
29
+ import "@mui/material/DialogActions";
30
+ import "react-papaparse";
31
+ import "@mui/material/Button";
32
+ import "@mui/material/Grid";
33
+ import "react-csv-downloader";
34
+ import "@mui/material/Alert";
35
+ import "@mui/material/styles";
36
+ import "../../inputs/reactHookForm/numbers/RangeInput.js";
37
+ import "localized-countries";
38
+ import "localized-countries/data/fr";
39
+ import "localized-countries/data/en";
40
+ import { DescriptionField } from "../../inputs/reactHookForm/text/DescriptionField.js";
41
+ import { UniqueNameInput } from "../../inputs/reactHookForm/text/UniqueNameInput.js";
42
+ import "@mui/icons-material/ControlPoint";
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 "@mui/material/IconButton";
49
+ import "@mui/icons-material/Delete";
50
+ import "react-querybuilder";
51
+ import "@mui/material/Box";
52
+ const schema = yup.object().shape({
53
+ [FieldConstants.NAME]: yup.string().trim().required(),
54
+ [FieldConstants.DESCRIPTION]: yup.string().optional().max(MAX_CHAR_DESCRIPTION, "descriptionLimitError")
55
+ }).required();
56
+ const emptyFormData = {
57
+ [FieldConstants.NAME]: "",
58
+ [FieldConstants.DESCRIPTION]: ""
59
+ };
60
+ function ElementCreationDialog({
61
+ open,
62
+ onSave,
63
+ onClose,
64
+ type,
65
+ titleId,
66
+ prefixIdForGeneratedName,
67
+ studyUuid,
68
+ initDirectory
69
+ }) {
70
+ const intl = useIntl();
71
+ const { snackError } = useSnackMessage();
72
+ const [directorySelectorOpen, setDirectorySelectorOpen] = useState(false);
73
+ const [destinationFolder, setDestinationFolder] = useState();
74
+ const formMethods = useForm({
75
+ defaultValues: emptyFormData,
76
+ resolver: yupResolver(schema)
77
+ });
78
+ const {
79
+ reset,
80
+ formState: { errors }
81
+ } = formMethods;
82
+ const disableSave = Object.keys(errors).length > 0;
83
+ const onCancel = useCallback(() => {
84
+ reset(emptyFormData);
85
+ onClose();
86
+ }, [onClose, reset]);
87
+ useEffect(() => {
88
+ if (prefixIdForGeneratedName) {
89
+ const getCurrentDateTime = () => (/* @__PURE__ */ new Date()).toISOString();
90
+ const formattedMessage = intl.formatMessage({
91
+ id: prefixIdForGeneratedName
92
+ });
93
+ const dateTime = getCurrentDateTime();
94
+ reset(
95
+ {
96
+ ...emptyFormData,
97
+ [FieldConstants.NAME]: `${formattedMessage}-${dateTime}`
98
+ },
99
+ { keepDefaultValues: true }
100
+ );
101
+ }
102
+ }, [prefixIdForGeneratedName, intl, reset]);
103
+ useEffect(() => {
104
+ if (open && studyUuid) {
105
+ fetchDirectoryElementPath(studyUuid).then((res) => {
106
+ if (!res || res.length < 2) {
107
+ snackError({
108
+ messageTxt: "unknown study directory",
109
+ headerId: "studyDirectoryFetchingError"
110
+ });
111
+ return;
112
+ }
113
+ const parentFolderIndex = res.length - 2;
114
+ const { elementUuid, elementName } = res[parentFolderIndex];
115
+ setDestinationFolder({
116
+ id: elementUuid,
117
+ name: elementName
118
+ });
119
+ });
120
+ }
121
+ }, [studyUuid, open, snackError]);
122
+ useEffect(() => {
123
+ if (open && initDirectory) {
124
+ setDestinationFolder({
125
+ id: initDirectory.elementUuid,
126
+ name: initDirectory.elementName
127
+ });
128
+ }
129
+ }, [initDirectory, open]);
130
+ const handleChangeFolder = useCallback(() => {
131
+ setDirectorySelectorOpen(true);
132
+ }, []);
133
+ const setSelectedFolder = useCallback(
134
+ (folder) => {
135
+ if ((folder == null ? void 0 : folder.length) > 0 && folder[0].id !== (destinationFolder == null ? void 0 : destinationFolder.id)) {
136
+ const { id, name } = folder[0];
137
+ setDestinationFolder({ id, name });
138
+ }
139
+ setDirectorySelectorOpen(false);
140
+ },
141
+ [destinationFolder == null ? void 0 : destinationFolder.id]
142
+ );
143
+ const onSubmit = useCallback(
144
+ (values) => {
145
+ if (destinationFolder) {
146
+ const creationData = {
147
+ [FieldConstants.NAME]: values.name,
148
+ [FieldConstants.DESCRIPTION]: values.description ?? "",
149
+ [FieldConstants.FOLDER_NAME]: destinationFolder.name ?? "",
150
+ [FieldConstants.FOLDER_ID]: destinationFolder.id
151
+ };
152
+ onSave(creationData);
153
+ }
154
+ },
155
+ [onSave, destinationFolder]
156
+ );
157
+ const folderChooser = /* @__PURE__ */ jsxs(Grid, { container: true, item: true, children: [
158
+ /* @__PURE__ */ jsx(Grid, { item: true, children: /* @__PURE__ */ jsx(Button, { onClick: handleChangeFolder, variant: "contained", size: "small", children: /* @__PURE__ */ jsx(FormattedMessage, { id: "showSelectDirectoryDialog" }) }) }),
159
+ /* @__PURE__ */ jsx(Typography, { m: 1, component: "span", children: /* @__PURE__ */ jsx(Box, { fontWeight: "fontWeightBold", children: destinationFolder ? destinationFolder.name : /* @__PURE__ */ jsx(CircularProgress, {}) }) })
160
+ ] });
161
+ return /* @__PURE__ */ jsxs(
162
+ CustomMuiDialog,
163
+ {
164
+ open,
165
+ onClose: onCancel,
166
+ titleId,
167
+ onSave: onSubmit,
168
+ disabledSave: disableSave,
169
+ formSchema: schema,
170
+ formMethods,
171
+ children: [
172
+ /* @__PURE__ */ jsxs(Grid, { container: true, spacing: 2, marginTop: "auto", direction: "column", children: [
173
+ /* @__PURE__ */ jsx(Grid, { item: true, children: /* @__PURE__ */ jsx(
174
+ UniqueNameInput,
175
+ {
176
+ name: FieldConstants.NAME,
177
+ label: "name",
178
+ elementType: type,
179
+ activeDirectory: destinationFolder == null ? void 0 : destinationFolder.id,
180
+ autoFocus: true
181
+ }
182
+ ) }),
183
+ /* @__PURE__ */ jsx(Grid, { item: true, children: /* @__PURE__ */ jsx(DescriptionField, {}) }),
184
+ folderChooser
185
+ ] }),
186
+ /* @__PURE__ */ jsx(
187
+ DirectoryItemSelector,
188
+ {
189
+ open: directorySelectorOpen,
190
+ onClose: setSelectedFolder,
191
+ types: [ElementType.DIRECTORY],
192
+ onlyLeaves: false,
193
+ multiSelect: false,
194
+ validationButtonText: intl.formatMessage({
195
+ id: "validate"
196
+ }),
197
+ title: intl.formatMessage({
198
+ id: "showSelectDirectoryDialog"
199
+ })
200
+ }
201
+ )
202
+ ]
203
+ }
204
+ );
205
+ }
206
+ export {
207
+ ElementCreationDialog
208
+ };
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Copyright (c) 2024, 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 './ElementCreationDialog';
@@ -0,0 +1,4 @@
1
+ import { ElementCreationDialog } from "./ElementCreationDialog.js";
2
+ export {
3
+ ElementCreationDialog
4
+ };
@@ -6,5 +6,6 @@
6
6
  */
7
7
  export * from './customMuiDialog/CustomMuiDialog';
8
8
  export * from './descriptionModificationDialog';
9
+ export * from './elementCreationDialog';
9
10
  export * from './modifyElementSelection';
10
11
  export * from './popupConfirmationDialog';
@@ -1,10 +1,12 @@
1
1
  import { CustomMuiDialog, unscrollableDialogStyles } from "./customMuiDialog/CustomMuiDialog.js";
2
2
  import { DescriptionModificationDialog } from "./descriptionModificationDialog/DescriptionModificationDialog.js";
3
+ import { ElementCreationDialog } from "./elementCreationDialog/ElementCreationDialog.js";
3
4
  import { ModifyElementSelection } from "./modifyElementSelection/ModifyElementSelection.js";
4
5
  import { PopupConfirmationDialog } from "./popupConfirmationDialog/PopupConfirmationDialog.js";
5
6
  export {
6
7
  CustomMuiDialog,
7
8
  DescriptionModificationDialog,
9
+ ElementCreationDialog,
8
10
  ModifyElementSelection,
9
11
  PopupConfirmationDialog,
10
12
  unscrollableDialogStyles
@@ -1,15 +1,13 @@
1
1
  import { UUID } from 'crypto';
2
- import { ElementExistsType } from '../../utils/types/elementType';
3
2
 
4
3
  export interface FilterCreationDialogProps {
5
4
  open: boolean;
6
5
  onClose: () => void;
7
6
  activeDirectory?: UUID;
8
- elementExists?: ElementExistsType;
9
7
  language?: string;
10
8
  sourceFilterForExplicitNamingConversion?: {
11
9
  id: UUID;
12
10
  equipmentType: string;
13
11
  };
14
12
  }
15
- export declare function FilterCreationDialog({ open, onClose, activeDirectory, elementExists, language, sourceFilterForExplicitNamingConversion, }: FilterCreationDialogProps): import("react/jsx-runtime").JSX.Element;
13
+ export declare function FilterCreationDialog({ open, onClose, activeDirectory, language, sourceFilterForExplicitNamingConversion, }: FilterCreationDialogProps): import("react/jsx-runtime").JSX.Element;
@@ -35,7 +35,6 @@ function FilterCreationDialog({
35
35
  open,
36
36
  onClose,
37
37
  activeDirectory,
38
- elementExists,
39
38
  language,
40
39
  sourceFilterForExplicitNamingConversion = void 0
41
40
  }) {
@@ -106,7 +105,6 @@ function FilterCreationDialog({
106
105
  {
107
106
  creation: true,
108
107
  activeDirectory,
109
- elementExists,
110
108
  sourceFilterForExplicitNamingConversion
111
109
  }
112
110
  )
@@ -1,3 +1,3 @@
1
1
  import { FilterFormProps } from './HeaderFilterForm';
2
2
 
3
- export declare function FilterForm({ sourceFilterForExplicitNamingConversion, creation, activeDirectory, elementExists, }: Readonly<FilterFormProps>): import("react/jsx-runtime").JSX.Element;
3
+ export declare function FilterForm({ sourceFilterForExplicitNamingConversion, creation, activeDirectory, }: Readonly<FilterFormProps>): import("react/jsx-runtime").JSX.Element;
@@ -9,6 +9,7 @@ import { ExpertFilterForm } from "./expert/ExpertFilterForm.js";
9
9
  import { FilterType } from "./constants/FilterConstants.js";
10
10
  import { unscrollableDialogStyles } from "../dialogs/customMuiDialog/CustomMuiDialog.js";
11
11
  import "../dialogs/descriptionModificationDialog/DescriptionModificationDialog.js";
12
+ import "../dialogs/elementCreationDialog/ElementCreationDialog.js";
12
13
  import "react-intl";
13
14
  import "@mui/icons-material";
14
15
  import "../treeViewFinder/TreeViewFinder.js";
@@ -22,8 +23,7 @@ import "@mui/material/styles";
22
23
  function FilterForm({
23
24
  sourceFilterForExplicitNamingConversion,
24
25
  creation,
25
- activeDirectory,
26
- elementExists
26
+ activeDirectory
27
27
  }) {
28
28
  const { setValue } = useFormContext();
29
29
  const filterType = useWatch({ name: FieldConstants.FILTER_TYPE });
@@ -41,7 +41,6 @@ function FilterForm({
41
41
  {
42
42
  creation,
43
43
  activeDirectory,
44
- elementExists,
45
44
  sourceFilterForExplicitNamingConversion,
46
45
  handleFilterTypeChange
47
46
  }
@@ -1,11 +1,9 @@
1
1
  import { UUID } from 'crypto';
2
- import { ElementExistsType } from '../../utils/types/elementType';
3
2
  import { default as yup } from '../../utils/yupConfig';
4
3
 
5
4
  export interface FilterFormProps {
6
5
  creation?: boolean;
7
6
  activeDirectory?: UUID;
8
- elementExists?: ElementExistsType;
9
7
  sourceFilterForExplicitNamingConversion?: {
10
8
  id: UUID;
11
9
  equipmentType: string;
@@ -18,4 +16,4 @@ export declare const HeaderFilterSchema: {
18
16
  equipmentType: yup.StringSchema<string, yup.AnyObject, undefined, "">;
19
17
  description: yup.StringSchema<string | undefined, yup.AnyObject, undefined, "">;
20
18
  };
21
- export declare function HeaderFilterForm({ sourceFilterForExplicitNamingConversion, creation, activeDirectory, elementExists, handleFilterTypeChange, }: Readonly<FilterFormProps>): import("react/jsx-runtime").JSX.Element;
19
+ export declare function HeaderFilterForm({ sourceFilterForExplicitNamingConversion, creation, activeDirectory, handleFilterTypeChange, }: Readonly<FilterFormProps>): import("react/jsx-runtime").JSX.Element;
@@ -19,7 +19,6 @@ function HeaderFilterForm({
19
19
  sourceFilterForExplicitNamingConversion,
20
20
  creation,
21
21
  activeDirectory,
22
- elementExists,
23
22
  handleFilterTypeChange
24
23
  }) {
25
24
  const filterTypes = Object.values(FilterType);
@@ -31,8 +30,7 @@ function HeaderFilterForm({
31
30
  label: "nameProperty",
32
31
  elementType: ElementType.FILTER,
33
32
  autoFocus: creation,
34
- activeDirectory,
35
- elementExists
33
+ activeDirectory
36
34
  }
37
35
  ) }),
38
36
  /* @__PURE__ */ jsxs(Fragment, { children: [
@@ -1,3 +1,3 @@
1
1
  import { FilterEditionProps } from '../filter.type';
2
2
 
3
- export declare function ExpertFilterEditionDialog({ id, name, titleId, open, onClose, broadcastChannel, itemSelectionForCopy, getFilterById, setItemSelectionForCopy, activeDirectory, elementExists, language, description, }: Readonly<FilterEditionProps>): import("react/jsx-runtime").JSX.Element;
3
+ export declare function ExpertFilterEditionDialog({ id, name, titleId, open, onClose, broadcastChannel, itemSelectionForCopy, getFilterById, setItemSelectionForCopy, activeDirectory, language, description, }: Readonly<FilterEditionProps>): import("react/jsx-runtime").JSX.Element;
@@ -31,7 +31,6 @@ function ExpertFilterEditionDialog({
31
31
  getFilterById,
32
32
  setItemSelectionForCopy,
33
33
  activeDirectory,
34
- elementExists,
35
34
  language,
36
35
  description
37
36
  }) {
@@ -109,7 +108,7 @@ function ExpertFilterEditionDialog({
109
108
  isDataFetching: dataFetchStatus === FetchStatus.FETCHING,
110
109
  language,
111
110
  unscrollableFullHeight: true,
112
- children: isDataReady && /* @__PURE__ */ jsx(FilterForm, { activeDirectory, elementExists })
111
+ children: isDataReady && /* @__PURE__ */ jsx(FilterForm, { activeDirectory })
113
112
  }
114
113
  );
115
114
  }
@@ -14,6 +14,7 @@ import { FilterType } from "../constants/FilterConstants.js";
14
14
  import { CustomReactQueryBuilder } from "../../inputs/reactQueryBuilder/CustomReactQueryBuilder.js";
15
15
  import { unscrollableDialogStyles } from "../../dialogs/customMuiDialog/CustomMuiDialog.js";
16
16
  import "../../dialogs/descriptionModificationDialog/DescriptionModificationDialog.js";
17
+ import "../../dialogs/elementCreationDialog/ElementCreationDialog.js";
17
18
  import "react-intl";
18
19
  import "@mui/icons-material";
19
20
  import "../../treeViewFinder/TreeViewFinder.js";
@@ -1,3 +1,3 @@
1
1
  import { FilterEditionProps } from '../filter.type';
2
2
 
3
- export declare function ExplicitNamingFilterEditionDialog({ id, name, titleId, open, onClose, broadcastChannel, itemSelectionForCopy, setItemSelectionForCopy, getFilterById, activeDirectory, elementExists, language, description, }: Readonly<FilterEditionProps>): import("react/jsx-runtime").JSX.Element;
3
+ export declare function ExplicitNamingFilterEditionDialog({ id, name, titleId, open, onClose, broadcastChannel, itemSelectionForCopy, setItemSelectionForCopy, getFilterById, activeDirectory, language, description, }: Readonly<FilterEditionProps>): import("react/jsx-runtime").JSX.Element;
@@ -31,7 +31,6 @@ function ExplicitNamingFilterEditionDialog({
31
31
  setItemSelectionForCopy,
32
32
  getFilterById,
33
33
  activeDirectory,
34
- elementExists,
35
34
  language,
36
35
  description
37
36
  }) {
@@ -110,7 +109,7 @@ function ExplicitNamingFilterEditionDialog({
110
109
  isDataFetching: dataFetchStatus === FetchStatus.FETCHING,
111
110
  language,
112
111
  unscrollableFullHeight: true,
113
- children: isDataReady && /* @__PURE__ */ jsx(FilterForm, { activeDirectory, elementExists })
112
+ children: isDataReady && /* @__PURE__ */ jsx(FilterForm, { activeDirectory })
114
113
  }
115
114
  );
116
115
  }
@@ -20,6 +20,7 @@ import { ModifyElementSelection } from "../../dialogs/modifyElementSelection/Mod
20
20
  import { exportFilter } from "../../../services/study.js";
21
21
  import { unscrollableDialogStyles } from "../../dialogs/customMuiDialog/CustomMuiDialog.js";
22
22
  import "../../dialogs/descriptionModificationDialog/DescriptionModificationDialog.js";
23
+ import "../../dialogs/elementCreationDialog/ElementCreationDialog.js";
23
24
  import "@mui/material/Dialog";
24
25
  import "@mui/material/DialogTitle";
25
26
  import "@mui/material/DialogContent";
@@ -1,5 +1,5 @@
1
1
  import { UUID } from 'crypto';
2
- import { ElementExistsType, FieldConstants } from '../../utils';
2
+ import { FieldConstants } from '../../utils';
3
3
  import { RuleGroupTypeExport } from './expert/expertFilter.type';
4
4
  import { EXPERT_FILTER_QUERY } from './expert/expertFilterConstants';
5
5
  import { FILTER_EQUIPMENTS_ATTRIBUTES } from './explicitNaming/ExplicitNamingFilterConstants';
@@ -34,7 +34,6 @@ export interface FilterEditionProps {
34
34
  [FILTER_EQUIPMENTS_ATTRIBUTES]?: EquipmentsFilter[];
35
35
  }>;
36
36
  activeDirectory?: UUID;
37
- elementExists?: ElementExistsType;
38
37
  language?: string;
39
38
  description?: string;
40
39
  }
@@ -15,6 +15,7 @@ import { CUSTOM_AGGRID_THEME, styles } from "./customAGGrid/customAggrid.style.j
15
15
  import { CustomAGGrid } from "./customAGGrid/customAggrid.js";
16
16
  import { CustomMuiDialog, unscrollableDialogStyles } from "./dialogs/customMuiDialog/CustomMuiDialog.js";
17
17
  import { DescriptionModificationDialog } from "./dialogs/descriptionModificationDialog/DescriptionModificationDialog.js";
18
+ import { ElementCreationDialog } from "./dialogs/elementCreationDialog/ElementCreationDialog.js";
18
19
  import { ModifyElementSelection } from "./dialogs/modifyElementSelection/ModifyElementSelection.js";
19
20
  import { PopupConfirmationDialog } from "./dialogs/popupConfirmationDialog/PopupConfirmationDialog.js";
20
21
  import { DirectoryItemSelector } from "./directoryItemSelector/DirectoryItemSelector.js";
@@ -142,6 +143,7 @@ export {
142
143
  EXPERT_FILTER_EQUIPMENTS,
143
144
  EXPERT_FILTER_FIELDS,
144
145
  EXPERT_FILTER_QUERY,
146
+ ElementCreationDialog,
145
147
  ElementSearchDialog,
146
148
  ElementSearchInput,
147
149
  ElementValueEditor,
@@ -1,6 +1,6 @@
1
1
  import { TextFieldProps } from '@mui/material';
2
2
  import { UUID } from 'crypto';
3
- import { ElementExistsType, ElementType } from '../../../../utils/types/elementType';
3
+ import { ElementType } from '../../../../utils';
4
4
 
5
5
  export interface UniqueNameInputProps {
6
6
  name: string;
@@ -10,9 +10,8 @@ export interface UniqueNameInputProps {
10
10
  onManualChangeCallback?: () => void;
11
11
  formProps?: Omit<TextFieldProps, 'value' | 'onChange' | 'name' | 'label' | 'inputRef' | 'inputProps' | 'InputProps'>;
12
12
  activeDirectory?: UUID;
13
- elementExists?: ElementExistsType;
14
13
  }
15
14
  /**
16
15
  * Input component that constantly check if the field's value is available or not
17
16
  */
18
- export declare function UniqueNameInput({ name, label, elementType, autoFocus, onManualChangeCallback, formProps, activeDirectory, elementExists, }: Readonly<UniqueNameInputProps>): import("react/jsx-runtime").JSX.Element;
17
+ export declare function UniqueNameInput({ name, label, elementType, autoFocus, onManualChangeCallback, formProps, activeDirectory, }: Readonly<UniqueNameInputProps>): import("react/jsx-runtime").JSX.Element;
@@ -6,8 +6,16 @@ import CheckIcon from "@mui/icons-material/Check";
6
6
  import { useController, useFormContext } from "react-hook-form";
7
7
  import CircularProgress from "@mui/material/CircularProgress";
8
8
  import TextField from "@mui/material/TextField";
9
+ import { elementAlreadyExists } from "../../../../services/directory.js";
9
10
  import { useDebounce } from "../../../../hooks/useDebounce.js";
11
+ import "localized-countries";
12
+ import "localized-countries/data/fr";
13
+ import "localized-countries/data/en";
14
+ import "notistack";
10
15
  import { FieldConstants } from "../../../../utils/constants/fieldConstants.js";
16
+ import "../../../../utils/conversionUtils.js";
17
+ import "@mui/icons-material";
18
+ import "../../../../utils/yupConfig.js";
11
19
  function UniqueNameInput({
12
20
  name,
13
21
  label,
@@ -15,8 +23,7 @@ function UniqueNameInput({
15
23
  autoFocus,
16
24
  onManualChangeCallback,
17
25
  formProps,
18
- activeDirectory,
19
- elementExists
26
+ activeDirectory
20
27
  }) {
21
28
  var _a;
22
29
  const {
@@ -41,7 +48,7 @@ function UniqueNameInput({
41
48
  const handleCheckName = useCallback(
42
49
  (nameValue) => {
43
50
  if (nameValue) {
44
- elementExists == null ? void 0 : elementExists(directory, nameValue, elementType).then((alreadyExist) => {
51
+ elementAlreadyExists(directory, nameValue, elementType).then((alreadyExist) => {
45
52
  if (alreadyExist) {
46
53
  setError(name, {
47
54
  type: "validate",
@@ -60,7 +67,7 @@ function UniqueNameInput({
60
67
  });
61
68
  }
62
69
  },
63
- [setError, clearErrors, name, elementType, elementExists, directory, trigger]
70
+ [setError, clearErrors, name, elementType, directory, trigger]
64
71
  );
65
72
  const debouncedHandleCheckName = useDebounce(handleCheckName, 700);
66
73
  useEffect(() => {
package/dist/index.js CHANGED
@@ -16,6 +16,7 @@ import { CUSTOM_AGGRID_THEME, styles } from "./components/customAGGrid/customAgg
16
16
  import { CustomAGGrid } from "./components/customAGGrid/customAggrid.js";
17
17
  import { CustomMuiDialog, unscrollableDialogStyles } from "./components/dialogs/customMuiDialog/CustomMuiDialog.js";
18
18
  import { DescriptionModificationDialog } from "./components/dialogs/descriptionModificationDialog/DescriptionModificationDialog.js";
19
+ import { ElementCreationDialog } from "./components/dialogs/elementCreationDialog/ElementCreationDialog.js";
19
20
  import { ModifyElementSelection } from "./components/dialogs/modifyElementSelection/ModifyElementSelection.js";
20
21
  import { PopupConfirmationDialog } from "./components/dialogs/popupConfirmationDialog/PopupConfirmationDialog.js";
21
22
  import { DirectoryItemSelector } from "./components/directoryItemSelector/DirectoryItemSelector.js";
@@ -120,7 +121,7 @@ import { getUserToken, setCommonStore } from "./redux/commonStore.js";
120
121
  import { backendFetch, backendFetchJson, catchErrorHandler, getRequestParamFromList } from "./services/utils.js";
121
122
  import { createFilter, fetchElementsInfos, saveFilter } from "./services/explore.js";
122
123
  import { fetchAppsMetadata, fetchDefaultCountry, fetchEnv, fetchFavoriteAndDefaultCountries, fetchStudyMetadata, isStudyMetadata } from "./services/appsMetadata.js";
123
- import { fetchDirectoryContent, fetchDirectoryElementPath, fetchRootFolders } from "./services/directory.js";
124
+ import { elementAlreadyExists, fetchDirectoryContent, fetchDirectoryElementPath, fetchRootFolders } from "./services/directory.js";
124
125
  import { exportFilter } from "./services/study.js";
125
126
  import { equalsArray } from "./utils/algos.js";
126
127
  import { DARK_THEME, LANG_ENGLISH, LANG_FRENCH, LANG_SYSTEM, LIGHT_THEME } from "./utils/constants/browserConstants.js";
@@ -229,6 +230,7 @@ export {
229
230
  EXPERT_FILTER_EQUIPMENTS,
230
231
  EXPERT_FILTER_FIELDS,
231
232
  EXPERT_FILTER_QUERY,
233
+ ElementCreationDialog,
232
234
  ElementSearchDialog,
233
235
  ElementSearchInput,
234
236
  ElementType,
@@ -371,6 +373,7 @@ export {
371
373
  directoryItemsInputEn,
372
374
  directoryItemsInputFr,
373
375
  dispatchUser,
376
+ elementAlreadyExists,
374
377
  elementSearchEn,
375
378
  elementSearchFr,
376
379
  equalsArray,
@@ -1,6 +1,7 @@
1
1
  import { UUID } from 'crypto';
2
- import { ElementAttributes } from '../utils/types/types';
2
+ import { ElementAttributes } from '../utils';
3
3
 
4
4
  export declare function fetchRootFolders(types: string[]): Promise<ElementAttributes[]>;
5
5
  export declare function fetchDirectoryContent(directoryUuid: UUID, types?: string[]): Promise<ElementAttributes[]>;
6
6
  export declare function fetchDirectoryElementPath(elementUuid: UUID): Promise<ElementAttributes[]>;
7
+ export declare function elementAlreadyExists(directoryUuid: UUID, elementName: string, type: string): Promise<boolean>;
@@ -1,4 +1,4 @@
1
- import { getRequestParamFromList, backendFetchJson } from "./utils.js";
1
+ import { getRequestParamFromList, backendFetchJson, backendFetch } from "./utils.js";
2
2
  const PREFIX_DIRECTORY_SERVER_QUERIES = `${"api/gateway"}/directory`;
3
3
  function fetchRootFolders(types) {
4
4
  console.info("Fetching Root Directories");
@@ -27,7 +27,17 @@ function fetchDirectoryElementPath(elementUuid) {
27
27
  headers: { "Content-Type": "application/json" }
28
28
  });
29
29
  }
30
+ function elementAlreadyExists(directoryUuid, elementName, type) {
31
+ const elementNameEncoded = encodeURIComponent(elementName);
32
+ const existsElementUrl = `${PREFIX_DIRECTORY_SERVER_QUERIES}/v1/directories/${directoryUuid}/elements/${elementNameEncoded}/types/${type}`;
33
+ console.debug(existsElementUrl);
34
+ return backendFetch(existsElementUrl, { method: "head" }).then(
35
+ (response) => response.status !== 204
36
+ // HTTP 204 : No-content
37
+ );
38
+ }
30
39
  export {
40
+ elementAlreadyExists,
31
41
  fetchDirectoryContent,
32
42
  fetchDirectoryElementPath,
33
43
  fetchRootFolders
@@ -1,13 +1,14 @@
1
1
  import { backendFetch, backendFetchJson, catchErrorHandler, getRequestParamFromList } from "./utils.js";
2
2
  import { createFilter, fetchElementsInfos, saveFilter } from "./explore.js";
3
3
  import { fetchAppsMetadata, fetchDefaultCountry, fetchEnv, fetchFavoriteAndDefaultCountries, fetchStudyMetadata, isStudyMetadata } from "./appsMetadata.js";
4
- import { fetchDirectoryContent, fetchDirectoryElementPath, fetchRootFolders } from "./directory.js";
4
+ import { elementAlreadyExists, fetchDirectoryContent, fetchDirectoryElementPath, fetchRootFolders } from "./directory.js";
5
5
  import { exportFilter } from "./study.js";
6
6
  export {
7
7
  backendFetch,
8
8
  backendFetchJson,
9
9
  catchErrorHandler,
10
10
  createFilter,
11
+ elementAlreadyExists,
11
12
  exportFilter,
12
13
  fetchAppsMetadata,
13
14
  fetchDefaultCountry,
@@ -5,41 +5,43 @@
5
5
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
6
  */
7
7
  export declare enum FieldConstants {
8
- ID = "id",
9
- NAME = "name",
10
- FILTER_TYPE = "filterType",
11
- EQUIPMENT_TYPE = "equipmentType",
12
- EQUIPMENT_TABLE = "equipmentTable",
13
- EQUIPMENT_ID = "equipmentID",
14
- EQUIPMENT_IDS = "equipmentIDs",
8
+ AG_GRID_ROW_UUID = "agGridRowUuid",
9
+ API_CALL = "apiCall",
10
+ CASE_FILE = "caseFile",
11
+ CASE_FORMAT = "caseFormat",
12
+ CASE_NAME = "caseName",
13
+ CASE_UUID = "caseUuid",
14
+ CONTINGENCY_LIST_TYPE = "contingencyListType",
15
15
  CONTINGENCY_NAME = "contingencyName",
16
- COUNTRIES = "countries",
17
16
  COUNTRIES_1 = "countries1",
18
17
  COUNTRIES_2 = "countries2",
19
- VALUE_1 = "value1",
20
- VALUE_2 = "value2",
21
- OPERATION_TYPE = "type",
22
- CONTINGENCY_LIST_TYPE = "contingencyListType",
23
- NOMINAL_VOLTAGE = "nominalVoltage",
24
- NOMINAL_VOLTAGE_1 = "nominalVoltage1",
25
- NOMINAL_VOLTAGE_2 = "nominalVoltage2",
26
- NOMINAL_VOLTAGE_3 = "nominalVoltage3",
27
- ENERGY_SOURCE = "energySource",
28
- SCRIPT = "script",
29
- AG_GRID_ROW_UUID = "agGridRowUuid",
18
+ COUNTRIES = "countries",
30
19
  CRITERIA_BASED = "criteriaBased",
31
- STUDY_NAME = "studyName",
32
- DESCRIPTION = "description",
33
- CASE_FILE = "caseFile",
34
- CASE_UUID = "caseUuid",
35
- FORMATTED_CASE_PARAMETERS = "formattedCaseParameters",
36
20
  CURRENT_PARAMETERS = "currentParameters",
37
- CASE_FORMAT = "caseFormat",
38
- API_CALL = "apiCall",
39
- CASE_NAME = "caseName",
21
+ DESCRIPTION = "description",
40
22
  DIRECTORY = "directory",
41
- PROPERTY = "PROPERTY",
23
+ ENERGY_SOURCE = "energySource",
24
+ EQUIPMENT_ID = "equipmentID",
25
+ EQUIPMENT_IDS = "equipmentIDs",
26
+ EQUIPMENT_TABLE = "equipmentTable",
27
+ EQUIPMENT_TYPE = "equipmentType",
28
+ FILTER_TYPE = "filterType",
29
+ FOLDER_ID = "folderId",
30
+ FOLDER_NAME = "folderName",
31
+ FORMATTED_CASE_PARAMETERS = "formattedCaseParameters",
32
+ ID = "id",
33
+ NAME = "name",
34
+ NOMINAL_VOLTAGE_1 = "nominalVoltage1",
35
+ NOMINAL_VOLTAGE_2 = "nominalVoltage2",
36
+ NOMINAL_VOLTAGE_3 = "nominalVoltage3",
37
+ NOMINAL_VOLTAGE = "nominalVoltage",
38
+ OPERATION_TYPE = "type",
42
39
  PROPERTY_NAME = "propertyName",
40
+ PROPERTY_OPERATOR = "propertyOperator",
41
+ PROPERTY = "PROPERTY",
43
42
  PROPERTY_VALUES = "propertyValues",
44
- PROPERTY_OPERATOR = "propertyOperator"
43
+ SCRIPT = "script",
44
+ STUDY_NAME = "studyName",
45
+ VALUE_1 = "value1",
46
+ VALUE_2 = "value2"
45
47
  }
@@ -1,41 +1,43 @@
1
1
  var FieldConstants = /* @__PURE__ */ ((FieldConstants2) => {
2
- FieldConstants2["ID"] = "id";
3
- FieldConstants2["NAME"] = "name";
4
- FieldConstants2["FILTER_TYPE"] = "filterType";
5
- FieldConstants2["EQUIPMENT_TYPE"] = "equipmentType";
6
- FieldConstants2["EQUIPMENT_TABLE"] = "equipmentTable";
7
- FieldConstants2["EQUIPMENT_ID"] = "equipmentID";
8
- FieldConstants2["EQUIPMENT_IDS"] = "equipmentIDs";
2
+ FieldConstants2["AG_GRID_ROW_UUID"] = "agGridRowUuid";
3
+ FieldConstants2["API_CALL"] = "apiCall";
4
+ FieldConstants2["CASE_FILE"] = "caseFile";
5
+ FieldConstants2["CASE_FORMAT"] = "caseFormat";
6
+ FieldConstants2["CASE_NAME"] = "caseName";
7
+ FieldConstants2["CASE_UUID"] = "caseUuid";
8
+ FieldConstants2["CONTINGENCY_LIST_TYPE"] = "contingencyListType";
9
9
  FieldConstants2["CONTINGENCY_NAME"] = "contingencyName";
10
- FieldConstants2["COUNTRIES"] = "countries";
11
10
  FieldConstants2["COUNTRIES_1"] = "countries1";
12
11
  FieldConstants2["COUNTRIES_2"] = "countries2";
13
- FieldConstants2["VALUE_1"] = "value1";
14
- FieldConstants2["VALUE_2"] = "value2";
15
- FieldConstants2["OPERATION_TYPE"] = "type";
16
- FieldConstants2["CONTINGENCY_LIST_TYPE"] = "contingencyListType";
17
- FieldConstants2["NOMINAL_VOLTAGE"] = "nominalVoltage";
18
- FieldConstants2["NOMINAL_VOLTAGE_1"] = "nominalVoltage1";
19
- FieldConstants2["NOMINAL_VOLTAGE_2"] = "nominalVoltage2";
20
- FieldConstants2["NOMINAL_VOLTAGE_3"] = "nominalVoltage3";
21
- FieldConstants2["ENERGY_SOURCE"] = "energySource";
22
- FieldConstants2["SCRIPT"] = "script";
23
- FieldConstants2["AG_GRID_ROW_UUID"] = "agGridRowUuid";
12
+ FieldConstants2["COUNTRIES"] = "countries";
24
13
  FieldConstants2["CRITERIA_BASED"] = "criteriaBased";
25
- FieldConstants2["STUDY_NAME"] = "studyName";
26
- FieldConstants2["DESCRIPTION"] = "description";
27
- FieldConstants2["CASE_FILE"] = "caseFile";
28
- FieldConstants2["CASE_UUID"] = "caseUuid";
29
- FieldConstants2["FORMATTED_CASE_PARAMETERS"] = "formattedCaseParameters";
30
14
  FieldConstants2["CURRENT_PARAMETERS"] = "currentParameters";
31
- FieldConstants2["CASE_FORMAT"] = "caseFormat";
32
- FieldConstants2["API_CALL"] = "apiCall";
33
- FieldConstants2["CASE_NAME"] = "caseName";
15
+ FieldConstants2["DESCRIPTION"] = "description";
34
16
  FieldConstants2["DIRECTORY"] = "directory";
35
- FieldConstants2["PROPERTY"] = "PROPERTY";
17
+ FieldConstants2["ENERGY_SOURCE"] = "energySource";
18
+ FieldConstants2["EQUIPMENT_ID"] = "equipmentID";
19
+ FieldConstants2["EQUIPMENT_IDS"] = "equipmentIDs";
20
+ FieldConstants2["EQUIPMENT_TABLE"] = "equipmentTable";
21
+ FieldConstants2["EQUIPMENT_TYPE"] = "equipmentType";
22
+ FieldConstants2["FILTER_TYPE"] = "filterType";
23
+ FieldConstants2["FOLDER_ID"] = "folderId";
24
+ FieldConstants2["FOLDER_NAME"] = "folderName";
25
+ FieldConstants2["FORMATTED_CASE_PARAMETERS"] = "formattedCaseParameters";
26
+ FieldConstants2["ID"] = "id";
27
+ FieldConstants2["NAME"] = "name";
28
+ FieldConstants2["NOMINAL_VOLTAGE_1"] = "nominalVoltage1";
29
+ FieldConstants2["NOMINAL_VOLTAGE_2"] = "nominalVoltage2";
30
+ FieldConstants2["NOMINAL_VOLTAGE_3"] = "nominalVoltage3";
31
+ FieldConstants2["NOMINAL_VOLTAGE"] = "nominalVoltage";
32
+ FieldConstants2["OPERATION_TYPE"] = "type";
36
33
  FieldConstants2["PROPERTY_NAME"] = "propertyName";
37
- FieldConstants2["PROPERTY_VALUES"] = "propertyValues";
38
34
  FieldConstants2["PROPERTY_OPERATOR"] = "propertyOperator";
35
+ FieldConstants2["PROPERTY"] = "PROPERTY";
36
+ FieldConstants2["PROPERTY_VALUES"] = "propertyValues";
37
+ FieldConstants2["SCRIPT"] = "script";
38
+ FieldConstants2["STUDY_NAME"] = "studyName";
39
+ FieldConstants2["VALUE_1"] = "value1";
40
+ FieldConstants2["VALUE_2"] = "value2";
39
41
  return FieldConstants2;
40
42
  })(FieldConstants || {});
41
43
  export {
@@ -1,5 +1,9 @@
1
- import { UUID } from 'crypto';
2
-
1
+ /**
2
+ * Copyright (c) 2024, 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
+ */
3
7
  export declare enum ElementType {
4
8
  DIRECTORY = "DIRECTORY",
5
9
  STUDY = "STUDY",
@@ -16,4 +20,3 @@ export declare enum ElementType {
16
20
  SPREADSHEET_CONFIG = "SPREADSHEET_CONFIG",
17
21
  SPREADSHEET_CONFIG_COLLECTION = "SPREADSHEET_CONFIG_COLLECTION"
18
22
  }
19
- export type ElementExistsType = (directory: UUID, value: string, elementType: ElementType) => Promise<boolean>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gridsuite/commons-ui",
3
- "version": "0.85.1",
3
+ "version": "0.86.0",
4
4
  "description": "common react components for gridsuite applications",
5
5
  "engines": {
6
6
  "node": ">=22",