@gridsuite/commons-ui 0.75.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.js +3 -24
- package/dist/index.js +3 -24
- package/dist/translations/en/filterEn.d.ts +0 -1
- package/dist/translations/en/filterEn.js +1 -2
- package/dist/translations/fr/filterFr.d.ts +0 -1
- package/dist/translations/fr/filterFr.js +1 -2
- package/package.json +1 -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
|
@@ -59,42 +59,3 @@ export declare function getCriteriaBasedFormData(criteriaValues?: Record<string,
|
|
|
59
59
|
readonly nominalVoltage3: any;
|
|
60
60
|
};
|
|
61
61
|
};
|
|
62
|
-
/**
|
|
63
|
-
* Transform
|
|
64
|
-
* from obj.equipmentFilterForm.{
|
|
65
|
-
* freeProperties.{nameB:valuesB},
|
|
66
|
-
* freeProperties1.{nameA:valuesA},
|
|
67
|
-
* freeProperties2.{nameA:valuesC}}
|
|
68
|
-
* to a obj.criteriaBased.freeProperties.[
|
|
69
|
-
* {name_property:nameA, prop_values1:valuesA, prop_values2:valuesC},
|
|
70
|
-
* {name_property:namesB, prop_values:valuesB}]
|
|
71
|
-
* @author Laurent LAUGARN modified by Florent MILLOT
|
|
72
|
-
*/
|
|
73
|
-
export declare function backToFrontTweak(response: any): {
|
|
74
|
-
readonly criteriaBased: {
|
|
75
|
-
readonly countries: any;
|
|
76
|
-
readonly countries1: any;
|
|
77
|
-
readonly countries2: any;
|
|
78
|
-
readonly nominalVoltage: any;
|
|
79
|
-
readonly nominalVoltage1: any;
|
|
80
|
-
readonly nominalVoltage2: any;
|
|
81
|
-
readonly nominalVoltage3: any;
|
|
82
|
-
};
|
|
83
|
-
readonly equipmentType: any;
|
|
84
|
-
};
|
|
85
|
-
/**
|
|
86
|
-
* Transform
|
|
87
|
-
* from obj.criteriaBased.freeProperties.[
|
|
88
|
-
* {name_property:nameA, prop_values1:valuesA, prop_values2:valuesC},
|
|
89
|
-
* {name_property:namesB, prop_values:valuesB}]
|
|
90
|
-
* to obj.equipmentFilterForm.{
|
|
91
|
-
* freeProperties.{nameB:valuesB},
|
|
92
|
-
* freeProperties1.{nameA:valuesA},
|
|
93
|
-
* freeProperties2.{nameA:valuesC}}
|
|
94
|
-
* @author Laurent LAUGARN modified by Florent MILLOT
|
|
95
|
-
*/
|
|
96
|
-
export declare function frontToBackTweak(id?: string, filter?: any): {
|
|
97
|
-
id: string | undefined;
|
|
98
|
-
type: string;
|
|
99
|
-
equipmentFilterForm: any;
|
|
100
|
-
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { FieldConstants } from "../../../utils/constants/fieldConstants.js";
|
|
2
|
+
import "../../../utils/yupConfig.js";
|
|
3
|
+
import { getRangeInputSchema, DEFAULT_RANGE_VALUE } from "../../inputs/reactHookForm/numbers/RangeInput.js";
|
|
4
|
+
import * as yup from "yup";
|
|
5
|
+
function getCriteriaBasedSchema(extraFields = {}) {
|
|
6
|
+
return {
|
|
7
|
+
[FieldConstants.CRITERIA_BASED]: yup.object().shape({
|
|
8
|
+
[FieldConstants.COUNTRIES]: yup.array().of(yup.string().required()),
|
|
9
|
+
[FieldConstants.COUNTRIES_1]: yup.array().of(yup.string().required()),
|
|
10
|
+
[FieldConstants.COUNTRIES_2]: yup.array().of(yup.string().required()),
|
|
11
|
+
...getRangeInputSchema(FieldConstants.NOMINAL_VOLTAGE),
|
|
12
|
+
...getRangeInputSchema(FieldConstants.NOMINAL_VOLTAGE_1),
|
|
13
|
+
...getRangeInputSchema(FieldConstants.NOMINAL_VOLTAGE_2),
|
|
14
|
+
...getRangeInputSchema(FieldConstants.NOMINAL_VOLTAGE_3),
|
|
15
|
+
...extraFields
|
|
16
|
+
})
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
function getCriteriaBasedFormData(criteriaValues, extraFields = {}) {
|
|
20
|
+
return {
|
|
21
|
+
[FieldConstants.CRITERIA_BASED]: {
|
|
22
|
+
[FieldConstants.COUNTRIES]: (criteriaValues == null ? void 0 : criteriaValues[FieldConstants.COUNTRIES]) ?? [],
|
|
23
|
+
[FieldConstants.COUNTRIES_1]: (criteriaValues == null ? void 0 : criteriaValues[FieldConstants.COUNTRIES_1]) ?? [],
|
|
24
|
+
[FieldConstants.COUNTRIES_2]: (criteriaValues == null ? void 0 : criteriaValues[FieldConstants.COUNTRIES_2]) ?? [],
|
|
25
|
+
[FieldConstants.NOMINAL_VOLTAGE]: (criteriaValues == null ? void 0 : criteriaValues[FieldConstants.NOMINAL_VOLTAGE]) ?? DEFAULT_RANGE_VALUE,
|
|
26
|
+
[FieldConstants.NOMINAL_VOLTAGE_1]: (criteriaValues == null ? void 0 : criteriaValues[FieldConstants.NOMINAL_VOLTAGE_1]) ?? DEFAULT_RANGE_VALUE,
|
|
27
|
+
[FieldConstants.NOMINAL_VOLTAGE_2]: (criteriaValues == null ? void 0 : criteriaValues[FieldConstants.NOMINAL_VOLTAGE_2]) ?? DEFAULT_RANGE_VALUE,
|
|
28
|
+
[FieldConstants.NOMINAL_VOLTAGE_3]: (criteriaValues == null ? void 0 : criteriaValues[FieldConstants.NOMINAL_VOLTAGE_3]) ?? DEFAULT_RANGE_VALUE,
|
|
29
|
+
...extraFields
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
export {
|
|
34
|
+
getCriteriaBasedFormData,
|
|
35
|
+
getCriteriaBasedSchema
|
|
36
|
+
};
|
|
@@ -4,10 +4,5 @@
|
|
|
4
4
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
5
5
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
6
6
|
*/
|
|
7
|
-
export * from './CriteriaBasedFilterEditionDialog';
|
|
8
|
-
export * from './CriteriaBasedFilterForm';
|
|
9
7
|
export * from './CriteriaBasedForm';
|
|
10
|
-
export * from './
|
|
11
|
-
export * from './FilterProperties';
|
|
12
|
-
export * from './FilterProperty';
|
|
13
|
-
export * from './criteriaBasedFilterUtils';
|
|
8
|
+
export * from './criteriaBasedUtils';
|
|
@@ -2,10 +2,9 @@ import { jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { useCallback } from "react";
|
|
3
3
|
import { useForm } from "react-hook-form";
|
|
4
4
|
import { yupResolver } from "@hookform/resolvers/yup";
|
|
5
|
-
import { saveExplicitNamingFilter,
|
|
5
|
+
import { saveExplicitNamingFilter, saveExpertFilter } from "./utils/filterApi.js";
|
|
6
6
|
import { useSnackMessage } from "../../hooks/useSnackMessage.js";
|
|
7
7
|
import { CustomMuiDialog } from "../dialogs/customMuiDialog/CustomMuiDialog.js";
|
|
8
|
-
import { criteriaBasedFilterEmptyFormData, criteriaBasedFilterSchema } from "./criteriaBased/CriteriaBasedFilterForm.js";
|
|
9
8
|
import { getExplicitNamingFilterEmptyFormData, explicitNamingFilterSchema, FILTER_EQUIPMENTS_ATTRIBUTES } from "./explicitNaming/ExplicitNamingFilterForm.js";
|
|
10
9
|
import { FieldConstants } from "../../utils/constants/fieldConstants.js";
|
|
11
10
|
import "../../utils/yupConfig.js";
|
|
@@ -18,7 +17,6 @@ const emptyFormData = {
|
|
|
18
17
|
[FieldConstants.DESCRIPTION]: "",
|
|
19
18
|
[FieldConstants.FILTER_TYPE]: FilterType.EXPERT.id,
|
|
20
19
|
[FieldConstants.EQUIPMENT_TYPE]: null,
|
|
21
|
-
...criteriaBasedFilterEmptyFormData,
|
|
22
20
|
...getExplicitNamingFilterEmptyFormData(),
|
|
23
21
|
...getExpertFilterEmptyFormData()
|
|
24
22
|
};
|
|
@@ -27,7 +25,6 @@ const formSchema = yup.object().shape({
|
|
|
27
25
|
[FieldConstants.DESCRIPTION]: yup.string().max(500, "descriptionLimitError"),
|
|
28
26
|
[FieldConstants.FILTER_TYPE]: yup.string().required(),
|
|
29
27
|
[FieldConstants.EQUIPMENT_TYPE]: yup.string().required(),
|
|
30
|
-
...criteriaBasedFilterSchema,
|
|
31
28
|
...explicitNamingFilterSchema,
|
|
32
29
|
...expertFilterSchema
|
|
33
30
|
}).required();
|
|
@@ -68,12 +65,6 @@ function FilterCreationDialog({
|
|
|
68
65
|
onClose,
|
|
69
66
|
activeDirectory
|
|
70
67
|
);
|
|
71
|
-
} else if (filterForm[FieldConstants.FILTER_TYPE] === FilterType.CRITERIA_BASED.id) {
|
|
72
|
-
saveCriteriaBasedFilter(filterForm, activeDirectory, onClose, (error) => {
|
|
73
|
-
snackError({
|
|
74
|
-
messageTxt: error
|
|
75
|
-
});
|
|
76
|
-
});
|
|
77
68
|
} else if (filterForm[FieldConstants.FILTER_TYPE] === FilterType.EXPERT.id) {
|
|
78
69
|
saveExpertFilter(
|
|
79
70
|
null,
|
|
@@ -4,7 +4,6 @@ import { useFormContext, useWatch } from "react-hook-form";
|
|
|
4
4
|
import { useEffect } from "react";
|
|
5
5
|
import { HeaderFilterForm } from "./HeaderFilterForm.js";
|
|
6
6
|
import { FieldConstants } from "../../utils/constants/fieldConstants.js";
|
|
7
|
-
import { CriteriaBasedFilterForm } from "./criteriaBased/CriteriaBasedFilterForm.js";
|
|
8
7
|
import { ExplicitNamingFilterForm } from "./explicitNaming/ExplicitNamingFilterForm.js";
|
|
9
8
|
import { ExpertFilterForm } from "./expert/ExpertFilterForm.js";
|
|
10
9
|
import { FilterType } from "./constants/FilterConstants.js";
|
|
@@ -47,7 +46,6 @@ function FilterForm({
|
|
|
47
46
|
handleFilterTypeChange
|
|
48
47
|
}
|
|
49
48
|
) }),
|
|
50
|
-
filterType === FilterType.CRITERIA_BASED.id && /* @__PURE__ */ jsx(CriteriaBasedFilterForm, {}),
|
|
51
49
|
filterType === FilterType.EXPLICIT_NAMING.id && /* @__PURE__ */ jsx(
|
|
52
50
|
ExplicitNamingFilterForm,
|
|
53
51
|
{
|
|
@@ -2,10 +2,6 @@ import { ItemSelectionForCopy } from '../filter.type';
|
|
|
2
2
|
|
|
3
3
|
export declare const DISTRIBUTION_KEY = "distributionKey";
|
|
4
4
|
export declare const FilterType: {
|
|
5
|
-
CRITERIA_BASED: {
|
|
6
|
-
id: string;
|
|
7
|
-
label: string;
|
|
8
|
-
};
|
|
9
5
|
EXPLICIT_NAMING: {
|
|
10
6
|
id: string;
|
|
11
7
|
label: string;
|
|
@@ -8,7 +8,7 @@ export * from './filter.type';
|
|
|
8
8
|
export * from './FilterCreationDialog';
|
|
9
9
|
export * from './FilterForm';
|
|
10
10
|
export * from './constants/FilterConstants';
|
|
11
|
-
export * from '
|
|
11
|
+
export * from '../contingencyList/criteriaBased';
|
|
12
12
|
export * from './expert';
|
|
13
13
|
export * from './explicitNaming';
|
|
14
14
|
export * from './utils';
|
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
import { FilterCreationDialog } from "./FilterCreationDialog.js";
|
|
2
2
|
import { FilterForm } from "./FilterForm.js";
|
|
3
3
|
import { DISTRIBUTION_KEY, FilterType, NO_ITEM_SELECTION_FOR_COPY } from "./constants/FilterConstants.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { CriteriaBasedForm } from "./criteriaBased/CriteriaBasedForm.js";
|
|
7
|
-
import { FilterFreeProperties, FreePropertiesTypes } from "./criteriaBased/FilterFreeProperties.js";
|
|
8
|
-
import { FilterProperties, filterPropertiesYupSchema } from "./criteriaBased/FilterProperties.js";
|
|
9
|
-
import { FilterProperty, PROPERTY_NAME, PROPERTY_VALUES, PROPERTY_VALUES_1, PROPERTY_VALUES_2 } from "./criteriaBased/FilterProperty.js";
|
|
10
|
-
import { backToFrontTweak, frontToBackTweak, getCriteriaBasedFormData, getCriteriaBasedSchema } from "./criteriaBased/criteriaBasedFilterUtils.js";
|
|
4
|
+
import { CriteriaBasedForm } from "../contingencyList/criteriaBased/CriteriaBasedForm.js";
|
|
5
|
+
import { getCriteriaBasedFormData, getCriteriaBasedSchema } from "../contingencyList/criteriaBased/criteriaBasedUtils.js";
|
|
11
6
|
import { ExpertFilterEditionDialog } from "./expert/ExpertFilterEditionDialog.js";
|
|
12
7
|
import { EXPERT_FILTER_QUERY, ExpertFilterForm, expertFilterSchema, getExpertFilterEmptyFormData, rqbQuerySchemaValidator } from "./expert/ExpertFilterForm.js";
|
|
13
8
|
import { CombinatorType, DataType, FieldType, OperatorType } from "./expert/expertFilter.type.js";
|
|
@@ -15,15 +10,13 @@ import { COMBINATOR_OPTIONS, CONVERTERS_MODE_OPTIONS, ENERGY_SOURCE_OPTIONS, EXP
|
|
|
15
10
|
import { countRules, exportExpertRules, getNumberOfSiblings, getOperators, importExpertRules, queryValidator, recursiveRemove, testQuery } from "./expert/expertFilterUtils.js";
|
|
16
11
|
import { ExplicitNamingFilterEditionDialog } from "./explicitNaming/ExplicitNamingFilterEditionDialog.js";
|
|
17
12
|
import { ExplicitNamingFilterForm, FILTER_EQUIPMENTS_ATTRIBUTES, explicitNamingFilterSchema, getExplicitNamingFilterEmptyFormData } from "./explicitNaming/ExplicitNamingFilterForm.js";
|
|
18
|
-
import {
|
|
13
|
+
import { saveExpertFilter, saveExplicitNamingFilter } from "./utils/filterApi.js";
|
|
19
14
|
import { CONTINGENCY_LIST_EQUIPMENTS, FILTER_EQUIPMENTS } from "./utils/filterFormUtils.js";
|
|
20
15
|
export {
|
|
21
16
|
COMBINATOR_OPTIONS,
|
|
22
17
|
CONTINGENCY_LIST_EQUIPMENTS,
|
|
23
18
|
CONVERTERS_MODE_OPTIONS,
|
|
24
19
|
CombinatorType,
|
|
25
|
-
CriteriaBasedFilterEditionDialog,
|
|
26
|
-
CriteriaBasedFilterForm,
|
|
27
20
|
CriteriaBasedForm,
|
|
28
21
|
DISTRIBUTION_KEY,
|
|
29
22
|
DataType,
|
|
@@ -41,34 +34,21 @@ export {
|
|
|
41
34
|
FieldType,
|
|
42
35
|
FilterCreationDialog,
|
|
43
36
|
FilterForm,
|
|
44
|
-
FilterFreeProperties,
|
|
45
|
-
FilterProperties,
|
|
46
|
-
FilterProperty,
|
|
47
37
|
FilterType,
|
|
48
|
-
FreePropertiesTypes,
|
|
49
38
|
LOAD_TYPE_OPTIONS,
|
|
50
39
|
NO_ITEM_SELECTION_FOR_COPY,
|
|
51
40
|
OPERATOR_OPTIONS,
|
|
52
41
|
OperatorType,
|
|
53
42
|
PHASE_REGULATION_MODE_OPTIONS,
|
|
54
|
-
PROPERTY_NAME,
|
|
55
|
-
PROPERTY_VALUES,
|
|
56
|
-
PROPERTY_VALUES_1,
|
|
57
|
-
PROPERTY_VALUES_2,
|
|
58
43
|
RATIO_REGULATION_MODE_OPTIONS,
|
|
59
44
|
REGULATION_TYPE_OPTIONS,
|
|
60
45
|
RULES,
|
|
61
46
|
SHUNT_COMPENSATOR_TYPE_OPTIONS,
|
|
62
47
|
SVAR_REGULATION_MODE_OPTIONS,
|
|
63
|
-
backToFrontTweak,
|
|
64
48
|
countRules,
|
|
65
|
-
criteriaBasedFilterEmptyFormData,
|
|
66
|
-
criteriaBasedFilterSchema,
|
|
67
49
|
expertFilterSchema,
|
|
68
50
|
explicitNamingFilterSchema,
|
|
69
51
|
exportExpertRules,
|
|
70
|
-
filterPropertiesYupSchema,
|
|
71
|
-
frontToBackTweak,
|
|
72
52
|
getCriteriaBasedFormData,
|
|
73
53
|
getCriteriaBasedSchema,
|
|
74
54
|
getExpertFilterEmptyFormData,
|
|
@@ -79,7 +59,6 @@ export {
|
|
|
79
59
|
queryValidator,
|
|
80
60
|
recursiveRemove,
|
|
81
61
|
rqbQuerySchemaValidator,
|
|
82
|
-
saveCriteriaBasedFilter,
|
|
83
62
|
saveExpertFilter,
|
|
84
63
|
saveExplicitNamingFilter,
|
|
85
64
|
testQuery
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { UUID } from 'crypto';
|
|
2
2
|
|
|
3
3
|
export declare const saveExplicitNamingFilter: (tableValues: any[], isFilterCreation: boolean, equipmentType: string, name: string, description: string, id: string | null, setCreateFilterErr: (value?: string) => void, handleClose: () => void, activeDirectory?: UUID, token?: string) => void;
|
|
4
|
-
export declare const saveCriteriaBasedFilter: (filter: any, activeDirectory: any, onClose: () => void, onError: (message: string) => void, token?: string) => void;
|
|
5
4
|
export declare const saveExpertFilter: (id: string | null, query: any, equipmentType: string, name: string, description: string, isFilterCreation: boolean, activeDirectory: any, onClose: () => void, onError: (message: string) => void, token?: string) => void;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { FieldConstants } from "../../../utils/constants/fieldConstants.js";
|
|
2
|
-
import { frontToBackTweak } from "../criteriaBased/criteriaBasedFilterUtils.js";
|
|
3
2
|
import { Generator, Load } from "../../../utils/types/equipmentTypes.js";
|
|
4
3
|
import { exportExpertRules } from "../expert/expertFilterUtils.js";
|
|
5
4
|
import { DISTRIBUTION_KEY, FilterType } from "../constants/FilterConstants.js";
|
|
@@ -50,14 +49,6 @@ const saveExplicitNamingFilter = (tableValues, isFilterCreation, equipmentType,
|
|
|
50
49
|
});
|
|
51
50
|
}
|
|
52
51
|
};
|
|
53
|
-
const saveCriteriaBasedFilter = (filter, activeDirectory, onClose, onError, token) => {
|
|
54
|
-
const filterForBack = frontToBackTweak(void 0, filter);
|
|
55
|
-
createFilter(filterForBack, filter[FieldConstants.NAME], filter[FieldConstants.DESCRIPTION], activeDirectory, token).then(() => {
|
|
56
|
-
onClose();
|
|
57
|
-
}).catch((error) => {
|
|
58
|
-
onError(error.message);
|
|
59
|
-
});
|
|
60
|
-
};
|
|
61
52
|
const saveExpertFilter = (id, query, equipmentType, name, description, isFilterCreation, activeDirectory, onClose, onError, token) => {
|
|
62
53
|
if (isFilterCreation) {
|
|
63
54
|
createFilter(
|
|
@@ -93,7 +84,6 @@ const saveExpertFilter = (id, query, equipmentType, name, description, isFilterC
|
|
|
93
84
|
}
|
|
94
85
|
};
|
|
95
86
|
export {
|
|
96
|
-
saveCriteriaBasedFilter,
|
|
97
87
|
saveExpertFilter,
|
|
98
88
|
saveExplicitNamingFilter
|
|
99
89
|
};
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { saveExpertFilter, saveExplicitNamingFilter } from "./filterApi.js";
|
|
2
2
|
import { CONTINGENCY_LIST_EQUIPMENTS, FILTER_EQUIPMENTS } from "./filterFormUtils.js";
|
|
3
3
|
export {
|
|
4
4
|
CONTINGENCY_LIST_EQUIPMENTS,
|
|
5
5
|
FILTER_EQUIPMENTS,
|
|
6
|
-
saveCriteriaBasedFilter,
|
|
7
6
|
saveExpertFilter,
|
|
8
7
|
saveExplicitNamingFilter
|
|
9
8
|
};
|
package/dist/components/index.js
CHANGED
|
@@ -26,13 +26,8 @@ import { TagRenderer } from "./elementSearch/tagRenderer/TagRenderer.js";
|
|
|
26
26
|
import { FilterCreationDialog } from "./filter/FilterCreationDialog.js";
|
|
27
27
|
import { FilterForm } from "./filter/FilterForm.js";
|
|
28
28
|
import { DISTRIBUTION_KEY, FilterType, NO_ITEM_SELECTION_FOR_COPY } from "./filter/constants/FilterConstants.js";
|
|
29
|
-
import {
|
|
30
|
-
import {
|
|
31
|
-
import { CriteriaBasedForm } from "./filter/criteriaBased/CriteriaBasedForm.js";
|
|
32
|
-
import { FilterFreeProperties, FreePropertiesTypes } from "./filter/criteriaBased/FilterFreeProperties.js";
|
|
33
|
-
import { FilterProperties, filterPropertiesYupSchema } from "./filter/criteriaBased/FilterProperties.js";
|
|
34
|
-
import { FilterProperty, PROPERTY_NAME, PROPERTY_VALUES, PROPERTY_VALUES_1, PROPERTY_VALUES_2 } from "./filter/criteriaBased/FilterProperty.js";
|
|
35
|
-
import { backToFrontTweak, frontToBackTweak, getCriteriaBasedFormData, getCriteriaBasedSchema } from "./filter/criteriaBased/criteriaBasedFilterUtils.js";
|
|
29
|
+
import { CriteriaBasedForm } from "./contingencyList/criteriaBased/CriteriaBasedForm.js";
|
|
30
|
+
import { getCriteriaBasedFormData, getCriteriaBasedSchema } from "./contingencyList/criteriaBased/criteriaBasedUtils.js";
|
|
36
31
|
import { ExpertFilterEditionDialog } from "./filter/expert/ExpertFilterEditionDialog.js";
|
|
37
32
|
import { EXPERT_FILTER_QUERY, ExpertFilterForm, expertFilterSchema, getExpertFilterEmptyFormData, rqbQuerySchemaValidator } from "./filter/expert/ExpertFilterForm.js";
|
|
38
33
|
import { CombinatorType, DataType, FieldType, OperatorType } from "./filter/expert/expertFilter.type.js";
|
|
@@ -40,7 +35,7 @@ import { COMBINATOR_OPTIONS, CONVERTERS_MODE_OPTIONS, ENERGY_SOURCE_OPTIONS, EXP
|
|
|
40
35
|
import { countRules, exportExpertRules, getNumberOfSiblings, getOperators, importExpertRules, queryValidator, recursiveRemove, testQuery } from "./filter/expert/expertFilterUtils.js";
|
|
41
36
|
import { ExplicitNamingFilterEditionDialog } from "./filter/explicitNaming/ExplicitNamingFilterEditionDialog.js";
|
|
42
37
|
import { ExplicitNamingFilterForm, FILTER_EQUIPMENTS_ATTRIBUTES, explicitNamingFilterSchema, getExplicitNamingFilterEmptyFormData } from "./filter/explicitNaming/ExplicitNamingFilterForm.js";
|
|
43
|
-
import {
|
|
38
|
+
import { saveExpertFilter, saveExplicitNamingFilter } from "./filter/utils/filterApi.js";
|
|
44
39
|
import { CONTINGENCY_LIST_EQUIPMENTS, FILTER_EQUIPMENTS } from "./filter/utils/filterFormUtils.js";
|
|
45
40
|
import { FlatParameters, extractDefault } from "./flatParameters/FlatParameters.js";
|
|
46
41
|
import { SelectClearable } from "./inputs/SelectClearable.js";
|
|
@@ -130,8 +125,6 @@ export {
|
|
|
130
125
|
CombinatorType,
|
|
131
126
|
CountriesInput,
|
|
132
127
|
CountryValueEditor,
|
|
133
|
-
CriteriaBasedFilterEditionDialog,
|
|
134
|
-
CriteriaBasedFilterForm,
|
|
135
128
|
CriteriaBasedForm,
|
|
136
129
|
CsvUploader,
|
|
137
130
|
CustomAGGrid,
|
|
@@ -174,13 +167,9 @@ export {
|
|
|
174
167
|
FieldType,
|
|
175
168
|
FilterCreationDialog,
|
|
176
169
|
FilterForm,
|
|
177
|
-
FilterFreeProperties,
|
|
178
|
-
FilterProperties,
|
|
179
|
-
FilterProperty,
|
|
180
170
|
FilterType,
|
|
181
171
|
FlatParameters,
|
|
182
172
|
FloatInput,
|
|
183
|
-
FreePropertiesTypes,
|
|
184
173
|
GridLogo,
|
|
185
174
|
GroupValueEditor,
|
|
186
175
|
InputWithPopupConfirmation,
|
|
@@ -205,10 +194,6 @@ export {
|
|
|
205
194
|
OperatorType,
|
|
206
195
|
OverflowableText,
|
|
207
196
|
PHASE_REGULATION_MODE_OPTIONS,
|
|
208
|
-
PROPERTY_NAME,
|
|
209
|
-
PROPERTY_VALUES,
|
|
210
|
-
PROPERTY_VALUES_1,
|
|
211
|
-
PROPERTY_VALUES_2,
|
|
212
197
|
PopupConfirmationDialog,
|
|
213
198
|
PropertyValueEditor,
|
|
214
199
|
RATIO_REGULATION_MODE_OPTIONS,
|
|
@@ -243,19 +228,14 @@ export {
|
|
|
243
228
|
UserManagerMock,
|
|
244
229
|
ValueEditor,
|
|
245
230
|
ValueSelector,
|
|
246
|
-
backToFrontTweak,
|
|
247
231
|
collectibleHelper,
|
|
248
232
|
countRules,
|
|
249
|
-
criteriaBasedFilterEmptyFormData,
|
|
250
|
-
criteriaBasedFilterSchema,
|
|
251
233
|
dispatchUser,
|
|
252
234
|
expertFilterSchema,
|
|
253
235
|
explicitNamingFilterSchema,
|
|
254
236
|
exportExpertRules,
|
|
255
237
|
extractDefault,
|
|
256
|
-
filterPropertiesYupSchema,
|
|
257
238
|
forTesting,
|
|
258
|
-
frontToBackTweak,
|
|
259
239
|
genHelperError,
|
|
260
240
|
genHelperPreviousValue,
|
|
261
241
|
generateMuiVirtualizedTableClass,
|
|
@@ -285,7 +265,6 @@ export {
|
|
|
285
265
|
queryValidator,
|
|
286
266
|
recursiveRemove,
|
|
287
267
|
rqbQuerySchemaValidator,
|
|
288
|
-
saveCriteriaBasedFilter,
|
|
289
268
|
saveExpertFilter,
|
|
290
269
|
saveExplicitNamingFilter,
|
|
291
270
|
styles,
|
package/dist/index.js
CHANGED
|
@@ -27,13 +27,8 @@ import { TagRenderer } from "./components/elementSearch/tagRenderer/TagRenderer.
|
|
|
27
27
|
import { FilterCreationDialog } from "./components/filter/FilterCreationDialog.js";
|
|
28
28
|
import { FilterForm } from "./components/filter/FilterForm.js";
|
|
29
29
|
import { DISTRIBUTION_KEY, FilterType, NO_ITEM_SELECTION_FOR_COPY } from "./components/filter/constants/FilterConstants.js";
|
|
30
|
-
import {
|
|
31
|
-
import {
|
|
32
|
-
import { CriteriaBasedForm } from "./components/filter/criteriaBased/CriteriaBasedForm.js";
|
|
33
|
-
import { FilterFreeProperties, FreePropertiesTypes } from "./components/filter/criteriaBased/FilterFreeProperties.js";
|
|
34
|
-
import { FilterProperties, filterPropertiesYupSchema } from "./components/filter/criteriaBased/FilterProperties.js";
|
|
35
|
-
import { FilterProperty, PROPERTY_NAME, PROPERTY_VALUES, PROPERTY_VALUES_1, PROPERTY_VALUES_2 } from "./components/filter/criteriaBased/FilterProperty.js";
|
|
36
|
-
import { backToFrontTweak, frontToBackTweak, getCriteriaBasedFormData, getCriteriaBasedSchema } from "./components/filter/criteriaBased/criteriaBasedFilterUtils.js";
|
|
30
|
+
import { CriteriaBasedForm } from "./components/contingencyList/criteriaBased/CriteriaBasedForm.js";
|
|
31
|
+
import { getCriteriaBasedFormData, getCriteriaBasedSchema } from "./components/contingencyList/criteriaBased/criteriaBasedUtils.js";
|
|
37
32
|
import { ExpertFilterEditionDialog } from "./components/filter/expert/ExpertFilterEditionDialog.js";
|
|
38
33
|
import { EXPERT_FILTER_QUERY, ExpertFilterForm, expertFilterSchema, getExpertFilterEmptyFormData, rqbQuerySchemaValidator } from "./components/filter/expert/ExpertFilterForm.js";
|
|
39
34
|
import { CombinatorType, DataType, FieldType, OperatorType } from "./components/filter/expert/expertFilter.type.js";
|
|
@@ -41,7 +36,7 @@ import { COMBINATOR_OPTIONS, CONVERTERS_MODE_OPTIONS, ENERGY_SOURCE_OPTIONS, EXP
|
|
|
41
36
|
import { countRules, exportExpertRules, getNumberOfSiblings, getOperators, importExpertRules, queryValidator, recursiveRemove, testQuery } from "./components/filter/expert/expertFilterUtils.js";
|
|
42
37
|
import { ExplicitNamingFilterEditionDialog } from "./components/filter/explicitNaming/ExplicitNamingFilterEditionDialog.js";
|
|
43
38
|
import { ExplicitNamingFilterForm, FILTER_EQUIPMENTS_ATTRIBUTES, explicitNamingFilterSchema, getExplicitNamingFilterEmptyFormData } from "./components/filter/explicitNaming/ExplicitNamingFilterForm.js";
|
|
44
|
-
import {
|
|
39
|
+
import { saveExpertFilter, saveExplicitNamingFilter } from "./components/filter/utils/filterApi.js";
|
|
45
40
|
import { CONTINGENCY_LIST_EQUIPMENTS, FILTER_EQUIPMENTS } from "./components/filter/utils/filterFormUtils.js";
|
|
46
41
|
import { FlatParameters, extractDefault } from "./components/flatParameters/FlatParameters.js";
|
|
47
42
|
import { SelectClearable } from "./components/inputs/SelectClearable.js";
|
|
@@ -207,8 +202,6 @@ export {
|
|
|
207
202
|
CombinatorType,
|
|
208
203
|
CountriesInput,
|
|
209
204
|
CountryValueEditor,
|
|
210
|
-
CriteriaBasedFilterEditionDialog,
|
|
211
|
-
CriteriaBasedFilterForm,
|
|
212
205
|
CriteriaBasedForm,
|
|
213
206
|
CsvUploader,
|
|
214
207
|
CustomAGGrid,
|
|
@@ -258,13 +251,9 @@ export {
|
|
|
258
251
|
FieldType,
|
|
259
252
|
FilterCreationDialog,
|
|
260
253
|
FilterForm,
|
|
261
|
-
FilterFreeProperties,
|
|
262
|
-
FilterProperties,
|
|
263
|
-
FilterProperty,
|
|
264
254
|
FilterType,
|
|
265
255
|
FlatParameters,
|
|
266
256
|
FloatInput,
|
|
267
|
-
FreePropertiesTypes,
|
|
268
257
|
GRIDSUITE_DEFAULT_PRECISION,
|
|
269
258
|
Generator,
|
|
270
259
|
GridLogo,
|
|
@@ -303,10 +292,6 @@ export {
|
|
|
303
292
|
OperatorType,
|
|
304
293
|
OverflowableText,
|
|
305
294
|
PHASE_REGULATION_MODE_OPTIONS,
|
|
306
|
-
PROPERTY_NAME,
|
|
307
|
-
PROPERTY_VALUES,
|
|
308
|
-
PROPERTY_VALUES_1,
|
|
309
|
-
PROPERTY_VALUES_2,
|
|
310
295
|
PopupConfirmationDialog,
|
|
311
296
|
PropertyValueEditor,
|
|
312
297
|
RATIO_REGULATION_MODE_OPTIONS,
|
|
@@ -357,7 +342,6 @@ export {
|
|
|
357
342
|
ValueSelector,
|
|
358
343
|
VoltageLevel,
|
|
359
344
|
areArrayElementsUnique,
|
|
360
|
-
backToFrontTweak,
|
|
361
345
|
backendFetch,
|
|
362
346
|
backendFetchJson,
|
|
363
347
|
cardErrorBoundaryEn,
|
|
@@ -368,8 +352,6 @@ export {
|
|
|
368
352
|
commonButtonFr,
|
|
369
353
|
countRules,
|
|
370
354
|
createFilter,
|
|
371
|
-
criteriaBasedFilterEmptyFormData,
|
|
372
|
-
criteriaBasedFilterSchema,
|
|
373
355
|
csvEn,
|
|
374
356
|
csvFr,
|
|
375
357
|
descriptionEn,
|
|
@@ -406,11 +388,9 @@ export {
|
|
|
406
388
|
filterExpertEn,
|
|
407
389
|
filterExpertFr,
|
|
408
390
|
filterFr,
|
|
409
|
-
filterPropertiesYupSchema,
|
|
410
391
|
flatParametersEn,
|
|
411
392
|
flatParametersFr,
|
|
412
393
|
forTesting,
|
|
413
|
-
frontToBackTweak,
|
|
414
394
|
genHelperError,
|
|
415
395
|
genHelperPreviousValue,
|
|
416
396
|
generateMuiVirtualizedTableClass,
|
|
@@ -469,7 +449,6 @@ export {
|
|
|
469
449
|
roundToDefaultPrecision,
|
|
470
450
|
roundToPrecision,
|
|
471
451
|
rqbQuerySchemaValidator,
|
|
472
|
-
saveCriteriaBasedFilter,
|
|
473
452
|
saveExpertFilter,
|
|
474
453
|
saveExplicitNamingFilter,
|
|
475
454
|
saveFilter,
|
|
@@ -19,8 +19,7 @@ const filterEn = {
|
|
|
19
19
|
betweenRule: "Left value of 'between' rule have to be lower than the right value",
|
|
20
20
|
emptyGroup: "Filter contains an empty group. Consider removing it or adding rules to this group",
|
|
21
21
|
Hvdc: "HVDC",
|
|
22
|
-
"filter.
|
|
23
|
-
"filter.expert": "Expert",
|
|
22
|
+
"filter.expert": "Criteria based",
|
|
24
23
|
"filter.explicitNaming": "Explicit naming",
|
|
25
24
|
nameEmpty: "The name is empty",
|
|
26
25
|
equipmentType: "Equipment type",
|
|
@@ -19,8 +19,7 @@ const filterFr = {
|
|
|
19
19
|
betweenRule: "La valeur de gauche d'une règle 'entre' doit être inférieure à la valeur de droite",
|
|
20
20
|
emptyGroup: "Le filtre contient un groupe vide. Supprimez le ou ajoutez des règles à ce groupe",
|
|
21
21
|
Hvdc: "HVDC",
|
|
22
|
-
"filter.
|
|
23
|
-
"filter.expert": "Expert",
|
|
22
|
+
"filter.expert": "Par critères",
|
|
24
23
|
"filter.explicitNaming": "Par nommage",
|
|
25
24
|
nameEmpty: "Le nom est vide",
|
|
26
25
|
equipmentType: "Type d'ouvrage",
|
package/package.json
CHANGED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { ItemSelectionForCopy } from '../filter.type';
|
|
2
|
-
import { ElementExistsType } from '../../../utils/types/elementType';
|
|
3
|
-
import { UUID } from 'crypto';
|
|
4
|
-
|
|
5
|
-
export interface CriteriaBasedFilterEditionDialogProps {
|
|
6
|
-
id: string;
|
|
7
|
-
name: string;
|
|
8
|
-
titleId: string;
|
|
9
|
-
open: boolean;
|
|
10
|
-
onClose: () => void;
|
|
11
|
-
broadcastChannel: BroadcastChannel;
|
|
12
|
-
getFilterById: (id: string) => Promise<any>;
|
|
13
|
-
itemSelectionForCopy: ItemSelectionForCopy;
|
|
14
|
-
setItemSelectionForCopy: (selection: ItemSelectionForCopy) => void;
|
|
15
|
-
activeDirectory?: UUID;
|
|
16
|
-
elementExists?: ElementExistsType;
|
|
17
|
-
language?: string;
|
|
18
|
-
}
|
|
19
|
-
export declare function CriteriaBasedFilterEditionDialog({ id, name, titleId, open, onClose, broadcastChannel, getFilterById, itemSelectionForCopy, setItemSelectionForCopy, activeDirectory, elementExists, language, }: Readonly<CriteriaBasedFilterEditionDialogProps>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { yupResolver } from "@hookform/resolvers/yup";
|
|
3
|
-
import { useState, useEffect, useCallback } from "react";
|
|
4
|
-
import { useForm } from "react-hook-form";
|
|
5
|
-
import { useSnackMessage } from "../../../hooks/useSnackMessage.js";
|
|
6
|
-
import { saveFilter } from "../../../services/explore.js";
|
|
7
|
-
import { FetchStatus } from "../../../utils/constants/fetchStatus.js";
|
|
8
|
-
import { FieldConstants } from "../../../utils/constants/fieldConstants.js";
|
|
9
|
-
import "../../../utils/yupConfig.js";
|
|
10
|
-
import { CustomMuiDialog } from "../../dialogs/customMuiDialog/CustomMuiDialog.js";
|
|
11
|
-
import { FilterForm } from "../FilterForm.js";
|
|
12
|
-
import { FilterType, NO_ITEM_SELECTION_FOR_COPY } from "../constants/FilterConstants.js";
|
|
13
|
-
import { criteriaBasedFilterSchema } from "./CriteriaBasedFilterForm.js";
|
|
14
|
-
import { backToFrontTweak, frontToBackTweak } from "./criteriaBasedFilterUtils.js";
|
|
15
|
-
import * as yup from "yup";
|
|
16
|
-
const formSchema = yup.object().shape({
|
|
17
|
-
[FieldConstants.NAME]: yup.string().trim().required("nameEmpty"),
|
|
18
|
-
[FieldConstants.FILTER_TYPE]: yup.string().required(),
|
|
19
|
-
[FieldConstants.EQUIPMENT_TYPE]: yup.string().required(),
|
|
20
|
-
...criteriaBasedFilterSchema
|
|
21
|
-
}).required();
|
|
22
|
-
function CriteriaBasedFilterEditionDialog({
|
|
23
|
-
id,
|
|
24
|
-
name,
|
|
25
|
-
titleId,
|
|
26
|
-
open,
|
|
27
|
-
onClose,
|
|
28
|
-
broadcastChannel,
|
|
29
|
-
getFilterById,
|
|
30
|
-
itemSelectionForCopy,
|
|
31
|
-
setItemSelectionForCopy,
|
|
32
|
-
activeDirectory,
|
|
33
|
-
elementExists,
|
|
34
|
-
language
|
|
35
|
-
}) {
|
|
36
|
-
var _a;
|
|
37
|
-
const { snackError } = useSnackMessage();
|
|
38
|
-
const [dataFetchStatus, setDataFetchStatus] = useState(FetchStatus.IDLE);
|
|
39
|
-
const formMethods = useForm({
|
|
40
|
-
resolver: yupResolver(formSchema)
|
|
41
|
-
});
|
|
42
|
-
const {
|
|
43
|
-
reset,
|
|
44
|
-
formState: { errors }
|
|
45
|
-
} = formMethods;
|
|
46
|
-
const nameError = errors[FieldConstants.NAME];
|
|
47
|
-
const isValidating = (_a = errors.root) == null ? void 0 : _a.isValidating;
|
|
48
|
-
useEffect(() => {
|
|
49
|
-
if (id && open) {
|
|
50
|
-
setDataFetchStatus(FetchStatus.FETCHING);
|
|
51
|
-
getFilterById(id).then((response) => {
|
|
52
|
-
setDataFetchStatus(FetchStatus.FETCH_SUCCESS);
|
|
53
|
-
reset({
|
|
54
|
-
[FieldConstants.NAME]: name,
|
|
55
|
-
[FieldConstants.FILTER_TYPE]: FilterType.CRITERIA_BASED.id,
|
|
56
|
-
...backToFrontTweak(response)
|
|
57
|
-
});
|
|
58
|
-
}).catch((error) => {
|
|
59
|
-
setDataFetchStatus(FetchStatus.FETCH_ERROR);
|
|
60
|
-
snackError({
|
|
61
|
-
messageTxt: error.message,
|
|
62
|
-
headerId: "cannotRetrieveFilter"
|
|
63
|
-
});
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
}, [id, name, open, reset, snackError, getFilterById]);
|
|
67
|
-
const onSubmit = useCallback(
|
|
68
|
-
(filterForm) => {
|
|
69
|
-
saveFilter(frontToBackTweak(id, filterForm), filterForm[FieldConstants.NAME]).then(() => {
|
|
70
|
-
if (itemSelectionForCopy.sourceItemUuid === id) {
|
|
71
|
-
setItemSelectionForCopy(NO_ITEM_SELECTION_FOR_COPY);
|
|
72
|
-
broadcastChannel.postMessage({ NO_SELECTION_FOR_COPY: NO_ITEM_SELECTION_FOR_COPY });
|
|
73
|
-
}
|
|
74
|
-
}).catch((error) => {
|
|
75
|
-
snackError({
|
|
76
|
-
messageTxt: error.message
|
|
77
|
-
});
|
|
78
|
-
});
|
|
79
|
-
},
|
|
80
|
-
[broadcastChannel, id, itemSelectionForCopy.sourceItemUuid, snackError, setItemSelectionForCopy]
|
|
81
|
-
);
|
|
82
|
-
const isDataReady = dataFetchStatus === FetchStatus.FETCH_SUCCESS;
|
|
83
|
-
return /* @__PURE__ */ jsx(
|
|
84
|
-
CustomMuiDialog,
|
|
85
|
-
{
|
|
86
|
-
open,
|
|
87
|
-
onClose,
|
|
88
|
-
onSave: onSubmit,
|
|
89
|
-
formSchema,
|
|
90
|
-
formMethods,
|
|
91
|
-
titleId,
|
|
92
|
-
removeOptional: true,
|
|
93
|
-
disabledSave: !!nameError || !!isValidating,
|
|
94
|
-
isDataFetching: dataFetchStatus === FetchStatus.FETCHING,
|
|
95
|
-
language,
|
|
96
|
-
unscrollableFullHeight: true,
|
|
97
|
-
children: isDataReady && /* @__PURE__ */ jsx(FilterForm, { activeDirectory, elementExists })
|
|
98
|
-
}
|
|
99
|
-
);
|
|
100
|
-
}
|
|
101
|
-
export {
|
|
102
|
-
CriteriaBasedFilterEditionDialog
|
|
103
|
-
};
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { default as yup } from '../../../utils/yupConfig';
|
|
2
|
-
|
|
3
|
-
export declare const criteriaBasedFilterSchema: {
|
|
4
|
-
readonly criteriaBased: yup.ObjectSchema<{
|
|
5
|
-
nominalVoltage3: {
|
|
6
|
-
value1: number | null;
|
|
7
|
-
value2: number | null;
|
|
8
|
-
type: string;
|
|
9
|
-
};
|
|
10
|
-
nominalVoltage2: {
|
|
11
|
-
value1: number | null;
|
|
12
|
-
value2: number | null;
|
|
13
|
-
type: string;
|
|
14
|
-
};
|
|
15
|
-
nominalVoltage1: {
|
|
16
|
-
value1: number | null;
|
|
17
|
-
value2: number | null;
|
|
18
|
-
type: string;
|
|
19
|
-
};
|
|
20
|
-
nominalVoltage: {
|
|
21
|
-
value1: number | null;
|
|
22
|
-
value2: number | null;
|
|
23
|
-
type: string;
|
|
24
|
-
};
|
|
25
|
-
countries: string[] | undefined;
|
|
26
|
-
countries1: string[] | undefined;
|
|
27
|
-
countries2: string[] | undefined;
|
|
28
|
-
}, yup.AnyObject, {
|
|
29
|
-
nominalVoltage3: any;
|
|
30
|
-
nominalVoltage2: any;
|
|
31
|
-
nominalVoltage1: any;
|
|
32
|
-
nominalVoltage: any;
|
|
33
|
-
countries: "";
|
|
34
|
-
countries1: "";
|
|
35
|
-
countries2: "";
|
|
36
|
-
}, "">;
|
|
37
|
-
};
|
|
38
|
-
export declare const criteriaBasedFilterEmptyFormData: {
|
|
39
|
-
readonly criteriaBased: {
|
|
40
|
-
readonly countries: any;
|
|
41
|
-
readonly countries1: any;
|
|
42
|
-
readonly countries2: any;
|
|
43
|
-
readonly nominalVoltage: any;
|
|
44
|
-
readonly nominalVoltage1: any;
|
|
45
|
-
readonly nominalVoltage2: any;
|
|
46
|
-
readonly nominalVoltage3: any;
|
|
47
|
-
};
|
|
48
|
-
};
|
|
49
|
-
export declare function CriteriaBasedFilterForm(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { filterPropertiesYupSchema, FilterProperties } from "./FilterProperties.js";
|
|
3
|
-
import { FieldConstants } from "../../../utils/constants/fieldConstants.js";
|
|
4
|
-
import "../../../utils/yupConfig.js";
|
|
5
|
-
import { CriteriaBasedForm } from "./CriteriaBasedForm.js";
|
|
6
|
-
import { getCriteriaBasedSchema, getCriteriaBasedFormData } from "./criteriaBasedFilterUtils.js";
|
|
7
|
-
import { FILTER_EQUIPMENTS } from "../utils/filterFormUtils.js";
|
|
8
|
-
import { FreePropertiesTypes } from "./FilterFreeProperties.js";
|
|
9
|
-
import * as yup from "yup";
|
|
10
|
-
const criteriaBasedFilterSchema = getCriteriaBasedSchema({
|
|
11
|
-
[FieldConstants.ENERGY_SOURCE]: yup.string().nullable(),
|
|
12
|
-
...filterPropertiesYupSchema
|
|
13
|
-
});
|
|
14
|
-
const criteriaBasedFilterEmptyFormData = getCriteriaBasedFormData(void 0, {
|
|
15
|
-
[FieldConstants.ENERGY_SOURCE]: null,
|
|
16
|
-
[FreePropertiesTypes.SUBSTATION_FILTER_PROPERTIES]: [],
|
|
17
|
-
[FreePropertiesTypes.FREE_FILTER_PROPERTIES]: []
|
|
18
|
-
});
|
|
19
|
-
function CriteriaBasedFilterForm() {
|
|
20
|
-
return /* @__PURE__ */ jsx(
|
|
21
|
-
CriteriaBasedForm,
|
|
22
|
-
{
|
|
23
|
-
equipments: FILTER_EQUIPMENTS,
|
|
24
|
-
defaultValues: criteriaBasedFilterEmptyFormData[FieldConstants.CRITERIA_BASED],
|
|
25
|
-
children: /* @__PURE__ */ jsx(FilterProperties, {})
|
|
26
|
-
}
|
|
27
|
-
);
|
|
28
|
-
}
|
|
29
|
-
export {
|
|
30
|
-
CriteriaBasedFilterForm,
|
|
31
|
-
criteriaBasedFilterEmptyFormData,
|
|
32
|
-
criteriaBasedFilterSchema
|
|
33
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { PredefinedProperties } from '../../../utils/types/types';
|
|
2
|
-
|
|
3
|
-
export declare enum FreePropertiesTypes {
|
|
4
|
-
SUBSTATION_FILTER_PROPERTIES = "substationFreeProperties",
|
|
5
|
-
FREE_FILTER_PROPERTIES = "freeProperties"
|
|
6
|
-
}
|
|
7
|
-
interface FilterFreePropertiesProps {
|
|
8
|
-
freePropertiesType: FreePropertiesTypes;
|
|
9
|
-
predefined: PredefinedProperties;
|
|
10
|
-
}
|
|
11
|
-
export declare function FilterFreeProperties({ freePropertiesType, predefined }: FilterFreePropertiesProps): import("react/jsx-runtime").JSX.Element;
|
|
12
|
-
export {};
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { jsxs, Fragment, jsx } from "react/jsx-runtime";
|
|
2
|
-
import { Grid, ListItem, Button } from "@mui/material";
|
|
3
|
-
import { useWatch, useFieldArray } from "react-hook-form";
|
|
4
|
-
import { FormattedMessage } from "react-intl";
|
|
5
|
-
import AddIcon from "@mui/icons-material/Add";
|
|
6
|
-
import { useMemo } from "react";
|
|
7
|
-
import { ErrorInput } from "../../inputs/reactHookForm/errorManagement/ErrorInput.js";
|
|
8
|
-
import { FieldErrorAlert } from "../../inputs/reactHookForm/errorManagement/FieldErrorAlert.js";
|
|
9
|
-
import { FieldConstants } from "../../../utils/constants/fieldConstants.js";
|
|
10
|
-
import { FilterProperty, PROPERTY_NAME, PROPERTY_VALUES_1, PROPERTY_VALUES_2, PROPERTY_VALUES } from "./FilterProperty.js";
|
|
11
|
-
import { Line, Hvdc } from "../../../utils/types/equipmentTypes.js";
|
|
12
|
-
var FreePropertiesTypes = /* @__PURE__ */ ((FreePropertiesTypes2) => {
|
|
13
|
-
FreePropertiesTypes2["SUBSTATION_FILTER_PROPERTIES"] = "substationFreeProperties";
|
|
14
|
-
FreePropertiesTypes2["FREE_FILTER_PROPERTIES"] = "freeProperties";
|
|
15
|
-
return FreePropertiesTypes2;
|
|
16
|
-
})(FreePropertiesTypes || {});
|
|
17
|
-
function FilterFreeProperties({ freePropertiesType, predefined }) {
|
|
18
|
-
const watchEquipmentType = useWatch({
|
|
19
|
-
name: FieldConstants.EQUIPMENT_TYPE
|
|
20
|
-
});
|
|
21
|
-
const isForLineOrHvdcLineSubstation = (watchEquipmentType === Line.type || watchEquipmentType === Hvdc.type) && freePropertiesType === "substationFreeProperties";
|
|
22
|
-
const fieldName = `${FieldConstants.CRITERIA_BASED}.${freePropertiesType}`;
|
|
23
|
-
const {
|
|
24
|
-
fields: filterProperties,
|
|
25
|
-
// don't use it to access form data ! check doc,
|
|
26
|
-
append,
|
|
27
|
-
remove
|
|
28
|
-
} = useFieldArray({
|
|
29
|
-
name: fieldName
|
|
30
|
-
});
|
|
31
|
-
function addNewProp() {
|
|
32
|
-
if (isForLineOrHvdcLineSubstation) {
|
|
33
|
-
append({
|
|
34
|
-
[PROPERTY_NAME]: null,
|
|
35
|
-
[PROPERTY_VALUES_1]: [],
|
|
36
|
-
[PROPERTY_VALUES_2]: []
|
|
37
|
-
});
|
|
38
|
-
} else {
|
|
39
|
-
append({ [PROPERTY_NAME]: null, [PROPERTY_VALUES]: [] });
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
const valuesFields = isForLineOrHvdcLineSubstation ? [
|
|
43
|
-
{ name: PROPERTY_VALUES_1, label: "PropertyValues1" },
|
|
44
|
-
{ name: PROPERTY_VALUES_2, label: "PropertyValues2" }
|
|
45
|
-
] : [{ name: PROPERTY_VALUES, label: "PropertyValues" }];
|
|
46
|
-
const title = useMemo(() => {
|
|
47
|
-
return freePropertiesType === "freeProperties" ? "FreeProps" : "SubstationFreeProps";
|
|
48
|
-
}, [freePropertiesType]);
|
|
49
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
50
|
-
/* @__PURE__ */ jsx(Grid, { item: true, xs: 12, children: /* @__PURE__ */ jsx(FormattedMessage, { id: title, children: (formattedTitle) => /* @__PURE__ */ jsx("h4", { children: formattedTitle }) }) }),
|
|
51
|
-
filterProperties.map((prop, index) => /* @__PURE__ */ jsx(ListItem, { children: /* @__PURE__ */ jsx(
|
|
52
|
-
FilterProperty,
|
|
53
|
-
{
|
|
54
|
-
index,
|
|
55
|
-
valuesFields,
|
|
56
|
-
predefined,
|
|
57
|
-
handleDelete: remove,
|
|
58
|
-
propertyType: freePropertiesType
|
|
59
|
-
}
|
|
60
|
-
) }, prop.id)),
|
|
61
|
-
/* @__PURE__ */ jsx(Grid, { item: true, children: /* @__PURE__ */ jsx(Button, { startIcon: /* @__PURE__ */ jsx(AddIcon, {}), onClick: () => addNewProp(), children: /* @__PURE__ */ jsx(FormattedMessage, { id: "AddFreePropCrit" }) }) }),
|
|
62
|
-
/* @__PURE__ */ jsx(Grid, { item: true, children: /* @__PURE__ */ jsx(ErrorInput, { name: fieldName, InputField: FieldErrorAlert }) })
|
|
63
|
-
] });
|
|
64
|
-
}
|
|
65
|
-
export {
|
|
66
|
-
FilterFreeProperties,
|
|
67
|
-
FreePropertiesTypes
|
|
68
|
-
};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { default as yup } from '../../../utils/yupConfig';
|
|
2
|
-
|
|
3
|
-
export declare const filterPropertiesYupSchema: {
|
|
4
|
-
substationFreeProperties: yup.ArraySchema<{
|
|
5
|
-
prop_values?: (string | undefined)[] | undefined;
|
|
6
|
-
prop_values1?: (string | undefined)[] | undefined;
|
|
7
|
-
prop_values2?: (string | undefined)[] | undefined;
|
|
8
|
-
name_property: string;
|
|
9
|
-
}[] | undefined, yup.AnyObject, "", "">;
|
|
10
|
-
freeProperties: yup.ArraySchema<{
|
|
11
|
-
prop_values?: (string | undefined)[] | undefined;
|
|
12
|
-
name_property: string;
|
|
13
|
-
}[] | undefined, yup.AnyObject, "", "">;
|
|
14
|
-
};
|
|
15
|
-
export declare function FilterProperties(): any;
|
|
@@ -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
|