From 28dd94bd73a2bead3613cdd5766000e60f41d9d9 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Mon, 4 Jun 2018 12:31:11 -0400 Subject: [PATCH] CRM-20621 - Initial cleanup toward performance improvements --- CRM/Admin/Page/AJAX.php | 38 +++++++++++++++++----------------- templates/CRM/Tag/Page/Tag.tpl | 1 + 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/CRM/Admin/Page/AJAX.php b/CRM/Admin/Page/AJAX.php index 2cfe371650..4854ffb9df 100644 --- a/CRM/Admin/Page/AJAX.php +++ b/CRM/Admin/Page/AJAX.php @@ -340,37 +340,37 @@ class CRM_Admin_Page_AJAX { } } else { - $style = ''; - if ($dao->color) { - $style = "background-color: {$dao->color}; color: " . CRM_Utils_Color::getContrast($dao->color); - } $hasChildTags = empty($childTagIDs[$dao->id]) ? FALSE : TRUE; $usedFor = (array) explode(',', $dao->used_for); - $result[] = array( + $tag = [ 'id' => $dao->id, 'text' => $dao->name, - 'icon' => FALSE, - 'li_attr' => array( - 'title' => ((string) $dao->description) . ($dao->is_reserved ? ' (*' . ts('Reserved') . ')' : ''), - 'class' => $dao->is_reserved ? 'is-reserved' : '', - ), - 'a_attr' => array( - 'style' => $style, + 'a_attr' => [ 'class' => 'crm-tag-item', - ), + ], 'children' => $hasChildTags, - 'data' => array( + 'data' => [ 'description' => (string) $dao->description, 'is_selectable' => (bool) $dao->is_selectable, 'is_reserved' => (bool) $dao->is_reserved, 'used_for' => $usedFor, 'color' => $dao->color ? $dao->color : '#ffffff', - 'usages' => civicrm_api3('EntityTag', 'getcount', array( - 'entity_table' => array('IN' => $usedFor), + 'usages' => civicrm_api3('EntityTag', 'getcount', [ + 'entity_table' => ['IN' => $usedFor], 'tag_id' => $dao->id, - )), - ), - ); + ]), + ], + ]; + if ($dao->description || $dao->is_reserved) { + $tag['li_attr']['title'] = ((string) $dao->description) . ($dao->is_reserved ? ' (*' . ts('Reserved') . ')' : ''); + } + if ($dao->is_reserved) { + $tag['li_attr']['class'] = 'is-reserved'; + } + if ($dao->color) { + $tag['a_attr']['style'] = "background-color: {$dao->color}; color: " . CRM_Utils_Color::getContrast($dao->color); + } + $result[] = $tag; } } diff --git a/templates/CRM/Tag/Page/Tag.tpl b/templates/CRM/Tag/Page/Tag.tpl index 142477f697..4fcbdf3669 100644 --- a/templates/CRM/Tag/Page/Tag.tpl +++ b/templates/CRM/Tag/Page/Tag.tpl @@ -286,6 +286,7 @@ return {parent_id: node.id === '#' ? tagset : node.id}; } }, + themes: {icons: false}, check_callback: true }, 'search': { -- 2.25.1