@m4l/components 1.0.10 → 1.0.12
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.705c7df5.js} +4 -4
- package/components/AppBar/{index.233917e6.js → index.04816fec.js} +4 -4
- package/components/CommonActions/components/ActionCancel/index.609a78ca.js +12 -0
- package/components/CommonActions/components/ActionFormCancel/index.2a55418d.js +56 -0
- package/components/CommonActions/components/ActionFormIntro/index.34d569d1.js +33 -0
- package/components/CommonActions/components/ActionIntro/index.ebac0bc1.js +25 -0
- package/components/CommonActions/components/Actions/index.258bf919.js +71 -0
- package/components/DataGrid/constants.e334cd50.js +10 -0
- package/components/DataGrid/formatters/ColumnBooleanFormatter/index.30ea5c9a.js +26 -0
- package/components/DataGrid/formatters/ColumnConcatenatedValueFormatter/index.512d6ee0.js +22 -0
- package/components/DataGrid/formatters/ColumnDateFormatter/index.e00d0cf2.js +19 -0
- package/components/DataGrid/formatters/ColumnInteractiveCheckFormatter/index.5d294f5d.js +23 -0
- package/components/DataGrid/formatters/ColumnNestedValueFormatter/index.880e743b.js +14 -0
- package/components/DataGrid/formatters/ColumnPointsFormatter/index.226cc583.js +10 -0
- package/components/DataGrid/formatters/ColumnPriceFormatter/index.bf9d9e60.js +10 -0
- package/components/DataGrid/formatters/ColumnSetCheckFormatter/index.4045b2f2.js +36 -0
- package/components/DataGrid/formatters/ColumnUncertaintyFormatter/index.a87302d1.js +10 -0
- package/components/DataGrid/formatters/index.2c2f0ae4.js +1 -0
- package/components/DataGrid/index.3ffee8f3.js +915 -0
- package/components/DataGrid/subcomponents/Actions/index.8224ef1a.js +596 -0
- package/components/DataGrid/subcomponents/editors/TextEditor/index.3f0d9e28.js +76 -0
- package/components/DragResizeWindow/{index.8b3e79f7.js → index.917d150b.js} +6 -3
- package/components/DynamicFilter/helpers/index.9baa9ef7.js +556 -0
- package/components/DynamicFilter/index.7e64ade0.js +441 -0
- package/components/DynamicFilter/slots/{index.268c8973.js → index.dbb0936d.js} +32 -32
- package/components/DynamicFilter/store/index.eafe4a4d.js +254 -0
- package/components/DynamicFilter/subcomponents/index.d5bea68c.js +786 -0
- package/components/FieldLabel/{index.61450047.js → index.317f5f6f.js} +4 -4
- package/components/GridLayout/{index.656840a5.js → index.68d907d4.js} +34 -11
- package/components/GridLayout/subcomponents/Griditem/{index.b23625d7.js → index.8955a794.js} +3 -4
- package/components/GridLayout/subcomponents/Responsive/{index.97505a31.js → index.45cecca2.js} +1 -2
- package/components/GridLayout/subcomponents/SizeProvider/{index.36cb4139.js → index.7050ac4f.js} +1 -1
- package/components/HelperText/{index.ebb53dac.js → index.09e80920.js} +1 -1
- package/components/Icon/{index.0d591435.js → index.0598dfb1.js} +10 -26
- package/components/Image/{index.7b1ce7d6.js → index.19aa7ff5.js} +3 -2
- package/components/LanguagePopover/index.921efd11.js +188 -0
- package/components/{mui_extended/LinearProgress/index.e9455b2e.js → LinearProgressIndeterminate/index.ea9c8518.js} +4 -9
- package/components/LoadingError/{index.5b8a819d.js → index.1e464569.js} +11 -7
- package/components/MFLoader/{index.6f690259.js → index.08b59dce.js} +8 -4
- package/components/ModalDialog/{index.bdae9c06.js → index.0dd5af28.js} +14 -5
- package/components/NavLink/{index.9f5d5670.js → index.ad039baf.js} +3 -2
- package/components/NoItemSelected/{index.71727588.js → index.d10603d7.js} +13 -3
- package/components/ObjectLogs/{index.5e18c08e.js → index.72dc8feb.js} +25 -8
- package/components/PDFViewer/{index.e5b7b58c.js → index.35f68e67.js} +2 -2
- package/components/Page/{index.bf61755b.js → index.f4755eba.js} +18 -2
- package/components/PaperForm/{index.2c5d1c14.js → index.5ef72398.js} +2 -2
- package/components/Period/{index.9f3a2531.js → index.301a752f.js} +15 -54
- package/components/PrintingSystem/{index.e166c8d5.js → index.a69a9d85.js} +14 -15
- package/components/PrintingSystem/subcomponents/BodyNode/{index.ff5bd9ba.js → index.528fcfbf.js} +1 -1
- package/components/PrintingSystem/subcomponents/ChartNode/{index.e78e9c90.js → index.fbe87257.js} +1 -1
- package/components/PrintingSystem/subcomponents/DividerNode/{index.1ff8a100.js → index.f5adab1d.js} +1 -1
- package/components/PrintingSystem/subcomponents/FooterNode/{index.7078b267.js → index.f42ca7dc.js} +1 -1
- package/components/PrintingSystem/subcomponents/GridNode/{index.45007400.js → index.041b9cff.js} +1 -1
- package/components/PrintingSystem/subcomponents/HeaderNode/{index.c19c37d6.js → index.a8140332.js} +1 -1
- package/components/PrintingSystem/subcomponents/PaperNode/{index.3a620060.js → index.aabde2bb.js} +1 -1
- package/components/PrintingSystem/subcomponents/PropertyValueNode/{index.c158a2b6.js → index.7f75ca46.js} +1 -1
- package/components/PrintingSystem/subcomponents/SectionNode/{index.cc08a0f8.js → index.61babb47.js} +1 -1
- package/components/PrintingSystem/subcomponents/TextBoxNode/{index.a37d8efa.js → index.4d0e67a3.js} +1 -1
- package/components/PropertyValue/{index.2e61bd86.js → index.0b5c361c.js} +7 -4
- package/components/Resizeable/{index.414ff687.js → index.4f75c0b5.js} +1 -1
- package/components/ScrollBar/{index.1e89bb44.js → index.21bc5025.js} +1 -1
- package/components/SideBar/{index.a645fbb3.js → index.8fdf28e0.js} +36 -7
- package/components/SplitLayout/{index.7d9edf4e.js → index.15756f0f.js} +3 -1
- package/components/ToastContainer/{index.c1ae5efc.js → index.123d26d9.js} +3 -3
- package/components/animate/variants/index.7a912140.js +1 -0
- package/components/areas/components/AreasAdmin/index.1aec24f3.js +733 -0
- package/components/areas/components/AreasViewer/index.429dbb7b.js +1072 -0
- package/components/areas/components/index.558684b3.js +1 -0
- package/components/areas/constants.66529246.js +6 -0
- package/components/areas/contexts/AreasContext/{index.ed31c72d.js → index.2e7cdc05.js} +6 -5
- package/components/areas/contexts/DynamicMFParmsContext/{index.37d1d444.js → index.3d9ad0ad.js} +2 -2
- package/components/areas/contexts/WindowToolsMFContext/{index.69d95c15.js → index.992ae7a3.js} +2 -2
- package/components/areas/contexts/index.24025b97.js +1 -0
- package/components/areas/dictionary.08cfc4c9.js +36 -0
- package/components/areas/hooks/index.d9dc1e21.js +1 -0
- package/components/areas/hooks/useAreas/{index.dca83673.js → index.8913b7b5.js} +1 -1
- package/components/areas/hooks/useDynamicMFParameters/{index.03ce6078.js → index.9e09e1e3.js} +1 -1
- package/components/areas/hooks/useWindowToolsMF/{index.09801b66.js → index.2fbae9dc.js} +1 -1
- package/components/areas/icons.8266ccc8.js +26 -0
- package/components/areas/index.4cc6a221.js +22 -0
- package/components/commercial/AppBarCommercial/index.cbd55cf8.js +28 -0
- package/components/commercial/SectionCommercial/index.d22ebbd5.js +57 -0
- package/components/commercial/TopBar/index.20c4b2ea.js +234 -0
- package/components/{HamburgerMenu/index.6da952c3.js → commercial/index.504bddfe.js} +5 -3
- package/components/formatters/BooleanFormatter/index.a4abeebc.js +44 -0
- package/components/formatters/DateFormatter/index.2ef6f261.js +43 -0
- package/components/formatters/PointsFormatter/index.d8a4ee54.js +25 -0
- package/components/formatters/PriceFormatter/index.97f75b4b.js +35 -0
- package/components/formatters/UncertaintyFormatter/index.c3ffdebc.js +29 -0
- package/components/formatters/index.18f49751.js +117 -0
- package/components/hook-form/HelperError/{index.2ed03a3c.js → index.c0109d5b.js} +1 -1
- package/components/hook-form/RHFAutocomplete/index.d6dd0f42.js +404 -0
- package/components/hook-form/RHFAutocompleteAsync/{index.58439d31.js → index.35d82ca9.js} +2 -3
- package/components/hook-form/RHFCheckbox/{index.52645cbc.js → index.6a1b97dd.js} +4 -4
- package/components/hook-form/RHFColorPicker/{index.ad3a7448.js → index.dccd7187.js} +6 -6
- package/components/hook-form/RHFDateTime/{index.0bb4279e.js → index.15976fef.js} +5 -5
- package/components/hook-form/RHFPeriod/{index.8075a132.js → index.e6d5c3a6.js} +4 -4
- package/components/hook-form/RHFTextField/{index.8d9e389c.js → index.55f91506.js} +6 -6
- package/components/hook-form/RHFUpload/{index.bb7f617e.js → index.7fd23b2a.js} +5 -5
- package/components/{mui_extended/Tab/index.03742bb6.js → maps/components/GpsTools/index.b126f06c.js} +331 -645
- package/components/maps/{index.595f5894.js → components/Map/index.c163038c.js} +737 -28
- package/components/maps/index.13bb982c.js +7 -0
- package/components/modal/{WindowBase.57f82667.js → WindowBase.6fbd595f.js} +4 -4
- package/components/modal/{WindowConfirm.21342f0a.js → WindowConfirm.a33e1d29.js} +10 -6
- package/components/modal/{index.5bce430d.js → index.81eb6def.js} +5 -1
- package/components/mui_extended/Accordion/{index.232b14c4.js → index.808f22d7.js} +5 -5
- package/components/mui_extended/Avatar/{index.12b96914.js → index.fb9ad158.js} +1 -1
- package/components/mui_extended/Badge/{index.4737c113.js → index.8beaeefc.js} +1 -1
- package/components/mui_extended/Button/{index.6276c580.js → index.d742e9ee.js} +6 -81
- package/components/mui_extended/{CheckBox/index.2bf3b459.js → CheckBox.2f354abf.js} +1 -1
- package/components/mui_extended/IconButton/{index.20a5a0be.js → index.98914ce2.js} +1 -1
- package/components/mui_extended/LinearProgress/index.4092bb69.js +9 -0
- package/components/mui_extended/MenuActions/index.ba7f3376.js +176 -0
- package/components/mui_extended/Pager/{index.2a5203df.js → index.abeb8d39.js} +22 -40
- package/components/mui_extended/Popover/index.2348fc4f.js +143 -0
- package/components/mui_extended/Tab/index.e911930f.js +135 -0
- package/components/mui_extended/ToggleButton/{index.7a4779c7.js → index.b834f5f0.js} +1 -1
- package/components/mui_extended/ToggleIconButton/{index.29fdefaa.js → index.efed3ff5.js} +1 -1
- package/components/mui_extended/Typography/{index.463f613f.js → index.642798f1.js} +1 -1
- package/components/mui_extended/index.b606cd9d.js +1 -0
- package/components/popups/PopupsProvider/{index.6b5befba.js → index.8609e808.js} +1 -1
- package/components/popups/PopupsViewer/{index.c7940ab0.js → index.bfab9357.js} +10 -6
- package/contexts/ModalContext/{index.e126d383.js → index.ad1fb73b.js} +1 -1
- package/contexts/RHFormContext/{index.95ebabc9.js → index.bf3a2812.js} +6 -2
- package/hooks/useFormAddEdit/{index.42356b18.js → index.faafbfae.js} +6 -2
- package/hooks/useModal/index.2003c854.js +11 -0
- package/hooks/useTab/index.8d1a6e63.js +12 -0
- package/index.js +330 -274
- package/package.json +1 -1
- package/{react-draggable.0cc9b257.js → react-draggable.1c1ba224.js} +1 -1
- package/{react-resizable.837c446d.js → react-resizable.a59c14f4.js} +2 -2
- package/test/constants_no_mock.86c553a9.js +4 -0
- package/test/{getNameDataTestId.aee44365.js → getNameDataTestId.0faeade8.js} +2 -2
- package/utils/{index.c64c2dd1.js → index.14912462.js} +1 -54
- package/components/CommonActions/index.5f5362d4.js +0 -170
- package/components/DynamicFilter/index.d698a952.js +0 -1721
- package/components/areas/constants.0d3ba950.js +0 -289
- package/components/areas/dictionary.ffe082b0.js +0 -266
- package/components/areas/icons.504ec098.js +0 -83
- package/components/maps/components/GpsTools/index.a32b12b7.js +0 -251
- package/components/mui_extended/Popover/index.fda32ba1.js +0 -1043
- package/hooks/useModal/index.20c3f2be.js +0 -67
- package/vendor.e16cc0cc.js +0 -3952
|
@@ -0,0 +1,556 @@
|
|
|
1
|
+
import * as Yup from "yup";
|
|
2
|
+
import { g as getDynamicFilterDictionary, B as BOOLEAN_OPERATORS, D as DICCTIONARY, S as STRING_OPERATORS, a as DATE_TIME_OPERATORS, N as NUMBER_OPERATORS, b as SELECT_OPERATORS } from "../index.7e64ade0.js";
|
|
3
|
+
import { B as BooleanFilter, S as StringFilter, D as DateTimeFilter, N as NumberFilter, a as SelectFilter, f as fieldFactory } from "../subcomponents/index.d5bea68c.js";
|
|
4
|
+
import { i as isValidDate } from "../../../utils/index.14912462.js";
|
|
5
|
+
class BooleanFilterHelpers {
|
|
6
|
+
getComponent() {
|
|
7
|
+
return BooleanFilter;
|
|
8
|
+
}
|
|
9
|
+
getDefaultFilter(field, fixed) {
|
|
10
|
+
const defaultOperand1 = field.defaultOperand1;
|
|
11
|
+
const defaultFilter = {
|
|
12
|
+
id: 0,
|
|
13
|
+
fieldType: "boolean",
|
|
14
|
+
field,
|
|
15
|
+
fixed,
|
|
16
|
+
isSet: true,
|
|
17
|
+
operator: "e",
|
|
18
|
+
operand1: true
|
|
19
|
+
};
|
|
20
|
+
if (defaultOperand1 !== void 0 && typeof defaultOperand1 === "boolean") {
|
|
21
|
+
defaultFilter.operand1 = defaultOperand1;
|
|
22
|
+
}
|
|
23
|
+
return defaultFilter;
|
|
24
|
+
}
|
|
25
|
+
getFilterFromFormValue(formFilterValue) {
|
|
26
|
+
const operator = formFilterValue.formValueOperator.id;
|
|
27
|
+
const operand1 = formFilterValue.formValueOperand1?.value || false;
|
|
28
|
+
return {
|
|
29
|
+
fieldType: "boolean",
|
|
30
|
+
operator,
|
|
31
|
+
operand1
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
getFormValue(field, getLabel, filterValue) {
|
|
35
|
+
const filterValueBoolean = filterValue ? filterValue : void 0;
|
|
36
|
+
const operator = filterValueBoolean ? filterValueBoolean.operator : field.defaultOperator ?? "e";
|
|
37
|
+
const formValueOperand1 = filterValueBoolean ? {
|
|
38
|
+
value: filterValueBoolean.operand1,
|
|
39
|
+
label: getLabel(getDynamicFilterDictionary(`operand_${filterValueBoolean.operand1}`))
|
|
40
|
+
} : null;
|
|
41
|
+
return {
|
|
42
|
+
fieldType: "boolean",
|
|
43
|
+
formValueOperator: {
|
|
44
|
+
id: operator,
|
|
45
|
+
label: getLabel(getDynamicFilterDictionary(`operator_${operator}`))
|
|
46
|
+
},
|
|
47
|
+
formValueOperand1
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
getLabels(filter, getLabel, _formatters, _field) {
|
|
51
|
+
const labelOperands = filter.operand1 ? getLabel(getDynamicFilterDictionary("operand_true")) : getLabel(getDynamicFilterDictionary("operand_false"));
|
|
52
|
+
return {
|
|
53
|
+
labelField: filter.field.label ?? getLabel(filter.field.dictionaryId),
|
|
54
|
+
labelOperator: getLabel(getDynamicFilterDictionary(`operator_${filter.operator}`)),
|
|
55
|
+
labelOperands
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
getSchema(getLabel) {
|
|
59
|
+
return Yup.object({
|
|
60
|
+
formValueOperator: Yup.object().nullable().required(getLabel(`dynamic_filter.error_operator_required`)),
|
|
61
|
+
formValueOperand1: Yup.object().nullable().required(getLabel(`dynamic_filter.error_operand_required`))
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
verifyFilter(filter, _field) {
|
|
65
|
+
if (typeof filter.operator !== "string") {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
if (BOOLEAN_OPERATORS.findIndex((f) => f === filter.operator) === -1) {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
return typeof filter.operand1 === "boolean";
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
class StringFilterHelpers {
|
|
75
|
+
getComponent() {
|
|
76
|
+
return StringFilter;
|
|
77
|
+
}
|
|
78
|
+
getDefaultFilter(field, fixed) {
|
|
79
|
+
const defaultOperand1 = field.defaultOperand1;
|
|
80
|
+
const defaultFilter = {
|
|
81
|
+
id: 0,
|
|
82
|
+
fieldType: "string",
|
|
83
|
+
field,
|
|
84
|
+
fixed,
|
|
85
|
+
isSet: false,
|
|
86
|
+
operator: "c",
|
|
87
|
+
operand1: ""
|
|
88
|
+
};
|
|
89
|
+
if (defaultOperand1 !== void 0 && typeof defaultOperand1 === "string") {
|
|
90
|
+
defaultFilter.operand1 = defaultOperand1;
|
|
91
|
+
}
|
|
92
|
+
return defaultFilter;
|
|
93
|
+
}
|
|
94
|
+
getFilterFromFormValue(formFilterValue) {
|
|
95
|
+
const operator = formFilterValue.formValueOperator.id;
|
|
96
|
+
const operand1 = formFilterValue.formValueOperand1;
|
|
97
|
+
return {
|
|
98
|
+
fieldType: "string",
|
|
99
|
+
operator,
|
|
100
|
+
operand1
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
getFormValue(field, getLabel, filterValue) {
|
|
104
|
+
const filterValueString = filterValue;
|
|
105
|
+
const operator = filterValueString ? filterValueString.operator : field.defaultOperator ?? "c";
|
|
106
|
+
const formValueOperand1 = filterValueString ? filterValueString.operand1 : "";
|
|
107
|
+
return {
|
|
108
|
+
fieldType: "string",
|
|
109
|
+
formValueOperator: {
|
|
110
|
+
id: operator,
|
|
111
|
+
label: getLabel(getDynamicFilterDictionary(`operator_${operator}`))
|
|
112
|
+
},
|
|
113
|
+
formValueOperand1
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
getLabels(filter, getLabel, _formatters, _field) {
|
|
117
|
+
const labelOperands = filter.operand1 !== void 0 ? filter.operand1 + "" : "";
|
|
118
|
+
return {
|
|
119
|
+
labelField: filter.field.label ?? getLabel(filter.field.dictionaryId),
|
|
120
|
+
labelOperator: getLabel(getDynamicFilterDictionary(`operator_${filter.operator}`)),
|
|
121
|
+
labelOperands
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
getSchema(getLabel) {
|
|
125
|
+
return Yup.object({
|
|
126
|
+
formValueOperator: Yup.object().nullable().required(getLabel(getDynamicFilterDictionary(DICCTIONARY.operator_required))),
|
|
127
|
+
formValueOperand1: Yup.string().required(
|
|
128
|
+
getLabel(getDynamicFilterDictionary(DICCTIONARY.error_operand_required))
|
|
129
|
+
)
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
verifyFilter(filter, _field) {
|
|
133
|
+
if (typeof filter.operator !== "string") {
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
if (STRING_OPERATORS.findIndex((f) => f === filter.operator) === -1) {
|
|
137
|
+
return false;
|
|
138
|
+
}
|
|
139
|
+
if (typeof filter.operand1 !== "string") {
|
|
140
|
+
return false;
|
|
141
|
+
}
|
|
142
|
+
return true;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
class DateTimeFilterHelpers {
|
|
146
|
+
getComponent() {
|
|
147
|
+
return DateTimeFilter;
|
|
148
|
+
}
|
|
149
|
+
getDefaultFilter(field, fixed) {
|
|
150
|
+
const defaultStartDate = new Date();
|
|
151
|
+
const defaultEndDate = new Date();
|
|
152
|
+
defaultStartDate.setHours(0, 0, 0, 0);
|
|
153
|
+
defaultEndDate.setHours(23, 59, 59, 999);
|
|
154
|
+
const defaultOperand1 = field.defaultOperand1 && field.defaultOperand1 instanceof Date ? field.defaultOperand1 : defaultStartDate;
|
|
155
|
+
const defaultOperand2 = field.defaultOperand2 && field.defaultOperand2 instanceof Date ? field.defaultOperand2 : defaultEndDate;
|
|
156
|
+
return {
|
|
157
|
+
id: 0,
|
|
158
|
+
fieldType: "datetime",
|
|
159
|
+
field,
|
|
160
|
+
fixed,
|
|
161
|
+
isSet: true,
|
|
162
|
+
operator: "b",
|
|
163
|
+
operand1: defaultOperand1,
|
|
164
|
+
operand2: defaultOperand2
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
getFormValue(field, getLabel, filterValueDateTime) {
|
|
168
|
+
const filterValue = filterValueDateTime;
|
|
169
|
+
const operator = filterValue ? filterValue.operator : field.defaultOperator ?? "b";
|
|
170
|
+
const defaultStartDate = new Date();
|
|
171
|
+
const defaultEndDate = new Date();
|
|
172
|
+
const defaultOperand1 = field.defaultOperand1 && field.defaultOperand1 instanceof Date ? field.defaultOperand1 : defaultStartDate;
|
|
173
|
+
const defaultOperand2 = field.defaultOperand2 && field.defaultOperand2 instanceof Date ? field.defaultOperand2 : defaultEndDate;
|
|
174
|
+
const formValueOperand1 = filterValue ? filterValue.operand1 : defaultOperand1;
|
|
175
|
+
const formValueOperand2 = filterValue && filterValue.operator === "b" ? filterValue.operand2 : defaultOperand2;
|
|
176
|
+
return {
|
|
177
|
+
fieldType: "datetime",
|
|
178
|
+
formValueOperator: {
|
|
179
|
+
id: operator,
|
|
180
|
+
label: getLabel(getDynamicFilterDictionary(`operator_${operator}`))
|
|
181
|
+
},
|
|
182
|
+
formValueOperand1,
|
|
183
|
+
formValueOperand2
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
getFilterFromFormValue(formFilterValue) {
|
|
187
|
+
const operator = formFilterValue.formValueOperator.id;
|
|
188
|
+
const operand1 = formFilterValue.formValueOperand1;
|
|
189
|
+
if (operator === "b") {
|
|
190
|
+
const operand2 = formFilterValue.formValueOperand2;
|
|
191
|
+
return {
|
|
192
|
+
fieldType: "datetime",
|
|
193
|
+
operator,
|
|
194
|
+
operand1,
|
|
195
|
+
operand2
|
|
196
|
+
};
|
|
197
|
+
} else {
|
|
198
|
+
return {
|
|
199
|
+
fieldType: "datetime",
|
|
200
|
+
operator,
|
|
201
|
+
operand1
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
getLabels(filter, getLabel, formatters, _field) {
|
|
206
|
+
const { dateFormatter } = formatters;
|
|
207
|
+
let labelOperands;
|
|
208
|
+
if (filter.operator === "b") {
|
|
209
|
+
labelOperands = filter.operand1 && filter.operand2 ? `${dateFormatter.formatDate(
|
|
210
|
+
filter.operand1,
|
|
211
|
+
dateFormatter.datetimeFormat
|
|
212
|
+
)} - ${dateFormatter.formatDate(filter.operand2, dateFormatter.datetimeFormat)}` : "";
|
|
213
|
+
} else {
|
|
214
|
+
labelOperands = filter.operand1 ? dateFormatter.formatDate(filter.operand1, dateFormatter.datetimeFormat) : "";
|
|
215
|
+
}
|
|
216
|
+
return {
|
|
217
|
+
labelField: filter.field.label ?? getLabel(filter.field.dictionaryId),
|
|
218
|
+
labelOperator: getLabel(getDynamicFilterDictionary(`operator_${filter.operator}`)),
|
|
219
|
+
labelOperands
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
getSchema(getLabel) {
|
|
223
|
+
return Yup.object({
|
|
224
|
+
formValueOperator: Yup.object().nullable().required(getLabel(getDynamicFilterDictionary(DICCTIONARY.operator_required))),
|
|
225
|
+
formValueOperand1: Yup.date().required(getLabel(getDynamicFilterDictionary(DICCTIONARY.error_invalid_date))).typeError(getLabel(getDynamicFilterDictionary(DICCTIONARY.error_invalid_date))),
|
|
226
|
+
formValueOperand2: Yup.mixed().when(["formValueOperator.id"], {
|
|
227
|
+
is: "b",
|
|
228
|
+
then: Yup.date().typeError(getLabel(getDynamicFilterDictionary(DICCTIONARY.error_invalid_date))).min(
|
|
229
|
+
Yup.ref("formValueOperand1"),
|
|
230
|
+
getLabel(getDynamicFilterDictionary(DICCTIONARY.error_invalid_date))
|
|
231
|
+
)
|
|
232
|
+
})
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
verifyFilter(filter, _field) {
|
|
236
|
+
if (typeof filter.operator !== "string") {
|
|
237
|
+
return false;
|
|
238
|
+
}
|
|
239
|
+
if (DATE_TIME_OPERATORS.findIndex((f) => f === filter.operator) === -1) {
|
|
240
|
+
return false;
|
|
241
|
+
}
|
|
242
|
+
if (typeof filter.operand1 !== "string") {
|
|
243
|
+
return false;
|
|
244
|
+
}
|
|
245
|
+
if (!isValidDate(new Date(filter.operand1))) {
|
|
246
|
+
return false;
|
|
247
|
+
}
|
|
248
|
+
if (filter.operator === "b") {
|
|
249
|
+
if (typeof filter.operand2 !== "string") {
|
|
250
|
+
return false;
|
|
251
|
+
}
|
|
252
|
+
if (!isValidDate(new Date(filter.operand1))) {
|
|
253
|
+
return false;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
return true;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
class NumberFilterHelpers {
|
|
260
|
+
getComponent() {
|
|
261
|
+
return NumberFilter;
|
|
262
|
+
}
|
|
263
|
+
getDefaultFilter(fieldNumber, fixed) {
|
|
264
|
+
const field = fieldNumber;
|
|
265
|
+
const dOperator = field.defaultOperator ?? "e";
|
|
266
|
+
const defaultOperand1 = field.defaultOperand1 ?? null;
|
|
267
|
+
const defaultOperand2 = field.defaultOperand2 ?? null;
|
|
268
|
+
return {
|
|
269
|
+
id: 0,
|
|
270
|
+
fieldType: "number",
|
|
271
|
+
field,
|
|
272
|
+
fixed,
|
|
273
|
+
isSet: false,
|
|
274
|
+
operator: dOperator,
|
|
275
|
+
operand1: defaultOperand1,
|
|
276
|
+
operand2: defaultOperand2
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
getFormValue(field, getLabel, filterValue) {
|
|
280
|
+
const filterValueNumber = filterValue;
|
|
281
|
+
const operator = filterValueNumber ? filterValueNumber.operator : field.defaultOperator ?? "e";
|
|
282
|
+
const formValueOperand1 = filterValueNumber ? filterValueNumber.operand1 : null;
|
|
283
|
+
const formValueOperand2 = filterValueNumber && filterValueNumber?.operator === "b" ? filterValueNumber.operand2 : null;
|
|
284
|
+
return {
|
|
285
|
+
fieldType: "number",
|
|
286
|
+
formValueOperator: {
|
|
287
|
+
id: operator,
|
|
288
|
+
label: getLabel(getDynamicFilterDictionary(`operator_${operator}`))
|
|
289
|
+
},
|
|
290
|
+
formValueOperand1,
|
|
291
|
+
formValueOperand2
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
getFilterFromFormValue(formFilterValue) {
|
|
295
|
+
const operator = formFilterValue.formValueOperator.id;
|
|
296
|
+
const operand1 = formFilterValue.formValueOperand1 ? formFilterValue.formValueOperand1 : 0;
|
|
297
|
+
if (operator === "b") {
|
|
298
|
+
const operand2 = formFilterValue.formValueOperand2 ? formFilterValue.formValueOperand2 : 0;
|
|
299
|
+
return {
|
|
300
|
+
fieldType: "number",
|
|
301
|
+
operator,
|
|
302
|
+
operand1,
|
|
303
|
+
operand2
|
|
304
|
+
};
|
|
305
|
+
} else {
|
|
306
|
+
return {
|
|
307
|
+
fieldType: "number",
|
|
308
|
+
operator,
|
|
309
|
+
operand1
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
getLabels(filter, getLabel, _formatters, _field) {
|
|
314
|
+
let labelOperands;
|
|
315
|
+
if (filter.operator === "b") {
|
|
316
|
+
labelOperands = filter.operand1 && filter.operand2 ? `${filter.operand1} - ${filter.operand2}` : "";
|
|
317
|
+
} else {
|
|
318
|
+
labelOperands = filter.operand1 !== void 0 ? filter.operand1 + "" : "";
|
|
319
|
+
}
|
|
320
|
+
return {
|
|
321
|
+
labelField: filter.field.label ?? getLabel(filter.field.dictionaryId),
|
|
322
|
+
labelOperator: getLabel(getDynamicFilterDictionary(`operator_${filter.operator}`)),
|
|
323
|
+
labelOperands
|
|
324
|
+
};
|
|
325
|
+
}
|
|
326
|
+
getSchema(getLabel) {
|
|
327
|
+
return Yup.object({
|
|
328
|
+
formValueOperator: Yup.object().nullable().required(getLabel(`dynamic_filter.error_operator_required`)),
|
|
329
|
+
formValueOperand1: Yup.number().typeError(
|
|
330
|
+
getLabel(`dynamic_filter.error_operand_mustbe_number`)
|
|
331
|
+
),
|
|
332
|
+
formValueOperand2: Yup.mixed().when(["formValueOperator.id"], {
|
|
333
|
+
is: "b",
|
|
334
|
+
then: Yup.number().typeError(getLabel(`dynamic_filter.error_operand_mustbe_number`)).min(Yup.ref("formValueOperand1"), getLabel(`dynamic_filter.error_less_than_start`))
|
|
335
|
+
})
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
verifyFilter(filter, _field) {
|
|
339
|
+
if (typeof filter.operator !== "number") {
|
|
340
|
+
return false;
|
|
341
|
+
}
|
|
342
|
+
if (NUMBER_OPERATORS.findIndex((f) => f === filter.operator) === -1) {
|
|
343
|
+
return false;
|
|
344
|
+
}
|
|
345
|
+
if (typeof filter.operand1 !== "number") {
|
|
346
|
+
return false;
|
|
347
|
+
}
|
|
348
|
+
if (filter.operator === "b" && typeof filter.operand2 !== "number") {
|
|
349
|
+
return false;
|
|
350
|
+
}
|
|
351
|
+
return true;
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
function filterValidOperandsArraySelect(operandsArray, field) {
|
|
355
|
+
const operandsArrayFormatted = Array.isArray(operandsArray) ? operandsArray : [operandsArray];
|
|
356
|
+
const getOptionId = field?.selectOptions?.getOptionId;
|
|
357
|
+
const getOptionLabel = field?.selectOptions?.getOptionLabel;
|
|
358
|
+
return operandsArrayFormatted?.filter((operand) => {
|
|
359
|
+
return typeof operand === "object" && getOptionId?.(operand) && getOptionLabel?.(operand);
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
class SelectFilterHelpers {
|
|
363
|
+
getComponent() {
|
|
364
|
+
return SelectFilter;
|
|
365
|
+
}
|
|
366
|
+
getDefaultFilter(field, fixed) {
|
|
367
|
+
const defaultOperand = field.defaultOperandsArray;
|
|
368
|
+
const defaultFilter = {
|
|
369
|
+
id: 0,
|
|
370
|
+
fieldType: "select",
|
|
371
|
+
field,
|
|
372
|
+
fixed,
|
|
373
|
+
isSet: true,
|
|
374
|
+
operator: "in",
|
|
375
|
+
operandsArray: []
|
|
376
|
+
};
|
|
377
|
+
if (defaultOperand !== void 0 && Array.isArray(defaultOperand)) {
|
|
378
|
+
const validOperandsArray = filterValidOperandsArraySelect(defaultOperand, field);
|
|
379
|
+
defaultFilter.operandsArray = validOperandsArray || [];
|
|
380
|
+
}
|
|
381
|
+
return defaultFilter;
|
|
382
|
+
}
|
|
383
|
+
getFormValue(field, getLabel, filterValueSelect) {
|
|
384
|
+
const filterValue = filterValueSelect ? filterValueSelect : void 0;
|
|
385
|
+
const isMultiple = field?.selectOptions?.multiple ?? false;
|
|
386
|
+
const formValueOperandsArray = isMultiple ? filterValueSelect?.operandsArray : filterValueSelect?.operandsArray?.[0] || filterValueSelect?.operandsArray;
|
|
387
|
+
const operator = filterValue ? filterValue.operator : field.defaultOperator ?? "in";
|
|
388
|
+
return {
|
|
389
|
+
fieldType: "select",
|
|
390
|
+
formValueOperator: {
|
|
391
|
+
id: operator,
|
|
392
|
+
label: getLabel(getDynamicFilterDictionary(`operator_${operator}`))
|
|
393
|
+
},
|
|
394
|
+
formValueOperandsArray
|
|
395
|
+
};
|
|
396
|
+
}
|
|
397
|
+
getFilterFromFormValue(formFilterValue) {
|
|
398
|
+
const operator = formFilterValue.formValueOperator.id;
|
|
399
|
+
const operandsArray = Array.isArray(formFilterValue.formValueOperandsArray) ? formFilterValue.formValueOperandsArray : [formFilterValue.formValueOperandsArray];
|
|
400
|
+
return {
|
|
401
|
+
fieldType: "select",
|
|
402
|
+
operator,
|
|
403
|
+
operandsArray
|
|
404
|
+
};
|
|
405
|
+
}
|
|
406
|
+
getLabels(filter, getLabel, _formatters, field) {
|
|
407
|
+
const operandsArray = filter.operandsArray;
|
|
408
|
+
const labelOperands = operandsArray?.reduce?.((label, operand) => {
|
|
409
|
+
const textLabel = field.selectOptions?.getOptionLabel?.(operand) || "";
|
|
410
|
+
return label ? `${label} | ${textLabel}` : textLabel;
|
|
411
|
+
}, "")?.toString() || "";
|
|
412
|
+
return {
|
|
413
|
+
labelField: filter.field.label ?? getLabel(filter.field.dictionaryId),
|
|
414
|
+
labelOperator: getLabel(getDynamicFilterDictionary(`operator_${filter.operator}`)),
|
|
415
|
+
labelOperands
|
|
416
|
+
};
|
|
417
|
+
}
|
|
418
|
+
getSchema(getLabel) {
|
|
419
|
+
return Yup.object({
|
|
420
|
+
formValueOperator: Yup.object().nullable().required(getLabel(`dynamic_filter.error_operator_required`)),
|
|
421
|
+
formValueOperandsArray: Yup.lazy((value) => {
|
|
422
|
+
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`));
|
|
423
|
+
})
|
|
424
|
+
});
|
|
425
|
+
}
|
|
426
|
+
verifyFilter(filter, field) {
|
|
427
|
+
if (typeof filter.operator !== "string") {
|
|
428
|
+
return false;
|
|
429
|
+
}
|
|
430
|
+
if (!field) {
|
|
431
|
+
return false;
|
|
432
|
+
}
|
|
433
|
+
if (SELECT_OPERATORS.findIndex((f) => f === filter.operator) === -1) {
|
|
434
|
+
return false;
|
|
435
|
+
}
|
|
436
|
+
if (!filter.operandsArray || typeof filter.operandsArray !== "object") {
|
|
437
|
+
return false;
|
|
438
|
+
}
|
|
439
|
+
const validOperandsArray = filterValidOperandsArraySelect(
|
|
440
|
+
filter.operandsArray,
|
|
441
|
+
field
|
|
442
|
+
);
|
|
443
|
+
if (!validOperandsArray || validOperandsArray?.length === 0) {
|
|
444
|
+
return false;
|
|
445
|
+
}
|
|
446
|
+
return true;
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
function getPurgedInitialFiltersApplied(fields, initialFilters, getFieldByName) {
|
|
450
|
+
const newFilters = [];
|
|
451
|
+
const fixedFields = [];
|
|
452
|
+
for (let index = 0; index < initialFilters.length; index++) {
|
|
453
|
+
try {
|
|
454
|
+
const initialFilter = initialFilters[index];
|
|
455
|
+
const field = getFieldByName(initialFilter.name);
|
|
456
|
+
const filter = {
|
|
457
|
+
id: 0,
|
|
458
|
+
isSet: true,
|
|
459
|
+
fixed: false,
|
|
460
|
+
field,
|
|
461
|
+
fieldType: field.type,
|
|
462
|
+
operator: initialFilters[index].operator,
|
|
463
|
+
operand1: initialFilters[index].operand1,
|
|
464
|
+
operand2: initialFilters[index].operand2,
|
|
465
|
+
operandsArray: initialFilters[index].operandsArray
|
|
466
|
+
};
|
|
467
|
+
if (!field)
|
|
468
|
+
continue;
|
|
469
|
+
const canAddField = fieldFactory(field.type).verifyFilter(initialFilter, field);
|
|
470
|
+
if (canAddField) {
|
|
471
|
+
if (filter.fieldType === "datetime") {
|
|
472
|
+
filter.operand1 = new Date(filter.operand1 + "");
|
|
473
|
+
filter.operand2 = new Date(filter.operand2 + "");
|
|
474
|
+
}
|
|
475
|
+
if (field.presence === "fixed") {
|
|
476
|
+
if (fixedFields.findIndex((f) => f === field.name) === -1) {
|
|
477
|
+
filter.fixed = true;
|
|
478
|
+
fixedFields.push(field.name);
|
|
479
|
+
} else {
|
|
480
|
+
filter.fixed = false;
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
filter.isSet = true;
|
|
484
|
+
filter.id = newFilters.length + 1;
|
|
485
|
+
newFilters.push(filter);
|
|
486
|
+
}
|
|
487
|
+
} catch (error) {
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
for (let index = 0; index < fields.length; index++) {
|
|
491
|
+
const field = fields[index];
|
|
492
|
+
if (field.presence === "initialized" || field.presence === "fixed") {
|
|
493
|
+
if (!initialFilters.find((f) => f.name === field.name)) {
|
|
494
|
+
const newFilter = fieldFactory(field.type).getDefaultFilter(
|
|
495
|
+
field,
|
|
496
|
+
field.presence === "fixed"
|
|
497
|
+
);
|
|
498
|
+
newFilter.id = newFilters.length + 1;
|
|
499
|
+
newFilters.push(newFilter);
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
return newFilters;
|
|
504
|
+
}
|
|
505
|
+
const formatToRawFilter = (appliedFilters) => {
|
|
506
|
+
return appliedFilters.map((af) => {
|
|
507
|
+
let oa = void 0;
|
|
508
|
+
if (af.field.type === "select" && af.operandsArray) {
|
|
509
|
+
oa = Array.isArray(af.operandsArray) ? af.operandsArray.map(af.field.selectOptions.getOptionId) : [af.field.selectOptions.getOptionId(af.operandsArray)];
|
|
510
|
+
}
|
|
511
|
+
return {
|
|
512
|
+
n: af.field.name,
|
|
513
|
+
o: af.operator,
|
|
514
|
+
o1: af.operand1,
|
|
515
|
+
o2: af.operator === "b" ? af.operand2 : void 0,
|
|
516
|
+
oa
|
|
517
|
+
};
|
|
518
|
+
});
|
|
519
|
+
};
|
|
520
|
+
function formatToInitialFilters(appliedFilters) {
|
|
521
|
+
return appliedFilters.map((appliedFilter) => {
|
|
522
|
+
const ret = {
|
|
523
|
+
name: appliedFilter.field.name,
|
|
524
|
+
operator: appliedFilter.operator,
|
|
525
|
+
operand1: appliedFilter.operand1,
|
|
526
|
+
operand2: appliedFilter.operator === "b" ? appliedFilter.operand2 : void 0
|
|
527
|
+
};
|
|
528
|
+
if (appliedFilter.fieldType === "datetime") {
|
|
529
|
+
ret.operand1 = appliedFilter.operand1.toISOString();
|
|
530
|
+
ret.operand2 = appliedFilter.operator === "b" ? appliedFilter.operand2.toISOString() : void 0;
|
|
531
|
+
}
|
|
532
|
+
if (appliedFilter.fieldType === "select") {
|
|
533
|
+
const validOperandsArray = filterValidOperandsArraySelect(
|
|
534
|
+
appliedFilter.operandsArray,
|
|
535
|
+
appliedFilter.field
|
|
536
|
+
);
|
|
537
|
+
if (validOperandsArray && validOperandsArray?.length > 0) {
|
|
538
|
+
ret.operandsArray = validOperandsArray;
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
if (ret.operand2 === void 0) {
|
|
542
|
+
delete ret.operand2;
|
|
543
|
+
}
|
|
544
|
+
return ret;
|
|
545
|
+
});
|
|
546
|
+
}
|
|
547
|
+
export {
|
|
548
|
+
BooleanFilterHelpers as B,
|
|
549
|
+
DateTimeFilterHelpers as D,
|
|
550
|
+
NumberFilterHelpers as N,
|
|
551
|
+
StringFilterHelpers as S,
|
|
552
|
+
formatToRawFilter as a,
|
|
553
|
+
SelectFilterHelpers as b,
|
|
554
|
+
formatToInitialFilters as f,
|
|
555
|
+
getPurgedInitialFiltersApplied as g
|
|
556
|
+
};
|