@teselagen/ui 0.7.33-beta.4 → 0.7.33-beta.5
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/queryParams.d.ts +3 -8
- package/DataTable/utils/tableQueryParamsToHasuraClauses.d.ts +12 -0
- package/index.cjs.js +161 -27
- package/index.es.js +161 -27
- package/package.json +1 -1
- package/src/DataTable/Columns.js +1 -1
- package/src/DataTable/DisplayOptions.js +1 -1
- package/src/DataTable/index.js +1 -1
- package/src/DataTable/utils/filterLocalEntitiesToHasura.js +6 -0
- package/src/DataTable/utils/filterLocalEntitiesToHasura.test.js +69 -46
- package/src/DataTable/utils/initializeHasuraWhereAndFilter.js +0 -1
- package/src/DataTable/utils/queryParams.js +32 -21
- package/src/DataTable/utils/tableQueryParamsToHasuraClauses.js +154 -17
- package/src/DataTable/utils/tableQueryParamsToHasuraClauses.test.js +8 -21
- package/src/DataTable/utils/withTableParams.js +2 -2
- package/DataTable/utils/simplifyHasuraWhere.d.ts +0 -1
- package/src/DataTable/utils/simplifyHasuraWhere.js +0 -80
- package/src/DataTable/utils/simplifyHasuraWhere.test.js +0 -73
|
@@ -3,12 +3,6 @@ export function getMergedOpts(topLevel?: {}, instanceLevel?: {}): {
|
|
|
3
3
|
defaults: any;
|
|
4
4
|
formName: string;
|
|
5
5
|
};
|
|
6
|
-
/**
|
|
7
|
-
*
|
|
8
|
-
* @param {object} field
|
|
9
|
-
* @returns the camelCase display name of the field, to be used for filters, sorting, etc
|
|
10
|
-
*/
|
|
11
|
-
export function getCCDisplayName(field: object): string;
|
|
12
6
|
export function getCurrentParamsFromUrl(location: any, isSimple: any): any;
|
|
13
7
|
export function setCurrentParamsOnUrl(newParams: any, replace: any, isSimple: any): void;
|
|
14
8
|
export function makeDataTableHandlers({ setNewParams, defaults, onlyOneFilter }: {
|
|
@@ -25,7 +19,7 @@ export function makeDataTableHandlers({ setNewParams, defaults, onlyOneFilter }:
|
|
|
25
19
|
setOrder: (order: any, isRemove: any, shiftHeld: any) => any;
|
|
26
20
|
setNewParams: any;
|
|
27
21
|
};
|
|
28
|
-
export function getQueryParams({ currentParams, defaults, schema, isInfinite, entities, isLocalCall, additionalFilter, doNotCoercePageSize, ownProps }: {
|
|
22
|
+
export function getQueryParams({ currentParams, defaults, schema, isInfinite, entities, isLocalCall, additionalFilter, doNotCoercePageSize, noOrderError, ownProps }: {
|
|
29
23
|
currentParams: any;
|
|
30
24
|
defaults: any;
|
|
31
25
|
schema: any;
|
|
@@ -34,6 +28,7 @@ export function getQueryParams({ currentParams, defaults, schema, isInfinite, en
|
|
|
34
28
|
isLocalCall: any;
|
|
35
29
|
additionalFilter: any;
|
|
36
30
|
doNotCoercePageSize: any;
|
|
31
|
+
noOrderError: any;
|
|
37
32
|
ownProps: any;
|
|
38
33
|
}): {
|
|
39
34
|
entities: any[];
|
|
@@ -48,7 +43,7 @@ export function getQueryParams({ currentParams, defaults, schema, isInfinite, en
|
|
|
48
43
|
};
|
|
49
44
|
page: any;
|
|
50
45
|
pageSize: any;
|
|
51
|
-
order: any;
|
|
46
|
+
order: any[];
|
|
52
47
|
filters: any;
|
|
53
48
|
searchTerm: any;
|
|
54
49
|
};
|
|
@@ -12,3 +12,15 @@ export function tableQueryParamsToHasuraClauses({ page, pageSize, searchTerm, fi
|
|
|
12
12
|
limit: any;
|
|
13
13
|
offset: number;
|
|
14
14
|
};
|
|
15
|
+
/**
|
|
16
|
+
* Takes a schema and returns an object with the fields mapped by their camelCased display name.
|
|
17
|
+
* If the displayName is not set or is a jsx element, the path is used instead.
|
|
18
|
+
* The same conversion must be done when using the result of this method
|
|
19
|
+
*/
|
|
20
|
+
export function getFieldsMappedByCCDisplayName(schema: any): any;
|
|
21
|
+
/**
|
|
22
|
+
*
|
|
23
|
+
* @param {object} field
|
|
24
|
+
* @returns the camelCase display name of the field, to be used for filters, sorting, etc
|
|
25
|
+
*/
|
|
26
|
+
export function getCCDisplayName(field: object): string;
|
package/index.cjs.js
CHANGED
|
@@ -19402,6 +19402,7 @@ function tableQueryParamsToHasuraClauses({
|
|
|
19402
19402
|
// Add schema as a parameter
|
|
19403
19403
|
additionalFilter
|
|
19404
19404
|
}) {
|
|
19405
|
+
const ccFields = getFieldsMappedByCCDisplayName(schema);
|
|
19405
19406
|
let where = {};
|
|
19406
19407
|
const order_by = {};
|
|
19407
19408
|
const limit = pageSize || 25;
|
|
@@ -19449,28 +19450,124 @@ function tableQueryParamsToHasuraClauses({
|
|
|
19449
19450
|
}
|
|
19450
19451
|
if (filters && filters.length > 0) {
|
|
19451
19452
|
const filterClauses = filters.map((filter2) => {
|
|
19452
|
-
|
|
19453
|
+
let { selectedFilter, filterOn, filterValue } = filter2;
|
|
19454
|
+
const fieldSchema = ccFields[filterOn] || {};
|
|
19455
|
+
const { path: path2, reference: reference2, type: type2 } = fieldSchema;
|
|
19456
|
+
let stringFilterValue = filterValue && filterValue.toString ? filterValue.toString() : filterValue;
|
|
19457
|
+
if (stringFilterValue === false) {
|
|
19458
|
+
stringFilterValue = "false";
|
|
19459
|
+
} else {
|
|
19460
|
+
stringFilterValue = stringFilterValue || "";
|
|
19461
|
+
}
|
|
19462
|
+
const arrayFilterValue = Array.isArray(filterValue) ? filterValue : stringFilterValue.split(";");
|
|
19463
|
+
if (type2 === "number" || type2 === "integer") {
|
|
19464
|
+
filterValue = Array.isArray(filterValue) ? filterValue.map((val) => Number(val)) : Number(filterValue);
|
|
19465
|
+
}
|
|
19466
|
+
if (fieldSchema.normalizeFilter) {
|
|
19467
|
+
filterValue = fieldSchema.normalizeFilter(
|
|
19468
|
+
filterValue,
|
|
19469
|
+
selectedFilter,
|
|
19470
|
+
filterOn
|
|
19471
|
+
);
|
|
19472
|
+
}
|
|
19473
|
+
if (reference2) {
|
|
19474
|
+
filterOn = reference2.sourceField;
|
|
19475
|
+
} else {
|
|
19476
|
+
filterOn = path2 || filterOn;
|
|
19477
|
+
}
|
|
19453
19478
|
switch (selectedFilter) {
|
|
19454
|
-
case "
|
|
19479
|
+
case "none":
|
|
19480
|
+
return {};
|
|
19481
|
+
case "startsWith":
|
|
19482
|
+
return { [filterOn]: { _ilike: `${filterValue}%` } };
|
|
19483
|
+
case "endsWith":
|
|
19484
|
+
return { [filterOn]: { _ilike: `%${filterValue}` } };
|
|
19485
|
+
case "contains":
|
|
19455
19486
|
return { [filterOn]: { _ilike: `%${filterValue}%` } };
|
|
19456
|
-
case "
|
|
19487
|
+
case "notContains":
|
|
19488
|
+
return { [filterOn]: { _not_ilike: `%${filterValue}%` } };
|
|
19489
|
+
case "isExactly":
|
|
19457
19490
|
return { [filterOn]: { _eq: filterValue } };
|
|
19458
|
-
case "
|
|
19459
|
-
return {
|
|
19460
|
-
|
|
19461
|
-
|
|
19462
|
-
|
|
19491
|
+
case "isEmpty":
|
|
19492
|
+
return {
|
|
19493
|
+
_or: [
|
|
19494
|
+
{ [filterOn]: { _eq: "" } },
|
|
19495
|
+
{ [filterOn]: { _is_null: true } }
|
|
19496
|
+
]
|
|
19497
|
+
};
|
|
19498
|
+
case "notEmpty":
|
|
19499
|
+
return {
|
|
19500
|
+
_and: [
|
|
19501
|
+
{ [filterOn]: { _neq: "" } },
|
|
19502
|
+
{ [filterOn]: { _is_null: false } }
|
|
19503
|
+
]
|
|
19504
|
+
};
|
|
19505
|
+
case "inList":
|
|
19506
|
+
return { [filterOn]: { _in: filterValue } };
|
|
19507
|
+
case "notInList":
|
|
19508
|
+
return { [filterOn]: { _nin: filterValue } };
|
|
19509
|
+
case "true":
|
|
19510
|
+
return { [filterOn]: { _eq: true } };
|
|
19511
|
+
case "false":
|
|
19512
|
+
return { [filterOn]: { _eq: false } };
|
|
19513
|
+
case "dateIs":
|
|
19514
|
+
return { [filterOn]: { _eq: filterValue } };
|
|
19515
|
+
case "notBetween":
|
|
19516
|
+
return {
|
|
19517
|
+
_or: [
|
|
19518
|
+
{
|
|
19519
|
+
[filterOn]: {
|
|
19520
|
+
_lt: new Date(arrayFilterValue[0])
|
|
19521
|
+
}
|
|
19522
|
+
},
|
|
19523
|
+
{
|
|
19524
|
+
[filterOn]: {
|
|
19525
|
+
_gt: new Date(new Date(arrayFilterValue[1]).setHours(23, 59))
|
|
19526
|
+
}
|
|
19527
|
+
}
|
|
19528
|
+
]
|
|
19529
|
+
};
|
|
19530
|
+
case "isBetween":
|
|
19531
|
+
return {
|
|
19532
|
+
[filterOn]: {
|
|
19533
|
+
_gte: new Date(arrayFilterValue[0]),
|
|
19534
|
+
_lte: new Date(new Date(arrayFilterValue[1]).setHours(23, 59))
|
|
19535
|
+
}
|
|
19536
|
+
};
|
|
19537
|
+
case "isBefore":
|
|
19538
|
+
return { [filterOn]: { _lt: new Date(filterValue) } };
|
|
19539
|
+
case "isAfter":
|
|
19540
|
+
return { [filterOn]: { _gt: new Date(filterValue) } };
|
|
19541
|
+
case "greaterThan":
|
|
19463
19542
|
return { [filterOn]: { _gt: parseFloat(filterValue) } };
|
|
19464
|
-
case "
|
|
19543
|
+
case "lessThan":
|
|
19465
19544
|
return { [filterOn]: { _lt: parseFloat(filterValue) } };
|
|
19466
|
-
case "
|
|
19467
|
-
return {
|
|
19468
|
-
|
|
19469
|
-
|
|
19470
|
-
|
|
19471
|
-
|
|
19472
|
-
|
|
19473
|
-
|
|
19545
|
+
case "inRange":
|
|
19546
|
+
return {
|
|
19547
|
+
[filterOn]: {
|
|
19548
|
+
_gte: parseFloat(arrayFilterValue[0]),
|
|
19549
|
+
_lte: parseFloat(arrayFilterValue[1])
|
|
19550
|
+
}
|
|
19551
|
+
};
|
|
19552
|
+
case "outsideRange":
|
|
19553
|
+
return {
|
|
19554
|
+
_or: [
|
|
19555
|
+
{
|
|
19556
|
+
[filterOn]: {
|
|
19557
|
+
_lt: parseFloat(arrayFilterValue[0])
|
|
19558
|
+
}
|
|
19559
|
+
},
|
|
19560
|
+
{
|
|
19561
|
+
[filterOn]: {
|
|
19562
|
+
_gt: parseFloat(arrayFilterValue[1])
|
|
19563
|
+
}
|
|
19564
|
+
}
|
|
19565
|
+
]
|
|
19566
|
+
};
|
|
19567
|
+
case "equalTo":
|
|
19568
|
+
return { [filterOn]: { _eq: parseFloat(filterValue) } };
|
|
19569
|
+
case "regex":
|
|
19570
|
+
return { [filterOn]: { _regex: filterValue } };
|
|
19474
19571
|
default:
|
|
19475
19572
|
console.warn(`Unsupported filter type: ${selectedFilter}`);
|
|
19476
19573
|
return {};
|
|
@@ -19497,6 +19594,21 @@ function tableQueryParamsToHasuraClauses({
|
|
|
19497
19594
|
return { where, order_by, limit, offset: offset3 };
|
|
19498
19595
|
}
|
|
19499
19596
|
__name(tableQueryParamsToHasuraClauses, "tableQueryParamsToHasuraClauses");
|
|
19597
|
+
function getFieldsMappedByCCDisplayName(schema) {
|
|
19598
|
+
if (!schema || !schema.fields) return {};
|
|
19599
|
+
return schema.fields.reduce((acc, field) => {
|
|
19600
|
+
const ccDisplayName = getCCDisplayName(field);
|
|
19601
|
+
acc[ccDisplayName] = field;
|
|
19602
|
+
return acc;
|
|
19603
|
+
}, {});
|
|
19604
|
+
}
|
|
19605
|
+
__name(getFieldsMappedByCCDisplayName, "getFieldsMappedByCCDisplayName");
|
|
19606
|
+
function getCCDisplayName(field) {
|
|
19607
|
+
return camelCase(
|
|
19608
|
+
typeof field.displayName === "string" ? field.displayName : field.path
|
|
19609
|
+
);
|
|
19610
|
+
}
|
|
19611
|
+
__name(getCCDisplayName, "getCCDisplayName");
|
|
19500
19612
|
function filterLocalEntitiesToHasura(records, { where, order_by, limit, offset: offset3, isInfinite } = {}) {
|
|
19501
19613
|
let filteredRecords = [...records];
|
|
19502
19614
|
if (where) {
|
|
@@ -19526,10 +19638,16 @@ function applyWhereClause(records, where) {
|
|
|
19526
19638
|
}
|
|
19527
19639
|
for (const key in filter2) {
|
|
19528
19640
|
if (key === "_and") {
|
|
19641
|
+
if (isEmpty$1(filter2[key])) {
|
|
19642
|
+
continue;
|
|
19643
|
+
}
|
|
19529
19644
|
if (!every(filter2[key], (subFilter) => applyFilter(record, subFilter))) {
|
|
19530
19645
|
return false;
|
|
19531
19646
|
}
|
|
19532
19647
|
} else if (key === "_or") {
|
|
19648
|
+
if (isEmpty$1(filter2[key])) {
|
|
19649
|
+
continue;
|
|
19650
|
+
}
|
|
19533
19651
|
if (!some(filter2[key], (subFilter) => applyFilter(record, subFilter))) {
|
|
19534
19652
|
return false;
|
|
19535
19653
|
}
|
|
@@ -19685,12 +19803,6 @@ function safeParse(val) {
|
|
|
19685
19803
|
}
|
|
19686
19804
|
}
|
|
19687
19805
|
__name(safeParse, "safeParse");
|
|
19688
|
-
function getCCDisplayName(field) {
|
|
19689
|
-
return camelCase(
|
|
19690
|
-
typeof field.displayName === "string" ? field.displayName : field.path
|
|
19691
|
-
);
|
|
19692
|
-
}
|
|
19693
|
-
__name(getCCDisplayName, "getCCDisplayName");
|
|
19694
19806
|
function getCurrentParamsFromUrl(location2, isSimple) {
|
|
19695
19807
|
let { search: search2 } = location2;
|
|
19696
19808
|
if (isSimple) {
|
|
@@ -19859,7 +19971,7 @@ function getQueryParams({
|
|
|
19859
19971
|
isLocalCall,
|
|
19860
19972
|
additionalFilter,
|
|
19861
19973
|
doNotCoercePageSize,
|
|
19862
|
-
|
|
19974
|
+
noOrderError,
|
|
19863
19975
|
// isCodeModel,
|
|
19864
19976
|
ownProps
|
|
19865
19977
|
}) {
|
|
@@ -19883,11 +19995,31 @@ function getQueryParams({
|
|
|
19883
19995
|
)[0];
|
|
19884
19996
|
pageSize = closest;
|
|
19885
19997
|
}
|
|
19998
|
+
const cleanedOrder = [];
|
|
19999
|
+
if (order2 && order2.length) {
|
|
20000
|
+
const ccFields = getFieldsMappedByCCDisplayName(schema);
|
|
20001
|
+
order2.forEach((orderVal) => {
|
|
20002
|
+
const ccDisplayName = orderVal.replace(/^-/gi, "");
|
|
20003
|
+
const schemaForField = ccFields[ccDisplayName];
|
|
20004
|
+
if (schemaForField) {
|
|
20005
|
+
const { path: path2 } = schemaForField;
|
|
20006
|
+
const reversed = ccDisplayName !== orderVal;
|
|
20007
|
+
const prefix2 = reversed ? "-" : "";
|
|
20008
|
+
cleanedOrder.push(prefix2 + path2);
|
|
20009
|
+
} else {
|
|
20010
|
+
!noOrderError && console.error(
|
|
20011
|
+
"No schema for field found!",
|
|
20012
|
+
ccDisplayName,
|
|
20013
|
+
JSON.stringify(schema.fields, null, 2)
|
|
20014
|
+
);
|
|
20015
|
+
}
|
|
20016
|
+
});
|
|
20017
|
+
}
|
|
19886
20018
|
const toReturn = {
|
|
19887
20019
|
//these are values that might be generally useful for the wrapped component
|
|
19888
20020
|
page,
|
|
19889
20021
|
pageSize: ownProps.controlled_pageSize || pageSize,
|
|
19890
|
-
order:
|
|
20022
|
+
order: cleanedOrder,
|
|
19891
20023
|
filters,
|
|
19892
20024
|
searchTerm
|
|
19893
20025
|
};
|
|
@@ -19896,19 +20028,20 @@ function getQueryParams({
|
|
|
19896
20028
|
pageSize,
|
|
19897
20029
|
searchTerm,
|
|
19898
20030
|
filters,
|
|
19899
|
-
order:
|
|
20031
|
+
order: cleanedOrder,
|
|
19900
20032
|
schema
|
|
19901
20033
|
});
|
|
19902
20034
|
initializeHasuraWhereAndFilter(additionalFilter, where, currentParams);
|
|
19903
20035
|
addCustomColumnFilters(where, schema.fields, currentParams);
|
|
19904
20036
|
if (isLocalCall) {
|
|
19905
|
-
|
|
20037
|
+
const toRet = filterLocalEntitiesToHasura(entities, {
|
|
19906
20038
|
where,
|
|
19907
20039
|
order_by,
|
|
19908
20040
|
limit,
|
|
19909
20041
|
offset: offset3,
|
|
19910
20042
|
isInfinite
|
|
19911
20043
|
});
|
|
20044
|
+
return toRet;
|
|
19912
20045
|
} else {
|
|
19913
20046
|
return __spreadProps(__spreadValues({}, toReturn), {
|
|
19914
20047
|
variables: {
|
|
@@ -71628,6 +71761,7 @@ const useTableParams = /* @__PURE__ */ __name((props) => {
|
|
|
71628
71761
|
isInfinite: isInfinite || isSimple && !withPaging,
|
|
71629
71762
|
isLocalCall,
|
|
71630
71763
|
additionalFilter,
|
|
71764
|
+
noOrderError,
|
|
71631
71765
|
ownProps: passingProps
|
|
71632
71766
|
});
|
|
71633
71767
|
}, [
|
package/index.es.js
CHANGED
|
@@ -19384,6 +19384,7 @@ function tableQueryParamsToHasuraClauses({
|
|
|
19384
19384
|
// Add schema as a parameter
|
|
19385
19385
|
additionalFilter
|
|
19386
19386
|
}) {
|
|
19387
|
+
const ccFields = getFieldsMappedByCCDisplayName(schema);
|
|
19387
19388
|
let where = {};
|
|
19388
19389
|
const order_by = {};
|
|
19389
19390
|
const limit = pageSize || 25;
|
|
@@ -19431,28 +19432,124 @@ function tableQueryParamsToHasuraClauses({
|
|
|
19431
19432
|
}
|
|
19432
19433
|
if (filters && filters.length > 0) {
|
|
19433
19434
|
const filterClauses = filters.map((filter2) => {
|
|
19434
|
-
|
|
19435
|
+
let { selectedFilter, filterOn, filterValue } = filter2;
|
|
19436
|
+
const fieldSchema = ccFields[filterOn] || {};
|
|
19437
|
+
const { path: path2, reference: reference2, type: type2 } = fieldSchema;
|
|
19438
|
+
let stringFilterValue = filterValue && filterValue.toString ? filterValue.toString() : filterValue;
|
|
19439
|
+
if (stringFilterValue === false) {
|
|
19440
|
+
stringFilterValue = "false";
|
|
19441
|
+
} else {
|
|
19442
|
+
stringFilterValue = stringFilterValue || "";
|
|
19443
|
+
}
|
|
19444
|
+
const arrayFilterValue = Array.isArray(filterValue) ? filterValue : stringFilterValue.split(";");
|
|
19445
|
+
if (type2 === "number" || type2 === "integer") {
|
|
19446
|
+
filterValue = Array.isArray(filterValue) ? filterValue.map((val) => Number(val)) : Number(filterValue);
|
|
19447
|
+
}
|
|
19448
|
+
if (fieldSchema.normalizeFilter) {
|
|
19449
|
+
filterValue = fieldSchema.normalizeFilter(
|
|
19450
|
+
filterValue,
|
|
19451
|
+
selectedFilter,
|
|
19452
|
+
filterOn
|
|
19453
|
+
);
|
|
19454
|
+
}
|
|
19455
|
+
if (reference2) {
|
|
19456
|
+
filterOn = reference2.sourceField;
|
|
19457
|
+
} else {
|
|
19458
|
+
filterOn = path2 || filterOn;
|
|
19459
|
+
}
|
|
19435
19460
|
switch (selectedFilter) {
|
|
19436
|
-
case "
|
|
19461
|
+
case "none":
|
|
19462
|
+
return {};
|
|
19463
|
+
case "startsWith":
|
|
19464
|
+
return { [filterOn]: { _ilike: `${filterValue}%` } };
|
|
19465
|
+
case "endsWith":
|
|
19466
|
+
return { [filterOn]: { _ilike: `%${filterValue}` } };
|
|
19467
|
+
case "contains":
|
|
19437
19468
|
return { [filterOn]: { _ilike: `%${filterValue}%` } };
|
|
19438
|
-
case "
|
|
19469
|
+
case "notContains":
|
|
19470
|
+
return { [filterOn]: { _not_ilike: `%${filterValue}%` } };
|
|
19471
|
+
case "isExactly":
|
|
19439
19472
|
return { [filterOn]: { _eq: filterValue } };
|
|
19440
|
-
case "
|
|
19441
|
-
return {
|
|
19442
|
-
|
|
19443
|
-
|
|
19444
|
-
|
|
19473
|
+
case "isEmpty":
|
|
19474
|
+
return {
|
|
19475
|
+
_or: [
|
|
19476
|
+
{ [filterOn]: { _eq: "" } },
|
|
19477
|
+
{ [filterOn]: { _is_null: true } }
|
|
19478
|
+
]
|
|
19479
|
+
};
|
|
19480
|
+
case "notEmpty":
|
|
19481
|
+
return {
|
|
19482
|
+
_and: [
|
|
19483
|
+
{ [filterOn]: { _neq: "" } },
|
|
19484
|
+
{ [filterOn]: { _is_null: false } }
|
|
19485
|
+
]
|
|
19486
|
+
};
|
|
19487
|
+
case "inList":
|
|
19488
|
+
return { [filterOn]: { _in: filterValue } };
|
|
19489
|
+
case "notInList":
|
|
19490
|
+
return { [filterOn]: { _nin: filterValue } };
|
|
19491
|
+
case "true":
|
|
19492
|
+
return { [filterOn]: { _eq: true } };
|
|
19493
|
+
case "false":
|
|
19494
|
+
return { [filterOn]: { _eq: false } };
|
|
19495
|
+
case "dateIs":
|
|
19496
|
+
return { [filterOn]: { _eq: filterValue } };
|
|
19497
|
+
case "notBetween":
|
|
19498
|
+
return {
|
|
19499
|
+
_or: [
|
|
19500
|
+
{
|
|
19501
|
+
[filterOn]: {
|
|
19502
|
+
_lt: new Date(arrayFilterValue[0])
|
|
19503
|
+
}
|
|
19504
|
+
},
|
|
19505
|
+
{
|
|
19506
|
+
[filterOn]: {
|
|
19507
|
+
_gt: new Date(new Date(arrayFilterValue[1]).setHours(23, 59))
|
|
19508
|
+
}
|
|
19509
|
+
}
|
|
19510
|
+
]
|
|
19511
|
+
};
|
|
19512
|
+
case "isBetween":
|
|
19513
|
+
return {
|
|
19514
|
+
[filterOn]: {
|
|
19515
|
+
_gte: new Date(arrayFilterValue[0]),
|
|
19516
|
+
_lte: new Date(new Date(arrayFilterValue[1]).setHours(23, 59))
|
|
19517
|
+
}
|
|
19518
|
+
};
|
|
19519
|
+
case "isBefore":
|
|
19520
|
+
return { [filterOn]: { _lt: new Date(filterValue) } };
|
|
19521
|
+
case "isAfter":
|
|
19522
|
+
return { [filterOn]: { _gt: new Date(filterValue) } };
|
|
19523
|
+
case "greaterThan":
|
|
19445
19524
|
return { [filterOn]: { _gt: parseFloat(filterValue) } };
|
|
19446
|
-
case "
|
|
19525
|
+
case "lessThan":
|
|
19447
19526
|
return { [filterOn]: { _lt: parseFloat(filterValue) } };
|
|
19448
|
-
case "
|
|
19449
|
-
return {
|
|
19450
|
-
|
|
19451
|
-
|
|
19452
|
-
|
|
19453
|
-
|
|
19454
|
-
|
|
19455
|
-
|
|
19527
|
+
case "inRange":
|
|
19528
|
+
return {
|
|
19529
|
+
[filterOn]: {
|
|
19530
|
+
_gte: parseFloat(arrayFilterValue[0]),
|
|
19531
|
+
_lte: parseFloat(arrayFilterValue[1])
|
|
19532
|
+
}
|
|
19533
|
+
};
|
|
19534
|
+
case "outsideRange":
|
|
19535
|
+
return {
|
|
19536
|
+
_or: [
|
|
19537
|
+
{
|
|
19538
|
+
[filterOn]: {
|
|
19539
|
+
_lt: parseFloat(arrayFilterValue[0])
|
|
19540
|
+
}
|
|
19541
|
+
},
|
|
19542
|
+
{
|
|
19543
|
+
[filterOn]: {
|
|
19544
|
+
_gt: parseFloat(arrayFilterValue[1])
|
|
19545
|
+
}
|
|
19546
|
+
}
|
|
19547
|
+
]
|
|
19548
|
+
};
|
|
19549
|
+
case "equalTo":
|
|
19550
|
+
return { [filterOn]: { _eq: parseFloat(filterValue) } };
|
|
19551
|
+
case "regex":
|
|
19552
|
+
return { [filterOn]: { _regex: filterValue } };
|
|
19456
19553
|
default:
|
|
19457
19554
|
console.warn(`Unsupported filter type: ${selectedFilter}`);
|
|
19458
19555
|
return {};
|
|
@@ -19479,6 +19576,21 @@ function tableQueryParamsToHasuraClauses({
|
|
|
19479
19576
|
return { where, order_by, limit, offset: offset3 };
|
|
19480
19577
|
}
|
|
19481
19578
|
__name(tableQueryParamsToHasuraClauses, "tableQueryParamsToHasuraClauses");
|
|
19579
|
+
function getFieldsMappedByCCDisplayName(schema) {
|
|
19580
|
+
if (!schema || !schema.fields) return {};
|
|
19581
|
+
return schema.fields.reduce((acc, field) => {
|
|
19582
|
+
const ccDisplayName = getCCDisplayName(field);
|
|
19583
|
+
acc[ccDisplayName] = field;
|
|
19584
|
+
return acc;
|
|
19585
|
+
}, {});
|
|
19586
|
+
}
|
|
19587
|
+
__name(getFieldsMappedByCCDisplayName, "getFieldsMappedByCCDisplayName");
|
|
19588
|
+
function getCCDisplayName(field) {
|
|
19589
|
+
return camelCase(
|
|
19590
|
+
typeof field.displayName === "string" ? field.displayName : field.path
|
|
19591
|
+
);
|
|
19592
|
+
}
|
|
19593
|
+
__name(getCCDisplayName, "getCCDisplayName");
|
|
19482
19594
|
function filterLocalEntitiesToHasura(records, { where, order_by, limit, offset: offset3, isInfinite } = {}) {
|
|
19483
19595
|
let filteredRecords = [...records];
|
|
19484
19596
|
if (where) {
|
|
@@ -19508,10 +19620,16 @@ function applyWhereClause(records, where) {
|
|
|
19508
19620
|
}
|
|
19509
19621
|
for (const key in filter2) {
|
|
19510
19622
|
if (key === "_and") {
|
|
19623
|
+
if (isEmpty$1(filter2[key])) {
|
|
19624
|
+
continue;
|
|
19625
|
+
}
|
|
19511
19626
|
if (!every(filter2[key], (subFilter) => applyFilter(record, subFilter))) {
|
|
19512
19627
|
return false;
|
|
19513
19628
|
}
|
|
19514
19629
|
} else if (key === "_or") {
|
|
19630
|
+
if (isEmpty$1(filter2[key])) {
|
|
19631
|
+
continue;
|
|
19632
|
+
}
|
|
19515
19633
|
if (!some(filter2[key], (subFilter) => applyFilter(record, subFilter))) {
|
|
19516
19634
|
return false;
|
|
19517
19635
|
}
|
|
@@ -19667,12 +19785,6 @@ function safeParse(val) {
|
|
|
19667
19785
|
}
|
|
19668
19786
|
}
|
|
19669
19787
|
__name(safeParse, "safeParse");
|
|
19670
|
-
function getCCDisplayName(field) {
|
|
19671
|
-
return camelCase(
|
|
19672
|
-
typeof field.displayName === "string" ? field.displayName : field.path
|
|
19673
|
-
);
|
|
19674
|
-
}
|
|
19675
|
-
__name(getCCDisplayName, "getCCDisplayName");
|
|
19676
19788
|
function getCurrentParamsFromUrl(location2, isSimple) {
|
|
19677
19789
|
let { search: search2 } = location2;
|
|
19678
19790
|
if (isSimple) {
|
|
@@ -19841,7 +19953,7 @@ function getQueryParams({
|
|
|
19841
19953
|
isLocalCall,
|
|
19842
19954
|
additionalFilter,
|
|
19843
19955
|
doNotCoercePageSize,
|
|
19844
|
-
|
|
19956
|
+
noOrderError,
|
|
19845
19957
|
// isCodeModel,
|
|
19846
19958
|
ownProps
|
|
19847
19959
|
}) {
|
|
@@ -19865,11 +19977,31 @@ function getQueryParams({
|
|
|
19865
19977
|
)[0];
|
|
19866
19978
|
pageSize = closest;
|
|
19867
19979
|
}
|
|
19980
|
+
const cleanedOrder = [];
|
|
19981
|
+
if (order2 && order2.length) {
|
|
19982
|
+
const ccFields = getFieldsMappedByCCDisplayName(schema);
|
|
19983
|
+
order2.forEach((orderVal) => {
|
|
19984
|
+
const ccDisplayName = orderVal.replace(/^-/gi, "");
|
|
19985
|
+
const schemaForField = ccFields[ccDisplayName];
|
|
19986
|
+
if (schemaForField) {
|
|
19987
|
+
const { path: path2 } = schemaForField;
|
|
19988
|
+
const reversed = ccDisplayName !== orderVal;
|
|
19989
|
+
const prefix2 = reversed ? "-" : "";
|
|
19990
|
+
cleanedOrder.push(prefix2 + path2);
|
|
19991
|
+
} else {
|
|
19992
|
+
!noOrderError && console.error(
|
|
19993
|
+
"No schema for field found!",
|
|
19994
|
+
ccDisplayName,
|
|
19995
|
+
JSON.stringify(schema.fields, null, 2)
|
|
19996
|
+
);
|
|
19997
|
+
}
|
|
19998
|
+
});
|
|
19999
|
+
}
|
|
19868
20000
|
const toReturn = {
|
|
19869
20001
|
//these are values that might be generally useful for the wrapped component
|
|
19870
20002
|
page,
|
|
19871
20003
|
pageSize: ownProps.controlled_pageSize || pageSize,
|
|
19872
|
-
order:
|
|
20004
|
+
order: cleanedOrder,
|
|
19873
20005
|
filters,
|
|
19874
20006
|
searchTerm
|
|
19875
20007
|
};
|
|
@@ -19878,19 +20010,20 @@ function getQueryParams({
|
|
|
19878
20010
|
pageSize,
|
|
19879
20011
|
searchTerm,
|
|
19880
20012
|
filters,
|
|
19881
|
-
order:
|
|
20013
|
+
order: cleanedOrder,
|
|
19882
20014
|
schema
|
|
19883
20015
|
});
|
|
19884
20016
|
initializeHasuraWhereAndFilter(additionalFilter, where, currentParams);
|
|
19885
20017
|
addCustomColumnFilters(where, schema.fields, currentParams);
|
|
19886
20018
|
if (isLocalCall) {
|
|
19887
|
-
|
|
20019
|
+
const toRet = filterLocalEntitiesToHasura(entities, {
|
|
19888
20020
|
where,
|
|
19889
20021
|
order_by,
|
|
19890
20022
|
limit,
|
|
19891
20023
|
offset: offset3,
|
|
19892
20024
|
isInfinite
|
|
19893
20025
|
});
|
|
20026
|
+
return toRet;
|
|
19894
20027
|
} else {
|
|
19895
20028
|
return __spreadProps(__spreadValues({}, toReturn), {
|
|
19896
20029
|
variables: {
|
|
@@ -71610,6 +71743,7 @@ const useTableParams = /* @__PURE__ */ __name((props) => {
|
|
|
71610
71743
|
isInfinite: isInfinite || isSimple && !withPaging,
|
|
71611
71744
|
isLocalCall,
|
|
71612
71745
|
additionalFilter,
|
|
71746
|
+
noOrderError,
|
|
71613
71747
|
ownProps: passingProps
|
|
71614
71748
|
});
|
|
71615
71749
|
}, [
|
package/package.json
CHANGED
package/src/DataTable/Columns.js
CHANGED
|
@@ -33,10 +33,10 @@ import getTextFromEl from "../utils/getTextFromEl";
|
|
|
33
33
|
import rowClick, { finalizeSelection } from "./utils/rowClick";
|
|
34
34
|
import { editCellHelper } from "./editCellHelper";
|
|
35
35
|
import { getCellVal } from "./getCellVal";
|
|
36
|
-
import { getCCDisplayName } from "./utils/queryParams";
|
|
37
36
|
import { useDispatch } from "react-redux";
|
|
38
37
|
import { change as _change } from "redux-form";
|
|
39
38
|
import { RenderCell } from "./RenderCell";
|
|
39
|
+
import { getCCDisplayName } from "./utils/tableQueryParamsToHasuraClauses";
|
|
40
40
|
|
|
41
41
|
dayjs.extend(localizedFormat);
|
|
42
42
|
|
package/src/DataTable/index.js
CHANGED
|
@@ -92,7 +92,6 @@ import { viewColumn, openColumn, multiViewColumn } from "./viewColumn";
|
|
|
92
92
|
import convertSchema from "./utils/convertSchema";
|
|
93
93
|
import TableFormTrackerContext from "./TableFormTrackerContext";
|
|
94
94
|
import {
|
|
95
|
-
getCCDisplayName,
|
|
96
95
|
getCurrentParamsFromUrl,
|
|
97
96
|
getQueryParams,
|
|
98
97
|
makeDataTableHandlers,
|
|
@@ -103,6 +102,7 @@ import { formValueSelector, change as _change } from "redux-form";
|
|
|
103
102
|
import { throwFormError } from "../throwFormError";
|
|
104
103
|
import { isObservableArray, toJS } from "mobx";
|
|
105
104
|
import { isBeingCalledExcessively } from "../utils/isBeingCalledExcessively";
|
|
105
|
+
import { getCCDisplayName } from "./utils/tableQueryParamsToHasuraClauses";
|
|
106
106
|
|
|
107
107
|
enablePatches();
|
|
108
108
|
const IS_LINUX = window.navigator.platform.toLowerCase().search("linux") > -1;
|
|
@@ -56,10 +56,16 @@ function applyWhereClause(records, where) {
|
|
|
56
56
|
|
|
57
57
|
for (const key in filter) {
|
|
58
58
|
if (key === "_and") {
|
|
59
|
+
if (isEmpty(filter[key])) {
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
59
62
|
if (!every(filter[key], subFilter => applyFilter(record, subFilter))) {
|
|
60
63
|
return false;
|
|
61
64
|
}
|
|
62
65
|
} else if (key === "_or") {
|
|
66
|
+
if (isEmpty(filter[key])) {
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
63
69
|
if (!some(filter[key], subFilter => applyFilter(record, subFilter))) {
|
|
64
70
|
return false;
|
|
65
71
|
}
|