Problem/Motivation
Currently, the "Add filter" and "Add sort" dropdowns incorrectly display the prefix of complex fields in addition to their properties, e.g., field_image as well as field_image.title, etc. Additionally, they behave display their options differently when it comes to relationship fields. The "Add sort" dropdown groups and alphabetizes relationship fields under their respective relationships, while the "Add filter" dropdown lists all relationship fields in a flat structure in no particular order. This issue is to fix the errors and update the "Add filter" dropdown to match the behavior of the "Add sort" dropdown. It will extract the common functionality to a shared component to prevent code code duplication and divergence in the future.
* #3545512: Errors when sorting
Steps to reproduce
- Go to the JSON:API Query Builder UI.
- With the default entity type/bundle of
node/article, go to the "Includes" tab in the "Query builder" region. - Add a relationship, e.g.,
field_image. -
Switch to the "Filters" tab and click on the "Add filter" > "Field" dropdown.
Before the fix, you would observe:- The fields are not grouped by relationship, and they're not alphabetized.
- There are invalid fields in the list, including
body,comment,field_image,field_tags,node_type,node_type.id,path,revision_uid, anduid.
After the fix, you should observe:
- The fields are now grouped by relationship and alphabetized.
- There are no invalid fields in the list. These formerly included
body,comment,field_image,field_tags,node_type,node_type.id,path,revision_uid, anduid.
Note: Some valid fields have also disappeared from the list, such as
node_type.id. This is because they are not represented in the schema. As in the previous issue, I have erred in the side of caution and preferred to omit valid fields over including invalid fields. This issue is probably more nuanced and can be revisited in the future. -
Switch to the "Filters" tab and click on the "Add filter" > "Field" dropdown.
Before the fix, you would observe: There are invalid fields in the list, includingfield_imageandfield_image.ui.
After the fix, you should observe: There are no invalid fields in the list. These formerly includedfield_imageandfield_image.ui.
User interface changes
Filter and sort field dropdowns now both group relationship fields under their relationship name.
Issue fork jsonapi_query_builder-3550058
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
traviscarden commentedComment #4
balsamaComment #6
balsama