Move unshared code to unshared function
authorEileen McNaughton <emcnaughton@wikimedia.org>
Wed, 10 Aug 2022 07:18:46 +0000 (19:18 +1200)
committerEileen McNaughton <emcnaughton@wikimedia.org>
Wed, 10 Aug 2022 07:18:46 +0000 (19:18 +1200)
templates/CRM/Contact/Import/Form/MapField.tpl
templates/CRM/Contact/Import/Form/MapTable.tpl

index a5f888946da6171c7f7c5023b48720d8a230bb25..7168bf9fd552302fd99f8fab5483adb142322f6d 100644 (file)
   {* Table for mapping data to CRM fields *}
  {include file="CRM/Contact/Import/Form/MapTable.tpl" mapper=$form.mapper}
 
+ {* // Set default location type *}
+ {literal}
+   <script type="text/javascript">
+     CRM.$(function($) {
+       var defaultLocationType = "{/literal}{$defaultLocationType}{literal}";
+       if (defaultLocationType.length) {
+        $('#map-field').on('change', 'select[id^="mapper"][id$="_0"]', function() {
+          var select = $(this).next();
+          $('option', select).each(function() {
+            if ($(this).attr('value') == defaultLocationType  && $(this).text() == {/literal}{
+              $defaultLocationTypeLabel|@json_encode}{literal}) {
+              select.val(defaultLocationType);
+            }
+          });
+        });
+       }
+     });
+   </script>
+ {/literal}
+
 <script type="text/javascript" >
 {literal}
 if ( document.getElementsByName("saveMapping")[0].checked ) {
index b13969c0fdddf9aaa272c2fb69e71c3b737cca35..4e8041ba7417e9f145936ba9bd614aaf119a18d1 100644 (file)
@@ -8,25 +8,3 @@
  +--------------------------------------------------------------------+
 *}
 {include file="CRM/Import/Form/MapTableCommon.tpl"}
-
-{if $wizard.currentStepName != 'Preview'}
-  {* // Set default location type *}
-  {literal}
-    <script type="text/javascript">
-    CRM.$(function($) {
-      var defaultLocationType = "{/literal}{$defaultLocationType}{literal}";
-      if (defaultLocationType.length) {
-        $('#map-field').on('change', 'select[id^="mapper"][id$="_0"]', function() {
-          var select = $(this).next();
-          $('option', select).each(function() {
-            if ($(this).attr('value') == defaultLocationType  && $(this).text() == {/literal}{
-              $defaultLocationTypeLabel|@json_encode}{literal}) {
-              select.val(defaultLocationType);
-            }
-          });
-        });
-      }
-    });
-    </script>
-  {/literal}
-{/if}