From 36e13a808c3ae1057586e9e954aa5a1c5efc31a2 Mon Sep 17 00:00:00 2001 From: Monish Deb Date: Mon, 19 Jul 2021 17:26:10 +0530 Subject: [PATCH] (Smart Group) is being constantly added while editing the smart group title from 'Manage Group' page --- CRM/Contact/BAO/Group.php | 2 +- templates/CRM/Group/Form/Search.tpl | 17 +++++++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/CRM/Contact/BAO/Group.php b/CRM/Contact/BAO/Group.php index b9c6be59ea..3079dda7c9 100644 --- a/CRM/Contact/BAO/Group.php +++ b/CRM/Contact/BAO/Group.php @@ -905,7 +905,7 @@ class CRM_Contact_BAO_Group extends CRM_Contact_DAO_Group { 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', diff --git a/templates/CRM/Group/Form/Search.tpl b/templates/CRM/Group/Form/Search.tpl index 6363fba591..6f24d0f67a 100644 --- a/templates/CRM/Group/Form/Search.tpl +++ b/templates/CRM/Group/Form/Search.tpl @@ -111,6 +111,7 @@ // also to handle search filtering for initial load of same page. var parentsOnly = 1 var ZeroRecordText = {/literal}'{ts escape="js"}
None found.{/ts}
'{literal}; + var smartGroupText = {/literal}'({ts escape="js"}Smart Group{/ts})'{literal}; $('table.crm-group-selector').data({ "ajax": { "url": {/literal}'{crmURL p="civicrm/ajax/grouplist" h=0 q="snippet=4"}'{literal}, @@ -157,15 +158,16 @@ }); //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}{literal}') .find('div').css({'display': 'inline'}); }); - }); - } + } + $('tbody tr.crm-smart-group > td.crm-group-name', settings.nTable).append(smartGroupText); + }); } }); $(function($) { @@ -236,13 +238,16 @@ ]; if ('DT_RowClass' in val) { val.row_classes = val.row_classes.concat(val.DT_RowClass.split(' ').filter((item) => val.row_classes.indexOf(item) < 0)); + if (val.DT_RowClass.indexOf('crm-smart-group') == -1) { + smartGroupText = ''; + } } appendHTML += ''; if ( val.is_parent ) { - appendHTML += '' + '{/literal}
{literal}' + val.title + '
'; + appendHTML += '' + '{/literal}
{literal}' + val.title + '
' + smartGroupText + ''; } else { - appendHTML += '' + val.title + ''; + appendHTML += '
' + val.title + '
' + smartGroupText + ''; } appendHTML += '' + val.count + ""; appendHTML += "" + val.created_by + ""; -- 2.25.1