From: JKingsnorth Date: Thu, 19 Nov 2015 16:58:45 +0000 (+0000) Subject: Refactoring and UI improvements X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=13919cf886019d3c7aa85c018055a1ca5ade727d;p=civicrm-core.git Refactoring and UI improvements --- diff --git a/CRM/Dedupe/Merger.php b/CRM/Dedupe/Merger.php index f90d49c782..5d4c4cfed9 100644 --- a/CRM/Dedupe/Merger.php +++ b/CRM/Dedupe/Merger.php @@ -795,8 +795,8 @@ INNER JOIN civicrm_membership membership2 ON membership1.membership_type_id = m * Array of information about which elements to merge. * @param string $mode * Helps decide how to behave when there are conflicts. - * A 'safe' value skips the merge if there are any un-resolved conflicts. - * Does a force merge otherwise (aggressive mode). + * - A 'safe' value skips the merge if there are any un-resolved conflicts. + * - Does a force merge otherwise (aggressive mode). * * @param array $conflicts * @@ -921,6 +921,7 @@ INNER JOIN civicrm_membership membership2 ON membership1.membership_type_id = m $allPhoneTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Phone', 'phone_type_id'); $allProviderTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_IM', 'provider_id'); $allWebsiteTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Website', 'website_type_id'); + $genders = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'gender_id'); // Fetch contacts foreach (array('main' => $mainId, 'other' => $otherId) as $moniker => $cid) { @@ -983,8 +984,6 @@ INNER JOIN civicrm_membership membership2 ON membership1.membership_type_id = m $rows = $elements = $relTableElements = $migrationInfo = array(); - $genders = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'gender_id'); - foreach ($compareFields['contact'] as $field) { if ($field == 'contact_sub_type') { // CRM-15681 don't display sub-types in UI @@ -1042,7 +1041,12 @@ INNER JOIN civicrm_membership membership2 ON membership1.membership_type_id = m if (is_array($value) && empty($value[1])) { $value[1] = NULL; } - $elements[] = array('advcheckbox', "move_$field", NULL, NULL, NULL, $value); + + // Display a checkbox to migrate, only if the values are different + if ($value != $main[$field]) { + $elements[] = array('advcheckbox', "move_$field", NULL, NULL, NULL, $value); + } + $migrationInfo["move_$field"] = $value; } } @@ -1052,11 +1056,16 @@ INNER JOIN civicrm_membership membership2 ON membership1.membership_type_id = m // Handle location blocks. // @todo OpenID not in API yet, so is not supported here. - $locationBlocks = array('Address', 'Email', 'IM', 'Phone', 'Website'); + $locationBlocks = array( + 'address' => 'Address', + 'email' => 'Email', + 'im' => 'IM', + 'phone' => 'Phone', + 'website' => 'Website', + ); $locations = array(); - foreach ($locationBlocks as $block) { - $blockName = strtolower($block); + foreach ($locationBlocks as $blockName => $block) { foreach (array('main' => $mainId, 'other' => $otherId) as $moniker => $cid) { $cnt = 1; $searchParams = array( @@ -1064,7 +1073,7 @@ INNER JOIN civicrm_membership membership2 ON membership1.membership_type_id = m 'contact_id' => $cid, ); // CRM-17556 Order by location and type - // @todo Temporary fix for websites (no location, only type) + // Handle websites (no location, only type) if ($blockName == 'website') { $searchParams['options'] = array('sort' => 'website_type_id'); } @@ -1117,7 +1126,7 @@ INNER JOIN civicrm_membership membership2 ON membership1.membership_type_id = m $locBlockIds['main'] = $locBlockIds['other'] = array(); $typeBlockIds['main'] = $typeBlockIds['other'] = array(); - foreach ($locationBlocks as $block) { + foreach ($locationBlocks as $blockName => $block) { $name = strtolower($block); foreach (array('main', 'other') as $moniker) { $locIndex = CRM_Utils_Array::value($moniker, $locations); @@ -1316,7 +1325,6 @@ INNER JOIN civicrm_membership membership2 ON membership1.membership_type_id = m $elements[] = array('advcheckbox', "move_location_{$name}_{$count}"); // Add location select list for location block (websites don't have a location) - // @todo make sure websites can be migrated as well if ($name != 'website') { $migrationInfo["move_location_{$name}_{$count}"] = 1; // make sure default location type is always on top @@ -1543,14 +1551,14 @@ INNER JOIN civicrm_membership membership2 ON membership1.membership_type_id = m } // **** Do location related migration. - // @todo Handle websites. // @todo Handle OpenID (not currently in API). if (!empty($locBlocks)) { - $locComponent = array( + + $locationBlocks = array( + 'address' => 'Address', 'email' => 'Email', - 'phone' => 'Phone', 'im' => 'IM', - 'address' => 'Address', + 'phone' => 'Phone', 'website' => 'Website', ); @@ -1561,7 +1569,7 @@ INNER JOIN civicrm_membership membership2 ON membership1.membership_type_id = m if (!is_array($block) || CRM_Utils_System::isNull($block)) { continue; } - $daoName = 'CRM_Core_DAO_' . $locComponent[$name]; + $daoName = 'CRM_Core_DAO_' . $locationBlocks[$name]; $primaryDAOId = (array_key_exists($name, $primaryBlockIds)) ? array_pop($primaryBlockIds[$name]) : NULL; $billingDAOId = (array_key_exists($name, $billingBlockIds)) ? array_pop($billingBlockIds[$name]) : NULL; @@ -1574,7 +1582,7 @@ INNER JOIN civicrm_membership membership2 ON membership1.membership_type_id = m $idKey = $blkCount; if ( $name != 'website' - && array_key_exists($name, $locComponent) + && array_key_exists($name, $locationBlocks) ) { $idKey = $locTypeId; } diff --git a/css/civicrm.css b/css/civicrm.css index 4e2918024e..37e16fb0c5 100644 --- a/css/civicrm.css +++ b/css/civicrm.css @@ -3173,6 +3173,14 @@ div.m ul#civicrm-menu, .crm-container .even.crm-row-selected { background-color: #fffdb2; } +.crm-container table tr.merge-row-equal { + background-color: #EFFFE7; + border-bottom: 1px solid #ccc; +} +.crm-container table tr.merge-row-diff { + background-color: #FFECEC; + border-bottom: 1px solid #ccc; +} #crm-container .crm-socialnetwork { margin-top: 1em; diff --git a/templates/CRM/Contact/Form/Merge.tpl b/templates/CRM/Contact/Form/Merge.tpl index dafda1cab4..723cf88091 100644 --- a/templates/CRM/Contact/Form/Merge.tpl +++ b/templates/CRM/Contact/Form/Merge.tpl @@ -68,7 +68,7 @@ {crmAPI var='main_result' entity='Contact' action='get' return="modified_date" id=$main_cid} - + Last modified {$other_result.values.0.modified_date|date_format:"%d/%m/%y %H:%M:%S"} {if $other_result.values.0.modified_date gt $main_result.values.0.modified_date} (Most recent) {/if} @@ -85,9 +85,9 @@ {else} {if $row.main eq $row.other} - + {else} - + {/if} {$row.title} @@ -160,7 +160,9 @@ {if isset($row.main) || isset($row.other)} - {if $row.main} + {if $row.main == $row.other} + (match)
+ {elseif $row.main} (overwrite)
{else} (add) @@ -292,7 +294,7 @@ You will need to manually delete that user (click on the link to open Drupal Use // Show/hide matching data rows $('.toggle_equal_rows').click(function() { - $('tr.equal-data').toggle(); + $('tr.merge-row-equal').toggle(); }); });