|
|
@ -227,88 +227,127 @@ export async function validateCondition( |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
switch (filter.comparison_op) { |
|
|
|
if ( |
|
|
|
case 'eq': |
|
|
|
[UITypes.User, UITypes.CreatedBy, UITypes.LastModifiedBy].includes( |
|
|
|
res = val == filter.value; |
|
|
|
column.uidt, |
|
|
|
break; |
|
|
|
) |
|
|
|
case 'neq': |
|
|
|
) { |
|
|
|
res = val != filter.value; |
|
|
|
const userIds = Array.isArray(data[field]) |
|
|
|
break; |
|
|
|
? data[field].map((user) => user.id) |
|
|
|
case 'like': |
|
|
|
: data[field]?.id |
|
|
|
res = |
|
|
|
? [data[field].id] |
|
|
|
data[field] |
|
|
|
: []; |
|
|
|
?.toString?.() |
|
|
|
|
|
|
|
?.toLowerCase() |
|
|
|
const filterValues = filter.value.split(',').map((v) => v.trim()); |
|
|
|
?.indexOf(filter.value?.toLowerCase()) > -1; |
|
|
|
|
|
|
|
break; |
|
|
|
switch (filter.comparison_op) { |
|
|
|
case 'nlike': |
|
|
|
case 'anyof': |
|
|
|
res = |
|
|
|
res = userIds.some((id) => filterValues.includes(id)); |
|
|
|
data[field] |
|
|
|
break; |
|
|
|
?.toString?.() |
|
|
|
case 'nanyof': |
|
|
|
?.toLowerCase() |
|
|
|
res = !userIds.some((id) => filterValues.includes(id)); |
|
|
|
?.indexOf(filter.value?.toLowerCase()) === -1; |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 'allof': |
|
|
|
case 'empty': |
|
|
|
res = filterValues.every((id) => userIds.includes(id)); |
|
|
|
case 'blank': |
|
|
|
break; |
|
|
|
res = |
|
|
|
case 'nallof': |
|
|
|
data[field] === '' || |
|
|
|
res = !filterValues.every((id) => userIds.includes(id)); |
|
|
|
data[field] === null || |
|
|
|
break; |
|
|
|
data[field] === undefined; |
|
|
|
case 'empty': |
|
|
|
break; |
|
|
|
case 'blank': |
|
|
|
case 'notempty': |
|
|
|
res = userIds.length === 0; |
|
|
|
case 'notblank': |
|
|
|
break; |
|
|
|
res = !( |
|
|
|
case 'notempty': |
|
|
|
data[field] === '' || |
|
|
|
case 'notblank': |
|
|
|
data[field] === null || |
|
|
|
res = userIds.length > 0; |
|
|
|
data[field] === undefined |
|
|
|
break; |
|
|
|
); |
|
|
|
default: |
|
|
|
break; |
|
|
|
res = false; // Unsupported operation for User fields
|
|
|
|
case 'checked': |
|
|
|
} |
|
|
|
res = !!data[field]; |
|
|
|
} else { |
|
|
|
break; |
|
|
|
switch (filter.comparison_op) { |
|
|
|
case 'notchecked': |
|
|
|
case 'eq': |
|
|
|
res = !data[field]; |
|
|
|
res = val == filter.value; |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 'null': |
|
|
|
case 'neq': |
|
|
|
res = res = data[field] === null; |
|
|
|
res = val != filter.value; |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 'notnull': |
|
|
|
case 'like': |
|
|
|
res = data[field] !== null; |
|
|
|
res = |
|
|
|
break; |
|
|
|
data[field] |
|
|
|
case 'allof': |
|
|
|
?.toString?.() |
|
|
|
res = ( |
|
|
|
?.toLowerCase() |
|
|
|
filter.value?.split(',').map((item) => item.trim()) ?? [] |
|
|
|
?.indexOf(filter.value?.toLowerCase()) > -1; |
|
|
|
).every((item) => (data[field]?.split(',') ?? []).includes(item)); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 'nlike': |
|
|
|
case 'anyof': |
|
|
|
res = |
|
|
|
res = ( |
|
|
|
data[field] |
|
|
|
filter.value?.split(',').map((item) => item.trim()) ?? [] |
|
|
|
?.toString?.() |
|
|
|
).some((item) => (data[field]?.split(',') ?? []).includes(item)); |
|
|
|
?.toLowerCase() |
|
|
|
break; |
|
|
|
?.indexOf(filter.value?.toLowerCase()) === -1; |
|
|
|
case 'nallof': |
|
|
|
break; |
|
|
|
res = !( |
|
|
|
case 'empty': |
|
|
|
filter.value?.split(',').map((item) => item.trim()) ?? [] |
|
|
|
case 'blank': |
|
|
|
).every((item) => (data[field]?.split(',') ?? []).includes(item)); |
|
|
|
res = |
|
|
|
break; |
|
|
|
data[field] === '' || |
|
|
|
case 'nanyof': |
|
|
|
data[field] === null || |
|
|
|
res = !( |
|
|
|
data[field] === undefined; |
|
|
|
filter.value?.split(',').map((item) => item.trim()) ?? [] |
|
|
|
break; |
|
|
|
).some((item) => (data[field]?.split(',') ?? []).includes(item)); |
|
|
|
case 'notempty': |
|
|
|
break; |
|
|
|
case 'notblank': |
|
|
|
case 'lt': |
|
|
|
res = !( |
|
|
|
res = +data[field] < +filter.value; |
|
|
|
data[field] === '' || |
|
|
|
break; |
|
|
|
data[field] === null || |
|
|
|
case 'lte': |
|
|
|
data[field] === undefined |
|
|
|
case 'le': |
|
|
|
); |
|
|
|
res = +data[field] <= +filter.value; |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 'checked': |
|
|
|
case 'gt': |
|
|
|
res = !!data[field]; |
|
|
|
res = +data[field] > +filter.value; |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 'notchecked': |
|
|
|
case 'gte': |
|
|
|
res = !data[field]; |
|
|
|
case 'ge': |
|
|
|
break; |
|
|
|
res = +data[field] >= +filter.value; |
|
|
|
case 'null': |
|
|
|
break; |
|
|
|
res = res = data[field] === null; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case 'notnull': |
|
|
|
|
|
|
|
res = data[field] !== null; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case 'allof': |
|
|
|
|
|
|
|
res = ( |
|
|
|
|
|
|
|
filter.value?.split(',').map((item) => item.trim()) ?? [] |
|
|
|
|
|
|
|
).every((item) => (data[field]?.split(',') ?? []).includes(item)); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case 'anyof': |
|
|
|
|
|
|
|
res = ( |
|
|
|
|
|
|
|
filter.value?.split(',').map((item) => item.trim()) ?? [] |
|
|
|
|
|
|
|
).some((item) => (data[field]?.split(',') ?? []).includes(item)); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case 'nallof': |
|
|
|
|
|
|
|
res = !( |
|
|
|
|
|
|
|
filter.value?.split(',').map((item) => item.trim()) ?? [] |
|
|
|
|
|
|
|
).every((item) => (data[field]?.split(',') ?? []).includes(item)); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case 'nanyof': |
|
|
|
|
|
|
|
res = !( |
|
|
|
|
|
|
|
filter.value?.split(',').map((item) => item.trim()) ?? [] |
|
|
|
|
|
|
|
).some((item) => (data[field]?.split(',') ?? []).includes(item)); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case 'lt': |
|
|
|
|
|
|
|
res = +data[field] < +filter.value; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case 'lte': |
|
|
|
|
|
|
|
case 'le': |
|
|
|
|
|
|
|
res = +data[field] <= +filter.value; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case 'gt': |
|
|
|
|
|
|
|
res = +data[field] > +filter.value; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case 'gte': |
|
|
|
|
|
|
|
case 'ge': |
|
|
|
|
|
|
|
res = +data[field] >= +filter.value; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|