From fa9fbb61e1982163284657efccaf0306e248de04 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Thu, 13 Mar 2014 09:44:50 -0400 Subject: [PATCH] CRM-13863 - Update more dependent tabs and blocks --- CRM/Contact/Form/Inline/ContactInfo.php | 5 +++++ CRM/Contact/Form/Relationship.php | 4 ++++ CRM/Event/Page/Tab.php | 2 ++ CRM/Member/Page/Tab.php | 3 +++ templates/CRM/common/TabHeader.js | 11 +++++++---- 5 files changed, 21 insertions(+), 4 deletions(-) diff --git a/CRM/Contact/Form/Inline/ContactInfo.php b/CRM/Contact/Form/Inline/ContactInfo.php index 7f954afc7a..dc37a4aef9 100644 --- a/CRM/Contact/Form/Inline/ContactInfo.php +++ b/CRM/Contact/Form/Inline/ContactInfo.php @@ -81,6 +81,11 @@ class CRM_Contact_Form_Inline_ContactInfo extends CRM_Contact_Form_Inline { CRM_Contact_BAO_Contact::create($params); + // Saving current employer affects relationship tab + $this->ajaxResponse['updateTabs'] = array( + '#tab_rel' => CRM_Contact_BAO_Contact::getCountComponent('rel', $this->_contactId), + ); + $this->response(); } } diff --git a/CRM/Contact/Form/Relationship.php b/CRM/Contact/Form/Relationship.php index ed669fde84..77264a95fc 100644 --- a/CRM/Contact/Form/Relationship.php +++ b/CRM/Contact/Form/Relationship.php @@ -515,6 +515,10 @@ class CRM_Contact_Form_Relationship extends CRM_Core_Form { CRM_Contact_BAO_Relationship::disableEnableRelationship($this->_relationshipId, $active); } } + // Refresh contact tabs with related data + $this->ajaxResponse['updateTabs'] = array( + '#tab_member' => CRM_Contact_BAO_Contact::getCountComponent('membership', $this->_contactId), + ); } // Set current employee/employer relationship, CRM-3532 if ($params['is_current_employer'] && $this->_allRelationshipNames[$relationshipTypeId]["name_a_b"] == 'Employee of') { diff --git a/CRM/Event/Page/Tab.php b/CRM/Event/Page/Tab.php index 35bbcad3e6..3d968f78d8 100644 --- a/CRM/Event/Page/Tab.php +++ b/CRM/Event/Page/Tab.php @@ -60,8 +60,10 @@ class CRM_Event_Page_Tab extends CRM_Core_Page { $displayName = CRM_Contact_BAO_Contact::displayName($this->_contactId); $this->assign('displayName', $displayName); $this->ajaxResponse['tabCount'] = CRM_Contact_BAO_Contact::getCountComponent('participant', $this->_contactId); + // Refresh other tabs with related data $this->ajaxResponse['updateTabs'] = array( '#tab_contribute' => CRM_Contact_BAO_Contact::getCountComponent('contribution', $this->_contactId), + '#tab_activity' => CRM_Contact_BAO_Contact::getCountComponent('activity', $this->_contactId), ); } } diff --git a/CRM/Member/Page/Tab.php b/CRM/Member/Page/Tab.php index 729b7004c6..eba2b77e68 100644 --- a/CRM/Member/Page/Tab.php +++ b/CRM/Member/Page/Tab.php @@ -206,8 +206,11 @@ class CRM_Member_Page_Tab extends CRM_Core_Page { $displayName = CRM_Contact_BAO_Contact::displayName($this->_contactId); $this->assign('displayName', $displayName); $this->ajaxResponse['tabCount'] = CRM_Contact_BAO_Contact::getCountComponent('membership', $this->_contactId); + // Refresh other tabs with related data $this->ajaxResponse['updateTabs'] = array( '#tab_contribute' => CRM_Contact_BAO_Contact::getCountComponent('contribution', $this->_contactId), + '#tab_activity' => CRM_Contact_BAO_Contact::getCountComponent('activity', $this->_contactId), + '#tab_rel' => CRM_Contact_BAO_Contact::getCountComponent('rel', $this->_contactId), ); } } diff --git a/templates/CRM/common/TabHeader.js b/templates/CRM/common/TabHeader.js index 46e4b08703..20b559c521 100644 --- a/templates/CRM/common/TabHeader.js +++ b/templates/CRM/common/TabHeader.js @@ -54,10 +54,6 @@ cj(function($) { if (typeof(data.tabCount) !== 'undefined') { CRM.tabHeader.updateCount(ui.tab, data.tabCount); } - if ($.isPlainObject(data.updateTabs)) { - $.each(data.updateTabs, CRM.tabHeader.updateCount); - $.each(data.updateTabs, CRM.tabHeader.resetTab); - } if (typeof(data.tabValid) !== 'undefined') { var method = data.tabValid ? 'removeClass' : 'addClass'; ui.tab[method]('disabled'); @@ -69,6 +65,13 @@ cj(function($) { e.preventDefault(); }) .tabs(tabSettings); + // Any load/submit event could potentially call for tabs to refresh. + $(document).on('crmLoad.tabInfo crmFormSuccess.tabInfo', function(e, data) { + if (data && $.isPlainObject(data.updateTabs)) { + $.each(data.updateTabs, CRM.tabHeader.updateCount); + $.each(data.updateTabs, CRM.tabHeader.resetTab); + } + }); }); (function($) { // Utility functions -- 2.25.1