@gridsuite/commons-ui 0.241.1 → 0.242.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/README.md +4 -0
- package/dist/components/composite/grid/grid-item.d.ts +2 -1
- package/dist/components/composite/grid/grid-item.js +9 -2
- package/dist/components/ui/inputs/checkbox-autocomplete/checkbox-autocomplete.d.ts +1 -2
- package/dist/features/index.js +87 -3
- package/dist/features/network-modification-table/index.js +2 -1
- package/dist/features/network-modification-table/use-modifications-drag-and-drop.js +2 -1
- package/dist/features/network-modification-table/utils.d.ts +1 -0
- package/dist/features/network-modification-table/utils.js +5 -1
- package/dist/features/network-modifications/battery/creation/BatteryCreationForm.js +3 -0
- package/dist/features/network-modifications/battery/creation/batteryCreation.utils.js +3 -0
- package/dist/features/network-modifications/battery/modification/BatteryDialogHeader.js +3 -0
- package/dist/features/network-modifications/battery/modification/BatteryDialogTabsContent.js +3 -0
- package/dist/features/network-modifications/battery/modification/batteryModification.utils.js +3 -0
- package/dist/features/network-modifications/common/connectivity/connectivityForm.utils.d.ts +71 -2
- package/dist/features/network-modifications/common/connectivity/connectivityForm.utils.js +26 -8
- package/dist/features/network-modifications/common/connectivity/index.js +3 -1
- package/dist/features/network-modifications/common/currentLimits/LimitsPane.d.ts +7 -0
- package/dist/features/network-modifications/common/currentLimits/LimitsPane.js +243 -0
- package/dist/features/network-modifications/common/currentLimits/LimitsTagChip.d.ts +9 -0
- package/dist/features/network-modifications/common/currentLimits/LimitsTagChip.js +29 -0
- package/dist/features/network-modifications/common/currentLimits/SelectedOperationalLimitGroup.d.ts +9 -0
- package/dist/features/network-modifications/common/currentLimits/SelectedOperationalLimitGroup.js +100 -0
- package/dist/features/network-modifications/common/currentLimits/index.d.ts +12 -0
- package/dist/features/network-modifications/common/currentLimits/index.js +47 -0
- package/dist/features/network-modifications/common/currentLimits/limits.types.d.ts +52 -0
- package/dist/features/network-modifications/common/currentLimits/limits.types.js +17 -0
- package/dist/features/network-modifications/common/currentLimits/limitsEditor/LimitsEditor.d.ts +10 -0
- package/dist/features/network-modifications/common/currentLimits/limitsEditor/LimitsEditor.js +285 -0
- package/dist/features/network-modifications/common/currentLimits/limitsEditor/LimitsPropertiesSideStack.d.ts +5 -0
- package/dist/features/network-modifications/common/currentLimits/limitsEditor/LimitsPropertiesSideStack.js +184 -0
- package/dist/features/network-modifications/common/currentLimits/limitsEditor/TemporaryLimitsTable.d.ts +14 -0
- package/dist/features/network-modifications/common/currentLimits/limitsEditor/TemporaryLimitsTable.js +166 -0
- package/dist/features/network-modifications/common/currentLimits/limitsEditor/index.d.ts +10 -0
- package/dist/features/network-modifications/common/currentLimits/limitsEditor/index.js +10 -0
- package/dist/features/network-modifications/common/currentLimits/limitsEditor/limitsChart.d.ts +11 -0
- package/dist/features/network-modifications/common/currentLimits/limitsEditor/limitsChart.js +177 -0
- package/dist/features/network-modifications/common/currentLimits/limitsPane.utils.d.ts +213 -0
- package/dist/features/network-modifications/common/currentLimits/limitsPane.utils.js +337 -0
- package/dist/features/network-modifications/common/currentLimits/operationalLimitsGroups/LimitsGroupsContextualMenu.d.ts +25 -0
- package/dist/features/network-modifications/common/currentLimits/operationalLimitsGroups/LimitsGroupsContextualMenu.js +92 -0
- package/dist/features/network-modifications/common/currentLimits/operationalLimitsGroups/LimitsPropertiesStack.d.ts +10 -0
- package/dist/features/network-modifications/common/currentLimits/operationalLimitsGroups/LimitsPropertiesStack.js +25 -0
- package/dist/features/network-modifications/common/currentLimits/operationalLimitsGroups/OperationalLimitsGroupTabLabel.d.ts +10 -0
- package/dist/features/network-modifications/common/currentLimits/operationalLimitsGroups/OperationalLimitsGroupTabLabel.js +73 -0
- package/dist/features/network-modifications/common/currentLimits/operationalLimitsGroups/OperationalLimitsGroups.d.ts +16 -0
- package/dist/features/network-modifications/common/currentLimits/operationalLimitsGroups/OperationalLimitsGroups.js +121 -0
- package/dist/features/network-modifications/common/currentLimits/operationalLimitsGroups/index.d.ts +11 -0
- package/dist/features/network-modifications/common/currentLimits/operationalLimitsGroups/index.js +12 -0
- package/dist/features/network-modifications/common/currentLimits/operationalLimitsGroups/operationalLimitsGroups.types.d.ts +71 -0
- package/dist/features/network-modifications/common/currentLimits/operationalLimitsGroups/operationalLimitsGroups.types.js +15 -0
- package/dist/features/network-modifications/common/currentLimits/operationalLimitsGroups/operationalLimitsGroupsStyles.d.ts +46 -0
- package/dist/features/network-modifications/common/currentLimits/operationalLimitsGroups/operationalLimitsGroupsStyles.js +45 -0
- package/dist/features/network-modifications/common/index.d.ts +1 -0
- package/dist/features/network-modifications/common/index.js +50 -2
- package/dist/features/network-modifications/common/measurements/branchActiveReactivePowerForm.utils.d.ts +11 -0
- package/dist/features/network-modifications/common/measurements/branchActiveReactivePowerForm.utils.js +6 -4
- package/dist/features/network-modifications/common/measurements/index.js +2 -1
- package/dist/features/network-modifications/common/reactiveLimits/reactiveCapabilityCurve/ReactiveCapabilityCurveTableForm.js +1 -1
- package/dist/features/network-modifications/common/voltageRegulation/VoltageRegulationForm.js +3 -7
- package/dist/features/network-modifications/equipmentDeletion/EquipmentDeletionForm.js +3 -0
- package/dist/features/network-modifications/generator/creation/GeneratorCreationForm.js +9 -6
- package/dist/features/network-modifications/generator/creation/generatorCreation.utils.js +3 -0
- package/dist/features/network-modifications/generator/modification/GeneratorDialogHeader.js +3 -0
- package/dist/features/network-modifications/generator/modification/GeneratorDialogTabsContent.js +9 -6
- package/dist/features/network-modifications/generator/modification/generatorModification.utils.js +3 -0
- package/dist/features/network-modifications/index.d.ts +1 -0
- package/dist/features/network-modifications/index.js +85 -2
- package/dist/features/network-modifications/line/catalog/index.d.ts +8 -0
- package/dist/features/network-modifications/line/catalog/index.js +14 -0
- package/dist/features/network-modifications/line/catalog/lineCatalog.type.d.ts +66 -0
- package/dist/features/network-modifications/line/catalog/lineCatalog.type.js +7 -0
- package/dist/features/network-modifications/line/catalog/segment.utils.d.ts +90 -0
- package/dist/features/network-modifications/line/catalog/segment.utils.js +100 -0
- package/dist/features/network-modifications/line/characteristics/LineCharacteristicsPane.d.ts +8 -0
- package/dist/features/network-modifications/line/characteristics/LineCharacteristicsPane.js +152 -0
- package/dist/features/network-modifications/line/characteristics/index.d.ts +9 -0
- package/dist/features/network-modifications/line/characteristics/index.js +9 -0
- package/dist/features/network-modifications/line/characteristics/lineCharacteristicsPane.types.d.ts +14 -0
- package/dist/features/network-modifications/line/characteristics/lineCharacteristicsPane.types.js +1 -0
- package/dist/features/network-modifications/line/characteristics/lineCharacteristicsPane.utils.d.ts +52 -0
- package/dist/features/network-modifications/line/characteristics/lineCharacteristicsPane.utils.js +53 -0
- package/dist/features/network-modifications/line/common/LineDialogHeader.d.ts +6 -0
- package/dist/features/network-modifications/line/common/LineDialogHeader.js +103 -0
- package/dist/features/network-modifications/line/common/LineDialogTabs.d.ts +9 -0
- package/dist/features/network-modifications/line/common/LineDialogTabs.js +61 -0
- package/dist/features/network-modifications/line/common/LineDialogTabsContent.d.ts +8 -0
- package/dist/features/network-modifications/line/common/LineDialogTabsContent.js +96 -0
- package/dist/features/network-modifications/line/common/LineForm.d.ts +6 -0
- package/dist/features/network-modifications/line/common/LineForm.js +50 -0
- package/dist/features/network-modifications/line/common/index.d.ts +12 -0
- package/dist/features/network-modifications/line/common/index.js +13 -0
- package/dist/features/network-modifications/line/common/line.types.d.ts +47 -0
- package/dist/features/network-modifications/line/common/line.types.js +1 -0
- package/dist/features/network-modifications/line/common/line.utils.d.ts +13 -0
- package/dist/features/network-modifications/line/common/line.utils.js +34 -0
- package/dist/features/network-modifications/line/creation/index.d.ts +8 -0
- package/dist/features/network-modifications/line/creation/index.js +7 -0
- package/dist/features/network-modifications/line/creation/lineCreation.types.d.ts +39 -0
- package/dist/features/network-modifications/line/creation/lineCreation.types.js +1 -0
- package/dist/features/network-modifications/line/creation/lineCreation.utils.d.ts +151 -0
- package/dist/features/network-modifications/line/creation/lineCreation.utils.js +172 -0
- package/dist/features/network-modifications/line/index.d.ts +10 -0
- package/dist/features/network-modifications/line/index.js +37 -0
- package/dist/features/network-modifications/load/common/LoadDialogHeader.js +3 -0
- package/dist/features/network-modifications/load/modification/loadModification.utils.js +3 -0
- package/dist/features/network-modifications/shunt-compensator/common/CharacteristicsForm.js +7 -6
- package/dist/features/network-modifications/shunt-compensator/creation/ShuntCompensatorCreationForm.js +3 -0
- package/dist/features/network-modifications/shunt-compensator/creation/shuntCompensatorCreation.utils.js +3 -0
- package/dist/features/network-modifications/shunt-compensator/modification/ShuntCompensatorModificationForm.js +3 -0
- package/dist/features/network-modifications/shunt-compensator/modification/shuntCompensatorModification.utils.js +3 -0
- package/dist/features/network-modifications/substation/creation/SubstationCreationForm.js +3 -0
- package/dist/features/network-modifications/substation/modification/SubstationModificationForm.js +3 -0
- package/dist/features/network-modifications/voltageLevel/creation/VoltageLevelCreationForm.js +3 -0
- package/dist/features/network-modifications/voltageLevel/creation/index.js +3 -0
- package/dist/features/network-modifications/voltageLevel/creation/tabs/substationTab/SubstationCreationSection.js +3 -0
- package/dist/features/network-modifications/voltageLevel/creation/voltageLevelCreation.utils.js +3 -0
- package/dist/features/network-modifications/voltageLevel/index.js +3 -0
- package/dist/features/network-modifications/voltageLevel/modification/VoltageLevelModificationForm.js +4 -1
- package/dist/features/parameters/common/contingency-table/contingency-table.js +22 -10
- package/dist/features/parameters/common/contingency-table/types.d.ts +7 -8
- package/dist/features/parameters/common/contingency-table/utils.d.ts +13 -0
- package/dist/features/parameters/common/contingency-table/utils.js +31 -0
- package/dist/features/parameters/loadflow/load-flow-general-parameters.js +5 -1
- package/dist/features/parameters/security-analysis/security-analysis-parameters-form.js +19 -31
- package/dist/hooks/useModificationLabelComputer.js +1 -0
- package/dist/index.js +87 -3
- package/dist/translations/en/networkModificationsEn.d.ts +28 -0
- package/dist/translations/en/networkModificationsEn.js +28 -0
- package/dist/translations/en/parameters.d.ts +3 -1
- package/dist/translations/en/parameters.js +3 -1
- package/dist/translations/fr/networkModificationsFr.d.ts +28 -0
- package/dist/translations/fr/networkModificationsFr.js +28 -0
- package/dist/translations/fr/parameters.d.ts +3 -1
- package/dist/translations/fr/parameters.js +3 -1
- package/dist/utils/constants/fieldConstants.d.ts +47 -1
- package/dist/utils/constants/fieldConstants.js +46 -0
- package/dist/utils/types/modificationType.d.ts +4 -0
- package/dist/utils/types/modificationType.js +5 -0
- package/package.json +11 -4
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Box, Grid2 } from "@mui/material";
|
|
3
|
+
import { useIntl, FormattedMessage } from "react-intl";
|
|
4
|
+
import { useMemo, useCallback, useEffect } from "react";
|
|
5
|
+
import { useFormContext, useController } from "react-hook-form";
|
|
6
|
+
import { TemporaryLimitsTable } from "./TemporaryLimitsTable.js";
|
|
7
|
+
import { LimitsChart } from "./limitsChart.js";
|
|
8
|
+
import { LimitsPropertiesSideStack } from "./LimitsPropertiesSideStack.js";
|
|
9
|
+
import { TEMPORARY_LIMIT_MODIFICATION_TYPE, APPLICABILITY } from "../limits.types.js";
|
|
10
|
+
import "@mui/icons-material";
|
|
11
|
+
import "../../../../../components/ui/overflowableText/OverflowableText.js";
|
|
12
|
+
import { AmpereAdornment } from "../../../../../utils/constants/adornments.js";
|
|
13
|
+
import { FieldConstants } from "../../../../../utils/constants/fieldConstants.js";
|
|
14
|
+
import "../../../../../utils/conversionUtils.js";
|
|
15
|
+
import "../../../../../utils/types/equipmentType.js";
|
|
16
|
+
import "localized-countries";
|
|
17
|
+
import "localized-countries/data/fr";
|
|
18
|
+
import "localized-countries/data/en";
|
|
19
|
+
import "notistack";
|
|
20
|
+
import "../../../../../components/ui/reactHookForm/provider/CustomFormProvider.js";
|
|
21
|
+
import { useCustomFormContext } from "../../../../../components/ui/reactHookForm/provider/useCustomFormContext.js";
|
|
22
|
+
import "yup";
|
|
23
|
+
import { ErrorInput } from "../../../../../components/ui/reactHookForm/errorManagement/ErrorInput.js";
|
|
24
|
+
import { FieldErrorAlert } from "../../../../../components/ui/reactHookForm/errorManagement/FieldErrorAlert.js";
|
|
25
|
+
import "../../../../../components/ui/treeViewFinder/TreeViewFinder.js";
|
|
26
|
+
import { FloatInput } from "../../../../../components/ui/reactHookForm/numbers/FloatInput.js";
|
|
27
|
+
import { TextInput } from "../../../../../components/ui/reactHookForm/text/TextInput.js";
|
|
28
|
+
import "../../../../../components/ui/reactHookForm/numbers/RangeInput.js";
|
|
29
|
+
import { SelectInput } from "../../../../../components/ui/reactHookForm/selectInputs/SelectInput.js";
|
|
30
|
+
import "@material-symbols/svg-400/outlined/left_panel_open.svg?react";
|
|
31
|
+
import "@material-symbols/svg-400/outlined/arrows_output.svg?react";
|
|
32
|
+
import "@material-symbols/svg-400/outlined/arrows_input.svg?react";
|
|
33
|
+
import "@material-symbols/svg-400/outlined/left_panel_close.svg?react";
|
|
34
|
+
import "@material-symbols/svg-400/outlined/add_notes.svg?react";
|
|
35
|
+
import "../../../../../components/ui/dialogs/descriptionModificationDialog/DescriptionModificationDialog.js";
|
|
36
|
+
import "../../../../../components/ui/reactHookForm/expandableInput/ExpandableInput.js";
|
|
37
|
+
import "../../../../../components/ui/reactHookForm/directory-item-input/directory-item-utils.js";
|
|
38
|
+
import "@hello-pangea/dnd";
|
|
39
|
+
import "../../../../../components/ui/dialogs/elementSaveDialog/ElementSaveDialog.js";
|
|
40
|
+
import "../../../../../components/ui/snackbarProvider/SnackbarProvider.js";
|
|
41
|
+
import "mui-nested-menu";
|
|
42
|
+
import "react-resizable-panels";
|
|
43
|
+
import "react-papaparse";
|
|
44
|
+
import "react-dom";
|
|
45
|
+
import { DndColumnType } from "../../../../../components/composite/dnd-table/dnd-table.type.js";
|
|
46
|
+
import "autosuggest-highlight/match";
|
|
47
|
+
import "autosuggest-highlight/parse";
|
|
48
|
+
import "clsx";
|
|
49
|
+
import "../../../../../components/composite/filter/FilterCreationDialog.js";
|
|
50
|
+
import "../../../../../components/composite/filter/HeaderFilterForm.js";
|
|
51
|
+
import "../../../../../components/composite/filter/explicitNaming/ExplicitNamingFilterForm.js";
|
|
52
|
+
import "../../../../../components/composite/filter/expert/ExpertFilterForm.js";
|
|
53
|
+
import "../../../../../components/composite/filter/expert/ExpertFilterEditionDialog.js";
|
|
54
|
+
import "../../../../../components/composite/filter/expert/expertFilterConstants.js";
|
|
55
|
+
import "react-querybuilder";
|
|
56
|
+
import "uuid";
|
|
57
|
+
import "../../../../../components/composite/filter/explicitNaming/ExplicitNamingFilterEditionDialog.js";
|
|
58
|
+
import "../../../../../components/composite/filter/utils/filterFormUtils.js";
|
|
59
|
+
import "@react-querybuilder/material";
|
|
60
|
+
import "../../../../../components/composite/reactQueryBuilder/CustomReactQueryBuilder.js";
|
|
61
|
+
import "../../../../../components/composite/reactQueryBuilder/PropertyValueEditor.js";
|
|
62
|
+
import "../../../../../components/composite/agGridTable/BottomTableButtons.js";
|
|
63
|
+
import "../../../../../components/composite/agGridTable/CustomAgGridTable.js";
|
|
64
|
+
import "ag-grid-community";
|
|
65
|
+
import "../../../../../components/composite/customAGGrid/customAggrid.js";
|
|
66
|
+
import "../../../../../components/composite/customAGGrid/context/custom-aggrid-context.js";
|
|
67
|
+
import "mathjs";
|
|
68
|
+
import "../../../../../components/composite/report/report-viewer/log-table/log-table.js";
|
|
69
|
+
import "react-window";
|
|
70
|
+
import "../../../../../components/composite/report/report-treeview/treeview-item.js";
|
|
71
|
+
import "../../../../../components/composite/report/report-viewer/context/report-viewer-context.js";
|
|
72
|
+
function LimitsEditor({
|
|
73
|
+
name,
|
|
74
|
+
permanentCurrentLimitPreviousValue,
|
|
75
|
+
temporaryLimitsPreviousValues,
|
|
76
|
+
applicabilityPreviousValue,
|
|
77
|
+
clearableFields,
|
|
78
|
+
disabled
|
|
79
|
+
}) {
|
|
80
|
+
const intl = useIntl();
|
|
81
|
+
const { getValues, subscribe, trigger } = useFormContext();
|
|
82
|
+
const { isNodeBuilt } = useCustomFormContext();
|
|
83
|
+
const limitsGroupFormName = `${name}.${FieldConstants.CURRENT_LIMITS}`;
|
|
84
|
+
const columnsDefinition = useMemo(() => {
|
|
85
|
+
return [
|
|
86
|
+
{
|
|
87
|
+
label: "TemporaryLimitName",
|
|
88
|
+
dataKey: FieldConstants.TEMPORARY_LIMIT_NAME,
|
|
89
|
+
initialValue: "",
|
|
90
|
+
editable: true,
|
|
91
|
+
type: DndColumnType.TEXT,
|
|
92
|
+
maxWidth: 200
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
label: "TemporaryLimitDuration",
|
|
96
|
+
dataKey: FieldConstants.TEMPORARY_LIMIT_DURATION,
|
|
97
|
+
initialValue: null,
|
|
98
|
+
editable: true,
|
|
99
|
+
type: DndColumnType.NUMERIC,
|
|
100
|
+
maxWidth: 100
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
label: "TemporaryLimitValue",
|
|
104
|
+
dataKey: FieldConstants.TEMPORARY_LIMIT_VALUE,
|
|
105
|
+
initialValue: null,
|
|
106
|
+
editable: true,
|
|
107
|
+
type: DndColumnType.NUMERIC,
|
|
108
|
+
maxWidth: 100
|
|
109
|
+
}
|
|
110
|
+
].map((column) => ({
|
|
111
|
+
...column,
|
|
112
|
+
label: intl.formatMessage({ id: column.label })
|
|
113
|
+
}));
|
|
114
|
+
}, [intl]);
|
|
115
|
+
const newRowData = useMemo(() => {
|
|
116
|
+
const newData = {};
|
|
117
|
+
columnsDefinition.forEach((column) => {
|
|
118
|
+
newData[column.dataKey] = column.initialValue;
|
|
119
|
+
});
|
|
120
|
+
return newData;
|
|
121
|
+
}, [columnsDefinition]);
|
|
122
|
+
const createRows = () => [newRowData];
|
|
123
|
+
const temporaryLimitHasPreviousValue = useCallback(
|
|
124
|
+
(rowIndex, arrayFormName, temporaryLimits) => {
|
|
125
|
+
if (!temporaryLimits) {
|
|
126
|
+
return false;
|
|
127
|
+
}
|
|
128
|
+
return temporaryLimits?.filter(
|
|
129
|
+
(l) => l.name === getValues(arrayFormName)[rowIndex]?.name && l.acceptableDuration === getValues(arrayFormName)[rowIndex]?.acceptableDuration
|
|
130
|
+
)?.length > 0;
|
|
131
|
+
},
|
|
132
|
+
[getValues]
|
|
133
|
+
);
|
|
134
|
+
const shouldReturnPreviousValue = useCallback(
|
|
135
|
+
(rowIndex, column, arrayFormName, temporaryLimits) => {
|
|
136
|
+
return temporaryLimitHasPreviousValue(rowIndex, arrayFormName, temporaryLimits) && column.dataKey === FieldConstants.TEMPORARY_LIMIT_VALUE || getValues(arrayFormName)[rowIndex]?.modificationType === TEMPORARY_LIMIT_MODIFICATION_TYPE.ADD;
|
|
137
|
+
},
|
|
138
|
+
[getValues, temporaryLimitHasPreviousValue]
|
|
139
|
+
);
|
|
140
|
+
const findTemporaryLimit = useCallback(
|
|
141
|
+
(rowIndex, arrayFormName, temporaryLimits) => {
|
|
142
|
+
return temporaryLimits?.find(
|
|
143
|
+
(e) => e.name === getValues(arrayFormName)[rowIndex]?.name && e.acceptableDuration === getValues(arrayFormName)[rowIndex]?.acceptableDuration
|
|
144
|
+
);
|
|
145
|
+
},
|
|
146
|
+
[getValues]
|
|
147
|
+
);
|
|
148
|
+
const getPreviousValue = useCallback(
|
|
149
|
+
(rowIndex, column, arrayFormName, temporaryLimits) => {
|
|
150
|
+
if (!temporaryLimits) {
|
|
151
|
+
return void 0;
|
|
152
|
+
}
|
|
153
|
+
if (!temporaryLimits?.length) {
|
|
154
|
+
return void 0;
|
|
155
|
+
}
|
|
156
|
+
if (!shouldReturnPreviousValue(rowIndex, column, arrayFormName, temporaryLimits)) {
|
|
157
|
+
return void 0;
|
|
158
|
+
}
|
|
159
|
+
const temporaryLimit = findTemporaryLimit(rowIndex, arrayFormName, temporaryLimits);
|
|
160
|
+
if (temporaryLimit === void 0) {
|
|
161
|
+
return void 0;
|
|
162
|
+
}
|
|
163
|
+
if (column.dataKey === FieldConstants.TEMPORARY_LIMIT_VALUE) {
|
|
164
|
+
return temporaryLimit?.value ?? Number.MAX_VALUE;
|
|
165
|
+
}
|
|
166
|
+
if (column.dataKey === FieldConstants.TEMPORARY_LIMIT_DURATION) {
|
|
167
|
+
return temporaryLimit?.acceptableDuration ?? Number.MAX_VALUE;
|
|
168
|
+
}
|
|
169
|
+
return void 0;
|
|
170
|
+
},
|
|
171
|
+
[findTemporaryLimit, shouldReturnPreviousValue]
|
|
172
|
+
);
|
|
173
|
+
const isValueModified = useCallback(
|
|
174
|
+
(rowIndex, arrayFormName) => {
|
|
175
|
+
const temporaryLimits = getValues(arrayFormName);
|
|
176
|
+
const temporaryLimit = temporaryLimits ? temporaryLimits[rowIndex] : null;
|
|
177
|
+
if (temporaryLimit?.modificationType === TEMPORARY_LIMIT_MODIFICATION_TYPE.MODIFY && !isNodeBuilt) {
|
|
178
|
+
return false;
|
|
179
|
+
}
|
|
180
|
+
return temporaryLimit?.modificationType !== null;
|
|
181
|
+
},
|
|
182
|
+
[getValues, isNodeBuilt]
|
|
183
|
+
);
|
|
184
|
+
useEffect(() => {
|
|
185
|
+
const unsubscribeCallBack = subscribe({
|
|
186
|
+
name: [`${name}.${FieldConstants.APPLICABILITY_FIELD}`, `${name}.${FieldConstants.NAME}`],
|
|
187
|
+
formState: {
|
|
188
|
+
values: true
|
|
189
|
+
},
|
|
190
|
+
callback: ({ isSubmitted }) => {
|
|
191
|
+
if (isSubmitted) {
|
|
192
|
+
const operationalLimitsGroups = getValues(
|
|
193
|
+
`${FieldConstants.LIMITS}.${FieldConstants.OPERATIONAL_LIMITS_GROUPS}`
|
|
194
|
+
);
|
|
195
|
+
for (let index = 0; index < operationalLimitsGroups?.length; index++) {
|
|
196
|
+
trigger(
|
|
197
|
+
`${FieldConstants.LIMITS}.${FieldConstants.OPERATIONAL_LIMITS_GROUPS}[${index}].${FieldConstants.OLG_IS_DUPLICATE}`
|
|
198
|
+
).then();
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
return () => unsubscribeCallBack();
|
|
204
|
+
}, [trigger, subscribe, name, getValues]);
|
|
205
|
+
const {
|
|
206
|
+
fieldState: { error }
|
|
207
|
+
} = useController({
|
|
208
|
+
name: `${name}.${FieldConstants.OLG_IS_DUPLICATE}`
|
|
209
|
+
});
|
|
210
|
+
return /* @__PURE__ */ jsxs(Box, { sx: { p: 2 }, children: [
|
|
211
|
+
/* @__PURE__ */ jsx(
|
|
212
|
+
LimitsChart,
|
|
213
|
+
{
|
|
214
|
+
limitsGroupFormName,
|
|
215
|
+
previousPermanentLimit: permanentCurrentLimitPreviousValue
|
|
216
|
+
}
|
|
217
|
+
),
|
|
218
|
+
name && /* @__PURE__ */ jsxs(Box, { children: [
|
|
219
|
+
/* @__PURE__ */ jsxs(
|
|
220
|
+
Grid2,
|
|
221
|
+
{
|
|
222
|
+
container: true,
|
|
223
|
+
justifyContent: "flex-start",
|
|
224
|
+
alignItems: "stretch",
|
|
225
|
+
spacing: 2,
|
|
226
|
+
sx: { paddingBottom: 1, paddingTop: 3 },
|
|
227
|
+
children: [
|
|
228
|
+
/* @__PURE__ */ jsx(Grid2, { size: 4, children: /* @__PURE__ */ jsx(
|
|
229
|
+
TextInput,
|
|
230
|
+
{
|
|
231
|
+
name: `${name}.${FieldConstants.NAME}`,
|
|
232
|
+
label: "name",
|
|
233
|
+
formProps: error?.message ? { error: true } : {},
|
|
234
|
+
disabled
|
|
235
|
+
}
|
|
236
|
+
) }),
|
|
237
|
+
/* @__PURE__ */ jsx(Grid2, { size: 4, children: /* @__PURE__ */ jsx(
|
|
238
|
+
SelectInput,
|
|
239
|
+
{
|
|
240
|
+
label: "Applicability",
|
|
241
|
+
options: Object.values(APPLICABILITY),
|
|
242
|
+
name: `${name}.${FieldConstants.APPLICABILITY_FIELD}`,
|
|
243
|
+
previousValue: applicabilityPreviousValue,
|
|
244
|
+
sx: { flexGrow: 1 },
|
|
245
|
+
disableClearable: true,
|
|
246
|
+
size: "small",
|
|
247
|
+
disabled,
|
|
248
|
+
formProps: { error: !!error?.message }
|
|
249
|
+
}
|
|
250
|
+
) }),
|
|
251
|
+
/* @__PURE__ */ jsx(Grid2, { size: 4, children: /* @__PURE__ */ jsx(
|
|
252
|
+
FloatInput,
|
|
253
|
+
{
|
|
254
|
+
name: `${limitsGroupFormName}.${FieldConstants.PERMANENT_LIMIT}`,
|
|
255
|
+
label: "PermanentCurrentLimitText",
|
|
256
|
+
adornment: AmpereAdornment,
|
|
257
|
+
previousValue: permanentCurrentLimitPreviousValue ?? void 0,
|
|
258
|
+
clearable: !disabled && clearableFields,
|
|
259
|
+
disabled
|
|
260
|
+
}
|
|
261
|
+
) })
|
|
262
|
+
]
|
|
263
|
+
}
|
|
264
|
+
),
|
|
265
|
+
/* @__PURE__ */ jsx(ErrorInput, { InputField: FieldErrorAlert, name: `${name}.${FieldConstants.OLG_IS_DUPLICATE}` })
|
|
266
|
+
] }),
|
|
267
|
+
/* @__PURE__ */ jsx(Box, { component: "h4", margin: 1, children: /* @__PURE__ */ jsx(FormattedMessage, { id: "TemporaryCurrentLimitsText" }) }),
|
|
268
|
+
/* @__PURE__ */ jsx(
|
|
269
|
+
TemporaryLimitsTable,
|
|
270
|
+
{
|
|
271
|
+
arrayFormName: `${limitsGroupFormName}.${FieldConstants.TEMPORARY_LIMITS}`,
|
|
272
|
+
createRow: createRows,
|
|
273
|
+
columnsDefinition,
|
|
274
|
+
previousValues: temporaryLimitsPreviousValues,
|
|
275
|
+
getPreviousValue,
|
|
276
|
+
isValueModified,
|
|
277
|
+
disabled
|
|
278
|
+
}
|
|
279
|
+
),
|
|
280
|
+
/* @__PURE__ */ jsx(LimitsPropertiesSideStack, { name: `${name}.${FieldConstants.LIMITS_PROPERTIES}`, disabled })
|
|
281
|
+
] });
|
|
282
|
+
}
|
|
283
|
+
export {
|
|
284
|
+
LimitsEditor
|
|
285
|
+
};
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Stack, Box, Autocomplete, TextField, IconButton } from "@mui/material";
|
|
3
|
+
import { useState, useMemo, useCallback } from "react";
|
|
4
|
+
import { Delete } from "@mui/icons-material";
|
|
5
|
+
import { useIntl } from "react-intl";
|
|
6
|
+
import { useFieldArray } from "react-hook-form";
|
|
7
|
+
import { LimitsTagChip } from "../LimitsTagChip.js";
|
|
8
|
+
import "../../../../../utils/conversionUtils.js";
|
|
9
|
+
import "../../../../../utils/types/equipmentType.js";
|
|
10
|
+
import "localized-countries";
|
|
11
|
+
import "localized-countries/data/fr";
|
|
12
|
+
import "localized-countries/data/en";
|
|
13
|
+
import { usePredefinedProperties } from "../../../../../hooks/usePredefinedProperties.js";
|
|
14
|
+
import "notistack";
|
|
15
|
+
import { AddButton } from "../../../../../components/ui/addButton/AddButton.js";
|
|
16
|
+
import "../../../../../components/ui/overflowableText/OverflowableText.js";
|
|
17
|
+
import "../../../../../components/ui/reactHookForm/provider/CustomFormProvider.js";
|
|
18
|
+
import "yup";
|
|
19
|
+
import "../../../../../components/ui/treeViewFinder/TreeViewFinder.js";
|
|
20
|
+
import "../../../../../components/ui/reactHookForm/numbers/RangeInput.js";
|
|
21
|
+
import "@material-symbols/svg-400/outlined/left_panel_open.svg?react";
|
|
22
|
+
import "@material-symbols/svg-400/outlined/arrows_output.svg?react";
|
|
23
|
+
import "@material-symbols/svg-400/outlined/arrows_input.svg?react";
|
|
24
|
+
import "@material-symbols/svg-400/outlined/left_panel_close.svg?react";
|
|
25
|
+
import "@material-symbols/svg-400/outlined/add_notes.svg?react";
|
|
26
|
+
import "../../../../../components/ui/dialogs/descriptionModificationDialog/DescriptionModificationDialog.js";
|
|
27
|
+
import "../../../../../components/ui/reactHookForm/expandableInput/ExpandableInput.js";
|
|
28
|
+
import "../../../../../components/ui/reactHookForm/directory-item-input/directory-item-utils.js";
|
|
29
|
+
import "@hello-pangea/dnd";
|
|
30
|
+
import "../../../../../components/ui/dialogs/elementSaveDialog/ElementSaveDialog.js";
|
|
31
|
+
import "../../../../../components/ui/snackbarProvider/SnackbarProvider.js";
|
|
32
|
+
import "mui-nested-menu";
|
|
33
|
+
import "react-resizable-panels";
|
|
34
|
+
import "react-papaparse";
|
|
35
|
+
import "react-dom";
|
|
36
|
+
import "autosuggest-highlight/match";
|
|
37
|
+
import "autosuggest-highlight/parse";
|
|
38
|
+
import "clsx";
|
|
39
|
+
import "../../../../../components/composite/filter/FilterCreationDialog.js";
|
|
40
|
+
import "../../../../../components/composite/filter/HeaderFilterForm.js";
|
|
41
|
+
import "../../../../../components/composite/filter/explicitNaming/ExplicitNamingFilterForm.js";
|
|
42
|
+
import "../../../../../components/composite/filter/expert/ExpertFilterForm.js";
|
|
43
|
+
import "../../../../../components/composite/filter/expert/ExpertFilterEditionDialog.js";
|
|
44
|
+
import "../../../../../components/composite/filter/expert/expertFilterConstants.js";
|
|
45
|
+
import "react-querybuilder";
|
|
46
|
+
import "uuid";
|
|
47
|
+
import "../../../../../components/composite/filter/explicitNaming/ExplicitNamingFilterEditionDialog.js";
|
|
48
|
+
import "../../../../../components/composite/filter/utils/filterFormUtils.js";
|
|
49
|
+
import "@react-querybuilder/material";
|
|
50
|
+
import "../../../../../components/composite/reactQueryBuilder/CustomReactQueryBuilder.js";
|
|
51
|
+
import "../../../../../components/composite/reactQueryBuilder/PropertyValueEditor.js";
|
|
52
|
+
import "../../../../../components/composite/agGridTable/BottomTableButtons.js";
|
|
53
|
+
import "../../../../../components/composite/agGridTable/CustomAgGridTable.js";
|
|
54
|
+
import "ag-grid-community";
|
|
55
|
+
import "../../../../../components/composite/customAGGrid/customAggrid.js";
|
|
56
|
+
import "../../../../../components/composite/customAGGrid/context/custom-aggrid-context.js";
|
|
57
|
+
import "mathjs";
|
|
58
|
+
import "../../../../../components/composite/report/report-viewer/log-table/log-table.js";
|
|
59
|
+
import "react-window";
|
|
60
|
+
import "../../../../../components/composite/report/report-treeview/treeview-item.js";
|
|
61
|
+
import "../../../../../components/composite/report/report-viewer/context/report-viewer-context.js";
|
|
62
|
+
function LimitsPropertiesSideStack({ name, disabled }) {
|
|
63
|
+
const { fields: limitsProperties, append, remove } = useFieldArray({ name });
|
|
64
|
+
const [isEditing, setIsEditing] = useState(false);
|
|
65
|
+
const [hovered, setHovered] = useState(false);
|
|
66
|
+
const [propertyName, setPropertyName] = useState("");
|
|
67
|
+
const [propertyValue, setPropertyValue] = useState("");
|
|
68
|
+
const [nameEditorError, setNameEditorError] = useState("");
|
|
69
|
+
const [valueEditorError, setValueEditorError] = useState("");
|
|
70
|
+
const intl = useIntl();
|
|
71
|
+
const [predefinedProperties] = usePredefinedProperties("limitsGroup");
|
|
72
|
+
const predefinedPropertiesNames = useMemo(() => {
|
|
73
|
+
return Object.keys(predefinedProperties ?? {}).sort((a, b) => a.localeCompare(b));
|
|
74
|
+
}, [predefinedProperties]);
|
|
75
|
+
const handleKeyPress = useCallback(
|
|
76
|
+
(event) => {
|
|
77
|
+
if (event.key === "Enter") {
|
|
78
|
+
setNameEditorError("");
|
|
79
|
+
setValueEditorError("");
|
|
80
|
+
let error = false;
|
|
81
|
+
if (propertyName.trim() === "") {
|
|
82
|
+
setNameEditorError(intl.formatMessage({ id: "FieldNotEmpty" }));
|
|
83
|
+
error = true;
|
|
84
|
+
}
|
|
85
|
+
if (propertyValue.trim() === "") {
|
|
86
|
+
setValueEditorError(intl.formatMessage({ id: "FieldNotEmpty" }));
|
|
87
|
+
error = true;
|
|
88
|
+
}
|
|
89
|
+
if (error) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
if (limitsProperties.some((l) => l.name === propertyName)) {
|
|
93
|
+
setNameEditorError(intl.formatMessage({ id: "UniqueName" }));
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
append({ name: propertyName, value: propertyValue });
|
|
97
|
+
setPropertyName("");
|
|
98
|
+
setPropertyValue("");
|
|
99
|
+
setIsEditing(false);
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
[append, intl, limitsProperties, propertyName, propertyValue]
|
|
103
|
+
);
|
|
104
|
+
const handleOnChange = useCallback((value) => {
|
|
105
|
+
setPropertyName(value);
|
|
106
|
+
setNameEditorError("");
|
|
107
|
+
}, []);
|
|
108
|
+
return /* @__PURE__ */ jsxs(Stack, { direction: "column", spacing: 2, paddingTop: 2, flexWrap: "wrap", children: [
|
|
109
|
+
/* @__PURE__ */ jsxs(Stack, { direction: "row", sx: { display: "flex", flexWrap: "wrap" }, children: [
|
|
110
|
+
limitsProperties?.map((property, index) => /* @__PURE__ */ jsx(
|
|
111
|
+
LimitsTagChip,
|
|
112
|
+
{
|
|
113
|
+
limitsProperty: property,
|
|
114
|
+
onDelete: () => remove(index),
|
|
115
|
+
disabled,
|
|
116
|
+
showTooltip: true
|
|
117
|
+
},
|
|
118
|
+
`${property.name}`
|
|
119
|
+
)),
|
|
120
|
+
!isEditing && /* @__PURE__ */ jsx(AddButton, { disabled, label: "AddProperty", onClick: () => setIsEditing(true) })
|
|
121
|
+
] }),
|
|
122
|
+
isEditing && !disabled ? /* @__PURE__ */ jsxs(
|
|
123
|
+
Box,
|
|
124
|
+
{
|
|
125
|
+
display: "flex",
|
|
126
|
+
gap: 2,
|
|
127
|
+
width: "100%",
|
|
128
|
+
onMouseEnter: () => setHovered(true),
|
|
129
|
+
onMouseLeave: () => setHovered(false),
|
|
130
|
+
children: [
|
|
131
|
+
/* @__PURE__ */ jsx(
|
|
132
|
+
Autocomplete,
|
|
133
|
+
{
|
|
134
|
+
options: Object.values(predefinedPropertiesNames),
|
|
135
|
+
size: "small",
|
|
136
|
+
onChange: (event, value) => handleOnChange(value ?? ""),
|
|
137
|
+
renderInput: (params) => /* @__PURE__ */ jsx(
|
|
138
|
+
TextField,
|
|
139
|
+
{
|
|
140
|
+
label: intl.formatMessage({ id: "PropertyName" }),
|
|
141
|
+
variant: "outlined",
|
|
142
|
+
...params,
|
|
143
|
+
onChange: (event) => handleOnChange(event.target.value),
|
|
144
|
+
fullWidth: true,
|
|
145
|
+
error: nameEditorError !== "",
|
|
146
|
+
helperText: nameEditorError,
|
|
147
|
+
onKeyDown: handleKeyPress
|
|
148
|
+
}
|
|
149
|
+
),
|
|
150
|
+
sx: { flex: 1 },
|
|
151
|
+
freeSolo: true
|
|
152
|
+
}
|
|
153
|
+
),
|
|
154
|
+
/* @__PURE__ */ jsx(
|
|
155
|
+
TextField,
|
|
156
|
+
{
|
|
157
|
+
size: "small",
|
|
158
|
+
label: intl.formatMessage({ id: "PropertyValue" }),
|
|
159
|
+
sx: { flex: 1, verticalAlign: "center" },
|
|
160
|
+
onKeyDown: handleKeyPress,
|
|
161
|
+
onChange: (event) => setPropertyValue(event.target.value),
|
|
162
|
+
error: valueEditorError !== "",
|
|
163
|
+
helperText: valueEditorError
|
|
164
|
+
}
|
|
165
|
+
),
|
|
166
|
+
/* @__PURE__ */ jsx(
|
|
167
|
+
IconButton,
|
|
168
|
+
{
|
|
169
|
+
sx: { verticalAlign: "center" },
|
|
170
|
+
onClick: () => {
|
|
171
|
+
setIsEditing(false);
|
|
172
|
+
setNameEditorError("");
|
|
173
|
+
},
|
|
174
|
+
children: /* @__PURE__ */ jsx(Delete, { visibility: hovered ? "visible" : "hidden" })
|
|
175
|
+
}
|
|
176
|
+
)
|
|
177
|
+
]
|
|
178
|
+
}
|
|
179
|
+
) : ""
|
|
180
|
+
] });
|
|
181
|
+
}
|
|
182
|
+
export {
|
|
183
|
+
LimitsPropertiesSideStack
|
|
184
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ColumnNumeric, ColumnText } from '../../../../../components';
|
|
2
|
+
import { TemporaryLimitsData } from '../limits.types';
|
|
3
|
+
interface TemporaryLimitsTableProps {
|
|
4
|
+
arrayFormName: string;
|
|
5
|
+
columnsDefinition: (ColumnText | ColumnNumeric)[];
|
|
6
|
+
createRow: () => any[];
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
previousValues: TemporaryLimitsData[];
|
|
9
|
+
getPreviousValue: (rowIndex: number, column: ColumnText | ColumnNumeric, arrayFormName: string, temporaryLimits: TemporaryLimitsData[]) => number | undefined;
|
|
10
|
+
isValueModified: (rowIndex: number, arrayFormName: string) => boolean;
|
|
11
|
+
disableAddingRows?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export declare function TemporaryLimitsTable({ arrayFormName, columnsDefinition, createRow, disabled, previousValues, getPreviousValue, isValueModified, disableAddingRows, }: Readonly<TemporaryLimitsTableProps>): import("react").JSX.Element;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useCallback } from "react";
|
|
3
|
+
import { useFieldArray } from "react-hook-form";
|
|
4
|
+
import { Grid2, TableContainer, Table, TableHead, TableRow, TableCell, Box, IconButton, TableBody } from "@mui/material";
|
|
5
|
+
import { AddCircle, Delete } from "@mui/icons-material";
|
|
6
|
+
import "react-intl";
|
|
7
|
+
import "../../../../../components/ui/overflowableText/OverflowableText.js";
|
|
8
|
+
import "../../../../../utils/conversionUtils.js";
|
|
9
|
+
import "../../../../../utils/types/equipmentType.js";
|
|
10
|
+
import "localized-countries";
|
|
11
|
+
import "localized-countries/data/fr";
|
|
12
|
+
import "localized-countries/data/en";
|
|
13
|
+
import "notistack";
|
|
14
|
+
import "../../../../../components/ui/reactHookForm/provider/CustomFormProvider.js";
|
|
15
|
+
import "yup";
|
|
16
|
+
import { ErrorInput } from "../../../../../components/ui/reactHookForm/errorManagement/ErrorInput.js";
|
|
17
|
+
import { FieldErrorAlert } from "../../../../../components/ui/reactHookForm/errorManagement/FieldErrorAlert.js";
|
|
18
|
+
import "../../../../../components/ui/treeViewFinder/TreeViewFinder.js";
|
|
19
|
+
import "../../../../../components/ui/reactHookForm/numbers/RangeInput.js";
|
|
20
|
+
import { TableNumericalInput } from "../../../../../components/ui/reactHookForm/tableInputs/table-numerical-input.js";
|
|
21
|
+
import { TableTextInput } from "../../../../../components/ui/reactHookForm/tableInputs/table-text-input.js";
|
|
22
|
+
import "@material-symbols/svg-400/outlined/left_panel_open.svg?react";
|
|
23
|
+
import "@material-symbols/svg-400/outlined/arrows_output.svg?react";
|
|
24
|
+
import "@material-symbols/svg-400/outlined/arrows_input.svg?react";
|
|
25
|
+
import "@material-symbols/svg-400/outlined/left_panel_close.svg?react";
|
|
26
|
+
import "@material-symbols/svg-400/outlined/add_notes.svg?react";
|
|
27
|
+
import "../../../../../components/ui/dialogs/descriptionModificationDialog/DescriptionModificationDialog.js";
|
|
28
|
+
import "../../../../../components/ui/reactHookForm/expandableInput/ExpandableInput.js";
|
|
29
|
+
import "../../../../../components/ui/reactHookForm/directory-item-input/directory-item-utils.js";
|
|
30
|
+
import "@hello-pangea/dnd";
|
|
31
|
+
import "../../../../../components/ui/dialogs/elementSaveDialog/ElementSaveDialog.js";
|
|
32
|
+
import "../../../../../components/ui/snackbarProvider/SnackbarProvider.js";
|
|
33
|
+
import "mui-nested-menu";
|
|
34
|
+
import "react-resizable-panels";
|
|
35
|
+
import "react-papaparse";
|
|
36
|
+
import "react-dom";
|
|
37
|
+
import { SELECTED, DndColumnType } from "../../../../../components/composite/dnd-table/dnd-table.type.js";
|
|
38
|
+
import "autosuggest-highlight/match";
|
|
39
|
+
import "autosuggest-highlight/parse";
|
|
40
|
+
import "clsx";
|
|
41
|
+
import "../../../../../components/composite/filter/FilterCreationDialog.js";
|
|
42
|
+
import "../../../../../components/composite/filter/HeaderFilterForm.js";
|
|
43
|
+
import "../../../../../components/composite/filter/explicitNaming/ExplicitNamingFilterForm.js";
|
|
44
|
+
import "../../../../../components/composite/filter/expert/ExpertFilterForm.js";
|
|
45
|
+
import "../../../../../components/composite/filter/expert/ExpertFilterEditionDialog.js";
|
|
46
|
+
import "../../../../../components/composite/filter/expert/expertFilterConstants.js";
|
|
47
|
+
import "react-querybuilder";
|
|
48
|
+
import "uuid";
|
|
49
|
+
import "../../../../../components/composite/filter/explicitNaming/ExplicitNamingFilterEditionDialog.js";
|
|
50
|
+
import "../../../../../components/composite/filter/utils/filterFormUtils.js";
|
|
51
|
+
import "@react-querybuilder/material";
|
|
52
|
+
import "../../../../../components/composite/reactQueryBuilder/CustomReactQueryBuilder.js";
|
|
53
|
+
import "../../../../../components/composite/reactQueryBuilder/PropertyValueEditor.js";
|
|
54
|
+
import "../../../../../components/composite/agGridTable/BottomTableButtons.js";
|
|
55
|
+
import "../../../../../components/composite/agGridTable/CustomAgGridTable.js";
|
|
56
|
+
import "ag-grid-community";
|
|
57
|
+
import "../../../../../components/composite/customAGGrid/customAggrid.js";
|
|
58
|
+
import "../../../../../components/composite/customAGGrid/context/custom-aggrid-context.js";
|
|
59
|
+
import "mathjs";
|
|
60
|
+
import "../../../../../components/composite/report/report-viewer/log-table/log-table.js";
|
|
61
|
+
import "react-window";
|
|
62
|
+
import "../../../../../components/composite/report/report-treeview/treeview-item.js";
|
|
63
|
+
import "../../../../../components/composite/report/report-viewer/context/report-viewer-context.js";
|
|
64
|
+
const styles = {
|
|
65
|
+
columnsStyle: {
|
|
66
|
+
display: "inline-flex",
|
|
67
|
+
justifyContent: "space-between",
|
|
68
|
+
alignItems: "center",
|
|
69
|
+
margin: 1,
|
|
70
|
+
textTransform: "none"
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
function EditableTableCell({ name, column, previousValue, valueModified, ...props }) {
|
|
74
|
+
return /* @__PURE__ */ jsx(TableCell, { sx: { padding: 0.5, maxWidth: column.maxWidth, verticalAlign: "top" }, children: column.type === DndColumnType.NUMERIC ? /* @__PURE__ */ jsx(
|
|
75
|
+
TableNumericalInput,
|
|
76
|
+
{
|
|
77
|
+
name,
|
|
78
|
+
previousValue,
|
|
79
|
+
valueModified,
|
|
80
|
+
hideErrorMessage: column.hideErrorMessage,
|
|
81
|
+
...props
|
|
82
|
+
}
|
|
83
|
+
) : /* @__PURE__ */ jsx(TableTextInput, { name, hideErrorMessage: column.hideErrorMessage, ...props }) });
|
|
84
|
+
}
|
|
85
|
+
function TemporaryLimitsTable({
|
|
86
|
+
arrayFormName,
|
|
87
|
+
columnsDefinition,
|
|
88
|
+
createRow,
|
|
89
|
+
disabled = false,
|
|
90
|
+
previousValues,
|
|
91
|
+
getPreviousValue,
|
|
92
|
+
isValueModified,
|
|
93
|
+
disableAddingRows = false
|
|
94
|
+
}) {
|
|
95
|
+
const { fields, append, remove } = useFieldArray({ name: arrayFormName });
|
|
96
|
+
const [hoveredRowIndex, setHoveredRowIndex] = useState(-1);
|
|
97
|
+
const handleMouseEnter = useCallback((event) => {
|
|
98
|
+
const { index } = event.currentTarget.dataset;
|
|
99
|
+
if (index !== void 0) {
|
|
100
|
+
setHoveredRowIndex(Number(index));
|
|
101
|
+
}
|
|
102
|
+
}, []);
|
|
103
|
+
const handleMouseLeave = useCallback(() => {
|
|
104
|
+
setHoveredRowIndex(-1);
|
|
105
|
+
}, []);
|
|
106
|
+
const handleRemove = useCallback(
|
|
107
|
+
(event) => {
|
|
108
|
+
const { index } = event.currentTarget.dataset;
|
|
109
|
+
if (index !== void 0) {
|
|
110
|
+
remove(Number(index));
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
[remove]
|
|
114
|
+
);
|
|
115
|
+
function renderTableCell(rowId, rowIndex, column) {
|
|
116
|
+
const name = `${arrayFormName}[${rowIndex}].${column.dataKey}`;
|
|
117
|
+
return /* @__PURE__ */ jsx(
|
|
118
|
+
EditableTableCell,
|
|
119
|
+
{
|
|
120
|
+
name,
|
|
121
|
+
column,
|
|
122
|
+
disabled,
|
|
123
|
+
previousValue: getPreviousValue ? getPreviousValue(rowIndex, column, arrayFormName, previousValues) : void 0,
|
|
124
|
+
valueModified: isValueModified ? isValueModified(rowIndex, arrayFormName) : false
|
|
125
|
+
},
|
|
126
|
+
rowId + column.dataKey
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
const handleAddRowButton = useCallback(() => {
|
|
130
|
+
const rowsToAdd = createRow().map((row) => {
|
|
131
|
+
return { ...row, [SELECTED]: false };
|
|
132
|
+
});
|
|
133
|
+
append(rowsToAdd);
|
|
134
|
+
}, [append, createRow]);
|
|
135
|
+
function renderTableHead() {
|
|
136
|
+
return /* @__PURE__ */ jsx(TableHead, { children: /* @__PURE__ */ jsxs(TableRow, { children: [
|
|
137
|
+
columnsDefinition.map((column) => /* @__PURE__ */ jsx(TableCell, { sx: { width: column.width, maxWidth: column.maxWidth }, children: /* @__PURE__ */ jsx(Box, { sx: styles.columnsStyle, children: column.label }) }, column.dataKey)),
|
|
138
|
+
/* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsx(
|
|
139
|
+
IconButton,
|
|
140
|
+
{
|
|
141
|
+
color: "primary",
|
|
142
|
+
onClick: handleAddRowButton,
|
|
143
|
+
disabled: disabled || disableAddingRows,
|
|
144
|
+
children: /* @__PURE__ */ jsx(AddCircle, {})
|
|
145
|
+
}
|
|
146
|
+
) })
|
|
147
|
+
] }) });
|
|
148
|
+
}
|
|
149
|
+
const renderTableRow = (rowId, index) => /* @__PURE__ */ jsxs(TableRow, { "data-index": index, onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave, children: [
|
|
150
|
+
columnsDefinition.map((column) => renderTableCell(rowId, index, column)),
|
|
151
|
+
/* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsx(IconButton, { "data-index": index, color: "primary", disabled, onClick: handleRemove, children: /* @__PURE__ */ jsx(Delete, { visibility: index === hoveredRowIndex ? "visible" : "hidden" }) }) }, `${rowId}delete`)
|
|
152
|
+
] }, rowId);
|
|
153
|
+
function renderTableBody() {
|
|
154
|
+
return /* @__PURE__ */ jsx(TableBody, { children: fields.map((value, index) => renderTableRow(value.id, index)) });
|
|
155
|
+
}
|
|
156
|
+
return /* @__PURE__ */ jsx(Grid2, { container: true, spacing: 1, children: /* @__PURE__ */ jsxs(Grid2, { container: true, size: 12, children: [
|
|
157
|
+
/* @__PURE__ */ jsx(TableContainer, { children: /* @__PURE__ */ jsxs(Table, { stickyHeader: true, size: "small", padding: "none", children: [
|
|
158
|
+
renderTableHead(),
|
|
159
|
+
renderTableBody()
|
|
160
|
+
] }) }),
|
|
161
|
+
/* @__PURE__ */ jsx(ErrorInput, { name: arrayFormName, InputField: FieldErrorAlert })
|
|
162
|
+
] }) });
|
|
163
|
+
}
|
|
164
|
+
export {
|
|
165
|
+
TemporaryLimitsTable
|
|
166
|
+
};
|