From 3bdb54e6ebcabd4ba6aa17356e4c86a084186e0f Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Thu, 9 Mar 2023 16:22:20 +1300 Subject: [PATCH] Consolidate DataSource.tpl --- .../CRM/Contact/Import/Form/DataSource.tpl | 163 +----------------- templates/CRM/Import/Form/DataSource.tpl | 108 +++++++++++- 2 files changed, 101 insertions(+), 170 deletions(-) diff --git a/templates/CRM/Contact/Import/Form/DataSource.tpl b/templates/CRM/Contact/Import/Form/DataSource.tpl index 7d9987b31d..5395b37fcf 100644 --- a/templates/CRM/Contact/Import/Form/DataSource.tpl +++ b/templates/CRM/Contact/Import/Form/DataSource.tpl @@ -7,165 +7,4 @@ | and copyright information, see https://civicrm.org/licensing | +--------------------------------------------------------------------+ *} - -
- {* Import Wizard - Step 1 (choose data source) *} - {* WizardHeader.tpl provides visual display of steps thru the wizard as well as title for current step *} - {include file="CRM/common/WizardHeader.tpl"} -
- {ts}The Import Wizard allows you to easily import contact records from other applications into CiviCRM. For example, if your organization has contacts in MS Access® or Excel®, and you want to start using CiviCRM to store these contacts, you can 'import' them here.{/ts} {help id='choose-data-source-intro'} -
-
{include file="CRM/common/formButtons.tpl" location="top"}
-
-

{ts}Choose Data Source{/ts}

- - - - - -
{$form.dataSource.label}{$form.dataSource.html} {help id='data-source-selection'}
-
- - {* Data source form pane is injected here when the data source is selected. *} -
-
- -
-

{ts}Import Options{/ts}

- - {if array_key_exists('contactType', $form)} - - - - - {/if} - {if array_key_exists('onDuplicate', $form)} - - - - - {/if} - {if array_key_exists('dedupe_rule_id', $form)} - - - - - {/if} - {include file="CRM/Core/Date.tpl"} - - - - - {if array_key_exists('doGeocodeAddress', $form)} - - - - - {/if} - - {if array_key_exists('savedMapping', $form)} - - - - - {/if} - - {if array_key_exists('disableUSPS', $form)} - - - - - {/if} -
{$form.contactType.label}{$form.contactType.html} {help id='contact-type'}{if array_key_exists('contactSubType', $form)}    - {$form.contactSubType.label}   {$form.contactSubType.html} {help id='contact-sub-type'}{/if} -
{$form.onDuplicate.label}{$form.onDuplicate.html} {help id='dupes'}
{$form.dedupe_rule_id.label}{$form.dedupe_rule_id.html} {help id='id-dedupe_rule'}
{ts}Select the format that is used for date fields in your import data.{/ts}
{$form.doGeocodeAddress.html} {$form.doGeocodeAddress.label}
- - {ts}This option is not recommended for large imports. Use the command-line geocoding script instead.{/ts} - - {docURL page="user/initial-set-up/scheduled-jobs"} -
{$form.savedMapping.html}
-     {ts}Select Saved Mapping or Leave blank to create a new One.{/ts} -
{$form.disableUSPS.html}
-     {ts}Uncheck at your own risk as batch processing violates USPS API TOS.{/ts} -
-
- -
{include file="CRM/common/formButtons.tpl" location="bottom"}
- {literal} - - {/literal} -
+{include file="CRM/Import/Form/DataSource.tpl"} diff --git a/templates/CRM/Import/Form/DataSource.tpl b/templates/CRM/Import/Form/DataSource.tpl index 5da2f56a9f..9a2b4686ca 100644 --- a/templates/CRM/Import/Form/DataSource.tpl +++ b/templates/CRM/Import/Form/DataSource.tpl @@ -37,41 +37,82 @@ {* Data source form pane is injected here when the data source is selected. *}
+
+

{ts}Import Options{/ts}

