From 5829a2b62d0144d0c2c3e47263ceb0cdc927fed2 Mon Sep 17 00:00:00 2001 From: Mathieu DEHARBE Date: Wed, 11 Sep 2024 10:32:17 +0200 Subject: [PATCH 01/18] draft refacto improve filter ihm Signed-off-by: Mathieu DEHARBE --- src/components/filter/filter-form.tsx | 48 +++++++++++++++++++-------- 1 file changed, 34 insertions(+), 14 deletions(-) diff --git a/src/components/filter/filter-form.tsx b/src/components/filter/filter-form.tsx index 059d3fc7..7269e9ca 100644 --- a/src/components/filter/filter-form.tsx +++ b/src/components/filter/filter-form.tsx @@ -29,16 +29,10 @@ interface FilterFormProps { }; } -function FilterForm(props: FilterFormProps) { +function HeaderFilterForm(props: FilterFormProps) { const { sourceFilterForExplicitNamingConversion, creation, activeDirectory, elementExists } = props; - const { setValue } = useFormContext(); - - const filterType = useWatch({ name: FieldConstants.FILTER_TYPE }); - // We do this because setValue don't set the field dirty - const handleChange = (_event: React.ChangeEvent, value: string) => { - setValue(FieldConstants.FILTER_TYPE, value); - }; + const { setValue } = useFormContext(); useEffect(() => { if (sourceFilterForExplicitNamingConversion) { @@ -46,8 +40,13 @@ function FilterForm(props: FilterFormProps) { } }, [sourceFilterForExplicitNamingConversion, setValue]); + // We do this because setValue don't set the field dirty + const handleChange = (_event: React.ChangeEvent, value: string) => { + setValue(FieldConstants.FILTER_TYPE, value); + }; + return ( - + <> )} - {filterType === FilterType.CRITERIA_BASED.id && } - {filterType === FilterType.EXPLICIT_NAMING.id && ( - + ); +} + +function FilterForm(props: FilterFormProps) { + const { sourceFilterForExplicitNamingConversion, creation, activeDirectory, elementExists } = props; + + const filterType = useWatch({ name: FieldConstants.FILTER_TYPE }); + + return ( + + + - )} - {filterType === FilterType.EXPERT.id && } + + + {filterType === FilterType.CRITERIA_BASED.id && } + {filterType === FilterType.EXPLICIT_NAMING.id && ( + + )} + {filterType === FilterType.EXPERT.id && } + ); } From e6a882f10b22b2fb05cf6d8902defe054994f789 Mon Sep 17 00:00:00 2001 From: Mathieu DEHARBE Date: Wed, 18 Sep 2024 15:45:08 +0200 Subject: [PATCH 02/18] new FilterForm file Signed-off-by: Mathieu DEHARBE --- src/components/filter/FilterForm.tsx | 76 +++------------------- src/components/filter/HeaderFilterForm.tsx | 72 ++++++++++++++++++++ 2 files changed, 80 insertions(+), 68 deletions(-) create mode 100644 src/components/filter/HeaderFilterForm.tsx diff --git a/src/components/filter/FilterForm.tsx b/src/components/filter/FilterForm.tsx index ecb012be..0f792ed9 100644 --- a/src/components/filter/FilterForm.tsx +++ b/src/components/filter/FilterForm.tsx @@ -5,81 +5,21 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import React, { useEffect } from 'react'; -import { useFormContext, useWatch } from 'react-hook-form'; +import { useWatch } from 'react-hook-form'; import { Grid } from '@mui/material'; -import { UUID } from 'crypto'; import FieldConstants from '../../utils/constants/fieldConstants'; import CriteriaBasedFilterForm from './criteriaBased/CriteriaBasedFilterForm'; +import HeaderFilterForm, { FilterFormProps } from './HeaderFilterForm'; import ExplicitNamingFilterForm from './explicitNaming/ExplicitNamingFilterForm'; import ExpertFilterForm from './expert/ExpertFilterForm'; import { FilterType } from './constants/FilterConstants'; -import RadioInput from '../inputs/reactHookForm/booleans/RadioInput'; -import { ElementExistsType, ElementType } from '../../utils/types/elementType'; -import UniqueNameInput from '../inputs/reactHookForm/text/UniqueNameInput'; -import DescriptionField from '../inputs/reactHookForm/text/DescriptionField'; - -interface FilterFormProps { - creation?: boolean; - activeDirectory?: UUID; - elementExists?: ElementExistsType; - sourceFilterForExplicitNamingConversion?: { - id: UUID; - equipmentType: string; - }; -} - -function HeaderFilterForm(props: FilterFormProps) { - const { sourceFilterForExplicitNamingConversion, creation, activeDirectory, elementExists } = props; - - const { setValue } = useFormContext(); - - useEffect(() => { - if (sourceFilterForExplicitNamingConversion) { - setValue(FieldConstants.FILTER_TYPE, FilterType.EXPLICIT_NAMING.id); - } - }, [sourceFilterForExplicitNamingConversion, setValue]); - - // We do this because setValue don't set the field dirty - const handleChange = (_event: React.ChangeEvent, value: string) => { - setValue(FieldConstants.FILTER_TYPE, value); - }; - - return ( - <> - - - - {creation && ( - <> - - - - {!sourceFilterForExplicitNamingConversion && ( - - - - )} - - )} - - ); -} - -function FilterForm(props: FilterFormProps) { - const { sourceFilterForExplicitNamingConversion, creation, activeDirectory, elementExists } = props; +function FilterForm({ + sourceFilterForExplicitNamingConversion, + creation, + activeDirectory, + elementExists, +}: FilterFormProps) { const filterType = useWatch({ name: FieldConstants.FILTER_TYPE }); return ( diff --git a/src/components/filter/HeaderFilterForm.tsx b/src/components/filter/HeaderFilterForm.tsx new file mode 100644 index 00000000..d84dc67c --- /dev/null +++ b/src/components/filter/HeaderFilterForm.tsx @@ -0,0 +1,72 @@ +import { useFormContext } from 'react-hook-form'; +import React, { useEffect } from 'react'; +import { Grid } from '@mui/material'; +import { UUID } from 'crypto'; +import FieldConstants from '../../utils/constants/fieldConstants'; +import { FilterType } from './constants/FilterConstants'; +import UniqueNameInput from '../inputs/reactHookForm/text/UniqueNameInput'; +import { ElementExistsType, ElementType } from '../../utils/types/elementType'; +import DescriptionField from '../inputs/reactHookForm/text/DescriptionField'; +import RadioInput from '../inputs/reactHookForm/booleans/RadioInput'; + +export interface FilterFormProps { + creation?: boolean; + activeDirectory?: UUID; + elementExists?: ElementExistsType; + sourceFilterForExplicitNamingConversion?: { + id: UUID; + equipmentType: string; + }; +} + +function HeaderFilterForm({ + sourceFilterForExplicitNamingConversion, + creation, + activeDirectory, + elementExists, +}: FilterFormProps) { + const { setValue } = useFormContext(); + + useEffect(() => { + if (sourceFilterForExplicitNamingConversion) { + setValue(FieldConstants.FILTER_TYPE, FilterType.EXPLICIT_NAMING.id); + } + }, [sourceFilterForExplicitNamingConversion, setValue]); + + // We do this because setValue don't set the field dirty + const handleChange = (_event: React.ChangeEvent, value: string) => { + setValue(FieldConstants.FILTER_TYPE, value); + }; + + return ( + <> + + + + {creation && ( + <> + + + + {!sourceFilterForExplicitNamingConversion && ( + + + + )} + + )} + + ); +} +export default HeaderFilterForm; From 4f53a68ff0390b0b78200c270696dc1aa69bf319 Mon Sep 17 00:00:00 2001 From: Mathieu DEHARBE Date: Wed, 18 Sep 2024 16:06:53 +0200 Subject: [PATCH 03/18] corrects errors Signed-off-by: Mathieu DEHARBE --- src/components/filter/FilterForm.tsx | 2 +- src/components/filter/HeaderFilterForm.tsx | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/components/filter/FilterForm.tsx b/src/components/filter/FilterForm.tsx index 0f792ed9..53bd8582 100644 --- a/src/components/filter/FilterForm.tsx +++ b/src/components/filter/FilterForm.tsx @@ -19,7 +19,7 @@ function FilterForm({ creation, activeDirectory, elementExists, -}: FilterFormProps) { +}: Readonly) { const filterType = useWatch({ name: FieldConstants.FILTER_TYPE }); return ( diff --git a/src/components/filter/HeaderFilterForm.tsx b/src/components/filter/HeaderFilterForm.tsx index d84dc67c..95b7ada0 100644 --- a/src/components/filter/HeaderFilterForm.tsx +++ b/src/components/filter/HeaderFilterForm.tsx @@ -1,3 +1,10 @@ +/** + * Copyright (c) 2024, RTE (http://www.rte-france.com) + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + import { useFormContext } from 'react-hook-form'; import React, { useEffect } from 'react'; import { Grid } from '@mui/material'; @@ -24,7 +31,7 @@ function HeaderFilterForm({ creation, activeDirectory, elementExists, -}: FilterFormProps) { +}: Readonly) { const { setValue } = useFormContext(); useEffect(() => { From 7950a93488121b114e4f275f9794a24c431bdc03 Mon Sep 17 00:00:00 2001 From: Mathieu DEHARBE Date: Thu, 19 Sep 2024 12:56:37 +0200 Subject: [PATCH 04/18] fixed window height Signed-off-by: Mathieu DEHARBE --- src/components/filter/FilterForm.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/components/filter/FilterForm.tsx b/src/components/filter/FilterForm.tsx index 53bd8582..42fbcc9a 100644 --- a/src/components/filter/FilterForm.tsx +++ b/src/components/filter/FilterForm.tsx @@ -14,6 +14,12 @@ import ExplicitNamingFilterForm from './explicitNaming/ExplicitNamingFilterForm' import ExpertFilterForm from './expert/ExpertFilterForm'; import { FilterType } from './constants/FilterConstants'; +const styles = { + filterForm: { + height: '80vh', + }, +}; + function FilterForm({ sourceFilterForExplicitNamingConversion, creation, @@ -23,7 +29,7 @@ function FilterForm({ const filterType = useWatch({ name: FieldConstants.FILTER_TYPE }); return ( - + Date: Tue, 24 Sep 2024 16:13:49 +0200 Subject: [PATCH 05/18] draft scrolling update Signed-off-by: Mathieu DEHARBE --- .../customMuiDialog/CustomMuiDialog.tsx | 7 ++- src/components/filter/FilterForm.tsx | 37 +++++---------- src/components/filter/HeaderFilterForm.tsx | 4 +- .../criteriaBased/CriteriaBasedFilterForm.tsx | 47 ++++++++++++++++--- .../criteriaBased/CriteriaBasedForm.tsx | 30 +----------- 5 files changed, 64 insertions(+), 61 deletions(-) diff --git a/src/components/dialogs/customMuiDialog/CustomMuiDialog.tsx b/src/components/dialogs/customMuiDialog/CustomMuiDialog.tsx index 5972af87..4f11b245 100644 --- a/src/components/dialogs/customMuiDialog/CustomMuiDialog.tsx +++ b/src/components/dialogs/customMuiDialog/CustomMuiDialog.tsx @@ -38,8 +38,13 @@ const styles = { width: 'auto', minWidth: '1100px', margin: 'auto', + height: '90vh', // devrait être valable seulement pour une version non scrollable spécifique }, }, + unscrollable: { // devrait être valable seulement pour une version non scrollable spécifique + overflowY: 'hidden', + maxHeight: '80vh', + }, }; function CustomMuiDialog({ @@ -120,7 +125,7 @@ function CustomMuiDialog({ - {children} + {children} - - + + {filterType === FilterType.CRITERIA_BASED.id && } + {filterType === FilterType.EXPLICIT_NAMING.id && ( + - - - {filterType === FilterType.CRITERIA_BASED.id && } - {filterType === FilterType.EXPLICIT_NAMING.id && ( - - )} - {filterType === FilterType.EXPERT.id && } - - + )} + {filterType === FilterType.EXPERT.id && } + ); } diff --git a/src/components/filter/HeaderFilterForm.tsx b/src/components/filter/HeaderFilterForm.tsx index 95b7ada0..ffc4435f 100644 --- a/src/components/filter/HeaderFilterForm.tsx +++ b/src/components/filter/HeaderFilterForm.tsx @@ -46,7 +46,7 @@ function HeaderFilterForm({ }; return ( - <> + )} - + ); } export default HeaderFilterForm; diff --git a/src/components/filter/criteriaBased/CriteriaBasedFilterForm.tsx b/src/components/filter/criteriaBased/CriteriaBasedFilterForm.tsx index 74215d4f..641edffb 100644 --- a/src/components/filter/criteriaBased/CriteriaBasedFilterForm.tsx +++ b/src/components/filter/criteriaBased/CriteriaBasedFilterForm.tsx @@ -5,6 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ import Grid from '@mui/material/Grid'; +import { useFormContext } from 'react-hook-form'; import FilterProperties, { filterPropertiesYupSchema } from './FilterProperties'; import FieldConstants from '../../../utils/constants/fieldConstants'; import yup from '../../../utils/yupConfig'; @@ -12,6 +13,8 @@ import CriteriaBasedForm from './CriteriaBasedForm'; import { getCriteriaBasedFormData, getCriteriaBasedSchema } from './criteriaBasedFilterUtils'; import { FILTER_EQUIPMENTS } from '../utils/filterFormUtils'; import { FreePropertiesTypes } from './FilterFreeProperties'; +import InputWithPopupConfirmation from '../../inputs/reactHookForm/selectInputs/InputWithPopupConfirmation'; +import SelectInput from '../../inputs/reactHookForm/selectInputs/SelectInput'; export const criteriaBasedFilterSchema = getCriteriaBasedSchema({ [FieldConstants.ENERGY_SOURCE]: yup.string().nullable(), @@ -24,14 +27,46 @@ export const criteriaBasedFilterEmptyFormData = getCriteriaBasedFormData(null, { [FreePropertiesTypes.FREE_FILTER_PROPERTIES]: [], }); +const styles = { + scrollablePart: { + height: '500px', // tmp : pas trouvé de moyen de déterminer dynamiquement la hauteur, et sans ça overflow ne fonctionne pas... + overflowY: 'auto', + flex: '1 1 auto', + }, +}; + function CriteriaBasedFilterForm() { + const { getValues, setValue } = useFormContext(); + const defaultValues: Record = criteriaBasedFilterEmptyFormData[FieldConstants.CRITERIA_BASED]; + + const openConfirmationPopup = () => { + return JSON.stringify(getValues(FieldConstants.CRITERIA_BASED)) !== JSON.stringify(defaultValues); + }; + + const handleResetOnConfirmation = () => { + Object.keys(defaultValues).forEach((field) => + setValue(`${FieldConstants.CRITERIA_BASED}.${field}`, defaultValues[field]) + ); + }; + return ( - - - + + + + + + + + ); } diff --git a/src/components/filter/criteriaBased/CriteriaBasedForm.tsx b/src/components/filter/criteriaBased/CriteriaBasedForm.tsx index 5e176e3d..c36f9172 100644 --- a/src/components/filter/criteriaBased/CriteriaBasedForm.tsx +++ b/src/components/filter/criteriaBased/CriteriaBasedForm.tsx @@ -5,22 +5,18 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { useFormContext, useWatch } from 'react-hook-form'; +import { useWatch } from 'react-hook-form'; import { Grid } from '@mui/material'; import { useEffect } from 'react'; import FieldConstants from '../../../utils/constants/fieldConstants'; -import SelectInput from '../../inputs/reactHookForm/selectInputs/SelectInput'; -import InputWithPopupConfirmation from '../../inputs/reactHookForm/selectInputs/InputWithPopupConfirmation'; import { FormEquipment } from '../utils/filterFormUtils'; import { useSnackMessage } from '../../../hooks/useSnackMessage'; export interface CriteriaBasedFormProps { equipments: Record; - defaultValues: Record; } -function CriteriaBasedForm({ equipments, defaultValues }: CriteriaBasedFormProps) { - const { getValues, setValue } = useFormContext(); +function CriteriaBasedForm({ equipments }: CriteriaBasedFormProps) { const { snackError } = useSnackMessage(); const watchEquipmentType = useWatch({ @@ -35,30 +31,8 @@ function CriteriaBasedForm({ equipments, defaultValues }: CriteriaBasedFormProps } }, [snackError, equipments, watchEquipmentType]); - const openConfirmationPopup = () => { - return JSON.stringify(getValues(FieldConstants.CRITERIA_BASED)) !== JSON.stringify(defaultValues); - }; - - const handleResetOnConfirmation = () => { - Object.keys(defaultValues).forEach((field) => - setValue(`${FieldConstants.CRITERIA_BASED}.${field}`, defaultValues[field]) - ); - }; - return ( - - - {watchEquipmentType && equipments[watchEquipmentType] && equipments[watchEquipmentType].fields.map((equipment: any, index: number) => { From 1591f18b457412e1795eb21ee43905d564e2d052 Mon Sep 17 00:00:00 2001 From: Mathieu DEHARBE Date: Tue, 24 Sep 2024 18:05:50 +0200 Subject: [PATCH 06/18] much better scrolling Signed-off-by: Mathieu DEHARBE --- .../customMuiDialog/CustomMuiDialog.tsx | 5 ++- src/components/filter/FilterForm.tsx | 16 +++++++- .../criteriaBased/CriteriaBasedFilterForm.tsx | 38 ++++++++++++------- 3 files changed, 42 insertions(+), 17 deletions(-) diff --git a/src/components/dialogs/customMuiDialog/CustomMuiDialog.tsx b/src/components/dialogs/customMuiDialog/CustomMuiDialog.tsx index 4f11b245..59a0651b 100644 --- a/src/components/dialogs/customMuiDialog/CustomMuiDialog.tsx +++ b/src/components/dialogs/customMuiDialog/CustomMuiDialog.tsx @@ -41,9 +41,10 @@ const styles = { height: '90vh', // devrait être valable seulement pour une version non scrollable spécifique }, }, - unscrollable: { // devrait être valable seulement pour une version non scrollable spécifique + unscrollable: { + // devrait être valable seulement pour une version non scrollable spécifique + height: '100%', overflowY: 'hidden', - maxHeight: '80vh', }, }; diff --git a/src/components/filter/FilterForm.tsx b/src/components/filter/FilterForm.tsx index 71e42d61..f81ef512 100644 --- a/src/components/filter/FilterForm.tsx +++ b/src/components/filter/FilterForm.tsx @@ -6,6 +6,7 @@ */ import { useWatch } from 'react-hook-form'; +import { Box } from '@mui/material'; import FieldConstants from '../../utils/constants/fieldConstants'; import CriteriaBasedFilterForm from './criteriaBased/CriteriaBasedFilterForm'; import HeaderFilterForm, { FilterFormProps } from './HeaderFilterForm'; @@ -13,6 +14,17 @@ import ExplicitNamingFilterForm from './explicitNaming/ExplicitNamingFilterForm' import ExpertFilterForm from './expert/ExpertFilterForm'; import { FilterType } from './constants/FilterConstants'; +const styles = { + NonScrollableContainer: { + height: '100%', + '&::before': { + content: '""', + height: '100%', + float: 'left', + }, + }, +}; + function FilterForm({ sourceFilterForExplicitNamingConversion, creation, @@ -22,7 +34,7 @@ function FilterForm({ const filterType = useWatch({ name: FieldConstants.FILTER_TYPE }); return ( - <> + )} {filterType === FilterType.EXPERT.id && } - + ); } diff --git a/src/components/filter/criteriaBased/CriteriaBasedFilterForm.tsx b/src/components/filter/criteriaBased/CriteriaBasedFilterForm.tsx index 641edffb..618d954e 100644 --- a/src/components/filter/criteriaBased/CriteriaBasedFilterForm.tsx +++ b/src/components/filter/criteriaBased/CriteriaBasedFilterForm.tsx @@ -4,8 +4,8 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import Grid from '@mui/material/Grid'; import { useFormContext } from 'react-hook-form'; +import { Box } from '@mui/material'; import FilterProperties, { filterPropertiesYupSchema } from './FilterProperties'; import FieldConstants from '../../../utils/constants/fieldConstants'; import yup from '../../../utils/yupConfig'; @@ -28,10 +28,20 @@ export const criteriaBasedFilterEmptyFormData = getCriteriaBasedFormData(null, { }); const styles = { - scrollablePart: { - height: '500px', // tmp : pas trouvé de moyen de déterminer dynamiquement la hauteur, et sans ça overflow ne fonctionne pas... - overflowY: 'auto', - flex: '1 1 auto', + ScrollableContainer: { + position: 'relative', + zIndex: '1', + '&::after': { + content: '""', + clear: 'both', + display: 'block', + }, + }, + ScrollableContent: { + position: 'absolute', + width: '100%', + height: '100%', + overflow: 'auto', }, }; @@ -50,8 +60,8 @@ function CriteriaBasedFilterForm() { }; return ( - - + <> + - - - - - - + + + + + + + + ); } From 3139240aeaf4f67f36cda5eb937e0954331b823e Mon Sep 17 00:00:00 2001 From: Mathieu DEHARBE Date: Tue, 24 Sep 2024 18:20:08 +0200 Subject: [PATCH 07/18] read only prop Signed-off-by: Mathieu DEHARBE --- src/components/filter/criteriaBased/CriteriaBasedForm.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/filter/criteriaBased/CriteriaBasedForm.tsx b/src/components/filter/criteriaBased/CriteriaBasedForm.tsx index c36f9172..ca106e83 100644 --- a/src/components/filter/criteriaBased/CriteriaBasedForm.tsx +++ b/src/components/filter/criteriaBased/CriteriaBasedForm.tsx @@ -16,7 +16,7 @@ export interface CriteriaBasedFormProps { equipments: Record; } -function CriteriaBasedForm({ equipments }: CriteriaBasedFormProps) { +function CriteriaBasedForm({ equipments }: Readonly) { const { snackError } = useSnackMessage(); const watchEquipmentType = useWatch({ From dedbbd0a1eb25a2d609c1adc790033618b5d1aae Mon Sep 17 00:00:00 2001 From: Mathieu DEHARBE Date: Tue, 1 Oct 2024 10:41:49 +0200 Subject: [PATCH 08/18] 95vh Signed-off-by: Mathieu DEHARBE --- src/components/dialogs/customMuiDialog/CustomMuiDialog.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/dialogs/customMuiDialog/CustomMuiDialog.tsx b/src/components/dialogs/customMuiDialog/CustomMuiDialog.tsx index 59a0651b..37686734 100644 --- a/src/components/dialogs/customMuiDialog/CustomMuiDialog.tsx +++ b/src/components/dialogs/customMuiDialog/CustomMuiDialog.tsx @@ -38,7 +38,7 @@ const styles = { width: 'auto', minWidth: '1100px', margin: 'auto', - height: '90vh', // devrait être valable seulement pour une version non scrollable spécifique + height: '95vh', // devrait être valable seulement pour une version non scrollable spécifique }, }, unscrollable: { From 51d29a1029c55d24b9965e5f2e9d503972863fee Mon Sep 17 00:00:00 2001 From: Mathieu DEHARBE Date: Tue, 1 Oct 2024 13:13:55 +0200 Subject: [PATCH 09/18] unscrollableFullHeight props parameter Signed-off-by: Mathieu DEHARBE --- .../customMuiDialog/CustomMuiDialog.tsx | 21 +++++++++++++++---- .../filter/FilterCreationDialog.tsx | 1 + .../CriteriaBasedFilterEditionDialog.tsx | 1 + .../expert/ExpertFilterEditionDialog.tsx | 1 + .../ExplicitNamingFilterEditionDialog.tsx | 1 + 5 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/components/dialogs/customMuiDialog/CustomMuiDialog.tsx b/src/components/dialogs/customMuiDialog/CustomMuiDialog.tsx index 37686734..5417f0d5 100644 --- a/src/components/dialogs/customMuiDialog/CustomMuiDialog.tsx +++ b/src/components/dialogs/customMuiDialog/CustomMuiDialog.tsx @@ -30,6 +30,7 @@ export interface CustomMuiDialogProps { isDataFetching?: boolean; language?: string; confirmationMessageKey?: string; + unscrollableFullHeight?: boolean; } const styles = { @@ -38,11 +39,17 @@ const styles = { width: 'auto', minWidth: '1100px', margin: 'auto', - height: '95vh', // devrait être valable seulement pour une version non scrollable spécifique + }, + }, + dialogPaperFullHeight: { + '.MuiDialog-paper': { + width: 'auto', + minWidth: '1100px', + margin: 'auto', + height: '95vh', }, }, unscrollable: { - // devrait être valable seulement pour une version non scrollable spécifique height: '100%', overflowY: 'hidden', }, @@ -63,6 +70,7 @@ function CustomMuiDialog({ children, language, confirmationMessageKey, + unscrollableFullHeight = false, }: Readonly) { const [openConfirmationPopup, setOpenConfirmationPopup] = useState(false); const [validatedData, setValidatedData] = useState(undefined); @@ -119,14 +127,19 @@ function CustomMuiDialog({ removeOptional={removeOptional} language={language} > - + {isDataFetching && } - {children} + {children} {isDataReady && } diff --git a/src/components/filter/expert/ExpertFilterEditionDialog.tsx b/src/components/filter/expert/ExpertFilterEditionDialog.tsx index 88ff9e45..d94d9e1c 100644 --- a/src/components/filter/expert/ExpertFilterEditionDialog.tsx +++ b/src/components/filter/expert/ExpertFilterEditionDialog.tsx @@ -143,6 +143,7 @@ function ExpertFilterEditionDialog({ disabledSave={!!nameError || !!isValidating} isDataFetching={dataFetchStatus === FetchStatus.FETCHING} language={language} + unscrollableFullHeight > {isDataReady && } diff --git a/src/components/filter/explicitNaming/ExplicitNamingFilterEditionDialog.tsx b/src/components/filter/explicitNaming/ExplicitNamingFilterEditionDialog.tsx index 6b85a7f0..32763aa1 100644 --- a/src/components/filter/explicitNaming/ExplicitNamingFilterEditionDialog.tsx +++ b/src/components/filter/explicitNaming/ExplicitNamingFilterEditionDialog.tsx @@ -145,6 +145,7 @@ function ExplicitNamingFilterEditionDialog({ disabledSave={!!nameError || !!isValidating} isDataFetching={dataFetchStatus === FetchStatus.FETCHING} language={language} + unscrollableFullHeight > {isDataReady && } From 51a45a27f6c1d93f6322c5d1e59e5877e11fed93 Mon Sep 17 00:00:00 2001 From: Mathieu DEHARBE Date: Tue, 1 Oct 2024 14:19:01 +0200 Subject: [PATCH 10/18] padding Signed-off-by: Mathieu DEHARBE --- src/components/filter/FilterForm.tsx | 4 ++-- src/components/filter/HeaderFilterForm.tsx | 2 +- .../filter/criteriaBased/CriteriaBasedFilterForm.tsx | 4 ++-- src/components/filter/criteriaBased/CriteriaBasedForm.tsx | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/components/filter/FilterForm.tsx b/src/components/filter/FilterForm.tsx index f81ef512..83ccd7a0 100644 --- a/src/components/filter/FilterForm.tsx +++ b/src/components/filter/FilterForm.tsx @@ -15,7 +15,7 @@ import ExpertFilterForm from './expert/ExpertFilterForm'; import { FilterType } from './constants/FilterConstants'; const styles = { - NonScrollableContainer: { + FillerContainer: { height: '100%', '&::before': { content: '""', @@ -34,7 +34,7 @@ function FilterForm({ const filterType = useWatch({ name: FieldConstants.FILTER_TYPE }); return ( - + + - + ) { }, [snackError, equipments, watchEquipmentType]); return ( - + {watchEquipmentType && equipments[watchEquipmentType] && equipments[watchEquipmentType].fields.map((equipment: any, index: number) => { From 5e3374f9cc271c065fdf880f0e53ab27cca9a4c0 Mon Sep 17 00:00:00 2001 From: Mathieu DEHARBE Date: Tue, 1 Oct 2024 17:20:34 +0200 Subject: [PATCH 11/18] draft scroll for exmplicit naming filters Signed-off-by: Mathieu DEHARBE --- .../ExplicitNamingFilterForm.tsx | 84 ++++++++++++------- 1 file changed, 53 insertions(+), 31 deletions(-) diff --git a/src/components/filter/explicitNaming/ExplicitNamingFilterForm.tsx b/src/components/filter/explicitNaming/ExplicitNamingFilterForm.tsx index ae8e2fa6..908451df 100644 --- a/src/components/filter/explicitNaming/ExplicitNamingFilterForm.tsx +++ b/src/components/filter/explicitNaming/ExplicitNamingFilterForm.tsx @@ -7,10 +7,10 @@ import { useCallback, useEffect, useMemo } from 'react'; import { useIntl } from 'react-intl'; import { useFormContext, useWatch } from 'react-hook-form'; -import Grid from '@mui/material/Grid'; import { ValueParserParams } from 'ag-grid-community'; import { v4 as uuid4 } from 'uuid'; import { UUID } from 'crypto'; +import { Box } from '@mui/material'; import FieldConstants from '../../../utils/constants/fieldConstants'; import yup from '../../../utils/yupConfig'; import CustomAgGridTable, { @@ -26,11 +26,30 @@ import { FILTER_EQUIPMENTS } from '../utils/filterFormUtils'; import { useSnackMessage } from '../../../hooks/useSnackMessage'; import { ElementType } from '../../../utils/types/elementType'; import ModifyElementSelection from '../../dialogs/modifyElementSelection/ModifyElementSelection'; -import { exportFilter } from '../../../services/study'; +import { exportFilter } from "../../../services"; import { EquipmentType } from '../../../utils/types/equipmentType'; export const FILTER_EQUIPMENTS_ATTRIBUTES = 'filterEquipmentsAttributes'; +const styles = { + ScrollableContainer: { + position: 'relative', + '&::after': { + content: '""', + clear: 'both', + display: 'block', + }, + }, + ScrollableContent: { + // should not be scrollable ! + paddingTop: '10px', + position: 'absolute', + width: '100%', + height: '100%', + overflow: 'auto', // not + }, +}; + function isGeneratorOrLoad(equipmentType: string): boolean { return equipmentType === Generator.type || equipmentType === Load.type; } @@ -212,8 +231,8 @@ function ExplicitNamingFilterForm({ sourceFilterForExplicitNamingConversion }: E }; return ( - - + <> + )} - + {watchEquipmentType && ( - - - + + + + + )} - + ); } From 8e6a88bee8323db170295a7f17a3255e589d73ef Mon Sep 17 00:00:00 2001 From: Mathieu DEHARBE Date: Tue, 1 Oct 2024 17:51:13 +0200 Subject: [PATCH 12/18] expert filters scroll Signed-off-by: Mathieu DEHARBE --- .../filter/expert/ExpertFilterForm.tsx | 38 ++++++++--- .../filter/expert/stylesExpertFilter.css | 5 -- .../ExplicitNamingFilterForm.tsx | 5 +- .../CustomReactQueryBuilder.tsx | 64 +++++++++---------- 4 files changed, 63 insertions(+), 49 deletions(-) diff --git a/src/components/filter/expert/ExpertFilterForm.tsx b/src/components/filter/expert/ExpertFilterForm.tsx index 8e2a223f..fc01ec72 100644 --- a/src/components/filter/expert/ExpertFilterForm.tsx +++ b/src/components/filter/expert/ExpertFilterForm.tsx @@ -7,7 +7,6 @@ import { useCallback, useMemo } from 'react'; -import Grid from '@mui/material/Grid'; import type { RuleGroupTypeAny } from 'react-querybuilder'; import { formatQuery } from 'react-querybuilder'; import './stylesExpertFilter.css'; @@ -15,6 +14,7 @@ import { useFormContext, useWatch } from 'react-hook-form'; import * as yup from 'yup'; import { v4 as uuid4 } from 'uuid'; import { useIntl } from 'react-intl'; +import { Box } from '@mui/material'; import { testQuery } from './expertFilterUtils'; import { COMBINATOR_OPTIONS, EXPERT_FILTER_EQUIPMENTS, fields, OPERATOR_OPTIONS, RULES } from './expertFilterConstants'; @@ -37,6 +37,24 @@ yup.setLocale({ }, }); +const styles = { + ScrollableContainer: { + position: 'relative', + '&::after': { + content: '""', + clear: 'both', + display: 'block', + }, + }, + ScrollableContent: { + position: 'absolute', + width: '100%', + height: '100%', + maxHeight: '100%', + overflow: 'auto', + }, +}; + export const EXPERT_FILTER_QUERY = 'rules'; function isSupportedEquipmentType(equipmentType: string): boolean { @@ -119,8 +137,8 @@ function ExpertFilterForm() { }, [intl, watchEquipmentType]); return ( - - + <> + - - {watchEquipmentType && isSupportedEquipmentType(watchEquipmentType) && ( - - )} - + + + + {watchEquipmentType && isSupportedEquipmentType(watchEquipmentType) && ( + + )} + + + ); } diff --git a/src/components/filter/expert/stylesExpertFilter.css b/src/components/filter/expert/stylesExpertFilter.css index 6b57ecd7..d0630750 100644 --- a/src/components/filter/expert/stylesExpertFilter.css +++ b/src/components/filter/expert/stylesExpertFilter.css @@ -129,11 +129,6 @@ border-bottom: 2px solid #ba000d; } -.queryBuilder { - overflow: auto; - max-height: 600px; -} - /* DnD section, copied from original, just 'border-bottom-color: lightgrey' change */ [data-inlinecombinators='disabled'] .dndOver.rule, [data-inlinecombinators='disabled'] .dndOver.ruleGroup-header { diff --git a/src/components/filter/explicitNaming/ExplicitNamingFilterForm.tsx b/src/components/filter/explicitNaming/ExplicitNamingFilterForm.tsx index 908451df..f0281fd5 100644 --- a/src/components/filter/explicitNaming/ExplicitNamingFilterForm.tsx +++ b/src/components/filter/explicitNaming/ExplicitNamingFilterForm.tsx @@ -26,7 +26,7 @@ import { FILTER_EQUIPMENTS } from '../utils/filterFormUtils'; import { useSnackMessage } from '../../../hooks/useSnackMessage'; import { ElementType } from '../../../utils/types/elementType'; import ModifyElementSelection from '../../dialogs/modifyElementSelection/ModifyElementSelection'; -import { exportFilter } from "../../../services"; +import { exportFilter } from '../../../services'; import { EquipmentType } from '../../../utils/types/equipmentType'; export const FILTER_EQUIPMENTS_ATTRIBUTES = 'filterEquipmentsAttributes'; @@ -41,12 +41,11 @@ const styles = { }, }, ScrollableContent: { - // should not be scrollable ! paddingTop: '10px', position: 'absolute', width: '100%', height: '100%', - overflow: 'auto', // not + overflow: 'auto', }, }; diff --git a/src/components/inputs/reactQueryBuilder/CustomReactQueryBuilder.tsx b/src/components/inputs/reactQueryBuilder/CustomReactQueryBuilder.tsx index 119a9983..70f39efe 100644 --- a/src/components/inputs/reactQueryBuilder/CustomReactQueryBuilder.tsx +++ b/src/components/inputs/reactQueryBuilder/CustomReactQueryBuilder.tsx @@ -5,7 +5,6 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import Grid from '@mui/material/Grid'; import { QueryBuilderDnD } from '@react-querybuilder/dnd'; import * as ReactDnD from 'react-dnd'; import * as ReactDndHtml5Backend from 'react-dnd-html5-backend'; @@ -14,6 +13,7 @@ import { ActionWithRulesAndAddersProps, Field, formatQuery, QueryBuilder, RuleGr import { useIntl } from 'react-intl'; import { useFormContext } from 'react-hook-form'; import { useCallback, useMemo } from 'react'; +import { Box } from '@mui/material'; import CombinatorSelector from './CombinatorSelector'; import AddButton from './AddButton'; import ValueEditor from './ValueEditor'; @@ -76,39 +76,37 @@ function CustomReactQueryBuilder(props: Readonly) return ( <> - - - - getOperators(fieldName, intl)} - validator={queryValidator} - controlClassnames={{ - queryBuilder: 'queryBuilder-branches', - }} - controlElements={{ - addRuleAction: RuleAddButton, - addGroupAction: GroupAddButton, - combinatorSelector: CombinatorSelector, - removeRuleAction: RemoveButton, - removeGroupAction: RemoveButton, - valueEditor: ValueEditor, - operatorSelector: ValueSelector, - fieldSelector: ValueSelector, - valueSourceSelector: ValueSelector, - }} - listsAsArrays - /> - - - - + + + getOperators(fieldName, intl)} + validator={queryValidator} + controlClassnames={{ + queryBuilder: 'queryBuilder-branches', + }} + controlElements={{ + addRuleAction: RuleAddButton, + addGroupAction: GroupAddButton, + combinatorSelector: CombinatorSelector, + removeRuleAction: RemoveButton, + removeGroupAction: RemoveButton, + valueEditor: ValueEditor, + operatorSelector: ValueSelector, + fieldSelector: ValueSelector, + valueSourceSelector: ValueSelector, + }} + listsAsArrays + /> + + + - + ); } From e8e8f8cba54a06ba7868320adb2d089f3242033e Mon Sep 17 00:00:00 2001 From: Mathieu DEHARBE Date: Wed, 2 Oct 2024 11:45:48 +0200 Subject: [PATCH 13/18] reset CriteriaForm to make it usable with aleas Signed-off-by: Mathieu DEHARBE --- .../criteriaBased/CriteriaBasedFilterForm.tsx | 61 ++----------- .../criteriaBased/CriteriaBasedForm.tsx | 87 +++++++++++++++---- 2 files changed, 76 insertions(+), 72 deletions(-) diff --git a/src/components/filter/criteriaBased/CriteriaBasedFilterForm.tsx b/src/components/filter/criteriaBased/CriteriaBasedFilterForm.tsx index bbeba175..c6075932 100644 --- a/src/components/filter/criteriaBased/CriteriaBasedFilterForm.tsx +++ b/src/components/filter/criteriaBased/CriteriaBasedFilterForm.tsx @@ -4,8 +4,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { useFormContext } from 'react-hook-form'; -import { Box } from '@mui/material'; import FilterProperties, { filterPropertiesYupSchema } from './FilterProperties'; import FieldConstants from '../../../utils/constants/fieldConstants'; import yup from '../../../utils/yupConfig'; @@ -13,8 +11,6 @@ import CriteriaBasedForm from './CriteriaBasedForm'; import { getCriteriaBasedFormData, getCriteriaBasedSchema } from './criteriaBasedFilterUtils'; import { FILTER_EQUIPMENTS } from '../utils/filterFormUtils'; import { FreePropertiesTypes } from './FilterFreeProperties'; -import InputWithPopupConfirmation from '../../inputs/reactHookForm/selectInputs/InputWithPopupConfirmation'; -import SelectInput from '../../inputs/reactHookForm/selectInputs/SelectInput'; export const criteriaBasedFilterSchema = getCriteriaBasedSchema({ [FieldConstants.ENERGY_SOURCE]: yup.string().nullable(), @@ -27,59 +23,14 @@ export const criteriaBasedFilterEmptyFormData = getCriteriaBasedFormData(null, { [FreePropertiesTypes.FREE_FILTER_PROPERTIES]: [], }); -const styles = { - ScrollableContainer: { - position: 'relative', - '&::after': { - content: '""', - clear: 'both', - display: 'block', - }, - }, - ScrollableContent: { - paddingTop: '10px', - position: 'absolute', - width: '100%', - height: '100%', - overflow: 'auto', - }, -}; - function CriteriaBasedFilterForm() { - const { getValues, setValue } = useFormContext(); - const defaultValues: Record = criteriaBasedFilterEmptyFormData[FieldConstants.CRITERIA_BASED]; - - const openConfirmationPopup = () => { - return JSON.stringify(getValues(FieldConstants.CRITERIA_BASED)) !== JSON.stringify(defaultValues); - }; - - const handleResetOnConfirmation = () => { - Object.keys(defaultValues).forEach((field) => - setValue(`${FieldConstants.CRITERIA_BASED}.${field}`, defaultValues[field]) - ); - }; - return ( - <> - - - - - - - - - - + + + ); } diff --git a/src/components/filter/criteriaBased/CriteriaBasedForm.tsx b/src/components/filter/criteriaBased/CriteriaBasedForm.tsx index 08403491..e1126989 100644 --- a/src/components/filter/criteriaBased/CriteriaBasedForm.tsx +++ b/src/components/filter/criteriaBased/CriteriaBasedForm.tsx @@ -5,18 +5,42 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { useWatch } from 'react-hook-form'; -import { Grid } from '@mui/material'; -import { useEffect } from 'react'; +import { useFormContext, useWatch } from 'react-hook-form'; +import { Box, Grid } from '@mui/material'; +import { ReactElement, useEffect } from 'react'; import FieldConstants from '../../../utils/constants/fieldConstants'; import { FormEquipment } from '../utils/filterFormUtils'; import { useSnackMessage } from '../../../hooks/useSnackMessage'; +import InputWithPopupConfirmation from '../../inputs/reactHookForm/selectInputs/InputWithPopupConfirmation'; +import SelectInput from '../../inputs/reactHookForm/selectInputs/SelectInput'; export interface CriteriaBasedFormProps { equipments: Record; + defaultValues: Record; + children?: ReactElement; } -function CriteriaBasedForm({ equipments }: Readonly) { +const styles = { + ScrollableContainer: { + paddingY: '12px', + position: 'relative', + '&::after': { + content: '""', + clear: 'both', + display: 'block', + }, + }, + ScrollableContent: { + paddingY: '12px', + position: 'absolute', + width: '100%', + height: '100%', + overflow: 'auto', + }, +}; + +function CriteriaBasedForm({ equipments, defaultValues, children }: Readonly) { + const { getValues, setValue } = useFormContext(); const { snackError } = useSnackMessage(); const watchEquipmentType = useWatch({ @@ -31,20 +55,49 @@ function CriteriaBasedForm({ equipments }: Readonly) { } }, [snackError, equipments, watchEquipmentType]); + const openConfirmationPopup = () => { + return JSON.stringify(getValues(FieldConstants.CRITERIA_BASED)) !== JSON.stringify(defaultValues); + }; + + const handleResetOnConfirmation = () => { + Object.keys(defaultValues).forEach((field) => + setValue(`${FieldConstants.CRITERIA_BASED}.${field}`, defaultValues[field]) + ); + }; + return ( - - {watchEquipmentType && - equipments[watchEquipmentType] && - equipments[watchEquipmentType].fields.map((equipment: any, index: number) => { - const EquipmentForm = equipment.renderer; - const uniqueKey = `${watchEquipmentType}-${index}`; - return ( - - - - ); - })} - + <> + + + + + + + {watchEquipmentType && + equipments[watchEquipmentType] && + equipments[watchEquipmentType].fields.map((equipment: any, index: number) => { + const EquipmentForm = equipment.renderer; + const uniqueKey = `${watchEquipmentType}-${index}`; + return ( + + + + ); + })} + {children} + + + + ); } From 1b3d7d289a3057d79c75fc23387fa12fece03017 Mon Sep 17 00:00:00 2001 From: Mathieu DEHARBE Date: Wed, 2 Oct 2024 13:12:53 +0200 Subject: [PATCH 14/18] min height Signed-off-by: Mathieu DEHARBE --- src/components/filter/criteriaBased/CriteriaBasedForm.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/filter/criteriaBased/CriteriaBasedForm.tsx b/src/components/filter/criteriaBased/CriteriaBasedForm.tsx index e1126989..2ee040cd 100644 --- a/src/components/filter/criteriaBased/CriteriaBasedForm.tsx +++ b/src/components/filter/criteriaBased/CriteriaBasedForm.tsx @@ -35,6 +35,7 @@ const styles = { position: 'absolute', width: '100%', height: '100%', + minHeight: '200px', overflow: 'auto', }, }; From 83985bc897ef69e5a5ea60899e54dea0ec4f3cc6 Mon Sep 17 00:00:00 2001 From: Mathieu DEHARBE Date: Wed, 9 Oct 2024 17:11:37 +0200 Subject: [PATCH 15/18] migrate network modification list display Signed-off-by: Mathieu DEHARBE --- demo/src/app.jsx | 4 + .../customMuiDialog/CustomMuiDialog.tsx | 2 +- src/hooks/useModificationLabelComputer.tsx | 108 +++++++++++ src/index.ts | 3 + .../en/networkModificationsLocaleEn.ts | 66 +++++++ .../fr/networkModificationsLocaleFr.ts | 69 +++++++ src/utils/types/modificationType.ts | 168 ++++++++++++++++++ 7 files changed, 419 insertions(+), 1 deletion(-) create mode 100644 src/hooks/useModificationLabelComputer.tsx create mode 100644 src/translations/en/networkModificationsLocaleEn.ts create mode 100644 src/translations/fr/networkModificationsLocaleFr.ts create mode 100644 src/utils/types/modificationType.ts diff --git a/demo/src/app.jsx b/demo/src/app.jsx index 6d355e66..b4d02fd1 100644 --- a/demo/src/app.jsx +++ b/demo/src/app.jsx @@ -75,6 +75,8 @@ import { TopBar, treeview_finder_en, treeview_finder_fr, + network_modifications_locale_en, + network_modifications_locale_fr, useSnackMessage, } from '../../src'; @@ -128,6 +130,7 @@ const messages = { ...card_error_boundary_en, ...flat_parameters_en, ...multiple_selection_dialog_en, + ...network_modifications_locale_en, ...inputs_en, ...translations.en, }, @@ -147,6 +150,7 @@ const messages = { ...card_error_boundary_fr, ...flat_parameters_fr, ...multiple_selection_dialog_fr, + ...network_modifications_locale_fr, ...inputs_fr, ...translations.fr, }, diff --git a/src/components/dialogs/customMuiDialog/CustomMuiDialog.tsx b/src/components/dialogs/customMuiDialog/CustomMuiDialog.tsx index 85214848..5083eaa8 100644 --- a/src/components/dialogs/customMuiDialog/CustomMuiDialog.tsx +++ b/src/components/dialogs/customMuiDialog/CustomMuiDialog.tsx @@ -44,7 +44,7 @@ const styles = { dialogPaperFullHeight: { '.MuiDialog-paper': { width: 'auto', - minWidth: '1100px', + minWidth: '1100px', // TODO : turn this into a parameter ?? margin: 'auto', height: '95vh', }, diff --git a/src/hooks/useModificationLabelComputer.tsx b/src/hooks/useModificationLabelComputer.tsx new file mode 100644 index 00000000..821f588b --- /dev/null +++ b/src/hooks/useModificationLabelComputer.tsx @@ -0,0 +1,108 @@ +/** + * Copyright (c) 2024, RTE (http://www.rte-france.com) + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +import { useIntl } from 'react-intl'; +import { useCallback } from 'react'; +import { UUID } from 'crypto'; +import { EQUIPMENT_TYPE } from '../utils/types/equipmentType'; +import { MODIFICATION_TYPES } from '../utils/types/modificationType'; + +export interface NetworkModificationMetadata { + uuid: UUID; + type: string; + date: Date; + stashed: boolean; + activated: boolean; + messageType: string; + messageValues: string; +} + +interface ModificationValues { + equipmentId: string; + action: string; + energizedVoltageLevelId: string; + equipmentAttributeName: string; + equipmentAttributeValue: string; +} + +const getOperatingStatusModificationValues = (modification: ModificationValues, withFormat: boolean) => { + return { + action: modification.action, + energizedEnd: modification.energizedVoltageLevelId, + computedLabel: withFormat ? {modification.equipmentId} : modification.equipmentId, + }; +}; +const getEquipmentAttributeModificationValues = (modification: ModificationValues, withFormat: boolean) => { + return { + equipmentAttributeName: modification.equipmentAttributeName, + equipmentAttributeValue: modification.equipmentAttributeValue, + computedLabel: withFormat ? {modification.equipmentId} : modification.equipmentId, + }; +}; + +const useModificationLabelComputer = () => { + const intl = useIntl(); + + const getLabel = useCallback( + (modif: NetworkModificationMetadata) => { + const modificationMetadata = JSON.parse(modif.messageValues); + + switch (modif.messageType) { + case MODIFICATION_TYPES.LINE_SPLIT_WITH_VOLTAGE_LEVEL.type: + return modificationMetadata.lineToSplitId; + case MODIFICATION_TYPES.LINE_ATTACH_TO_VOLTAGE_LEVEL.type: + return modificationMetadata.lineToAttachToId; + case MODIFICATION_TYPES.LINES_ATTACH_TO_SPLIT_LINES.type: + return modificationMetadata.attachedLineId; + case MODIFICATION_TYPES.DELETE_VOLTAGE_LEVEL_ON_LINE.type: + return `${modificationMetadata.lineToAttachTo1Id}/${modificationMetadata.lineToAttachTo2Id}`; + case MODIFICATION_TYPES.DELETE_ATTACHING_LINE.type: + return `${modificationMetadata.attachedLineId}/${modificationMetadata.lineToAttachTo1Id}/${modificationMetadata.lineToAttachTo2Id}`; + case MODIFICATION_TYPES.TABULAR_MODIFICATION.type: + return intl.formatMessage({ + id: `network_modifications.tabular.${modificationMetadata.tabularModificationType}`, + }); + case MODIFICATION_TYPES.BY_FILTER_DELETION.type: + return intl.formatMessage({ + id: + modificationMetadata.equipmentType === EQUIPMENT_TYPE.HVDC_LINE + ? 'Hvdc' + : modificationMetadata.equipmentType, + }); + case MODIFICATION_TYPES.TABULAR_CREATION.type: + return intl.formatMessage({ + id: `network_modifications.tabular.${modificationMetadata.tabularCreationType}`, + }); + default: + return modificationMetadata.equipmentId || ''; + } + }, + [intl] + ); + + const computeLabel = useCallback( + (modif: NetworkModificationMetadata, withFormat = true) => { + const modificationValues = JSON.parse(modif.messageValues); + + switch (modif.messageType) { + case MODIFICATION_TYPES.OPERATING_STATUS_MODIFICATION.type: + return getOperatingStatusModificationValues(modificationValues, withFormat); + case MODIFICATION_TYPES.EQUIPMENT_ATTRIBUTE_MODIFICATION.type: + return getEquipmentAttributeModificationValues(modificationValues, withFormat); + default: + return { + computedLabel: withFormat ? {getLabel(modif)} : getLabel(modif), + }; + } + }, + [getLabel] + ); + + return { computeLabel }; +}; + +export default useModificationLabelComputer; diff --git a/src/index.ts b/src/index.ts index a68a3aab..a62b947f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -163,6 +163,8 @@ export { default as flat_parameters_en } from './translations/en/flatParametersE export { default as flat_parameters_fr } from './translations/fr/flatParametersFr'; export { default as multiple_selection_dialog_en } from './translations/en/multipleSelectionDialogEn'; export { default as multiple_selection_dialog_fr } from './translations/fr/multipleSelectionDialogFr'; +export { default as network_modifications_locale_en } from './translations/en/networkModificationsLocaleEn'; +export { default as network_modifications_locale_fr } from './translations/fr/networkModificationsLocaleFr'; export { default as common_button_en } from './translations/en/commonButtonEn'; export { default as common_button_fr } from './translations/fr/commonButtonFr'; export { default as directory_items_input_en } from './translations/en/directoryItemsInputEn'; @@ -179,6 +181,7 @@ export type { UseSnackMessageReturn } from './hooks/useSnackMessage'; export { default as useDebounce } from './hooks/useDebounce'; export { default as usePrevious } from './hooks/usePrevious'; export { default as useConfidentialityWarning } from './hooks/useConfidentialityWarning'; +export { default as useModificationLabelComputer } from './hooks/useModificationLabelComputer'; export { default as usePredefinedProperties } from './hooks/usePredefinedProperties'; export { default as useStateBoolean } from './hooks/customStates/useStateBoolean'; export type { UseStateBooleanReturn } from './hooks/customStates/useStateBoolean'; diff --git a/src/translations/en/networkModificationsLocaleEn.ts b/src/translations/en/networkModificationsLocaleEn.ts new file mode 100644 index 00000000..f15b4eeb --- /dev/null +++ b/src/translations/en/networkModificationsLocaleEn.ts @@ -0,0 +1,66 @@ +/** + * Copyright (c) 2024, RTE (http://www.rte-france.com) + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +const networkModificationsLocaleEn = { + 'network_modifications.modificationsCount': + '{hide, select, false {{count, plural, =0 {no modification} =1 {{count} modification} other {{count} modifications}}} other {...}}', + 'network_modifications.EQUIPMENT_DELETION': 'Deletion of {computedLabel}', + 'network_modifications.BY_FILTER_DELETION': 'By filter deletion ({computedLabel})', + 'network_modifications.SUBSTATION_CREATION': 'Creating substation {computedLabel}', + 'network_modifications.SUBSTATION_MODIFICATION': 'Modifying substation {computedLabel}', + 'network_modifications.VOLTAGE_LEVEL_CREATION': 'Creating voltage level {computedLabel}', + 'network_modifications.VOLTAGE_LEVEL_MODIFICATION': 'Modifying voltage level {computedLabel}', + 'network_modifications.LINE_SPLIT_WITH_VOLTAGE_LEVEL': 'Splitting a line {computedLabel}', + 'network_modifications.LINE_ATTACH_TO_VOLTAGE_LEVEL': 'Attaching line {computedLabel}', + 'network_modifications.LINES_ATTACH_TO_SPLIT_LINES': 'Attaching lines to splitting lines {computedLabel}', + 'network_modifications.LOAD_SCALING': 'Load scaling {computedLabel}', + 'network_modifications.DELETE_VOLTAGE_LEVEL_ON_LINE': 'Deleting a voltage level on a line {computedLabel}', + 'network_modifications.DELETE_ATTACHING_LINE': 'Deleting attaching line {computedLabel}', + 'network_modifications.LOAD_CREATION': 'Creating load {computedLabel}', + 'network_modifications.LOAD_MODIFICATION': 'Modifying load {computedLabel}', + 'network_modifications.BATTERY_CREATION': 'Creating battery {computedLabel}', + 'network_modifications.BATTERY_MODIFICATION': 'Modifying battery {computedLabel}', + 'network_modifications.GENERATOR_CREATION': 'Creating generator {computedLabel}', + 'network_modifications.GENERATOR_MODIFICATION': 'Modifying generator {computedLabel}', + 'network_modifications.LINE_CREATION': 'Creating line {computedLabel}', + 'network_modifications.LINE_MODIFICATION': 'Modifying line {computedLabel}', + 'network_modifications.TWO_WINDINGS_TRANSFORMER_CREATION': 'Creating 2 windings transformer {computedLabel}', + 'network_modifications.TWO_WINDINGS_TRANSFORMER_MODIFICATION': 'Modifying 2 windings transformer {computedLabel}', + 'network_modifications.OPERATING_STATUS_MODIFICATION': + '{action, select, TRIP {Trip {computedLabel}} LOCKOUT {Lock out {computedLabel}} ENERGISE_END_ONE {Energise {computedLabel} on {energizedEnd}} ENERGISE_END_TWO {Energise {computedLabel} on {energizedEnd}} SWITCH_ON {Switch on {computedLabel}} other {Equipment operating status modification {computedLabel}}}', + 'network_modifications.SHUNT_COMPENSATOR_CREATION': 'Creating shunt compensator {computedLabel}', + 'network_modifications.SHUNT_COMPENSATOR_MODIFICATION': 'Modifying shunt compensator {computedLabel}', + 'network_modifications.GENERATOR_SCALING': 'Generator scaling {computedLabel}', + 'network_modifications.VSC_CREATION': 'Creating HVDC (VSC) {computedLabel}', + 'network_modifications.VSC_MODIFICATION': 'Modifing HVDC (VSC) {computedLabel}', + 'network_modifications.GROOVY_SCRIPT': 'Modification by script', + 'network_modifications.EQUIPMENT_ATTRIBUTE_MODIFICATION': + '{equipmentAttributeName, select, open {{equipmentAttributeValue, select, true {Open {computedLabel}} other {Close {computedLabel}}}} other {Equipment modification {computedLabel}}}', + 'network_modifications.creatingModification': 'Creating modification ...', + 'network_modifications.deletingModification': 'Deleting modification ...', + 'network_modifications.updatingModification': 'Updating modification ...', + 'network_modifications.stashingModification': 'Stashing modification ...', + 'network_modifications.restoringModification': 'Restoring modification ...', + 'network_modifications.modifications': 'Updating modification list ...', + 'network_modifications.GENERATION_DISPATCH': 'Generation dispatch {computedLabel}', + 'network_modifications.VOLTAGE_INIT_MODIFICATION': 'Voltage profile initialization {computedLabel}', + 'network_modifications.TABULAR_MODIFICATION': 'Tabular modification - {computedLabel}', + 'network_modifications.tabular.GENERATOR_MODIFICATION': 'generator modifications', + 'network_modifications.tabular.LOAD_MODIFICATION': 'load modifications', + 'network_modifications.BY_FORMULA_MODIFICATION': 'Modification by formula {computedLabel}', + 'network_modifications.MODIFICATION_BY_ASSIGNMENT': 'Modification by filter {computedLabel}', + 'network_modifications.tabular.LINE_MODIFICATION': 'line modifications', + 'network_modifications.tabular.BATTERY_MODIFICATION': 'battery modifications', + 'network_modifications.tabular.VOLTAGE_LEVEL_MODIFICATION': 'voltage level modifications', + 'network_modifications.tabular.TWO_WINDINGS_TRANSFORMER_MODIFICATION': 'two windings transformer modifications', + 'network_modifications.tabular.SHUNT_COMPENSATOR_MODIFICATION': 'linear shunt compensator modifications', + 'network_modifications.tabular.SUBSTATION_MODIFICATION': 'substation modifications', + 'network_modifications.TABULAR_CREATION': 'Tabular creation - {computedLabel}', + 'network_modifications.tabular.GENERATOR_CREATION': 'generator creations', +}; + +export default networkModificationsLocaleEn; diff --git a/src/translations/fr/networkModificationsLocaleFr.ts b/src/translations/fr/networkModificationsLocaleFr.ts new file mode 100644 index 00000000..372458e0 --- /dev/null +++ b/src/translations/fr/networkModificationsLocaleFr.ts @@ -0,0 +1,69 @@ +/** + * Copyright (c) 2024, RTE (http://www.rte-france.com) + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +const networkModificationsLocaleFr = { + 'network_modifications.modificationsCount': + '{hide, select, false {{count, plural, =0 {aucune modification} =1 {# modification} other {# modifications}}} other {...}}', + 'network_modifications.EQUIPMENT_DELETION': 'Suppression de {computedLabel}', + 'network_modifications.BY_FILTER_DELETION': 'Suppression par filtre ({computedLabel})', + 'network_modifications.SUBSTATION_CREATION': 'Création du site {computedLabel}', + 'network_modifications.SUBSTATION_MODIFICATION': 'Modification du site {computedLabel}', + 'network_modifications.VOLTAGE_LEVEL_CREATION': 'Création du poste {computedLabel}', + 'network_modifications.VOLTAGE_LEVEL_MODIFICATION': 'Modification du poste {computedLabel}', + 'network_modifications.LINE_SPLIT_WITH_VOLTAGE_LEVEL': "Création d'une coupure {computedLabel}", + 'network_modifications.LINE_ATTACH_TO_VOLTAGE_LEVEL': "Création d'un piquage {computedLabel}", + 'network_modifications.LINES_ATTACH_TO_SPLIT_LINES': 'Passage de piquage en coupure {computedLabel}', + 'network_modifications.LOAD_SCALING': 'Variation plan de consommation {computedLabel}', + 'network_modifications.DELETE_VOLTAGE_LEVEL_ON_LINE': "Suppression d'une coupure {computedLabel}", + 'network_modifications.DELETE_ATTACHING_LINE': "Suppression d'un piquage {computedLabel}", + 'network_modifications.LOAD_CREATION': 'Création de la charge {computedLabel}', + 'network_modifications.LOAD_MODIFICATION': 'Modification de la charge {computedLabel}', + 'network_modifications.BATTERY_CREATION': 'Création de batterie {computedLabel}', + 'network_modifications.BATTERY_MODIFICATION': 'Modification de batterie {computedLabel}', + 'network_modifications.GENERATOR_CREATION': 'Création du générateur {computedLabel}', + 'network_modifications.GENERATOR_MODIFICATION': 'Modification du générateur {computedLabel}', + 'network_modifications.LINE_CREATION': 'Création de la ligne {computedLabel}', + 'network_modifications.LINE_MODIFICATION': 'Modification de la ligne {computedLabel}', + 'network_modifications.TWO_WINDINGS_TRANSFORMER_CREATION': + 'Création du transformateur à 2 enroulements {computedLabel}', + 'network_modifications.TWO_WINDINGS_TRANSFORMER_MODIFICATION': + 'Modification du transformateur à 2 enroulements {computedLabel}', + 'network_modifications.OPERATING_STATUS_MODIFICATION': + "{action, select, TRIP {Déclenchement de {computedLabel}} LOCKOUT {Consignation de {computedLabel}} ENERGISE_END_ONE {Mise sous tension à vide de {computedLabel} depuis {energizedEnd}} ENERGISE_END_TWO {Mise sous tension à vide de {computedLabel} depuis {energizedEnd}} SWITCH_ON {Mise en service de {computedLabel}} other {Modification du statut opérationnel de l'équipement {computedLabel}}}", + 'network_modifications.SHUNT_COMPENSATOR_CREATION': "Création d'un moyen de compensation {computedLabel}", + 'network_modifications.SHUNT_COMPENSATOR_MODIFICATION': "Modification d'un moyen de compensation {computedLabel}", + 'network_modifications.GENERATOR_SCALING': 'Variation plan de production {computedLabel}', + 'network_modifications.VSC_CREATION': 'Création de la HVDC (VSC) {computedLabel}', + 'network_modifications.VSC_MODIFICATION': 'Modification de la HVDC (VSC) {computedLabel}', + 'network_modifications.GROOVY_SCRIPT': 'Modification par script', + 'network_modifications.EQUIPMENT_ATTRIBUTE_MODIFICATION': + "{equipmentAttributeName, select, open {{equipmentAttributeValue, select, true {Ouverture de {computedLabel}} other {Fermeture de {computedLabel}}}} other {Modification de l'equipement {computedLabel}}}", + 'network_modifications.creatingModification': 'Création de la modification en cours ...', + 'network_modifications.deletingModification': 'Suppression de la modification en cours ...', + 'network_modifications.updatingModification': 'Mise à jour de la modification en cours ...', + 'network_modifications.stashingModification': 'Mise en corbeille de la modification en cours ...', + 'network_modifications.restoringModification': 'Restauration de la modification en cours ...', + 'network_modifications.modifications': 'Mise à jour de la liste des modifications en cours ...', + 'network_modifications.GENERATION_DISPATCH': 'Démarrage de groupes {computedLabel}', + 'network_modifications.VOLTAGE_INIT_MODIFICATION': 'Initialisation du plan de tension {computedLabel}', + 'network_modifications.TABULAR_MODIFICATION': 'Modification tabulaire - {computedLabel}', + 'network_modifications.tabular.GENERATOR_MODIFICATION': 'modifications de générateurs', + 'network_modifications.tabular.LOAD_MODIFICATION': 'modifications de consommations', + 'network_modifications.BY_FORMULA_MODIFICATION': 'Modification par formule {computedLabel}', + 'network_modifications.MODIFICATION_BY_ASSIGNMENT': 'Modification par filtre {computedLabel}', + 'network_modifications.tabular.LINE_MODIFICATION': 'modifications de lignes', + 'network_modifications.tabular.BATTERY_MODIFICATION': 'modifications de batteries', + 'network_modifications.tabular.VOLTAGE_LEVEL_MODIFICATION': 'modifications de postes', + 'network_modifications.tabular.TWO_WINDINGS_TRANSFORMER_MODIFICATION': + 'modifications de transformateurs à 2 enroulements', + 'network_modifications.tabular.SHUNT_COMPENSATOR_MODIFICATION': 'modifications de MCS linéaires', + 'network_modifications.tabular.SUBSTATION_MODIFICATION': 'modifications de sites', + 'network_modifications.TABULAR_CREATION': 'Création tabulaire - {computedLabel}', + 'network_modifications.tabular.GENERATOR_CREATION': 'créations de générateurs', +}; + +export default networkModificationsLocaleFr; diff --git a/src/utils/types/modificationType.ts b/src/utils/types/modificationType.ts new file mode 100644 index 00000000..299e5ea0 --- /dev/null +++ b/src/utils/types/modificationType.ts @@ -0,0 +1,168 @@ +/** + * Copyright (c) 2023, RTE (http://www.rte-france.com) + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +export enum ModificationType { + GROOVY_SCRIPT = 'GROOVY_SCRIPT', + LOAD_CREATION = 'LOAD_CREATION', + LOAD_MODIFICATION = 'LOAD_MODIFICATION', + BATTERY_CREATION = 'BATTERY_CREATION', + BATTERY_MODIFICATION = 'BATTERY_MODIFICATION', + GENERATOR_CREATION = 'GENERATOR_CREATION', + GENERATOR_MODIFICATION = 'GENERATOR_MODIFICATION', + LINE_CREATION = 'LINE_CREATION', + LINE_MODIFICATION = 'LINE_MODIFICATION', + SUBSTATION_CREATION = 'SUBSTATION_CREATION', + SUBSTATION_MODIFICATION = 'SUBSTATION_MODIFICATION', + VOLTAGE_LEVEL_CREATION = 'VOLTAGE_LEVEL_CREATION', + VOLTAGE_LEVEL_MODIFICATION = 'VOLTAGE_LEVEL_MODIFICATION', + SHUNT_COMPENSATOR_CREATION = 'SHUNT_COMPENSATOR_CREATION', + SHUNT_COMPENSATOR_MODIFICATION = 'SHUNT_COMPENSATOR_MODIFICATION', + TWO_WINDINGS_TRANSFORMER_CREATION = 'TWO_WINDINGS_TRANSFORMER_CREATION', + TWO_WINDINGS_TRANSFORMER_MODIFICATION = 'TWO_WINDINGS_TRANSFORMER_MODIFICATION', + VSC_CREATION = 'VSC_CREATION', + EQUIPMENT_DELETION = 'EQUIPMENT_DELETION', + BY_FILTER_DELETION = 'BY_FILTER_DELETION', + LINE_SPLIT_WITH_VOLTAGE_LEVEL = 'LINE_SPLIT_WITH_VOLTAGE_LEVEL', + LINE_ATTACH_TO_VOLTAGE_LEVEL = 'LINE_ATTACH_TO_VOLTAGE_LEVEL', + LINES_ATTACH_TO_SPLIT_LINES = 'LINES_ATTACH_TO_SPLIT_LINES', + OPERATING_STATUS_MODIFICATION = 'OPERATING_STATUS_MODIFICATION', + EQUIPMENT_ATTRIBUTE_MODIFICATION = 'EQUIPMENT_ATTRIBUTE_MODIFICATION', + LOAD_SCALING = 'LOAD_SCALING', + DELETE_VOLTAGE_LEVEL_ON_LINE = 'DELETE_VOLTAGE_LEVEL_ON_LINE', + DELETE_ATTACHING_LINE = 'DELETE_ATTACHING_LINE', + GENERATOR_SCALING = 'GENERATOR_SCALING', + GENERATION_DISPATCH = 'GENERATION_DISPATCH', + VOLTAGE_INIT_MODIFICATION = 'VOLTAGE_INIT_MODIFICATION', + CONVERTER_STATION_CREATION = 'CONVERTER_STATION_CREATION', + TABULAR_MODIFICATION = 'TABULAR_MODIFICATION', + BY_FORMULA_MODIFICATION = 'BY_FORMULA_MODIFICATION', + MODIFICATION_BY_ASSIGNMENT = 'MODIFICATION_BY_ASSIGNMENT', + TABULAR_CREATION = 'TABULAR_CREATION', + VSC_MODIFICATION = 'VSC_MODIFICATION', + CONVERTER_STATION_MODIFICATION = 'CONVERTER_STATION_MODIFICATION', + COMPOSITE_MODIFICATION = 'COMPOSITE_MODIFICATION', +} + +export const MODIFICATION_TYPES = { + GROOVY_SCRIPT: { + type: ModificationType.GROOVY_SCRIPT, + }, + LOAD_CREATION: { + type: ModificationType.LOAD_CREATION, + }, + LOAD_MODIFICATION: { + type: ModificationType.LOAD_MODIFICATION, + }, + BATTERY_CREATION: { + type: ModificationType.BATTERY_CREATION, + }, + BATTERY_MODIFICATION: { + type: ModificationType.BATTERY_MODIFICATION, + }, + GENERATOR_CREATION: { + type: ModificationType.GENERATOR_CREATION, + }, + GENERATOR_MODIFICATION: { + type: ModificationType.GENERATOR_MODIFICATION, + }, + LINE_CREATION: { + type: ModificationType.LINE_CREATION, + }, + LINE_MODIFICATION: { + type: ModificationType.LINE_MODIFICATION, + }, + SUBSTATION_CREATION: { + type: ModificationType.SUBSTATION_CREATION, + }, + SUBSTATION_MODIFICATION: { + type: ModificationType.SUBSTATION_MODIFICATION, + }, + VOLTAGE_LEVEL_CREATION: { + type: ModificationType.VOLTAGE_LEVEL_CREATION, + }, + VOLTAGE_LEVEL_MODIFICATION: { + type: ModificationType.VOLTAGE_LEVEL_MODIFICATION, + }, + SHUNT_COMPENSATOR_CREATION: { + type: ModificationType.SHUNT_COMPENSATOR_CREATION, + }, + SHUNT_COMPENSATOR_MODIFICATION: { + type: ModificationType.SHUNT_COMPENSATOR_MODIFICATION, + }, + TWO_WINDINGS_TRANSFORMER_CREATION: { + type: ModificationType.TWO_WINDINGS_TRANSFORMER_CREATION, + }, + TWO_WINDINGS_TRANSFORMER_MODIFICATION: { + type: ModificationType.TWO_WINDINGS_TRANSFORMER_MODIFICATION, + }, + VSC_CREATION: { + type: ModificationType.VSC_CREATION, + }, + EQUIPMENT_DELETION: { + type: ModificationType.EQUIPMENT_DELETION, + }, + BY_FILTER_DELETION: { + type: ModificationType.BY_FILTER_DELETION, + }, + LINE_SPLIT_WITH_VOLTAGE_LEVEL: { + type: ModificationType.LINE_SPLIT_WITH_VOLTAGE_LEVEL, + }, + LINE_ATTACH_TO_VOLTAGE_LEVEL: { + type: ModificationType.LINE_ATTACH_TO_VOLTAGE_LEVEL, + }, + LINES_ATTACH_TO_SPLIT_LINES: { + type: ModificationType.LINES_ATTACH_TO_SPLIT_LINES, + }, + OPERATING_STATUS_MODIFICATION: { + type: ModificationType.OPERATING_STATUS_MODIFICATION, + }, + EQUIPMENT_ATTRIBUTE_MODIFICATION: { + type: ModificationType.EQUIPMENT_ATTRIBUTE_MODIFICATION, + }, + LOAD_SCALING: { + type: ModificationType.LOAD_SCALING, + }, + DELETE_VOLTAGE_LEVEL_ON_LINE: { + type: ModificationType.DELETE_VOLTAGE_LEVEL_ON_LINE, + }, + DELETE_ATTACHING_LINE: { + type: ModificationType.DELETE_ATTACHING_LINE, + }, + GENERATOR_SCALING: { + type: ModificationType.GENERATOR_SCALING, + }, + GENERATION_DISPATCH: { + type: ModificationType.GENERATION_DISPATCH, + }, + VOLTAGE_INIT_MODIFICATION: { + type: ModificationType.VOLTAGE_INIT_MODIFICATION, + }, + CONVERTER_STATION_CREATION: { + type: ModificationType.CONVERTER_STATION_CREATION, + }, + TABULAR_MODIFICATION: { + type: ModificationType.TABULAR_MODIFICATION, + }, + BY_FORMULA_MODIFICATION: { + type: ModificationType.BY_FORMULA_MODIFICATION, + }, + MODIFICATION_BY_ASSIGNMENT: { + type: 'MODIFICATION_BY_ASSIGNMENT', + }, + TABULAR_CREATION: { + type: ModificationType.TABULAR_CREATION, + }, + VSC_MODIFICATION: { + type: ModificationType.VSC_MODIFICATION, + }, + CONVERTER_STATION_MODIFICATION: { + type: ModificationType.CONVERTER_STATION_MODIFICATION, + }, + COMPOSITE_MODIFICATION: { + type: ModificationType.COMPOSITE_MODIFICATION, + }, +}; From bde26d649e5ef4f161931b3f504affb86fad9e9e Mon Sep 17 00:00:00 2001 From: Mathieu DEHARBE Date: Wed, 9 Oct 2024 17:31:38 +0200 Subject: [PATCH 16/18] commit test Signed-off-by: Mathieu DEHARBE --- src/hooks/useModificationLabelComputer.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hooks/useModificationLabelComputer.tsx b/src/hooks/useModificationLabelComputer.tsx index 821f588b..8bdecefc 100644 --- a/src/hooks/useModificationLabelComputer.tsx +++ b/src/hooks/useModificationLabelComputer.tsx @@ -8,8 +8,8 @@ import { useIntl } from 'react-intl'; import { useCallback } from 'react'; import { UUID } from 'crypto'; -import { EQUIPMENT_TYPE } from '../utils/types/equipmentType'; import { MODIFICATION_TYPES } from '../utils/types/modificationType'; +import { EQUIPMENT_TYPE } from '../utils/types/equipmentType'; export interface NetworkModificationMetadata { uuid: UUID; From e321394861f7300662ac98e6daaa9b50ee91bb02 Mon Sep 17 00:00:00 2001 From: Mathieu DEHARBE Date: Tue, 22 Oct 2024 14:46:45 +0200 Subject: [PATCH 17/18] omissions Signed-off-by: Mathieu DEHARBE --- src/utils/types/index.ts | 1 + src/utils/types/modificationType.ts | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/src/utils/types/index.ts b/src/utils/types/index.ts index fcd99782..bb53009a 100644 --- a/src/utils/types/index.ts +++ b/src/utils/types/index.ts @@ -9,3 +9,4 @@ export * from './equipmentType'; export * from './equipmentTypes'; export * from './metadata'; export * from './types'; +export * from './modificationType'; diff --git a/src/utils/types/modificationType.ts b/src/utils/types/modificationType.ts index 299e5ea0..494a85ad 100644 --- a/src/utils/types/modificationType.ts +++ b/src/utils/types/modificationType.ts @@ -21,6 +21,7 @@ export enum ModificationType { VOLTAGE_LEVEL_MODIFICATION = 'VOLTAGE_LEVEL_MODIFICATION', SHUNT_COMPENSATOR_CREATION = 'SHUNT_COMPENSATOR_CREATION', SHUNT_COMPENSATOR_MODIFICATION = 'SHUNT_COMPENSATOR_MODIFICATION', + STATIC_VAR_COMPENSATOR_CREATION = 'STATIC_VAR_COMPENSATOR_CREATION', TWO_WINDINGS_TRANSFORMER_CREATION = 'TWO_WINDINGS_TRANSFORMER_CREATION', TWO_WINDINGS_TRANSFORMER_MODIFICATION = 'TWO_WINDINGS_TRANSFORMER_MODIFICATION', VSC_CREATION = 'VSC_CREATION', @@ -93,6 +94,9 @@ export const MODIFICATION_TYPES = { SHUNT_COMPENSATOR_MODIFICATION: { type: ModificationType.SHUNT_COMPENSATOR_MODIFICATION, }, + STATIC_VAR_COMPENSATOR_CREATION: { + type: ModificationType.STATIC_VAR_COMPENSATOR_CREATION, + }, TWO_WINDINGS_TRANSFORMER_CREATION: { type: ModificationType.TWO_WINDINGS_TRANSFORMER_CREATION, }, From d62d53456aac2e8379a81810eddbb7b4d7cc5c15 Mon Sep 17 00:00:00 2001 From: Mathieu DEHARBE Date: Wed, 30 Oct 2024 14:32:26 +0100 Subject: [PATCH 18/18] rename localization files Signed-off-by: Mathieu DEHARBE --- demo/src/app.jsx | 8 ++++---- src/translations/en/index.ts | 2 +- ...ModificationsLocaleEn.ts => networkModificationsEn.ts} | 2 +- src/translations/fr/index.ts | 2 +- ...ModificationsLocaleFr.ts => networkModificationsFr.ts} | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) rename src/translations/en/{networkModificationsLocaleEn.ts => networkModificationsEn.ts} (99%) rename src/translations/fr/{networkModificationsLocaleFr.ts => networkModificationsFr.ts} (99%) diff --git a/demo/src/app.jsx b/demo/src/app.jsx index bfae1df8..3579c85b 100644 --- a/demo/src/app.jsx +++ b/demo/src/app.jsx @@ -107,8 +107,8 @@ import { useSnackMessage, commonButtonEn, commonButtonFr, - networkModificationsLocaleEn, - networkModificationsLocaleFr, + networkModificationsEn, + networkModificationsFr, } from '../../src'; const messages = { @@ -129,7 +129,7 @@ const messages = { ...flatParametersEn, ...multipleSelectionDialogEn, ...commonButtonEn, - ...networkModificationsLocaleEn, + ...networkModificationsEn, ...inputsEn, ...translations.en, }, @@ -149,7 +149,7 @@ const messages = { ...cardErrorBoundaryFr, ...flatParametersFr, ...commonButtonFr, - ...networkModificationsLocaleFr, + ...networkModificationsFr, ...multipleSelectionDialogFr, ...inputsFr, ...translations.fr, diff --git a/src/translations/en/index.ts b/src/translations/en/index.ts index aafe32d8..8cf8ed91 100644 --- a/src/translations/en/index.ts +++ b/src/translations/en/index.ts @@ -22,4 +22,4 @@ export * from './reportViewerEn'; export * from './tableEn'; export * from './topBarEn'; export * from './treeviewFinderEn'; -export * from './networkModificationsLocaleEn'; +export * from './networkModificationsEn'; diff --git a/src/translations/en/networkModificationsLocaleEn.ts b/src/translations/en/networkModificationsEn.ts similarity index 99% rename from src/translations/en/networkModificationsLocaleEn.ts rename to src/translations/en/networkModificationsEn.ts index 1c5e9306..c12e4be3 100644 --- a/src/translations/en/networkModificationsLocaleEn.ts +++ b/src/translations/en/networkModificationsEn.ts @@ -5,7 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -export const networkModificationsLocaleEn = { +export const networkModificationsEn = { 'network_modifications.modificationsCount': '{hide, select, false {{count, plural, =0 {no modification} =1 {{count} modification} other {{count} modifications}}} other {...}}', 'network_modifications.EQUIPMENT_DELETION': 'Deletion of {computedLabel}', diff --git a/src/translations/fr/index.ts b/src/translations/fr/index.ts index 50ad1933..15c7d60a 100644 --- a/src/translations/fr/index.ts +++ b/src/translations/fr/index.ts @@ -22,4 +22,4 @@ export * from './reportViewerFr'; export * from './tableFr'; export * from './topBarFr'; export * from './treeviewFinderFr'; -export * from './networkModificationsLocaleFr'; +export * from './networkModificationsFr'; diff --git a/src/translations/fr/networkModificationsLocaleFr.ts b/src/translations/fr/networkModificationsFr.ts similarity index 99% rename from src/translations/fr/networkModificationsLocaleFr.ts rename to src/translations/fr/networkModificationsFr.ts index 77c9ff62..8c7a10ca 100644 --- a/src/translations/fr/networkModificationsLocaleFr.ts +++ b/src/translations/fr/networkModificationsFr.ts @@ -5,7 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -export const networkModificationsLocaleFr = { +export const networkModificationsFr = { 'network_modifications.modificationsCount': '{hide, select, false {{count, plural, =0 {aucune modification} =1 {# modification} other {# modifications}}} other {...}}', 'network_modifications.EQUIPMENT_DELETION': 'Suppression de {computedLabel}',