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

Separate delete participant form from edit participant form #27660

Merged
merged 5 commits into from
Oct 4, 2023

Conversation

eileenmcnaughton
Copy link
Contributor

@eileenmcnaughton eileenmcnaughton commented Sep 27, 2023

Overview

Separate delete participant form from edit participant form

Before

The delete participant action and the load price field action are overloaded onto the edit participant form - in part via the confusing EventTab class. This makes the code really hard to follow.

After

I separated the delete participant form to have it's own path..

Technical Details

Note that

  1. the bulk action for delete participant already has a separate class & form (it didn't seem important to combine them as they message slightly differently)
  2. the context handling isn't needed - the key thing it does is handled the situation where there is no form to bounce back to when the Participant form has been used to register a new participant in 'standalone' mode - ie when selected on the form - in which case it goes to the newly created contact's participant tab. This doesn't apply to delete
  3. requires menu/rebuild I think
  4. my main worry atm is I might have missed some links to update - but I checked & report & contact dashboard don't have them & user participant tab & search results work - delete on view tab seems a bit borked

Comments

@civibot
Copy link

civibot bot commented Sep 27, 2023

🤖 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 27, 2023
@eileenmcnaughton eileenmcnaughton changed the title Separate delete participant form from edit participant formb Separate delete participant form from edit participant form Sep 27, 2023
{$form.delete_participant.html}
{/if}
{else} {* If action is other than Delete *}
{if 1} {* If action is other than Delete *}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the if can go later - but getting that right in tpls can be error prone so didn't want to do it here

@eileenmcnaughton
Copy link
Contributor Author

eileenmcnaughton commented Sep 27, 2023

@colemanw I'm wondering if you can help here - I have a hold-out problem - the delete button on the view form - I want that to load the delete code more directly....

UPDATE - got it working

image

@colemanw
Copy link
Member

colemanw commented Oct 3, 2023

@eileenmcnaughton we have a lot of overloaded pages in CiviCRM that embed the form in the page for really no good reason. I've been tackling this in various places and I'm glad to see you making this change here. I'd love to get rid of them all.
IMO the most important thing is to get the form out of the page, so I consider the lightest-touch refactor to take this structure where a single page handles all 4 actions:

<item>
     <path>civicrm/admin/reltype</path> <!-- view, add, update, delete -->
     <page_callback>CRM_Admin_Page_RelationshipType</page_callback>
</item>

And break it apart into 2 paths:

<item>
     <path>civicrm/admin/reltype</path> <!-- view -->
     <page_callback>CRM_Admin_Page_RelationshipType</page_callback>
</item>
<item>
     <path>civicrm/admin/reltype/edit</path> <!-- add, update, delete -->
     <page_callback>CRM_Admin_Form_RelationshipType</page_callback>
</item>

In the above (real) example, the form itself is still overloaded with multiple actions, but at least it's not embedded inside an overloaded page -- that's the most heinous part.
Splitting the form further into multiple paths for multiple actions I think is an ok thing to do as a follow-up (I'm kinda +0 on doing it since it's extra work and not necessarily any benefit). But the nice thing about storing our paths in the xml schema is that we can change them and every SearchKit display will pick it up automatically without needing to be updated.
So all that is to say, I'm fine with merging this, but what about getting the form out of the page?

@eileenmcnaughton
Copy link
Contributor Author

@colemanw hmm - from the point of view of making the form less brittle moving this functionality and the overload functionality that loads the fee information by ajax are the priorities. This does the first of those & I would follow up with the second. The reality is that we probably could replace the extracted form with a SearchKit form pretty quickly if we choose - but it will take a while longer to replace the main form which is 'freed up' by getting this functionality out of it.

So I think if the objective is to support php8.x, get rid of smarty notices & make the sending of workflow messages independent of the form layer (my goal) - this moves us in that direction. At the moment we have the need to retrieve consistent values like event id & participant id & that retrieval works differently in the different forms jammed into Form_Participant making it super fragile. But once the form is just doing add & edit (& perhaps still that nasty bulk action) a huge part of the main add/edit form can be removed & what is left is less fragile

I think it does take us forwards on the part that you think is most heinous but is probably a side issue from my point of view.

@colemanw colemanw merged commit 484084e into civicrm:master Oct 4, 2023
@colemanw colemanw deleted the delete branch October 4, 2023 00:25
@colemanw
Copy link
Member

colemanw commented Oct 4, 2023

Well it's progress either way. And now you know what I think about overloading pages with embedded forms 🤮

@eileenmcnaughton
Copy link
Contributor Author

It looks like it is just update & view that go the through the page -
image

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