From 60e37cae51463bd92f7360784a83bc19cce35281 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Tue, 26 Mar 2013 14:50:35 -0700 Subject: [PATCH] Address delete button CRM-12218 --- templates/CRM/Contact/Form/Inline/Address.tpl | 3 +++ templates/CRM/Contact/Page/View/Summary.js | 20 ++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/templates/CRM/Contact/Form/Inline/Address.tpl b/templates/CRM/Contact/Form/Inline/Address.tpl index b013d1124a..5f35234c2b 100644 --- a/templates/CRM/Contact/Form/Inline/Address.tpl +++ b/templates/CRM/Contact/Form/Inline/Address.tpl @@ -30,6 +30,9 @@
{include file="CRM/common/formButtons.tpl"} + {if $addressId} +  
{ts}Delete{/ts}
+ {/if}
diff --git a/templates/CRM/Contact/Page/View/Summary.js b/templates/CRM/Contact/Page/View/Summary.js index 1018791953..35b365fbf8 100644 --- a/templates/CRM/Contact/Page/View/Summary.js +++ b/templates/CRM/Contact/Page/View/Summary.js @@ -72,7 +72,7 @@ // Delete an address if (o.hasClass('address') && !o.hasClass('add-new') && !response.addressId) { o.parent().remove(); - CRM.alert('', ts('Removed'), 'success'); + CRM.alert('', ts('Address Deleted'), 'success'); } else { // Reload this block plus all dependent blocks @@ -243,6 +243,24 @@ } $('.add-more-inline', form).show(); }) + // Delete an address + .on('click', '.crm-inline-edit.address .delete-button', function() { + var $block = $(this).closest('.crm-inline-edit.address'); + CRM.confirm(function() { + CRM.api('address', 'delete', {id: $block.data('edit-params').aid}, {success: + function(data) { + CRM.alert('', ts('Address Deleted.'), 'success'); + $('.crm-inline-edit-container').addClass('crm-edit-ready'); + $block.remove(); + } + }); + }, + { + message: ts('Are you sure you want to delete this address?') + } + ); + return false; + }) // add more and set focus to new row .on('click', '.add-more-inline', function() { var form = $(this).closest('form'); -- 2.25.1