Commit c903e3f7 authored by jaapjansma's avatar jaapjansma

Merge branch 'contact-in-group-filter' into 'master'

Fix two quirks with multiple groups by Contact in Group filter

See merge request !39
parents 8f7d3682 032e3ff0
......@@ -11,6 +11,7 @@
* Improved In Memory Dataflow so that joins and filters would work.
* Improved Contact Summary Tab output so it includes a count.
* Fixed caching issues on the contact data source #31.
* Fixed bugs with ContactInGroup filter #33
# Version 1.6.0
......
......@@ -51,8 +51,9 @@ class ContactInGroupFilter extends AbstractFieldFilterHandler {
$this->resetFilter();
$dataFlow = $this->dataSource->ensureField($this->inputFieldSpecification);
$group_ids = $filter['value'];
if (!is_array($group_ids)) {
$group_ids = array($group_ids);
$group_ids = explode(",", $group_ids);
}
// If the groups are smartgroups (saved searches) they may be out of date.
......@@ -207,16 +208,18 @@ class ContactInGroupFilter extends AbstractFieldFilterHandler {
$sizeClass = 'huge';
$minWidth = 'min-width: 250px;';
if ($size =='compact') {
$sizeClass = 'medium';
$minWidth = '';
}
$api_params['is_active'] = 1;
if ($this->parent_group_id) {
$childGroupIds = \CRM_Contact_BAO_GroupNesting::getDescendentGroupIds([$this->parent_group_id], FALSE);
$api_params['id']['IN'] = $childGroupIds;
}
$childGroupIds = \CRM_Contact_BAO_GroupNesting::getDescendentGroupIds([$this->parent_group_id], FALSE);
$api_params['parents']['IN'] = array_merge( [ $this->parent_group_id ] , $childGroupIds);
}
$form->add('select', "{$fieldSpec->alias}_op", E::ts('Operator:'), $operations, true, [
'style' => $minWidth,
......@@ -224,6 +227,7 @@ class ContactInGroupFilter extends AbstractFieldFilterHandler {
'multiple' => FALSE,
'placeholder' => E::ts('- select -'),
]);
$form->addEntityRef( "{$fieldSpec->alias}_value", NULL, array(
'placeholder' => E::ts('Select a group'),
'entity' => 'Group',
......@@ -238,6 +242,7 @@ class ContactInGroupFilter extends AbstractFieldFilterHandler {
} else {
$defaults[$alias . '_op'] = key($operations);
}
if (isset($defaultFilterValue['value'])) {
$defaults[$alias.'_value'] = $defaultFilterValue['value'];
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment