CRM-12872 - Update component search to display count
authorColeman Watts <coleman@civicrm.org>
Tue, 3 Jun 2014 12:29:30 +0000 (13:29 +0100)
committerColeman Watts <coleman@civicrm.org>
Tue, 3 Jun 2014 12:31:12 +0000 (13:31 +0100)
js/Common.js
js/crm.searchForm.js
templates/CRM/Contact/Form/Search/ResultTasks.tpl
templates/CRM/common/searchResultTasks.tpl

index ee438daa50609905178fbdad109dc00656bb42d2..2681102e5e5f9f6d7200bbff9adc6c186969f7cd 100644 (file)
@@ -452,13 +452,6 @@ CRM.validate = CRM.validate || {
   // Initialize widgets
   $(document)
     .on('crmLoad', function(e) {
-      $('table.form-layout-compressed')
-        .on('change', 'input.select-rows', function () {
-          if ($(this).prop('checked')) {
-            $('input#toggleSelect:checked').prop('checked', false);
-            $('input.select-row:checked').prop('checked', false);
-          }
-         })
       $('table.row-highlight', e.target)
         .off('.rowHighlight')
         .on('change.rowHighlight', 'input.select-row, input.select-rows', function (e, data) {
@@ -472,9 +465,6 @@ CRM.validate = CRM.validate || {
             if (data !== 'master-selected') {
               $('input.select-rows', $table).prop('checked', $(".select-row:not(':checked')", $table).length < 1);
             }
-           if ($(this).prop('checked')) {
-             $('input[value=ts_sel]:radio').prop('checked', true);
-           }
           }
         })
         .find('input.select-row:checked').parents('tr').addClass('crm-row-selected');
index 04c002fc548a3ac6274c3a2bedcba9ebe240821a..29e5bbea52b485676a69c6b2d809f6c5663b2938 100644 (file)
@@ -1,16 +1,5 @@
 // http://civicrm.org/licensing
 
-function countSelectedCheckboxes(fldPrefix, form) {
-  fieldCount = 0;
-  for (i = 0; i < form.elements.length; i++) {
-    fpLen = fldPrefix.length;
-    if (form.elements[i].type == 'checkbox' && form.elements[i].name.slice(0, fpLen) == fldPrefix && form.elements[i].checked == true) {
-      fieldCount++;
-    }
-  }
-  return fieldCount;
-}
-
 (function($, _) {
   "use strict";
   var form = 'form.crm-search-form';
@@ -25,9 +14,17 @@ function countSelectedCheckboxes(fldPrefix, form) {
     }
   }
 
+  function countCheckboxes() {
+    $('label[for*=ts_sel] span', form).text($('input.select-row:checked', form).length);
+  }
+
   $('#crm-container')
     .on('change', '[name=radio_ts], .select-row', toggleTaskMenu)
+    .on('change', 'input.select-row', countCheckboxes)
     .on('crmLoad', toggleTaskMenu)
+    .on('click', 'input.select-row, input.select-rows', function() {
+      $(this).closest('form').find('input[name=radio_ts][value=ts_sel]').prop('checked', true);
+    })
     .on('change', 'select#task', function() {
       $(this).siblings('input[type=submit]').click();
     });
index 3db10ead9794eee720df3481398cc55817a3e98d..011d94e6a5f62b41da7af918e35231d24b7ef7b1 100644 (file)
@@ -69,7 +69,7 @@
   <tr>
     <td class="font-size11pt"> {ts}Select Records{/ts}:</td>
     <td class="nowrap">
-        {$form.radio_ts.ts_all.html} <label for="{$ts_all_id}">{ts count=$pager->_totalItems plural='All %count records'}The found record{/ts}</label> &nbsp; {if $pager->_totalItems > 1} {$form.radio_ts.ts_sel.html} <label for="{$ts_sel_id}">{ts}Selected records only{/ts}</label>{/if}
+        {$form.radio_ts.ts_all.html} <label for="{$ts_all_id}">{ts count=$pager->_totalItems plural='All %count records'}The found record{/ts}</label> &nbsp; {if $pager->_totalItems > 1} {$form.radio_ts.ts_sel.html} <label for="{$ts_sel_id}">{ts 1="<span></span>"}%1 Selected records only{/ts}</label>{/if}
     </td>
   </tr>
   <tr>
index 3fd7569153057bb21a0b202bf1754c5e6a17f3b7..b51b2fda50c065679227a013df93af96c0e0f76d 100644 (file)
@@ -52,7 +52,7 @@
   <tr>
     <td class="font-size11pt"> {ts}Select Records{/ts}:</td>
     <td class="nowrap">
-        {$form.radio_ts.ts_all.html} {ts count=$pager->_totalItems plural='All %count records'}The found record{/ts} &nbsp; {if $pager->_totalItems > 1} {$form.radio_ts.ts_sel.html} {ts}Selected records only{/ts} {/if}
+      {$form.radio_ts.ts_all.html} <label for="{$ts_all_id}">{ts count=$pager->_totalItems plural='All %count records'}The found record{/ts}</label> &nbsp; {if $pager->_totalItems > 1} {$form.radio_ts.ts_sel.html} <label for="{$ts_sel_id}">{ts 1="<span></span>"}%1 Selected records only{/ts}</label>{/if}
     </td>
   </tr>
   <tr>