worked on CRM-12235, added missing feature of inline edit for multi-value custom...
authorkurund <kurund@civicrm.org>
Mon, 15 Apr 2013 21:47:21 +0000 (03:17 +0530)
committerkurund <kurund@civicrm.org>
Mon, 15 Apr 2013 21:47:21 +0000 (03:17 +0530)
----------------------------------------
* CRM-12235: Inline edit of multi-record custom fields broken
  http://issues.civicrm.org/jira/browse/CRM-12235

CRM/Contact/Form/Inline/CustomData.php
CRM/Contact/Page/Inline/CustomData.php
templates/CRM/Contact/Page/View/CustomDataFieldView.tpl
templates/CRM/Contact/Page/View/CustomDataView.tpl

index ad9e73ae2e4d7005c7dcab8b40f97b2ecba48434..6bea43e1a5fcb2f56abede24d1ba786196d68dd8 100644 (file)
@@ -61,9 +61,9 @@ class CRM_Contact_Form_Inline_CustomData extends CRM_Contact_Form_Inline {
 
     $this->_groupID = CRM_Utils_Request::retrieve('groupID', 'Positive', $this, TRUE, NULL, $_REQUEST);
     $this->assign('customGroupId', $this->_groupID);
-
+    $customRecId = CRM_Utils_Request::retrieve('customRecId', 'Positive', $this, FALSE, 1, $_REQUEST);
     $subType = CRM_Contact_BAO_Contact::getContactSubType($this->_contactId, ',');
-    CRM_Custom_Form_CustomData::preProcess($this, null, $subType, 1,
+    CRM_Custom_Form_CustomData::preProcess($this, null, $subType, $customRecId,
       $this->_contactType, $this->_contactId);
   }
 
index 3eb0e48e60077d7d824d912398af3a5eed431742..a6a150d8d9ded92650c1eafdbb46bb1584e10ae6 100644 (file)
@@ -34,7 +34,7 @@
  */
 
 /**
- * This page displays custom data during inline edit 
+ * This page displays custom data during inline edit
  *
  */
 class CRM_Contact_Page_Inline_CustomData extends CRM_Core_Page {
@@ -52,17 +52,19 @@ class CRM_Contact_Page_Inline_CustomData extends CRM_Core_Page {
     // get the emails for this contact
     $contactId = CRM_Utils_Request::retrieve('cid', 'Positive', CRM_Core_DAO::$_nullObject, TRUE, NULL, $_REQUEST);
     $cgId = CRM_Utils_Request::retrieve('groupID', 'Positive', CRM_Core_DAO::$_nullObject, TRUE, NULL, $_REQUEST);
+    $customRecId = CRM_Utils_Request::retrieve('customRecId', 'Positive', CRM_Core_DAO::$_nullObject, FALSE, 1, $_REQUEST);
+
     //custom groups Inline
     $entityType    = CRM_Contact_BAO_Contact::getContactType($contactId);
     $entitySubType = CRM_Contact_BAO_Contact::getContactSubType($contactId);
     $groupTree     = &CRM_Core_BAO_CustomGroup::getTree($entityType, $this, $contactId,
       $cgId, $entitySubType
       );
-
     $details = CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree);
-    $fields = array_pop($details[$cgId]);
+    //get the fields of single custom group record
+    $fields = CRM_Utils_Array::value($customRecId, $details[$cgId]);
 
+    $this->assign('customRecId', $customRecId);
     $this->assign('contactId', $contactId);
     $this->assign('customGroupId', $cgId);
     $this->assign_by_ref('cd_edit', $fields);
@@ -70,8 +72,7 @@ class CRM_Contact_Page_Inline_CustomData extends CRM_Core_Page {
     // check logged in user permission
     CRM_Contact_Page_View::checkUserPermission($this, $contactId);
     
-    // finally call parent 
+    // finally call parent
     parent::run();
   }
 }
-
index 9b70a60cb0bf154ded44502ce1f8b0b1b41b96bc..8122e3325bfbee84ce75a4bfc2ed0aa61a8e0ccc 100644 (file)
@@ -23,7 +23,7 @@
  | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
  +--------------------------------------------------------------------+
 *}
-<div id="custom-set-content-{$customGroupId}" {if $permission EQ 'edit'} class="crm-inline-edit" data-edit-params='{ldelim}"cid": "{$contactId}", "class_name": "CRM_Contact_Form_Inline_CustomData", "groupID": "{$customGroupId}"{rdelim}'{/if}>
+<div id="custom-set-content-{$customGroupId}" {if $permission EQ 'edit'} class="crm-inline-edit" data-edit-params='{ldelim}"cid": "{$contactId}", "class_name": "CRM_Contact_Form_Inline_CustomData", "groupID": "{$customGroupId}", "customRecId": "{$customRecId}"{rdelim}'{/if}>
   <div class="crm-clear crm-inline-block-content" {if $permission EQ 'edit'}title="{ts}Edit{/ts}"{/if}>
     {if $permission EQ 'edit'}
       <div class="crm-edit-help">
index d3426fa80a265d7edb8ed3f0a2800b03ab8056d9..a89fc7553eaad89e1e6d0f913cc5056380cc6104 100644 (file)
         <div class="collapsible-title">
           {$cd_edit.title}
         </div>
-        <div class="crm-summary-block" id="custom-set-block-{$customGroupId}">
-          {include file="CRM/Contact/Page/View/CustomDataFieldView.tpl" customGroupId=$customGroupId}
+        {if $cvID eq 0}
+          {assign var='cvID' value='-1'}
+        {/if}
+        <div class="crm-summary-block" id="custom-set-block-{$customGroupId}-{$cvID}">
+          {include file="CRM/Contact/Page/View/CustomDataFieldView.tpl" customGroupId=$customGroupId customRecId=$cvID}
         </div>
       </div>
     {/foreach}