CRM-15471 - Clear search checkboxes when choosing 'select all' radio
authorColeman Watts <coleman@civicrm.org>
Sat, 18 Oct 2014 21:40:44 +0000 (17:40 -0400)
committerColeman Watts <coleman@civicrm.org>
Sat, 18 Oct 2014 21:40:44 +0000 (17:40 -0400)
js/crm.searchForm.js

index dc3a9cb637299b9e441aa37716a6797a950a4a53..4f8963be147a6d44cec0a51598d2095aee19f915 100644 (file)
     return $('input.select-row:checked', form).length;
   }
 
+  function clearSelections(e) {
+    if (selected) {
+      var $form = $(this).closest('form');
+      $('input.select-row, input.select-rows', $form).prop('checked', false).closest('tr').removeClass('crm-row-selected');
+      if (usesAjax()) {
+        phoneHome(false, $(this));
+      } else {
+        selected = 0;
+        displayCount();
+      }
+    }
+  }
+
   function usesAjax() {
     return $(form).hasClass('crm-ajax-selection-form');
   }
@@ -31,7 +44,7 @@
   function phoneHome(single, $el, event) {
     var url = CRM.url('civicrm/ajax/markSelection');
     var params = {qfKey: 'civicrm search ' + $('input[name=qfKey]', form).val()};
-    if (!$el.is(':checked')) {
+    if (!$el.is(':checked') || $el.is('input[name=radio_ts][value=ts_all]')) {
       params.action = 'unselect';
       params.state = 'unchecked';
     }
@@ -45,7 +58,7 @@
         $("input.select-row, input.select-rows", form).prop('checked', false).closest('tr').removeClass('crm-row-selected');
       }
       // Master checkbox
-      else {
+      else if ($el.hasClass('select-rows')) {
         params.name = $('input.select-row').map(function() {return $(this).attr('id')}).get().join('-');
       }
     }
       clearTaskMenu();
       enableTaskMenu();
     })
+    .on('click', 'input[name=radio_ts][value=ts_all]', clearSelections)
     // When making a selection
     .on('click', 'input.select-row, input.select-rows, a.crm-selection-reset', function(event) {
       var $el = $(this),