From 41b47b8a7e84d491d0f8f07294cb1f27b83cb13e Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Thu, 2 Jan 2014 13:36:31 -0800 Subject: [PATCH] CRM-13863 - Fix relationship form to work in popup --- CRM/Contact/Form/Relationship.php | 7 +++-- CRM/Contact/Page/View/Relationship.php | 13 ++------ CRM/Contact/Page/View/Summary.php | 3 +- templates/CRM/Contact/Form/Relationship.tpl | 30 ++++++++----------- .../CRM/Contact/Page/View/Relationship.tpl | 13 ++++---- 5 files changed, 27 insertions(+), 39 deletions(-) diff --git a/CRM/Contact/Form/Relationship.php b/CRM/Contact/Form/Relationship.php index 9d59760020..8eea3342eb 100644 --- a/CRM/Contact/Form/Relationship.php +++ b/CRM/Contact/Form/Relationship.php @@ -282,7 +282,7 @@ class CRM_Contact_Form_Relationship extends CRM_Core_Form { $relTypeID = explode('_', $this->_rtypeId, 3); if ($this->_action & CRM_Core_Action::DELETE) { - + $this->assign('id', $this->_relationshipId); $this->addButtons(array( array( 'type' => 'next', @@ -690,8 +690,9 @@ class CRM_Contact_Form_Relationship extends CRM_Core_Form { CRM_Contact_BAO_Contact_Utils::setCurrentEmployer($currentEmpParams); } } - - if ($quickSave) { + // Don't redirect in ajaxForm context + // FIXME: Perhaps changing the button type would avoid needing the redirect at allq + if ($quickSave && empty($_REQUEST['snippet'])) { $session = CRM_Core_Session::singleton(); CRM_Utils_System::redirect($session->popUserContext()); } diff --git a/CRM/Contact/Page/View/Relationship.php b/CRM/Contact/Page/View/Relationship.php index b3ab7bd1ad..153bdf14f1 100644 --- a/CRM/Contact/Page/View/Relationship.php +++ b/CRM/Contact/Page/View/Relationship.php @@ -314,10 +314,6 @@ class CRM_Contact_Page_View_Relationship extends CRM_Core_Page { */ static function &links() { if (!(self::$_links)) { - $deleteExtra = ts('Are you sure you want to delete this relationship?'); - $disableExtra = ts('Are you sure you want to disable this relationship?'); - $enableExtra = ts('Are you sure you want to re-enable this relationship?'); - self::$_links = array( CRM_Core_Action::VIEW => array( 'name' => ts('View'), @@ -333,23 +329,18 @@ class CRM_Contact_Page_View_Relationship extends CRM_Core_Page { ), CRM_Core_Action::ENABLE => array( 'name' => ts('Enable'), - 'url' => 'civicrm/contact/view/rel', - 'qs' => 'action=enable&reset=1&cid=%%cid%%&id=%%id%%&rtype=%%rtype%%&selectedChild=rel', - 'extra' => 'onclick = "return confirm(\'' . $enableExtra . '\');"', + 'ref' => 'crm-enable-disable', 'title' => ts('Enable Relationship'), ), CRM_Core_Action::DISABLE => array( 'name' => ts('Disable'), - 'url' => 'civicrm/contact/view/rel', - 'qs' => 'action=disable&reset=1&cid=%%cid%%&id=%%id%%&rtype=%%rtype%%&selectedChild=rel', - 'extra' => 'onclick = "return confirm(\'' . $disableExtra . '\');"', + 'ref' => 'crm-enable-disable', 'title' => ts('Disable Relationship'), ), CRM_Core_Action::DELETE => array( 'name' => ts('Delete'), 'url' => 'civicrm/contact/view/rel', 'qs' => 'action=delete&reset=1&cid=%%cid%%&id=%%id%%&rtype=%%rtype%%', - 'extra' => 'onclick = "if (confirm(\'' . $deleteExtra . '\') ) this.href+=\'&confirmed=1\'; else return false;"', 'title' => ts('Delete Relationship'), ), // FIXME: Not sure what to put as the key. diff --git a/CRM/Contact/Page/View/Summary.php b/CRM/Contact/Page/View/Summary.php index ad287fdec1..b8197b6f90 100644 --- a/CRM/Contact/Page/View/Summary.php +++ b/CRM/Contact/Page/View/Summary.php @@ -211,8 +211,7 @@ class CRM_Contact_Page_View_Summary extends CRM_Contact_Page_View { } if (CRM_Utils_Array::value('gender_id', $defaults)) { - $gender = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'gender_id', array('localize' => TRUE)); - $defaults['gender_display'] = $gender[CRM_Utils_Array::value('gender_id', $defaults)]; + $defaults['gender_display'] = CRM_Core_PseudoConstant::getLabel('CRM_Contact_DAO_Contact', 'gender_id', $defaults['gender_id']); } $communicationStyle = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'communication_style_id'); diff --git a/templates/CRM/Contact/Form/Relationship.tpl b/templates/CRM/Contact/Form/Relationship.tpl index b712db17ad..05fb113600 100644 --- a/templates/CRM/Contact/Form/Relationship.tpl +++ b/templates/CRM/Contact/Form/Relationship.tpl @@ -72,7 +72,7 @@ {/foreach} {include file="CRM/Custom/Page/CustomDataView.tpl"} -
{ts}Done{/ts}
+
{ts}Done{/ts}
{/if} @@ -80,6 +80,17 @@ {* Retrieve the ID for the Employee / Employer relationship type *} {crmAPI var="employmentRelationship" entity="RelationshipType" action="getvalue" version="3" name_a_b="Employee of" return="id"}

{if $action eq 1}{ts}New Relationship{/ts}{else}{ts}Edit Relationship{/ts}{/if}

+ {literal} + + {/literal}
{if $action eq 1}
@@ -355,17 +366,6 @@ {$form.is_active.html} - {literal} - - {/literal}
{* end of save element div *}
@@ -501,11 +501,7 @@ function submitAjaxData() {