Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for Links filtering #5785

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export const formatFieldMetadataItemsAsFilterDefinitions = ({
FieldMetadataType.Email,
FieldMetadataType.Number,
FieldMetadataType.Link,
FieldMetadataType.Links,
FieldMetadataType.FullName,
FieldMetadataType.Address,
FieldMetadataType.Relation,
Expand Down Expand Up @@ -65,6 +66,8 @@ export const getFilterTypeFromFieldType = (fieldType: FieldMetadataType) => {
return 'DATE';
case FieldMetadataType.Link:
return 'LINK';
case FieldMetadataType.Links:
return 'LINKS';
case FieldMetadataType.FullName:
return 'FULL_NAME';
case FieldMetadataType.Number:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export const MultipleFiltersDropdownContent = ({
'PHONE',
'FULL_NAME',
'LINK',
'LINKS',
'ADDRESS',
].includes(filterDefinitionUsedInDropdown.type) && (
<ObjectFilterDropdownTextSearchInput />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export type FilterType =
| 'CURRENCY'
| 'FULL_NAME'
| 'LINK'
| 'LINKS'
| 'RELATION'
| 'ADDRESS'
| 'SELECT'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ describe('getOperandsForFilterType', () => {
],
['ADDRESS', [ViewFilterOperand.Contains, ViewFilterOperand.DoesNotContain]],
['LINK', [ViewFilterOperand.Contains, ViewFilterOperand.DoesNotContain]],
['LINKS', [ViewFilterOperand.Contains, ViewFilterOperand.DoesNotContain]],
['CURRENCY', [ViewFilterOperand.GreaterThan, ViewFilterOperand.LessThan]],
['NUMBER', [ViewFilterOperand.GreaterThan, ViewFilterOperand.LessThan]],
['DATE_TIME', [ViewFilterOperand.GreaterThan, ViewFilterOperand.LessThan]],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ export const getOperandsForFilterType = (
case 'PHONE':
case 'LINK':
return [ViewFilterOperand.Contains, ViewFilterOperand.DoesNotContain];
case 'LINKS':
return [ViewFilterOperand.Contains, ViewFilterOperand.DoesNotContain];
case 'CURRENCY':
case 'NUMBER':
case 'DATE_TIME':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,35 @@ export const turnObjectDropdownFilterIntoQueryFilter = (
);
}
break;
case 'LINKS': {
const linksFilters = generateILikeFiltersForCompositeFields(
rawUIFilter.value,
correspondingField.name,
['primaryLinkLabel', 'primaryLinkUrl'],
);
switch (rawUIFilter.operand) {
case ViewFilterOperand.Contains:
objectRecordFilters.push({
or: linksFilters,
});
break;
case ViewFilterOperand.DoesNotContain:
objectRecordFilters.push({
and: linksFilters.map((filter) => {
return {
not: filter,
};
}),
});
break;
default:
throw new Error(
`Unknown operand ${rawUIFilter.operand} for ${rawUIFilter.definition.type} filter`,
);
}
break;
}

case 'FULL_NAME': {
const fullNameFilters = generateILikeFiltersForCompositeFields(
rawUIFilter.value,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ export class CompositeInputTypeDefinitionFactory {
continue;
}

// Skip secondaryLinks property for LINKS type in Filter input type
if (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we actually try to change packages/twenty-server/src/engine/metadata-modules/field-metadata/composite-types/links.composite-type.ts to have hidden: 'input' on secondaryLinks. This should leverage the continue check line 61 of composite-input-type-definition.factory and avoid adding this extra edge case

kind === InputTypeDefinitionKind.Filter &&
property.name === 'secondaryLinks'
) {
continue;
}

const type = this.inputTypeFactory.create(
property.name,
property.type,
Expand Down
Loading