-
-
Notifications
You must be signed in to change notification settings - Fork 825
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
Allow columns in relationship table to be modified by searchColumns hook #14184
Conversation
(Standard links)
|
64cfed3
to
a1a7cf2
Compare
eee3002
to
61dd34b
Compare
Tested the PR. works great except that before this change the rows were sorted by relationship type id by default, but now it is sorted by relationship type labels? @mattwire The addition of searchColumns hook works as desired. Thanks. |
@@ -134,6 +134,10 @@ public function view() { | |||
*/ | |||
public function browse() { | |||
// do nothing :) we are using datatable for rendering relationship selectors | |||
$columnHeaders = CRM_Contact_BAO_Relationship::getColumnHeaders(); | |||
$contactRelationships = $selector = NULL; | |||
CRM_Utils_Hook::searchColumns('relationship.columns', $columnHeaders, $contactRelationships, $selector); |
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.
Why do we need the hook here - in other places it is very centralised - but they do seem to be actually using the selector whereas I think you are mocking 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.
We are mocking it and there are two different functions - the page loads with the columns here. Later the datatable loads the rows via an ajax call.
Good spotting @pradpnayak - my instinct is that relationship type labels is at least as good as relationship_type_id - which seems kinda arbitrary. My concern is the 2 different contexts - 'relationship.rows' & 'relationship.columns' - there doesn't seem to be a precedent for that? The cleanup looks good |
@mattwire You might want to rebase the PR. +1 for the improvement :) |
89d4c53
to
20dabfd
Compare
Rebased! |
@mattwire Thanks! Do we have documentation for the hook to got with this? |
@yashodha Yes documentation is (accidently) already merged - see https://github.com/civicrm/civicrm-dev-docs/issues/609 If you are happy with those docs we could merge this and close that issue? |
@mattwire sure, will check |
I've flagged this merge-ready as I think we've got confirmation from reviewers that it's good to merge - just need the merger to confirm the documentation is ok. |
Matt, can you explain how you responded to @eileenmcnaughton 's question above
I didn't seek what the AddEntityPage stuff just under it meant. |
@mattwire Can you please rebase this PR? |
20dabfd
to
1ea8369
Compare
@JoeMurray @eileenmcnaughton Sorry :-) There probably isn't a precedent because this is the first time we're mocking the search selector instead of using it directly (as relationships is not using it).
Is that ok? |
We do have a precedent - it's just different - on the contribution tpl the headers are assigned to the template as an array & iterated - as you do. However, we don't provide a hook for that - we leave people to do it in another hook as a smarty assign. This feels like a compromise to me - you can achieve what you want but it's clear it is only quasi-supported - which I think is appropriate because I could see the code being cleaned up later. If you ditched I would merge the cleanup to the tpl & you can see whether you really need this hook or whether you can assign the values to the tpl from an existing hook |
1ea8369
to
78ed7f1
Compare
Done
@eileenmcnaughton
If you prefer, we could simplify the selector and just use See here for an example implementation: https://github.com/mattwire/civicrm-hrgb/blob/master/hrgb.php#L160 |
I'm okay with an implementation that makes use of params passed in via an existing hook to do more than one thing. |
@eileenmcnaughton @JoeMurray @mattwire |
@mattwire Does this well with user dashboard as well? |
@jitendrapurohit Did you test user dashboard for this PR as well? |
@yashodha Where is this shown on userdashboard? |
@mattwire Please check screenshot |
@mattwire
|
@eileenmcnaughton I have removed merge ready tag as the proposed changes need to be done for this to work on userdashboard as well. |
78ed7f1
to
16b745b
Compare
@yashodha Thanks for review + patch. I've added and pushed your changes. @seamuslee001 |
Given the discussion and the fact that Matt has reponded to Yash's review this looks fine to me. Merging |
@seamuslee001 Thanks! It works fine. |
Overview
Allow columns in relationship table to be modified by searchColumns hook. This allows us to modify the columns that are shown to the user on the Contact relationships tab.
Before
Not possible to modify relationship tab columns without changing templates/php.
After
Can modify columns by implementing searchColumns hook.
Technical Details
Implemented in standard way as done by other entities
Comments
@eileenmcnaughton There's a couple of bits in here that would probably be good to take further into an EntityPageTrait or similar. I've done a bit of work towards that here.