-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Date filter improvements (#5917) #7196
Date filter improvements (#5917) #7196
Conversation
…entity definition
…ighlighting is not yet implemented.
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
This PR implements significant improvements to date filtering functionality, addressing the requirements outlined in issue #5917. Key changes include:
- Added new date filter operands: 'Is Before', 'Is After', 'Is Relative', 'Is in the past', 'Is in the future', and 'Is today'
- Introduced
RelativeDatePickerHeader
component for selecting relative date filters - Implemented
ViewFilterValueType
enum to distinguish between static and variable filter values - Enhanced
InternalDatePicker
to support both absolute and relative date selection - Created utility functions for resolving and displaying date filter values
However, there are still issues with applying multiple filters, particularly with the 'and' query where the 'lte' condition is being ignored.
26 file(s) reviewed, 13 comment(s)
Edit PR Review Bot Settings
packages/twenty-front/src/modules/object-record/object-filter-dropdown/types/Filter.ts
Outdated
Show resolved
Hide resolved
packages/twenty-front/src/modules/object-record/object-filter-dropdown/utils/getOperandLabel.ts
Show resolved
Hide resolved
...-front/src/modules/object-record/object-filter-dropdown/utils/getRelativeDateDisplayValue.ts
Outdated
Show resolved
Hide resolved
...ont/src/modules/object-record/record-filter/utils/turnObjectDropdownFilterIntoQueryFilter.ts
Outdated
Show resolved
Hide resolved
...ont/src/modules/object-record/record-filter/utils/turnObjectDropdownFilterIntoQueryFilter.ts
Outdated
Show resolved
Hide resolved
...twenty-front/src/modules/ui/input/components/internal/date/components/InternalDatePicker.tsx
Outdated
Show resolved
Hide resolved
...enty-front/src/modules/ui/input/components/internal/date/components/RelativePickerHeader.tsx
Outdated
Show resolved
Hide resolved
...es/twenty-front/src/modules/ui/input/components/internal/date/constants/RelativeDateUnits.ts
Outdated
Show resolved
Hide resolved
...ages/twenty-front/src/modules/ui/input/components/internal/date/utils/getHighlightedDates.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.
Great work!!! Very cool feature
Some early comments but I didn't do a full review yet
packages/twenty-server/src/modules/view/standard-objects/view-filter.workspace-entity.ts
Outdated
Show resolved
Hide resolved
...c/modules/object-record/object-filter-dropdown/components/MultipleFiltersDropdownContent.tsx
Outdated
Show resolved
Hide resolved
...rc/modules/object-record/object-filter-dropdown/components/ObjectFilterDropdownDateInput.tsx
Outdated
Show resolved
Hide resolved
...-front/src/modules/object-record/object-filter-dropdown/utils/getRelativeDateDisplayValue.ts
Outdated
Show resolved
Hide resolved
...-front/src/modules/ui/input/components/internal/date/components/AbsoluteDatePickerHeader.tsx
Outdated
Show resolved
Hide resolved
...-front/src/modules/ui/input/components/internal/date/components/AbsoluteDatePickerHeader.tsx
Show resolved
Hide resolved
...-front/src/modules/ui/input/components/internal/date/components/AbsoluteDatePickerHeader.tsx
Show resolved
Hide resolved
...twenty-front/src/modules/ui/input/components/internal/date/components/InternalDatePicker.tsx
Show resolved
Hide resolved
@FelixMalfait Ready for another review! @ad-elias Fix tomorrow: selecting a date in 'is' operand and then switching to 'isRelative' operand breaks the filter |
type: FieldMetadataType.SELECT, | ||
label: 'Value type', | ||
description: 'View filter value type', | ||
defaultValue: `'${ViewFilterValueType.STATIC}'`, |
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.
Strange syntax no? Should it just be defaultValue: ViewFilterValueType.STATIC}
? Maybe you did this for a good reason but I don't see why?
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.
I think the quotes are needed to refer to an enum. Same syntax is used in message-channel-message-association.workspace-entity.ts
. I'm not sure but I think without quotes the value would be interpreted as a string, I tried that and it didn't work. The generated table seems correct:
-- Generated by the database client.
CREATE TABLE workspace_1wgvd1injqtife6y4rvfbu3h5."viewFilter"(
id uuid NOT NULL DEFAULT public.uuid_generate_v4(),
"createdAt" timestamp with time zone NOT NULL DEFAULT now(),
"updatedAt" timestamp with time zone NOT NULL DEFAULT now(),
"deletedAt" timestamp with time zone,
position double precision,
name text NOT NULL DEFAULT 'Untitled'::text,
"createdBySource" "viewFilter_createdBySource_enum" NOT NULL DEFAULT 'MANUAL'::"viewFilter_createdBySource_enum",
"createdByWorkspaceMemberId" uuid,
"createdByName" text NOT NULL DEFAULT ''::text,
"displayValue" text NOT NULL DEFAULT ''::text,
"fieldMetadataId" uuid NOT NULL,
operand text NOT NULL DEFAULT 'Contains'::text,
"value" text NOT NULL DEFAULT ''::text,
"valueType" "viewFilter_valueType_enum" NOT NULL DEFAULT 'STATIC'::"viewFilter_valueType_enum",
"viewId" uuid,
PRIMARY KEY(id),
CONSTRAINT FK_06858adf0fb54ec88fa602198ca FOREIGN key("viewId") REFERENCES view(id)
);
CREATE INDEX IDX_5653b106ee9a9e3d5c1c790419a ON workspace_1wgvd1injqtife6y4rvfbu3h5."viewFilter" USING btree ("deletedAt","viewId");
COMMENT ON TABLE workspace_1wgvd1injqtife6y4rvfbu3h5."viewFilter" IS '@graphql({"totalCount": {"enabled": 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.
OK great
...-front/src/modules/ui/input/components/internal/date/components/RelativeDatePickerHeader.tsx
Outdated
Show resolved
Hide resolved
@FelixMalfait I removed the default value and the test is also fixed now! |
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.
Great work!
Log
|
Solves issue twentyhq#5917. This PR is now ready for the first review! Filters do not fully work yet, there's a problem applying multiple filters like the following: ``` { and: [ { [correspondingField.name]: { gte: start.toISOString(), } as DateFilter, }, { [correspondingField.name]: { lte: end.toISOString(), } as DateFilter, }, ], } ``` I'll do my best to dig into it tonight! --------- Co-authored-by: Félix Malfait <[email protected]>
Solves issue #5917.
This PR is now ready for the first review!
Filters do not fully work yet, there's a problem applying multiple filters like the following:
I'll do my best to dig into it tonight!