[View migration] Clean ViewFilterOperand (#14785)
In the BE we have stored filter operand as IS_EMPTY, IS_NOT_EMPTY, etc. For some reason in the FE we were manipulating IsEmpty, IsNotEmpty, etc. (maybe because they were used before in Views before they were moved to core) So we were converting the operands in the FE from IS to Is (convertViewFilterOperandFromCore) to read and manipulate viewFilters, and then back to BE version to send mutations etc., from Is to IS (convertViewFilterOperandToCore). The migration is now over, so we can remove and simplify that code. (In the 1-5:migrate-views-to-core command we still do the migration from Is format to IS format.)
This commit is contained in:
+1
-1
@@ -78,7 +78,7 @@ export const ObjectFilterDropdownDateInput = () => {
|
||||
};
|
||||
|
||||
const isRelativeOperand =
|
||||
selectedOperandInDropdown === ViewFilterOperand.IsRelative;
|
||||
selectedOperandInDropdown === ViewFilterOperand.IS_RELATIVE;
|
||||
|
||||
const handleClear = () => {
|
||||
isRelativeOperand
|
||||
|
||||
+11
-11
@@ -42,20 +42,20 @@ export const ObjectFilterDropdownFilterInput = ({
|
||||
const isOperandWithFilterValue =
|
||||
selectedOperandInDropdown &&
|
||||
[
|
||||
ViewFilterOperand.Is,
|
||||
ViewFilterOperand.IsNotNull,
|
||||
ViewFilterOperand.IsNot,
|
||||
ViewFilterOperand.LessThanOrEqual,
|
||||
ViewFilterOperand.GreaterThanOrEqual,
|
||||
ViewFilterOperand.IsBefore,
|
||||
ViewFilterOperand.IsAfter,
|
||||
ViewFilterOperand.Contains,
|
||||
ViewFilterOperand.DoesNotContain,
|
||||
ViewFilterOperand.IsRelative,
|
||||
ViewFilterOperand.IS,
|
||||
ViewFilterOperand.IS_NOT_NULL,
|
||||
ViewFilterOperand.IS_NOT,
|
||||
ViewFilterOperand.LESS_THAN_OR_EQUAL,
|
||||
ViewFilterOperand.GREATER_THAN_OR_EQUAL,
|
||||
ViewFilterOperand.IS_BEFORE,
|
||||
ViewFilterOperand.IS_AFTER,
|
||||
ViewFilterOperand.CONTAINS,
|
||||
ViewFilterOperand.DOES_NOT_CONTAIN,
|
||||
ViewFilterOperand.IS_RELATIVE,
|
||||
].includes(selectedOperandInDropdown);
|
||||
|
||||
const isVectorSearchFilter =
|
||||
selectedOperandInDropdown === ViewFilterOperand.VectorSearch;
|
||||
selectedOperandInDropdown === ViewFilterOperand.VECTOR_SEARCH;
|
||||
|
||||
if (isVectorSearchFilter && isDefined(filterDropdownId)) {
|
||||
return <ObjectFilterDropdownVectorSearchInput />;
|
||||
|
||||
+1
-1
@@ -33,7 +33,7 @@ export const ObjectFilterDropdownFilterInputHeader = () => {
|
||||
dropdownInstanceId === VIEW_BAR_FILTER_DROPDOWN_ID;
|
||||
|
||||
const isVectorSearchFilter =
|
||||
selectedOperandInDropdown === ViewFilterOperand.VectorSearch;
|
||||
selectedOperandInDropdown === ViewFilterOperand.VECTOR_SEARCH;
|
||||
|
||||
if (isInViewBarFilterDropdown) {
|
||||
return <ViewBarFilterDropdownFilterInputMenuHeader />;
|
||||
|
||||
+4
-4
@@ -2,8 +2,8 @@ import { RecordFilterOperand } from '@/object-record/record-filter/types/RecordF
|
||||
|
||||
export const DATE_OPERANDS_THAT_SHOULD_BE_INITIALIZED_WITH_NOW: RecordFilterOperand[] =
|
||||
[
|
||||
RecordFilterOperand.Is,
|
||||
RecordFilterOperand.IsNot,
|
||||
RecordFilterOperand.IsAfter,
|
||||
RecordFilterOperand.IsBefore,
|
||||
RecordFilterOperand.IS,
|
||||
RecordFilterOperand.IS_NOT,
|
||||
RecordFilterOperand.IS_AFTER,
|
||||
RecordFilterOperand.IS_BEFORE,
|
||||
];
|
||||
|
||||
+6
-6
@@ -44,11 +44,11 @@ export const useApplyObjectFilterDropdownOperand = () => {
|
||||
newOperand: RecordFilterOperand,
|
||||
) => {
|
||||
const isValuelessOperand = [
|
||||
RecordFilterOperand.IsEmpty,
|
||||
RecordFilterOperand.IsNotEmpty,
|
||||
RecordFilterOperand.IsInPast,
|
||||
RecordFilterOperand.IsInFuture,
|
||||
RecordFilterOperand.IsToday,
|
||||
RecordFilterOperand.IS_EMPTY,
|
||||
RecordFilterOperand.IS_NOT_EMPTY,
|
||||
RecordFilterOperand.IS_IN_PAST,
|
||||
RecordFilterOperand.IS_IN_FUTURE,
|
||||
RecordFilterOperand.IS_TODAY,
|
||||
].includes(newOperand);
|
||||
|
||||
let recordFilterToUpsert: RecordFilter | null | undefined = null;
|
||||
@@ -93,7 +93,7 @@ export const useApplyObjectFilterDropdownOperand = () => {
|
||||
);
|
||||
|
||||
recordFilterToUpsert.displayValue = displayValue;
|
||||
} else if (newOperand === RecordFilterOperand.IsRelative) {
|
||||
} else if (newOperand === RecordFilterOperand.IS_RELATIVE) {
|
||||
const defaultRelativeDate = {
|
||||
direction: 'THIS' as VariableDateViewFilterValueDirection,
|
||||
amount: 1,
|
||||
|
||||
+14
-14
@@ -5,13 +5,13 @@ import { getOperandLabel, getOperandLabelShort } from '../getOperandLabel';
|
||||
|
||||
describe('getOperandLabel', () => {
|
||||
const testCases = [
|
||||
[ViewFilterOperand.Contains, 'Contains'],
|
||||
[ViewFilterOperand.DoesNotContain, "Doesn't contain"],
|
||||
[ViewFilterOperand.GreaterThanOrEqual, 'Greater than or equal'],
|
||||
[ViewFilterOperand.LessThanOrEqual, 'Less than or equal'],
|
||||
[ViewFilterOperand.Is, 'Is'],
|
||||
[ViewFilterOperand.IsNot, 'Is not'],
|
||||
[ViewFilterOperand.IsNotNull, 'Is not null'],
|
||||
[ViewFilterOperand.CONTAINS, 'Contains'],
|
||||
[ViewFilterOperand.DOES_NOT_CONTAIN, "Doesn't contain"],
|
||||
[ViewFilterOperand.GREATER_THAN_OR_EQUAL, 'Greater than or equal'],
|
||||
[ViewFilterOperand.LESS_THAN_OR_EQUAL, 'Less than or equal'],
|
||||
[ViewFilterOperand.IS, 'Is'],
|
||||
[ViewFilterOperand.IS_NOT, 'Is not'],
|
||||
[ViewFilterOperand.IS_NOT_NULL, 'Is not null'],
|
||||
[undefined, ''], // undefined operand
|
||||
];
|
||||
|
||||
@@ -27,13 +27,13 @@ describe('getOperandLabel', () => {
|
||||
|
||||
describe('getOperandLabelShort', () => {
|
||||
const testCases = [
|
||||
[ViewFilterOperand.Is, ': '],
|
||||
[ViewFilterOperand.Contains, ': '],
|
||||
[ViewFilterOperand.IsNot, ': Not'],
|
||||
[ViewFilterOperand.DoesNotContain, ': Not'],
|
||||
[ViewFilterOperand.IsNotNull, ': NotNull'],
|
||||
[ViewFilterOperand.GreaterThanOrEqual, '\u00A0≥ '],
|
||||
[ViewFilterOperand.LessThanOrEqual, '\u00A0≤ '],
|
||||
[ViewFilterOperand.IS, ': '],
|
||||
[ViewFilterOperand.CONTAINS, ': '],
|
||||
[ViewFilterOperand.IS_NOT, ': Not'],
|
||||
[ViewFilterOperand.DOES_NOT_CONTAIN, ': Not'],
|
||||
[ViewFilterOperand.IS_NOT_NULL, ': NotNull'],
|
||||
[ViewFilterOperand.GREATER_THAN_OR_EQUAL, '\u00A0≥ '],
|
||||
[ViewFilterOperand.LESS_THAN_OR_EQUAL, '\u00A0≤ '],
|
||||
[undefined, ': '], // undefined operand
|
||||
];
|
||||
|
||||
|
||||
+22
-22
@@ -6,48 +6,48 @@ import { type FilterableFieldType } from 'twenty-shared/types';
|
||||
|
||||
describe('getOperandsForFilterType', () => {
|
||||
const emptyOperands = [
|
||||
RecordFilterOperand.IsEmpty,
|
||||
RecordFilterOperand.IsNotEmpty,
|
||||
RecordFilterOperand.IS_EMPTY,
|
||||
RecordFilterOperand.IS_NOT_EMPTY,
|
||||
];
|
||||
|
||||
const containsOperands = [
|
||||
RecordFilterOperand.Contains,
|
||||
RecordFilterOperand.DoesNotContain,
|
||||
RecordFilterOperand.CONTAINS,
|
||||
RecordFilterOperand.DOES_NOT_CONTAIN,
|
||||
];
|
||||
|
||||
const numberOperands = [
|
||||
RecordFilterOperand.GreaterThanOrEqual,
|
||||
RecordFilterOperand.LessThanOrEqual,
|
||||
RecordFilterOperand.GREATER_THAN_OR_EQUAL,
|
||||
RecordFilterOperand.LESS_THAN_OR_EQUAL,
|
||||
];
|
||||
|
||||
const currencyAmountMicrosOperands = [
|
||||
RecordFilterOperand.GreaterThanOrEqual,
|
||||
RecordFilterOperand.LessThanOrEqual,
|
||||
RecordFilterOperand.Is,
|
||||
RecordFilterOperand.IsNot,
|
||||
RecordFilterOperand.GREATER_THAN_OR_EQUAL,
|
||||
RecordFilterOperand.LESS_THAN_OR_EQUAL,
|
||||
RecordFilterOperand.IS,
|
||||
RecordFilterOperand.IS_NOT,
|
||||
];
|
||||
|
||||
const currencyCurrencyCodeOperands = [
|
||||
RecordFilterOperand.Is,
|
||||
RecordFilterOperand.IsNot,
|
||||
RecordFilterOperand.IS,
|
||||
RecordFilterOperand.IS_NOT,
|
||||
];
|
||||
|
||||
const actorSourceOperands = [
|
||||
RecordFilterOperand.Is,
|
||||
RecordFilterOperand.IsNot,
|
||||
RecordFilterOperand.IS,
|
||||
RecordFilterOperand.IS_NOT,
|
||||
];
|
||||
|
||||
const dateOperands = [
|
||||
RecordFilterOperand.Is,
|
||||
RecordFilterOperand.IsRelative,
|
||||
RecordFilterOperand.IsInPast,
|
||||
RecordFilterOperand.IsInFuture,
|
||||
RecordFilterOperand.IsToday,
|
||||
RecordFilterOperand.IsBefore,
|
||||
RecordFilterOperand.IsAfter,
|
||||
RecordFilterOperand.IS,
|
||||
RecordFilterOperand.IS_RELATIVE,
|
||||
RecordFilterOperand.IS_IN_PAST,
|
||||
RecordFilterOperand.IS_IN_FUTURE,
|
||||
RecordFilterOperand.IS_TODAY,
|
||||
RecordFilterOperand.IS_BEFORE,
|
||||
RecordFilterOperand.IS_AFTER,
|
||||
];
|
||||
|
||||
const relationOperand = [RecordFilterOperand.Is, RecordFilterOperand.IsNot];
|
||||
const relationOperand = [RecordFilterOperand.IS, RecordFilterOperand.IS_NOT];
|
||||
|
||||
const testCases = [
|
||||
['TEXT', [...containsOperands, ...emptyOperands]],
|
||||
|
||||
+15
-15
@@ -4,22 +4,22 @@ import { isFilterOperandExpectingValue } from '../isFilterOperandExpectingValue'
|
||||
|
||||
describe('isFilterOperandExpectingValue', () => {
|
||||
const testCases = [
|
||||
{ operand: ViewFilterOperand.Contains, expectedResult: true },
|
||||
{ operand: ViewFilterOperand.DoesNotContain, expectedResult: true },
|
||||
{ operand: ViewFilterOperand.GreaterThanOrEqual, expectedResult: true },
|
||||
{ operand: ViewFilterOperand.LessThanOrEqual, expectedResult: true },
|
||||
{ operand: ViewFilterOperand.Is, expectedResult: true },
|
||||
{ operand: ViewFilterOperand.IsNot, expectedResult: true },
|
||||
{ operand: ViewFilterOperand.IsRelative, expectedResult: true },
|
||||
{ operand: ViewFilterOperand.IsBefore, expectedResult: true },
|
||||
{ operand: ViewFilterOperand.IsAfter, expectedResult: true },
|
||||
{ operand: ViewFilterOperand.CONTAINS, expectedResult: true },
|
||||
{ operand: ViewFilterOperand.DOES_NOT_CONTAIN, expectedResult: true },
|
||||
{ operand: ViewFilterOperand.GREATER_THAN_OR_EQUAL, expectedResult: true },
|
||||
{ operand: ViewFilterOperand.LESS_THAN_OR_EQUAL, expectedResult: true },
|
||||
{ operand: ViewFilterOperand.IS, expectedResult: true },
|
||||
{ operand: ViewFilterOperand.IS_NOT, expectedResult: true },
|
||||
{ operand: ViewFilterOperand.IS_RELATIVE, expectedResult: true },
|
||||
{ operand: ViewFilterOperand.IS_BEFORE, expectedResult: true },
|
||||
{ operand: ViewFilterOperand.IS_AFTER, expectedResult: true },
|
||||
|
||||
{ operand: ViewFilterOperand.IsNotNull, expectedResult: false },
|
||||
{ operand: ViewFilterOperand.IsEmpty, expectedResult: false },
|
||||
{ operand: ViewFilterOperand.IsNotEmpty, expectedResult: false },
|
||||
{ operand: ViewFilterOperand.IsInPast, expectedResult: false },
|
||||
{ operand: ViewFilterOperand.IsInFuture, expectedResult: false },
|
||||
{ operand: ViewFilterOperand.IsToday, expectedResult: false },
|
||||
{ operand: ViewFilterOperand.IS_NOT_NULL, expectedResult: false },
|
||||
{ operand: ViewFilterOperand.IS_EMPTY, expectedResult: false },
|
||||
{ operand: ViewFilterOperand.IS_NOT_EMPTY, expectedResult: false },
|
||||
{ operand: ViewFilterOperand.IS_IN_PAST, expectedResult: false },
|
||||
{ operand: ViewFilterOperand.IS_IN_FUTURE, expectedResult: false },
|
||||
{ operand: ViewFilterOperand.IS_TODAY, expectedResult: false },
|
||||
];
|
||||
|
||||
testCases.forEach(({ operand, expectedResult }) => {
|
||||
|
||||
+10
-10
@@ -1,14 +1,14 @@
|
||||
import { ViewFilterOperand } from 'twenty-shared/types';
|
||||
|
||||
export const configurableViewFilterOperands = new Set<ViewFilterOperand>([
|
||||
ViewFilterOperand.Is,
|
||||
ViewFilterOperand.IsNotNull,
|
||||
ViewFilterOperand.IsNot,
|
||||
ViewFilterOperand.LessThanOrEqual,
|
||||
ViewFilterOperand.GreaterThanOrEqual,
|
||||
ViewFilterOperand.IsBefore,
|
||||
ViewFilterOperand.IsAfter,
|
||||
ViewFilterOperand.Contains,
|
||||
ViewFilterOperand.DoesNotContain,
|
||||
ViewFilterOperand.IsRelative,
|
||||
ViewFilterOperand.IS,
|
||||
ViewFilterOperand.IS_NOT_NULL,
|
||||
ViewFilterOperand.IS_NOT,
|
||||
ViewFilterOperand.LESS_THAN_OR_EQUAL,
|
||||
ViewFilterOperand.GREATER_THAN_OR_EQUAL,
|
||||
ViewFilterOperand.IS_BEFORE,
|
||||
ViewFilterOperand.IS_AFTER,
|
||||
ViewFilterOperand.CONTAINS,
|
||||
ViewFilterOperand.DOES_NOT_CONTAIN,
|
||||
ViewFilterOperand.IS_RELATIVE,
|
||||
]);
|
||||
|
||||
+4
-4
@@ -11,9 +11,9 @@ export const getInitialFilterValue = (
|
||||
case 'DATE':
|
||||
case 'DATE_TIME': {
|
||||
const activeDatePickerOperands = [
|
||||
RecordFilterOperand.IsBefore,
|
||||
RecordFilterOperand.Is,
|
||||
RecordFilterOperand.IsAfter,
|
||||
RecordFilterOperand.IS_BEFORE,
|
||||
RecordFilterOperand.IS,
|
||||
RecordFilterOperand.IS_AFTER,
|
||||
];
|
||||
|
||||
if (activeDatePickerOperands.includes(newOperand)) {
|
||||
@@ -25,7 +25,7 @@ export const getInitialFilterValue = (
|
||||
return { value, displayValue };
|
||||
}
|
||||
|
||||
if (newOperand === RecordFilterOperand.IsRelative) {
|
||||
if (newOperand === RecordFilterOperand.IS_RELATIVE) {
|
||||
return { value: '', displayValue: '' };
|
||||
}
|
||||
|
||||
|
||||
+29
-29
@@ -5,35 +5,35 @@ export const getOperandLabel = (
|
||||
operand: ViewFilterOperand | null | undefined,
|
||||
) => {
|
||||
switch (operand) {
|
||||
case ViewFilterOperand.Contains:
|
||||
case ViewFilterOperand.CONTAINS:
|
||||
return t`Contains`;
|
||||
case ViewFilterOperand.DoesNotContain:
|
||||
case ViewFilterOperand.DOES_NOT_CONTAIN:
|
||||
return t`Doesn't contain`;
|
||||
case ViewFilterOperand.GreaterThanOrEqual:
|
||||
case ViewFilterOperand.GREATER_THAN_OR_EQUAL:
|
||||
return t`Greater than or equal`;
|
||||
case ViewFilterOperand.LessThanOrEqual:
|
||||
case ViewFilterOperand.LESS_THAN_OR_EQUAL:
|
||||
return t`Less than or equal`;
|
||||
case ViewFilterOperand.IsBefore:
|
||||
case ViewFilterOperand.IS_BEFORE:
|
||||
return t`Is before`;
|
||||
case ViewFilterOperand.IsAfter:
|
||||
case ViewFilterOperand.IS_AFTER:
|
||||
return t`Is after`;
|
||||
case ViewFilterOperand.Is:
|
||||
case ViewFilterOperand.IS:
|
||||
return t`Is`;
|
||||
case ViewFilterOperand.IsNot:
|
||||
case ViewFilterOperand.IS_NOT:
|
||||
return t`Is not`;
|
||||
case ViewFilterOperand.IsNotNull:
|
||||
case ViewFilterOperand.IS_NOT_NULL:
|
||||
return t`Is not null`;
|
||||
case ViewFilterOperand.IsEmpty:
|
||||
case ViewFilterOperand.IS_EMPTY:
|
||||
return t`Is empty`;
|
||||
case ViewFilterOperand.IsNotEmpty:
|
||||
case ViewFilterOperand.IS_NOT_EMPTY:
|
||||
return t`Is not empty`;
|
||||
case ViewFilterOperand.IsRelative:
|
||||
case ViewFilterOperand.IS_RELATIVE:
|
||||
return t`Is relative`;
|
||||
case ViewFilterOperand.IsInPast:
|
||||
case ViewFilterOperand.IS_IN_PAST:
|
||||
return t`Is in past`;
|
||||
case ViewFilterOperand.IsInFuture:
|
||||
case ViewFilterOperand.IS_IN_FUTURE:
|
||||
return t`Is in future`;
|
||||
case ViewFilterOperand.IsToday:
|
||||
case ViewFilterOperand.IS_TODAY:
|
||||
return t`Is today`;
|
||||
default:
|
||||
return '';
|
||||
@@ -44,31 +44,31 @@ export const getOperandLabelShort = (
|
||||
operand: ViewFilterOperand | null | undefined,
|
||||
) => {
|
||||
switch (operand) {
|
||||
case ViewFilterOperand.Is:
|
||||
case ViewFilterOperand.Contains:
|
||||
case ViewFilterOperand.IS:
|
||||
case ViewFilterOperand.CONTAINS:
|
||||
return ': ';
|
||||
case ViewFilterOperand.IsNot:
|
||||
case ViewFilterOperand.DoesNotContain:
|
||||
case ViewFilterOperand.IS_NOT:
|
||||
case ViewFilterOperand.DOES_NOT_CONTAIN:
|
||||
return t`: Not`;
|
||||
case ViewFilterOperand.IsNotNull:
|
||||
case ViewFilterOperand.IS_NOT_NULL:
|
||||
return t`: NotNull`;
|
||||
case ViewFilterOperand.IsNotEmpty:
|
||||
case ViewFilterOperand.IS_NOT_EMPTY:
|
||||
return t`: NotEmpty`;
|
||||
case ViewFilterOperand.IsEmpty:
|
||||
case ViewFilterOperand.IS_EMPTY:
|
||||
return t`: Empty`;
|
||||
case ViewFilterOperand.GreaterThanOrEqual:
|
||||
case ViewFilterOperand.GREATER_THAN_OR_EQUAL:
|
||||
return '\u00A0≥ ';
|
||||
case ViewFilterOperand.LessThanOrEqual:
|
||||
case ViewFilterOperand.LESS_THAN_OR_EQUAL:
|
||||
return '\u00A0≤ ';
|
||||
case ViewFilterOperand.IsBefore:
|
||||
case ViewFilterOperand.IS_BEFORE:
|
||||
return '\u00A0< ';
|
||||
case ViewFilterOperand.IsAfter:
|
||||
case ViewFilterOperand.IS_AFTER:
|
||||
return '\u00A0> ';
|
||||
case ViewFilterOperand.IsInPast:
|
||||
case ViewFilterOperand.IS_IN_PAST:
|
||||
return t`: Past`;
|
||||
case ViewFilterOperand.IsInFuture:
|
||||
case ViewFilterOperand.IS_IN_FUTURE:
|
||||
return t`: Future`;
|
||||
case ViewFilterOperand.IsToday:
|
||||
case ViewFilterOperand.IS_TODAY:
|
||||
return t`: Today`;
|
||||
default:
|
||||
return ': ';
|
||||
|
||||
+15
-15
@@ -2,22 +2,22 @@ import { ViewFilterOperand } from 'twenty-shared/types';
|
||||
|
||||
export const isFilterOperandExpectingValue = (operand: ViewFilterOperand) => {
|
||||
switch (operand) {
|
||||
case ViewFilterOperand.IsNotNull:
|
||||
case ViewFilterOperand.IsEmpty:
|
||||
case ViewFilterOperand.IsNotEmpty:
|
||||
case ViewFilterOperand.IsInPast:
|
||||
case ViewFilterOperand.IsInFuture:
|
||||
case ViewFilterOperand.IsToday:
|
||||
case ViewFilterOperand.IS_NOT_NULL:
|
||||
case ViewFilterOperand.IS_EMPTY:
|
||||
case ViewFilterOperand.IS_NOT_EMPTY:
|
||||
case ViewFilterOperand.IS_IN_PAST:
|
||||
case ViewFilterOperand.IS_IN_FUTURE:
|
||||
case ViewFilterOperand.IS_TODAY:
|
||||
return false;
|
||||
case ViewFilterOperand.IsNot:
|
||||
case ViewFilterOperand.Contains:
|
||||
case ViewFilterOperand.DoesNotContain:
|
||||
case ViewFilterOperand.GreaterThanOrEqual:
|
||||
case ViewFilterOperand.LessThanOrEqual:
|
||||
case ViewFilterOperand.IsBefore:
|
||||
case ViewFilterOperand.IsAfter:
|
||||
case ViewFilterOperand.Is:
|
||||
case ViewFilterOperand.IsRelative:
|
||||
case ViewFilterOperand.IS_NOT:
|
||||
case ViewFilterOperand.CONTAINS:
|
||||
case ViewFilterOperand.DOES_NOT_CONTAIN:
|
||||
case ViewFilterOperand.GREATER_THAN_OR_EQUAL:
|
||||
case ViewFilterOperand.LESS_THAN_OR_EQUAL:
|
||||
case ViewFilterOperand.IS_BEFORE:
|
||||
case ViewFilterOperand.IS_AFTER:
|
||||
case ViewFilterOperand.IS:
|
||||
case ViewFilterOperand.IS_RELATIVE:
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
|
||||
+2
-2
@@ -33,7 +33,7 @@ export const useRecordCalendarQueryDateRangeFilter = (selectedDate: Date) => {
|
||||
id: DATE_RANGE_FILTER_AFTER_ID,
|
||||
fieldMetadataId: dateRangeFilterFieldMetadataId,
|
||||
value: `${firstDayOfFirstWeek.toISOString()}`,
|
||||
operand: RecordFilterOperand.IsAfter,
|
||||
operand: RecordFilterOperand.IS_AFTER,
|
||||
type: 'DATE',
|
||||
label: 'After',
|
||||
displayValue: `${firstDayOfFirstWeek.toISOString()}`,
|
||||
@@ -43,7 +43,7 @@ export const useRecordCalendarQueryDateRangeFilter = (selectedDate: Date) => {
|
||||
id: DATE_RANGE_FILTER_BEFORE_ID,
|
||||
fieldMetadataId: dateRangeFilterFieldMetadataId,
|
||||
value: `${lastDayOfLastWeek.toISOString()}`,
|
||||
operand: RecordFilterOperand.IsBefore,
|
||||
operand: RecordFilterOperand.IS_BEFORE,
|
||||
type: 'DATE',
|
||||
label: 'Before',
|
||||
displayValue: `${lastDayOfLastWeek.toISOString()}`,
|
||||
|
||||
+1
-1
@@ -92,7 +92,7 @@ export const RecordDetailRelationSection = ({
|
||||
const filterQueryParams = {
|
||||
filter: {
|
||||
[relationFieldMetadataItem?.name || '']: {
|
||||
[ViewFilterOperand.Is]: {
|
||||
[ViewFilterOperand.IS]: {
|
||||
selectedRecordIds: [recordId],
|
||||
},
|
||||
},
|
||||
|
||||
+2
-2
@@ -40,7 +40,7 @@ describe('useRemoveRecordFilter', () => {
|
||||
id: 'filter-1',
|
||||
fieldMetadataId: 'field-1',
|
||||
value: 'test-value',
|
||||
operand: ViewFilterOperand.Contains,
|
||||
operand: ViewFilterOperand.CONTAINS,
|
||||
displayValue: 'test-value',
|
||||
label: 'Test Field',
|
||||
type: FieldMetadataType.TEXT,
|
||||
@@ -85,7 +85,7 @@ describe('useRemoveRecordFilter', () => {
|
||||
id: 'filter-1',
|
||||
fieldMetadataId: 'field-1',
|
||||
value: 'test-value',
|
||||
operand: ViewFilterOperand.Contains,
|
||||
operand: ViewFilterOperand.CONTAINS,
|
||||
displayValue: 'test-value',
|
||||
label: 'Test Field',
|
||||
type: FieldMetadataType.TEXT,
|
||||
|
||||
+3
-3
@@ -34,7 +34,7 @@ describe('useUpsertRecordFilter', () => {
|
||||
id: 'filter-1',
|
||||
fieldMetadataId: 'field-1',
|
||||
value: 'test-value',
|
||||
operand: ViewFilterOperand.Contains,
|
||||
operand: ViewFilterOperand.CONTAINS,
|
||||
displayValue: 'test-value',
|
||||
label: 'Test Field',
|
||||
type: FieldMetadataType.TEXT,
|
||||
@@ -68,7 +68,7 @@ describe('useUpsertRecordFilter', () => {
|
||||
id: 'filter-1',
|
||||
fieldMetadataId: 'field-1',
|
||||
value: 'initial-value',
|
||||
operand: ViewFilterOperand.Contains,
|
||||
operand: ViewFilterOperand.CONTAINS,
|
||||
displayValue: 'initial-value',
|
||||
label: 'Test Field',
|
||||
type: FieldMetadataType.TEXT,
|
||||
@@ -78,7 +78,7 @@ describe('useUpsertRecordFilter', () => {
|
||||
id: 'filter-1',
|
||||
fieldMetadataId: 'field-1',
|
||||
value: 'updated-value',
|
||||
operand: ViewFilterOperand.Contains,
|
||||
operand: ViewFilterOperand.CONTAINS,
|
||||
displayValue: 'updated-value',
|
||||
label: 'Test Field',
|
||||
type: FieldMetadataType.TEXT,
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ export const useCheckIsSoftDeleteFilter = () => {
|
||||
});
|
||||
|
||||
const isNotEmptyFilter =
|
||||
recordFilter.operand === RecordFilterOperand.IsNotEmpty;
|
||||
recordFilter.operand === RecordFilterOperand.IS_NOT_EMPTY;
|
||||
|
||||
return (
|
||||
foundFieldMetadataItem.name === SOFT_DELETE_FILTER_FIELD_NAME &&
|
||||
|
||||
+34
-34
@@ -46,7 +46,7 @@ describe('computeViewRecordGqlOperationFilter', () => {
|
||||
value: companiesMock[0].name,
|
||||
fieldMetadataId: companyMockNameFieldMetadataId.id,
|
||||
displayValue: companiesMock[0].name,
|
||||
operand: RecordFilterOperand.Contains,
|
||||
operand: RecordFilterOperand.CONTAINS,
|
||||
type: 'TEXT',
|
||||
label: 'Name',
|
||||
};
|
||||
@@ -89,7 +89,7 @@ describe('computeViewRecordGqlOperationFilter', () => {
|
||||
value: companiesMock[0].name,
|
||||
fieldMetadataId: companyMockNameFieldMetadataId.id,
|
||||
displayValue: companiesMock[0].name,
|
||||
operand: ViewFilterOperand.Contains,
|
||||
operand: ViewFilterOperand.CONTAINS,
|
||||
type: FieldMetadataType.TEXT,
|
||||
label: 'Name',
|
||||
};
|
||||
@@ -99,7 +99,7 @@ describe('computeViewRecordGqlOperationFilter', () => {
|
||||
value: '1000',
|
||||
fieldMetadataId: companyMockEmployeesFieldMetadataId.id,
|
||||
displayValue: '1000',
|
||||
operand: ViewFilterOperand.GreaterThanOrEqual,
|
||||
operand: ViewFilterOperand.GREATER_THAN_OR_EQUAL,
|
||||
type: FieldMetadataType.NUMBER,
|
||||
label: 'Employees',
|
||||
};
|
||||
@@ -144,7 +144,7 @@ describe('should work as expected for the different field types', () => {
|
||||
value: '123 Main St',
|
||||
fieldMetadataId: companyMockAddressFieldMetadataId.id,
|
||||
displayValue: '123 Main St',
|
||||
operand: ViewFilterOperand.Contains,
|
||||
operand: ViewFilterOperand.CONTAINS,
|
||||
type: FieldMetadataType.ADDRESS,
|
||||
label: 'Address',
|
||||
};
|
||||
@@ -154,7 +154,7 @@ describe('should work as expected for the different field types', () => {
|
||||
value: '123 Main St',
|
||||
fieldMetadataId: companyMockAddressFieldMetadataId?.id,
|
||||
displayValue: '123 Main St',
|
||||
operand: ViewFilterOperand.DoesNotContain,
|
||||
operand: ViewFilterOperand.DOES_NOT_CONTAIN,
|
||||
type: FieldMetadataType.ADDRESS,
|
||||
label: 'Address',
|
||||
};
|
||||
@@ -164,7 +164,7 @@ describe('should work as expected for the different field types', () => {
|
||||
value: '',
|
||||
fieldMetadataId: companyMockAddressFieldMetadataId?.id,
|
||||
displayValue: '',
|
||||
operand: ViewFilterOperand.IsEmpty,
|
||||
operand: ViewFilterOperand.IS_EMPTY,
|
||||
type: FieldMetadataType.ADDRESS,
|
||||
label: 'Address',
|
||||
};
|
||||
@@ -174,7 +174,7 @@ describe('should work as expected for the different field types', () => {
|
||||
value: '',
|
||||
fieldMetadataId: companyMockAddressFieldMetadataId?.id,
|
||||
displayValue: '',
|
||||
operand: ViewFilterOperand.IsNotEmpty,
|
||||
operand: ViewFilterOperand.IS_NOT_EMPTY,
|
||||
label: 'Address',
|
||||
type: FieldMetadataType.ADDRESS,
|
||||
};
|
||||
@@ -608,7 +608,7 @@ describe('should work as expected for the different field types', () => {
|
||||
value: '1234567890',
|
||||
fieldMetadataId: personMockPhonesFieldMetadataId.id,
|
||||
displayValue: '1234567890',
|
||||
operand: ViewFilterOperand.Contains,
|
||||
operand: ViewFilterOperand.CONTAINS,
|
||||
label: 'Phones',
|
||||
type: FieldMetadataType.PHONES,
|
||||
};
|
||||
@@ -618,7 +618,7 @@ describe('should work as expected for the different field types', () => {
|
||||
value: '1234567890',
|
||||
fieldMetadataId: personMockPhonesFieldMetadataId.id,
|
||||
displayValue: '1234567890',
|
||||
operand: ViewFilterOperand.DoesNotContain,
|
||||
operand: ViewFilterOperand.DOES_NOT_CONTAIN,
|
||||
label: 'Phones',
|
||||
type: FieldMetadataType.PHONES,
|
||||
};
|
||||
@@ -628,7 +628,7 @@ describe('should work as expected for the different field types', () => {
|
||||
value: '',
|
||||
fieldMetadataId: personMockPhonesFieldMetadataId?.id,
|
||||
displayValue: '',
|
||||
operand: ViewFilterOperand.IsEmpty,
|
||||
operand: ViewFilterOperand.IS_EMPTY,
|
||||
label: 'Phones',
|
||||
type: FieldMetadataType.PHONES,
|
||||
};
|
||||
@@ -638,7 +638,7 @@ describe('should work as expected for the different field types', () => {
|
||||
value: '',
|
||||
fieldMetadataId: personMockPhonesFieldMetadataId?.id,
|
||||
displayValue: '',
|
||||
operand: ViewFilterOperand.IsNotEmpty,
|
||||
operand: ViewFilterOperand.IS_NOT_EMPTY,
|
||||
label: 'Phones',
|
||||
type: FieldMetadataType.PHONES,
|
||||
};
|
||||
@@ -833,7 +833,7 @@ describe('should work as expected for the different field types', () => {
|
||||
value: 'test@test.com',
|
||||
fieldMetadataId: personMockEmailFieldMetadataId.id,
|
||||
displayValue: 'test@test.com',
|
||||
operand: ViewFilterOperand.Contains,
|
||||
operand: ViewFilterOperand.CONTAINS,
|
||||
label: 'Emails',
|
||||
type: FieldMetadataType.EMAILS,
|
||||
};
|
||||
@@ -843,7 +843,7 @@ describe('should work as expected for the different field types', () => {
|
||||
value: 'test@test.com',
|
||||
fieldMetadataId: personMockEmailFieldMetadataId.id,
|
||||
displayValue: 'test@test.com',
|
||||
operand: ViewFilterOperand.DoesNotContain,
|
||||
operand: ViewFilterOperand.DOES_NOT_CONTAIN,
|
||||
label: 'Emails',
|
||||
type: FieldMetadataType.EMAILS,
|
||||
};
|
||||
@@ -853,7 +853,7 @@ describe('should work as expected for the different field types', () => {
|
||||
value: '',
|
||||
fieldMetadataId: personMockEmailFieldMetadataId?.id,
|
||||
displayValue: '',
|
||||
operand: ViewFilterOperand.IsEmpty,
|
||||
operand: ViewFilterOperand.IS_EMPTY,
|
||||
label: 'Emails',
|
||||
type: FieldMetadataType.EMAILS,
|
||||
};
|
||||
@@ -863,7 +863,7 @@ describe('should work as expected for the different field types', () => {
|
||||
value: '',
|
||||
fieldMetadataId: personMockEmailFieldMetadataId?.id,
|
||||
displayValue: '',
|
||||
operand: ViewFilterOperand.IsNotEmpty,
|
||||
operand: ViewFilterOperand.IS_NOT_EMPTY,
|
||||
label: 'Emails',
|
||||
type: FieldMetadataType.EMAILS,
|
||||
};
|
||||
@@ -1034,7 +1034,7 @@ describe('should work as expected for the different field types', () => {
|
||||
value: '2024-09-17T20:46:58.922Z',
|
||||
fieldMetadataId: companyMockDateFieldMetadataId?.id,
|
||||
displayValue: '2024-09-17T20:46:58.922Z',
|
||||
operand: ViewFilterOperand.IsAfter,
|
||||
operand: ViewFilterOperand.IS_AFTER,
|
||||
label: 'Created At',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
};
|
||||
@@ -1044,7 +1044,7 @@ describe('should work as expected for the different field types', () => {
|
||||
value: '2024-09-17T20:46:58.922Z',
|
||||
fieldMetadataId: companyMockDateFieldMetadataId?.id,
|
||||
displayValue: '2024-09-17T20:46:58.922Z',
|
||||
operand: ViewFilterOperand.IsBefore,
|
||||
operand: ViewFilterOperand.IS_BEFORE,
|
||||
label: 'Created At',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
};
|
||||
@@ -1054,7 +1054,7 @@ describe('should work as expected for the different field types', () => {
|
||||
value: '2024-09-17T20:46:58.922Z',
|
||||
fieldMetadataId: companyMockDateFieldMetadataId?.id,
|
||||
displayValue: '2024-09-17T20:46:58.922Z',
|
||||
operand: ViewFilterOperand.Is,
|
||||
operand: ViewFilterOperand.IS,
|
||||
label: 'Created At',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
};
|
||||
@@ -1064,7 +1064,7 @@ describe('should work as expected for the different field types', () => {
|
||||
value: '',
|
||||
fieldMetadataId: companyMockDateFieldMetadataId?.id,
|
||||
displayValue: '',
|
||||
operand: ViewFilterOperand.IsEmpty,
|
||||
operand: ViewFilterOperand.IS_EMPTY,
|
||||
label: 'Created At',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
};
|
||||
@@ -1074,7 +1074,7 @@ describe('should work as expected for the different field types', () => {
|
||||
value: '',
|
||||
fieldMetadataId: companyMockDateFieldMetadataId?.id,
|
||||
displayValue: '',
|
||||
operand: ViewFilterOperand.IsNotEmpty,
|
||||
operand: ViewFilterOperand.IS_NOT_EMPTY,
|
||||
label: 'Created At',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
};
|
||||
@@ -1147,7 +1147,7 @@ describe('should work as expected for the different field types', () => {
|
||||
value: '1000',
|
||||
fieldMetadataId: companyMockEmployeesFieldMetadataId?.id,
|
||||
displayValue: '1000',
|
||||
operand: ViewFilterOperand.GreaterThanOrEqual,
|
||||
operand: ViewFilterOperand.GREATER_THAN_OR_EQUAL,
|
||||
label: 'Employees',
|
||||
type: FieldMetadataType.NUMBER,
|
||||
};
|
||||
@@ -1157,7 +1157,7 @@ describe('should work as expected for the different field types', () => {
|
||||
value: '1000',
|
||||
fieldMetadataId: companyMockEmployeesFieldMetadataId?.id,
|
||||
displayValue: '1000',
|
||||
operand: ViewFilterOperand.LessThanOrEqual,
|
||||
operand: ViewFilterOperand.LESS_THAN_OR_EQUAL,
|
||||
label: 'Employees',
|
||||
type: FieldMetadataType.NUMBER,
|
||||
};
|
||||
@@ -1167,7 +1167,7 @@ describe('should work as expected for the different field types', () => {
|
||||
value: '',
|
||||
fieldMetadataId: companyMockEmployeesFieldMetadataId?.id,
|
||||
displayValue: '',
|
||||
operand: ViewFilterOperand.IsEmpty,
|
||||
operand: ViewFilterOperand.IS_EMPTY,
|
||||
label: 'Employees',
|
||||
type: FieldMetadataType.NUMBER,
|
||||
};
|
||||
@@ -1177,7 +1177,7 @@ describe('should work as expected for the different field types', () => {
|
||||
value: '',
|
||||
fieldMetadataId: companyMockEmployeesFieldMetadataId?.id,
|
||||
displayValue: '',
|
||||
operand: ViewFilterOperand.IsNotEmpty,
|
||||
operand: ViewFilterOperand.IS_NOT_EMPTY,
|
||||
label: 'Employees',
|
||||
type: FieldMetadataType.NUMBER,
|
||||
};
|
||||
@@ -1233,7 +1233,7 @@ describe('should work as expected for the different field types', () => {
|
||||
value: '1000',
|
||||
fieldMetadataId: companyMockARRFieldMetadataId?.id,
|
||||
displayValue: '1000',
|
||||
operand: RecordFilterOperand.GreaterThanOrEqual,
|
||||
operand: RecordFilterOperand.GREATER_THAN_OR_EQUAL,
|
||||
subFieldName: 'amountMicros' satisfies Extract<
|
||||
keyof FieldCurrencyValue,
|
||||
'amountMicros'
|
||||
@@ -1247,7 +1247,7 @@ describe('should work as expected for the different field types', () => {
|
||||
value: '1000',
|
||||
fieldMetadataId: companyMockARRFieldMetadataId.id,
|
||||
displayValue: '1000',
|
||||
operand: RecordFilterOperand.LessThanOrEqual,
|
||||
operand: RecordFilterOperand.LESS_THAN_OR_EQUAL,
|
||||
subFieldName: 'amountMicros' satisfies Extract<
|
||||
keyof FieldCurrencyValue,
|
||||
'amountMicros'
|
||||
@@ -1261,7 +1261,7 @@ describe('should work as expected for the different field types', () => {
|
||||
value: '1000',
|
||||
fieldMetadataId: companyMockARRFieldMetadataId.id,
|
||||
displayValue: '1000',
|
||||
operand: RecordFilterOperand.Is,
|
||||
operand: RecordFilterOperand.IS,
|
||||
subFieldName: 'amountMicros' satisfies Extract<
|
||||
keyof FieldCurrencyValue,
|
||||
'amountMicros'
|
||||
@@ -1275,7 +1275,7 @@ describe('should work as expected for the different field types', () => {
|
||||
value: '1000',
|
||||
fieldMetadataId: companyMockARRFieldMetadataId.id,
|
||||
displayValue: '1000',
|
||||
operand: RecordFilterOperand.IsNot,
|
||||
operand: RecordFilterOperand.IS_NOT,
|
||||
subFieldName: 'amountMicros' satisfies Extract<
|
||||
keyof FieldCurrencyValue,
|
||||
'amountMicros'
|
||||
@@ -1343,7 +1343,7 @@ describe('should work as expected for the different field types', () => {
|
||||
value: '["USD"]',
|
||||
fieldMetadataId: companyMockARRFieldMetadataId.id,
|
||||
displayValue: 'USD',
|
||||
operand: RecordFilterOperand.Is,
|
||||
operand: RecordFilterOperand.IS,
|
||||
subFieldName: 'currencyCode' satisfies Extract<
|
||||
keyof FieldCurrencyValue,
|
||||
'currencyCode'
|
||||
@@ -1357,7 +1357,7 @@ describe('should work as expected for the different field types', () => {
|
||||
value: '["USD"]',
|
||||
fieldMetadataId: companyMockARRFieldMetadataId.id,
|
||||
displayValue: 'Not USD',
|
||||
operand: RecordFilterOperand.IsNot,
|
||||
operand: RecordFilterOperand.IS_NOT,
|
||||
subFieldName: 'currencyCode' satisfies Extract<
|
||||
keyof FieldCurrencyValue,
|
||||
'currencyCode'
|
||||
@@ -1411,7 +1411,7 @@ describe('should work as expected for the different field types', () => {
|
||||
value: '["DOG",""]',
|
||||
fieldMetadataId: selectFieldMetadata?.id,
|
||||
displayValue: '["Dog",""]',
|
||||
operand: ViewFilterOperand.Is,
|
||||
operand: ViewFilterOperand.IS,
|
||||
label: 'Select',
|
||||
type: FieldMetadataType.SELECT,
|
||||
};
|
||||
@@ -1421,7 +1421,7 @@ describe('should work as expected for the different field types', () => {
|
||||
value: '["DOG",""]',
|
||||
fieldMetadataId: selectFieldMetadata.id,
|
||||
displayValue: '["Dog",""]',
|
||||
operand: ViewFilterOperand.IsNot,
|
||||
operand: ViewFilterOperand.IS_NOT,
|
||||
label: 'Select',
|
||||
type: FieldMetadataType.SELECT,
|
||||
};
|
||||
@@ -1481,7 +1481,7 @@ describe('should work as expected for the different field types', () => {
|
||||
value: '["option1",""]',
|
||||
fieldMetadataId: multiSelectFieldMetadata.id,
|
||||
displayValue: '["option1",""]',
|
||||
operand: ViewFilterOperand.Contains,
|
||||
operand: ViewFilterOperand.CONTAINS,
|
||||
label: 'MultiSelect',
|
||||
type: FieldMetadataType.MULTI_SELECT,
|
||||
};
|
||||
@@ -1491,7 +1491,7 @@ describe('should work as expected for the different field types', () => {
|
||||
value: '["option1",""]',
|
||||
fieldMetadataId: multiSelectFieldMetadata.id,
|
||||
displayValue: '["option1",""]',
|
||||
operand: ViewFilterOperand.DoesNotContain,
|
||||
operand: ViewFilterOperand.DOES_NOT_CONTAIN,
|
||||
label: 'MultiSelect',
|
||||
type: FieldMetadataType.MULTI_SELECT,
|
||||
};
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@ const MOCK_RECORD_FILTER_FIELDS: RecordFilter = {
|
||||
id: 'filter-1',
|
||||
recordFilterGroupId: 'root-group',
|
||||
fieldMetadataId: 'field-1',
|
||||
operand: RecordFilterOperand.Contains,
|
||||
operand: RecordFilterOperand.CONTAINS,
|
||||
value: 'value-1',
|
||||
displayValue: 'Display Value 1',
|
||||
label: 'Label 1',
|
||||
|
||||
+61
-57
@@ -14,13 +14,13 @@ export type GetRecordFilterOperandsParams = {
|
||||
};
|
||||
|
||||
const emptyOperands = [
|
||||
RecordFilterOperand.IsEmpty,
|
||||
RecordFilterOperand.IsNotEmpty,
|
||||
RecordFilterOperand.IS_EMPTY,
|
||||
RecordFilterOperand.IS_NOT_EMPTY,
|
||||
] as const;
|
||||
|
||||
const relationOperands = [
|
||||
RecordFilterOperand.Is,
|
||||
RecordFilterOperand.IsNot,
|
||||
RecordFilterOperand.IS,
|
||||
RecordFilterOperand.IS_NOT,
|
||||
] as const;
|
||||
|
||||
type FilterOperandMap = {
|
||||
@@ -38,110 +38,114 @@ type CompositeFieldFilterOperandMap = {
|
||||
|
||||
export const FILTER_OPERANDS_MAP = {
|
||||
TEXT: [
|
||||
RecordFilterOperand.Contains,
|
||||
RecordFilterOperand.DoesNotContain,
|
||||
RecordFilterOperand.CONTAINS,
|
||||
RecordFilterOperand.DOES_NOT_CONTAIN,
|
||||
...emptyOperands,
|
||||
],
|
||||
EMAILS: [
|
||||
RecordFilterOperand.Contains,
|
||||
RecordFilterOperand.DoesNotContain,
|
||||
RecordFilterOperand.CONTAINS,
|
||||
RecordFilterOperand.DOES_NOT_CONTAIN,
|
||||
...emptyOperands,
|
||||
],
|
||||
FULL_NAME: [
|
||||
RecordFilterOperand.Contains,
|
||||
RecordFilterOperand.DoesNotContain,
|
||||
RecordFilterOperand.CONTAINS,
|
||||
RecordFilterOperand.DOES_NOT_CONTAIN,
|
||||
...emptyOperands,
|
||||
],
|
||||
ADDRESS: [
|
||||
RecordFilterOperand.Contains,
|
||||
RecordFilterOperand.DoesNotContain,
|
||||
RecordFilterOperand.CONTAINS,
|
||||
RecordFilterOperand.DOES_NOT_CONTAIN,
|
||||
...emptyOperands,
|
||||
],
|
||||
LINKS: [
|
||||
RecordFilterOperand.Contains,
|
||||
RecordFilterOperand.DoesNotContain,
|
||||
RecordFilterOperand.CONTAINS,
|
||||
RecordFilterOperand.DOES_NOT_CONTAIN,
|
||||
...emptyOperands,
|
||||
],
|
||||
PHONES: [
|
||||
RecordFilterOperand.Contains,
|
||||
RecordFilterOperand.DoesNotContain,
|
||||
RecordFilterOperand.CONTAINS,
|
||||
RecordFilterOperand.DOES_NOT_CONTAIN,
|
||||
...emptyOperands,
|
||||
],
|
||||
CURRENCY: [
|
||||
RecordFilterOperand.GreaterThanOrEqual,
|
||||
RecordFilterOperand.LessThanOrEqual,
|
||||
RecordFilterOperand.GREATER_THAN_OR_EQUAL,
|
||||
RecordFilterOperand.LESS_THAN_OR_EQUAL,
|
||||
...emptyOperands,
|
||||
],
|
||||
NUMBER: [
|
||||
RecordFilterOperand.GreaterThanOrEqual,
|
||||
RecordFilterOperand.LessThanOrEqual,
|
||||
RecordFilterOperand.GREATER_THAN_OR_EQUAL,
|
||||
RecordFilterOperand.LESS_THAN_OR_EQUAL,
|
||||
...emptyOperands,
|
||||
],
|
||||
RAW_JSON: [
|
||||
RecordFilterOperand.Contains,
|
||||
RecordFilterOperand.DoesNotContain,
|
||||
RecordFilterOperand.CONTAINS,
|
||||
RecordFilterOperand.DOES_NOT_CONTAIN,
|
||||
...emptyOperands,
|
||||
],
|
||||
DATE_TIME: [
|
||||
RecordFilterOperand.Is,
|
||||
RecordFilterOperand.IsRelative,
|
||||
RecordFilterOperand.IsInPast,
|
||||
RecordFilterOperand.IsInFuture,
|
||||
RecordFilterOperand.IsToday,
|
||||
RecordFilterOperand.IsBefore,
|
||||
RecordFilterOperand.IsAfter,
|
||||
RecordFilterOperand.IS,
|
||||
RecordFilterOperand.IS_RELATIVE,
|
||||
RecordFilterOperand.IS_IN_PAST,
|
||||
RecordFilterOperand.IS_IN_FUTURE,
|
||||
RecordFilterOperand.IS_TODAY,
|
||||
RecordFilterOperand.IS_BEFORE,
|
||||
RecordFilterOperand.IS_AFTER,
|
||||
...emptyOperands,
|
||||
],
|
||||
DATE: [
|
||||
RecordFilterOperand.Is,
|
||||
RecordFilterOperand.IsRelative,
|
||||
RecordFilterOperand.IsInPast,
|
||||
RecordFilterOperand.IsInFuture,
|
||||
RecordFilterOperand.IsToday,
|
||||
RecordFilterOperand.IsBefore,
|
||||
RecordFilterOperand.IsAfter,
|
||||
RecordFilterOperand.IS,
|
||||
RecordFilterOperand.IS_RELATIVE,
|
||||
RecordFilterOperand.IS_IN_PAST,
|
||||
RecordFilterOperand.IS_IN_FUTURE,
|
||||
RecordFilterOperand.IS_TODAY,
|
||||
RecordFilterOperand.IS_BEFORE,
|
||||
RecordFilterOperand.IS_AFTER,
|
||||
...emptyOperands,
|
||||
],
|
||||
RATING: [
|
||||
RecordFilterOperand.Is,
|
||||
RecordFilterOperand.GreaterThanOrEqual,
|
||||
RecordFilterOperand.LessThanOrEqual,
|
||||
RecordFilterOperand.IS,
|
||||
RecordFilterOperand.GREATER_THAN_OR_EQUAL,
|
||||
RecordFilterOperand.LESS_THAN_OR_EQUAL,
|
||||
...emptyOperands,
|
||||
],
|
||||
RELATION: [...relationOperands, ...emptyOperands],
|
||||
MULTI_SELECT: [
|
||||
RecordFilterOperand.Contains,
|
||||
RecordFilterOperand.DoesNotContain,
|
||||
RecordFilterOperand.CONTAINS,
|
||||
RecordFilterOperand.DOES_NOT_CONTAIN,
|
||||
...emptyOperands,
|
||||
],
|
||||
SELECT: [
|
||||
RecordFilterOperand.IS,
|
||||
RecordFilterOperand.IS_NOT,
|
||||
...emptyOperands,
|
||||
],
|
||||
SELECT: [RecordFilterOperand.Is, RecordFilterOperand.IsNot, ...emptyOperands],
|
||||
ACTOR: [
|
||||
RecordFilterOperand.Contains,
|
||||
RecordFilterOperand.DoesNotContain,
|
||||
RecordFilterOperand.CONTAINS,
|
||||
RecordFilterOperand.DOES_NOT_CONTAIN,
|
||||
...emptyOperands,
|
||||
],
|
||||
ARRAY: [
|
||||
RecordFilterOperand.Contains,
|
||||
RecordFilterOperand.DoesNotContain,
|
||||
RecordFilterOperand.CONTAINS,
|
||||
RecordFilterOperand.DOES_NOT_CONTAIN,
|
||||
...emptyOperands,
|
||||
],
|
||||
BOOLEAN: [RecordFilterOperand.Is],
|
||||
TS_VECTOR: [RecordFilterOperand.VectorSearch],
|
||||
UUID: [RecordFilterOperand.Is],
|
||||
BOOLEAN: [RecordFilterOperand.IS],
|
||||
TS_VECTOR: [RecordFilterOperand.VECTOR_SEARCH],
|
||||
UUID: [RecordFilterOperand.IS],
|
||||
} as const satisfies FilterOperandMap;
|
||||
|
||||
export const COMPOSITE_FIELD_FILTER_OPERANDS_MAP = {
|
||||
CURRENCY: {
|
||||
currencyCode: [
|
||||
RecordFilterOperand.Is,
|
||||
RecordFilterOperand.IsNot,
|
||||
RecordFilterOperand.IS,
|
||||
RecordFilterOperand.IS_NOT,
|
||||
...emptyOperands,
|
||||
],
|
||||
amountMicros: [
|
||||
RecordFilterOperand.GreaterThanOrEqual,
|
||||
RecordFilterOperand.LessThanOrEqual,
|
||||
RecordFilterOperand.Is,
|
||||
RecordFilterOperand.IsNot,
|
||||
RecordFilterOperand.GREATER_THAN_OR_EQUAL,
|
||||
RecordFilterOperand.LESS_THAN_OR_EQUAL,
|
||||
RecordFilterOperand.IS,
|
||||
RecordFilterOperand.IS_NOT,
|
||||
...emptyOperands,
|
||||
],
|
||||
},
|
||||
@@ -190,8 +194,8 @@ export const getRecordFilterOperands = ({
|
||||
case 'ACTOR': {
|
||||
if (isFilterOnActorSourceSubField(subFieldName)) {
|
||||
return [
|
||||
RecordFilterOperand.Is,
|
||||
RecordFilterOperand.IsNot,
|
||||
RecordFilterOperand.IS,
|
||||
RecordFilterOperand.IS_NOT,
|
||||
...emptyOperands,
|
||||
];
|
||||
}
|
||||
|
||||
+2
-2
@@ -18,9 +18,9 @@ export const isRecordFilterAboutSoftDelete = ({
|
||||
});
|
||||
|
||||
const valueIsNotEmptyFilter =
|
||||
(recordFilter.operand === RecordFilterOperand.Is &&
|
||||
(recordFilter.operand === RecordFilterOperand.IS &&
|
||||
!isEmpty(recordFilter.value)) ||
|
||||
recordFilter.operand === RecordFilterOperand.IsNotEmpty;
|
||||
recordFilter.operand === RecordFilterOperand.IS_NOT_EMPTY;
|
||||
|
||||
return (
|
||||
foundFieldMetadataItem.name === SOFT_DELETE_FILTER_FIELD_NAME &&
|
||||
|
||||
+5
-5
@@ -10,11 +10,11 @@ export const isRecordFilterConsideredEmpty = (
|
||||
if (
|
||||
(!isDefined(value) || value === '' || value === '[]') &&
|
||||
![
|
||||
RecordFilterOperand.IsEmpty,
|
||||
RecordFilterOperand.IsNotEmpty,
|
||||
RecordFilterOperand.IsInPast,
|
||||
RecordFilterOperand.IsInFuture,
|
||||
RecordFilterOperand.IsToday,
|
||||
RecordFilterOperand.IS_EMPTY,
|
||||
RecordFilterOperand.IS_NOT_EMPTY,
|
||||
RecordFilterOperand.IS_IN_PAST,
|
||||
RecordFilterOperand.IS_IN_FUTURE,
|
||||
RecordFilterOperand.IS_TODAY,
|
||||
].includes(operand)
|
||||
) {
|
||||
return true;
|
||||
|
||||
+12
-12
@@ -35,7 +35,7 @@ export const turnAnyFieldFilterIntoRecordGqlFilter = ({
|
||||
filterValue,
|
||||
fieldMetadataItem,
|
||||
}),
|
||||
operand: RecordFilterOperand.Contains,
|
||||
operand: RecordFilterOperand.CONTAINS,
|
||||
type: 'TEXT',
|
||||
} satisfies RecordFilter);
|
||||
break;
|
||||
@@ -46,7 +46,7 @@ export const turnAnyFieldFilterIntoRecordGqlFilter = ({
|
||||
filterValue,
|
||||
fieldMetadataItem,
|
||||
}),
|
||||
operand: RecordFilterOperand.Contains,
|
||||
operand: RecordFilterOperand.CONTAINS,
|
||||
type: 'ADDRESS',
|
||||
} satisfies RecordFilter);
|
||||
break;
|
||||
@@ -57,7 +57,7 @@ export const turnAnyFieldFilterIntoRecordGqlFilter = ({
|
||||
filterValue,
|
||||
fieldMetadataItem,
|
||||
}),
|
||||
operand: RecordFilterOperand.Contains,
|
||||
operand: RecordFilterOperand.CONTAINS,
|
||||
type: 'LINKS',
|
||||
} satisfies RecordFilter);
|
||||
break;
|
||||
@@ -68,7 +68,7 @@ export const turnAnyFieldFilterIntoRecordGqlFilter = ({
|
||||
filterValue,
|
||||
fieldMetadataItem,
|
||||
}),
|
||||
operand: RecordFilterOperand.Contains,
|
||||
operand: RecordFilterOperand.CONTAINS,
|
||||
type: 'FULL_NAME',
|
||||
} satisfies RecordFilter);
|
||||
break;
|
||||
@@ -79,7 +79,7 @@ export const turnAnyFieldFilterIntoRecordGqlFilter = ({
|
||||
filterValue,
|
||||
fieldMetadataItem,
|
||||
}),
|
||||
operand: RecordFilterOperand.Contains,
|
||||
operand: RecordFilterOperand.CONTAINS,
|
||||
type: 'ARRAY',
|
||||
} satisfies RecordFilter);
|
||||
break;
|
||||
@@ -90,7 +90,7 @@ export const turnAnyFieldFilterIntoRecordGqlFilter = ({
|
||||
filterValue,
|
||||
fieldMetadataItem,
|
||||
}),
|
||||
operand: RecordFilterOperand.Contains,
|
||||
operand: RecordFilterOperand.CONTAINS,
|
||||
type: 'EMAILS',
|
||||
} satisfies RecordFilter);
|
||||
break;
|
||||
@@ -101,7 +101,7 @@ export const turnAnyFieldFilterIntoRecordGqlFilter = ({
|
||||
filterValue,
|
||||
fieldMetadataItem,
|
||||
}),
|
||||
operand: RecordFilterOperand.Contains,
|
||||
operand: RecordFilterOperand.CONTAINS,
|
||||
type: 'PHONES',
|
||||
} satisfies RecordFilter);
|
||||
break;
|
||||
@@ -113,7 +113,7 @@ export const turnAnyFieldFilterIntoRecordGqlFilter = ({
|
||||
filterValue,
|
||||
fieldMetadataItem,
|
||||
}),
|
||||
operand: RecordFilterOperand.Is,
|
||||
operand: RecordFilterOperand.IS,
|
||||
type: 'NUMBER',
|
||||
} satisfies RecordFilter);
|
||||
}
|
||||
@@ -126,7 +126,7 @@ export const turnAnyFieldFilterIntoRecordGqlFilter = ({
|
||||
filterValue,
|
||||
fieldMetadataItem,
|
||||
}),
|
||||
operand: RecordFilterOperand.Is,
|
||||
operand: RecordFilterOperand.IS,
|
||||
type: 'CURRENCY',
|
||||
subFieldName: 'amountMicros',
|
||||
} satisfies RecordFilter);
|
||||
@@ -149,7 +149,7 @@ export const turnAnyFieldFilterIntoRecordGqlFilter = ({
|
||||
filterValue: arrayOfCurrenciesStringified,
|
||||
fieldMetadataItem,
|
||||
}),
|
||||
operand: RecordFilterOperand.Is,
|
||||
operand: RecordFilterOperand.IS,
|
||||
type: 'CURRENCY',
|
||||
subFieldName: 'currencyCode',
|
||||
} satisfies RecordFilter);
|
||||
@@ -177,7 +177,7 @@ export const turnAnyFieldFilterIntoRecordGqlFilter = ({
|
||||
fieldMetadataItem,
|
||||
filterValue: arrayOfSelectValues,
|
||||
}),
|
||||
operand: RecordFilterOperand.Is,
|
||||
operand: RecordFilterOperand.IS,
|
||||
type: 'SELECT',
|
||||
} satisfies RecordFilter);
|
||||
}
|
||||
@@ -204,7 +204,7 @@ export const turnAnyFieldFilterIntoRecordGqlFilter = ({
|
||||
fieldMetadataItem,
|
||||
filterValue: arrayOfSelectValues,
|
||||
}),
|
||||
operand: RecordFilterOperand.Contains,
|
||||
operand: RecordFilterOperand.CONTAINS,
|
||||
type: 'MULTI_SELECT',
|
||||
} satisfies RecordFilter);
|
||||
}
|
||||
|
||||
+1
-1
@@ -57,7 +57,7 @@ export const useHandleToggleTrashColumnFilter = ({
|
||||
const newFilter: RecordFilter = {
|
||||
id: v4(),
|
||||
fieldMetadataId: trashFieldMetadata.id,
|
||||
operand: ViewFilterOperand.IsNotEmpty,
|
||||
operand: ViewFilterOperand.IS_NOT_EMPTY,
|
||||
displayValue: '',
|
||||
type: filterType,
|
||||
label: `Deleted`,
|
||||
|
||||
+45
-45
@@ -38,22 +38,22 @@ describe('buildValueFromFilter', () => {
|
||||
describe('TEXT field type', () => {
|
||||
const testCases = [
|
||||
{
|
||||
operand: ViewFilterOperand.Contains,
|
||||
operand: ViewFilterOperand.CONTAINS,
|
||||
value: 'test',
|
||||
expected: 'test',
|
||||
},
|
||||
{
|
||||
operand: ViewFilterOperand.DoesNotContain,
|
||||
operand: ViewFilterOperand.DOES_NOT_CONTAIN,
|
||||
value: 'test',
|
||||
expected: undefined,
|
||||
},
|
||||
{
|
||||
operand: ViewFilterOperand.IsNotEmpty,
|
||||
operand: ViewFilterOperand.IS_NOT_EMPTY,
|
||||
value: 'test',
|
||||
expected: 'test',
|
||||
},
|
||||
{
|
||||
operand: ViewFilterOperand.IsEmpty,
|
||||
operand: ViewFilterOperand.IS_EMPTY,
|
||||
value: 'test',
|
||||
expected: undefined,
|
||||
},
|
||||
@@ -71,47 +71,47 @@ describe('buildValueFromFilter', () => {
|
||||
describe('DATE_TIME field type', () => {
|
||||
const testCases = [
|
||||
{
|
||||
operand: ViewFilterOperand.Is,
|
||||
operand: ViewFilterOperand.IS,
|
||||
value: '2024-03-20T12:00:00Z',
|
||||
expected: mockDate,
|
||||
},
|
||||
{
|
||||
operand: ViewFilterOperand.IsAfter,
|
||||
operand: ViewFilterOperand.IS_AFTER,
|
||||
value: '2024-03-20T12:00:00Z',
|
||||
expected: mockDate,
|
||||
},
|
||||
{
|
||||
operand: ViewFilterOperand.IsBefore,
|
||||
operand: ViewFilterOperand.IS_BEFORE,
|
||||
value: '2024-03-20T12:00:00Z',
|
||||
expected: mockDate,
|
||||
},
|
||||
{
|
||||
operand: ViewFilterOperand.IsInPast,
|
||||
operand: ViewFilterOperand.IS_IN_PAST,
|
||||
value: '2024-03-20T12:00:00Z',
|
||||
expected: mockDate,
|
||||
},
|
||||
{
|
||||
operand: ViewFilterOperand.IsInFuture,
|
||||
operand: ViewFilterOperand.IS_IN_FUTURE,
|
||||
value: '2024-03-20T12:00:00Z',
|
||||
expected: mockDate,
|
||||
},
|
||||
{
|
||||
operand: ViewFilterOperand.IsToday,
|
||||
operand: ViewFilterOperand.IS_TODAY,
|
||||
value: '',
|
||||
expected: mockDate,
|
||||
},
|
||||
{
|
||||
operand: ViewFilterOperand.IsRelative,
|
||||
operand: ViewFilterOperand.IS_RELATIVE,
|
||||
value: '',
|
||||
expected: mockDate,
|
||||
},
|
||||
{
|
||||
operand: ViewFilterOperand.IsEmpty,
|
||||
operand: ViewFilterOperand.IS_EMPTY,
|
||||
value: '',
|
||||
expected: undefined,
|
||||
},
|
||||
{
|
||||
operand: ViewFilterOperand.IsNotEmpty,
|
||||
operand: ViewFilterOperand.IS_NOT_EMPTY,
|
||||
value: '2024-03-20T12:00:00Z',
|
||||
expected: mockDate,
|
||||
},
|
||||
@@ -135,22 +135,22 @@ describe('buildValueFromFilter', () => {
|
||||
describe('NUMBER field type', () => {
|
||||
const testCases = [
|
||||
{
|
||||
operand: ViewFilterOperand.GreaterThanOrEqual,
|
||||
operand: ViewFilterOperand.GREATER_THAN_OR_EQUAL,
|
||||
value: '5',
|
||||
expected: 6,
|
||||
},
|
||||
{
|
||||
operand: ViewFilterOperand.LessThanOrEqual,
|
||||
operand: ViewFilterOperand.LESS_THAN_OR_EQUAL,
|
||||
value: '5',
|
||||
expected: 4,
|
||||
},
|
||||
{
|
||||
operand: ViewFilterOperand.IsNotEmpty,
|
||||
operand: ViewFilterOperand.IS_NOT_EMPTY,
|
||||
value: '5',
|
||||
expected: 5,
|
||||
},
|
||||
{
|
||||
operand: ViewFilterOperand.IsEmpty,
|
||||
operand: ViewFilterOperand.IS_EMPTY,
|
||||
value: '5',
|
||||
expected: undefined,
|
||||
},
|
||||
@@ -168,12 +168,12 @@ describe('buildValueFromFilter', () => {
|
||||
describe('BOOLEAN field type', () => {
|
||||
const testCases = [
|
||||
{
|
||||
operand: ViewFilterOperand.Is,
|
||||
operand: ViewFilterOperand.IS,
|
||||
value: 'true',
|
||||
expected: true,
|
||||
},
|
||||
{
|
||||
operand: ViewFilterOperand.Is,
|
||||
operand: ViewFilterOperand.IS,
|
||||
value: 'false',
|
||||
expected: false,
|
||||
},
|
||||
@@ -191,22 +191,22 @@ describe('buildValueFromFilter', () => {
|
||||
describe('ARRAY field type', () => {
|
||||
const testCases = [
|
||||
{
|
||||
operand: ViewFilterOperand.Contains,
|
||||
operand: ViewFilterOperand.CONTAINS,
|
||||
value: 'test',
|
||||
expected: 'test',
|
||||
},
|
||||
{
|
||||
operand: ViewFilterOperand.DoesNotContain,
|
||||
operand: ViewFilterOperand.DOES_NOT_CONTAIN,
|
||||
value: 'test',
|
||||
expected: undefined,
|
||||
},
|
||||
{
|
||||
operand: ViewFilterOperand.IsNotEmpty,
|
||||
operand: ViewFilterOperand.IS_NOT_EMPTY,
|
||||
value: 'test',
|
||||
expected: 'test',
|
||||
},
|
||||
{
|
||||
operand: ViewFilterOperand.IsEmpty,
|
||||
operand: ViewFilterOperand.IS_EMPTY,
|
||||
value: 'test',
|
||||
expected: undefined,
|
||||
},
|
||||
@@ -236,7 +236,7 @@ describe('buildValueFromFilter', () => {
|
||||
|
||||
const testCases = [
|
||||
{
|
||||
operand: ViewFilterOperand.Is,
|
||||
operand: ViewFilterOperand.IS,
|
||||
value: JSON.stringify({
|
||||
isCurrentWorkspaceMemberSelected: false,
|
||||
selectedRecordIds: ['record-1'],
|
||||
@@ -246,7 +246,7 @@ describe('buildValueFromFilter', () => {
|
||||
expected: 'record-1',
|
||||
},
|
||||
{
|
||||
operand: ViewFilterOperand.Is,
|
||||
operand: ViewFilterOperand.IS,
|
||||
value: JSON.stringify({
|
||||
isCurrentWorkspaceMemberSelected: true,
|
||||
selectedRecordIds: ['record-1'],
|
||||
@@ -256,7 +256,7 @@ describe('buildValueFromFilter', () => {
|
||||
expected: 'current-workspace-member-id',
|
||||
},
|
||||
{
|
||||
operand: ViewFilterOperand.Is,
|
||||
operand: ViewFilterOperand.IS,
|
||||
value: JSON.stringify({
|
||||
isCurrentWorkspaceMemberSelected: false,
|
||||
selectedRecordIds: ['record-1', 'record-2'],
|
||||
@@ -266,7 +266,7 @@ describe('buildValueFromFilter', () => {
|
||||
expected: undefined,
|
||||
},
|
||||
{
|
||||
operand: ViewFilterOperand.IsNot,
|
||||
operand: ViewFilterOperand.IS_NOT,
|
||||
value: JSON.stringify({
|
||||
isCurrentWorkspaceMemberSelected: false,
|
||||
selectedRecordIds: ['record-1'],
|
||||
@@ -276,7 +276,7 @@ describe('buildValueFromFilter', () => {
|
||||
expected: undefined,
|
||||
},
|
||||
{
|
||||
operand: ViewFilterOperand.IsEmpty,
|
||||
operand: ViewFilterOperand.IS_EMPTY,
|
||||
value: JSON.stringify({
|
||||
isCurrentWorkspaceMemberSelected: false,
|
||||
selectedRecordIds: ['record-1'],
|
||||
@@ -309,7 +309,7 @@ describe('buildValueFromFilter', () => {
|
||||
it.each(compositeTypes)(
|
||||
'should return undefined for composite type %s',
|
||||
(type) => {
|
||||
const filter = createTestFilter(ViewFilterOperand.Is, 'test', type);
|
||||
const filter = createTestFilter(ViewFilterOperand.IS, 'test', type);
|
||||
expect(buildValueFromFilter({ filter })).toBeUndefined();
|
||||
},
|
||||
);
|
||||
@@ -317,7 +317,7 @@ describe('buildValueFromFilter', () => {
|
||||
|
||||
describe('RAW_JSON field type', () => {
|
||||
it('should return undefined', () => {
|
||||
const filter = createTestFilter(ViewFilterOperand.Is, 'test', 'RAW_JSON');
|
||||
const filter = createTestFilter(ViewFilterOperand.IS, 'test', 'RAW_JSON');
|
||||
expect(buildValueFromFilter({ filter })).toBeUndefined();
|
||||
});
|
||||
});
|
||||
@@ -346,27 +346,27 @@ describe('buildValueFromFilter', () => {
|
||||
|
||||
const testCases = [
|
||||
{
|
||||
operand: ViewFilterOperand.Is,
|
||||
operand: ViewFilterOperand.IS,
|
||||
value: 'Rating 1',
|
||||
expected: 'RATING_1',
|
||||
},
|
||||
{
|
||||
operand: ViewFilterOperand.IsNotEmpty,
|
||||
operand: ViewFilterOperand.IS_NOT_EMPTY,
|
||||
value: 'Rating 2',
|
||||
expected: 'RATING_2',
|
||||
},
|
||||
{
|
||||
operand: ViewFilterOperand.IsEmpty,
|
||||
operand: ViewFilterOperand.IS_EMPTY,
|
||||
value: 'Rating 1',
|
||||
expected: undefined,
|
||||
},
|
||||
{
|
||||
operand: ViewFilterOperand.GreaterThanOrEqual,
|
||||
operand: ViewFilterOperand.GREATER_THAN_OR_EQUAL,
|
||||
value: 'Rating 1',
|
||||
expected: 'RATING_2',
|
||||
},
|
||||
{
|
||||
operand: ViewFilterOperand.LessThanOrEqual,
|
||||
operand: ViewFilterOperand.LESS_THAN_OR_EQUAL,
|
||||
value: 'Rating 2',
|
||||
expected: 'RATING_1',
|
||||
},
|
||||
@@ -387,7 +387,7 @@ describe('buildValueFromFilter', () => {
|
||||
|
||||
it('should return undefined when option is not found', () => {
|
||||
const filter = createTestFilter(
|
||||
ViewFilterOperand.Is,
|
||||
ViewFilterOperand.IS,
|
||||
'Rating 4',
|
||||
'RATING',
|
||||
);
|
||||
@@ -420,17 +420,17 @@ describe('buildValueFromFilter', () => {
|
||||
|
||||
const testCases = [
|
||||
{
|
||||
operand: ViewFilterOperand.Is,
|
||||
operand: ViewFilterOperand.IS,
|
||||
value: JSON.stringify(['OPTION_1']),
|
||||
expected: 'OPTION_1',
|
||||
},
|
||||
{
|
||||
operand: ViewFilterOperand.IsNot,
|
||||
operand: ViewFilterOperand.IS_NOT,
|
||||
value: JSON.stringify(['OPTION_1']),
|
||||
expected: undefined,
|
||||
},
|
||||
{
|
||||
operand: ViewFilterOperand.IsEmpty,
|
||||
operand: ViewFilterOperand.IS_EMPTY,
|
||||
value: JSON.stringify(['OPTION_1']),
|
||||
expected: undefined,
|
||||
},
|
||||
@@ -451,7 +451,7 @@ describe('buildValueFromFilter', () => {
|
||||
|
||||
it('should handle invalid JSON', () => {
|
||||
const filter = createTestFilter(
|
||||
ViewFilterOperand.Is,
|
||||
ViewFilterOperand.IS,
|
||||
'invalid-json',
|
||||
'SELECT',
|
||||
);
|
||||
@@ -467,17 +467,17 @@ describe('buildValueFromFilter', () => {
|
||||
describe('MULTI_SELECT field type', () => {
|
||||
const testCases = [
|
||||
{
|
||||
operand: ViewFilterOperand.Contains,
|
||||
operand: ViewFilterOperand.CONTAINS,
|
||||
value: JSON.stringify(['OPTION_1', 'OPTION_2']),
|
||||
expected: ['OPTION_1', 'OPTION_2'],
|
||||
},
|
||||
{
|
||||
operand: ViewFilterOperand.DoesNotContain,
|
||||
operand: ViewFilterOperand.DOES_NOT_CONTAIN,
|
||||
value: JSON.stringify(['OPTION_1']),
|
||||
expected: undefined,
|
||||
},
|
||||
{
|
||||
operand: ViewFilterOperand.IsEmpty,
|
||||
operand: ViewFilterOperand.IS_EMPTY,
|
||||
value: JSON.stringify(['OPTION_1']),
|
||||
expected: undefined,
|
||||
},
|
||||
@@ -493,7 +493,7 @@ describe('buildValueFromFilter', () => {
|
||||
|
||||
it('should handle invalid JSON', () => {
|
||||
const filter = createTestFilter(
|
||||
ViewFilterOperand.Contains,
|
||||
ViewFilterOperand.CONTAINS,
|
||||
'invalid-json',
|
||||
'MULTI_SELECT',
|
||||
);
|
||||
@@ -504,7 +504,7 @@ describe('buildValueFromFilter', () => {
|
||||
describe('UUID field type', () => {
|
||||
it('should return the value', () => {
|
||||
const filter = createTestFilter(
|
||||
ViewFilterOperand.Is,
|
||||
ViewFilterOperand.IS,
|
||||
'test-uuid',
|
||||
'UUID',
|
||||
);
|
||||
|
||||
+41
-41
@@ -111,12 +111,12 @@ const computeValueFromFilterText = (
|
||||
value: string,
|
||||
) => {
|
||||
switch (operand) {
|
||||
case ViewFilterOperand.Contains:
|
||||
case ViewFilterOperand.CONTAINS:
|
||||
return value;
|
||||
case ViewFilterOperand.IsNotEmpty:
|
||||
case ViewFilterOperand.IS_NOT_EMPTY:
|
||||
return value;
|
||||
case ViewFilterOperand.IsEmpty:
|
||||
case ViewFilterOperand.DoesNotContain:
|
||||
case ViewFilterOperand.IS_EMPTY:
|
||||
case ViewFilterOperand.DOES_NOT_CONTAIN:
|
||||
return undefined;
|
||||
default:
|
||||
assertUnreachable(operand);
|
||||
@@ -128,17 +128,17 @@ const computeValueFromFilterDate = (
|
||||
value: string,
|
||||
) => {
|
||||
switch (operand) {
|
||||
case ViewFilterOperand.Is:
|
||||
case ViewFilterOperand.IsAfter:
|
||||
case ViewFilterOperand.IsBefore:
|
||||
case ViewFilterOperand.IS:
|
||||
case ViewFilterOperand.IS_AFTER:
|
||||
case ViewFilterOperand.IS_BEFORE:
|
||||
return new Date(value);
|
||||
case ViewFilterOperand.IsToday:
|
||||
case ViewFilterOperand.IsNotEmpty:
|
||||
case ViewFilterOperand.IsInPast:
|
||||
case ViewFilterOperand.IsInFuture:
|
||||
case ViewFilterOperand.IsRelative:
|
||||
case ViewFilterOperand.IS_TODAY:
|
||||
case ViewFilterOperand.IS_NOT_EMPTY:
|
||||
case ViewFilterOperand.IS_IN_PAST:
|
||||
case ViewFilterOperand.IS_IN_FUTURE:
|
||||
case ViewFilterOperand.IS_RELATIVE:
|
||||
return new Date();
|
||||
case ViewFilterOperand.IsEmpty:
|
||||
case ViewFilterOperand.IS_EMPTY:
|
||||
return undefined;
|
||||
default:
|
||||
assertUnreachable(operand);
|
||||
@@ -151,13 +151,13 @@ const computeValueFromFilterNumber = (
|
||||
) => {
|
||||
switch (operand) {
|
||||
//TODO: we shouln't create values from those filters as it makes no sense for the user
|
||||
case ViewFilterOperand.GreaterThanOrEqual:
|
||||
case ViewFilterOperand.GREATER_THAN_OR_EQUAL:
|
||||
return Number(value) + 1;
|
||||
case ViewFilterOperand.LessThanOrEqual:
|
||||
case ViewFilterOperand.LESS_THAN_OR_EQUAL:
|
||||
return Number(value) - 1;
|
||||
case ViewFilterOperand.IsNotEmpty:
|
||||
case ViewFilterOperand.IS_NOT_EMPTY:
|
||||
return Number(value);
|
||||
case ViewFilterOperand.IsEmpty:
|
||||
case ViewFilterOperand.IS_EMPTY:
|
||||
return undefined;
|
||||
default:
|
||||
assertUnreachable(operand);
|
||||
@@ -169,7 +169,7 @@ const computeValueFromFilterBoolean = (
|
||||
value: string,
|
||||
) => {
|
||||
switch (operand) {
|
||||
case ViewFilterOperand.Is:
|
||||
case ViewFilterOperand.IS:
|
||||
return value === 'true';
|
||||
default:
|
||||
assertUnreachable(operand);
|
||||
@@ -181,11 +181,11 @@ const computeValueFromFilterArray = (
|
||||
value: string,
|
||||
) => {
|
||||
switch (operand) {
|
||||
case ViewFilterOperand.Contains:
|
||||
case ViewFilterOperand.IsNotEmpty:
|
||||
case ViewFilterOperand.CONTAINS:
|
||||
case ViewFilterOperand.IS_NOT_EMPTY:
|
||||
return value;
|
||||
case ViewFilterOperand.DoesNotContain:
|
||||
case ViewFilterOperand.IsEmpty:
|
||||
case ViewFilterOperand.DOES_NOT_CONTAIN:
|
||||
case ViewFilterOperand.IS_EMPTY:
|
||||
return undefined;
|
||||
default:
|
||||
assertUnreachable(operand);
|
||||
@@ -203,22 +203,22 @@ const computeValueFromFilterRating = (
|
||||
}
|
||||
|
||||
switch (operand) {
|
||||
case ViewFilterOperand.Is:
|
||||
case ViewFilterOperand.IsNotEmpty:
|
||||
case ViewFilterOperand.IS:
|
||||
case ViewFilterOperand.IS_NOT_EMPTY:
|
||||
return option.value;
|
||||
case ViewFilterOperand.GreaterThanOrEqual: {
|
||||
case ViewFilterOperand.GREATER_THAN_OR_EQUAL: {
|
||||
const plusOne = options?.find(
|
||||
(opt) => opt.position === option.position + 1,
|
||||
)?.value;
|
||||
return plusOne ? plusOne : option.value;
|
||||
}
|
||||
case ViewFilterOperand.LessThanOrEqual: {
|
||||
case ViewFilterOperand.LESS_THAN_OR_EQUAL: {
|
||||
const minusOne = options?.find(
|
||||
(opt) => opt.position === option.position - 1,
|
||||
)?.value;
|
||||
return minusOne ? minusOne : option.value;
|
||||
}
|
||||
case ViewFilterOperand.IsEmpty:
|
||||
case ViewFilterOperand.IS_EMPTY:
|
||||
return undefined;
|
||||
default:
|
||||
assertUnreachable(operand);
|
||||
@@ -231,8 +231,8 @@ const computeValueFromFilterSelect = (
|
||||
options?: FieldMetadataItemOption[],
|
||||
) => {
|
||||
switch (operand) {
|
||||
case ViewFilterOperand.Is:
|
||||
case ViewFilterOperand.IsNotEmpty:
|
||||
case ViewFilterOperand.IS:
|
||||
case ViewFilterOperand.IS_NOT_EMPTY:
|
||||
try {
|
||||
const valueParsed = parseJson<string[]>(value)?.[0];
|
||||
const option = options?.find((option) => option.value === valueParsed);
|
||||
@@ -243,8 +243,8 @@ const computeValueFromFilterSelect = (
|
||||
} catch {
|
||||
return undefined;
|
||||
}
|
||||
case ViewFilterOperand.IsNot:
|
||||
case ViewFilterOperand.IsEmpty:
|
||||
case ViewFilterOperand.IS_NOT:
|
||||
case ViewFilterOperand.IS_EMPTY:
|
||||
return undefined;
|
||||
default:
|
||||
assertUnreachable(operand);
|
||||
@@ -256,16 +256,16 @@ const computeValueFromFilterMultiSelect = (
|
||||
value: string,
|
||||
) => {
|
||||
switch (operand) {
|
||||
case ViewFilterOperand.Contains:
|
||||
case ViewFilterOperand.IsNotEmpty:
|
||||
case ViewFilterOperand.CONTAINS:
|
||||
case ViewFilterOperand.IS_NOT_EMPTY:
|
||||
try {
|
||||
const parsedValue = parseJson<string[]>(value);
|
||||
return parsedValue ? parsedValue : undefined;
|
||||
} catch {
|
||||
return undefined;
|
||||
}
|
||||
case ViewFilterOperand.DoesNotContain:
|
||||
case ViewFilterOperand.IsEmpty:
|
||||
case ViewFilterOperand.DOES_NOT_CONTAIN:
|
||||
case ViewFilterOperand.IS_EMPTY:
|
||||
return undefined;
|
||||
default:
|
||||
assertUnreachable(operand);
|
||||
@@ -280,7 +280,7 @@ const computeValueFromFilterRelation = (
|
||||
label?: string,
|
||||
) => {
|
||||
switch (operand) {
|
||||
case ViewFilterOperand.Is: {
|
||||
case ViewFilterOperand.IS: {
|
||||
const parsedValue = parseJson<{
|
||||
isCurrentWorkspaceMemberSelected: boolean;
|
||||
selectedRecordIds: string[];
|
||||
@@ -296,9 +296,9 @@ const computeValueFromFilterRelation = (
|
||||
}
|
||||
return undefined; //todo
|
||||
}
|
||||
case ViewFilterOperand.IsNot:
|
||||
case ViewFilterOperand.IsNotEmpty: // todo
|
||||
case ViewFilterOperand.IsEmpty:
|
||||
case ViewFilterOperand.IS_NOT:
|
||||
case ViewFilterOperand.IS_NOT_EMPTY: // todo
|
||||
case ViewFilterOperand.IS_EMPTY:
|
||||
return undefined;
|
||||
default:
|
||||
assertUnreachable(operand);
|
||||
@@ -310,7 +310,7 @@ const computeValueFromFilterTSVector = (
|
||||
value: string,
|
||||
) => {
|
||||
switch (operand) {
|
||||
case ViewFilterOperand.VectorSearch:
|
||||
case ViewFilterOperand.VECTOR_SEARCH:
|
||||
return value;
|
||||
default:
|
||||
assertUnreachable(operand);
|
||||
@@ -322,7 +322,7 @@ const computeValueFromFilterUUID = (
|
||||
value: string,
|
||||
) => {
|
||||
switch (operand) {
|
||||
case ViewFilterOperand.Is:
|
||||
case ViewFilterOperand.IS:
|
||||
return value;
|
||||
default:
|
||||
assertUnreachable(operand);
|
||||
|
||||
Reference in New Issue
Block a user