@m4l/components 9.3.23 → 9.3.24
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/components/DynamicFilter/helpers/formatToInitialFilters.js +3 -3
- package/components/DynamicFilter/subcomponents/FieldTypes/BooleanFilter/helpers.js +11 -3
- package/components/DynamicFilter/subcomponents/FieldTypes/DateTimeFilter/helpers.js +16 -4
- package/components/DynamicFilter/subcomponents/FieldTypes/NumberFilter/helpers.js +11 -8
- package/components/DynamicFilter/subcomponents/FieldTypes/SelectAsyncFilter/helpers.js +21 -8
- package/components/DynamicFilter/subcomponents/FieldTypes/SelectFilter/helpers.js +18 -8
- package/components/DynamicFilter/subcomponents/FieldTypes/StringFilter/helpers.js +5 -3
- package/package.json +1 -1
|
@@ -30,9 +30,9 @@ function formatToInitialFilters(appliedFilters) {
|
|
|
30
30
|
return {
|
|
31
31
|
name: af.field.name,
|
|
32
32
|
operator: af.operator,
|
|
33
|
-
...operand1 ? { operand1 } : {},
|
|
34
|
-
...operand2 ? { operand2 } : {},
|
|
35
|
-
...operandArray ? { operandArray } : {}
|
|
33
|
+
...operand1 !== void 0 ? { operand1 } : {},
|
|
34
|
+
...operand2 !== void 0 ? { operand2 } : {},
|
|
35
|
+
...operandArray !== void 0 ? { operandArray } : {}
|
|
36
36
|
};
|
|
37
37
|
});
|
|
38
38
|
}
|
|
@@ -11,12 +11,16 @@ class BooleanFilterHelpers {
|
|
|
11
11
|
*/
|
|
12
12
|
getDefaultFilter(field, fixed) {
|
|
13
13
|
const defaultOperand1 = field.defaultOperand1;
|
|
14
|
+
let isSet = false;
|
|
15
|
+
if (defaultOperand1 !== void 0 && typeof defaultOperand1 === "boolean") {
|
|
16
|
+
isSet = true;
|
|
17
|
+
}
|
|
14
18
|
const defaultFilter = {
|
|
15
19
|
id: 0,
|
|
16
20
|
fieldType: "boolean",
|
|
17
21
|
field,
|
|
18
22
|
fixed,
|
|
19
|
-
isSet
|
|
23
|
+
isSet,
|
|
20
24
|
operator: "e",
|
|
21
25
|
operand1: true
|
|
22
26
|
};
|
|
@@ -45,7 +49,9 @@ class BooleanFilterHelpers {
|
|
|
45
49
|
const operator = filterValueBoolean ? filterValueBoolean.operator : field.defaultOperator ?? "e";
|
|
46
50
|
const formValueOperand1 = filterValueBoolean ? {
|
|
47
51
|
value: filterValueBoolean.operand1,
|
|
48
|
-
label: getLabel(
|
|
52
|
+
label: getLabel(
|
|
53
|
+
`${DYNAMIC_FILTER_DICTIONARY_ID}.operand_${filterValueBoolean.operand1}`
|
|
54
|
+
)
|
|
49
55
|
} : null;
|
|
50
56
|
return {
|
|
51
57
|
fieldType: "boolean",
|
|
@@ -63,7 +69,9 @@ class BooleanFilterHelpers {
|
|
|
63
69
|
const labelOperands = filter.operand1 ? getLabel(DICCTIONARY.operand_true) : getLabel(DICCTIONARY.operand_false);
|
|
64
70
|
return {
|
|
65
71
|
labelField: filter.field.label ?? getLabel(filter.field.dictionaryId),
|
|
66
|
-
labelOperator: getLabel(
|
|
72
|
+
labelOperator: getLabel(
|
|
73
|
+
`${DYNAMIC_FILTER_DICTIONARY_ID}.operator_${filter.operator}`
|
|
74
|
+
),
|
|
67
75
|
labelOperands
|
|
68
76
|
};
|
|
69
77
|
}
|
|
@@ -18,12 +18,16 @@ class DateTimeFilterHelpers {
|
|
|
18
18
|
defaultEndDate.setHours(23, 59, 59, 999);
|
|
19
19
|
const defaultOperand1 = field.defaultOperand1 && field.defaultOperand1 instanceof Date ? field.defaultOperand1 : defaultStartDate;
|
|
20
20
|
const defaultOperand2 = field.defaultOperand2 && field.defaultOperand2 instanceof Date ? field.defaultOperand2 : defaultEndDate;
|
|
21
|
+
let isSet = false;
|
|
22
|
+
if (defaultOperand1 !== void 0) {
|
|
23
|
+
isSet = true;
|
|
24
|
+
}
|
|
21
25
|
return {
|
|
22
26
|
id: 0,
|
|
23
27
|
fieldType: "datetime",
|
|
24
28
|
field,
|
|
25
29
|
fixed,
|
|
26
|
-
isSet
|
|
30
|
+
isSet,
|
|
27
31
|
operator: "b",
|
|
28
32
|
operand1: defaultOperand1,
|
|
29
33
|
operand2: defaultOperand2
|
|
@@ -83,13 +87,21 @@ class DateTimeFilterHelpers {
|
|
|
83
87
|
labelOperands = filter.operand1 && filter.operand2 ? `${dateFormatter.formatDate(
|
|
84
88
|
filter.operand1,
|
|
85
89
|
dateFormatter.datetimeFormat
|
|
86
|
-
)} - ${dateFormatter.formatDate(
|
|
90
|
+
)} - ${dateFormatter.formatDate(
|
|
91
|
+
filter.operand2,
|
|
92
|
+
dateFormatter.datetimeFormat
|
|
93
|
+
)}` : "";
|
|
87
94
|
} else {
|
|
88
|
-
labelOperands = filter.operand1 ? dateFormatter.formatDate(
|
|
95
|
+
labelOperands = filter.operand1 ? dateFormatter.formatDate(
|
|
96
|
+
filter.operand1,
|
|
97
|
+
dateFormatter.datetimeFormat
|
|
98
|
+
) : "";
|
|
89
99
|
}
|
|
90
100
|
return {
|
|
91
101
|
labelField: filter.field.label ?? getLabel(filter.field.dictionaryId),
|
|
92
|
-
labelOperator: getLabel(
|
|
102
|
+
labelOperator: getLabel(
|
|
103
|
+
`${DYNAMIC_FILTER_DICTIONARY_ID}.operator_${filter.operator}`
|
|
104
|
+
),
|
|
93
105
|
labelOperands
|
|
94
106
|
};
|
|
95
107
|
}
|
|
@@ -15,12 +15,10 @@ class NumberFilterHelpers {
|
|
|
15
15
|
const defaultOperand1 = field.defaultOperand1 ?? null;
|
|
16
16
|
const defaultOperand2 = field.defaultOperand2 ?? null;
|
|
17
17
|
let isSet = false;
|
|
18
|
-
if (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
isSet = defaultOperand1 !== null ? true : false;
|
|
23
|
-
}
|
|
18
|
+
if (["b"].includes(dOperator)) {
|
|
19
|
+
isSet = defaultOperand1 !== null && defaultOperand2 !== null ? true : false;
|
|
20
|
+
} else {
|
|
21
|
+
isSet = defaultOperand1 !== null ? true : false;
|
|
24
22
|
}
|
|
25
23
|
return {
|
|
26
24
|
id: 0,
|
|
@@ -85,7 +83,9 @@ class NumberFilterHelpers {
|
|
|
85
83
|
}
|
|
86
84
|
return {
|
|
87
85
|
labelField: filter.field.label ?? getLabel(filter.field.dictionaryId),
|
|
88
|
-
labelOperator: getLabel(
|
|
86
|
+
labelOperator: getLabel(
|
|
87
|
+
`${DYNAMIC_FILTER_DICTIONARY_ID}.operator_${filter.operator}`
|
|
88
|
+
),
|
|
89
89
|
labelOperands
|
|
90
90
|
};
|
|
91
91
|
}
|
|
@@ -100,7 +100,10 @@ class NumberFilterHelpers {
|
|
|
100
100
|
),
|
|
101
101
|
formValueOperand2: Yup.mixed().when(["formValueOperator.id"], {
|
|
102
102
|
is: "b",
|
|
103
|
-
then: Yup.number().typeError(getLabel(DICCTIONARY.error_operand_mustbe_number)).min(
|
|
103
|
+
then: Yup.number().typeError(getLabel(DICCTIONARY.error_operand_mustbe_number)).min(
|
|
104
|
+
Yup.ref("formValueOperand1"),
|
|
105
|
+
getLabel(DICCTIONARY.error_less_than_start)
|
|
106
|
+
)
|
|
104
107
|
})
|
|
105
108
|
});
|
|
106
109
|
}
|
|
@@ -27,13 +27,16 @@ class SelectAsyncFilterHelpers {
|
|
|
27
27
|
let operandsArray = [];
|
|
28
28
|
if (isMultiple) {
|
|
29
29
|
dOperator = field.defaultOperator ?? "in";
|
|
30
|
-
isSet =
|
|
30
|
+
isSet = defaultOperandsArray !== null && defaultOperandsArray.length > 0;
|
|
31
31
|
if (field.defaultOperandsArray !== void 0 && Array.isArray(field.defaultOperandsArray)) {
|
|
32
|
-
operandsArray = filterValidOperandsArraySelectAsync(
|
|
32
|
+
operandsArray = filterValidOperandsArraySelectAsync(
|
|
33
|
+
field.defaultOperandsArray,
|
|
34
|
+
field
|
|
35
|
+
);
|
|
33
36
|
}
|
|
34
37
|
} else {
|
|
35
38
|
dOperator = field.defaultOperator ?? "e";
|
|
36
|
-
isSet =
|
|
39
|
+
isSet = defaultOperand1 ? true : false;
|
|
37
40
|
}
|
|
38
41
|
const defaultCommonFilter = {
|
|
39
42
|
id: 0,
|
|
@@ -122,15 +125,21 @@ class SelectAsyncFilterHelpers {
|
|
|
122
125
|
let labelOperands = "";
|
|
123
126
|
if (isMultiple) {
|
|
124
127
|
labelOperands = operandsArray?.reduce?.((label, operand) => {
|
|
125
|
-
const textLabel = field.selectAsyncOptions?.getOptionLabel?.(
|
|
128
|
+
const textLabel = field.selectAsyncOptions?.getOptionLabel?.(
|
|
129
|
+
operand
|
|
130
|
+
) || "";
|
|
126
131
|
return label ? `${label} | ${textLabel}` : textLabel;
|
|
127
132
|
}, "")?.toString() || "?";
|
|
128
133
|
} else {
|
|
129
|
-
labelOperands = (field.selectAsyncOptions?.getOptionLabel?.(
|
|
134
|
+
labelOperands = (field.selectAsyncOptions?.getOptionLabel?.(
|
|
135
|
+
filter.operand1
|
|
136
|
+
) ?? "?") + "";
|
|
130
137
|
}
|
|
131
138
|
return {
|
|
132
139
|
labelField: filter.field.label ?? getLabel(filter.field.dictionaryId),
|
|
133
|
-
labelOperator: getLabel(
|
|
140
|
+
labelOperator: getLabel(
|
|
141
|
+
`${DYNAMIC_FILTER_DICTIONARY_ID}.operator_${filter.operator}`
|
|
142
|
+
),
|
|
134
143
|
labelOperands
|
|
135
144
|
};
|
|
136
145
|
}
|
|
@@ -163,7 +172,9 @@ class SelectAsyncFilterHelpers {
|
|
|
163
172
|
return false;
|
|
164
173
|
}
|
|
165
174
|
if (isMultiple) {
|
|
166
|
-
if (SELECT_ASYNC_OPERATORS_MULTIPLE.findIndex(
|
|
175
|
+
if (SELECT_ASYNC_OPERATORS_MULTIPLE.findIndex(
|
|
176
|
+
(f) => f === filter.operator
|
|
177
|
+
) === -1) {
|
|
167
178
|
return false;
|
|
168
179
|
}
|
|
169
180
|
if (!filter.operandsArray || typeof filter.operandsArray !== "object") {
|
|
@@ -180,7 +191,9 @@ class SelectAsyncFilterHelpers {
|
|
|
180
191
|
return false;
|
|
181
192
|
}
|
|
182
193
|
} else {
|
|
183
|
-
if (SELECT_ASYNC_OPERATORS_SINGLE.findIndex(
|
|
194
|
+
if (SELECT_ASYNC_OPERATORS_SINGLE.findIndex(
|
|
195
|
+
(f) => f === filter.operator
|
|
196
|
+
) === -1) {
|
|
184
197
|
return false;
|
|
185
198
|
}
|
|
186
199
|
if (!filter.operand1 || typeof filter.operand1 !== "object") {
|
|
@@ -26,13 +26,15 @@ class SelectFilterHelpers {
|
|
|
26
26
|
let operandsArray = [];
|
|
27
27
|
if (isMultiple) {
|
|
28
28
|
dOperator = field.defaultOperator ?? "in";
|
|
29
|
-
isSet =
|
|
29
|
+
isSet = defaultOperandsArray !== null && defaultOperandsArray.length > 0;
|
|
30
30
|
if (field.defaultOperandsArray !== void 0 && Array.isArray(field.defaultOperandsArray)) {
|
|
31
|
-
operandsArray = filterValidOperandsArraySelect(
|
|
31
|
+
operandsArray = filterValidOperandsArraySelect(
|
|
32
|
+
field.defaultOperandsArray
|
|
33
|
+
);
|
|
32
34
|
}
|
|
33
35
|
} else {
|
|
34
36
|
dOperator = field.defaultOperator ?? "e";
|
|
35
|
-
isSet =
|
|
37
|
+
isSet = defaultOperand1 !== null;
|
|
36
38
|
}
|
|
37
39
|
const defaultCommonFilter = {
|
|
38
40
|
id: 0,
|
|
@@ -123,7 +125,9 @@ class SelectFilterHelpers {
|
|
|
123
125
|
let labelOperands = "";
|
|
124
126
|
if (isMultiple) {
|
|
125
127
|
labelOperands = operandsArray?.reduce?.((label, operand) => {
|
|
126
|
-
const textLabel = field.selectOptions?.options.find(
|
|
128
|
+
const textLabel = field.selectOptions?.options.find(
|
|
129
|
+
(option) => option.id === operand
|
|
130
|
+
)?.label || "";
|
|
127
131
|
return label ? `${label} | ${textLabel}` : textLabel;
|
|
128
132
|
}, "")?.toString() || "?";
|
|
129
133
|
} else {
|
|
@@ -131,7 +135,9 @@ class SelectFilterHelpers {
|
|
|
131
135
|
}
|
|
132
136
|
return {
|
|
133
137
|
labelField: filter.field.label ?? getLabel(filter.field.dictionaryId),
|
|
134
|
-
labelOperator: getLabel(
|
|
138
|
+
labelOperator: getLabel(
|
|
139
|
+
`${DYNAMIC_FILTER_DICTIONARY_ID}.operator_${filter.operator}`
|
|
140
|
+
),
|
|
135
141
|
labelOperands
|
|
136
142
|
};
|
|
137
143
|
}
|
|
@@ -147,9 +153,13 @@ class SelectFilterHelpers {
|
|
|
147
153
|
}),
|
|
148
154
|
formValueOperand1: Yup.mixed().when(["multiple"], {
|
|
149
155
|
is: false,
|
|
150
|
-
then: Yup.mixed().test(
|
|
151
|
-
|
|
152
|
-
|
|
156
|
+
then: Yup.mixed().test(
|
|
157
|
+
"is-string-or-number",
|
|
158
|
+
getLabel(DICCTIONARY.error_operand_required),
|
|
159
|
+
(value) => {
|
|
160
|
+
return typeof value === "string" || typeof value === "number";
|
|
161
|
+
}
|
|
162
|
+
).required(getLabel(DICCTIONARY.error_operand_required))
|
|
153
163
|
})
|
|
154
164
|
});
|
|
155
165
|
}
|
|
@@ -12,8 +12,8 @@ class StringFilterHelpers {
|
|
|
12
12
|
getDefaultFilter(field, fixed) {
|
|
13
13
|
const defaultOperand1 = field.defaultOperand1;
|
|
14
14
|
let isSet = false;
|
|
15
|
-
if (
|
|
16
|
-
isSet =
|
|
15
|
+
if (defaultOperand1 !== null && typeof defaultOperand1 === "string") {
|
|
16
|
+
isSet = true;
|
|
17
17
|
}
|
|
18
18
|
const defaultFilter = {
|
|
19
19
|
id: 0,
|
|
@@ -64,7 +64,9 @@ class StringFilterHelpers {
|
|
|
64
64
|
const labelOperands = filter.operand1 !== void 0 ? filter.operand1 + "" : "";
|
|
65
65
|
return {
|
|
66
66
|
labelField: filter.field.label ?? getLabel(filter.field.dictionaryId),
|
|
67
|
-
labelOperator: getLabel(
|
|
67
|
+
labelOperator: getLabel(
|
|
68
|
+
`${DYNAMIC_FILTER_DICTIONARY_ID}.operator_${filter.operator}`
|
|
69
|
+
),
|
|
68
70
|
labelOperands
|
|
69
71
|
};
|
|
70
72
|
}
|