Search ext: Fix column appearing in the aggregate list when it is used in GROUP_BY
authorColeman Watts <coleman@civicrm.org>
Sat, 3 Oct 2020 00:44:43 +0000 (20:44 -0400)
committerColeman Watts <coleman@civicrm.org>
Sat, 3 Oct 2020 00:44:43 +0000 (20:44 -0400)
The bug was that it wasn't recognizing the column name after a function was added to it.

ext/search/ang/search/crmSearch.component.js

index cda1af0d57d51da7a3a658b0e7da63e21bf906d4..9da0ffe8fabfb3e64ae0b9fb411f17b8a467d4f2 100644 (file)
 
       // Is a column eligible to use an aggregate function?
       this.canAggregate = function(col) {
+        var info = searchMeta.parseExpr(col);
         // If the column is used for a groupBy, no
-        if (ctrl.params.groupBy.indexOf(col) > -1) {
+        if (ctrl.params.groupBy.indexOf(info.path) > -1) {
           return false;
         }
         // If the entity this column belongs to is being grouped by id, then also no
-        var info = searchMeta.parseExpr(col);
         return ctrl.params.groupBy.indexOf(info.prefix + 'id') < 0;
       };