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

Add boolean filtering (#7190) #8700

Merged
merged 4 commits into from
Nov 24, 2024

Conversation

ad-elias
Copy link
Contributor

@ad-elias ad-elias commented Nov 23, 2024

filter-icp-true

Link to issue: #7190

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

Added boolean filtering capability across the application, enabling users to filter records based on true/false values with a dedicated dropdown selector component.

  • Added ObjectFilterDropdownBooleanSelect.tsx with true/false selection UI and keyboard navigation support
  • Modified formatFieldMetadataItemsAsFilterDefinitions.ts to include FieldMetadataType.Boolean in supported field types
  • Added boolean case in computeViewRecordGqlOperationFilter.ts to convert string values to booleans for database queries
  • Added resolveBooleanViewFilterValue.ts utility to handle boolean filter value resolution
  • Limited boolean filters to only use 'Is' operand in getOperandsForFilterType.ts, unlike other field types that support additional operands

8 file(s) reviewed, 9 comment(s)
Edit PR Review Bot Settings | Greptile

<SelectableList
selectableListId="boolean-select"
selectableItemIdArray={options.map((option) => option.toString())}
hotkeyScope={RelationPickerHotkeyScope.RelationPicker}
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: using RelationPicker scope for boolean select seems incorrect - should have its own scope

Copy link
Member

Choose a reason for hiding this comment

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

Agree this is weird. Maybe you could create a followup issue for that we can take later? (as this was not introduced by your PR and is already in other places)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok! Here #8703

Comment on lines +859 to +865
case 'BOOLEAN': {
return {
[correspondingField.name]: {
eq: filter.value === 'true',
} as BooleanFilter,
};
}
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: Missing support for IsEmpty/IsNotEmpty operands that are supported by other filter types

Comment on lines +859 to +865
case 'BOOLEAN': {
return {
[correspondingField.name]: {
eq: filter.value === 'true',
} as BooleanFilter,
};
}
Copy link
Contributor

Choose a reason for hiding this comment

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

style: No support for IsNot operand which would be a logical complement to the current implementation

case 'BOOLEAN': {
return {
[correspondingField.name]: {
eq: filter.value === 'true',
Copy link
Contributor

Choose a reason for hiding this comment

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

style: Consider using Boolean(filter.value) instead of filter.value === 'true' for more robust string-to-boolean conversion

export const resolveBooleanViewFilterValue = (
viewFilter: Pick<ViewFilter, 'value'>,
) => {
return viewFilter.value === 'true';
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: Strict equality comparison with string 'true' could miss valid boolean string values like 'True' or '1'. Consider using Boolean() or implementing case-insensitive comparison.

@twentyhq twentyhq deleted a comment from greptile-apps bot Nov 23, 2024
@twentyhq twentyhq deleted a comment from greptile-apps bot Nov 23, 2024
@twentyhq twentyhq deleted a comment from greptile-apps bot Nov 23, 2024
Copy link
Member

@FelixMalfait FelixMalfait left a comment

Choose a reason for hiding this comment

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

Great work! Only issue I found is if you try to set the filter not from the filter menu but from the column, then you end up in a weird state
Screenshot 2024-11-23 at 19 19 03

@FelixMalfait
Copy link
Member

Screenshot 2024-11-23 at 20 08 09 Also this test (which is a bit annoying... Not sure if we should keep it tbh but let's keep it for now)

@ad-elias
Copy link
Contributor Author

ad-elias commented Nov 23, 2024

The weird filter state issue is happening with all filters and also in main branch.

In production, if you add a filter from the column after adding the same filter from the filters menu, you end up in this same broken state.

Let's fix this in a separate PR right after this one?

@FelixMalfait FelixMalfait merged commit bad7ad4 into twentyhq:main Nov 24, 2024
17 checks passed
Copy link

Thanks @ad-elias for your contribution!
This marks your 10th PR on the repo. You're top 3% of all our contributors 🎉
See contributor page - Share on LinkedIn - Share on Twitter

Contributions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants