From: kurund Date: Tue, 15 Jul 2014 21:03:43 +0000 (+0530) Subject: CRM-14937, code cleanup X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=f16f7f7579ebbbfcb4c979c1e1717db81114ed33;p=civicrm-core.git CRM-14937, code cleanup ---------------------------------------- * 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 --- diff --git a/templates/CRM/Event/Form/ManageEvent/Location.tpl b/templates/CRM/Event/Form/ManageEvent/Location.tpl index 33dffe58d4..1ac4deb8a3 100644 --- a/templates/CRM/Event/Form/ManageEvent/Location.tpl +++ b/templates/CRM/Event/Form/ManageEvent/Location.tpl @@ -111,14 +111,21 @@ 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(); + buildBlocks('Email'); + buildBlocks('Phone'); + + // build blocks only if it is not built + function buildBlocks(element) { + if (!cj('[id='+ element +'_Block_2]').length) { + buildAdditionalBlocks(element, 'CRM_Event_Form_ManageEvent_Location'); + } + } + + hideAddDeleteLinks('Email'); + hideAddDeleteLinks('Phone'); + function hideAddDeleteLinks(element) { + cj('#add'+ element).hide(); + cj('[id='+ element +'_Block_2] a:last').hide(); } cj('#loc_event_id').change(function() {