-- CRM-13037 fix for Navigating among tabs produces wrong popups
authorRavish Nair <ravish.nair@webaccess.co.in>
Mon, 29 Jul 2013 09:42:45 +0000 (15:12 +0530)
committerRavish Nair <ravish.nair@webaccess.co.in>
Mon, 29 Jul 2013 09:42:45 +0000 (15:12 +0530)
----------------------------------------
* CRM-13037:
  http://issues.civicrm.org/jira/browse/CRM-13037

CRM/Profile/Form/Edit.php
CRM/Profile/Page/MultipleRecordFieldsListing.php
templates/CRM/Profile/Page/MultipleRecordFieldsListing.tpl

index 5de91aab3d07c1ad1fd605ad159a55e497e11783..e63229577f0b45bec6f2362e8e4e030d5257ff5f 100644 (file)
@@ -63,6 +63,7 @@ class CRM_Profile_Form_Edit extends CRM_Profile_Form {
     $this->_mode = CRM_Profile_Form::MODE_CREATE;
 
     $this->_onPopupClose = CRM_Utils_Request::retrieve('onPopupClose', 'String', $this);
+    $this->assign('onPopupClose', $this->_onPopupClose);
 
     //set the context for the profile
     $this->_context = CRM_Utils_Request::retrieve('context', 'String', $this);
index 81bc7bd191d8b24dccbc5ee56093a3b740b874f2..9ac8ea0fad63b9d646cfb37f73ab5e4e5360e25c 100644 (file)
@@ -75,21 +75,21 @@ class CRM_Profile_Page_MultipleRecordFieldsListing extends CRM_Core_Page_Basic {
       $links[CRM_Core_Action::VIEW] = array(
         'name' => ts('View'),
         'url' => 'civicrm/profile/view',
-        'qs' => "id=%%id%%&recordId=%%recordId%%&gid=%%gid%%&multiRecord={$view}&snippet=1&context=multiProfileDialog",
+        'qs' => "reset=1&id=%%id%%&recordId=%%recordId%%&gid=%%gid%%&multiRecord={$view}&snippet=1&context=multiProfileDialog&onPopupClose=%%onPopupClose%%",
         'title' => ts('View %1', array( 1 => $this->_customGroupTitle . ' record')),
       );
 
       $links[CRM_Core_Action::UPDATE] = array(
         'name' => ts('Edit'),
         'url' => 'civicrm/profile/edit',
-        'qs' => "id=%%id%%&recordId=%%recordId%%&gid=%%gid%%&multiRecord={$update}&snippet=1&context=multiProfileDialog",
+        'qs' => "reset=1&id=%%id%%&recordId=%%recordId%%&gid=%%gid%%&multiRecord={$update}&snippet=1&context=multiProfileDialog&onPopupClose=%%onPopupClose%%",
         'title' => ts('Edit %1', array( 1 => $this->_customGroupTitle . ' record')),
       );
 
       $links[CRM_Core_Action::DELETE] = array(
         'name' => ts('Delete'),
         'url' => 'civicrm/profile/edit',
-        'qs' => "id=%%id%%&recordId=%%recordId%%&gid=%%gid%%&multiRecord={$delete}&snippet=1&context=multiProfileDialog",
+        'qs' => "reset=1&id=%%id%%&recordId=%%recordId%%&gid=%%gid%%&multiRecord={$delete}&snippet=1&context=multiProfileDialog&onPopupClose=%%onPopupClose%%",
         'title' => ts('Delete %1', array( 1 => $this->_customGroupTitle . ' record')),
       );
 
@@ -112,6 +112,7 @@ class CRM_Profile_Page_MultipleRecordFieldsListing extends CRM_Core_Page_Basic {
   function run() {
     // get the requested action, default to 'browse'
     $action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, FALSE);
+    $this->_onPopupClose = CRM_Utils_Request::retrieve('onPopupClose', 'String', $this);
 
     // assign vars to templates
     $this->assign('action', $action);
@@ -229,7 +230,7 @@ class CRM_Profile_Page_MultipleRecordFieldsListing extends CRM_Core_Page_Basic {
                $customValue = "";
              }
              $actionParams = array('recordId' => $recId, 'gid' => $this->_profileId,
-               'id' => $this->_contactId);
+               'id' => $this->_contactId, 'onPopupClose' => $this->_onPopupClose);
              if ($pageCheckSum) {
                $actionParams['cs'] = $pageCheckSum;
              }
index 153313137283e8695f9b451cababeecf05ca3819..3dec6a66c47d3c0ddb2df874cdb30e0b6be8217f 100644 (file)
@@ -62,7 +62,7 @@
   {/if}
 
   {if !$reachedMax}
-    <a accesskey="N" href="{crmURL p='civicrm/profile/edit' q="id=`$contactId`&multiRecord=add&gid=`$gid`&snippet=1&context=multiProfileDialog"}"
+    <a accesskey="N" href="{crmURL p='civicrm/profile/edit' q="reset=1&id=`$contactId`&multiRecord=add&gid=`$gid`&snippet=1&context=multiProfileDialog&onPopupClose=`$onPopupClose`"}"
        class="button action-item"><span><div class="icon add-icon"></div>{ts}Add New Record{/ts}</span></a>
   {/if}
 {/if}
         }});
       }
 
+      var profileName = {/literal}"{$ufGroupName}"{literal};
       cj('.action-item').each(function () {
-        cj(this).attr('jshref', cj(this).attr('href'));
-        cj(this).attr('href', '#browseValues');
+        if (!cj(this).attr('jshref')) {
+          cj(this).attr('jshref', cj(this).attr('href'));
+          cj(this).attr('href', '#browseValues');
+       }
       });
 
-      cj(".action-item").click(function () {
+      cj(".crm-profile-name-" + profileName + " .action-item").click(function () {
         dataURL = cj(this).attr('jshref');
         dialogTitle = cj(this).attr('title');
         formDialog(dataURL, dialogTitle);