Skip to content

Commit

Permalink
(Smart Group) is being constantly added while editing the smart group…
Browse files Browse the repository at this point in the history
… title from 'Manage Group' page
  • Loading branch information
monishdeb authored and Monish Deb committed Jul 28, 2021
1 parent 930539a commit 27d4ea3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion CRM/Contact/BAO/Group.php
Original file line number Diff line number Diff line change
Expand Up @@ -912,7 +912,7 @@ public static function getGroupList(&$params) {
CRM_Core_DAO::storeValues($object, $values[$object->id]);

if ($object->saved_search_id) {
$values[$object->id]['title'] .= ' (' . ts('Smart Group') . ')';
$values[$object->id]['class'][] = "crm-smart-group";
// check if custom search, if so fix view link
$customSearchID = CRM_Core_DAO::getFieldValue(
'CRM_Contact_DAO_SavedSearch',
Expand Down
18 changes: 13 additions & 5 deletions templates/CRM/Group/Form/Search.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@
// also to handle search filtering for initial load of same page.
var parentsOnly = 1
var ZeroRecordText = {/literal}'{ts escape="js"}<div class="status messages">None found.{/ts}</div>'{literal};
var smartGroupText = {/literal}'<span>({ts escape="js"}Smart Group{/ts})</span>'{literal};
$('table.crm-group-selector').data({
"ajax": {
"url": {/literal}'{crmURL p="civicrm/ajax/grouplist" h=0 q="snippet=4"}'{literal},
Expand Down Expand Up @@ -157,15 +158,19 @@
});
//Reload table after draw
$(settings.nTable).trigger('crmLoad');
if (parentsOnly) {
CRM.loadScript(CRM.config.resourceBase + 'js/jquery/jquery.crmEditable.js').done(function () {
CRM.loadScript(CRM.config.resourceBase + 'js/jquery/jquery.crmEditable.js').done(function () {
if (parentsOnly) {
$('tbody tr.crm-group-parent', settings.nTable).each(function () {
$(this).find('td:first')
.prepend('{/literal}<span class="collapsed show-children" title="{ts}show child groups{/ts}"/></span>{literal}')
.find('div').css({'display': 'inline'});
});
}
$('tbody tr.crm-smart-group', settings.nTable).each(function () {
$(this).find('td:first')
.append(smartGroupText);
});
}
});
}
});
$(function($) {
Expand Down Expand Up @@ -234,15 +239,18 @@
'parent_is_' + parent_id,
'crm-row-child'
];
if (!$.inArray("crm-smart-group", val.row_classes)) {
smartGroupText = '';
}
if ('DT_RowClass' in val) {
val.row_classes = val.row_classes.concat(val.DT_RowClass.split(' ').filter((item) => val.row_classes.indexOf(item) < 0));
}
appendHTML += '<tr id="row_'+val.group_id+'_'+parent_id+'" data-entity="group" data-id="'+val.group_id+'" class="' + val.row_classes.join(' ') + '">';
if ( val.is_parent ) {
appendHTML += '<td class="crm-group-name crmf-title ' + levelClass + '">' + '{/literal}<span class="collapsed show-children" title="{ts}show child groups{/ts}"/></span><div class="crmf-title {$editableClass}" style="display:inline">{literal}' + val.title + '</div></td>';
appendHTML += '<td class="crm-group-name crmf-title ' + levelClass + '">' + '{/literal}<span class="collapsed show-children" title="{ts}show child groups{/ts}"/></span><div class="crmf-title {$editableClass}" style="display:inline">{literal}' + val.title + '</div>' + smartGroupText + '</td>';
}
else {
appendHTML += '<td class="crm-group-name crmf-title {/literal}{$editableClass}{literal} ' + levelClass + '"><span class="crm-no-children"></span>' + val.title + '</td>';
appendHTML += '<td class="crm-group-name' + levelClass + '"><div class="crmf-title {/literal}{$editableClass}{literal}"><span class="crm-no-children"></span>' + val.title + '</div>' + smartGroupText + '</td>';
}
appendHTML += '<td class="right">' + val.count + "</td>";
appendHTML += "<td>" + val.created_by + "</td>";
Expand Down

0 comments on commit 27d4ea3

Please sign in to comment.