From 58b65bf6c41081dfce943a747e7614fea38f3820 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Sat, 28 Dec 2013 11:58:12 -0800 Subject: [PATCH] CRM-13997 CRM-13863 - Use CRM.loadPage for contact tabs --- CRM/Contact/Page/View/Summary.php | 17 +++++++------- templates/CRM/Contact/Page/View/Summary.js | 3 ++- templates/CRM/Contact/Page/View/Summary.tpl | 25 +-------------------- templates/CRM/Tag/Form/Tag.tpl | 7 ++---- templates/CRM/common/TabHeader.js | 8 +++++++ 5 files changed, 22 insertions(+), 38 deletions(-) diff --git a/CRM/Contact/Page/View/Summary.php b/CRM/Contact/Page/View/Summary.php index 668bcc10cb..d561d123e3 100644 --- a/CRM/Contact/Page/View/Summary.php +++ b/CRM/Contact/Page/View/Summary.php @@ -137,7 +137,11 @@ class CRM_Contact_Page_View_Summary extends CRM_Contact_Page_View { ->addScriptFile('civicrm', 'templates/CRM/Contact/Page/View/Summary.js') ->addScriptFile('civicrm', 'packages/jquery/plugins/jstree/jquery.jstree.js', 0, 'html-header', FALSE) ->addStyleFile('civicrm', 'packages/jquery/plugins/jstree/themes/default/style.css', 0, 'html-header') - ->addSetting(array('summaryPrint' => array('mode' => $this->_print))); + ->addScriptFile('civicrm', 'templates/CRM/common/TabHeader.js') + ->addSetting(array( + 'summaryPrint' => array('mode' => $this->_print), + 'tabSettings' => array('active' => CRM_Utils_Request::retrieve('selectedChild', 'String', $this, FALSE, 'summary')), + )); $this->assign('summaryPrint', $this->_print); $session = CRM_Core_Session::singleton(); $url = CRM_Utils_System::url('civicrm/contact/view', 'reset=1&cid=' . $this->_contactId); @@ -316,9 +320,9 @@ class CRM_Contact_Page_View_Summary extends CRM_Contact_Page_View { //appending isTest to url for test soft credit CRM-3891. //FIXME: hack ajax url. - $q = "reset=1&snippet=1&force=1&cid={$this->_contactId}"; + $q = "reset=1&force=1&cid={$this->_contactId}"; if (CRM_Utils_Request::retrieve('isTest', 'Positive', $this)) { - $q = $q . "&isTest=1"; + $q .= "&isTest=1"; } $allTabs[] = array( 'id' => $i, @@ -351,7 +355,7 @@ class CRM_Contact_Page_View_Summary extends CRM_Contact_Page_View { 'id' => $k, 'url' => CRM_Utils_System::url( "civicrm/contact/view/$k", - "reset=1&snippet=1&cid={$this->_contactId}" + "reset=1&cid={$this->_contactId}" ), 'title' => $v, 'weight' => $weight, @@ -373,7 +377,7 @@ class CRM_Contact_Page_View_Summary extends CRM_Contact_Page_View { $id = "custom_{$group['id']}"; $allTabs[] = array( 'id' => $id, - 'url' => CRM_Utils_System::url($group['path'], $group['query'] . "&snippet=1&selectedChild=$id"), + 'url' => CRM_Utils_System::url($group['path'], $group['query'] . "&selectedChild=$id"), 'title' => $group['title'], 'weight' => $weight, 'count' => CRM_Contact_BAO_Contact::getCountComponent($id, $this->_contactId, $group['table_name']), @@ -389,9 +393,6 @@ class CRM_Contact_Page_View_Summary extends CRM_Contact_Page_View { $this->assign('allTabs', $allTabs); - $selectedChild = CRM_Utils_Request::retrieve('selectedChild', 'String', $this, FALSE, 'summary'); - $this->assign('selectedChild', $selectedChild); - // hook for contact summary // ignored but needed to prevent warnings $contentPlacement = CRM_Utils_Hook::SUMMARY_BELOW; diff --git a/templates/CRM/Contact/Page/View/Summary.js b/templates/CRM/Contact/Page/View/Summary.js index 8c8bbc4b1a..edf04537ae 100644 --- a/templates/CRM/Contact/Page/View/Summary.js +++ b/templates/CRM/Contact/Page/View/Summary.js @@ -90,7 +90,7 @@ } // Update changelog tab and contact footer if (response.changeLog.count) { - $("#tab_log a em").html(response.changeLog.count); + CRM.updateTabCount('#tab_log', response.changeLog.count); } $("#crm-record-log").replaceWith(response.changeLog.markup); // Refresh tab contents - Advanced logging @@ -294,5 +294,6 @@ $('#tab_log a').click(); return false; }); + $().crmAccordions(); }); })(cj); diff --git a/templates/CRM/Contact/Page/View/Summary.tpl b/templates/CRM/Contact/Page/View/Summary.tpl index 0225cb6372..13291abbd6 100644 --- a/templates/CRM/Contact/Page/View/Summary.tpl +++ b/templates/CRM/Contact/Page/View/Summary.tpl @@ -131,7 +131,7 @@ {/if}
- - - {/if} {* CRM-10560 *} diff --git a/templates/CRM/Tag/Form/Tag.tpl b/templates/CRM/Tag/Form/Tag.tpl index 4a8e70fef0..3132cabb2e 100644 --- a/templates/CRM/Tag/Form/Tag.tpl +++ b/templates/CRM/Tag/Form/Tag.tpl @@ -67,15 +67,12 @@ }); CRM.updateContactSummaryTags = function() { - var tags = [], $tab = $('#tab_tag'); + var tags = []; $('.tag-section .token-input-token-facebook p, #tagtree input:checkbox:checked+label').each(function() { tags.push($(this).text()); }); // showing count of tags in summary tab - $('a em', $tab).html('' + tags.length); - $tab - .removeClass($tab.attr('class').match(/(crm-count-\d+)/)[0]) - .addClass('crm-count-' + tags.length); + CRM.updateTabCount('#tab_tag', tags.length); // update summary tab $("#tags").html(tags.join(', ')); }; diff --git a/templates/CRM/common/TabHeader.js b/templates/CRM/common/TabHeader.js index a39b1b2d4c..948bced38f 100644 --- a/templates/CRM/common/TabHeader.js +++ b/templates/CRM/common/TabHeader.js @@ -21,3 +21,11 @@ cj(function($) { }) .tabs(tabSettings); }); +(function($) { + CRM.updateTabCount = function(tab, count) { + $(tab) + .removeClass($(tab).attr('class').match(/(crm-count-\d+)/)[0]) + .addClass('crm-count-' + count) + .find('a em').html('' + count); + } +})(cj); -- 2.25.1