-
Notifications
You must be signed in to change notification settings - Fork 54
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
Remove broken isAnyOf filter in lists/views #1565
Conversation
…ers depnding on data type.
I'm guessing this is ready for review? |
Yes
Den fre 29 sep. 2023 11:54Richard Olsson ***@***.***> skrev:
… I'm guessing this is ready for review?
—
Reply to this email directly, view it on GitHub
<#1565 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADSE3OZOFHDEFX64542AH7DX42LFZANCNFSM6AAAAAA5LYVKOY>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
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.
In your PR intro you put:
In the future we should probably have the filterOperators based on the type of column, but a lot of these seem to need custom functions because e.g. dates are not stored as dates in the cells.
I agree with this, and it's actually already being done for some column types, e.g. the local_query
type:
It can also be achieved quite easily for other column types, e.g. survey_submitted
which should be interpreted as a date:
diff --git a/src/features/views/components/ViewDataTable/columnTypes/SurveySubmittedColumnType.tsx b/src/features/views/components/ViewDataTable/columnTypes/SurveySubmittedColumnType.tsx
index c973b302..519b3cee 100644
--- a/src/features/views/components/ViewDataTable/columnTypes/SurveySubmittedColumnType.tsx
+++ b/src/features/views/components/ViewDataTable/columnTypes/SurveySubmittedColumnType.tsx
@@ -29,6 +29,8 @@ export default class SurveySubmittedColumnType
return <Cell cell={params.value} />;
},
width: 250,
+ type: 'dateTime',
+ valueGetter: (params) => new Date(params.value.submitted),
};
}
getSearchableStrings(): string[] {
But this PR is actually a step in the opposite direction, because it overrides all filter operators (except local_bool
), regardless of column data type and other configuration options in the colDef
, to always use string operators.
In my opinion, this is not a good solution, because it not only removes functionality that currently exists (e.g. boolean filtering of Smart Search columns, screenshot above), but it also makes future changes more difficult by adding this override that whoever comes back to add more flexible filters will have a very hard time finding.
I think another approach to this is needed, and I'd really wish that we could solve the underlying issue. Maybe if you could elaborate on it, we could work it out together?
if (COLUMN_TYPE.LOCAL_BOOL === col.type) { | ||
return getGridBooleanOperators(); | ||
} else { | ||
return getGridStringOperators().filter((op) => op.value !== 'isAnyOf'); |
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.
This means all columns except local_bool
get handled as strings, regardless of how they've been marked up in the column definition.
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 this came out good and the diff looks nice and clean to me. I suggest you use the GitHub feature to "squash and merge" as a single commit. 😊
Description
This PR removes the broken isAnyOf filter in lists, and customizes the filter type for the local_bool type. In the future we should probably have the filterOperators based on the type of column, but a lot of these seem to need custom functions because e.g. dates are not stored as dates in the cells.
Screenshots
Notes to reviewer
I tried to solve the underlying issue, which is that
GridFilterInputMultipleValues
sometimes receives a single string rather than an array of strings, which crashes the page. Perhaps this could be solved in the future if we think the "any of" filter is important.Related issues
Resolves #1544