-
Notifications
You must be signed in to change notification settings - Fork 0
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
♻️ - refactor: move filterTransform to DataGrid as prop #83
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -416,17 +416,17 @@ export const DateRangeFilter: Story = { | |
type: "string", | ||
}, | ||
{ | ||
filterTransform: (data) => { | ||
const { dateOfBirth, _data } = data; | ||
const [dateOfBirth__gte = "", dateOfBirth__lte = ""] = | ||
String(dateOfBirth).split("/"); | ||
return { dateOfBirth__gte, dateOfBirth__lte, ..._data }; | ||
}, | ||
name: "dateOfBirth", | ||
type: "daterange", | ||
}, | ||
], | ||
filterable: true, | ||
filterTransform: (data) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am wondering: if I understand correctly, now we will have one function that has to handle the filters transform for all the fields. If that's the case, it could be harder to maintain than specifying the filters transform on the fields themselves 🤔 Maybe the filter transforms could still be specified per field and then when they need to be applied we could iterate over the fields that are active and pass to a filter the output of the previous one? Also, how does this behave in the case of selectable columns when a particular field is disabled? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yes, as I there might be (rare) cases where another filter's value needs to be used as well.
Wouldn't this mean that the order the fields is affect the outcome? The order which is used for presentational purposes (and in the future maybe dynamic?
I'm not sure what you mean here but I think this is up to the user. |
||
const { dateOfBirth, ..._data } = data; | ||
const [dateOfBirth__gte = "", dateOfBirth__lte = ""] = | ||
String(dateOfBirth).split("/"); | ||
return { dateOfBirth__gte, dateOfBirth__lte, ..._data }; | ||
}, | ||
objectList: [ | ||
{ | ||
firstName: "Albert", | ||
|
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.
Maybe good to have a story where multiple fields need to be transformed?
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.
Yes, in general we better stories are useful. TBH I kinda rushed this in to fix our broken PR but better documentation is a good idea.