From: JKingsnorth Date: Wed, 17 Aug 2016 12:58:30 +0000 (+0100) Subject: CRM-19179: Add indication of primary location block X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=041d6d6ba3552830e6688447c0770b43be26a974;p=civicrm-core.git CRM-19179: Add indication of primary location block --- diff --git a/CRM/Dedupe/Merger.php b/CRM/Dedupe/Merger.php index f994219486..78460f923f 100644 --- a/CRM/Dedupe/Merger.php +++ b/CRM/Dedupe/Merger.php @@ -1227,6 +1227,7 @@ INNER JOIN civicrm_membership membership2 ON membership1.membership_type_id = m ) { // Set this value as the default against the 'other' contact value $rows["move_location_{$blockName}_{$count}"]['main'] = $mainValueCheck[$blockInfo['displayField']]; + $rows["move_location_{$blockName}_{$count}"]['main_is_primary'] = $mainValueCheck['is_primary']; $mainContactBlockId = $mainValueCheck['id']; break; } diff --git a/templates/CRM/Contact/Form/Merge.tpl b/templates/CRM/Contact/Form/Merge.tpl index d830fc3636..2d5c309f2d 100644 --- a/templates/CRM/Contact/Form/Merge.tpl +++ b/templates/CRM/Contact/Form/Merge.tpl @@ -113,7 +113,9 @@ {assign var=blockName value=$field|substr:14:$position-14} - {if $row.title|substr:0:7 == "Address"}{else}{/if}{if !is_array($row.other)}{$row.other}{elseif $row.other.fileName}{$row.other.fileName}{else}{', '|implode:$row.other}{/if} + {* @TODO check if this is ever an array or a fileName? *} + {* This is on one long line for address formatting *} + {if $row.title|substr:0:7 == "Address"}{else}{/if}{if !is_array($row.other)}{$row.other}{elseif $row.other.fileName}{$row.other.fileName}{else}{', '|implode:$row.other}{/if} @@ -128,7 +130,9 @@ $row.title|substr:0:5 == "Phone"} - {if $row.title|substr:0:7 == "Address"}{else}{/if}{if !is_array($row.main)}{$row.main}{elseif $row.main.fileName}{$row.main.fileName}{else}{', '|implode:$row.main}{/if} + {* @TODO check if this is ever an array or a fileName? *} + {* This is on one long line for address formatting *} + {if $row.title|substr:0:7 == "Address"}{else}{/if}{if !is_array($row.main)}{$row.main}{elseif $row.main.fileName}{$row.main.fileName}{else}{', '|implode:$row.main}{/if} @@ -145,7 +149,13 @@ {* Display the overwrite/add/add new label *} {if $row.main} - ({ts}overwrite{/ts})  + + {* Display whether it is primary *} + {if $row.main_is_primary == "1"} + Primary  + {/if} + ({ts}overwrite{/ts}) + {if $blockName eq 'email' || $blockName eq 'phone' } {$form.location_blocks.$blockName.$blockId.operation.html}  {/if} @@ -154,6 +164,7 @@ ({ts}add{/ts})  {/if} + {* For non-location blocks *} @@ -266,13 +277,21 @@ label = '({/literal}{ts}add{/ts}{literal})'; } else { - // Set display and ID mainBlockDisplay = mainBlock['display']; mainBlockId = mainBlock['id']; // Set label - var label = '({/literal}{ts}overwrite{/ts}{literal}) '; + var label = ''; + + // Check if the main location is primary + console.log(mainBlock); + if (mainBlock['is_primary'] == "1") { + label += 'Primary '; + } + + // Display the action + label += '({/literal}{ts}overwrite{/ts}{literal}) '; if (blockname == 'email' || blockname == 'phone') { var opLabel = 'location_blocks[' + blockname + '][' + blockId + '][operation]'; label += '
'; @@ -310,7 +329,8 @@ if (locationBlockInfo[entName]['hasType'] == false || typeID == entityArray[i][locationBlockInfo[entName]['hasType']]) { result = { display: entityArray[i][locationBlockInfo[entName]['displayField']], - id: entityArray[i]['id'] + id: entityArray[i]['id'], + is_primary: entityArray[i]['is_primary'] }; break; }