-
-
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
dev/core#1050 - Delete repeat activities that are selected for deletion #14784
dev/core#1050 - Delete repeat activities that are selected for deletion #14784
Conversation
Can one of the admins verify this patch? |
(Standard links)
|
add to whitelist |
42103ab
to
bdf27a0
Compare
As requested by @mattwire, I have added a test: CRM_Activity_Form_ActivityTest::testActivityDelete. It creates a number of non-repeating and repeating activities, and then calls the CRM_Activity_Form_Activity::postProcess function (the one that I've patched) to test the following:
After each deletion it checks that the expected activity/activities were deleted and no others. Is it ready to merge now? |
Hmm, not sure why tests failed after I pushed commit c774305. That commit only contains a very minor code change that shouldn't have had any effect on any tests. Perhaps some other change in master caused the failure? Is it possible to rerun the tests? |
@kirk-circle Overall seems good to me. And at some point can you rebase the commits (https://docs.civicrm.org/dev/en/latest/tools/git/#rebasing-interactive). If you get stuck I've found that this article has a nice procedure that has prevented at least one laptop from being smashed with a hammer: https://stackoverflow.com/a/6103022/8332458
|
Jenkins re test this please |
c774305
to
70ea735
Compare
Hi @demeritcowboy, thanks for the review. 🙂
Good call. How did I not know about the array_column function?
Thanks for the helpful advice. I have squashed the existing commits, together with the above change, into two commits - one for deleting repeat activities, and one for testing the form's deletion of single and repeating activities. |
based on @demeritcowboy review i'm going to merge this |
Overview
Ensures that when the user opts to delete multiple repeat activities, the specified activities are actually deleted.
Repeating activities are created by entering details into the "Repeat Activity" section on the New/Edit Activity form. Then when the user clicks "Delete" on a repeat activity, a pop-up appears asking whether to delete "Only this activity", "This activity onwards" or "Every activity".
Before
On the Activities tab, if the user clicks "Delete" on a repeat activity and then opts to delete either "This activity onwards" or "Every activity", the only activity that's deleted is the one whose "Delete" link was clicked.
After
On the Activities tab, if the user clicks "Delete" on a repeat activity and then opts to delete either "This activity onwards" or "Every activity", the specified repeat activities are deleted as well as the one whose "Delete" link was clicked.
Technical Details
Although the pop-up asks the user which repeat activities to delete, it looks like this feature was never actually implemented.
This PR implements the feature as follows: Instead of CRM_Activity_Form_Activity::postProcess deleting a single activity, it builds a list of activities to be deleted and then iterates over that list, deleting each one.
To build a list containing the IDs of the repeat activities to be deleted, the CRM_Core_BAO_RecurringEntity::getEntitiesFor function is called. If the activity is not a repeating activity, then that function will return an empty list, in which case the list will then be set to contain only the ID of the single activity whose "Delete" link was clicked.