CRM-19485, Fixed selector issue on Batch Transaction form
authorPradeep Nayak <pradpnayak@gmail.com>
Tue, 11 Oct 2016 15:25:25 +0000 (20:55 +0530)
committerPradeep Nayak <pradpnayak@gmail.com>
Thu, 20 Oct 2016 12:40:50 +0000 (18:10 +0530)
----------------------------------------
* CRM-19485: Selector issue on Batch trxn assignment page
  https://issues.civicrm.org/jira/browse/CRM-19485

templates/CRM/Financial/Form/BatchTransaction.tpl

index 2a6a457fa6042a3b70d5870513fcfb653892e1bb..487d16138c24e535c4448da46b3bd5264a524c0e 100644 (file)
@@ -52,6 +52,7 @@
             {else}
             <td>&nbsp;</td>
           {/if}
+          </tr>
           {include file="CRM/Contribute/Form/Search/Common.tpl"}
         </table>
        <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div>
@@ -143,20 +144,10 @@ CRM.$(function($) {
     });
 
     CRM.$("#crm-transaction-selector-assign-{/literal}{$entityID}{literal} #toggleSelect").click( function() {
-      if (CRM.$("#crm-transaction-selector-assign-{/literal}{$entityID}{literal} #toggleSelect").is(':checked')) {
-        CRM.$("#crm-transaction-selector-assign-{/literal}{$entityID}{literal} input[id^='mark_x_']").prop('checked',true);
-      }
-      else {
-        CRM.$("#crm-transaction-selector-assign-{/literal}{$entityID}{literal} input[id^='mark_x_']").prop('checked',false);
-      }
+      toggleFinancialSelections('#toggleSelect', 'assign');
     });
     CRM.$("#crm-transaction-selector-remove-{/literal}{$entityID}{literal} #toggleSelects").click( function() {
-      if (CRM.$("#crm-transaction-selector-remove-{/literal}{$entityID}{literal} #toggleSelects").is(':checked')) {
-        CRM.$("#crm-transaction-selector-remove-{/literal}{$entityID}{literal} input[id^='mark_y_']").prop('checked',true);
-      }
-      else {
-        CRM.$("#crm-transaction-selector-remove-{/literal}{$entityID}{literal} input[id^='mark_y_']").prop('checked',false);
-      }
+      toggleFinancialSelections('#toggleSelects', 'remove');
     });
   {/literal}{else}{literal}
     buildTransactionSelectorRemove();
@@ -172,6 +163,19 @@ function enableActions( type ) {
   }
 }
 
+function toggleFinancialSelections(toggleID, toggleClass) {
+  mark = 'x';
+  if (toggleClass == 'remove') {
+    mark = 'y';
+  }
+  if (CRM.$("#crm-transaction-selector-" + toggleClass + "-{/literal}{$entityID}{literal} " +  toggleID).is(':checked')) {
+    CRM.$("#crm-transaction-selector-" + toggleClass + "-{/literal}{$entityID}{literal} input[id^='mark_" + mark + "_']").prop('checked',true);
+  }
+  else {
+    CRM.$("#crm-transaction-selector-" + toggleClass + "-{/literal}{$entityID}{literal} input[id^='mark_" + mark + "_']").prop('checked',false);
+  }
+}
+
 function buildTransactionSelectorAssign(filterSearch) {
   var columns = '';
   var sourceUrl = {/literal}'{crmURL p="civicrm/ajax/rest" h=0 q="className=CRM_Financial_Page_AJAX&fnName=getFinancialTransactionsList&snippet=4&context=financialBatch&entityID=$entityID&notPresent=1&statusID=$statusID"}'{literal};
@@ -238,12 +242,14 @@ function buildTransactionSelectorAssign(filterSearch) {
     CRM.$.ajax({
       "dataType": 'json',
       "type": "POST",
+      'async': false,
       "url": sSource,
       "data": aoData,
       "success": fnCallback
     });
   }
 });
+toggleFinancialSelections('#toggleSelect', 'assign');
 }
 
 function buildTransactionSelectorRemove( ) {
@@ -295,10 +301,12 @@ function buildTransactionSelectorRemove( ) {
       "type": "POST",
       "url": sSource,
       "data": aoData,
+      'async': false,
       "success": fnCallback
     });
   }
 });
+toggleFinancialSelections('#toggleSelects', 'remove');
 }
 
 function selectAction( id, toggleSelectId, checkId ) {