-
Notifications
You must be signed in to change notification settings - Fork 9
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
Fixed the "Is blank"/"Is not blank" filters for the tags field type #3637
base: develop
Are you sure you want to change the base?
Conversation
Client has complained that the "Is blank"/"Is not blank" filter options present in the custom filter on the grid column filter do not work as an "is empty"/"is non-empty" when set on a tag/array object. I have fixed this by making filter op/values of "= null" and "!= null" also succeed for the cases of "empty array" and "non-empty array". |
|
Toolbox PR: https://github.com/xh/toolbox/pull/712/commits |
}) | ||
// Filter out the null tag value as it isn't a valid value to display in value lists. | ||
// It is set by 'is blank'/'is not blank' filters. | ||
.filter(it => isEqual(it, [null])) |
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.
seems safe enough, independent of whether we continue to put null
in as filter values.
@@ -119,6 +119,6 @@ const switcherButton = hoistCmp.factory<ColumnHeaderFilterModel>(({model, id, ti | |||
text: title, | |||
active: activeTabId === id, | |||
outlined: true, | |||
onClick: () => tabContainerModel.activateTab(id) | |||
onClick: () => model.activateTab(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.
tabContainerModel reference no longer needed on line 114
@@ -128,14 +130,14 @@ export class FieldFilter extends Filter { | |||
switch (op) { |
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.
would rValue
and fValue
be more helpful here? Very hard to keep track of which is which.
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 suggestion! Might I suggest we are even more explicit and call them recordVal
and filterVal
(i.e. more characters for the source than the word 'value')
return columnFilters.some(it => !['=', '!=', 'includes'].includes(it.op)); | ||
return columnFilters.some( | ||
it => | ||
!['=', '!=', 'includes'].includes(it.op) || |
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 code (line 75 and 77) would be easier to grok if we expanded out to equals checks, and did not try to use the javascript 'includes' function . We are already dealing with an 'includes' filter and it is confusing!
@@ -82,7 +82,7 @@ export class CustomRowModel extends HoistModel { | |||
makeObservable(this); | |||
|
|||
let newOp = op as OperatorOptionValue; | |||
if (isNil(value)) { | |||
if (isNil(value) || (isArray(value) && isEmpty(value))) { |
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.
might add a util isEmptyArray()
-- we do this check 4 times in this PR -- might be others in hoist
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.
Thanks for this Jakub - looks and works great! Thanks also for setting up the Toolbox branch, made it very easy to reproduce the issues against develop before testing your fixes in this branch.
@@ -128,14 +130,14 @@ export class FieldFilter extends Filter { | |||
switch (op) { |
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 suggestion! Might I suggest we are even more explicit and call them recordVal
and filterVal
(i.e. more characters for the source than the word 'value')
return filterModel.toDisplayValue(value); | ||
}); | ||
// The parseVal of tag will castArray the value a second time, so make sure to flatten at the end. | ||
const newValues = flatten( |
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.
Minor thing, but I think this would be more readable if we flatten() on line 96 as we push to filterValues
I noticed a minor issue when playing around with this - here's how to reproduce:
I think the fix is probably as simple as syncing the values tab to the filter after clicking the central clear button. |
@jskupsik - wanted to ensure that you saw the comments above from earlier in the summer. It would be good to catch this up and have another look. |
Hoist P/R Checklist
Pull request authors: Review and check off the below. Items that do not apply can also be
checked off to indicate they have been considered. If unclear if a step is relevant, please leave
unchecked and note in comments.
develop
branch as of last change.breaking-change
label + CHANGELOG if so.If your change is still a WIP, please use the "Create draft pull request" option in the split
button below to indicate it is not ready yet for a final review.