-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
DataViews: add support for NOT IN
operator in filter
#56479
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
10472ea
Add support for not in filter
oandregal f3fb592
Field API: allow declaring which operators a field supports
oandregal d4f9d09
Fix rebase
oandregal ac468f1
Fix: do not change operator
oandregal 40c25c3
Do not register filter if it does not support any operator
oandregal fe31c56
FilterSummary: improve semantics
oandregal c443139
Add aria-checked
oandregal c2a7949
Use Conditions instead of Settings
oandregal 91ebe82
Use Is/Is not
oandregal bf74922
Show condition is submenu trigger
oandregal 162d71f
Use right or left depending on RTL
oandregal 5c1e48c
Fix rebase
oandregal 9497e67
Revert "Use right or left depending on RTL"
oandregal 3819906
Fix rebase
oandregal 0c14102
Fix AddFilter: ignore operator to decide which filters to list
oandregal c493dbf
Fix rebase
oandregal File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,17 @@ | |
import FilterSummary from './filter-summary'; | ||
import AddFilter from './add-filter'; | ||
import ResetFilters from './reset-filters'; | ||
import { ENUMERATION_TYPE, OPERATOR_IN } from './constants'; | ||
import { ENUMERATION_TYPE, OPERATOR_IN, OPERATOR_NOT_IN } from './constants'; | ||
|
||
const operatorsFromField = ( field ) => { | ||
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. Wondering if a better name might be 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. |
||
let operators = field.filterBy?.operators; | ||
if ( ! operators || ! Array.isArray( operators ) ) { | ||
operators = [ OPERATOR_IN, OPERATOR_NOT_IN ]; | ||
} | ||
return operators.filter( ( operator ) => | ||
[ OPERATOR_IN, OPERATOR_NOT_IN ].includes( operator ) | ||
); | ||
}; | ||
|
||
export default function Filters( { fields, view, onChangeView } ) { | ||
const filters = []; | ||
|
@@ -13,15 +23,24 @@ export default function Filters( { fields, view, onChangeView } ) { | |
return; | ||
} | ||
|
||
const operators = operatorsFromField( field ); | ||
if ( operators.length === 0 ) { | ||
return; | ||
} | ||
|
||
switch ( field.type ) { | ||
case ENUMERATION_TYPE: | ||
filters.push( { | ||
field: field.id, | ||
name: field.header, | ||
elements: field.elements || [], | ||
operators, | ||
isVisible: view.filters.some( | ||
( f ) => | ||
f.field === field.id && f.operator === OPERATOR_IN | ||
f.field === field.id && | ||
[ OPERATOR_IN, OPERATOR_NOT_IN ].includes( | ||
f.operator | ||
) | ||
), | ||
} ); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,4 +6,5 @@ export { | |
LAYOUT_LIST, | ||
ENUMERATION_TYPE, | ||
OPERATOR_IN, | ||
OPERATOR_NOT_IN, | ||
} from './constants'; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 wonder how more synthetic languages are handled in this sort of UI (e.g. Notion). I'm not discouraging this bit of string interpolation, just pointing out that we should see how others have done this, so that later we are sure that this UI is localisable.
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.
At some point, the proposal was
Field: value
. Though it didn't scale well when you have more operators (in, not in, starts with, etc.).This is how notion does it (suffers from the same issue):
Gravacao.do.ecra.2023-12-14.as.10.14.24.mov
This is linear (same issue):
Gravacao.do.ecra.2023-12-14.as.10.16.52.mov
The same in other platforms (github, etc.).
I find synthetic languages difficult for this use case because the individual parts (field name, value) are translated separately, and you have no context what they are when translating this string as a whole. Happy to look at examples to improve it.
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 is German:
Gravacao.do.ecra.2023-12-14.as.10.25.31.mov
The gender does affect other parts of the sentence, though the general structure is the same – I'd think what we have here is fine.
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 having a look! Yeah, I think it's doable, and at worst there might be a handful of languages in which the UI reads slightly awkwardly but remains understandable.