Use shared function to add mapping form now dependencies are gone
authoreileen <emcnaughton@wikimedia.org>
Fri, 6 Sep 2019 00:18:56 +0000 (12:18 +1200)
committereileen <emcnaughton@wikimedia.org>
Fri, 6 Sep 2019 01:47:12 +0000 (13:47 +1200)
CRM/Contact/Import/Form/MapField.php
tests/phpunit/CRM/Contact/Import/Form/MapFieldTest.php

index 79bd3321a45ffa2b3713d79556b1a87b6ec00139..0d2d3ce56ebe069d72a069622c2d554f5df7cf1c 100644 (file)
@@ -198,39 +198,7 @@ class CRM_Contact_Import_Form_MapField extends CRM_Import_Form_MapField {
    */
   public function buildQuickForm() {
     $savedMappingID = (int) $this->get('savedMapping');
-    //to save the current mappings
-    if (!$savedMappingID) {
-      $saveDetailsName = ts('Save this field mapping');
-      $this->applyFilter('saveMappingName', 'trim');
-      $this->add('text', 'saveMappingName', ts('Name'));
-      $this->add('text', 'saveMappingDesc', ts('Description'));
-    }
-    else {
-      $savedMapping = $this->get('savedMapping');
-
-      list($mappingName) = CRM_Core_BAO_Mapping::getMappingFields($savedMapping, TRUE);
-
-      //get loaded Mapping Fields
-      $mappingName = CRM_Utils_Array::value(1, $mappingName);
-
-      $this->assign('loadedMapping', $savedMapping);
-      $this->set('loadedMapping', $savedMapping);
-
-      $params = ['id' => $savedMapping];
-      $temp = [];
-      $mappingDetails = CRM_Core_BAO_Mapping::retrieve($params, $temp);
-
-      $this->assign('savedName', $mappingDetails->name);
-
-      $this->add('hidden', 'mappingId', $savedMapping);
-
-      $this->addElement('checkbox', 'updateMapping', ts('Update this field mapping'), NULL);
-      $saveDetailsName = ts('Save as a new field mapping');
-      $this->add('text', 'saveMappingName', ts('Name'));
-      $this->add('text', 'saveMappingDesc', ts('Description'));
-    }
-
-    $this->addElement('checkbox', 'saveMapping', $saveDetailsName, NULL, ['onclick' => "showSaveDetails(this)"]);
+    $this->buildSavedMappingFields($savedMappingID);
 
     $this->addFormRule(['CRM_Contact_Import_Form_MapField', 'formRule']);
 
index ceea85bb7f141fdae9fb30927b05f6a5dfad027e..500a5fc74c48ba3546e15546c075bfc056b598cd 100644 (file)
@@ -365,8 +365,6 @@ document.forms.MapField['mapper[0][3]'].style.display = 'none';\n",
    *
    * This signature of the function we are calling is funky as a new extraction & will be refined.
    *
-   * @param \CRM_Contact_Import_Form_MapField $form
-   *
    * @param int $mappingID
    * @param int $columnNumber
    *