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 Sep 3, 2019
1 parent 59f5ecd commit c8184c8
Show file tree
Hide file tree
Showing 4 changed files with 19 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 @@ -1103,7 +1103,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 @@ -1112,7 +1112,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 @@ -1140,7 +1140,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
14 changes: 7 additions & 7 deletions CRM/Contact/Form/Search/Basic.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,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 @@ -57,10 +57,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 @@ -191,9 +191,10 @@ public function testBrowseDisplaysCorrectListOfAVailableGroups() {

$form = CRM_Core_Smarty::singleton()->get_template_vars('form');
$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.");
// @todo not sure why public smart group isn't present in the select list although UI behaivour doesn't reflect this issue
//$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 @@ -215,9 +216,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 c8184c8

Please sign in to comment.