CRM-14937, by default show 2 email and phone for location block in event configuration
authorkurund <kurund@civicrm.org>
Tue, 15 Jul 2014 20:31:22 +0000 (02:01 +0530)
committerkurund <kurund@civicrm.org>
Tue, 15 Jul 2014 20:31:22 +0000 (02:01 +0530)
----------------------------------------
* CRM-14937: CiviEvents: when using existing location on a new event, only the first phone number is loaded causing data loss on save
  https://issues.civicrm.org/jira/browse/CRM-14937

templates/CRM/Event/Form/ManageEvent/Location.tpl

index 05fb5216e06de1e4ff23e97620537faaa4af9078..33dffe58d4a6bacba17b321677be3fa984af71f8 100644 (file)
@@ -96,6 +96,9 @@
 {* Include Javascript to hide and display the appropriate blocks as directed by the php code *}
 {*include file="CRM/common/showHide.tpl"*}
 {if $locEvents}
+  {* include common additional blocks tpl *}
+  {include file="CRM/common/additionalBlocks.tpl"}
+
 <script type="text/javascript">
 {literal}
 var locUsedMsgTxt = {/literal}"{$locUsedMsgTxt}"{literal};
@@ -106,6 +109,18 @@ if ( {/literal}"{$locUsed}"{literal} ) {
 }
 
 cj(document).ready(function() {
+  //FIX ME: by default load 2 blocks and hide add and delete links
+  //we should make additional block function more flexible to set max block limit
+  buildAdditionalBlocks('Email', 'CRM_Event_Form_ManageEvent_Location');
+  buildAdditionalBlocks('Phone', 'CRM_Event_Form_ManageEvent_Location');
+  hideAddDeleteLinks();
+  function hideAddDeleteLinks() {
+    cj('#addEmail').hide();
+    cj('#addPhone').hide();
+    cj('[id=Email_Block_2] a:last').hide();
+    cj('[id=Phone_Block_2] a:last').hide();
+  }
+
   cj('#loc_event_id').change(function() {
     cj.ajax({
       url: CRM.url('civicrm/ajax/locBlock', 'reset=1'),
@@ -123,7 +138,12 @@ cj(document).ready(function() {
               displayMessage( false );
             }
           } else {
-            cj('#'+i).val(data[i]);
+            if (i == 'phone_1_phone_type_id' || i == 'phone_2_phone_type_id') {
+              cj('#'+i).select2('val', data[i]);
+            }
+            else {
+              cj('#'+i).val(data[i]);
+            }
           }
         }
       }
@@ -164,7 +184,4 @@ showLocFields( );
 </script>
 {/if}
 
-{* include common additional blocks tpl *}
-{include file="CRM/common/additionalBlocks.tpl"}
-
 {/if} {* add block if end*}