@gridsuite/commons-ui 0.74.0 → 0.76.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 → contingencyList}/criteriaBased/CriteriaBasedForm.d.ts +1 -1
- package/dist/components/{filter/criteriaBased/criteriaBasedFilterUtils.d.ts → contingencyList/criteriaBased/criteriaBasedUtils.d.ts} +0 -39
- package/dist/components/contingencyList/criteriaBased/criteriaBasedUtils.js +36 -0
- package/dist/components/{filter → contingencyList}/criteriaBased/index.d.ts +1 -6
- package/dist/components/contingencyList/criteriaBased/index.js +7 -0
- package/dist/components/filter/FilterCreationDialog.js +1 -10
- package/dist/components/filter/FilterForm.js +0 -2
- package/dist/components/filter/constants/FilterConstants.d.ts +0 -4
- package/dist/components/filter/constants/FilterConstants.js +0 -1
- package/dist/components/filter/index.d.ts +1 -1
- package/dist/components/filter/index.js +3 -24
- package/dist/components/filter/utils/filterApi.d.ts +0 -1
- package/dist/components/filter/utils/filterApi.js +0 -10
- package/dist/components/filter/utils/index.js +1 -2
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +11 -24
- package/dist/components/notifications/NotificationsProvider.d.ts +6 -0
- package/dist/components/notifications/NotificationsProvider.js +54 -0
- package/dist/components/notifications/contexts/NotificationsContext.d.ts +23 -0
- package/dist/components/notifications/contexts/NotificationsContext.js +14 -0
- package/dist/components/notifications/hooks/useListenerManager.d.ts +7 -0
- package/dist/components/notifications/hooks/useListenerManager.js +50 -0
- package/dist/components/notifications/hooks/useNotificationsListener.d.ts +11 -0
- package/dist/components/notifications/hooks/useNotificationsListener.js +33 -0
- package/dist/components/notifications/index.d.ts +4 -0
- package/dist/components/notifications/index.js +10 -0
- package/dist/index.js +11 -24
- package/dist/translations/en/filterEn.d.ts +0 -1
- package/dist/translations/en/filterEn.js +1 -2
- package/dist/translations/en/networkModificationsEn.d.ts +1 -1
- package/dist/translations/en/networkModificationsEn.js +1 -1
- package/dist/translations/fr/filterFr.d.ts +0 -1
- package/dist/translations/fr/filterFr.js +1 -2
- package/dist/utils/mapper/getFileIcon.js +3 -1
- package/dist/utils/types/elementType.d.ts +2 -1
- package/dist/utils/types/elementType.js +1 -0
- package/package.json +2 -1
- package/dist/components/filter/criteriaBased/CriteriaBasedFilterEditionDialog.d.ts +0 -19
- package/dist/components/filter/criteriaBased/CriteriaBasedFilterEditionDialog.js +0 -103
- package/dist/components/filter/criteriaBased/CriteriaBasedFilterForm.d.ts +0 -49
- package/dist/components/filter/criteriaBased/CriteriaBasedFilterForm.js +0 -33
- package/dist/components/filter/criteriaBased/FilterFreeProperties.d.ts +0 -12
- package/dist/components/filter/criteriaBased/FilterFreeProperties.js +0 -68
- package/dist/components/filter/criteriaBased/FilterProperties.d.ts +0 -15
- package/dist/components/filter/criteriaBased/FilterProperties.js +0 -121
- package/dist/components/filter/criteriaBased/FilterProperty.d.ts +0 -18
- package/dist/components/filter/criteriaBased/FilterProperty.js +0 -65
- package/dist/components/filter/criteriaBased/criteriaBasedFilterUtils.js +0 -158
- package/dist/components/filter/criteriaBased/index.js +0 -27
- /package/dist/components/{filter → contingencyList}/criteriaBased/CriteriaBasedForm.js +0 -0
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import Grid from "@mui/material/Grid";
|
|
3
|
-
import { useMemo, useEffect } from "react";
|
|
4
|
-
import { useWatch } from "react-hook-form";
|
|
5
|
-
import { FormattedMessage } from "react-intl";
|
|
6
|
-
import { Line, Hvdc, Substation, Load, Generator, TwoWindingTransfo, Battery, ShuntCompensator, VoltageLevel } from "../../../utils/types/equipmentTypes.js";
|
|
7
|
-
import { areArrayElementsUnique } from "../../../utils/functions.js";
|
|
8
|
-
import { FieldConstants } from "../../../utils/constants/fieldConstants.js";
|
|
9
|
-
import "../../../utils/yupConfig.js";
|
|
10
|
-
import { FreePropertiesTypes, FilterFreeProperties } from "./FilterFreeProperties.js";
|
|
11
|
-
import { PROPERTY_NAME, PROPERTY_VALUES, PROPERTY_VALUES_1, PROPERTY_VALUES_2 } from "./FilterProperty.js";
|
|
12
|
-
import { usePredefinedProperties } from "../../../hooks/usePredefinedProperties.js";
|
|
13
|
-
import { FilterType } from "../constants/FilterConstants.js";
|
|
14
|
-
import "@mui/icons-material";
|
|
15
|
-
import { EquipmentType } from "../../../utils/types/equipmentType.js";
|
|
16
|
-
import * as yup from "yup";
|
|
17
|
-
function propertyValuesTest(values, context, doublePropertyValues) {
|
|
18
|
-
const rootLevelForm = context.from[context.from.length - 1];
|
|
19
|
-
const filterType = rootLevelForm.value[FieldConstants.FILTER_TYPE];
|
|
20
|
-
if (filterType !== FilterType.CRITERIA_BASED.id) {
|
|
21
|
-
return true;
|
|
22
|
-
}
|
|
23
|
-
const equipmentType = rootLevelForm.value[FieldConstants.EQUIPMENT_TYPE];
|
|
24
|
-
const isForLineOrHvdcLine = equipmentType === Line.type || equipmentType === Hvdc.type;
|
|
25
|
-
if (doublePropertyValues) {
|
|
26
|
-
return isForLineOrHvdcLine ? (values == null ? void 0 : values.length) > 0 : true;
|
|
27
|
-
}
|
|
28
|
-
return isForLineOrHvdcLine || (values == null ? void 0 : values.length) > 0;
|
|
29
|
-
}
|
|
30
|
-
const filterPropertiesYupSchema = {
|
|
31
|
-
[FreePropertiesTypes.SUBSTATION_FILTER_PROPERTIES]: yup.array().of(
|
|
32
|
-
yup.object().shape({
|
|
33
|
-
[PROPERTY_NAME]: yup.string().required(),
|
|
34
|
-
[PROPERTY_VALUES]: yup.array().of(yup.string()).test(
|
|
35
|
-
"can not be empty if not line",
|
|
36
|
-
"YupRequired",
|
|
37
|
-
(values, context) => propertyValuesTest(values, context, false)
|
|
38
|
-
),
|
|
39
|
-
[PROPERTY_VALUES_1]: yup.array().of(yup.string()).test(
|
|
40
|
-
"can not be empty if line",
|
|
41
|
-
"YupRequired",
|
|
42
|
-
(values, context) => propertyValuesTest(values, context, true)
|
|
43
|
-
),
|
|
44
|
-
[PROPERTY_VALUES_2]: yup.array().of(yup.string()).test(
|
|
45
|
-
"can not be empty if line",
|
|
46
|
-
"YupRequired",
|
|
47
|
-
(values, context) => propertyValuesTest(values, context, true)
|
|
48
|
-
)
|
|
49
|
-
})
|
|
50
|
-
).test("distinct names", "filterPropertiesNameUniquenessError", (properties, context) => {
|
|
51
|
-
const rootLevelForm = context.from[context.from.length - 1];
|
|
52
|
-
const filterType = rootLevelForm.value[FieldConstants.FILTER_TYPE];
|
|
53
|
-
if (filterType !== FilterType.CRITERIA_BASED.id) {
|
|
54
|
-
return true;
|
|
55
|
-
}
|
|
56
|
-
const names = properties.filter((prop) => !!prop[PROPERTY_NAME]).map((prop) => prop[PROPERTY_NAME]);
|
|
57
|
-
return areArrayElementsUnique(names);
|
|
58
|
-
}),
|
|
59
|
-
[FreePropertiesTypes.FREE_FILTER_PROPERTIES]: yup.array().of(
|
|
60
|
-
yup.object().shape({
|
|
61
|
-
[PROPERTY_NAME]: yup.string().required(),
|
|
62
|
-
[PROPERTY_VALUES]: yup.array().of(yup.string()).test(
|
|
63
|
-
"can not be empty if not line",
|
|
64
|
-
"YupRequired",
|
|
65
|
-
(values, context) => propertyValuesTest(values, context, false)
|
|
66
|
-
)
|
|
67
|
-
})
|
|
68
|
-
).test("distinct names", "filterPropertiesNameUniquenessError", (properties, context) => {
|
|
69
|
-
const rootLevelForm = context.from[context.from.length - 1];
|
|
70
|
-
const filterType = rootLevelForm.value[FieldConstants.FILTER_TYPE];
|
|
71
|
-
if (filterType !== FilterType.CRITERIA_BASED.id) {
|
|
72
|
-
return true;
|
|
73
|
-
}
|
|
74
|
-
const names = properties.filter((prop) => !!prop[PROPERTY_NAME]).map((prop) => prop[PROPERTY_NAME]);
|
|
75
|
-
return areArrayElementsUnique(names);
|
|
76
|
-
})
|
|
77
|
-
};
|
|
78
|
-
function FilterProperties() {
|
|
79
|
-
const watchEquipmentType = useWatch({
|
|
80
|
-
name: FieldConstants.EQUIPMENT_TYPE
|
|
81
|
-
});
|
|
82
|
-
const [equipmentPredefinedProps, setEquipmentType] = usePredefinedProperties(watchEquipmentType);
|
|
83
|
-
const [substationPredefinedProps, setSubstationType] = usePredefinedProperties(null);
|
|
84
|
-
const displayEquipmentProperties = useMemo(() => {
|
|
85
|
-
return watchEquipmentType === Substation.type || watchEquipmentType === Load.type || watchEquipmentType === Generator.type || watchEquipmentType === Line.type || watchEquipmentType === TwoWindingTransfo.type || watchEquipmentType === Battery.type || watchEquipmentType === ShuntCompensator.type || watchEquipmentType === VoltageLevel.type;
|
|
86
|
-
}, [watchEquipmentType]);
|
|
87
|
-
const displaySubstationProperties = useMemo(() => {
|
|
88
|
-
return watchEquipmentType !== Substation.type && watchEquipmentType !== null;
|
|
89
|
-
}, [watchEquipmentType]);
|
|
90
|
-
useEffect(() => {
|
|
91
|
-
if (displayEquipmentProperties) {
|
|
92
|
-
setEquipmentType(watchEquipmentType);
|
|
93
|
-
}
|
|
94
|
-
}, [displayEquipmentProperties, watchEquipmentType, setEquipmentType]);
|
|
95
|
-
useEffect(() => {
|
|
96
|
-
if (displaySubstationProperties) {
|
|
97
|
-
setSubstationType(EquipmentType.SUBSTATION);
|
|
98
|
-
}
|
|
99
|
-
}, [displaySubstationProperties, setSubstationType]);
|
|
100
|
-
return watchEquipmentType && /* @__PURE__ */ jsx(Grid, { item: true, container: true, spacing: 1, children: /* @__PURE__ */ jsxs(Grid, { item: true, xs: 12, children: [
|
|
101
|
-
/* @__PURE__ */ jsx(FormattedMessage, { id: "FreePropsCrit", children: (txt) => /* @__PURE__ */ jsx("h3", { children: txt }) }),
|
|
102
|
-
displayEquipmentProperties && /* @__PURE__ */ jsx(
|
|
103
|
-
FilterFreeProperties,
|
|
104
|
-
{
|
|
105
|
-
freePropertiesType: FreePropertiesTypes.FREE_FILTER_PROPERTIES,
|
|
106
|
-
predefined: equipmentPredefinedProps
|
|
107
|
-
}
|
|
108
|
-
),
|
|
109
|
-
displaySubstationProperties && /* @__PURE__ */ jsx(
|
|
110
|
-
FilterFreeProperties,
|
|
111
|
-
{
|
|
112
|
-
freePropertiesType: FreePropertiesTypes.SUBSTATION_FILTER_PROPERTIES,
|
|
113
|
-
predefined: substationPredefinedProps
|
|
114
|
-
}
|
|
115
|
-
)
|
|
116
|
-
] }) });
|
|
117
|
-
}
|
|
118
|
-
export {
|
|
119
|
-
FilterProperties,
|
|
120
|
-
filterPropertiesYupSchema
|
|
121
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { PredefinedProperties } from '../../../utils/types/types';
|
|
2
|
-
|
|
3
|
-
export declare const PROPERTY_NAME = "name_property";
|
|
4
|
-
export declare const PROPERTY_VALUES = "prop_values";
|
|
5
|
-
export declare const PROPERTY_VALUES_1 = "prop_values1";
|
|
6
|
-
export declare const PROPERTY_VALUES_2 = "prop_values2";
|
|
7
|
-
interface FilterPropertyProps {
|
|
8
|
-
index: number;
|
|
9
|
-
valuesFields: Array<{
|
|
10
|
-
name: string;
|
|
11
|
-
label: string;
|
|
12
|
-
}>;
|
|
13
|
-
handleDelete: (index: number) => void;
|
|
14
|
-
predefined: PredefinedProperties;
|
|
15
|
-
propertyType: string;
|
|
16
|
-
}
|
|
17
|
-
export declare function FilterProperty(props: FilterPropertyProps): import("react/jsx-runtime").JSX.Element;
|
|
18
|
-
export {};
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useMemo, useCallback } from "react";
|
|
3
|
-
import DeleteIcon from "@mui/icons-material/Delete";
|
|
4
|
-
import IconButton from "@mui/material/IconButton";
|
|
5
|
-
import Grid from "@mui/material/Grid";
|
|
6
|
-
import { useFormContext, useWatch } from "react-hook-form";
|
|
7
|
-
import { AutocompleteInput } from "../../inputs/reactHookForm/autocompleteInputs/AutocompleteInput.js";
|
|
8
|
-
import { MultipleAutocompleteInput } from "../../inputs/reactHookForm/autocompleteInputs/MultipleAutocompleteInput.js";
|
|
9
|
-
import { FieldConstants } from "../../../utils/constants/fieldConstants.js";
|
|
10
|
-
const PROPERTY_NAME = "name_property";
|
|
11
|
-
const PROPERTY_VALUES = "prop_values";
|
|
12
|
-
const PROPERTY_VALUES_1 = "prop_values1";
|
|
13
|
-
const PROPERTY_VALUES_2 = "prop_values2";
|
|
14
|
-
function FilterProperty(props) {
|
|
15
|
-
const { propertyType, index, predefined, valuesFields, handleDelete } = props;
|
|
16
|
-
const { setValue } = useFormContext();
|
|
17
|
-
const watchName = useWatch({
|
|
18
|
-
name: `${FieldConstants.CRITERIA_BASED}.${propertyType}[${index}].${PROPERTY_NAME}`
|
|
19
|
-
});
|
|
20
|
-
const predefinedNames = useMemo(() => {
|
|
21
|
-
return Object.keys(predefined ?? []).sort();
|
|
22
|
-
}, [predefined]);
|
|
23
|
-
const predefinedValues = useMemo(() => {
|
|
24
|
-
const predefinedForName = predefined == null ? void 0 : predefined[watchName];
|
|
25
|
-
if (!predefinedForName) {
|
|
26
|
-
return [];
|
|
27
|
-
}
|
|
28
|
-
return [...new Set(predefinedForName)].sort();
|
|
29
|
-
}, [watchName, predefined]);
|
|
30
|
-
const onNameChange = useCallback(() => {
|
|
31
|
-
valuesFields.forEach(
|
|
32
|
-
(valuesField) => setValue(`${FieldConstants.CRITERIA_BASED}.${propertyType}[${index}].${valuesField.name}`, [])
|
|
33
|
-
);
|
|
34
|
-
}, [setValue, index, valuesFields, propertyType]);
|
|
35
|
-
return /* @__PURE__ */ jsxs(Grid, { container: true, item: true, spacing: 1, columns: 21, children: [
|
|
36
|
-
/* @__PURE__ */ jsx(Grid, { item: true, xs: 6, children: /* @__PURE__ */ jsx(
|
|
37
|
-
AutocompleteInput,
|
|
38
|
-
{
|
|
39
|
-
name: `${FieldConstants.CRITERIA_BASED}.${propertyType}[${index}].${PROPERTY_NAME}`,
|
|
40
|
-
label: "PropertyName",
|
|
41
|
-
options: predefinedNames,
|
|
42
|
-
freeSolo: true,
|
|
43
|
-
autoSelect: true,
|
|
44
|
-
forcePopupIcon: true,
|
|
45
|
-
onChangeCallback: onNameChange
|
|
46
|
-
}
|
|
47
|
-
) }),
|
|
48
|
-
valuesFields.map((valuesField) => /* @__PURE__ */ jsx(Grid, { item: true, xs: true, children: /* @__PURE__ */ jsx(
|
|
49
|
-
MultipleAutocompleteInput,
|
|
50
|
-
{
|
|
51
|
-
name: `${FieldConstants.CRITERIA_BASED}.${propertyType}[${index}].${valuesField.name}`,
|
|
52
|
-
label: valuesField.label,
|
|
53
|
-
options: predefinedValues
|
|
54
|
-
}
|
|
55
|
-
) }, valuesField.name)),
|
|
56
|
-
/* @__PURE__ */ jsx(Grid, { item: true, xs: 1, alignSelf: "center", children: /* @__PURE__ */ jsx(IconButton, { onClick: () => handleDelete(index), children: /* @__PURE__ */ jsx(DeleteIcon, {}) }) })
|
|
57
|
-
] });
|
|
58
|
-
}
|
|
59
|
-
export {
|
|
60
|
-
FilterProperty,
|
|
61
|
-
PROPERTY_NAME,
|
|
62
|
-
PROPERTY_VALUES,
|
|
63
|
-
PROPERTY_VALUES_1,
|
|
64
|
-
PROPERTY_VALUES_2
|
|
65
|
-
};
|
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
import { FieldConstants } from "../../../utils/constants/fieldConstants.js";
|
|
2
|
-
import { PROPERTY_VALUES, PROPERTY_VALUES_1, PROPERTY_VALUES_2, PROPERTY_NAME } from "./FilterProperty.js";
|
|
3
|
-
import { FilterType } from "../constants/FilterConstants.js";
|
|
4
|
-
import "../../../utils/yupConfig.js";
|
|
5
|
-
import { getRangeInputSchema, DEFAULT_RANGE_VALUE } from "../../inputs/reactHookForm/numbers/RangeInput.js";
|
|
6
|
-
import { FreePropertiesTypes } from "./FilterFreeProperties.js";
|
|
7
|
-
import * as yup from "yup";
|
|
8
|
-
function getCriteriaBasedSchema(extraFields = {}) {
|
|
9
|
-
return {
|
|
10
|
-
[FieldConstants.CRITERIA_BASED]: yup.object().shape({
|
|
11
|
-
[FieldConstants.COUNTRIES]: yup.array().of(yup.string().required()),
|
|
12
|
-
[FieldConstants.COUNTRIES_1]: yup.array().of(yup.string().required()),
|
|
13
|
-
[FieldConstants.COUNTRIES_2]: yup.array().of(yup.string().required()),
|
|
14
|
-
...getRangeInputSchema(FieldConstants.NOMINAL_VOLTAGE),
|
|
15
|
-
...getRangeInputSchema(FieldConstants.NOMINAL_VOLTAGE_1),
|
|
16
|
-
...getRangeInputSchema(FieldConstants.NOMINAL_VOLTAGE_2),
|
|
17
|
-
...getRangeInputSchema(FieldConstants.NOMINAL_VOLTAGE_3),
|
|
18
|
-
...extraFields
|
|
19
|
-
})
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
function getCriteriaBasedFormData(criteriaValues, extraFields = {}) {
|
|
23
|
-
return {
|
|
24
|
-
[FieldConstants.CRITERIA_BASED]: {
|
|
25
|
-
[FieldConstants.COUNTRIES]: (criteriaValues == null ? void 0 : criteriaValues[FieldConstants.COUNTRIES]) ?? [],
|
|
26
|
-
[FieldConstants.COUNTRIES_1]: (criteriaValues == null ? void 0 : criteriaValues[FieldConstants.COUNTRIES_1]) ?? [],
|
|
27
|
-
[FieldConstants.COUNTRIES_2]: (criteriaValues == null ? void 0 : criteriaValues[FieldConstants.COUNTRIES_2]) ?? [],
|
|
28
|
-
[FieldConstants.NOMINAL_VOLTAGE]: (criteriaValues == null ? void 0 : criteriaValues[FieldConstants.NOMINAL_VOLTAGE]) ?? DEFAULT_RANGE_VALUE,
|
|
29
|
-
[FieldConstants.NOMINAL_VOLTAGE_1]: (criteriaValues == null ? void 0 : criteriaValues[FieldConstants.NOMINAL_VOLTAGE_1]) ?? DEFAULT_RANGE_VALUE,
|
|
30
|
-
[FieldConstants.NOMINAL_VOLTAGE_2]: (criteriaValues == null ? void 0 : criteriaValues[FieldConstants.NOMINAL_VOLTAGE_2]) ?? DEFAULT_RANGE_VALUE,
|
|
31
|
-
[FieldConstants.NOMINAL_VOLTAGE_3]: (criteriaValues == null ? void 0 : criteriaValues[FieldConstants.NOMINAL_VOLTAGE_3]) ?? DEFAULT_RANGE_VALUE,
|
|
32
|
-
...extraFields
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
function backToFrontTweak(response) {
|
|
37
|
-
const subProps = response.equipmentFilterForm.substationFreeProperties;
|
|
38
|
-
const freeProps = response.equipmentFilterForm.freeProperties;
|
|
39
|
-
const props1 = response.equipmentFilterForm.freeProperties1;
|
|
40
|
-
const props2 = response.equipmentFilterForm.freeProperties2;
|
|
41
|
-
const allKeys = /* @__PURE__ */ new Set();
|
|
42
|
-
if (subProps) {
|
|
43
|
-
Object.keys(subProps).forEach((k) => allKeys.add(k));
|
|
44
|
-
}
|
|
45
|
-
if (props1) {
|
|
46
|
-
Object.keys(props1).forEach((k) => allKeys.add(k));
|
|
47
|
-
}
|
|
48
|
-
if (props2) {
|
|
49
|
-
Object.keys(props2).forEach((k) => allKeys.add(k));
|
|
50
|
-
}
|
|
51
|
-
const filterSubstationProperties = [];
|
|
52
|
-
const filterFreeProperties = [];
|
|
53
|
-
allKeys.forEach((k) => {
|
|
54
|
-
const prop = { [PROPERTY_NAME]: k };
|
|
55
|
-
const values = subProps == null ? void 0 : subProps[k];
|
|
56
|
-
if (values) {
|
|
57
|
-
prop[PROPERTY_VALUES] = values;
|
|
58
|
-
}
|
|
59
|
-
const values1 = props1 == null ? void 0 : props1[k];
|
|
60
|
-
if (values1) {
|
|
61
|
-
prop[PROPERTY_VALUES_1] = values1;
|
|
62
|
-
}
|
|
63
|
-
const values2 = props2 == null ? void 0 : props2[k];
|
|
64
|
-
if (values2) {
|
|
65
|
-
prop[PROPERTY_VALUES_2] = values2;
|
|
66
|
-
}
|
|
67
|
-
filterSubstationProperties.push(prop);
|
|
68
|
-
});
|
|
69
|
-
allKeys.clear();
|
|
70
|
-
if (freeProps) {
|
|
71
|
-
Object.keys(freeProps).forEach((k) => allKeys.add(k));
|
|
72
|
-
}
|
|
73
|
-
allKeys.forEach((k) => {
|
|
74
|
-
const prop = { [PROPERTY_NAME]: k };
|
|
75
|
-
const values = freeProps == null ? void 0 : freeProps[k];
|
|
76
|
-
if (values) {
|
|
77
|
-
prop[PROPERTY_VALUES] = values;
|
|
78
|
-
}
|
|
79
|
-
filterFreeProperties.push(prop);
|
|
80
|
-
});
|
|
81
|
-
return {
|
|
82
|
-
[FieldConstants.EQUIPMENT_TYPE]: response[FieldConstants.EQUIPMENT_TYPE],
|
|
83
|
-
...getCriteriaBasedFormData(response.equipmentFilterForm, {
|
|
84
|
-
[FieldConstants.ENERGY_SOURCE]: response.equipmentFilterForm[FieldConstants.ENERGY_SOURCE],
|
|
85
|
-
[FreePropertiesTypes.SUBSTATION_FILTER_PROPERTIES]: filterSubstationProperties,
|
|
86
|
-
[FreePropertiesTypes.FREE_FILTER_PROPERTIES]: filterFreeProperties
|
|
87
|
-
})
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
function isNominalVoltageEmpty(nominalVoltage) {
|
|
91
|
-
return nominalVoltage[FieldConstants.VALUE_1] === null && nominalVoltage[FieldConstants.VALUE_2] === null;
|
|
92
|
-
}
|
|
93
|
-
function cleanNominalVoltages(formValues) {
|
|
94
|
-
const cleanedFormValues = { ...formValues };
|
|
95
|
-
if (isNominalVoltageEmpty(cleanedFormValues[FieldConstants.NOMINAL_VOLTAGE])) {
|
|
96
|
-
cleanedFormValues[FieldConstants.NOMINAL_VOLTAGE] = null;
|
|
97
|
-
}
|
|
98
|
-
if (isNominalVoltageEmpty(cleanedFormValues[FieldConstants.NOMINAL_VOLTAGE_1])) {
|
|
99
|
-
cleanedFormValues[FieldConstants.NOMINAL_VOLTAGE_1] = null;
|
|
100
|
-
}
|
|
101
|
-
if (isNominalVoltageEmpty(cleanedFormValues[FieldConstants.NOMINAL_VOLTAGE_2])) {
|
|
102
|
-
cleanedFormValues[FieldConstants.NOMINAL_VOLTAGE_2] = null;
|
|
103
|
-
}
|
|
104
|
-
if (isNominalVoltageEmpty(cleanedFormValues[FieldConstants.NOMINAL_VOLTAGE_3])) {
|
|
105
|
-
cleanedFormValues[FieldConstants.NOMINAL_VOLTAGE_3] = null;
|
|
106
|
-
}
|
|
107
|
-
return cleanedFormValues;
|
|
108
|
-
}
|
|
109
|
-
function frontToBackTweak(id, filter) {
|
|
110
|
-
const filterSubstationProperties = filter[FieldConstants.CRITERIA_BASED][FreePropertiesTypes.SUBSTATION_FILTER_PROPERTIES];
|
|
111
|
-
const eff = {
|
|
112
|
-
[FieldConstants.EQUIPMENT_TYPE]: filter[FieldConstants.EQUIPMENT_TYPE],
|
|
113
|
-
...cleanNominalVoltages(filter[FieldConstants.CRITERIA_BASED])
|
|
114
|
-
};
|
|
115
|
-
delete eff[FreePropertiesTypes.SUBSTATION_FILTER_PROPERTIES];
|
|
116
|
-
const props = {};
|
|
117
|
-
const props1 = {};
|
|
118
|
-
const props2 = {};
|
|
119
|
-
filterSubstationProperties.forEach((prop) => {
|
|
120
|
-
const values = prop[PROPERTY_VALUES];
|
|
121
|
-
const values1 = prop[PROPERTY_VALUES_1];
|
|
122
|
-
const values2 = prop[PROPERTY_VALUES_2];
|
|
123
|
-
if (values) {
|
|
124
|
-
props[prop[PROPERTY_NAME]] = values;
|
|
125
|
-
}
|
|
126
|
-
if (values1) {
|
|
127
|
-
props1[prop[PROPERTY_NAME]] = values1;
|
|
128
|
-
}
|
|
129
|
-
if (values2) {
|
|
130
|
-
props2[prop[PROPERTY_NAME]] = values2;
|
|
131
|
-
}
|
|
132
|
-
});
|
|
133
|
-
eff.substationFreeProperties = props;
|
|
134
|
-
eff.freeProperties1 = props1;
|
|
135
|
-
eff.freeProperties2 = props2;
|
|
136
|
-
const filterFreeProperties = filter[FieldConstants.CRITERIA_BASED][FreePropertiesTypes.FREE_FILTER_PROPERTIES];
|
|
137
|
-
delete eff[FreePropertiesTypes.FREE_FILTER_PROPERTIES];
|
|
138
|
-
const freeProps = {};
|
|
139
|
-
filterFreeProperties.forEach((prop) => {
|
|
140
|
-
const values = prop[PROPERTY_VALUES];
|
|
141
|
-
if (values) {
|
|
142
|
-
freeProps[prop[PROPERTY_NAME]] = values;
|
|
143
|
-
}
|
|
144
|
-
});
|
|
145
|
-
eff.freeProperties = freeProps;
|
|
146
|
-
return {
|
|
147
|
-
id,
|
|
148
|
-
type: FilterType.CRITERIA_BASED.id,
|
|
149
|
-
// in the back end we store everything in a field called equipmentFilterForm
|
|
150
|
-
equipmentFilterForm: eff
|
|
151
|
-
};
|
|
152
|
-
}
|
|
153
|
-
export {
|
|
154
|
-
backToFrontTweak,
|
|
155
|
-
frontToBackTweak,
|
|
156
|
-
getCriteriaBasedFormData,
|
|
157
|
-
getCriteriaBasedSchema
|
|
158
|
-
};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { CriteriaBasedFilterEditionDialog } from "./CriteriaBasedFilterEditionDialog.js";
|
|
2
|
-
import { CriteriaBasedFilterForm, criteriaBasedFilterEmptyFormData, criteriaBasedFilterSchema } from "./CriteriaBasedFilterForm.js";
|
|
3
|
-
import { CriteriaBasedForm } from "./CriteriaBasedForm.js";
|
|
4
|
-
import { FilterFreeProperties, FreePropertiesTypes } from "./FilterFreeProperties.js";
|
|
5
|
-
import { FilterProperties, filterPropertiesYupSchema } from "./FilterProperties.js";
|
|
6
|
-
import { FilterProperty, PROPERTY_NAME, PROPERTY_VALUES, PROPERTY_VALUES_1, PROPERTY_VALUES_2 } from "./FilterProperty.js";
|
|
7
|
-
import { backToFrontTweak, frontToBackTweak, getCriteriaBasedFormData, getCriteriaBasedSchema } from "./criteriaBasedFilterUtils.js";
|
|
8
|
-
export {
|
|
9
|
-
CriteriaBasedFilterEditionDialog,
|
|
10
|
-
CriteriaBasedFilterForm,
|
|
11
|
-
CriteriaBasedForm,
|
|
12
|
-
FilterFreeProperties,
|
|
13
|
-
FilterProperties,
|
|
14
|
-
FilterProperty,
|
|
15
|
-
FreePropertiesTypes,
|
|
16
|
-
PROPERTY_NAME,
|
|
17
|
-
PROPERTY_VALUES,
|
|
18
|
-
PROPERTY_VALUES_1,
|
|
19
|
-
PROPERTY_VALUES_2,
|
|
20
|
-
backToFrontTweak,
|
|
21
|
-
criteriaBasedFilterEmptyFormData,
|
|
22
|
-
criteriaBasedFilterSchema,
|
|
23
|
-
filterPropertiesYupSchema,
|
|
24
|
-
frontToBackTweak,
|
|
25
|
-
getCriteriaBasedFormData,
|
|
26
|
-
getCriteriaBasedSchema
|
|
27
|
-
};
|
|
File without changes
|