@m4l/components 1.0.10 → 1.0.11
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/AccountPopover/{index.85964263.js → index.62b1290b.js} +2 -2
- package/components/AppBar/{index.233917e6.js → index.b48343d8.js} +2 -2
- package/components/CommonActions/{index.5f5362d4.js → index.19f39dca.js} +3 -3
- package/components/DynamicFilter/helpers/index.609b3915.js +557 -0
- package/components/DynamicFilter/index.0f04f223.js +363 -0
- package/components/DynamicFilter/slots/{index.268c8973.js → index.00b68384.js} +7 -6
- package/components/DynamicFilter/store/index.85a2812f.js +254 -0
- package/components/DynamicFilter/subcomponents/index.86c6fda2.js +586 -0
- package/components/FieldLabel/{index.61450047.js → index.1577ac9c.js} +1 -1
- package/components/HamburgerMenu/{index.6da952c3.js → index.6c82741d.js} +2 -2
- package/components/Icon/{index.0d591435.js → index.8ecfb193.js} +2 -2
- package/components/Image/{index.7b1ce7d6.js → index.4a822ede.js} +1 -1
- package/components/LoadingError/{index.5b8a819d.js → index.9e829e8d.js} +2 -2
- package/components/MFLoader/{index.6f690259.js → index.29f445e2.js} +1 -1
- package/components/ModalDialog/{index.bdae9c06.js → index.96c4aba3.js} +1 -1
- package/components/NoItemSelected/{index.71727588.js → index.0ae9f28f.js} +1 -1
- package/components/ObjectLogs/{index.5e18c08e.js → index.40c5047f.js} +5 -5
- package/components/PDFViewer/{index.e5b7b58c.js → index.651cc4b6.js} +1 -1
- package/components/Page/{index.bf61755b.js → index.1d08818c.js} +1 -1
- package/components/PaperForm/{index.2c5d1c14.js → index.1a8b10d4.js} +1 -1
- package/components/Period/{index.9f3a2531.js → index.236971ae.js} +2 -2
- package/components/PrintingSystem/{index.e166c8d5.js → index.9fdae551.js} +13 -13
- package/components/PrintingSystem/subcomponents/BodyNode/{index.ff5bd9ba.js → index.794dbc69.js} +1 -1
- package/components/PrintingSystem/subcomponents/ChartNode/{index.e78e9c90.js → index.6bbf7d75.js} +1 -1
- package/components/PrintingSystem/subcomponents/DividerNode/{index.1ff8a100.js → index.015a2212.js} +1 -1
- package/components/PrintingSystem/subcomponents/FooterNode/{index.7078b267.js → index.08eeb1d2.js} +1 -1
- package/components/PrintingSystem/subcomponents/GridNode/{index.45007400.js → index.23995699.js} +1 -1
- package/components/PrintingSystem/subcomponents/HeaderNode/{index.c19c37d6.js → index.3fa36620.js} +1 -1
- package/components/PrintingSystem/subcomponents/PaperNode/{index.3a620060.js → index.8b7d43f4.js} +1 -1
- package/components/PrintingSystem/subcomponents/PropertyValueNode/{index.c158a2b6.js → index.9856c572.js} +1 -1
- package/components/PrintingSystem/subcomponents/SectionNode/{index.cc08a0f8.js → index.89b3a4e0.js} +1 -1
- package/components/PrintingSystem/subcomponents/TextBoxNode/{index.a37d8efa.js → index.dc6e9dc2.js} +1 -1
- package/components/PropertyValue/{index.2e61bd86.js → index.646a7e8b.js} +2 -2
- package/components/SideBar/{index.a645fbb3.js → index.d221254d.js} +4 -4
- package/components/ToastContainer/{index.c1ae5efc.js → index.7f246bbd.js} +1 -1
- package/components/areas/contexts/AreasContext/{index.ed31c72d.js → index.0815f278.js} +2 -2
- package/components/areas/{dictionary.ffe082b0.js → dictionary.6168209a.js} +2 -2
- package/components/areas/hooks/useAreas/{index.dca83673.js → index.4039e30d.js} +1 -1
- package/components/hook-form/RHFAutocompleteAsync/{index.58439d31.js → index.69f5661d.js} +2 -2
- package/components/hook-form/RHFCheckbox/{index.52645cbc.js → index.13de27db.js} +2 -2
- package/components/hook-form/RHFColorPicker/{index.ad3a7448.js → index.66004599.js} +5 -5
- package/components/hook-form/RHFDateTime/{index.0bb4279e.js → index.dfe07e18.js} +3 -3
- package/components/hook-form/RHFPeriod/{index.8075a132.js → index.d852649b.js} +3 -3
- package/components/hook-form/RHFTextField/{index.8d9e389c.js → index.d207efc1.js} +3 -3
- package/components/hook-form/RHFUpload/{index.bb7f617e.js → index.955a4ba5.js} +2 -2
- package/components/maps/components/GpsTools/{index.a32b12b7.js → index.01acaf3e.js} +2 -2
- package/components/maps/{index.595f5894.js → index.a1bf63f2.js} +9 -9
- package/components/modal/{WindowBase.57f82667.js → WindowBase.390b0910.js} +3 -3
- package/components/modal/{WindowConfirm.21342f0a.js → WindowConfirm.243e1bef.js} +5 -5
- package/components/mui_extended/Accordion/{index.232b14c4.js → index.f7a17c83.js} +2 -2
- package/components/mui_extended/Button/{index.6276c580.js → index.52852c42.js} +4 -4
- package/components/mui_extended/CheckBox/{index.2bf3b459.js → index.01218423.js} +1 -1
- package/components/mui_extended/IconButton/{index.20a5a0be.js → index.d5b273e6.js} +1 -1
- package/components/mui_extended/Pager/{index.2a5203df.js → index.8960227c.js} +3 -3
- package/components/mui_extended/Popover/{index.fda32ba1.js → index.146ded9e.js} +12 -11
- package/components/mui_extended/Tab/{index.03742bb6.js → index.37d588d6.js} +15 -15
- package/components/mui_extended/ToggleButton/{index.7a4779c7.js → index.c441b949.js} +1 -1
- package/components/mui_extended/ToggleIconButton/{index.29fdefaa.js → index.8a84f25e.js} +1 -1
- package/components/popups/PopupsProvider/{index.6b5befba.js → index.d4caacc3.js} +1 -1
- package/components/popups/PopupsViewer/{index.c7940ab0.js → index.42312806.js} +3 -3
- package/contexts/ModalContext/{index.e126d383.js → index.5f77a463.js} +1 -1
- package/hooks/useFormAddEdit/{index.42356b18.js → index.ecb77e67.js} +2 -2
- package/hooks/useModal/{index.20c3f2be.js → index.d14c7e46.js} +4 -4
- package/index.js +64 -61
- package/package.json +1 -1
- package/{vendor.e16cc0cc.js → vendor.5b266106.js} +49 -49
- package/components/DynamicFilter/index.d698a952.js +0 -1721
|
@@ -6,8 +6,8 @@ import { unstable_composeClasses } from "@mui/base";
|
|
|
6
6
|
import { T as TEST_PROP_ID } from "../areas/constants.0d3ba950.js";
|
|
7
7
|
import { A as Avatar } from "../mui_extended/Avatar/index.12b96914.js";
|
|
8
8
|
import { C as CircularProgress } from "../mui_extended/CircularProgress/index.967e70b7.js";
|
|
9
|
-
import { P as Popover } from "../mui_extended/Popover/index.
|
|
10
|
-
import { I as Icon } from "../Icon/index.
|
|
9
|
+
import { P as Popover } from "../mui_extended/Popover/index.146ded9e.js";
|
|
10
|
+
import { I as Icon } from "../Icon/index.8ecfb193.js";
|
|
11
11
|
import clsx from "clsx";
|
|
12
12
|
const componentName = "M4LAccountPopover";
|
|
13
13
|
generateUtilityClasses(
|
|
@@ -5,9 +5,9 @@ import { useEnvironment, useModuleDictionary } from "@m4l/core";
|
|
|
5
5
|
import { T as TEST_PROP_ID } from "../areas/constants.0d3ba950.js";
|
|
6
6
|
import { generateUtilityClasses, generateUtilityClass } from "@mui/material";
|
|
7
7
|
import { unstable_composeClasses } from "@mui/base";
|
|
8
|
-
import { I as Image } from "../Image/index.
|
|
8
|
+
import { I as Image } from "../Image/index.4a822ede.js";
|
|
9
9
|
import { T as Typography } from "../mui_extended/Typography/index.463f613f.js";
|
|
10
|
-
import { I as IconButton } from "../mui_extended/IconButton/index.
|
|
10
|
+
import { I as IconButton } from "../mui_extended/IconButton/index.d5b273e6.js";
|
|
11
11
|
const AppBarRoot = styled("header")(({ theme }) => ({
|
|
12
12
|
...theme.components?.M4LAppBar?.styleOverrides
|
|
13
13
|
}));
|
|
@@ -4,11 +4,11 @@ import clsx from "clsx";
|
|
|
4
4
|
import { T as TEST_PROP_ID } from "../areas/constants.0d3ba950.js";
|
|
5
5
|
import { styled } from "@mui/material/styles";
|
|
6
6
|
import { useModuleDictionary, useModuleSkeleton } from "@m4l/core";
|
|
7
|
-
import { B as Button, L as LoadingButton } from "../mui_extended/Button/index.
|
|
7
|
+
import { B as Button, L as LoadingButton } from "../mui_extended/Button/index.52852c42.js";
|
|
8
8
|
import { useFormContext, useFormState } from "react-hook-form";
|
|
9
|
-
import { u as useModal } from "../../hooks/useModal/index.
|
|
9
|
+
import { u as useModal } from "../../hooks/useModal/index.d14c7e46.js";
|
|
10
10
|
import { u as useWindowToolsMF } from "../areas/hooks/useWindowToolsMF/index.09801b66.js";
|
|
11
|
-
import { W as WindowConfirm } from "../modal/WindowConfirm.
|
|
11
|
+
import { W as WindowConfirm } from "../modal/WindowConfirm.243e1bef.js";
|
|
12
12
|
import { generateUtilityClasses, Skeleton } from "@mui/material";
|
|
13
13
|
import { unstable_composeClasses } from "@mui/base";
|
|
14
14
|
import { g as getComponentUtilityClass } from "../../utils/index.c64c2dd1.js";
|
|
@@ -0,0 +1,557 @@
|
|
|
1
|
+
import * as Yup from "yup";
|
|
2
|
+
import { g as getDynamicFilterDictionary, D as DICCTIONARY } from "../../areas/dictionary.6168209a.js";
|
|
3
|
+
import { B as BOOLEAN_OPERATORS, S as STRING_OPERATORS, b as DATE_TIME_OPERATORS, N as NUMBER_OPERATORS, c as SELECT_OPERATORS } from "../../areas/constants.0d3ba950.js";
|
|
4
|
+
import { B as BooleanFilter, S as StringFilter, D as DateTimeFilter, N as NumberFilter, a as SelectFilter, f as fieldFactory } from "../subcomponents/index.86c6fda2.js";
|
|
5
|
+
import { i as isValidDate } from "../../../utils/index.c64c2dd1.js";
|
|
6
|
+
class BooleanFilterHelpers {
|
|
7
|
+
getComponent() {
|
|
8
|
+
return BooleanFilter;
|
|
9
|
+
}
|
|
10
|
+
getDefaultFilter(field, fixed) {
|
|
11
|
+
const defaultOperand1 = field.defaultOperand1;
|
|
12
|
+
const defaultFilter = {
|
|
13
|
+
id: 0,
|
|
14
|
+
fieldType: "boolean",
|
|
15
|
+
field,
|
|
16
|
+
fixed,
|
|
17
|
+
isSet: true,
|
|
18
|
+
operator: "e",
|
|
19
|
+
operand1: true
|
|
20
|
+
};
|
|
21
|
+
if (defaultOperand1 !== void 0 && typeof defaultOperand1 === "boolean") {
|
|
22
|
+
defaultFilter.operand1 = defaultOperand1;
|
|
23
|
+
}
|
|
24
|
+
return defaultFilter;
|
|
25
|
+
}
|
|
26
|
+
getFilterFromFormValue(formFilterValue) {
|
|
27
|
+
const operator = formFilterValue.formValueOperator.id;
|
|
28
|
+
const operand1 = formFilterValue.formValueOperand1?.value || false;
|
|
29
|
+
return {
|
|
30
|
+
fieldType: "boolean",
|
|
31
|
+
operator,
|
|
32
|
+
operand1
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
getFormValue(field, getLabel, filterValue) {
|
|
36
|
+
const filterValueBoolean = filterValue ? filterValue : void 0;
|
|
37
|
+
const operator = filterValueBoolean ? filterValueBoolean.operator : field.defaultOperator ?? "e";
|
|
38
|
+
const formValueOperand1 = filterValueBoolean ? {
|
|
39
|
+
value: filterValueBoolean.operand1,
|
|
40
|
+
label: getLabel(getDynamicFilterDictionary(`operand_${filterValueBoolean.operand1}`))
|
|
41
|
+
} : null;
|
|
42
|
+
return {
|
|
43
|
+
fieldType: "boolean",
|
|
44
|
+
formValueOperator: {
|
|
45
|
+
id: operator,
|
|
46
|
+
label: getLabel(getDynamicFilterDictionary(`operator_${operator}`))
|
|
47
|
+
},
|
|
48
|
+
formValueOperand1
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
getLabels(filter, getLabel, _formatters, _field) {
|
|
52
|
+
const labelOperands = filter.operand1 ? getLabel(getDynamicFilterDictionary("operand_true")) : getLabel(getDynamicFilterDictionary("operand_false"));
|
|
53
|
+
return {
|
|
54
|
+
labelField: filter.field.label ?? getLabel(filter.field.dictionaryId),
|
|
55
|
+
labelOperator: getLabel(getDynamicFilterDictionary(`operator_${filter.operator}`)),
|
|
56
|
+
labelOperands
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
getSchema(getLabel) {
|
|
60
|
+
return Yup.object({
|
|
61
|
+
formValueOperator: Yup.object().nullable().required(getLabel(`dynamic_filter.error_operator_required`)),
|
|
62
|
+
formValueOperand1: Yup.object().nullable().required(getLabel(`dynamic_filter.error_operand_required`))
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
verifyFilter(filter, _field) {
|
|
66
|
+
if (typeof filter.operator !== "string") {
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
if (BOOLEAN_OPERATORS.findIndex((f) => f === filter.operator) === -1) {
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
return typeof filter.operand1 === "boolean";
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
class StringFilterHelpers {
|
|
76
|
+
getComponent() {
|
|
77
|
+
return StringFilter;
|
|
78
|
+
}
|
|
79
|
+
getDefaultFilter(field, fixed) {
|
|
80
|
+
const defaultOperand1 = field.defaultOperand1;
|
|
81
|
+
const defaultFilter = {
|
|
82
|
+
id: 0,
|
|
83
|
+
fieldType: "string",
|
|
84
|
+
field,
|
|
85
|
+
fixed,
|
|
86
|
+
isSet: false,
|
|
87
|
+
operator: "c",
|
|
88
|
+
operand1: ""
|
|
89
|
+
};
|
|
90
|
+
if (defaultOperand1 !== void 0 && typeof defaultOperand1 === "string") {
|
|
91
|
+
defaultFilter.operand1 = defaultOperand1;
|
|
92
|
+
}
|
|
93
|
+
return defaultFilter;
|
|
94
|
+
}
|
|
95
|
+
getFilterFromFormValue(formFilterValue) {
|
|
96
|
+
const operator = formFilterValue.formValueOperator.id;
|
|
97
|
+
const operand1 = formFilterValue.formValueOperand1;
|
|
98
|
+
return {
|
|
99
|
+
fieldType: "string",
|
|
100
|
+
operator,
|
|
101
|
+
operand1
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
getFormValue(field, getLabel, filterValue) {
|
|
105
|
+
const filterValueString = filterValue;
|
|
106
|
+
const operator = filterValueString ? filterValueString.operator : field.defaultOperator ?? "c";
|
|
107
|
+
const formValueOperand1 = filterValueString ? filterValueString.operand1 : "";
|
|
108
|
+
return {
|
|
109
|
+
fieldType: "string",
|
|
110
|
+
formValueOperator: {
|
|
111
|
+
id: operator,
|
|
112
|
+
label: getLabel(getDynamicFilterDictionary(`operator_${operator}`))
|
|
113
|
+
},
|
|
114
|
+
formValueOperand1
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
getLabels(filter, getLabel, _formatters, _field) {
|
|
118
|
+
const labelOperands = filter.operand1 !== void 0 ? filter.operand1 + "" : "";
|
|
119
|
+
return {
|
|
120
|
+
labelField: filter.field.label ?? getLabel(filter.field.dictionaryId),
|
|
121
|
+
labelOperator: getLabel(getDynamicFilterDictionary(`operator_${filter.operator}`)),
|
|
122
|
+
labelOperands
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
getSchema(getLabel) {
|
|
126
|
+
return Yup.object({
|
|
127
|
+
formValueOperator: Yup.object().nullable().required(getLabel(getDynamicFilterDictionary(DICCTIONARY.operator_required))),
|
|
128
|
+
formValueOperand1: Yup.string().required(
|
|
129
|
+
getLabel(getDynamicFilterDictionary(DICCTIONARY.error_operand_required))
|
|
130
|
+
)
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
verifyFilter(filter, _field) {
|
|
134
|
+
if (typeof filter.operator !== "string") {
|
|
135
|
+
return false;
|
|
136
|
+
}
|
|
137
|
+
if (STRING_OPERATORS.findIndex((f) => f === filter.operator) === -1) {
|
|
138
|
+
return false;
|
|
139
|
+
}
|
|
140
|
+
if (typeof filter.operand1 !== "string") {
|
|
141
|
+
return false;
|
|
142
|
+
}
|
|
143
|
+
return true;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
class DateTimeFilterHelpers {
|
|
147
|
+
getComponent() {
|
|
148
|
+
return DateTimeFilter;
|
|
149
|
+
}
|
|
150
|
+
getDefaultFilter(field, fixed) {
|
|
151
|
+
const defaultStartDate = new Date();
|
|
152
|
+
const defaultEndDate = new Date();
|
|
153
|
+
defaultStartDate.setHours(0, 0, 0, 0);
|
|
154
|
+
defaultEndDate.setHours(23, 59, 59, 999);
|
|
155
|
+
const defaultOperand1 = field.defaultOperand1 && field.defaultOperand1 instanceof Date ? field.defaultOperand1 : defaultStartDate;
|
|
156
|
+
const defaultOperand2 = field.defaultOperand2 && field.defaultOperand2 instanceof Date ? field.defaultOperand2 : defaultEndDate;
|
|
157
|
+
return {
|
|
158
|
+
id: 0,
|
|
159
|
+
fieldType: "datetime",
|
|
160
|
+
field,
|
|
161
|
+
fixed,
|
|
162
|
+
isSet: true,
|
|
163
|
+
operator: "b",
|
|
164
|
+
operand1: defaultOperand1,
|
|
165
|
+
operand2: defaultOperand2
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
getFormValue(field, getLabel, filterValueDateTime) {
|
|
169
|
+
const filterValue = filterValueDateTime;
|
|
170
|
+
const operator = filterValue ? filterValue.operator : field.defaultOperator ?? "b";
|
|
171
|
+
const defaultStartDate = new Date();
|
|
172
|
+
const defaultEndDate = new Date();
|
|
173
|
+
const defaultOperand1 = field.defaultOperand1 && field.defaultOperand1 instanceof Date ? field.defaultOperand1 : defaultStartDate;
|
|
174
|
+
const defaultOperand2 = field.defaultOperand2 && field.defaultOperand2 instanceof Date ? field.defaultOperand2 : defaultEndDate;
|
|
175
|
+
const formValueOperand1 = filterValue ? filterValue.operand1 : defaultOperand1;
|
|
176
|
+
const formValueOperand2 = filterValue && filterValue.operator === "b" ? filterValue.operand2 : defaultOperand2;
|
|
177
|
+
return {
|
|
178
|
+
fieldType: "datetime",
|
|
179
|
+
formValueOperator: {
|
|
180
|
+
id: operator,
|
|
181
|
+
label: getLabel(getDynamicFilterDictionary(`operator_${operator}`))
|
|
182
|
+
},
|
|
183
|
+
formValueOperand1,
|
|
184
|
+
formValueOperand2
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
getFilterFromFormValue(formFilterValue) {
|
|
188
|
+
const operator = formFilterValue.formValueOperator.id;
|
|
189
|
+
const operand1 = formFilterValue.formValueOperand1;
|
|
190
|
+
if (operator === "b") {
|
|
191
|
+
const operand2 = formFilterValue.formValueOperand2;
|
|
192
|
+
return {
|
|
193
|
+
fieldType: "datetime",
|
|
194
|
+
operator,
|
|
195
|
+
operand1,
|
|
196
|
+
operand2
|
|
197
|
+
};
|
|
198
|
+
} else {
|
|
199
|
+
return {
|
|
200
|
+
fieldType: "datetime",
|
|
201
|
+
operator,
|
|
202
|
+
operand1
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
getLabels(filter, getLabel, formatters, _field) {
|
|
207
|
+
const { dateFormatter } = formatters;
|
|
208
|
+
let labelOperands;
|
|
209
|
+
if (filter.operator === "b") {
|
|
210
|
+
labelOperands = filter.operand1 && filter.operand2 ? `${dateFormatter.formatDate(
|
|
211
|
+
filter.operand1,
|
|
212
|
+
dateFormatter.datetimeFormat
|
|
213
|
+
)} - ${dateFormatter.formatDate(filter.operand2, dateFormatter.datetimeFormat)}` : "";
|
|
214
|
+
} else {
|
|
215
|
+
labelOperands = filter.operand1 ? dateFormatter.formatDate(filter.operand1, dateFormatter.datetimeFormat) : "";
|
|
216
|
+
}
|
|
217
|
+
return {
|
|
218
|
+
labelField: filter.field.label ?? getLabel(filter.field.dictionaryId),
|
|
219
|
+
labelOperator: getLabel(getDynamicFilterDictionary(`operator_${filter.operator}`)),
|
|
220
|
+
labelOperands
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
getSchema(getLabel) {
|
|
224
|
+
return Yup.object({
|
|
225
|
+
formValueOperator: Yup.object().nullable().required(getLabel(getDynamicFilterDictionary(DICCTIONARY.operator_required))),
|
|
226
|
+
formValueOperand1: Yup.date().required(getLabel(getDynamicFilterDictionary(DICCTIONARY.error_invalid_date))).typeError(getLabel(getDynamicFilterDictionary(DICCTIONARY.error_invalid_date))),
|
|
227
|
+
formValueOperand2: Yup.mixed().when(["formValueOperator.id"], {
|
|
228
|
+
is: "b",
|
|
229
|
+
then: Yup.date().typeError(getLabel(getDynamicFilterDictionary(DICCTIONARY.error_invalid_date))).min(
|
|
230
|
+
Yup.ref("formValueOperand1"),
|
|
231
|
+
getLabel(getDynamicFilterDictionary(DICCTIONARY.error_invalid_date))
|
|
232
|
+
)
|
|
233
|
+
})
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
verifyFilter(filter, _field) {
|
|
237
|
+
if (typeof filter.operator !== "string") {
|
|
238
|
+
return false;
|
|
239
|
+
}
|
|
240
|
+
if (DATE_TIME_OPERATORS.findIndex((f) => f === filter.operator) === -1) {
|
|
241
|
+
return false;
|
|
242
|
+
}
|
|
243
|
+
if (typeof filter.operand1 !== "string") {
|
|
244
|
+
return false;
|
|
245
|
+
}
|
|
246
|
+
if (!isValidDate(new Date(filter.operand1))) {
|
|
247
|
+
return false;
|
|
248
|
+
}
|
|
249
|
+
if (filter.operator === "b") {
|
|
250
|
+
if (typeof filter.operand2 !== "string") {
|
|
251
|
+
return false;
|
|
252
|
+
}
|
|
253
|
+
if (!isValidDate(new Date(filter.operand1))) {
|
|
254
|
+
return false;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
return true;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
class NumberFilterHelpers {
|
|
261
|
+
getComponent() {
|
|
262
|
+
return NumberFilter;
|
|
263
|
+
}
|
|
264
|
+
getDefaultFilter(fieldNumber, fixed) {
|
|
265
|
+
const field = fieldNumber;
|
|
266
|
+
const dOperator = field.defaultOperator ?? "e";
|
|
267
|
+
const defaultOperand1 = field.defaultOperand1 ?? null;
|
|
268
|
+
const defaultOperand2 = field.defaultOperand2 ?? null;
|
|
269
|
+
return {
|
|
270
|
+
id: 0,
|
|
271
|
+
fieldType: "number",
|
|
272
|
+
field,
|
|
273
|
+
fixed,
|
|
274
|
+
isSet: false,
|
|
275
|
+
operator: dOperator,
|
|
276
|
+
operand1: defaultOperand1,
|
|
277
|
+
operand2: defaultOperand2
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
getFormValue(field, getLabel, filterValue) {
|
|
281
|
+
const filterValueNumber = filterValue;
|
|
282
|
+
const operator = filterValueNumber ? filterValueNumber.operator : field.defaultOperator ?? "e";
|
|
283
|
+
const formValueOperand1 = filterValueNumber ? filterValueNumber.operand1 : null;
|
|
284
|
+
const formValueOperand2 = filterValueNumber && filterValueNumber?.operator === "b" ? filterValueNumber.operand2 : null;
|
|
285
|
+
return {
|
|
286
|
+
fieldType: "number",
|
|
287
|
+
formValueOperator: {
|
|
288
|
+
id: operator,
|
|
289
|
+
label: getLabel(getDynamicFilterDictionary(`operator_${operator}`))
|
|
290
|
+
},
|
|
291
|
+
formValueOperand1,
|
|
292
|
+
formValueOperand2
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
getFilterFromFormValue(formFilterValue) {
|
|
296
|
+
const operator = formFilterValue.formValueOperator.id;
|
|
297
|
+
const operand1 = formFilterValue.formValueOperand1 ? formFilterValue.formValueOperand1 : 0;
|
|
298
|
+
if (operator === "b") {
|
|
299
|
+
const operand2 = formFilterValue.formValueOperand2 ? formFilterValue.formValueOperand2 : 0;
|
|
300
|
+
return {
|
|
301
|
+
fieldType: "number",
|
|
302
|
+
operator,
|
|
303
|
+
operand1,
|
|
304
|
+
operand2
|
|
305
|
+
};
|
|
306
|
+
} else {
|
|
307
|
+
return {
|
|
308
|
+
fieldType: "number",
|
|
309
|
+
operator,
|
|
310
|
+
operand1
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
getLabels(filter, getLabel, _formatters, _field) {
|
|
315
|
+
let labelOperands;
|
|
316
|
+
if (filter.operator === "b") {
|
|
317
|
+
labelOperands = filter.operand1 && filter.operand2 ? `${filter.operand1} - ${filter.operand2}` : "";
|
|
318
|
+
} else {
|
|
319
|
+
labelOperands = filter.operand1 !== void 0 ? filter.operand1 + "" : "";
|
|
320
|
+
}
|
|
321
|
+
return {
|
|
322
|
+
labelField: filter.field.label ?? getLabel(filter.field.dictionaryId),
|
|
323
|
+
labelOperator: getLabel(getDynamicFilterDictionary(`operator_${filter.operator}`)),
|
|
324
|
+
labelOperands
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
getSchema(getLabel) {
|
|
328
|
+
return Yup.object({
|
|
329
|
+
formValueOperator: Yup.object().nullable().required(getLabel(`dynamic_filter.error_operator_required`)),
|
|
330
|
+
formValueOperand1: Yup.number().typeError(
|
|
331
|
+
getLabel(`dynamic_filter.error_operand_mustbe_number`)
|
|
332
|
+
),
|
|
333
|
+
formValueOperand2: Yup.mixed().when(["formValueOperator.id"], {
|
|
334
|
+
is: "b",
|
|
335
|
+
then: Yup.number().typeError(getLabel(`dynamic_filter.error_operand_mustbe_number`)).min(Yup.ref("formValueOperand1"), getLabel(`dynamic_filter.error_less_than_start`))
|
|
336
|
+
})
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
verifyFilter(filter, _field) {
|
|
340
|
+
if (typeof filter.operator !== "number") {
|
|
341
|
+
return false;
|
|
342
|
+
}
|
|
343
|
+
if (NUMBER_OPERATORS.findIndex((f) => f === filter.operator) === -1) {
|
|
344
|
+
return false;
|
|
345
|
+
}
|
|
346
|
+
if (typeof filter.operand1 !== "number") {
|
|
347
|
+
return false;
|
|
348
|
+
}
|
|
349
|
+
if (filter.operator === "b" && typeof filter.operand2 !== "number") {
|
|
350
|
+
return false;
|
|
351
|
+
}
|
|
352
|
+
return true;
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
function filterValidOperandsArraySelect(operandsArray, field) {
|
|
356
|
+
const operandsArrayFormatted = Array.isArray(operandsArray) ? operandsArray : [operandsArray];
|
|
357
|
+
const getOptionId = field?.selectOptions?.getOptionId;
|
|
358
|
+
const getOptionLabel = field?.selectOptions?.getOptionLabel;
|
|
359
|
+
return operandsArrayFormatted?.filter((operand) => {
|
|
360
|
+
return typeof operand === "object" && getOptionId?.(operand) && getOptionLabel?.(operand);
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
class SelectFilterHelpers {
|
|
364
|
+
getComponent() {
|
|
365
|
+
return SelectFilter;
|
|
366
|
+
}
|
|
367
|
+
getDefaultFilter(field, fixed) {
|
|
368
|
+
const defaultOperand = field.defaultOperandsArray;
|
|
369
|
+
const defaultFilter = {
|
|
370
|
+
id: 0,
|
|
371
|
+
fieldType: "select",
|
|
372
|
+
field,
|
|
373
|
+
fixed,
|
|
374
|
+
isSet: true,
|
|
375
|
+
operator: "in",
|
|
376
|
+
operandsArray: []
|
|
377
|
+
};
|
|
378
|
+
if (defaultOperand !== void 0 && Array.isArray(defaultOperand)) {
|
|
379
|
+
const validOperandsArray = filterValidOperandsArraySelect(defaultOperand, field);
|
|
380
|
+
defaultFilter.operandsArray = validOperandsArray || [];
|
|
381
|
+
}
|
|
382
|
+
return defaultFilter;
|
|
383
|
+
}
|
|
384
|
+
getFormValue(field, getLabel, filterValueSelect) {
|
|
385
|
+
const filterValue = filterValueSelect ? filterValueSelect : void 0;
|
|
386
|
+
const isMultiple = field?.selectOptions?.multiple ?? false;
|
|
387
|
+
const formValueOperandsArray = isMultiple ? filterValueSelect?.operandsArray : filterValueSelect?.operandsArray?.[0] || filterValueSelect?.operandsArray;
|
|
388
|
+
const operator = filterValue ? filterValue.operator : field.defaultOperator ?? "in";
|
|
389
|
+
return {
|
|
390
|
+
fieldType: "select",
|
|
391
|
+
formValueOperator: {
|
|
392
|
+
id: operator,
|
|
393
|
+
label: getLabel(getDynamicFilterDictionary(`operator_${operator}`))
|
|
394
|
+
},
|
|
395
|
+
formValueOperandsArray
|
|
396
|
+
};
|
|
397
|
+
}
|
|
398
|
+
getFilterFromFormValue(formFilterValue) {
|
|
399
|
+
const operator = formFilterValue.formValueOperator.id;
|
|
400
|
+
const operandsArray = Array.isArray(formFilterValue.formValueOperandsArray) ? formFilterValue.formValueOperandsArray : [formFilterValue.formValueOperandsArray];
|
|
401
|
+
return {
|
|
402
|
+
fieldType: "select",
|
|
403
|
+
operator,
|
|
404
|
+
operandsArray
|
|
405
|
+
};
|
|
406
|
+
}
|
|
407
|
+
getLabels(filter, getLabel, _formatters, field) {
|
|
408
|
+
const operandsArray = filter.operandsArray;
|
|
409
|
+
const labelOperands = operandsArray?.reduce?.((label, operand) => {
|
|
410
|
+
const textLabel = field.selectOptions?.getOptionLabel?.(operand) || "";
|
|
411
|
+
return label ? `${label} | ${textLabel}` : textLabel;
|
|
412
|
+
}, "")?.toString() || "";
|
|
413
|
+
return {
|
|
414
|
+
labelField: filter.field.label ?? getLabel(filter.field.dictionaryId),
|
|
415
|
+
labelOperator: getLabel(getDynamicFilterDictionary(`operator_${filter.operator}`)),
|
|
416
|
+
labelOperands
|
|
417
|
+
};
|
|
418
|
+
}
|
|
419
|
+
getSchema(getLabel) {
|
|
420
|
+
return Yup.object({
|
|
421
|
+
formValueOperator: Yup.object().nullable().required(getLabel(`dynamic_filter.error_operator_required`)),
|
|
422
|
+
formValueOperandsArray: Yup.lazy((value) => {
|
|
423
|
+
return Array.isArray(value) ? Yup.array().min(1, getLabel(`dynamic_filter.error_operand_required`)).of(Yup.object().nullable()).required(getLabel(`dynamic_filter.error_operand_required`)) : Yup.object().nullable().required(getLabel(`dynamic_filter.error_operand_required`));
|
|
424
|
+
})
|
|
425
|
+
});
|
|
426
|
+
}
|
|
427
|
+
verifyFilter(filter, field) {
|
|
428
|
+
if (typeof filter.operator !== "string") {
|
|
429
|
+
return false;
|
|
430
|
+
}
|
|
431
|
+
if (!field) {
|
|
432
|
+
return false;
|
|
433
|
+
}
|
|
434
|
+
if (SELECT_OPERATORS.findIndex((f) => f === filter.operator) === -1) {
|
|
435
|
+
return false;
|
|
436
|
+
}
|
|
437
|
+
if (!filter.operandsArray || typeof filter.operandsArray !== "object") {
|
|
438
|
+
return false;
|
|
439
|
+
}
|
|
440
|
+
const validOperandsArray = filterValidOperandsArraySelect(
|
|
441
|
+
filter.operandsArray,
|
|
442
|
+
field
|
|
443
|
+
);
|
|
444
|
+
if (!validOperandsArray || validOperandsArray?.length === 0) {
|
|
445
|
+
return false;
|
|
446
|
+
}
|
|
447
|
+
return true;
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
function getPurgedInitialFiltersApplied(fields, initialFilters, getFieldByName) {
|
|
451
|
+
const newFilters = [];
|
|
452
|
+
const fixedFields = [];
|
|
453
|
+
for (let index = 0; index < initialFilters.length; index++) {
|
|
454
|
+
try {
|
|
455
|
+
const initialFilter = initialFilters[index];
|
|
456
|
+
const field = getFieldByName(initialFilter.name);
|
|
457
|
+
const filter = {
|
|
458
|
+
id: 0,
|
|
459
|
+
isSet: true,
|
|
460
|
+
fixed: false,
|
|
461
|
+
field,
|
|
462
|
+
fieldType: field.type,
|
|
463
|
+
operator: initialFilters[index].operator,
|
|
464
|
+
operand1: initialFilters[index].operand1,
|
|
465
|
+
operand2: initialFilters[index].operand2,
|
|
466
|
+
operandsArray: initialFilters[index].operandsArray
|
|
467
|
+
};
|
|
468
|
+
if (!field)
|
|
469
|
+
continue;
|
|
470
|
+
const canAddField = fieldFactory(field.type).verifyFilter(initialFilter, field);
|
|
471
|
+
if (canAddField) {
|
|
472
|
+
if (filter.fieldType === "datetime") {
|
|
473
|
+
filter.operand1 = new Date(filter.operand1 + "");
|
|
474
|
+
filter.operand2 = new Date(filter.operand2 + "");
|
|
475
|
+
}
|
|
476
|
+
if (field.presence === "fixed") {
|
|
477
|
+
if (fixedFields.findIndex((f) => f === field.name) === -1) {
|
|
478
|
+
filter.fixed = true;
|
|
479
|
+
fixedFields.push(field.name);
|
|
480
|
+
} else {
|
|
481
|
+
filter.fixed = false;
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
filter.isSet = true;
|
|
485
|
+
filter.id = newFilters.length + 1;
|
|
486
|
+
newFilters.push(filter);
|
|
487
|
+
}
|
|
488
|
+
} catch (error) {
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
for (let index = 0; index < fields.length; index++) {
|
|
492
|
+
const field = fields[index];
|
|
493
|
+
if (field.presence === "initialized" || field.presence === "fixed") {
|
|
494
|
+
if (!initialFilters.find((f) => f.name === field.name)) {
|
|
495
|
+
const newFilter = fieldFactory(field.type).getDefaultFilter(
|
|
496
|
+
field,
|
|
497
|
+
field.presence === "fixed"
|
|
498
|
+
);
|
|
499
|
+
newFilter.id = newFilters.length + 1;
|
|
500
|
+
newFilters.push(newFilter);
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
return newFilters;
|
|
505
|
+
}
|
|
506
|
+
const formatToRawFilter = (appliedFilters) => {
|
|
507
|
+
return appliedFilters.map((af) => {
|
|
508
|
+
let oa = void 0;
|
|
509
|
+
if (af.field.type === "select" && af.operandsArray) {
|
|
510
|
+
oa = Array.isArray(af.operandsArray) ? af.operandsArray.map(af.field.selectOptions.getOptionId) : [af.field.selectOptions.getOptionId(af.operandsArray)];
|
|
511
|
+
}
|
|
512
|
+
return {
|
|
513
|
+
n: af.field.name,
|
|
514
|
+
o: af.operator,
|
|
515
|
+
o1: af.operand1,
|
|
516
|
+
o2: af.operator === "b" ? af.operand2 : void 0,
|
|
517
|
+
oa
|
|
518
|
+
};
|
|
519
|
+
});
|
|
520
|
+
};
|
|
521
|
+
function formatToInitialFilters(appliedFilters) {
|
|
522
|
+
return appliedFilters.map((appliedFilter) => {
|
|
523
|
+
const ret = {
|
|
524
|
+
name: appliedFilter.field.name,
|
|
525
|
+
operator: appliedFilter.operator,
|
|
526
|
+
operand1: appliedFilter.operand1,
|
|
527
|
+
operand2: appliedFilter.operator === "b" ? appliedFilter.operand2 : void 0
|
|
528
|
+
};
|
|
529
|
+
if (appliedFilter.fieldType === "datetime") {
|
|
530
|
+
ret.operand1 = appliedFilter.operand1.toISOString();
|
|
531
|
+
ret.operand2 = appliedFilter.operator === "b" ? appliedFilter.operand2.toISOString() : void 0;
|
|
532
|
+
}
|
|
533
|
+
if (appliedFilter.fieldType === "select") {
|
|
534
|
+
const validOperandsArray = filterValidOperandsArraySelect(
|
|
535
|
+
appliedFilter.operandsArray,
|
|
536
|
+
appliedFilter.field
|
|
537
|
+
);
|
|
538
|
+
if (validOperandsArray && validOperandsArray?.length > 0) {
|
|
539
|
+
ret.operandsArray = validOperandsArray;
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
if (ret.operand2 === void 0) {
|
|
543
|
+
delete ret.operand2;
|
|
544
|
+
}
|
|
545
|
+
return ret;
|
|
546
|
+
});
|
|
547
|
+
}
|
|
548
|
+
export {
|
|
549
|
+
BooleanFilterHelpers as B,
|
|
550
|
+
DateTimeFilterHelpers as D,
|
|
551
|
+
NumberFilterHelpers as N,
|
|
552
|
+
StringFilterHelpers as S,
|
|
553
|
+
formatToRawFilter as a,
|
|
554
|
+
SelectFilterHelpers as b,
|
|
555
|
+
formatToInitialFilters as f,
|
|
556
|
+
getPurgedInitialFiltersApplied as g
|
|
557
|
+
};
|