-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Add boolean filtering (#7190) #8700
Conversation
There was a problem hiding this 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 includeFieldMetadataType.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} |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok! Here #8703
case 'BOOLEAN': { | ||
return { | ||
[correspondingField.name]: { | ||
eq: filter.value === 'true', | ||
} as BooleanFilter, | ||
}; | ||
} |
There was a problem hiding this comment.
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
case 'BOOLEAN': { | ||
return { | ||
[correspondingField.name]: { | ||
eq: filter.value === 'true', | ||
} as BooleanFilter, | ||
}; | ||
} |
There was a problem hiding this comment.
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', |
There was a problem hiding this comment.
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'; |
There was a problem hiding this comment.
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.
...ages/twenty-front/src/modules/views/view-filter-value/utils/resolveBooleanViewFilterValue.ts
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The weird filter state issue is happening with all filters and also in 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? |
Thanks @ad-elias for your contribution! |
Link to issue: #7190