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

  1. Go to the JSON:API Query Builder UI.
  2. With the default entity type/bundle of node/article, go to the "Includes" tab in the "Query builder" region.
  3. Add a relationship, e.g., field_image.
  4. Switch to the "Filters" tab and click on the "Add filter" > "Field" dropdown.

    Before the fix, you would observe:
    1. The fields are not grouped by relationship, and they're not alphabetized.
    2. There are invalid fields in the list, including body, comment, field_image, field_tags, node_type, node_type.id, path, revision_uid, and uid.

    After the fix, you should observe:

    1. The fields are now grouped by relationship and alphabetized.
    2. 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, and uid.

    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.

  5. 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, including field_image and field_image.ui.

    After the fix, you should observe: There are no invalid fields in the list. These formerly included field_image and field_image.ui.

User interface changes

Filter and sort field dropdowns now both group relationship fields under their relationship name.

Command icon 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

traviscarden created an issue. See original summary.

traviscarden’s picture

Issue summary: View changes
Status: Active » Needs review
balsama’s picture

Status: Needs review » Reviewed & tested by the community

balsama’s picture

Status: Reviewed & tested by the community » Fixed

Now that this issue is closed, please review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, please credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.