@gridsuite/commons-ui 0.211.0 → 0.213.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/filter/expert/ExpertFilterForm.d.ts +1 -1
- package/dist/components/filter/expert/ExpertFilterForm.js +2 -13
- package/dist/components/filter/explicitNaming/ExplicitNamingFilterForm.js +7 -10
- package/dist/components/filter/utils/filterApi.js +3 -3
- package/dist/components/index.js +16 -0
- package/dist/components/network-modification-table/columns-definition.d.ts +0 -2
- package/dist/components/network-modification-table/index.js +16 -0
- package/dist/components/network-modification-table/network-modifications-table.d.ts +9 -5
- package/dist/components/network-modification-table/network-modifications-table.js +56 -13
- package/dist/components/network-modification-table/renderers/cell-renderers.d.ts +23 -0
- package/dist/components/network-modification-table/renderers/cell-renderers.js +103 -0
- package/dist/components/network-modification-table/renderers/description-cell.d.ts +9 -0
- package/dist/components/network-modification-table/renderers/description-cell.js +73 -0
- package/dist/components/network-modification-table/renderers/index.d.ts +4 -0
- package/dist/components/network-modification-table/renderers/index.js +17 -1
- package/dist/components/network-modification-table/renderers/name-cell.d.ts +2 -2
- package/dist/components/network-modification-table/renderers/name-cell.js +28 -9
- package/dist/components/network-modification-table/renderers/root-network-chip-cell.d.ts +13 -0
- package/dist/components/network-modification-table/renderers/root-network-chip-cell.js +138 -0
- package/dist/components/network-modification-table/renderers/select-cell.js +2 -2
- package/dist/components/network-modification-table/renderers/select-header-cell.js +2 -2
- package/dist/components/network-modification-table/renderers/switch-cell.d.ts +9 -0
- package/dist/components/network-modification-table/renderers/switch-cell.js +63 -0
- package/dist/index.js +24 -3
- package/dist/services/index.js +4 -1
- package/dist/services/networkModification.d.ts +8 -1
- package/dist/services/networkModification.js +45 -1
- package/dist/translations/en/filterEn.d.ts +0 -1
- package/dist/translations/en/filterEn.js +0 -1
- package/dist/translations/en/filterExpertEn.d.ts +0 -2
- package/dist/translations/en/filterExpertEn.js +0 -2
- package/dist/translations/en/networkModificationsEn.d.ts +1 -0
- package/dist/translations/en/networkModificationsEn.js +4 -3
- package/dist/translations/fr/filterExpertFr.d.ts +0 -2
- package/dist/translations/fr/filterExpertFr.js +0 -2
- package/dist/translations/fr/filterFr.d.ts +0 -1
- package/dist/translations/fr/filterFr.js +0 -1
- package/dist/translations/fr/networkModificationsFr.d.ts +1 -0
- package/dist/translations/fr/networkModificationsFr.js +4 -3
- package/dist/utils/constants/index.js +2 -1
- package/dist/utils/constants/translationKeys.d.ts +1 -0
- package/dist/utils/constants/translationKeys.js +2 -0
- package/dist/utils/index.js +4 -2
- package/dist/utils/types/equipmentTypes.d.ts +1 -0
- package/dist/utils/types/equipmentTypes.js +5 -1
- package/dist/utils/types/index.js +2 -1
- package/dist/utils/types/network-modification-types.d.ts +6 -0
- package/package.json +1 -1
|
@@ -2,9 +2,9 @@ import { jsxs, Fragment, jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { useCallback, useMemo } from "react";
|
|
3
3
|
import { formatQuery } from "react-querybuilder/formatQuery";
|
|
4
4
|
import { useWatch } from "react-hook-form";
|
|
5
|
-
import * as yup from "yup";
|
|
6
5
|
import { v4 } from "uuid";
|
|
7
6
|
import { Box } from "@mui/material";
|
|
7
|
+
import "../../../utils/yupConfig.js";
|
|
8
8
|
import { testQuery } from "./expertFilterUtils.js";
|
|
9
9
|
import { EXPERT_FILTER_QUERY, RULES, OPERATOR_OPTIONS, COMBINATOR_OPTIONS, EXPERT_FILTER_FIELDS, EXPERT_FILTER_EQUIPMENTS } from "./expertFilterConstants.js";
|
|
10
10
|
import { FieldConstants } from "../../../utils/constants/fieldConstants.js";
|
|
@@ -18,7 +18,6 @@ import "../../../utils/conversionUtils.js";
|
|
|
18
18
|
import "../../../utils/types/equipmentType.js";
|
|
19
19
|
import { FieldType } from "../../../utils/types/fieldType.js";
|
|
20
20
|
import "@mui/icons-material";
|
|
21
|
-
import "../../../utils/yupConfig.js";
|
|
22
21
|
import "react-intl";
|
|
23
22
|
import "../../treeViewFinder/TreeViewFinder.js";
|
|
24
23
|
import "localized-countries";
|
|
@@ -30,6 +29,7 @@ import { filterStyles } from "../HeaderFilterForm.js";
|
|
|
30
29
|
import "../../overflowableText/OverflowableText.js";
|
|
31
30
|
import "../../inputs/reactHookForm/provider/CustomFormProvider.js";
|
|
32
31
|
import { useCustomFormContext } from "../../inputs/reactHookForm/provider/useCustomFormContext.js";
|
|
32
|
+
import * as yup from "yup";
|
|
33
33
|
import "../../inputs/reactHookForm/agGridTable/BottomRightButtons.js";
|
|
34
34
|
import "../../customAGGrid/customAggrid.js";
|
|
35
35
|
import "ag-grid-community";
|
|
@@ -44,17 +44,6 @@ import "@material-symbols/svg-400/outlined/add_notes.svg?react";
|
|
|
44
44
|
import "../../inputs/reactHookForm/expandableInput/ExpandableInput.js";
|
|
45
45
|
import "@react-querybuilder/material";
|
|
46
46
|
import "../../inputs/reactQueryBuilder/PropertyValueEditor.js";
|
|
47
|
-
yup.setLocale({
|
|
48
|
-
mixed: {
|
|
49
|
-
required: "YupRequired",
|
|
50
|
-
notType: ({ type }) => {
|
|
51
|
-
if (type === "number") {
|
|
52
|
-
return "YupNotTypeNumber";
|
|
53
|
-
}
|
|
54
|
-
return "YupNotTypeDefault";
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
47
|
import '../../../assets/ExpertFilterForm.css';function isSupportedEquipmentType(equipmentType) {
|
|
59
48
|
return Object.values(EXPERT_FILTER_EQUIPMENTS).map((equipments) => equipments.id).includes(equipmentType);
|
|
60
49
|
}
|
|
@@ -8,7 +8,7 @@ import { FieldConstants } from "../../../utils/constants/fieldConstants.js";
|
|
|
8
8
|
import "../../../utils/yupConfig.js";
|
|
9
9
|
import { CustomAgGridTable } from "../../inputs/reactHookForm/agGridTable/CustomAgGridTable.js";
|
|
10
10
|
import { SelectInput } from "../../inputs/reactHookForm/selectInputs/SelectInput.js";
|
|
11
|
-
import {
|
|
11
|
+
import { isInjection } from "../../../utils/types/equipmentTypes.js";
|
|
12
12
|
import { NumericEditor } from "../../inputs/reactHookForm/agGridTable/cellEditors/numericEditor.js";
|
|
13
13
|
import { InputWithPopupConfirmation } from "../../inputs/reactHookForm/selectInputs/InputWithPopupConfirmation.js";
|
|
14
14
|
import { toFloatOrNullValue } from "../../inputs/reactHookForm/utils/functions.js";
|
|
@@ -50,9 +50,6 @@ import "../../inputs/reactQueryBuilder/CustomReactQueryBuilder.js";
|
|
|
50
50
|
import "../../inputs/reactQueryBuilder/PropertyValueEditor.js";
|
|
51
51
|
import "react-querybuilder";
|
|
52
52
|
import * as yup from "yup";
|
|
53
|
-
function isGeneratorOrLoad(equipmentType) {
|
|
54
|
-
return equipmentType === Generator.type || equipmentType === Load.type;
|
|
55
|
-
}
|
|
56
53
|
const explicitNamingFilterSchema = {
|
|
57
54
|
[FILTER_EQUIPMENTS_ATTRIBUTES]: yup.array().of(
|
|
58
55
|
yup.object().shape({
|
|
@@ -60,7 +57,7 @@ const explicitNamingFilterSchema = {
|
|
|
60
57
|
[DISTRIBUTION_KEY]: yup.number().nullable()
|
|
61
58
|
})
|
|
62
59
|
).compact((row) => !row[DISTRIBUTION_KEY] && !row[FieldConstants.EQUIPMENT_ID]).min(1, "emptyFilterError").when([FieldConstants.EQUIPMENT_TYPE], {
|
|
63
|
-
is: (equipmentType) =>
|
|
60
|
+
is: (equipmentType) => isInjection(equipmentType),
|
|
64
61
|
then: (innerSchema) => innerSchema.test("noKeyWithoutId", "distributionKeyWithMissingIdError", (array) => {
|
|
65
62
|
return !array.some((row) => !row[FieldConstants.EQUIPMENT_ID]);
|
|
66
63
|
}).test("ifOneKeyThenKeyEverywhere", "missingDistributionKeyError", (array) => {
|
|
@@ -100,7 +97,7 @@ function ExplicitNamingFilterForm({
|
|
|
100
97
|
});
|
|
101
98
|
}
|
|
102
99
|
}, [snackError, watchEquipmentType]);
|
|
103
|
-
const
|
|
100
|
+
const forGeneratorBatteryOrLoad = isInjection(watchEquipmentType);
|
|
104
101
|
useEffect(() => {
|
|
105
102
|
if (sourceFilterForExplicitNamingConversion) {
|
|
106
103
|
setValue(FieldConstants.EQUIPMENT_TYPE, sourceFilterForExplicitNamingConversion.equipmentType);
|
|
@@ -120,7 +117,7 @@ function ExplicitNamingFilterForm({
|
|
|
120
117
|
valueParser: (params) => params.newValue?.trim() ?? null
|
|
121
118
|
}
|
|
122
119
|
];
|
|
123
|
-
if (
|
|
120
|
+
if (forGeneratorBatteryOrLoad) {
|
|
124
121
|
newColumnDefs.push({
|
|
125
122
|
headerName: intl.formatMessage({ id: DISTRIBUTION_KEY }),
|
|
126
123
|
field: DISTRIBUTION_KEY,
|
|
@@ -131,7 +128,7 @@ function ExplicitNamingFilterForm({
|
|
|
131
128
|
});
|
|
132
129
|
}
|
|
133
130
|
return newColumnDefs;
|
|
134
|
-
}, [intl,
|
|
131
|
+
}, [intl, forGeneratorBatteryOrLoad]);
|
|
135
132
|
const defaultColDef = useMemo(
|
|
136
133
|
() => ({
|
|
137
134
|
suppressMovable: true
|
|
@@ -140,11 +137,11 @@ function ExplicitNamingFilterForm({
|
|
|
140
137
|
);
|
|
141
138
|
const csvFileHeaders = useMemo(() => {
|
|
142
139
|
const newCsvFileHeaders = [intl.formatMessage({ id: FieldConstants.EQUIPMENT_ID })];
|
|
143
|
-
if (
|
|
140
|
+
if (forGeneratorBatteryOrLoad) {
|
|
144
141
|
newCsvFileHeaders.push(intl.formatMessage({ id: DISTRIBUTION_KEY }));
|
|
145
142
|
}
|
|
146
143
|
return newCsvFileHeaders;
|
|
147
|
-
}, [intl,
|
|
144
|
+
}, [intl, forGeneratorBatteryOrLoad]);
|
|
148
145
|
const getDataFromCsvFile = useCallback((csvData) => {
|
|
149
146
|
if (csvData) {
|
|
150
147
|
return csvData.map((value) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FieldConstants } from "../../../utils/constants/fieldConstants.js";
|
|
2
|
-
import {
|
|
2
|
+
import { isInjection } from "../../../utils/types/equipmentTypes.js";
|
|
3
3
|
import { exportExpertRules } from "../expert/expertFilterUtils.js";
|
|
4
4
|
import { DISTRIBUTION_KEY, FilterType } from "../constants/FilterConstants.js";
|
|
5
5
|
import { createFilter, saveFilter } from "../../../services/explore.js";
|
|
@@ -11,8 +11,8 @@ import "@mui/icons-material";
|
|
|
11
11
|
import "../../../utils/yupConfig.js";
|
|
12
12
|
const saveExplicitNamingFilter = (tableValues, isFilterCreation, equipmentType, name, description, id, setCreateFilterErr, handleClose, activeDirectory, token) => {
|
|
13
13
|
let cleanedTableValues;
|
|
14
|
-
const
|
|
15
|
-
if (
|
|
14
|
+
const isEquipmentAnInjection = isInjection(equipmentType);
|
|
15
|
+
if (isEquipmentAnInjection) {
|
|
16
16
|
cleanedTableValues = tableValues.map((row) => ({
|
|
17
17
|
[FieldConstants.EQUIPMENT_ID]: row[FieldConstants.EQUIPMENT_ID],
|
|
18
18
|
[DISTRIBUTION_KEY]: row[DISTRIBUTION_KEY]
|
package/dist/components/index.js
CHANGED
|
@@ -269,12 +269,16 @@ import { COLUMNS_WITHOUT_BORDER, DEPTH_CELL_WIDTH, DROP_FORBIDDEN_INDICATOR_BOTT
|
|
|
269
269
|
import { AUTO_EXTENSIBLE_COLUMNS, BASE_MODIFICATION_TABLE_COLUMNS, computeTagMinSize } from "./network-modification-table/columns-definition.js";
|
|
270
270
|
import { NetworkModificationsTable } from "./network-modification-table/network-modifications-table.js";
|
|
271
271
|
import { useModificationsDragAndDrop } from "./network-modification-table/use-modifications-drag-and-drop.js";
|
|
272
|
+
import { DescriptionCellRenderer, DragHandleRenderer, NameCellRenderer, NameHeaderRenderer, RootNetworkCellRenderer, RootNetworkHeaderRenderer, SelectCellRenderer, SelectHeaderRenderer, SwitchCellRenderer } from "./network-modification-table/renderers/cell-renderers.js";
|
|
272
273
|
import { DepthBox } from "./network-modification-table/renderers/depth-box.js";
|
|
274
|
+
import { DescriptionCell } from "./network-modification-table/renderers/description-cell.js";
|
|
273
275
|
import { DragHandleCell } from "./network-modification-table/renderers/drag-handle-cell.js";
|
|
274
276
|
import { NameCell } from "./network-modification-table/renderers/name-cell.js";
|
|
275
277
|
import { NetworkModificationEditorNameHeader } from "./network-modification-table/renderers/network-modification-node-editor-name-header.js";
|
|
278
|
+
import { RootNetworkChipCell } from "./network-modification-table/renderers/root-network-chip-cell.js";
|
|
276
279
|
import { SelectCell } from "./network-modification-table/renderers/select-cell.js";
|
|
277
280
|
import { SelectHeaderCell } from "./network-modification-table/renderers/select-header-cell.js";
|
|
281
|
+
import { SwitchCell } from "./network-modification-table/renderers/switch-cell.js";
|
|
278
282
|
import { DragCloneRow } from "./network-modification-table/row/drag-row-clone.js";
|
|
279
283
|
import { ModificationRow } from "./network-modification-table/row/modification-row.js";
|
|
280
284
|
import { MAX_COMPOSITE_NESTING_DEPTH, fetchSubModificationsForExpandedRows, findAllLoadedCompositeModifications, findModificationInTree, formatToComposedModification, isCompositeModification, mergeSubModificationsIntoTree, moveSubModificationInTree, updateModificationFieldInTree, updateSubModificationsOfACompositeInTree } from "./network-modification-table/utils.js";
|
|
@@ -385,6 +389,8 @@ export {
|
|
|
385
389
|
DataType,
|
|
386
390
|
DefaultCellRenderer,
|
|
387
391
|
DepthBox,
|
|
392
|
+
DescriptionCell,
|
|
393
|
+
DescriptionCellRenderer,
|
|
388
394
|
DescriptionField,
|
|
389
395
|
DescriptionInput,
|
|
390
396
|
DescriptionModificationDialog,
|
|
@@ -398,6 +404,7 @@ export {
|
|
|
398
404
|
DndTableBottomRightButtons,
|
|
399
405
|
DragCloneRow,
|
|
400
406
|
DragHandleCell,
|
|
407
|
+
DragHandleRenderer,
|
|
401
408
|
DynamicMarginCalculationInline,
|
|
402
409
|
DynamicSecurityAnalysisInline,
|
|
403
410
|
DynamicSimulationInline,
|
|
@@ -516,6 +523,8 @@ export {
|
|
|
516
523
|
NODE_CLUSTER_FILTER_IDS,
|
|
517
524
|
NadPositionsGenerationMode,
|
|
518
525
|
NameCell,
|
|
526
|
+
NameCellRenderer,
|
|
527
|
+
NameHeaderRenderer,
|
|
519
528
|
NetworkModificationEditorNameHeader,
|
|
520
529
|
NetworkModificationNameCellRenderer,
|
|
521
530
|
NetworkModificationsTable,
|
|
@@ -590,6 +599,9 @@ export {
|
|
|
590
599
|
ReadOnlyInput,
|
|
591
600
|
RemoveButton,
|
|
592
601
|
ResizeHandle,
|
|
602
|
+
RootNetworkCellRenderer,
|
|
603
|
+
RootNetworkChipCell,
|
|
604
|
+
RootNetworkHeaderRenderer,
|
|
593
605
|
RuleValueEditor,
|
|
594
606
|
SCENARIO_DURATION,
|
|
595
607
|
SELECTED,
|
|
@@ -624,8 +636,10 @@ export {
|
|
|
624
636
|
SecurityAnalysisParametersDialog,
|
|
625
637
|
SecurityAnalysisParametersInline,
|
|
626
638
|
SelectCell,
|
|
639
|
+
SelectCellRenderer,
|
|
627
640
|
SelectClearable,
|
|
628
641
|
SelectHeaderCell,
|
|
642
|
+
SelectHeaderRenderer,
|
|
629
643
|
SelectInput,
|
|
630
644
|
SelectWithConfirmationInput,
|
|
631
645
|
SensiBranchesTabValues,
|
|
@@ -647,6 +661,8 @@ export {
|
|
|
647
661
|
SubstationCreationForm,
|
|
648
662
|
SubstationLayout,
|
|
649
663
|
SubstationModificationForm,
|
|
664
|
+
SwitchCell,
|
|
665
|
+
SwitchCellRenderer,
|
|
650
666
|
SwitchInput,
|
|
651
667
|
SwitchKind,
|
|
652
668
|
SwitchWithLabel,
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { NetworkModificationEditorNameHeaderProps } from './renderers';
|
|
2
1
|
export declare const computeTagMinSize: (tag: string) => number;
|
|
3
2
|
export declare const BASE_MODIFICATION_TABLE_COLUMNS: {
|
|
4
3
|
DRAG_HANDLE: {
|
|
@@ -23,4 +22,3 @@ export declare const BASE_MODIFICATION_TABLE_COLUMNS: {
|
|
|
23
22
|
};
|
|
24
23
|
};
|
|
25
24
|
export declare const AUTO_EXTENSIBLE_COLUMNS: string[];
|
|
26
|
-
export type NameHeaderProps = Omit<NetworkModificationEditorNameHeaderProps, 'modificationCount'>;
|
|
@@ -2,12 +2,16 @@ import { COLUMNS_WITHOUT_BORDER, DEPTH_CELL_WIDTH, DROP_FORBIDDEN_INDICATOR_BOTT
|
|
|
2
2
|
import { AUTO_EXTENSIBLE_COLUMNS, BASE_MODIFICATION_TABLE_COLUMNS, computeTagMinSize } from "./columns-definition.js";
|
|
3
3
|
import { NetworkModificationsTable } from "./network-modifications-table.js";
|
|
4
4
|
import { useModificationsDragAndDrop } from "./use-modifications-drag-and-drop.js";
|
|
5
|
+
import { DescriptionCellRenderer, DragHandleRenderer, NameCellRenderer, NameHeaderRenderer, RootNetworkCellRenderer, RootNetworkHeaderRenderer, SelectCellRenderer, SelectHeaderRenderer, SwitchCellRenderer } from "./renderers/cell-renderers.js";
|
|
5
6
|
import { DepthBox } from "./renderers/depth-box.js";
|
|
7
|
+
import { DescriptionCell } from "./renderers/description-cell.js";
|
|
6
8
|
import { DragHandleCell } from "./renderers/drag-handle-cell.js";
|
|
7
9
|
import { NameCell } from "./renderers/name-cell.js";
|
|
8
10
|
import { NetworkModificationEditorNameHeader } from "./renderers/network-modification-node-editor-name-header.js";
|
|
11
|
+
import { RootNetworkChipCell } from "./renderers/root-network-chip-cell.js";
|
|
9
12
|
import { SelectCell } from "./renderers/select-cell.js";
|
|
10
13
|
import { SelectHeaderCell } from "./renderers/select-header-cell.js";
|
|
14
|
+
import { SwitchCell } from "./renderers/switch-cell.js";
|
|
11
15
|
import { DragCloneRow } from "./row/drag-row-clone.js";
|
|
12
16
|
import { ModificationRow } from "./row/modification-row.js";
|
|
13
17
|
import { MAX_COMPOSITE_NESTING_DEPTH, fetchSubModificationsForExpandedRows, findAllLoadedCompositeModifications, findModificationInTree, formatToComposedModification, isCompositeModification, mergeSubModificationsIntoTree, moveSubModificationInTree, updateModificationFieldInTree, updateSubModificationsOfACompositeInTree } from "./utils.js";
|
|
@@ -21,16 +25,28 @@ export {
|
|
|
21
25
|
DROP_INDICATOR_BOTTOM,
|
|
22
26
|
DROP_INDICATOR_TOP,
|
|
23
27
|
DepthBox,
|
|
28
|
+
DescriptionCell,
|
|
29
|
+
DescriptionCellRenderer,
|
|
24
30
|
DragCloneRow,
|
|
25
31
|
DragHandleCell,
|
|
32
|
+
DragHandleRenderer,
|
|
26
33
|
MAX_COMPOSITE_NESTING_DEPTH,
|
|
27
34
|
MODIFICATION_ROW_HEIGHT,
|
|
28
35
|
ModificationRow,
|
|
29
36
|
NameCell,
|
|
37
|
+
NameCellRenderer,
|
|
38
|
+
NameHeaderRenderer,
|
|
30
39
|
NetworkModificationEditorNameHeader,
|
|
31
40
|
NetworkModificationsTable,
|
|
41
|
+
RootNetworkCellRenderer,
|
|
42
|
+
RootNetworkChipCell,
|
|
43
|
+
RootNetworkHeaderRenderer,
|
|
32
44
|
SelectCell,
|
|
45
|
+
SelectCellRenderer,
|
|
33
46
|
SelectHeaderCell,
|
|
47
|
+
SelectHeaderRenderer,
|
|
48
|
+
SwitchCell,
|
|
49
|
+
SwitchCellRenderer,
|
|
34
50
|
computeTagMinSize,
|
|
35
51
|
createCellBorderColor,
|
|
36
52
|
createCellContentWrapperSx,
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Dispatch, SetStateAction } from 'react';
|
|
2
2
|
import { ColumnDef } from '@tanstack/react-table';
|
|
3
3
|
import { UUID } from 'node:crypto';
|
|
4
4
|
import { NetworkModificationEditorNameHeaderProps } from './renderers';
|
|
5
|
-
import {
|
|
6
|
-
import { ComposedModificationMetadata, NetworkModificationMetadata } from '../../utils';
|
|
5
|
+
import { ExcludedNetworkModifications, RootNetworkRowInfo, ComposedModificationMetadata, NetworkModificationMetadata } from '../../utils';
|
|
7
6
|
interface NetworkModificationsTableProps extends Omit<NetworkModificationEditorNameHeaderProps, 'modificationCount'> {
|
|
8
7
|
modifications: NetworkModificationMetadata[];
|
|
9
8
|
handleCellClick: (modification: NetworkModificationMetadata) => void;
|
|
@@ -11,10 +10,15 @@ interface NetworkModificationsTableProps extends Omit<NetworkModificationEditorN
|
|
|
11
10
|
onRowDragStart: () => void;
|
|
12
11
|
onRowDragEnd: () => void;
|
|
13
12
|
onRowSelected: (selectedRows: ComposedModificationMetadata[]) => void;
|
|
14
|
-
|
|
13
|
+
columns: ColumnDef<ComposedModificationMetadata>[];
|
|
15
14
|
highlightedModificationUuid: UUID | null;
|
|
16
15
|
studyUuid: UUID | null;
|
|
17
16
|
currentNodeId?: UUID;
|
|
17
|
+
currentRootNetworkUuid?: UUID;
|
|
18
|
+
rootNetworks?: RootNetworkRowInfo[];
|
|
19
|
+
modificationsToExclude?: ExcludedNetworkModifications[];
|
|
20
|
+
setModificationsToExclude?: Dispatch<SetStateAction<ExcludedNetworkModifications[]>>;
|
|
21
|
+
isDisabled?: boolean;
|
|
18
22
|
}
|
|
19
|
-
export declare function NetworkModificationsTable({ modifications, handleCellClick, isRowDragDisabled, onRowDragStart, onRowDragEnd, onRowSelected,
|
|
23
|
+
export declare function NetworkModificationsTable({ modifications, handleCellClick, isRowDragDisabled, onRowDragStart, onRowDragEnd, onRowSelected, columns, highlightedModificationUuid, studyUuid, currentNodeId, currentRootNetworkUuid, rootNetworks, modificationsToExclude, setModificationsToExclude, isDisabled, isImpactedByNotification, notificationMessageId, isFetchingModifications, pendingState, }: Readonly<NetworkModificationsTableProps>): import("react/jsx-runtime").JSX.Element;
|
|
20
24
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useRef, useState,
|
|
2
|
+
import { useRef, useState, useEffect, useCallback, useMemo } from "react";
|
|
3
3
|
import { useTheme, Box, Table, TableHead, TableRow, TableCell, TableBody } from "@mui/material";
|
|
4
4
|
import { useReactTable, getExpandedRowModel, getCoreRowModel, flexRender } from "@tanstack/react-table";
|
|
5
5
|
import { DragDropContext, Droppable } from "@hello-pangea/dnd";
|
|
@@ -26,11 +26,19 @@ function NetworkModificationsTable({
|
|
|
26
26
|
onRowDragStart,
|
|
27
27
|
onRowDragEnd,
|
|
28
28
|
onRowSelected,
|
|
29
|
-
|
|
29
|
+
columns,
|
|
30
30
|
highlightedModificationUuid,
|
|
31
31
|
studyUuid = null,
|
|
32
32
|
currentNodeId = void 0,
|
|
33
|
-
|
|
33
|
+
currentRootNetworkUuid,
|
|
34
|
+
rootNetworks,
|
|
35
|
+
modificationsToExclude,
|
|
36
|
+
setModificationsToExclude,
|
|
37
|
+
isDisabled = false,
|
|
38
|
+
isImpactedByNotification,
|
|
39
|
+
notificationMessageId,
|
|
40
|
+
isFetchingModifications,
|
|
41
|
+
pendingState
|
|
34
42
|
}) {
|
|
35
43
|
const theme = useTheme();
|
|
36
44
|
const containerRef = useRef(null);
|
|
@@ -42,15 +50,6 @@ function NetworkModificationsTable({
|
|
|
42
50
|
modifications: composedModifications,
|
|
43
51
|
onRowSelected
|
|
44
52
|
});
|
|
45
|
-
const columns = useMemo(
|
|
46
|
-
() => createAllColumns(
|
|
47
|
-
isRowDragDisabled ?? false,
|
|
48
|
-
modifications.length,
|
|
49
|
-
nameHeaderProps,
|
|
50
|
-
setComposedModifications
|
|
51
|
-
),
|
|
52
|
-
[createAllColumns, isRowDragDisabled, modifications.length, nameHeaderProps]
|
|
53
|
-
);
|
|
54
53
|
useEffect(() => {
|
|
55
54
|
setComposedModifications((prevMods) => {
|
|
56
55
|
const nextMods = mergeSubModificationsIntoTree(formatToComposedModification(modifications), prevMods);
|
|
@@ -78,6 +77,50 @@ function NetworkModificationsTable({
|
|
|
78
77
|
return nextExpanded;
|
|
79
78
|
});
|
|
80
79
|
}, []);
|
|
80
|
+
const tableMeta = useMemo(
|
|
81
|
+
() => ({
|
|
82
|
+
context: {
|
|
83
|
+
studyUuid,
|
|
84
|
+
currentNodeId,
|
|
85
|
+
currentRootNetworkUuid,
|
|
86
|
+
rootNetworks
|
|
87
|
+
},
|
|
88
|
+
modifications: {
|
|
89
|
+
count: modifications.length,
|
|
90
|
+
toExclude: modificationsToExclude,
|
|
91
|
+
setToExclude: setModificationsToExclude
|
|
92
|
+
},
|
|
93
|
+
interaction: {
|
|
94
|
+
lastClickedRowId,
|
|
95
|
+
onRowSelected,
|
|
96
|
+
isRowDragDisabled
|
|
97
|
+
},
|
|
98
|
+
status: {
|
|
99
|
+
isImpactedByNotification,
|
|
100
|
+
notificationMessageId,
|
|
101
|
+
isFetchingModifications,
|
|
102
|
+
pendingState,
|
|
103
|
+
isDisabled
|
|
104
|
+
}
|
|
105
|
+
}),
|
|
106
|
+
[
|
|
107
|
+
studyUuid,
|
|
108
|
+
currentNodeId,
|
|
109
|
+
currentRootNetworkUuid,
|
|
110
|
+
rootNetworks,
|
|
111
|
+
modifications.length,
|
|
112
|
+
modificationsToExclude,
|
|
113
|
+
setModificationsToExclude,
|
|
114
|
+
lastClickedRowId,
|
|
115
|
+
onRowSelected,
|
|
116
|
+
isRowDragDisabled,
|
|
117
|
+
isImpactedByNotification,
|
|
118
|
+
notificationMessageId,
|
|
119
|
+
isFetchingModifications,
|
|
120
|
+
pendingState,
|
|
121
|
+
isDisabled
|
|
122
|
+
]
|
|
123
|
+
);
|
|
81
124
|
const table = useReactTable({
|
|
82
125
|
data: composedModifications,
|
|
83
126
|
columns,
|
|
@@ -92,7 +135,7 @@ function NetworkModificationsTable({
|
|
|
92
135
|
enableExpanding: true,
|
|
93
136
|
onExpandedChange: handleExpandRow,
|
|
94
137
|
onRowSelectionChange,
|
|
95
|
-
meta:
|
|
138
|
+
meta: tableMeta
|
|
96
139
|
});
|
|
97
140
|
const { rows, flatRows } = table.getRowModel();
|
|
98
141
|
useEffect(() => {
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { CellContext, HeaderContext } from '@tanstack/react-table';
|
|
2
|
+
import { ComposedModificationMetadata } from '../../../utils';
|
|
3
|
+
/**
|
|
4
|
+
* Cell/header renderers must keep a stable reference across renders to avoid
|
|
5
|
+
* unmounting/remounting cells and resetting local states. The renderers below are
|
|
6
|
+
* hoisted because they're reused by `createBaseColumns` and `createRootNetworksColumns`,
|
|
7
|
+
* factories called inside a hook — defining them inline there would produce fresh references.
|
|
8
|
+
*
|
|
9
|
+
* Dynamic values are routed via react-table's `meta`: table-wide via `table.options.meta`,
|
|
10
|
+
* per-column via `column.columnDef.meta`.
|
|
11
|
+
*/
|
|
12
|
+
type CCtx = CellContext<ComposedModificationMetadata, unknown>;
|
|
13
|
+
type HCtx = HeaderContext<ComposedModificationMetadata, unknown>;
|
|
14
|
+
export declare function DragHandleRenderer({ table }: CCtx): import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
export declare function SelectHeaderRenderer({ table }: HCtx): import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
export declare function SelectCellRenderer({ row, table }: CCtx): import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
export declare function NameHeaderRenderer({ table }: HCtx): import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
export declare function NameCellRenderer({ row, column }: CCtx): import("react/jsx-runtime").JSX.Element;
|
|
19
|
+
export declare function DescriptionCellRenderer({ row, table }: CCtx): import("react/jsx-runtime").JSX.Element;
|
|
20
|
+
export declare function SwitchCellRenderer({ row, table }: CCtx): import("react/jsx-runtime").JSX.Element;
|
|
21
|
+
export declare function RootNetworkHeaderRenderer({ column, table }: HCtx): import("react/jsx-runtime").JSX.Element | null;
|
|
22
|
+
export declare function RootNetworkCellRenderer({ row, column, table }: CCtx): import("react/jsx-runtime").JSX.Element | null;
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Box, Tooltip, Badge } from "@mui/material";
|
|
3
|
+
import { RemoveRedEye } from "@mui/icons-material";
|
|
4
|
+
import { FormattedMessage } from "react-intl";
|
|
5
|
+
import { DragHandleCell } from "./drag-handle-cell.js";
|
|
6
|
+
import { NameCell } from "./name-cell.js";
|
|
7
|
+
import { NetworkModificationEditorNameHeader } from "./network-modification-node-editor-name-header.js";
|
|
8
|
+
import { SelectCell } from "./select-cell.js";
|
|
9
|
+
import { SelectHeaderCell } from "./select-header-cell.js";
|
|
10
|
+
import { DescriptionCell } from "./description-cell.js";
|
|
11
|
+
import { SwitchCell } from "./switch-cell.js";
|
|
12
|
+
import { RootNetworkChipCell } from "./root-network-chip-cell.js";
|
|
13
|
+
import { networkModificationTableStyles, createRootNetworkChipCellSx } from "../network-modification-table-styles.js";
|
|
14
|
+
function DragHandleRenderer({ table }) {
|
|
15
|
+
return /* @__PURE__ */ jsx(DragHandleCell, { isRowDragDisabled: table.options.meta?.interaction.isRowDragDisabled ?? false });
|
|
16
|
+
}
|
|
17
|
+
function SelectHeaderRenderer({ table }) {
|
|
18
|
+
return /* @__PURE__ */ jsx(SelectHeaderCell, { table });
|
|
19
|
+
}
|
|
20
|
+
function SelectCellRenderer({ row, table }) {
|
|
21
|
+
return /* @__PURE__ */ jsx(SelectCell, { row, table });
|
|
22
|
+
}
|
|
23
|
+
function NameHeaderRenderer({ table }) {
|
|
24
|
+
const { meta } = table.options;
|
|
25
|
+
return /* @__PURE__ */ jsx(
|
|
26
|
+
NetworkModificationEditorNameHeader,
|
|
27
|
+
{
|
|
28
|
+
modificationCount: meta?.modifications.count ?? 0,
|
|
29
|
+
isImpactedByNotification: meta?.status.isImpactedByNotification ?? (() => false),
|
|
30
|
+
notificationMessageId: meta?.status.notificationMessageId,
|
|
31
|
+
isFetchingModifications: meta?.status.isFetchingModifications ?? false,
|
|
32
|
+
pendingState: meta?.status.pendingState ?? false
|
|
33
|
+
}
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
function NameCellRenderer({ row, column }) {
|
|
37
|
+
return /* @__PURE__ */ jsx(NameCell, { row, onChange: column.columnDef.meta?.onChange });
|
|
38
|
+
}
|
|
39
|
+
function DescriptionCellRenderer({ row, table }) {
|
|
40
|
+
const { meta } = table.options;
|
|
41
|
+
return /* @__PURE__ */ jsx(
|
|
42
|
+
DescriptionCell,
|
|
43
|
+
{
|
|
44
|
+
data: row.original,
|
|
45
|
+
studyUuid: meta?.context.studyUuid ?? null,
|
|
46
|
+
currentNodeId: meta?.context.currentNodeId,
|
|
47
|
+
isDisabled: meta?.status.isDisabled
|
|
48
|
+
}
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
function SwitchCellRenderer({ row, table }) {
|
|
52
|
+
const { meta } = table.options;
|
|
53
|
+
return /* @__PURE__ */ jsx(
|
|
54
|
+
SwitchCell,
|
|
55
|
+
{
|
|
56
|
+
data: row.original,
|
|
57
|
+
studyUuid: meta?.context.studyUuid ?? null,
|
|
58
|
+
currentNodeId: meta?.context.currentNodeId,
|
|
59
|
+
isDisabled: meta?.status.isDisabled
|
|
60
|
+
}
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
function RootNetworkHeaderRenderer({ column, table }) {
|
|
64
|
+
const { meta } = table.options;
|
|
65
|
+
const isCurrentRootNetwork = !!meta?.context.currentRootNetworkUuid && column.id === meta.context.currentRootNetworkUuid;
|
|
66
|
+
if (!isCurrentRootNetwork || (meta?.modifications.count ?? 0) < 1) {
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
const currentRootNetworkTag = meta?.context.rootNetworks?.find(
|
|
70
|
+
(r) => r.rootNetworkUuid === meta.context.currentRootNetworkUuid
|
|
71
|
+
)?.tag;
|
|
72
|
+
return /* @__PURE__ */ jsx(Box, { sx: networkModificationTableStyles.rootNetworkHeader, children: /* @__PURE__ */ jsx(Tooltip, { title: /* @__PURE__ */ jsx(FormattedMessage, { id: "visualizedRootNetwork", values: { tag: currentRootNetworkTag } }), children: /* @__PURE__ */ jsx(Badge, { overlap: "circular", color: "primary", variant: "dot", children: /* @__PURE__ */ jsx(RemoveRedEye, {}) }) }) });
|
|
73
|
+
}
|
|
74
|
+
function RootNetworkCellRenderer({ row, column, table }) {
|
|
75
|
+
const { meta } = table.options;
|
|
76
|
+
const rootNetwork = meta?.context.rootNetworks?.find((r) => r.rootNetworkUuid === column.id);
|
|
77
|
+
if (!rootNetwork || !meta?.modifications.toExclude || !meta.modifications.setToExclude) {
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
return /* @__PURE__ */ jsx(Box, { sx: createRootNetworkChipCellSx(row.original.activated), children: /* @__PURE__ */ jsx(
|
|
81
|
+
RootNetworkChipCell,
|
|
82
|
+
{
|
|
83
|
+
data: row.original,
|
|
84
|
+
studyUuid: meta?.context.studyUuid ?? null,
|
|
85
|
+
currentNodeId: meta?.context.currentNodeId,
|
|
86
|
+
rootNetwork,
|
|
87
|
+
modificationsToExclude: meta.modifications.toExclude,
|
|
88
|
+
setModificationsToExclude: meta.modifications.setToExclude,
|
|
89
|
+
isDisabled: meta?.status.isDisabled
|
|
90
|
+
}
|
|
91
|
+
) });
|
|
92
|
+
}
|
|
93
|
+
export {
|
|
94
|
+
DescriptionCellRenderer,
|
|
95
|
+
DragHandleRenderer,
|
|
96
|
+
NameCellRenderer,
|
|
97
|
+
NameHeaderRenderer,
|
|
98
|
+
RootNetworkCellRenderer,
|
|
99
|
+
RootNetworkHeaderRenderer,
|
|
100
|
+
SelectCellRenderer,
|
|
101
|
+
SelectHeaderRenderer,
|
|
102
|
+
SwitchCellRenderer
|
|
103
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { UUID } from 'node:crypto';
|
|
2
|
+
import { ComposedModificationMetadata } from '../../../utils';
|
|
3
|
+
export interface DescriptionCellProps {
|
|
4
|
+
data: ComposedModificationMetadata;
|
|
5
|
+
studyUuid: UUID | null;
|
|
6
|
+
currentNodeId?: UUID;
|
|
7
|
+
isDisabled?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare function DescriptionCell(props: DescriptionCellProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { jsxs, Fragment, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useCallback } from "react";
|
|
3
|
+
import { Tooltip, IconButton } from "@mui/material";
|
|
4
|
+
import { FormattedMessage } from "react-intl";
|
|
5
|
+
import "react-hook-form";
|
|
6
|
+
import "../../inputs/reactHookForm/provider/CustomFormProvider.js";
|
|
7
|
+
import { DescriptionModificationDialog } from "../../dialogs/descriptionModificationDialog/DescriptionModificationDialog.js";
|
|
8
|
+
import "../../dialogs/elementSaveDialog/ElementSaveDialog.js";
|
|
9
|
+
import "../../../utils/conversionUtils.js";
|
|
10
|
+
import "../../../utils/types/equipmentType.js";
|
|
11
|
+
import "@mui/icons-material";
|
|
12
|
+
import "../../../utils/yupConfig.js";
|
|
13
|
+
import { setModificationMetadata } from "../../../services/networkModification.js";
|
|
14
|
+
import "../../treeViewFinder/TreeViewFinder.js";
|
|
15
|
+
import "localized-countries";
|
|
16
|
+
import "localized-countries/data/fr";
|
|
17
|
+
import "localized-countries/data/en";
|
|
18
|
+
import "notistack";
|
|
19
|
+
import "@material-symbols/svg-400/outlined/left_panel_open.svg?react";
|
|
20
|
+
import "@material-symbols/svg-400/outlined/arrows_output.svg?react";
|
|
21
|
+
import "@material-symbols/svg-400/outlined/arrows_input.svg?react";
|
|
22
|
+
import "@material-symbols/svg-400/outlined/left_panel_close.svg?react";
|
|
23
|
+
import { EditNoteIcon } from "../../icons/EditNoteIcon.js";
|
|
24
|
+
import { createEditDescriptionStyle } from "../network-modification-table-styles.js";
|
|
25
|
+
function DescriptionCell(props) {
|
|
26
|
+
const { data, studyUuid, currentNodeId, isDisabled = false } = props;
|
|
27
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
28
|
+
const [openDescModificationDialog, setOpenDescModificationDialog] = useState(false);
|
|
29
|
+
const modificationUuid = data.uuid;
|
|
30
|
+
const { description } = data;
|
|
31
|
+
const empty = !description;
|
|
32
|
+
const updateModification = useCallback(
|
|
33
|
+
async (descriptionRecord) => {
|
|
34
|
+
setIsLoading(true);
|
|
35
|
+
return setModificationMetadata(studyUuid, currentNodeId, modificationUuid, {
|
|
36
|
+
description: descriptionRecord.description,
|
|
37
|
+
type: data.type
|
|
38
|
+
}).finally(() => {
|
|
39
|
+
setIsLoading(false);
|
|
40
|
+
});
|
|
41
|
+
},
|
|
42
|
+
[studyUuid, currentNodeId, modificationUuid, data.type]
|
|
43
|
+
);
|
|
44
|
+
const handleDescDialogClose = useCallback(() => {
|
|
45
|
+
setOpenDescModificationDialog(false);
|
|
46
|
+
}, []);
|
|
47
|
+
const handleModifyDescription = useCallback(() => {
|
|
48
|
+
setOpenDescModificationDialog(true);
|
|
49
|
+
}, []);
|
|
50
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
51
|
+
openDescModificationDialog && modificationUuid && /* @__PURE__ */ jsx(
|
|
52
|
+
DescriptionModificationDialog,
|
|
53
|
+
{
|
|
54
|
+
open: true,
|
|
55
|
+
description: description ?? "",
|
|
56
|
+
onClose: handleDescDialogClose,
|
|
57
|
+
updateElement: updateModification
|
|
58
|
+
}
|
|
59
|
+
),
|
|
60
|
+
/* @__PURE__ */ jsx(Tooltip, { title: description ?? /* @__PURE__ */ jsx(FormattedMessage, { id: "addDescription" }), arrow: true, enterDelay: 250, children: /* @__PURE__ */ jsx("span", { children: /* @__PURE__ */ jsx(
|
|
61
|
+
IconButton,
|
|
62
|
+
{
|
|
63
|
+
onClick: handleModifyDescription,
|
|
64
|
+
disabled: isLoading || isDisabled,
|
|
65
|
+
sx: createEditDescriptionStyle(data.description),
|
|
66
|
+
children: /* @__PURE__ */ jsx(EditNoteIcon, { empty })
|
|
67
|
+
}
|
|
68
|
+
) }) })
|
|
69
|
+
] });
|
|
70
|
+
}
|
|
71
|
+
export {
|
|
72
|
+
DescriptionCell
|
|
73
|
+
};
|
|
@@ -4,9 +4,13 @@
|
|
|
4
4
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
5
5
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
6
6
|
*/
|
|
7
|
+
export * from './cell-renderers';
|
|
7
8
|
export * from './depth-box';
|
|
9
|
+
export * from './description-cell';
|
|
8
10
|
export * from './drag-handle-cell';
|
|
9
11
|
export * from './name-cell';
|
|
10
12
|
export * from './network-modification-node-editor-name-header';
|
|
13
|
+
export * from './root-network-chip-cell';
|
|
11
14
|
export * from './select-cell';
|
|
12
15
|
export * from './select-header-cell';
|
|
16
|
+
export * from './switch-cell';
|
|
@@ -1,14 +1,30 @@
|
|
|
1
|
+
import { DescriptionCellRenderer, DragHandleRenderer, NameCellRenderer, NameHeaderRenderer, RootNetworkCellRenderer, RootNetworkHeaderRenderer, SelectCellRenderer, SelectHeaderRenderer, SwitchCellRenderer } from "./cell-renderers.js";
|
|
1
2
|
import { DepthBox } from "./depth-box.js";
|
|
3
|
+
import { DescriptionCell } from "./description-cell.js";
|
|
2
4
|
import { DragHandleCell } from "./drag-handle-cell.js";
|
|
3
5
|
import { NameCell } from "./name-cell.js";
|
|
4
6
|
import { NetworkModificationEditorNameHeader } from "./network-modification-node-editor-name-header.js";
|
|
7
|
+
import { RootNetworkChipCell } from "./root-network-chip-cell.js";
|
|
5
8
|
import { SelectCell } from "./select-cell.js";
|
|
6
9
|
import { SelectHeaderCell } from "./select-header-cell.js";
|
|
10
|
+
import { SwitchCell } from "./switch-cell.js";
|
|
7
11
|
export {
|
|
8
12
|
DepthBox,
|
|
13
|
+
DescriptionCell,
|
|
14
|
+
DescriptionCellRenderer,
|
|
9
15
|
DragHandleCell,
|
|
16
|
+
DragHandleRenderer,
|
|
10
17
|
NameCell,
|
|
18
|
+
NameCellRenderer,
|
|
19
|
+
NameHeaderRenderer,
|
|
11
20
|
NetworkModificationEditorNameHeader,
|
|
21
|
+
RootNetworkCellRenderer,
|
|
22
|
+
RootNetworkChipCell,
|
|
23
|
+
RootNetworkHeaderRenderer,
|
|
12
24
|
SelectCell,
|
|
13
|
-
|
|
25
|
+
SelectCellRenderer,
|
|
26
|
+
SelectHeaderCell,
|
|
27
|
+
SelectHeaderRenderer,
|
|
28
|
+
SwitchCell,
|
|
29
|
+
SwitchCellRenderer
|
|
14
30
|
};
|