added delete link for soft credit, CRM-12463
authorKurund Jalmi <kurund@civicrm.org>
Sat, 4 May 2013 23:09:08 +0000 (16:09 -0700)
committerKurund Jalmi <kurund@civicrm.org>
Sat, 4 May 2013 23:09:08 +0000 (16:09 -0700)
templates/CRM/Contribute/Form/SoftCredit.js
templates/CRM/Contribute/Form/SoftCredit.tpl

index 001b210f466459a58b179bb871cf6eb2fa52c000..4d6938f54c319ede02a333ee2d92093a6e36dc31 100644 (file)
@@ -49,4 +49,11 @@ cj(function($) {
     }
   });
 
+  $('.delete-link').click(function(){
+    var row = $(this).attr('row-no');
+    $('#soft-credit-row-' + row).hide().find('input').val('');
+    $('input[name="soft_credit_contact_select_id['+row+']"]').val('');
+    return false;
+  });
+
 });
index a3111adef6417bd23cf3da646dca93130825cc87..ca39d484a3f1d3354cf0c536ee6df5b1a5ae3d66 100644 (file)
 {* template for adding form elements for soft credit form*}
 
 <table class="form-layout-compressed crm-soft-credit-block">
-{section name='i' start=1 loop=$rowCount}
-{assign var='rowNumber' value=$smarty.section.i.index}
-  <tr id="soft-credit-row-{$rowNumber}" class="crm-contribution-form-block-soft_credit_to {if $rowNumber gte $showSoftCreditRow}hiddenElement{/if}">
-    <td class="label">{ts}Select Contact{/ts}</td>
+  {section name='i' start=1 loop=$rowCount}
+    {assign var='rowNumber' value=$smarty.section.i.index}
+    <tr id="soft-credit-row-{$rowNumber}"
+        class="crm-contribution-form-block-soft_credit_to {if $rowNumber gte $showSoftCreditRow}hiddenElement{/if}">
+      <td class="label">{ts}Select Contact{/ts}</td>
+      <td>
+        {assign var='createNewStatus' value=true}
+        {if !$showCreateNew and $rowNumber lt $showSoftCreditRow}
+          {assign var='createNewStatus' value=false}
+        {/if}
+        {include file="CRM/Contact/Form/NewContact.tpl" noLabel=true skipBreak=true blockNo=$rowNumber
+        prefix="soft_credit_" showNewSelect=$createNewStatus}
+      </td>
+      <td>
+        {$form.soft_credit_amount.$rowNumber.label}&nbsp;{$form.soft_credit_amount.$rowNumber.html|crmAddClass:eight}
+        &nbsp;<a class="delete-link" row-no={$rowNumber} href="#">{ts}delete{/ts}</a>
+      </td>
+    </tr>
+  {/section}
+  <tr>
+    <td></td>
     <td>
-      {assign var='createNewStatus' value=true}
-      {if !$showCreateNew and $rowNumber lt $showSoftCreditRow}
-        {assign var='createNewStatus' value=false}
-      {/if}
-      {include file="CRM/Contact/Form/NewContact.tpl" noLabel=true skipBreak=true blockNo=$rowNumber
-      prefix="soft_credit_" showNewSelect=$createNewStatus}
+      <a href="#" id="addMoreSoftCredit">{ts}add another soft credit{/ts}</a>
     </td>
-         <td>
-                 {$form.soft_credit_amount.$rowNumber.label}&nbsp;{$form.soft_credit_amount.$rowNumber.html|crmAddClass:eight}
-         </td>
   </tr>
-{/section}
-       <tr>
-               <td></td>
-               <td>
-                       <a href="#" id="addMoreSoftCredit">{ts}add another soft credit{/ts}</a>
-               </td>
-       </tr>
 </table>
\ No newline at end of file