dev/core#2347 Search Kit: Fix 'Select All' in table display
authorColeman Watts <coleman@civicrm.org>
Mon, 1 Feb 2021 14:43:52 +0000 (09:43 -0500)
committerColeman Watts <coleman@civicrm.org>
Mon, 1 Feb 2021 14:43:52 +0000 (09:43 -0500)
ext/search/ang/crmSearchDisplayTable/crmSearchDisplayTable.component.js

index bdcd65683ae3e40d748d878fdd1f1f50ef094e78..1606ef39a0261a8ebae01832ba73bb746af247ad 100644 (file)
         }
         // Select all
         ctrl.allRowsSelected = true;
-        if (ctrl.page === 1 && ctrl.results[1].length < ctrl.apiParams.limit) {
-          ctrl.selectedRows = _.pluck(ctrl.results[1], 'id');
+        if (ctrl.page === 1 && ctrl.results.length < ctrl.apiParams.limit) {
+          ctrl.selectedRows = _.pluck(ctrl.results, 'id');
           return;
         }
         // If more than one page of results, use ajax to fetch all ids
         $scope.loadingAllRows = true;
         var params = _.cloneDeep(ctrl.apiParams);
-        params.select = ['id'];
+        delete params.limit;
+        // Select only ids unless HAVING clause is present
+        params.select = params.having && params.having.length? params.select : ['id'];
         crmApi4(ctrl.apiEntity, 'get', params, ['id']).then(function(ids) {
           $scope.loadingAllRows = false;
           ctrl.selectedRows = _.toArray(ids);