@gridsuite/commons-ui 0.193.0 → 0.195.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/directoryItemSelector/DirectoryItemSelector.js +0 -1
- package/dist/components/dnd-table-v2/deletable-table-row.d.ts +7 -0
- package/dist/components/dnd-table-v2/deletable-table-row.js +37 -0
- package/dist/components/dnd-table-v2/dnd-table-add-rows-dialog.d.ts +13 -0
- package/dist/components/dnd-table-v2/dnd-table-add-rows-dialog.js +75 -0
- package/dist/components/dnd-table-v2/dnd-table-bottom-left-buttons.d.ts +17 -0
- package/dist/components/dnd-table-v2/dnd-table-bottom-left-buttons.js +48 -0
- package/dist/components/dnd-table-v2/dnd-table-bottom-right-buttons.d.ts +17 -0
- package/dist/components/dnd-table-v2/dnd-table-bottom-right-buttons.js +103 -0
- package/dist/components/dnd-table-v2/dnd-table-row.d.ts +23 -0
- package/dist/components/dnd-table-v2/dnd-table-row.js +183 -0
- package/dist/components/dnd-table-v2/dnd-table-utils.d.ts +2 -0
- package/dist/components/dnd-table-v2/dnd-table-utils.js +10 -0
- package/dist/components/dnd-table-v2/dnd-table.d.ts +32 -0
- package/dist/components/dnd-table-v2/dnd-table.js +381 -0
- package/dist/components/dnd-table-v2/dnd-table.type.d.ts +70 -0
- package/dist/components/dnd-table-v2/dnd-table.type.js +19 -0
- package/dist/components/dnd-table-v2/index.d.ts +12 -0
- package/dist/components/dnd-table-v2/index.js +16 -0
- package/dist/components/index.js +3 -8
- package/dist/components/inputs/reactHookForm/DirectoryItemsInput.d.ts +1 -2
- package/dist/components/inputs/reactHookForm/DirectoryItemsInput.js +2 -5
- package/dist/components/inputs/reactHookForm/booleans/BooleanInput.js +6 -4
- package/dist/components/inputs/reactQueryBuilder/OperatorSelector.js +0 -1
- package/dist/components/network-modifications/by-filter/assignment/assignment/assignment-form.js +72 -53
- package/dist/components/network-modifications/by-filter/assignment/assignment/assignment-utils.d.ts +1 -0
- package/dist/components/network-modifications/by-filter/assignment/assignment/assignment-utils.js +8 -5
- package/dist/components/network-modifications/by-filter/assignment/modificationByAssignment.utils.js +5 -5
- package/dist/components/parameters/common/contingency-table/columns-definitions.d.ts +4 -3
- package/dist/components/parameters/common/contingency-table/columns-definitions.js +23 -15
- package/dist/components/parameters/common/contingency-table/contingency-table.d.ts +2 -1
- package/dist/components/parameters/common/contingency-table/contingency-table.js +45 -44
- package/dist/components/parameters/common/contingency-table/index.js +2 -2
- package/dist/components/parameters/common/index.js +2 -2
- package/dist/components/parameters/common/parameter-field.js +2 -0
- package/dist/components/parameters/common/parameter-table/table-cell.js +1 -1
- package/dist/components/parameters/common/parameter-table-field/constants.d.ts +10 -0
- package/dist/components/parameters/common/parameter-table-field/constants.js +10 -0
- package/dist/components/parameters/common/{parameter-table → parameter-table-field}/index.d.ts +2 -3
- package/dist/components/parameters/common/parameter-table-field/index.js +9 -0
- package/dist/components/parameters/common/parameter-table-field/parameter-table-field.d.ts +11 -0
- package/dist/components/parameters/common/parameter-table-field/parameter-table-field.js +121 -0
- package/dist/components/parameters/common/parameters-edition-dialog-props.d.ts +1 -1
- package/dist/components/parameters/dynamic-margin-calculation/dynamic-margin-calculation-form.js +2 -0
- package/dist/components/parameters/dynamic-margin-calculation/dynamic-margin-calculation-inline.js +2 -0
- package/dist/components/parameters/dynamic-margin-calculation/loads-variations-parameters.js +7 -6
- package/dist/components/parameters/dynamic-margin-calculation/use-dynamic-margin-calculation-parameters-form.js +2 -0
- package/dist/components/parameters/dynamic-security-analysis/contingency-parameters.js +2 -0
- package/dist/components/parameters/dynamic-security-analysis/dynamic-security-analysis-inline.js +2 -0
- package/dist/components/parameters/dynamic-security-analysis/dynamic-security-analysis-parameters-form.js +2 -0
- package/dist/components/parameters/dynamic-security-analysis/use-dynamic-security-analysis-parameters-form.js +2 -0
- package/dist/components/parameters/dynamic-simulation/dynamic-simulation-inline.js +2 -0
- package/dist/components/parameters/dynamic-simulation/dynamic-simulation-parameters-form.js +2 -0
- package/dist/components/parameters/dynamic-simulation/mapping/mapping-parameters.js +0 -1
- package/dist/components/parameters/dynamic-simulation/use-dynamic-simulation-parameters-form.js +2 -0
- package/dist/components/parameters/index.js +3 -8
- package/dist/components/parameters/loadflow/load-flow-general-parameters.js +2 -0
- package/dist/components/parameters/loadflow/load-flow-parameters-content.js +2 -0
- package/dist/components/parameters/loadflow/load-flow-parameters-dialog.js +2 -0
- package/dist/components/parameters/loadflow/load-flow-parameters-header.js +2 -0
- package/dist/components/parameters/loadflow/load-flow-parameters-inline.js +3 -1
- package/dist/components/parameters/loadflow/load-flow-parameters-utils.js +2 -0
- package/dist/components/parameters/loadflow/use-load-flow-parameters-form.js +2 -0
- package/dist/components/parameters/network-visualizations/map-parameters.js +2 -0
- package/dist/components/parameters/network-visualizations/network-visualizations-form.js +2 -0
- package/dist/components/parameters/network-visualizations/network-visualizations-parameters-inline.js +3 -1
- package/dist/components/parameters/network-visualizations/single-line-diagram-parameters.js +2 -0
- package/dist/components/parameters/pcc-min/pcc-min-parameters-form.js +2 -0
- package/dist/components/parameters/pcc-min/pcc-min-parameters-inline.js +3 -1
- package/dist/components/parameters/security-analysis/columns-definitions.js +2 -0
- package/dist/components/parameters/security-analysis/security-analysis-parameters-dialog.js +3 -1
- package/dist/components/parameters/security-analysis/security-analysis-parameters-form.js +5 -4
- package/dist/components/parameters/security-analysis/security-analysis-parameters-inline.js +2 -0
- package/dist/components/parameters/security-analysis/security-analysis-parameters-selector.js +2 -0
- package/dist/components/parameters/security-analysis/security-analysis-violations-hiding.js +2 -0
- package/dist/components/parameters/security-analysis/use-security-analysis-parameters-form.d.ts +1 -1
- package/dist/components/parameters/security-analysis/use-security-analysis-parameters-form.js +7 -3
- package/dist/components/parameters/sensi/columns-definitions.d.ts +7 -180
- package/dist/components/parameters/sensi/columns-definitions.js +81 -73
- package/dist/components/parameters/sensi/index.js +1 -6
- package/dist/components/parameters/sensi/sensitivity-analysis-parameters-dialog.js +3 -1
- package/dist/components/parameters/sensi/sensitivity-analysis-parameters-form.js +4 -2
- package/dist/components/parameters/sensi/sensitivity-analysis-parameters-inline.js +2 -0
- package/dist/components/parameters/sensi/sensitivity-parameters-selector.js +52 -51
- package/dist/components/parameters/sensi/use-sensitivity-analysis-parameters.d.ts +2 -2
- package/dist/components/parameters/sensi/use-sensitivity-analysis-parameters.js +41 -61
- package/dist/components/parameters/sensi/utils.d.ts +4 -4
- package/dist/components/parameters/sensi/utils.js +8 -6
- package/dist/components/parameters/short-circuit/short-circuit-general-tab-panel.js +2 -0
- package/dist/components/parameters/short-circuit/short-circuit-parameters-content.js +2 -0
- package/dist/components/parameters/short-circuit/short-circuit-parameters-dialog.js +2 -0
- package/dist/components/parameters/short-circuit/short-circuit-parameters-inline.js +3 -1
- package/dist/components/parameters/short-circuit/short-circuit-parameters-utils.js +2 -0
- package/dist/components/parameters/short-circuit/short-circuit-power-electronics-tab-panel.js +2 -0
- package/dist/components/parameters/short-circuit/short-circuit-study-area-tab-panel.js +2 -0
- package/dist/components/parameters/short-circuit/use-short-circuit-parameters-form.js +2 -0
- package/dist/components/parameters/voltage-init/equipment-selection-parameters.js +2 -0
- package/dist/components/parameters/voltage-init/general-parameters.js +2 -0
- package/dist/components/parameters/voltage-init/voltage-init-parameters-form.js +2 -0
- package/dist/components/parameters/voltage-init/voltage-init-parameters-inline.js +3 -1
- package/dist/components/parameters/voltage-init/voltage-limits-parameters.js +17 -31
- package/dist/hooks/index.d.ts +0 -1
- package/dist/hooks/index.js +0 -2
- package/dist/index.js +3 -10
- package/package.json +1 -1
- package/dist/components/parameters/common/parameter-dnd-table-field.d.ts +0 -9
- package/dist/components/parameters/common/parameter-dnd-table-field.js +0 -86
- package/dist/components/parameters/common/parameter-table/index.js +0 -10
- package/dist/hooks/use-create-row-data.d.ts +0 -4
- package/dist/hooks/use-create-row-data.js +0 -19
- /package/dist/components/parameters/sensi/{sensitivity-Flow-parameters.d.ts → sensitivity-parameters-fields.d.ts} +0 -0
- /package/dist/components/parameters/sensi/{sensitivity-Flow-parameters.js → sensitivity-parameters-fields.js} +0 -0
package/dist/components/network-modifications/by-filter/assignment/assignment/assignment-form.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { useMemo, useCallback } from "react";
|
|
2
|
+
import { useMemo, useRef, useState, useEffect, useCallback } from "react";
|
|
3
3
|
import { DensityLarge } from "@mui/icons-material";
|
|
4
4
|
import { useFormContext, useWatch } from "react-hook-form";
|
|
5
5
|
import { useIntl } from "react-intl";
|
|
@@ -8,14 +8,13 @@ import "../../../../../utils/conversionUtils.js";
|
|
|
8
8
|
import { ElementType } from "../../../../../utils/types/elementType.js";
|
|
9
9
|
import "../../../../../utils/types/equipmentType.js";
|
|
10
10
|
import { FieldType } from "../../../../../utils/types/fieldType.js";
|
|
11
|
-
import {
|
|
11
|
+
import { getIdOrValue, areIdsEqual } from "../../../../../utils/ts-utils.js";
|
|
12
12
|
import "../../../../../utils/yupConfig.js";
|
|
13
13
|
import "@mui/material";
|
|
14
14
|
import "localized-countries";
|
|
15
15
|
import "localized-countries/data/fr";
|
|
16
16
|
import "localized-countries/data/en";
|
|
17
17
|
import { usePredefinedProperties } from "../../../../../hooks/usePredefinedProperties.js";
|
|
18
|
-
import { usePrevious } from "../../../../../hooks/usePrevious.js";
|
|
19
18
|
import "notistack";
|
|
20
19
|
import { useFormatLabelWithUnit } from "../../../../../hooks/useFormatLabelWithUnit.js";
|
|
21
20
|
import "../../../../overflowableText/OverflowableText.js";
|
|
@@ -49,6 +48,7 @@ import "react-querybuilder";
|
|
|
49
48
|
import { DataType } from "./assignment.type.js";
|
|
50
49
|
import GridItem from "../../../../grid/grid-item.js";
|
|
51
50
|
import { EQUIPMENTS_FIELDS } from "./assignment-constants.js";
|
|
51
|
+
import { EMPTY_FIELD_VALUE } from "./assignment-utils.js";
|
|
52
52
|
const comparatorStrIgnoreCase = (str1, str2) => {
|
|
53
53
|
return str1?.toLowerCase()?.localeCompare(str2?.toLowerCase());
|
|
54
54
|
};
|
|
@@ -94,24 +94,31 @@ function AssignmentForm(props) {
|
|
|
94
94
|
const options = useMemo(() => {
|
|
95
95
|
return equipmentFields?.find((fieldOption) => fieldOption?.id === watchEditedField)?.values ?? [];
|
|
96
96
|
}, [watchEditedField, equipmentFields]);
|
|
97
|
-
const
|
|
98
|
-
if (prevDataType && prevDataType !== dataType) {
|
|
99
|
-
setValue(`${name}.${index}.${FieldConstants.VALUE}`, dataType === DataType.BOOLEAN ? false : null);
|
|
100
|
-
}
|
|
101
|
-
const emptyValueStr = useMemo(() => {
|
|
97
|
+
const emptyFieldLabel = useMemo(() => {
|
|
102
98
|
return intl.formatMessage({ id: "EmptyField" });
|
|
103
99
|
}, [intl]);
|
|
104
100
|
const formatLabelWithUnit = useFormatLabelWithUnit();
|
|
101
|
+
const prevEditedField = useRef(watchEditedField);
|
|
102
|
+
const [editedFieldKey, setEditedFieldKey] = useState(watchEditedField);
|
|
103
|
+
useEffect(() => {
|
|
104
|
+
if (prevEditedField.current !== watchEditedField) {
|
|
105
|
+
prevEditedField.current = watchEditedField;
|
|
106
|
+
setValue(`${name}.${index}.${FieldConstants.VALUE}`, dataType === DataType.BOOLEAN ? false : null);
|
|
107
|
+
setValue(`${name}.${index}.${FieldConstants.PROPERTY_NAME}`, null);
|
|
108
|
+
setEditedFieldKey(watchEditedField);
|
|
109
|
+
}
|
|
110
|
+
}, [dataType, index, name, setValue, watchEditedField]);
|
|
105
111
|
const renderAutoCompleteSettableToNone = useCallback(
|
|
106
112
|
(numberOnly) => /* @__PURE__ */ jsx(
|
|
107
113
|
AutocompleteInput,
|
|
108
114
|
{
|
|
109
115
|
name: `${name}.${index}.${FieldConstants.VALUE}`,
|
|
110
116
|
label: "ValueOrEmptyField",
|
|
111
|
-
options: [
|
|
117
|
+
options: [emptyFieldLabel],
|
|
112
118
|
size: "small",
|
|
113
119
|
onCheckNewValue: numberOnly ? (option) => {
|
|
114
|
-
|
|
120
|
+
const optionValue = getIdOrValue(option);
|
|
121
|
+
if (optionValue && optionValue !== emptyFieldLabel && optionValue !== EMPTY_FIELD_VALUE && Number.isNaN(Number(optionValue))) {
|
|
115
122
|
setError(`${name}.${index}.${FieldConstants.VALUE}`, {
|
|
116
123
|
message: "NumericValueOrEmptyField"
|
|
117
124
|
});
|
|
@@ -123,10 +130,19 @@ function AssignmentForm(props) {
|
|
|
123
130
|
return true;
|
|
124
131
|
} : void 0,
|
|
125
132
|
getOptionLabel: (option) => typeof option !== "string" ? option?.label ?? option : option,
|
|
133
|
+
inputTransform: (value) => value === EMPTY_FIELD_VALUE ? emptyFieldLabel : value,
|
|
134
|
+
outputTransform: (value) => {
|
|
135
|
+
const optionValue = getIdOrValue(value);
|
|
136
|
+
if (optionValue === emptyFieldLabel) {
|
|
137
|
+
return EMPTY_FIELD_VALUE;
|
|
138
|
+
}
|
|
139
|
+
return optionValue ?? null;
|
|
140
|
+
},
|
|
126
141
|
allowNewValue: true
|
|
127
|
-
}
|
|
142
|
+
},
|
|
143
|
+
editedFieldKey
|
|
128
144
|
),
|
|
129
|
-
[
|
|
145
|
+
[emptyFieldLabel, index, name, setError, editedFieldKey]
|
|
130
146
|
);
|
|
131
147
|
const filtersField = /* @__PURE__ */ jsx(
|
|
132
148
|
DirectoryItemsInput,
|
|
@@ -162,47 +178,50 @@ function AssignmentForm(props) {
|
|
|
162
178
|
allowNewValue: true
|
|
163
179
|
}
|
|
164
180
|
);
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
|
|
181
|
+
let valueField;
|
|
182
|
+
if (dataType === DataType.PROPERTY) {
|
|
183
|
+
valueField = /* @__PURE__ */ jsx(
|
|
184
|
+
AutocompleteInput,
|
|
185
|
+
{
|
|
186
|
+
name: `${name}.${index}.${FieldConstants.VALUE}`,
|
|
187
|
+
label: "PropertyValue",
|
|
188
|
+
options: predefinedPropertiesValues,
|
|
189
|
+
size: "small",
|
|
190
|
+
allowNewValue: true
|
|
191
|
+
},
|
|
192
|
+
editedFieldKey
|
|
193
|
+
);
|
|
194
|
+
} else if (dataType === DataType.INTEGER) {
|
|
195
|
+
valueField = /* @__PURE__ */ jsx(IntegerInput, { name: `${name}.${index}.${FieldConstants.VALUE}`, label: "Value" }, editedFieldKey);
|
|
196
|
+
} else if (dataType === DataType.BOOLEAN) {
|
|
197
|
+
valueField = /* @__PURE__ */ jsx(
|
|
198
|
+
SwitchInput,
|
|
199
|
+
{
|
|
200
|
+
name: `${name}.${index}.${FieldConstants.VALUE}`,
|
|
201
|
+
formProps: { value: false }
|
|
202
|
+
},
|
|
203
|
+
editedFieldKey
|
|
204
|
+
);
|
|
205
|
+
} else if (dataType === DataType.ENUM) {
|
|
206
|
+
valueField = /* @__PURE__ */ jsx(
|
|
207
|
+
SelectInput,
|
|
208
|
+
{
|
|
209
|
+
name: `${name}.${index}.${FieldConstants.VALUE}`,
|
|
210
|
+
label: "Value",
|
|
211
|
+
options,
|
|
212
|
+
size: "small"
|
|
213
|
+
},
|
|
214
|
+
editedFieldKey
|
|
215
|
+
);
|
|
216
|
+
} else if (dataType === DataType.STRING && settableToNone) {
|
|
217
|
+
valueField = renderAutoCompleteSettableToNone();
|
|
218
|
+
} else if (dataType === DataType.STRING) {
|
|
219
|
+
valueField = /* @__PURE__ */ jsx(TextInput, { name: `${name}.${index}.${FieldConstants.VALUE}`, label: "Value", clearable: true }, editedFieldKey);
|
|
220
|
+
} else if (dataType === DataType.DOUBLE && settableToNone) {
|
|
221
|
+
valueField = renderAutoCompleteSettableToNone(true);
|
|
222
|
+
} else {
|
|
223
|
+
valueField = /* @__PURE__ */ jsx(FloatInput, { name: `${name}.${index}.${FieldConstants.VALUE}`, label: "Value" }, editedFieldKey);
|
|
224
|
+
}
|
|
206
225
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
207
226
|
/* @__PURE__ */ jsx(GridItem, { size: 3.25, children: filtersField }),
|
|
208
227
|
/* @__PURE__ */ jsx(GridItem, { size: 3, children: editedField }),
|
package/dist/components/network-modifications/by-filter/assignment/assignment/assignment-utils.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { yupConfig as yup } from '../../../../../utils';
|
|
2
2
|
import { Assignment, DataType, FieldOptionType, FieldValue } from './assignment.type';
|
|
3
|
+
export declare const EMPTY_FIELD_VALUE = "\u2014";
|
|
3
4
|
export declare const getFieldOption: (fieldName?: string | null) => FieldOptionType | undefined;
|
|
4
5
|
export declare const getDataType: (fieldName?: string | null) => DataType | undefined;
|
|
5
6
|
export declare const getUnsettable: (fieldName?: string | null) => boolean | undefined;
|
package/dist/components/network-modifications/by-filter/assignment/assignment/assignment-utils.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { FieldConstants } from "../../../../../utils/constants/fieldConstants.js";
|
|
2
|
+
import { YUP_REQUIRED } from "../../../../../utils/constants/translationKeys.js";
|
|
2
3
|
import "../../../../../utils/conversionUtils.js";
|
|
3
4
|
import "../../../../../utils/types/equipmentType.js";
|
|
4
5
|
import "react/jsx-runtime";
|
|
@@ -7,6 +8,7 @@ import "../../../../../utils/yupConfig.js";
|
|
|
7
8
|
import { DataType } from "./assignment.type.js";
|
|
8
9
|
import { FIELD_OPTIONS } from "./assignment-constants.js";
|
|
9
10
|
import * as yup from "yup";
|
|
11
|
+
const EMPTY_FIELD_VALUE = "—";
|
|
10
12
|
const getFieldOption = (fieldName) => {
|
|
11
13
|
return Object.values(FIELD_OPTIONS).find((fieldOption) => fieldOption.id === fieldName);
|
|
12
14
|
};
|
|
@@ -40,7 +42,7 @@ function getValueSchema(emptyValueStr, dataType, settable_to_none) {
|
|
|
40
42
|
default:
|
|
41
43
|
schema = yup.number();
|
|
42
44
|
}
|
|
43
|
-
return schema.required();
|
|
45
|
+
return schema.required(YUP_REQUIRED);
|
|
44
46
|
}
|
|
45
47
|
const getAssignmentInitialValue = () => ({
|
|
46
48
|
[FieldConstants.FILTERS]: [],
|
|
@@ -56,12 +58,12 @@ function getAssignmentsSchema(emptyValueStr) {
|
|
|
56
58
|
[FieldConstants.ID]: yup.string().required(),
|
|
57
59
|
[FieldConstants.NAME]: yup.string().required()
|
|
58
60
|
})
|
|
59
|
-
).required().min(1,
|
|
60
|
-
[FieldConstants.EDITED_FIELD]: yup.string().required(),
|
|
61
|
+
).required().min(1, YUP_REQUIRED),
|
|
62
|
+
[FieldConstants.EDITED_FIELD]: yup.string().required(YUP_REQUIRED),
|
|
61
63
|
[FieldConstants.PROPERTY_NAME]: yup.string().when([FieldConstants.EDITED_FIELD], ([editedField], schema) => {
|
|
62
64
|
const dataType = getDataType(editedField);
|
|
63
65
|
if (dataType === DataType.PROPERTY) {
|
|
64
|
-
return schema.required();
|
|
66
|
+
return schema.required(YUP_REQUIRED);
|
|
65
67
|
}
|
|
66
68
|
return schema.nullable();
|
|
67
69
|
}),
|
|
@@ -69,7 +71,7 @@ function getAssignmentsSchema(emptyValueStr) {
|
|
|
69
71
|
const dataType = getDataType(editedField);
|
|
70
72
|
const unsettable = getUnsettable(editedField);
|
|
71
73
|
return getValueSchema(emptyValueStr, dataType, unsettable);
|
|
72
|
-
}).required()
|
|
74
|
+
}).required(YUP_REQUIRED)
|
|
73
75
|
})
|
|
74
76
|
).required();
|
|
75
77
|
}
|
|
@@ -80,6 +82,7 @@ function getAssignmentFromEditData(assignment) {
|
|
|
80
82
|
};
|
|
81
83
|
}
|
|
82
84
|
export {
|
|
85
|
+
EMPTY_FIELD_VALUE,
|
|
83
86
|
getAssignmentFromEditData,
|
|
84
87
|
getAssignmentInitialValue,
|
|
85
88
|
getAssignmentsSchema,
|
package/dist/components/network-modifications/by-filter/assignment/modificationByAssignment.utils.js
CHANGED
|
@@ -8,12 +8,11 @@ import { FieldType } from "../../../../utils/types/fieldType.js";
|
|
|
8
8
|
import "react/jsx-runtime";
|
|
9
9
|
import "@mui/icons-material";
|
|
10
10
|
import "../../../../utils/yupConfig.js";
|
|
11
|
-
import { getAssignmentsSchema, getAssignmentInitialValue, getAssignmentFromEditData, getDataType } from "./assignment/assignment-utils.js";
|
|
11
|
+
import { getAssignmentsSchema, getAssignmentInitialValue, getAssignmentFromEditData, getUnsettable, EMPTY_FIELD_VALUE, getDataType } from "./assignment/assignment-utils.js";
|
|
12
12
|
import { DataType } from "./assignment/assignment.type.js";
|
|
13
|
-
const emptyValueStr = "—";
|
|
14
13
|
const modificationByAssignmentFormSchema = yup.object().shape({
|
|
15
14
|
[FieldConstants.EQUIPMENT_TYPE]: mixed().oneOf(Object.values(EquipmentType)).required(),
|
|
16
|
-
[FieldConstants.ASSIGNMENTS]: getAssignmentsSchema(
|
|
15
|
+
[FieldConstants.ASSIGNMENTS]: getAssignmentsSchema(EMPTY_FIELD_VALUE)
|
|
17
16
|
}).required();
|
|
18
17
|
const emptyModificationByAssignmentFormData = {
|
|
19
18
|
[FieldConstants.EQUIPMENT_TYPE]: null,
|
|
@@ -27,9 +26,10 @@ const modificationByAssignmentDtoToForm = (dto) => ({
|
|
|
27
26
|
const field = FieldType[fieldKey];
|
|
28
27
|
const { value } = assignment;
|
|
29
28
|
const valueConverted = convertInputValue(field, value);
|
|
29
|
+
const unsettable = getUnsettable(assignment.editedField);
|
|
30
30
|
return {
|
|
31
31
|
...assignment,
|
|
32
|
-
value: valueConverted !== 0 && !valueConverted ?
|
|
32
|
+
value: unsettable && valueConverted !== 0 && !valueConverted ? EMPTY_FIELD_VALUE : valueConverted
|
|
33
33
|
};
|
|
34
34
|
}) ?? [getAssignmentInitialValue()]
|
|
35
35
|
});
|
|
@@ -39,7 +39,7 @@ const modificationByAssignmentFormToDto = (formData) => ({
|
|
|
39
39
|
assignmentInfosList: formData.assignments.map((assignment) => {
|
|
40
40
|
const fieldKey = assignment.editedField;
|
|
41
41
|
const field = FieldType[fieldKey];
|
|
42
|
-
const value = assignment.value ===
|
|
42
|
+
const value = assignment.value === EMPTY_FIELD_VALUE ? "" : assignment.value;
|
|
43
43
|
return {
|
|
44
44
|
...assignment,
|
|
45
45
|
dataType: getDataType(assignment.editedField) ?? DataType.STRING,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FieldValues } from 'react-hook-form';
|
|
2
2
|
import { default as yup } from '../../../../utils/yupConfig';
|
|
3
3
|
import { ContingencyListsInfos } from './types';
|
|
4
|
-
|
|
5
|
-
export declare const
|
|
4
|
+
import { DndColumn } from '../../../dnd-table-v2';
|
|
5
|
+
export declare const COLUMNS_DEFINITIONS_CONTINGENCY_LISTS_INFOS: DndColumn[];
|
|
6
6
|
export declare const getContingencyListsInfosFormSchema: () => yup.ObjectSchema<{
|
|
7
7
|
contingencyListsInfos: {
|
|
8
8
|
description?: string | undefined;
|
|
@@ -25,3 +25,4 @@ export declare const toFormValuesContingencyListsInfos: (contingencyListsInfos:
|
|
|
25
25
|
activated: boolean;
|
|
26
26
|
}[];
|
|
27
27
|
};
|
|
28
|
+
export declare const isValidContingencyRow: (row?: FieldValues) => boolean;
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CONTINGENCY_LISTS, CONTINGENCY_LISTS_INFOS } from "../constants.js";
|
|
2
|
+
import { DESCRIPTION, ACTIVATED, NAME, ID } from "../parameter-table-field/constants.js";
|
|
2
3
|
import "react/jsx-runtime";
|
|
3
4
|
import "@mui/material";
|
|
4
|
-
import "@mui/icons-material";
|
|
5
|
-
import "react";
|
|
6
5
|
import "react-intl";
|
|
7
6
|
import "react-hook-form";
|
|
7
|
+
import "@mui/icons-material";
|
|
8
|
+
import "react";
|
|
9
|
+
import "react-dom";
|
|
10
|
+
import "@hello-pangea/dnd";
|
|
11
|
+
import { DndColumnType } from "../../../dnd-table-v2/dnd-table.type.js";
|
|
8
12
|
import "../../../overflowableText/OverflowableText.js";
|
|
9
13
|
import "../../../../utils/conversionUtils.js";
|
|
10
14
|
import { ElementType } from "../../../../utils/types/elementType.js";
|
|
@@ -35,38 +39,38 @@ import "../../../inputs/reactQueryBuilder/CustomReactQueryBuilder.js";
|
|
|
35
39
|
import "uuid";
|
|
36
40
|
import "../../../inputs/reactQueryBuilder/PropertyValueEditor.js";
|
|
37
41
|
import "react-querybuilder";
|
|
38
|
-
import { CONTINGENCY_LISTS, CONTINGENCY_LISTS_INFOS } from "../constants.js";
|
|
39
42
|
const COLUMNS_DEFINITIONS_CONTINGENCY_LISTS_INFOS = [
|
|
40
43
|
{
|
|
41
44
|
label: "ContingencyLists",
|
|
42
45
|
dataKey: CONTINGENCY_LISTS,
|
|
43
46
|
initialValue: [],
|
|
44
47
|
editable: true,
|
|
45
|
-
|
|
48
|
+
type: DndColumnType.DIRECTORY_ITEMS,
|
|
49
|
+
equipmentTypes: [],
|
|
46
50
|
elementType: ElementType.CONTINGENCY_LIST,
|
|
47
|
-
titleId: "ContingencyListsSelection"
|
|
51
|
+
titleId: "ContingencyListsSelection",
|
|
52
|
+
shouldHandleOnChangeCell: true
|
|
48
53
|
},
|
|
49
54
|
{
|
|
50
55
|
label: "description",
|
|
56
|
+
sxHeader: { textAlign: "center" },
|
|
51
57
|
dataKey: DESCRIPTION,
|
|
52
58
|
initialValue: "",
|
|
53
59
|
editable: true,
|
|
54
|
-
|
|
55
|
-
|
|
60
|
+
width: "8rem",
|
|
61
|
+
type: DndColumnType.DESCRIPTIONS
|
|
56
62
|
},
|
|
57
63
|
{
|
|
58
64
|
label: "Active",
|
|
65
|
+
sxHeader: { textAlign: "center" },
|
|
59
66
|
dataKey: ACTIVATED,
|
|
60
67
|
initialValue: true,
|
|
61
|
-
checkboxItems: true,
|
|
62
68
|
editable: true,
|
|
63
|
-
width: "4rem"
|
|
69
|
+
width: "4rem",
|
|
70
|
+
type: DndColumnType.SWITCH,
|
|
71
|
+
shouldHandleOnChangeCell: true
|
|
64
72
|
}
|
|
65
73
|
];
|
|
66
|
-
const ParamContingencyLists = {
|
|
67
|
-
columnsDef: COLUMNS_DEFINITIONS_CONTINGENCY_LISTS_INFOS,
|
|
68
|
-
name: CONTINGENCY_LISTS_INFOS
|
|
69
|
-
};
|
|
70
74
|
const getContingencyListsInfosFormSchema = () => {
|
|
71
75
|
return yup.object().shape({
|
|
72
76
|
[CONTINGENCY_LISTS_INFOS]: yup.array().of(
|
|
@@ -95,9 +99,13 @@ const toFormValuesContingencyListsInfos = (contingencyListsInfos) => {
|
|
|
95
99
|
}))
|
|
96
100
|
};
|
|
97
101
|
};
|
|
102
|
+
const isValidContingencyRow = (row) => {
|
|
103
|
+
const contingencyLists = row?.[CONTINGENCY_LISTS];
|
|
104
|
+
return row?.[ACTIVATED] === true && Array.isArray(contingencyLists) && contingencyLists.length > 0;
|
|
105
|
+
};
|
|
98
106
|
export {
|
|
99
107
|
COLUMNS_DEFINITIONS_CONTINGENCY_LISTS_INFOS,
|
|
100
|
-
ParamContingencyLists,
|
|
101
108
|
getContingencyListsInfosFormSchema,
|
|
109
|
+
isValidContingencyRow,
|
|
102
110
|
toFormValuesContingencyListsInfos
|
|
103
111
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { UUID } from 'node:crypto';
|
|
2
2
|
import { ContingencyCount } from './types';
|
|
3
|
-
export declare function ContingencyTable({ showContingencyCount, fetchContingencyCount, isBuiltCurrentNode, }: Readonly<{
|
|
3
|
+
export declare function ContingencyTable({ name, showContingencyCount, fetchContingencyCount, isBuiltCurrentNode, }: Readonly<{
|
|
4
|
+
name: string;
|
|
4
5
|
showContingencyCount: boolean;
|
|
5
6
|
fetchContingencyCount?: (contingencyLists: UUID[] | null, abortSignal: AbortSignal) => Promise<ContingencyCount>;
|
|
6
7
|
isBuiltCurrentNode?: boolean;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
import { useState, useCallback, useEffect } from "react";
|
|
2
|
+
import { Grid, Alert, CircularProgress } from "@mui/material";
|
|
3
|
+
import { useState, useCallback, useMemo, useEffect } from "react";
|
|
4
4
|
import { useIntl, FormattedMessage } from "react-intl";
|
|
5
|
-
import {
|
|
5
|
+
import { useFormContext } from "react-hook-form";
|
|
6
6
|
import "../../../../utils/conversionUtils.js";
|
|
7
7
|
import { snackWithFallback } from "../../../../utils/error.js";
|
|
8
8
|
import "../../../../utils/types/equipmentType.js";
|
|
@@ -13,40 +13,44 @@ import "localized-countries";
|
|
|
13
13
|
import "localized-countries/data/fr";
|
|
14
14
|
import "localized-countries/data/en";
|
|
15
15
|
import { useSnackMessage } from "../../../../hooks/useSnackMessage.js";
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
|
|
16
|
+
import { ACTIVATED, ID } from "../parameter-table-field/constants.js";
|
|
17
|
+
import { ParameterTableField } from "../parameter-table-field/parameter-table-field.js";
|
|
18
|
+
import { CONTINGENCY_LISTS } from "../constants.js";
|
|
19
|
+
import { COLUMNS_DEFINITIONS_CONTINGENCY_LISTS_INFOS, isValidContingencyRow } from "./columns-definitions.js";
|
|
20
|
+
const styles = {
|
|
21
|
+
alert: { color: "text.primary", paddingTop: 0, paddingBottom: 0 }
|
|
22
|
+
};
|
|
21
23
|
function ContingencyTable({
|
|
24
|
+
name,
|
|
22
25
|
showContingencyCount = false,
|
|
23
26
|
fetchContingencyCount,
|
|
24
27
|
isBuiltCurrentNode
|
|
25
28
|
}) {
|
|
26
29
|
const intl = useIntl();
|
|
27
30
|
const [simulatedContingencyCount, setSimulatedContingencyCount] = useState(null);
|
|
28
|
-
const [rowData, useFieldArrayOutput] = useCreateRowData(ParamContingencyLists);
|
|
29
|
-
const contingencyListsInfos = useWatch({ name: CONTINGENCY_LISTS_INFOS });
|
|
30
31
|
const [isLoading, setIsLoading] = useState(false);
|
|
32
|
+
const [contingencyCountRefreshTrigger, setContingencyCountRefreshTrigger] = useState(0);
|
|
31
33
|
const { snackError } = useSnackMessage();
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
);
|
|
34
|
+
const { getValues } = useFormContext();
|
|
35
|
+
const handleOnChange = useCallback(() => {
|
|
36
|
+
setContingencyCountRefreshTrigger((prevValue) => prevValue + 1);
|
|
37
|
+
}, []);
|
|
38
|
+
const columnsDefinition = useMemo(() => {
|
|
39
|
+
return COLUMNS_DEFINITIONS_CONTINGENCY_LISTS_INFOS.map(
|
|
40
|
+
(colDef) => ({
|
|
41
|
+
...colDef,
|
|
42
|
+
label: intl.formatMessage({ id: colDef.label })
|
|
43
|
+
})
|
|
44
|
+
);
|
|
45
|
+
}, [intl]);
|
|
44
46
|
useEffect(() => {
|
|
45
47
|
if (!showContingencyCount || !isBuiltCurrentNode) {
|
|
46
48
|
setIsLoading(false);
|
|
49
|
+
setSimulatedContingencyCount(null);
|
|
47
50
|
return () => {
|
|
48
51
|
};
|
|
49
52
|
}
|
|
53
|
+
const contingencyListsInfos = getValues(name);
|
|
50
54
|
const hasNoContingencies = !contingencyListsInfos || (contingencyListsInfos.length ?? 0) === 0 || contingencyListsInfos.every(
|
|
51
55
|
(contingencyList) => !contingencyList[ACTIVATED] || (contingencyList[CONTINGENCY_LISTS]?.length ?? 0) === 0
|
|
52
56
|
);
|
|
@@ -80,26 +84,26 @@ function ContingencyTable({
|
|
|
80
84
|
controller?.abort(new Error(IGNORE_SIGNAL));
|
|
81
85
|
clearTimeout(loadingTimeoutId);
|
|
82
86
|
};
|
|
83
|
-
}, [
|
|
87
|
+
}, [
|
|
88
|
+
snackError,
|
|
89
|
+
getValues,
|
|
90
|
+
fetchContingencyCount,
|
|
91
|
+
showContingencyCount,
|
|
92
|
+
isBuiltCurrentNode,
|
|
93
|
+
name,
|
|
94
|
+
contingencyCountRefreshTrigger
|
|
95
|
+
]);
|
|
84
96
|
const renderContingencyCount = () => {
|
|
85
97
|
if (!isBuiltCurrentNode) {
|
|
86
|
-
return /* @__PURE__ */ jsx(Alert, { variant: "standard", severity: "warning", sx:
|
|
98
|
+
return /* @__PURE__ */ jsx(Alert, { variant: "standard", severity: "warning", sx: styles.alert, children: /* @__PURE__ */ jsx(FormattedMessage, { id: "contingencyCountImpossibleOnUnbuiltNode" }) });
|
|
87
99
|
}
|
|
88
100
|
if (isLoading) {
|
|
89
|
-
return /* @__PURE__ */ jsx(
|
|
90
|
-
Alert,
|
|
91
|
-
{
|
|
92
|
-
variant: "standard",
|
|
93
|
-
icon: /* @__PURE__ */ jsx(CircularProgress, { size: 22 }),
|
|
94
|
-
severity: "info",
|
|
95
|
-
sx: { color: "text.primary" }
|
|
96
|
-
}
|
|
97
|
-
);
|
|
101
|
+
return /* @__PURE__ */ jsx(Alert, { variant: "standard", icon: /* @__PURE__ */ jsx(CircularProgress, { size: 22 }), severity: "info", sx: styles.alert });
|
|
98
102
|
}
|
|
99
103
|
if (simulatedContingencyCount?.contingencies === 0 && simulatedContingencyCount.notFoundElements === 0) {
|
|
100
|
-
return /* @__PURE__ */ jsx(Alert, { variant: "standard", severity: "error", sx:
|
|
104
|
+
return /* @__PURE__ */ jsx(Alert, { variant: "standard", severity: "error", sx: styles.alert, children: /* @__PURE__ */ jsx(FormattedMessage, { id: "noContingency" }) });
|
|
101
105
|
}
|
|
102
|
-
return /* @__PURE__ */ jsx(Alert, { variant: "standard", icon: false, severity: "info", sx:
|
|
106
|
+
return /* @__PURE__ */ jsx(Alert, { variant: "standard", icon: false, severity: "info", sx: styles.alert, children: /* @__PURE__ */ jsx(
|
|
103
107
|
FormattedMessage,
|
|
104
108
|
{
|
|
105
109
|
id: "xContingenciesWillBeSimulatedAndYNotFound",
|
|
@@ -110,18 +114,15 @@ function ContingencyTable({
|
|
|
110
114
|
}
|
|
111
115
|
) });
|
|
112
116
|
};
|
|
113
|
-
return /* @__PURE__ */ jsxs(
|
|
117
|
+
return /* @__PURE__ */ jsxs(Grid, { container: true, direction: "column", children: [
|
|
114
118
|
/* @__PURE__ */ jsx(
|
|
115
|
-
|
|
119
|
+
ParameterTableField,
|
|
116
120
|
{
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
columnsDefinition: getColumnsDefinition(COLUMNS_DEFINITIONS_CONTINGENCY_LISTS_INFOS),
|
|
121
|
+
name,
|
|
122
|
+
columnsDefinition,
|
|
120
123
|
tableHeight: 270,
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
},
|
|
124
|
-
isValidParameterRow: (row) => row[CONTINGENCY_LISTS]?.length > 0
|
|
124
|
+
onChange: handleOnChange,
|
|
125
|
+
isValidRow: isValidContingencyRow
|
|
125
126
|
}
|
|
126
127
|
),
|
|
127
128
|
showContingencyCount && renderContingencyCount()
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { ContingencyTable } from "./contingency-table.js";
|
|
2
|
-
import { COLUMNS_DEFINITIONS_CONTINGENCY_LISTS_INFOS,
|
|
2
|
+
import { COLUMNS_DEFINITIONS_CONTINGENCY_LISTS_INFOS, getContingencyListsInfosFormSchema, isValidContingencyRow, toFormValuesContingencyListsInfos } from "./columns-definitions.js";
|
|
3
3
|
export {
|
|
4
4
|
COLUMNS_DEFINITIONS_CONTINGENCY_LISTS_INFOS,
|
|
5
5
|
ContingencyTable,
|
|
6
|
-
ParamContingencyLists,
|
|
7
6
|
getContingencyListsInfosFormSchema,
|
|
7
|
+
isValidContingencyRow,
|
|
8
8
|
toFormValuesContingencyListsInfos
|
|
9
9
|
};
|
|
@@ -17,7 +17,7 @@ import { LimitReductionsTableForm } from "./limitreductions/limit-reductions-tab
|
|
|
17
17
|
import { LimitReductionTableRow } from "./limitreductions/limit-reduction-table-row.js";
|
|
18
18
|
import { LimitReductionTableCell } from "./limitreductions/limit-reduction-table-cell.js";
|
|
19
19
|
import { ContingencyTable } from "./contingency-table/contingency-table.js";
|
|
20
|
-
import { COLUMNS_DEFINITIONS_CONTINGENCY_LISTS_INFOS,
|
|
20
|
+
import { COLUMNS_DEFINITIONS_CONTINGENCY_LISTS_INFOS, getContingencyListsInfosFormSchema, isValidContingencyRow, toFormValuesContingencyListsInfos } from "./contingency-table/columns-definitions.js";
|
|
21
21
|
import { useTabs } from "./hook/use-tabs.js";
|
|
22
22
|
import { useParametersForm } from "./hook/use-parameters-form.js";
|
|
23
23
|
export {
|
|
@@ -48,7 +48,6 @@ export {
|
|
|
48
48
|
PARAM_SA_LOW_VOLTAGE_PROPORTIONAL_THRESHOLD,
|
|
49
49
|
PARAM_SA_PROVIDER,
|
|
50
50
|
PROVIDER,
|
|
51
|
-
ParamContingencyLists,
|
|
52
51
|
ParameterFloat,
|
|
53
52
|
ParameterGroup,
|
|
54
53
|
ParameterLineDirectoryItemsInput,
|
|
@@ -67,6 +66,7 @@ export {
|
|
|
67
66
|
getContingencyListsInfosFormSchema,
|
|
68
67
|
getLimitReductionsFormSchema,
|
|
69
68
|
isValidComputingType,
|
|
69
|
+
isValidContingencyRow,
|
|
70
70
|
sanitizePercentageValue,
|
|
71
71
|
toFormValuesContingencyListsInfos,
|
|
72
72
|
toFormValuesLimitReductions,
|
|
@@ -47,6 +47,8 @@ import { LineSeparator } from "./line-separator.js";
|
|
|
47
47
|
import "../../dialogs/elementSaveDialog/ElementSaveDialog.js";
|
|
48
48
|
import "./widget/parameter-line-slider.js";
|
|
49
49
|
import "./limitreductions/columns-definitions.js";
|
|
50
|
+
import "react-dom";
|
|
51
|
+
import "@hello-pangea/dnd";
|
|
50
52
|
import "./contingency-table/columns-definitions.js";
|
|
51
53
|
import "@hookform/resolvers/yup";
|
|
52
54
|
import "../../filter/HeaderFilterForm.js";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026, RTE (http://www.rte-france.com)
|
|
3
|
+
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
4
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
5
|
+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
6
|
+
*/
|
|
7
|
+
export declare const NAME = "name";
|
|
8
|
+
export declare const ID = "id";
|
|
9
|
+
export declare const ACTIVATED = "activated";
|
|
10
|
+
export declare const DESCRIPTION = "description";
|
package/dist/components/parameters/common/{parameter-table → parameter-table-field}/index.d.ts
RENAMED
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
* Copyright (c) 2026, RTE (http://www.rte-france.com)
|
|
3
3
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
4
4
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
5
|
-
* file, You can obtain one at
|
|
5
|
+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
6
6
|
*/
|
|
7
7
|
export * from './constants';
|
|
8
|
-
export * from './parameter-table';
|
|
9
|
-
export * from './types';
|
|
8
|
+
export * from './parameter-table-field';
|