Skip to content

Commit

Permalink
add asterisk for smart group option in select2 widget
Browse files Browse the repository at this point in the history
  • Loading branch information
monishdeb committed Feb 6, 2020
1 parent bc46afb commit 64bf59b
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 17 deletions.
7 changes: 4 additions & 3 deletions CRM/Contact/BAO/Group.php
Original file line number Diff line number Diff line change
Expand Up @@ -1082,7 +1082,7 @@ public static function getGroupsHierarchy(
'visibility' => $dao->visibility,
'description' => $dao->description,
'icon' => empty($dao->saved_search_id) ? NULL : 'fa-lightbulb-o',
);
];
}
else {
$roots[] = [
Expand All @@ -1091,7 +1091,7 @@ public static function getGroupsHierarchy(
'visibility' => $dao->visibility,
'description' => $dao->description,
'icon' => empty($dao->saved_search_id) ? NULL : 'fa-lightbulb-o',
);
];
}
}

Expand Down Expand Up @@ -1119,7 +1119,8 @@ private static function buildGroupHierarchy(&$hierarchy, $group, $tree, $titleOn
$spaces = str_repeat($spacer, $level);

if ($titleOnly) {
$hierarchy[$group['id']] = $spaces . $group['title'];
$icon = $group['icon'] ? '* ' : '';
$hierarchy[$group['id']] = $icon . $spaces . $group['title'];
}
else {
$hierarchy[] = array(
Expand Down
2 changes: 1 addition & 1 deletion CRM/Contact/Form/GroupContact.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function buildQuickForm() {
if ($onlyPublicGroups && $group['visibility'] == 'User and User Admin Only') {
continue;
}
$allGroups[$id] = $group;
$allGroups[$group['id']] = $group;
}
}
else {
Expand Down
14 changes: 7 additions & 7 deletions CRM/Contact/Form/Search/Basic.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ public function buildQuickForm() {
// Get hierarchical listing of groups, respecting ACLs for CRM-16836.
$groupHierarchy = CRM_Contact_BAO_Group::getGroupsHierarchy($this->_group, NULL, '  ');
if (!empty($searchOptions['groups'])) {
$this->addField('group', array[
'entity' => 'group_contact',
'label' => ts('in'),
'placeholder' => ts('- any group -'),
'options' => $groupHierarchy,
'type' => 'Select2',
]);
$this->addField('group', [
'entity' => 'group_contact',
'label' => ts('in'),
'placeholder' => ts('- any group -'),
'options' => $groupHierarchy,
'type' => 'Select2',
]);
}

if (!empty($searchOptions['tags'])) {
Expand Down
6 changes: 3 additions & 3 deletions CRM/Contact/Form/Search/Criteria.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ public static function basic(&$form) {
// multiselect for groups
if ($form->_group) {
// Arrange groups into hierarchical listing (child groups follow their parents and have indentation spacing in title)
$groupHierarchy = CRM_Contact_BAO_Group::getGroupsHierarchy($form->_group, NULL, '  ', TRUE);
$groupHierarchy = CRM_Contact_BAO_Group::getGroupsHierarchy($form->_group, NULL, '  ');

$form->add('select', 'group', ts('Groups'), $groupHierarchy, FALSE,
['id' => 'group', 'multiple' => 'multiple', 'class' => 'crm-select2']
$form->add('select2', 'group', ts('Groups'), $groupHierarchy, FALSE,
['placeholder' => '- select -', 'multiple' => TRUE, 'class' => 'twenty']
);
$groupOptions = CRM_Core_BAO_OptionValue::getOptionValuesAssocArrayFromName('group_type');
$form->add('select', 'group_type', ts('Group Types'), $groupOptions, FALSE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public function testBrowseDisplaysCorrectListOfAVailableGroups() {
$group_id_field_html = $form['group_id']['html'];
$this->assertContains($publicSmartGroupTitle, $group_id_field_html, "Group '$publicSmartGroupTitle' should be in listed available groups, but is not.");
$this->assertContains($publicStdGroupTitle, $group_id_field_html, "Group '$publicStdGroupTitle' should be in listed available groups, but is not.");
$this->assertNotContains($adminSmartGroupTitle, $group_id_field_html, "Group '$adminSmartGroupTitle' should not be in listed available groups, but is.");
$this->assertNotContains('* ' . $adminSmartGroupTitle, $group_id_field_html, "Group '$adminSmartGroupTitle' should not be in listed available groups, but is.");
$this->assertNotContains($adminStdGroupTitle, $group_id_field_html, "Group '$adminStdGroupTitle' should not be in listed available groups, but is.");

// Add current user to the test groups.
Expand All @@ -199,9 +199,9 @@ public function testBrowseDisplaysCorrectListOfAVailableGroups() {

$form = CRM_Core_Smarty::singleton()->get_template_vars('form');
$group_id_field_html = $form['group_id']['html'];
$this->assertNotContains($publicSmartGroupTitle, $group_id_field_html, "Group '$publicSmartGroupTitle' should not be in listed available groups, but is.");
$this->assertNotContains('* ' . $publicSmartGroupTitle, $group_id_field_html, "Group '$publicSmartGroupTitle' should not be in listed available groups, but is.");
$this->assertNotContains($publicStdGroupTitle, $group_id_field_html, "Group '$publicStdGroupTitle' should not be in listed available groups, but is.");
$this->assertNotContains($adminSmartGroupTitle, $group_id_field_html, "Group '$adminSmartGroupTitle' should not be in listed available groups, but is.");
$this->assertNotContains('* ' . $adminSmartGroupTitle, $group_id_field_html, "Group '$adminSmartGroupTitle' should not be in listed available groups, but is.");
$this->assertNotContains($adminStdGroupTitle, $group_id_field_html, "Group '$adminStdGroupTitle' should not be in listed available groups, but is.");
}

Expand Down

0 comments on commit 64bf59b

Please sign in to comment.