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

dev/core/287 Disable child groups if all parents are disabled #12797

Merged
merged 4 commits into from
Nov 2, 2018
Merged

dev/core/287 Disable child groups if all parents are disabled #12797

merged 4 commits into from
Nov 2, 2018

Conversation

madhavimalgaonkar
Copy link
Contributor

@madhavimalgaonkar madhavimalgaonkar commented Sep 7, 2018

Overview

Child groups with all parents disabled shows in group list

Before

How it works currently: If a child group has multiple parent groups and one of them is disabled, the child group should to show up on group selector lists. This has been fixed here https://issues.civicrm.org/jira/browse/CRM-20934.

If all parent group(s) are disabled the child group still shows up in search mode.

You can see the child group with title as Child group Child of: With null value for parent.
image
image

After

If a child group has multiple or single parent group and all of them are disabled, then the child group be
disabled and removed from the selector lists.

Technical Details

Added warning before disabling any group. Checked for groups with both single and multiple parent groups.

https://lab.civicrm.org/dev/core/issues/287

@civicrm-builder
Copy link

Can one of the admins verify this patch?

@@ -350,6 +350,23 @@ public static function create(&$params) {
CRM_Utils_Hook::pre('create', 'Group', NULL, $params);
}

// CRM-287 Disable child groups if all parents are disabled.
Copy link
Contributor

Choose a reason for hiding this comment

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

CRM-287? This is not the correct issue number!

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this whole process should be done after parent group is disabled.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated the issue number.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

And about the workflow. Lets consider a situation with three parent groups to one child group. The child group will be disabled after the 3rd parent is disabled. But when any of the parent is enabled the child should be enabled too. So I think the current workflow is right.

Copy link
Contributor

@pradpnayak pradpnayak Sep 12, 2018

Choose a reason for hiding this comment

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

@madhavimalgaonkar Can you iron out more of my confusion for below use case(or isn't a valid use case)?

  1. Disabled child group.
  2. After some days Disabled #1's Parent group.
  3. Later Enabled #1's Parent group, but don't want the child group to be enabled.

}
if (count($parentIds) > 1 && $activeParentsCount <= 1) {
$setDisable = self::setIsActive($childValue, $params['is_active']);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we group 362 and 365 with OR statement?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the point :) . Have updated the conditions.

@totten totten added the master label Sep 11, 2018
@@ -350,6 +350,20 @@ public static function create(&$params) {
CRM_Utils_Hook::pre('create', 'Group', NULL, $params);
}

// dev/core#287 Disable child groups if all parents are disabled.
if(!empty($params['id'])) {
Copy link
Contributor

@pradpnayak pradpnayak Sep 12, 2018

Choose a reason for hiding this comment

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

should be if (!empty($params['id'])) {

'id' => ['IN' => $parentIds],
'is_active' => 1,
]);
if (count($parentIds) == 1 || count($parentIds) > 1 && $activeParentsCount <= 1) {
Copy link
Contributor

Choose a reason for hiding this comment

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

can this be written as if (count($parentIds) >= 1 && $activeParentsCount <= 1) { ?

@eileenmcnaughton
Copy link
Contributor

test this please

@eileenmcnaughton
Copy link
Contributor

@lcdservices @pradpnayak is this mergeable?

@lcdservices
Copy link
Contributor

I ran through a simple test and it appeared to work as expected:

  • created a parent group
  • created a child group of the parent
  • disabled the parent group
  • noted that the confirmation popup indicated that child groups would also be disabled
  • searched for child group -- confirmed it had been disabled

@eileenmcnaughton
Copy link
Contributor

merging based on @lcdservices review & @pradpnayak code input.

Thank you @lcdservices @pradpnayak and @madhavimalgaonkar

@eileenmcnaughton eileenmcnaughton merged commit 9fb047b into civicrm:master Nov 2, 2018
seamuslee001 added a commit to seamuslee001/civicrm-core that referenced this pull request Nov 3, 2018
@seamuslee001
Copy link
Contributor

seamuslee001 added a commit that referenced this pull request Nov 4, 2018
Fix unit tests following merge of PR #12797
@eileenmcnaughton eileenmcnaughton changed the title CRM-287 Disable child groups if all parents are disabled dev/core/287 Disable child groups if all parents are disabled Nov 9, 2018
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.

7 participants