From b3206d3bb12e6684434fe801cd1bfc5ee2f3b0a8 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Sun, 2 Apr 2023 19:04:30 +1200 Subject: [PATCH] Minor fixes to Civi-Import screen, populating defaults, missing ts --- CRM/Contribute/Import/Parser/Contribution.php | 15 ++++++++++++--- ext/civiimport/ang/crmCiviimport.js | 2 +- ext/civiimport/ang/crmCiviimport/Import.html | 8 ++++---- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/CRM/Contribute/Import/Parser/Contribution.php b/CRM/Contribute/Import/Parser/Contribution.php index 1c7c0792ec..2017f3e850 100644 --- a/CRM/Contribute/Import/Parser/Contribution.php +++ b/CRM/Contribute/Import/Parser/Contribution.php @@ -338,12 +338,16 @@ class CRM_Contribute_Import_Parser_Contribution extends CRM_Import_Parser { * @throws \CRM_Core_Exception */ public function getImportEntities() : array { - $softCreditTypes = ContributionSoft::getFields() - ->setLoadOptions(['id', 'name', 'label', 'description']) + $softCreditTypes = ContributionSoft::getFields(FALSE) + ->setLoadOptions(['id', 'name', 'label', 'description', 'is_default']) ->addWhere('name', '=', 'soft_credit_type_id') ->selectRowCount() ->addSelect('options')->execute()->first()['options']; + $defaultSoftCreditTypeID = NULL; foreach ($softCreditTypes as &$softCreditType) { + if (empty($defaultSoftCreditTypeID) || $softCreditType['is_default']) { + $defaultSoftCreditTypeID = $softCreditType['id']; + } $softCreditType['text'] = $softCreditType['label']; } @@ -389,7 +393,12 @@ class CRM_Contribute_Import_Parser_Contribution extends CRM_Import_Parser { 'is_contact' => TRUE, 'is_required' => FALSE, 'actions' => array_merge([['id' => 'ignore', 'text' => ts('Do not import')]], $this->getActions(['select', 'update', 'save'])), - 'selected' => ['contact_type' => '', 'soft_credit_type_id' => reset($softCreditTypes)['id'], 'action' => 'ignore'], + 'selected' => [ + 'contact_type' => 'Individual', + 'soft_credit_type_id' => $defaultSoftCreditTypeID, + 'action' => 'ignore', + 'dedupe_rule' => $this->getDedupeRule('Individual')['name'], + ], 'default_action' => 'ignore', 'entity_name' => 'SoftCreditContact', 'entity_field_prefix' => 'soft_credit.contact.', diff --git a/ext/civiimport/ang/crmCiviimport.js b/ext/civiimport/ang/crmCiviimport.js index 5927a2ab98..dd4280aaaf 100644 --- a/ext/civiimport/ang/crmCiviimport.js +++ b/ext/civiimport/ang/crmCiviimport.js @@ -265,7 +265,7 @@ // For now we just hard-code this - mapping to soft_credit a bit undefined - but // we are mimicking getMappingFieldFromMapperInput on the php layer. // Could get it from entity_data but .... later. - entityConfig = {'soft_credit': $scope.userJob.metadata.entity_configuration[selectedEntity].entity.entity_data}; + entityConfig = {'soft_credit': $scope.userJob.metadata.entity_configuration[selectedEntity]}; } $scope.userJob.metadata.import_mappings.push({ diff --git a/ext/civiimport/ang/crmCiviimport/Import.html b/ext/civiimport/ang/crmCiviimport/Import.html index bd623388b7..e0132f9c09 100644 --- a/ext/civiimport/ang/crmCiviimport/Import.html +++ b/ext/civiimport/ang/crmCiviimport/Import.html @@ -56,7 +56,7 @@
@@ -142,8 +142,8 @@
- - - + + +
-- 2.25.1