{if array_key_exists('contactType', $form)} - {/if} + {if array_key_exists('contactSubType', $form)} + + + + + {/if} + {if array_key_exists('onDuplicate', $form)} {/if} + {if array_key_exists('dedupe_rule_id', $form)} + + + + + {/if} {if array_key_exists('multipleCustomData', $form)} {/if} - {include file="CRM/Core/Date.tpl"} + {include file="CRM/Core/Date.tpl"} + + + + + {if array_key_exists('doGeocodeAddress', $form)} + + + + + {/if} + {if array_key_exists('disableUSPS', $form)} + + + + + {/if} {if array_key_exists('savedMapping', $form)} - + {/if}
{$form.contactType.label}{$form.contactType.html}
- - {ts 1=$importEntities}Select 'Individual' if you are importing %1 made by individual persons.{/ts} - {ts 1=$importEntities}Select 'Organization' or 'Household' if you are importing %1 to contacts of that type.{/ts} - +
{$form.contactType.html}{help id='contact-type'}
+ {if $importEntity !== 'Contact'} + + {ts 1=$importEntities}Select 'Individual' if you are importing %1 made by individual persons.{/ts} + {ts 1=$importEntities}Select 'Organization' or 'Household' if you are importing %1 to contacts of that type.{/ts} + + {/if}
{$form.contactSubType.label}{$form.contactSubType.html} {help id='contact-sub-type'}
{$form.onDuplicate.label} {$form.onDuplicate.html} {help id="id-onDuplicate"}
{$form.dedupe_rule_id.label}{$form.dedupe_rule_id.html} {help id='id-dedupe_rule'}
{$form.multipleCustomData.label} {$form.multipleCustomData.html}
{ts}Select the format that is used for date fields in your import data.{/ts}
{$form.doGeocodeAddress.html} {$form.doGeocodeAddress.label}
+ + {ts}This option is not recommended for large imports. Use the command-line geocoding script instead.{/ts} + + {docURL page="user/initial-set-up/scheduled-jobs"} +
{$form.disableUSPS.html}
+     {ts}Uncheck at your own risk as batch processing violates USPS API TOS.{/ts} +
{$form.savedMapping.label} {$form.savedMapping.html}
{ts}If you want to use a previously saved import field mapping - select it here.{/ts}
-
+
+
{include file="CRM/common/formButtons.tpl" location="bottom"}
{literal} @@ -79,6 +120,8 @@ CRM.$(function($) { // build data source form block buildDataSourceFormBlock(); + buildSubTypes(); + buildDedupeRules(); }); function buildDataSourceFormBlock(dataSource) { @@ -97,6 +140,55 @@ CRM.$("#data-source-form-block").load(dataUrl); } + + function buildSubTypes( ) + { + element = cj('input[name="contactType"]:checked').val( ); + var postUrl = {/literal}"{crmURL p='civicrm/ajax/subtype' h=0 }"{literal}; + var param = 'parentId='+ element; + cj.ajax({ type: "POST", url: postUrl, data: param, async: false, dataType: 'json', + success: function(subtype) + { + if ( subtype.length === 0 ) { + cj("#contactSubType").empty(); + cj("#contact-subtype").hide(); + } + else { + cj("#contact-subtype").show(); + cj("#contactSubType").empty(); + cj("#contactSubType").append(""); + for ( var key in subtype ) { + // stick these new options in the subtype select + cj("#contactSubType").append(""); + } + } + } + }); + } + + function buildDedupeRules( ) + { + element = cj("input[name=contactType]:checked").val(); + var postUrl = {/literal}"{crmURL p='civicrm/ajax/dedupeRules' h=0 }"{literal}; + var param = 'parentId='+ element; + cj.ajax({ type: "POST", url: postUrl, data: param, async: false, dataType: 'json', + success: function(dedupe){ + if ( dedupe.length === 0 ) { + cj("#dedupe_rule_id").empty(); + cj("#contact-dedupe").hide(); + } else { + cj("#contact-dedupe").show(); + cj("#dedupe_rule_id").empty(); + + cj("#dedupe_rule_id").append(""); + for ( var key in dedupe ) { + // stick these new options in the dedupe select + cj("#dedupe_rule_id").append(""); + } + } + } + }); + } {/literal} -- 2.25.1