Skip to content

Commit

Permalink
Merge pull request #15189 from eileenmcnaughton/import_tiny
Browse files Browse the repository at this point in the history
[Import][ref] Minor code improvement -  move setDefaults to processor
  • Loading branch information
colemanw authored Sep 4, 2019
2 parents 6e80fe5 + df90a4d commit 1f84e94
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
14 changes: 1 addition & 13 deletions CRM/Contact/Import/Form/MapField.php
Original file line number Diff line number Diff line change
Expand Up @@ -914,19 +914,7 @@ public function loadSavedMapping($processor, $mappingName, $i, $defaults, $js, $
$jsSet = TRUE;
}
else {
$mappingHeader = $processor->getFieldName($i);
$websiteTypeId = $processor->getWebsiteTypeID($i);
$locationId = $processor->getLocationTypeID($i);
$typeId = $processor->getPhoneOrIMTypeID($i);

if ($websiteTypeId) {
$defaults["mapper[$i]"] = [$mappingHeader, $websiteTypeId];
}
else {
//default for IM/phone without related contact
$defaults["mapper[$i]"] = [$mappingHeader ?? '', $locationId, $typeId];
}

$defaults["mapper[$i]"] = $processor->getSavedQuickformDefaultsForColumn($i);
$js .= $processor->getQuickFormJSForField($i);

$jsSet = TRUE;
Expand Down
15 changes: 15 additions & 0 deletions CRM/Import/ImportProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -504,4 +504,19 @@ public function getQuickFormJSForField($column) {
return implode("\n", $jsClauses) . "\n";
}

/**
* Get the defaults for the column from the saved mapping.
*
* @param int $column
*
* @return array
* @throws \CiviCRM_API3_Exception
*/
public function getSavedQuickformDefaultsForColumn($column) {
if ($this->getWebsiteTypeID($column)) {
return [$this->getFieldName($column), $this->getWebsiteTypeID($column)];
}
return [(string) $this->getFieldName($column), $this->getLocationTypeID($column), $this->getPhoneOrIMTypeID($column)];
}

}

0 comments on commit 1f84e94

Please sign in to comment.