@teselagen/ui 0.7.32 → 0.7.33-beta.1
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/DataTable/utils/filterLocalEntitiesToHasura.d.ts +5 -0
- package/DataTable/utils/initializeHasuraWhereAndFilter.d.ts +2 -0
- package/DataTable/utils/queryParams.d.ts +8 -12
- package/DataTable/utils/simplifyHasuraWhere.d.ts +1 -0
- package/DataTable/utils/tableQueryParamsToHasuraClauses.d.ts +14 -0
- package/{src/DataTable/FilterAndSortMenu.js → FilterAndSortMenu.js} +27 -30
- package/filterLocalEntitiesToHasura.js +216 -0
- package/index.cjs.js +695 -967
- package/index.d.ts +1 -0
- package/index.es.js +695 -967
- package/initializeHasuraWhereAndFilter.js +27 -0
- package/{src/utils/isBeingCalledExcessively.js → isBeingCalledExcessively.js} +0 -1
- package/package.json +1 -1
- package/queryParams.js +336 -0
- package/simplifyHasuraWhere.js +80 -0
- package/tableQueryParamsToHasuraClauses.js +113 -0
- package/{src/DataTable/utils/withTableParams.js → withTableParams.js} +1 -14
- package/src/AdvancedOptions.spec.js +0 -26
- package/src/AsyncValidateFieldSpinner/index.js +0 -12
- package/src/BlueprintError/index.js +0 -14
- package/src/BounceLoader/index.js +0 -16
- package/src/BounceLoader/style.css +0 -45
- package/src/CollapsibleCard/index.js +0 -68
- package/src/CollapsibleCard/style.css +0 -23
- package/src/DNALoader/index.js +0 -20
- package/src/DNALoader/style.css +0 -251
- package/src/DataTable/index.js +0 -3213
- package/src/DataTable/style.css +0 -608
- package/src/DataTable/utils/index.js +0 -55
- package/src/DataTable/utils/queryParams.js +0 -1058
- package/src/DialogFooter/index.js +0 -86
- package/src/DialogFooter/style.css +0 -9
- package/src/FormComponents/index.js +0 -1266
- package/src/FormComponents/style.css +0 -275
- package/src/FormComponents/utils.js +0 -6
- package/src/HotkeysDialog/index.js +0 -79
- package/src/HotkeysDialog/style.css +0 -54
- package/src/InfoHelper/index.js +0 -78
- package/src/InfoHelper/style.css +0 -7
- package/src/IntentText/index.js +0 -18
- package/src/Loading/index.js +0 -70
- package/src/Loading/style.css +0 -4
- package/src/MenuBar/index.js +0 -423
- package/src/MenuBar/style.css +0 -45
- package/src/PromptUnsavedChanges/index.js +0 -38
- package/src/ResizableDraggableDialog/index.js +0 -141
- package/src/ResizableDraggableDialog/style.css +0 -42
- package/src/ScrollToTop/index.js +0 -72
- package/src/TagSelect/index.js +0 -69
- package/src/TagSelect/style.css +0 -13
- package/src/TgHtmlSelect/index.js +0 -20
- package/src/TgSelect/index.js +0 -537
- package/src/TgSelect/style.css +0 -61
- package/src/TgSuggest/index.js +0 -124
- package/src/Timeline/index.js +0 -15
- package/src/enhancers/withDialog/index.js +0 -196
- package/src/index.js +0 -87
- package/src/showConfirmationDialog/index.js +0 -148
- package/src/style.css +0 -265
- /package/{src/AdvancedOptions.js → AdvancedOptions.js} +0 -0
- /package/{src/AssignDefaultsModeContext.js → AssignDefaultsModeContext.js} +0 -0
- /package/{src/DataTable/CellDragHandle.js → CellDragHandle.js} +0 -0
- /package/{src/DataTable/ColumnFilterMenu.js → ColumnFilterMenu.js} +0 -0
- /package/{src/DataTable/Columns.js → Columns.js} +0 -0
- /package/{src/DataTable/DisabledLoadingComponent.js → DisabledLoadingComponent.js} +0 -0
- /package/{src/DataTable/DisplayOptions.js → DisplayOptions.js} +0 -0
- /package/{src/DropdownButton.js → DropdownButton.js} +0 -0
- /package/{src/DataTable/DropdownCell.js → DropdownCell.js} +0 -0
- /package/{src/DataTable/EditableCell.js → EditableCell.js} +0 -0
- /package/{src/FillWindow.css → FillWindow.css} +0 -0
- /package/{src/FillWindow.js → FillWindow.js} +0 -0
- /package/{src/FormComponents/FormSeparator.js → FormSeparator.js} +0 -0
- /package/{src/FormComponents/LoadingDots.js → LoadingDots.js} +0 -0
- /package/{src/MatchHeaders.js → MatchHeaders.js} +0 -0
- /package/{src/DataTable/PagingTool.js → PagingTool.js} +0 -0
- /package/{src/DataTable/RenderCell.js → RenderCell.js} +0 -0
- /package/{src/DataTable/SearchBar.js → SearchBar.js} +0 -0
- /package/{src/SimpleStepViz.js → SimpleStepViz.js} +0 -0
- /package/{src/DataTable/SortableColumns.js → SortableColumns.js} +0 -0
- /package/{src/DataTable/TableFormTrackerContext.js → TableFormTrackerContext.js} +0 -0
- /package/{src/Tag.js → Tag.js} +0 -0
- /package/{src/DataTable/ThComponent.js → ThComponent.js} +0 -0
- /package/{src/Timeline/TimelineEvent.js → TimelineEvent.js} +0 -0
- /package/{src/UploadCsvWizard.css → UploadCsvWizard.css} +0 -0
- /package/{src/UploadCsvWizard.js → UploadCsvWizard.js} +0 -0
- /package/{src/FormComponents/Uploader.js → Uploader.js} +0 -0
- /package/{src/utils/adHoc.js → adHoc.js} +0 -0
- /package/{src/autoTooltip.js → autoTooltip.js} +0 -0
- /package/{src/utils/basicHandleActionsWithFullState.js → basicHandleActionsWithFullState.js} +0 -0
- /package/{src/utils/browserUtils.js → browserUtils.js} +0 -0
- /package/{src/utils/combineReducersWithFullState.js → combineReducersWithFullState.js} +0 -0
- /package/{src/utils/commandControls.js → commandControls.js} +0 -0
- /package/{src/utils/commandUtils.js → commandUtils.js} +0 -0
- /package/{src/constants.js → constants.js} +0 -0
- /package/{src/DataTable/utils/convertSchema.js → convertSchema.js} +0 -0
- /package/{src/customIcons.js → customIcons.js} +0 -0
- /package/{src/DataTable/dataTableEnhancer.js → dataTableEnhancer.js} +0 -0
- /package/{src/DataTable/defaultFormatters.js → defaultFormatters.js} +0 -0
- /package/{src/DataTable/defaultValidators.js → defaultValidators.js} +0 -0
- /package/{src/utils/determineBlackOrWhiteTextColor.js → determineBlackOrWhiteTextColor.js} +0 -0
- /package/{src/DataTable/editCellHelper.js → editCellHelper.js} +0 -0
- /package/{src/DataTable/utils/formatPasteData.js → formatPasteData.js} +0 -0
- /package/{src/DataTable/utils/getAllRows.js → getAllRows.js} +0 -0
- /package/{src/DataTable/utils/getCellCopyText.js → getCellCopyText.js} +0 -0
- /package/{src/DataTable/utils/getCellInfo.js → getCellInfo.js} +0 -0
- /package/{src/DataTable/getCellVal.js → getCellVal.js} +0 -0
- /package/{src/utils/getDayjsFormatter.js → getDayjsFormatter.js} +0 -0
- /package/{src/DataTable/utils/getFieldPathToField.js → getFieldPathToField.js} +0 -0
- /package/{src/DataTable/utils/getIdOrCodeOrIndex.js → getIdOrCodeOrIndex.js} +0 -0
- /package/{src/DataTable/utils/getLastSelectedEntity.js → getLastSelectedEntity.js} +0 -0
- /package/{src/DataTable/utils/getNewEntToSelect.js → getNewEntToSelect.js} +0 -0
- /package/{src/FormComponents/getNewName.js → getNewName.js} +0 -0
- /package/{src/DataTable/utils/getRowCopyText.js → getRowCopyText.js} +0 -0
- /package/{src/DataTable/utils/getTableConfigFromStorage.js → getTableConfigFromStorage.js} +0 -0
- /package/{src/utils/getTextFromEl.js → getTextFromEl.js} +0 -0
- /package/{src/DataTable/getVals.js → getVals.js} +0 -0
- /package/{src/DataTable/utils/handleCopyColumn.js → handleCopyColumn.js} +0 -0
- /package/{src/DataTable/utils/handleCopyHelper.js → handleCopyHelper.js} +0 -0
- /package/{src/DataTable/utils/handleCopyRows.js → handleCopyRows.js} +0 -0
- /package/{src/DataTable/utils/handleCopyTable.js → handleCopyTable.js} +0 -0
- /package/{src/utils/handlerHelpers.js → handlerHelpers.js} +0 -0
- /package/{src/utils/hotkeyUtils.js → hotkeyUtils.js} +0 -0
- /package/{src/utils/hooks/index.js → index.js} +0 -0
- /package/{src/DataTable/utils/isBottomRightCornerOfRectangle.js → isBottomRightCornerOfRectangle.js} +0 -0
- /package/{src/DataTable/utils/isEntityClean.js → isEntityClean.js} +0 -0
- /package/{src/DataTable/isTruthy.js → isTruthy.js} +0 -0
- /package/{src/DataTable/isValueEmpty.js → isValueEmpty.js} +0 -0
- /package/{src/FormComponents/itemUpload.js → itemUpload.js} +0 -0
- /package/{src/utils/menuUtils.js → menuUtils.js} +0 -0
- /package/{src/utils/popoverOverflowModifiers.js → popoverOverflowModifiers.js} +0 -0
- /package/{src/DataTable/utils/primarySelectedValue.js → primarySelectedValue.js} +0 -0
- /package/{src/utils/pureNoFunc.js → pureNoFunc.js} +0 -0
- /package/{src/DataTable/utils/removeCleanRows.js → removeCleanRows.js} +0 -0
- /package/{src/utils/renderOnDoc.js → renderOnDoc.js} +0 -0
- /package/{src/rerenderOnWindowResize.js → rerenderOnWindowResize.js} +0 -0
- /package/{src/DataTable/utils/rowClick.js → rowClick.js} +0 -0
- /package/{src/DataTable/utils/selection.js → selection.js} +0 -0
- /package/{src/showAppSpinner.js → showAppSpinner.js} +0 -0
- /package/{src/showDialogOnDocBody.js → showDialogOnDocBody.js} +0 -0
- /package/{src/utils/showProgressToast.js → showProgressToast.js} +0 -0
- /package/{src/FormComponents/sortify.js → sortify.js} +0 -0
- /package/{src/Timeline/style.css → style.css} +0 -0
- /package/{src/utils/tagUtils.js → tagUtils.js} +0 -0
- /package/{src/utils/tgFormValues.js → tgFormValues.js} +0 -0
- /package/{src/enhancers/withDialog/tg_modalState.js → tg_modalState.js} +0 -0
- /package/{src/throwFormError.js → throwFormError.js} +0 -0
- /package/{src/toastr.js → toastr.js} +0 -0
- /package/{src/FormComponents/tryToMatchSchemas.js → tryToMatchSchemas.js} +0 -0
- /package/{src/typeToCommonType.js → typeToCommonType.js} +0 -0
- /package/{src/utils/hooks/useDeepEqualMemo.js → useDeepEqualMemo.js} +0 -0
- /package/{src/useDialog.js → useDialog.js} +0 -0
- /package/{src/utils/hooks/useStableReference.js → useStableReference.js} +0 -0
- /package/{src/DataTable/utils/useTableEntities.js → useTableEntities.js} +0 -0
- /package/{src/utils/useTraceUpdate.js → useTraceUpdate.js} +0 -0
- /package/{src/DataTable/utils/utils.js → utils.js} +0 -0
- /package/{src/DataTable/validateTableWideErrors.js → validateTableWideErrors.js} +0 -0
- /package/{src/DataTable/viewColumn.js → viewColumn.js} +0 -0
- /package/{src/enhancers/withField.js → withField.js} +0 -0
- /package/{src/enhancers/withFields.js → withFields.js} +0 -0
- /package/{src/enhancers/withLocalStorage.js → withLocalStorage.js} +0 -0
- /package/{src/utils/withSelectTableRecords.js → withSelectTableRecords.js} +0 -0
- /package/{src/DataTable/utils/withSelectedEntities.js → withSelectedEntities.js} +0 -0
- /package/{src/utils/withStore.js → withStore.js} +0 -0
- /package/{src/wrapDialog.js → wrapDialog.js} +0 -0
|
@@ -25,31 +25,27 @@ export function makeDataTableHandlers({ setNewParams, defaults, onlyOneFilter }:
|
|
|
25
25
|
setOrder: (order: any, isRemove: any, shiftHeld: any) => any;
|
|
26
26
|
setNewParams: any;
|
|
27
27
|
};
|
|
28
|
-
export function getQueryParams({ currentParams,
|
|
28
|
+
export function getQueryParams({ currentParams, defaults, schema, isInfinite, entities, isLocalCall, additionalFilter, doNotCoercePageSize, ownProps }: {
|
|
29
29
|
currentParams: any;
|
|
30
|
-
urlConnected: any;
|
|
31
30
|
defaults: any;
|
|
32
31
|
schema: any;
|
|
33
32
|
isInfinite: any;
|
|
34
33
|
entities: any;
|
|
35
34
|
isLocalCall: any;
|
|
36
35
|
additionalFilter: any;
|
|
37
|
-
additionalOrFilter: any;
|
|
38
36
|
doNotCoercePageSize: any;
|
|
39
|
-
noOrderError: any;
|
|
40
|
-
isCodeModel: any;
|
|
41
37
|
ownProps: any;
|
|
42
38
|
}): {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
filters: any;
|
|
47
|
-
searchTerm: any;
|
|
39
|
+
entities: any[];
|
|
40
|
+
entitiesAcrossPages: any[];
|
|
41
|
+
entityCount: number;
|
|
48
42
|
} | {
|
|
49
43
|
variables: {
|
|
50
|
-
|
|
44
|
+
where: {};
|
|
45
|
+
order_by: {};
|
|
46
|
+
limit: any;
|
|
47
|
+
offset: number;
|
|
51
48
|
};
|
|
52
|
-
errorParsingUrlString: unknown;
|
|
53
49
|
page: any;
|
|
54
50
|
pageSize: any;
|
|
55
51
|
order: any;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function simplifyHasuraWhere(whereClause: any): {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export function tableQueryParamsToHasuraClauses({ page, pageSize, searchTerm, filters, order, schema, additionalFilter }: {
|
|
2
|
+
page: any;
|
|
3
|
+
pageSize: any;
|
|
4
|
+
searchTerm: any;
|
|
5
|
+
filters: any;
|
|
6
|
+
order: any;
|
|
7
|
+
schema: any;
|
|
8
|
+
additionalFilter: any;
|
|
9
|
+
}): {
|
|
10
|
+
where: {};
|
|
11
|
+
order_by: {};
|
|
12
|
+
limit: any;
|
|
13
|
+
offset: number;
|
|
14
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useState } from "react";
|
|
2
2
|
import { DateInput, DateRangeInput } from "@blueprintjs/datetime";
|
|
3
|
-
import { camelCase } from "lodash-es";
|
|
3
|
+
import { camelCase, startCase } from "lodash-es";
|
|
4
4
|
import classNames from "classnames";
|
|
5
5
|
import {
|
|
6
6
|
Menu,
|
|
@@ -349,43 +349,40 @@ function getFilterMenuItems(dataType) {
|
|
|
349
349
|
let filterMenuItems = [];
|
|
350
350
|
if (dataType === "string") {
|
|
351
351
|
filterMenuItems = [
|
|
352
|
-
"
|
|
353
|
-
"
|
|
354
|
-
"
|
|
355
|
-
"
|
|
356
|
-
"
|
|
357
|
-
"
|
|
358
|
-
"
|
|
359
|
-
"
|
|
360
|
-
"
|
|
361
|
-
"
|
|
352
|
+
"contains",
|
|
353
|
+
"notContains",
|
|
354
|
+
"startsWith",
|
|
355
|
+
"endsWith",
|
|
356
|
+
"isExactly",
|
|
357
|
+
"regex",
|
|
358
|
+
"inList",
|
|
359
|
+
"notInList",
|
|
360
|
+
"isEmpty",
|
|
361
|
+
"notEmpty"
|
|
362
362
|
];
|
|
363
363
|
} else if (dataType === "lookup") {
|
|
364
364
|
filterMenuItems = [
|
|
365
|
-
"
|
|
366
|
-
"
|
|
367
|
-
"
|
|
368
|
-
"
|
|
369
|
-
"
|
|
370
|
-
"
|
|
365
|
+
"contains",
|
|
366
|
+
"notContains",
|
|
367
|
+
"startsWith",
|
|
368
|
+
"endsWith",
|
|
369
|
+
"isExactly",
|
|
370
|
+
"regex"
|
|
371
371
|
];
|
|
372
372
|
} else if (dataType === "boolean") {
|
|
373
|
-
filterMenuItems = ["
|
|
373
|
+
filterMenuItems = ["true", "false"];
|
|
374
374
|
} else if (dataType === "number" || dataType === "integer") {
|
|
375
|
-
// else if (dataType === "lookup") {
|
|
376
|
-
// filterMenuItems = ["None"];
|
|
377
|
-
// }
|
|
378
375
|
filterMenuItems = [
|
|
379
|
-
"
|
|
380
|
-
"
|
|
381
|
-
"
|
|
382
|
-
"
|
|
383
|
-
"
|
|
384
|
-
"
|
|
385
|
-
"
|
|
376
|
+
"greaterThan",
|
|
377
|
+
"lessThan",
|
|
378
|
+
"inRange",
|
|
379
|
+
"outsideRange",
|
|
380
|
+
"equalTo",
|
|
381
|
+
"inList",
|
|
382
|
+
"notInList"
|
|
386
383
|
];
|
|
387
384
|
} else if (dataType === "timestamp") {
|
|
388
|
-
filterMenuItems = ["
|
|
385
|
+
filterMenuItems = ["isBetween", "notBetween", "isBefore", "isAfter"];
|
|
389
386
|
}
|
|
390
|
-
return filterMenuItems;
|
|
387
|
+
return filterMenuItems.map(item => startCase(item));
|
|
391
388
|
}
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isEmpty,
|
|
3
|
+
every,
|
|
4
|
+
some,
|
|
5
|
+
isEqual,
|
|
6
|
+
isString,
|
|
7
|
+
isNull,
|
|
8
|
+
isArray,
|
|
9
|
+
includes,
|
|
10
|
+
isObject,
|
|
11
|
+
has,
|
|
12
|
+
orderBy
|
|
13
|
+
} from "lodash-es";
|
|
14
|
+
|
|
15
|
+
export function filterLocalEntitiesToHasura(
|
|
16
|
+
records,
|
|
17
|
+
{ where, order_by, limit, offset, isInfinite } = {}
|
|
18
|
+
) {
|
|
19
|
+
let filteredRecords = [...records];
|
|
20
|
+
|
|
21
|
+
// Apply where clause if it exists
|
|
22
|
+
if (where) {
|
|
23
|
+
filteredRecords = applyWhereClause(filteredRecords, where);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Apply order_by if it exists
|
|
27
|
+
if (order_by) {
|
|
28
|
+
filteredRecords = applyOrderBy(filteredRecords, order_by);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Store the complete filtered and ordered records for pagination info
|
|
32
|
+
const allFilteredRecords = [...filteredRecords];
|
|
33
|
+
|
|
34
|
+
// Apply limit and offset
|
|
35
|
+
if (!isInfinite && offset !== undefined) {
|
|
36
|
+
filteredRecords = filteredRecords.slice(offset);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (!isInfinite && limit !== undefined) {
|
|
40
|
+
filteredRecords = filteredRecords.slice(0, limit);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// For consistency, always return an object with entities, entitiesAcrossPages, and entityCount
|
|
44
|
+
return {
|
|
45
|
+
entities: filteredRecords,
|
|
46
|
+
entitiesAcrossPages: allFilteredRecords,
|
|
47
|
+
entityCount: allFilteredRecords.length
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function applyWhereClause(records, where) {
|
|
52
|
+
function applyFilter(record, filter) {
|
|
53
|
+
if (isEmpty(filter)) {
|
|
54
|
+
return true; // No filter, all records pass
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
for (const key in filter) {
|
|
58
|
+
if (key === "_and") {
|
|
59
|
+
if (!every(filter[key], subFilter => applyFilter(record, subFilter))) {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
} else if (key === "_or") {
|
|
63
|
+
if (!some(filter[key], subFilter => applyFilter(record, subFilter))) {
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
} else if (key === "_not") {
|
|
67
|
+
if (applyFilter(record, filter[key])) {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
} else {
|
|
71
|
+
const value = record[key];
|
|
72
|
+
const conditions = filter[key];
|
|
73
|
+
|
|
74
|
+
for (const operator in conditions) {
|
|
75
|
+
const conditionValue = conditions[operator];
|
|
76
|
+
|
|
77
|
+
// Handle range conditions (_gt/_lt or _gte/_lte combinations)
|
|
78
|
+
if (operator === "_gt" && conditions._lt) {
|
|
79
|
+
if (!(value > conditionValue && value < conditions._lt))
|
|
80
|
+
return false;
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
if (operator === "_gte" && conditions._lte) {
|
|
84
|
+
if (!(value >= conditionValue && value <= conditions._lte))
|
|
85
|
+
return false;
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
switch (operator) {
|
|
90
|
+
case "_eq":
|
|
91
|
+
if (!isEqual(value, conditionValue)) return false;
|
|
92
|
+
break;
|
|
93
|
+
case "_neq":
|
|
94
|
+
if (isEqual(value, conditionValue)) return false;
|
|
95
|
+
break;
|
|
96
|
+
case "_gt":
|
|
97
|
+
if (!(value > conditionValue)) return false;
|
|
98
|
+
break;
|
|
99
|
+
case "_gte":
|
|
100
|
+
if (!(value >= conditionValue)) return false;
|
|
101
|
+
break;
|
|
102
|
+
case "_lt":
|
|
103
|
+
if (!(value < conditionValue)) return false;
|
|
104
|
+
break;
|
|
105
|
+
case "_lte":
|
|
106
|
+
if (!(value <= conditionValue)) return false;
|
|
107
|
+
break;
|
|
108
|
+
case "_like":
|
|
109
|
+
if (
|
|
110
|
+
!isString(value) ||
|
|
111
|
+
!new RegExp(conditionValue.replace(/%/g, ".*")).test(value)
|
|
112
|
+
)
|
|
113
|
+
return false;
|
|
114
|
+
break;
|
|
115
|
+
case "_ilike":
|
|
116
|
+
if (
|
|
117
|
+
!isString(value) ||
|
|
118
|
+
!new RegExp(conditionValue.replace(/%/g, ".*"), "i").test(value)
|
|
119
|
+
)
|
|
120
|
+
return false;
|
|
121
|
+
break;
|
|
122
|
+
case "_nlike":
|
|
123
|
+
if (
|
|
124
|
+
!isString(value) ||
|
|
125
|
+
new RegExp(conditionValue.replace(/%/g, ".*")).test(value)
|
|
126
|
+
)
|
|
127
|
+
return false;
|
|
128
|
+
break;
|
|
129
|
+
case "_nilike":
|
|
130
|
+
if (
|
|
131
|
+
!isString(value) ||
|
|
132
|
+
new RegExp(conditionValue.replace(/%/g, ".*"), "i").test(value)
|
|
133
|
+
)
|
|
134
|
+
return false;
|
|
135
|
+
break;
|
|
136
|
+
case "_starts_with":
|
|
137
|
+
if (!isString(value) || !value.startsWith(conditionValue))
|
|
138
|
+
return false;
|
|
139
|
+
break;
|
|
140
|
+
case "_ends_with":
|
|
141
|
+
if (!isString(value) || !value.endsWith(conditionValue))
|
|
142
|
+
return false;
|
|
143
|
+
break;
|
|
144
|
+
case "_is_null":
|
|
145
|
+
if (
|
|
146
|
+
(conditionValue && !isNull(value)) ||
|
|
147
|
+
(!conditionValue && isNull(value))
|
|
148
|
+
)
|
|
149
|
+
return false;
|
|
150
|
+
break;
|
|
151
|
+
case "_contains":
|
|
152
|
+
if (
|
|
153
|
+
!isArray(value) ||
|
|
154
|
+
!every(conditionValue, item => includes(value, item))
|
|
155
|
+
)
|
|
156
|
+
return false;
|
|
157
|
+
break;
|
|
158
|
+
case "_contained_in":
|
|
159
|
+
if (
|
|
160
|
+
!isArray(value) ||
|
|
161
|
+
!every(value, item => includes(conditionValue, item))
|
|
162
|
+
)
|
|
163
|
+
return false;
|
|
164
|
+
break;
|
|
165
|
+
case "_has_key":
|
|
166
|
+
if (!isObject(value) || !has(value, conditionValue)) return false;
|
|
167
|
+
break;
|
|
168
|
+
case "_has_keys_any":
|
|
169
|
+
if (
|
|
170
|
+
!isObject(value) ||
|
|
171
|
+
!some(conditionValue, item => has(value, item))
|
|
172
|
+
)
|
|
173
|
+
return false;
|
|
174
|
+
break;
|
|
175
|
+
case "_has_keys_all":
|
|
176
|
+
if (
|
|
177
|
+
!isObject(value) ||
|
|
178
|
+
!every(conditionValue, item => has(value, item))
|
|
179
|
+
)
|
|
180
|
+
return false;
|
|
181
|
+
break;
|
|
182
|
+
case "_similar":
|
|
183
|
+
if (
|
|
184
|
+
!isString(value) ||
|
|
185
|
+
!new RegExp(conditionValue.replace(/%/g, ".*")).test(value)
|
|
186
|
+
)
|
|
187
|
+
return false;
|
|
188
|
+
break;
|
|
189
|
+
default:
|
|
190
|
+
if (operator.startsWith("_")) {
|
|
191
|
+
console.warn(`Unsupported operator: ${operator}`);
|
|
192
|
+
return false;
|
|
193
|
+
} else {
|
|
194
|
+
console.warn(`Unsupported operator: ${operator}`);
|
|
195
|
+
return false;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
return true;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
return records.filter(record => applyFilter(record, where));
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
function applyOrderBy(records, order_by) {
|
|
209
|
+
const keys = Object.keys(order_by);
|
|
210
|
+
if (keys.length > 0) {
|
|
211
|
+
const field = keys[0];
|
|
212
|
+
const direction = order_by[field] === "asc" ? "asc" : "desc";
|
|
213
|
+
return orderBy(records, [field], [direction]);
|
|
214
|
+
}
|
|
215
|
+
return records;
|
|
216
|
+
}
|