Skip to content
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

SearchKit - Hierarchical entity displays #31189

Merged
merged 4 commits into from
Oct 2, 2024

Conversation

colemanw
Copy link
Member

@colemanw colemanw commented Sep 26, 2024

Overview

Makes it possible to visualize nested hierarchies in search display tables. Updates 3 Admin tables to do so (screenshots below).

Before

Trying to do this in SearchKit was like... 🤔

After

Now you can! Here's the updated "Administer Contact Types" screen in Admin UI:

image

And here's the "Administer Role Permissions" screen in Standalone:

image

(requires #31191 to show all the grey checkboxes correctly)

And the updated "Manage Groups" screen in Admin UI:

image

Technical Details

Adds HierarchicalEntity APIv4 trait.

A special _depth field is available to these entities. Adding it to the select clause will cause returned records to be sorted in nested order.

Copy link

civibot bot commented Sep 26, 2024

🤖 Thank you for contributing to CiviCRM! ❤️ We will need to test and review this PR. 👷

Introduction for new contributors...
  • If this is your first PR, an admin will greenlight automated testing with the command ok to test or add to whitelist.
  • A series of tests will automatically run. You can see the results at the bottom of this page (if there are any problems, it will include a link to see what went wrong).
  • A demo site will be built where anyone can try out a version of CiviCRM that includes your changes.
  • If this process needs to be repeated, an admin will issue the command test this please to rerun tests and build a new demo site.
  • Before this PR can be merged, it needs to be reviewed. Please keep in mind that reviewers are volunteers, and their response time can vary from a few hours to a few weeks depending on their availability and their knowledge of this particular part of CiviCRM.
  • A great way to speed up this process is to "trade reviews" with someone - find an open PR that you feel able to review, and leave a comment like "I'm reviewing this now, could you please review mine?" (include a link to yours). You don't have to wait for a response to get started (and you don't have to stop at one!) the more you review, the faster this process goes for everyone 😄
  • To ensure that you are credited properly in the final release notes, please add yourself to contributor-key.yml
  • For more information about contributing, see CONTRIBUTING.md.
Quick links for reviewers...

➡️ Online demo of this PR 🔗

@civibot civibot bot added the master label Sep 26, 2024
@colemanw colemanw force-pushed the hierarchicalEntity branch 6 times, most recently from 822bc89 to 99fc572 Compare September 28, 2024 00:53
This trait gives entities a special `_depth` field, selecting it triggers a special get mode
which will cause returned records to be returned in nested order.
A hierarchical table shows child rows nested under their parents
@mattwire
Copy link
Contributor

@colemanw this looks nice. Just some thoughts/questions...

  1. Looks like this relies on the entity having a field "parent_id" - correct?
  2. Do you think this would be extendable to make it possible to collapse/expand children - maybe that could be done in CSS?
  3. What happens if you try to sort by another column?
  4. Would this be extendable to support other types of "parent/child" eg. Contribution->Payments, Contact->Related contact etc. or would those be better modelled in a different display?

@colemanw
Copy link
Member Author

Thanks @mattwire. To answer:

  1. Yes but it doesn't have to be named that exactly. You can specify in the entity metadata the field name.
  2. Yep, could do it with css & a bit of js, just need to keep accessibility in mind.
  3. Sorting works by any column :) The results will always be correctly nested, and then the nested groups are sorted by the column of your choice.
  4. You mean 1-to-many joins? Yea that's a really good idea. I think the same concept could potentially apply, probably slightly different mechanics but basically could work, yes. I'll think about that one...

@mattwire
Copy link
Contributor

You mean 1-to-many joins? Yea that's a really good idea. I think the same concept could potentially apply, probably slightly different mechanics but basically could work, yes. I'll think about that one...

Ok great. Well let me know if you'd like this one reviewed/merged in the mean time or if you'd like a little think first :-)

@colemanw
Copy link
Member Author

@mattwire yes it'd be good to get this merged in the meantime.

@mattwire
Copy link
Contributor

mattwire commented Oct 2, 2024

Ok, I've done some testing and code review on this. I didn't test the "role permissions" screen as currently don't have a standalone system setup but the groups and contact types seem to work well. Nested permissions checkbox appears for those entities only as expected.

@mattwire mattwire merged commit 4afde08 into civicrm:master Oct 2, 2024
1 check passed
@colemanw colemanw deleted the hierarchicalEntity branch October 2, 2024 17:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants