Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ui-grid/grouping

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ui-grid/grouping - npm Package Compare versions

Comparing version 4.8.3 to 4.8.4

11

CHANGELOG.md

@@ -6,2 +6,13 @@ # Change Log

## [4.8.4](https://github.com/angular-ui/ui-grid/compare/v4.8.3...v4.8.4) (2020-09-14)
### Bug Fixes
* **grouping:** adds aggregationLabel to aggregateColumn call to match ([60fcedc](https://github.com/angular-ui/ui-grid/commit/60fcedcebd815661fbb7868a5d11e964c971c5b6))
## [4.8.3](https://github.com/angular-ui/ui-grid/compare/v4.8.2...v4.8.3) (2019-10-21)

@@ -8,0 +19,0 @@

14

js/ui-grid.grouping.js
/*!
* ui-grid - v4.8.3 - 2019-10-21
* Copyright (c) 2019 ; License: MIT
* ui-grid - v4.8.4 - 2020-09-14
* Copyright (c) 2020 ; License: MIT
*/

@@ -755,4 +755,5 @@

* @param {string} aggregationType of the recognised types from uiGridGroupingConstants or one of the custom aggregations from gridOptions
* @param {string} aggregationLabel to be used instead of the default label. If empty string is passed, label is omitted
*/
aggregateColumn: function( grid, column, aggregationType) {
aggregateColumn: function( grid, column, aggregationType, aggregationLabel ) {
if (typeof(column.grouping) !== 'undefined' && typeof(column.grouping.groupPriority) !== 'undefined' && column.grouping.groupPriority >= 0) {

@@ -770,3 +771,8 @@ service.ungroupColumn( grid, column );

column.treeAggregation = { type: aggregationType, label: i18nService.get().aggregation[aggregationDef.label] || aggregationDef.label };
column.treeAggregation = {
type: aggregationType,
label: ( typeof aggregationLabel === 'string') ?
aggregationLabel :
i18nService.get().aggregation[aggregationDef.label] || aggregationDef.label
};
column.treeAggregationFn = aggregationDef.aggregationFn;

@@ -773,0 +779,0 @@ column.treeAggregationFinalizerFn = aggregationDef.finalizerFn;

/*!
* ui-grid - v4.8.3 - 2019-10-21
* Copyright (c) 2019 ; License: MIT
* ui-grid - v4.8.4 - 2020-09-14
* Copyright (c) 2020 ; License: MIT
*/
!function(){"use strict";var r=angular.module("ui.grid.grouping",["ui.grid","ui.grid.treeBase"]);r.constant("uiGridGroupingConstants",{featureName:"grouping",rowHeaderColName:"treeBaseRowHeaderCol",EXPANDED:"expanded",COLLAPSED:"collapsed",aggregation:{COUNT:"count",SUM:"sum",MAX:"max",MIN:"min",AVG:"avg"}}),r.service("uiGridGroupingService",["$q","uiGridGroupingConstants","gridUtil","rowSorter","GridRow","gridClassFactory","i18nService","uiGridConstants","uiGridTreeBaseService",function(r,u,a,p,s,d,l,e,c){var f={initializeGrid:function(n,r){c.initializeGrid(n,r),n.grouping={},n.grouping.groupHeaderCache={},f.defaultGridOptions(n.options),n.registerRowsProcessor(f.groupRows,400),n.registerColumnBuilder(f.groupingColumnBuilder),n.registerColumnsProcessor(f.groupingColumnProcessor,400);var o={events:{grouping:{aggregationChanged:{},groupingChanged:{}}},methods:{grouping:{getGrouping:function(r){var o=f.getGrouping(n);return o.grouping.forEach(function(r){r.colName=r.col.name,delete r.col}),o.aggregations.forEach(function(r){r.colName=r.col.name,delete r.col}),o.aggregations=o.aggregations.filter(function(r){return!r.aggregation.source||"grouping"!==r.aggregation.source}),r&&(o.rowExpandedStates=f.getRowExpandedStates(n.grouping.groupingHeaderCache)),o},setGrouping:function(r){f.setGrouping(n,r)},groupColumn:function(r){var o=n.getColumn(r);f.groupColumn(n,o)},ungroupColumn:function(r){var o=n.getColumn(r);f.ungroupColumn(n,o)},clearGrouping:function(){f.clearGrouping(n)},aggregateColumn:function(r,o,i){var e=n.getColumn(r);f.aggregateColumn(n,e,o,i)}}}};n.api.registerEventsFromObject(o.events),n.api.registerMethodsFromObject(o.methods),n.api.core.on.sortChanged(r,f.tidyPriorities)},defaultGridOptions:function(r){r.enableGrouping=!1!==r.enableGrouping,r.groupingShowCounts=!1!==r.groupingShowCounts,r.groupingNullLabel=void 0===r.groupingNullLabel?"Null":r.groupingNullLabel,r.enableGroupHeaderSelection=!0===r.enableGroupHeaderSelection},groupingColumnBuilder:function(r,e,o){if(!1!==r.enableGrouping){void 0===e.grouping&&void 0!==r.grouping?(e.grouping=angular.copy(r.grouping),void 0!==e.grouping.groupPriority&&-1<e.grouping.groupPriority&&(e.treeAggregationFn=c.nativeAggregations()[u.aggregation.COUNT].aggregationFn,e.treeAggregationFinalizerFn=f.groupedFinalizerFn)):void 0===e.grouping&&(e.grouping={}),void 0!==e.grouping&&void 0!==e.grouping.groupPriority&&0<=e.grouping.groupPriority&&(e.suppressRemoveSort=!0);var i={name:"ui.grid.grouping.group",title:l.get().grouping.group,icon:"ui-grid-icon-indent-right",shown:function(){return void 0===this.context.col.grouping||void 0===this.context.col.grouping.groupPriority||this.context.col.grouping.groupPriority<0},action:function(){f.groupColumn(this.context.col.grid,this.context.col)}},n={name:"ui.grid.grouping.ungroup",title:l.get().grouping.ungroup,icon:"ui-grid-icon-indent-left",shown:function(){return void 0!==this.context.col.grouping&&void 0!==this.context.col.grouping.groupPriority&&0<=this.context.col.grouping.groupPriority},action:function(){f.ungroupColumn(this.context.col.grid,this.context.col)}},g={name:"ui.grid.grouping.aggregateRemove",title:l.get().grouping.aggregate_remove,shown:function(){return void 0!==this.context.col.treeAggregationFn},action:function(){f.aggregateColumn(this.context.col.grid,this.context.col,null)}},t=function(r,o){o=o||l.get().grouping["aggregate_"+r]||r;var i={name:"ui.grid.grouping.aggregate"+r,title:o,shown:function(){return void 0===this.context.col.treeAggregation||void 0===this.context.col.treeAggregation.type||this.context.col.treeAggregation.type!==r},action:function(){f.aggregateColumn(this.context.col.grid,this.context.col,r)}};a.arrayContainsObjectWithProperty(e.menuItems,"name","ui.grid.grouping.aggregate"+r)||e.menuItems.push(i)};!1!==e.colDef.groupingShowGroupingMenu&&(a.arrayContainsObjectWithProperty(e.menuItems,"name","ui.grid.grouping.group")||e.menuItems.push(i),a.arrayContainsObjectWithProperty(e.menuItems,"name","ui.grid.grouping.ungroup")||e.menuItems.push(n)),!1!==e.colDef.groupingShowAggregationMenu&&(angular.forEach(c.nativeAggregations(),function(r,o){t(o)}),angular.forEach(o.treeCustomAggregations,function(r,o){t(o,r.menuTitle)}),a.arrayContainsObjectWithProperty(e.menuItems,"name","ui.grid.grouping.aggregateRemove")||e.menuItems.push(g))}},groupingColumnProcessor:function(r,o){return r=f.moveGroupColumns(this,r,o)},groupedFinalizerFn:function(r){var o=this;void 0!==r.groupVal?(r.rendered=r.groupVal,o.grid.options.groupingShowCounts&&"date"!==o.colDef.type&&"object"!==o.colDef.type&&(r.rendered+=" ("+r.value+")")):r.rendered=null},moveGroupColumns:function(r,o){return!1===r.options.moveGroupColumns||(o.forEach(function(r,o){r.groupingPosition=o}),o.sort(function(r,o){var i,e;return i=r.isRowHeader?r.headerPriority:void 0===r.grouping||void 0===r.grouping.groupPriority||r.grouping.groupPriority<0?null:r.grouping.groupPriority,e=o.isRowHeader?o.headerPriority:void 0===o.grouping||void 0===o.grouping.groupPriority||o.grouping.groupPriority<0?null:o.grouping.groupPriority,null!==i&&null===e?-1:null!==e&&null===i?1:null!==i&&null!==e?i-e:r.groupingPosition-o.groupingPosition}),o.forEach(function(r){delete r.groupingPosition})),o},groupColumn:function(r,o){void 0===o.grouping&&(o.grouping={});var i=f.getGrouping(r);o.grouping.groupPriority=i.grouping.length,o.previousSort=angular.copy(o.sort),o.sort?void 0!==o.sort.direction&&null!==o.sort.direction||(o.sort.direction=e.ASC):o.sort={direction:e.ASC},o.treeAggregation={type:u.aggregation.COUNT,source:"grouping"},o.colDef&&angular.isFunction(o.colDef.customTreeAggregationFn)?o.treeAggregationFn=o.colDef.customTreeAggregationFn:o.treeAggregationFn=c.nativeAggregations()[u.aggregation.COUNT].aggregationFn,o.treeAggregationFinalizerFn=f.groupedFinalizerFn,r.api.grouping.raise.groupingChanged(o),r.api.core.raise.sortChanged(r,r.getColumnSorting()),r.queueGridRefresh()},ungroupColumn:function(r,o){void 0!==o.grouping&&(delete o.grouping.groupPriority,delete o.treeAggregation,delete o.customTreeAggregationFinalizer,o.previousSort&&(o.sort=o.previousSort,delete o.previousSort),f.tidyPriorities(r),r.api.grouping.raise.groupingChanged(o),r.api.core.raise.sortChanged(r,r.getColumnSorting()),r.queueGridRefresh())},aggregateColumn:function(r,o,i){void 0!==o.grouping&&void 0!==o.grouping.groupPriority&&0<=o.grouping.groupPriority&&f.ungroupColumn(r,o);var e={};void 0!==r.options.treeCustomAggregations[i]?e=r.options.treeCustomAggregations[i]:void 0!==c.nativeAggregations()[i]&&(e=c.nativeAggregations()[i]),o.treeAggregation={type:i,label:l.get().aggregation[e.label]||e.label},o.treeAggregationFn=e.aggregationFn,o.treeAggregationFinalizerFn=e.finalizerFn,r.api.grouping.raise.aggregationChanged(o),r.queueGridRefresh()},setGrouping:function(i,r){void 0!==r&&(f.clearGrouping(i),r.grouping&&r.grouping.length&&0<r.grouping.length&&r.grouping.forEach(function(r){var o=i.getColumn(r.colName);o&&f.groupColumn(i,o)}),r.aggregations&&r.aggregations.length&&r.aggregations.forEach(function(r){var o=i.getColumn(r.colName);o&&f.aggregateColumn(i,o,r.aggregation.type)}),r.rowExpandedStates&&f.applyRowExpandedStates(i.grouping.groupingHeaderCache,r.rowExpandedStates))},clearGrouping:function(o){var r=f.getGrouping(o);0<r.grouping.length&&r.grouping.forEach(function(r){r.col||(r.col=o.getColumn(r.colName)),f.ungroupColumn(o,r.col)}),0<r.aggregations.length&&r.aggregations.forEach(function(r){r.col||(r.col=o.getColumn(r.colName)),f.aggregateColumn(o,r.col,null)})},tidyPriorities:function(r){void 0!==r&&void 0===r.grid||void 0===this.grid||(r=this.grid);var i=[],e=[];r.columns.forEach(function(r,o){void 0!==r.grouping&&void 0!==r.grouping.groupPriority&&0<=r.grouping.groupPriority?i.push(r):void 0!==r.sort&&void 0!==r.sort.priority&&0<=r.sort.priority&&e.push(r)}),i.sort(function(r,o){return r.grouping.groupPriority-o.grouping.groupPriority}),i.forEach(function(r,o){r.grouping.groupPriority=o,r.suppressRemoveSort=!0,void 0===r.sort&&(r.sort={}),r.sort.priority=o});var o=i.length;e.sort(function(r,o){return r.sort.priority-o.sort.priority}),e.forEach(function(r){r.sort.priority=o,r.suppressRemoveSort=r.colDef.suppressRemoveSort,o++})},groupRows:function(e){if(0===e.length)return e;var n=this;n.grouping.oldGroupingHeaderCache=n.grouping.groupingHeaderCache||{},n.grouping.groupingHeaderCache={};for(var g=f.initialiseProcessingState(n),r=function(r,o){var i=n.getCellValue(u,r.col);r.initialised&&0===p.getSortFn(n,r.col,e)(i,r.currentValue)||(f.insertGroupHeader(n,e,t,g,o),t++)},t=0;t<e.length;t++){var u=e[t];u.visible&&g.forEach(r)}return delete n.grouping.oldGroupingHeaderCache,e},initialiseProcessingState:function(r){var i=[];return f.getGrouping(r).grouping.forEach(function(r,o){i.push({fieldName:r.field,col:r.col,initialised:!1,currentValue:null,currentRow:null})}),i},getGrouping:function(r){var o=[],i=[];return r.columns.forEach(function(r){r.grouping&&void 0!==r.grouping.groupPriority&&0<=r.grouping.groupPriority&&o.push({field:r.field,col:r,groupPriority:r.grouping.groupPriority,grouping:r.grouping}),r.treeAggregation&&r.treeAggregation.type&&i.push({field:r.field,col:r,aggregation:r.treeAggregation})}),o.sort(function(r,o){return r.groupPriority-o.groupPriority}),o.forEach(function(r,o){r.grouping.groupPriority=o,r.groupPriority=o,delete r.grouping}),{grouping:o,aggregations:i}},insertGroupHeader:function(r,o,i,e,n){var g=e[n].col,t=r.getCellValue(o[i],g),u=t;function a(r){return angular.isObject(r)?JSON.stringify(r):r}null==t&&(u=r.options.groupingNullLabel);for(var p,l=r.grouping.oldGroupingHeaderCache,c=0;c<n;c++)l&&l[a(e[c].currentValue)]&&(l=l[a(e[c].currentValue)].children);for(l&&l[a(t)]?(p=l[a(t)].row).entity={}:(p=new s({},null,r),d.rowTemplateAssigner.call(r,p)),p.entity["$$"+e[n].col.uid]={groupVal:u},p.treeLevel=n,p.groupHeader=!0,p.internalRow=!0,p.enableCellEdit=!1,p.enableSelection=r.options.enableGroupHeaderSelection,e[n].initialised=!0,e[n].currentValue=t,e[n].currentRow=p,f.finaliseProcessingState(e,n+1),o.splice(i,0,p),l=r.grouping.groupingHeaderCache,c=0;c<n;c++)l=l[a(e[c].currentValue)].children;l[a(t)]={row:p,children:{}}},finaliseProcessingState:function(r,o){for(var i=o;i<r.length;i++)r[i].initialised=!1,r[i].currentRow=null,r[i].currentValue=null},getRowExpandedStates:function(r){if(void 0===r)return{};var i={};return angular.forEach(r,function(r,o){i[o]={state:r.row.treeNode.state},r.children?i[o].children=f.getRowExpandedStates(r.children):i[o].children={}}),i},applyRowExpandedStates:function(i,r){void 0!==r&&angular.forEach(r,function(r,o){i[o]&&(i[o].row.treeNode.state=r.state,r.children&&i[o].children&&f.applyRowExpandedStates(i[o].children,r.children))})}};return f}]),r.directive("uiGridGrouping",["uiGridGroupingConstants","uiGridGroupingService",function(r,n){return{replace:!0,priority:0,require:"^uiGrid",scope:!1,compile:function(){return{pre:function(r,o,i,e){!1!==e.grid.options.enableGrouping&&n.initializeGrid(e.grid,r)},post:function(r,o,i,e){}}}}}])}();
!function(){"use strict";var r=angular.module("ui.grid.grouping",["ui.grid","ui.grid.treeBase"]);r.constant("uiGridGroupingConstants",{featureName:"grouping",rowHeaderColName:"treeBaseRowHeaderCol",EXPANDED:"expanded",COLLAPSED:"collapsed",aggregation:{COUNT:"count",SUM:"sum",MAX:"max",MIN:"min",AVG:"avg"}}),r.service("uiGridGroupingService",["$q","uiGridGroupingConstants","gridUtil","rowSorter","GridRow","gridClassFactory","i18nService","uiGridConstants","uiGridTreeBaseService",function(r,u,a,p,s,d,l,e,c){var f={initializeGrid:function(n,r){c.initializeGrid(n,r),n.grouping={},n.grouping.groupHeaderCache={},f.defaultGridOptions(n.options),n.registerRowsProcessor(f.groupRows,400),n.registerColumnBuilder(f.groupingColumnBuilder),n.registerColumnsProcessor(f.groupingColumnProcessor,400);var o={events:{grouping:{aggregationChanged:{},groupingChanged:{}}},methods:{grouping:{getGrouping:function(r){var o=f.getGrouping(n);return o.grouping.forEach(function(r){r.colName=r.col.name,delete r.col}),o.aggregations.forEach(function(r){r.colName=r.col.name,delete r.col}),o.aggregations=o.aggregations.filter(function(r){return!r.aggregation.source||"grouping"!==r.aggregation.source}),r&&(o.rowExpandedStates=f.getRowExpandedStates(n.grouping.groupingHeaderCache)),o},setGrouping:function(r){f.setGrouping(n,r)},groupColumn:function(r){var o=n.getColumn(r);f.groupColumn(n,o)},ungroupColumn:function(r){var o=n.getColumn(r);f.ungroupColumn(n,o)},clearGrouping:function(){f.clearGrouping(n)},aggregateColumn:function(r,o,i){var e=n.getColumn(r);f.aggregateColumn(n,e,o,i)}}}};n.api.registerEventsFromObject(o.events),n.api.registerMethodsFromObject(o.methods),n.api.core.on.sortChanged(r,f.tidyPriorities)},defaultGridOptions:function(r){r.enableGrouping=!1!==r.enableGrouping,r.groupingShowCounts=!1!==r.groupingShowCounts,r.groupingNullLabel=void 0===r.groupingNullLabel?"Null":r.groupingNullLabel,r.enableGroupHeaderSelection=!0===r.enableGroupHeaderSelection},groupingColumnBuilder:function(r,e,o){if(!1!==r.enableGrouping){void 0===e.grouping&&void 0!==r.grouping?(e.grouping=angular.copy(r.grouping),void 0!==e.grouping.groupPriority&&-1<e.grouping.groupPriority&&(e.treeAggregationFn=c.nativeAggregations()[u.aggregation.COUNT].aggregationFn,e.treeAggregationFinalizerFn=f.groupedFinalizerFn)):void 0===e.grouping&&(e.grouping={}),void 0!==e.grouping&&void 0!==e.grouping.groupPriority&&0<=e.grouping.groupPriority&&(e.suppressRemoveSort=!0);var i={name:"ui.grid.grouping.group",title:l.get().grouping.group,icon:"ui-grid-icon-indent-right",shown:function(){return void 0===this.context.col.grouping||void 0===this.context.col.grouping.groupPriority||this.context.col.grouping.groupPriority<0},action:function(){f.groupColumn(this.context.col.grid,this.context.col)}},n={name:"ui.grid.grouping.ungroup",title:l.get().grouping.ungroup,icon:"ui-grid-icon-indent-left",shown:function(){return void 0!==this.context.col.grouping&&void 0!==this.context.col.grouping.groupPriority&&0<=this.context.col.grouping.groupPriority},action:function(){f.ungroupColumn(this.context.col.grid,this.context.col)}},g={name:"ui.grid.grouping.aggregateRemove",title:l.get().grouping.aggregate_remove,shown:function(){return void 0!==this.context.col.treeAggregationFn},action:function(){f.aggregateColumn(this.context.col.grid,this.context.col,null)}},t=function(r,o){o=o||l.get().grouping["aggregate_"+r]||r;var i={name:"ui.grid.grouping.aggregate"+r,title:o,shown:function(){return void 0===this.context.col.treeAggregation||void 0===this.context.col.treeAggregation.type||this.context.col.treeAggregation.type!==r},action:function(){f.aggregateColumn(this.context.col.grid,this.context.col,r)}};a.arrayContainsObjectWithProperty(e.menuItems,"name","ui.grid.grouping.aggregate"+r)||e.menuItems.push(i)};!1!==e.colDef.groupingShowGroupingMenu&&(a.arrayContainsObjectWithProperty(e.menuItems,"name","ui.grid.grouping.group")||e.menuItems.push(i),a.arrayContainsObjectWithProperty(e.menuItems,"name","ui.grid.grouping.ungroup")||e.menuItems.push(n)),!1!==e.colDef.groupingShowAggregationMenu&&(angular.forEach(c.nativeAggregations(),function(r,o){t(o)}),angular.forEach(o.treeCustomAggregations,function(r,o){t(o,r.menuTitle)}),a.arrayContainsObjectWithProperty(e.menuItems,"name","ui.grid.grouping.aggregateRemove")||e.menuItems.push(g))}},groupingColumnProcessor:function(r,o){return r=f.moveGroupColumns(this,r,o)},groupedFinalizerFn:function(r){var o=this;void 0!==r.groupVal?(r.rendered=r.groupVal,o.grid.options.groupingShowCounts&&"date"!==o.colDef.type&&"object"!==o.colDef.type&&(r.rendered+=" ("+r.value+")")):r.rendered=null},moveGroupColumns:function(r,o){return!1===r.options.moveGroupColumns||(o.forEach(function(r,o){r.groupingPosition=o}),o.sort(function(r,o){var i,e;return i=r.isRowHeader?r.headerPriority:void 0===r.grouping||void 0===r.grouping.groupPriority||r.grouping.groupPriority<0?null:r.grouping.groupPriority,e=o.isRowHeader?o.headerPriority:void 0===o.grouping||void 0===o.grouping.groupPriority||o.grouping.groupPriority<0?null:o.grouping.groupPriority,null!==i&&null===e?-1:null!==e&&null===i?1:null!==i&&null!==e?i-e:r.groupingPosition-o.groupingPosition}),o.forEach(function(r){delete r.groupingPosition})),o},groupColumn:function(r,o){void 0===o.grouping&&(o.grouping={});var i=f.getGrouping(r);o.grouping.groupPriority=i.grouping.length,o.previousSort=angular.copy(o.sort),o.sort?void 0!==o.sort.direction&&null!==o.sort.direction||(o.sort.direction=e.ASC):o.sort={direction:e.ASC},o.treeAggregation={type:u.aggregation.COUNT,source:"grouping"},o.colDef&&angular.isFunction(o.colDef.customTreeAggregationFn)?o.treeAggregationFn=o.colDef.customTreeAggregationFn:o.treeAggregationFn=c.nativeAggregations()[u.aggregation.COUNT].aggregationFn,o.treeAggregationFinalizerFn=f.groupedFinalizerFn,r.api.grouping.raise.groupingChanged(o),r.api.core.raise.sortChanged(r,r.getColumnSorting()),r.queueGridRefresh()},ungroupColumn:function(r,o){void 0!==o.grouping&&(delete o.grouping.groupPriority,delete o.treeAggregation,delete o.customTreeAggregationFinalizer,o.previousSort&&(o.sort=o.previousSort,delete o.previousSort),f.tidyPriorities(r),r.api.grouping.raise.groupingChanged(o),r.api.core.raise.sortChanged(r,r.getColumnSorting()),r.queueGridRefresh())},aggregateColumn:function(r,o,i,e){void 0!==o.grouping&&void 0!==o.grouping.groupPriority&&0<=o.grouping.groupPriority&&f.ungroupColumn(r,o);var n={};void 0!==r.options.treeCustomAggregations[i]?n=r.options.treeCustomAggregations[i]:void 0!==c.nativeAggregations()[i]&&(n=c.nativeAggregations()[i]),o.treeAggregation={type:i,label:"string"==typeof e?e:l.get().aggregation[n.label]||n.label},o.treeAggregationFn=n.aggregationFn,o.treeAggregationFinalizerFn=n.finalizerFn,r.api.grouping.raise.aggregationChanged(o),r.queueGridRefresh()},setGrouping:function(i,r){void 0!==r&&(f.clearGrouping(i),r.grouping&&r.grouping.length&&0<r.grouping.length&&r.grouping.forEach(function(r){var o=i.getColumn(r.colName);o&&f.groupColumn(i,o)}),r.aggregations&&r.aggregations.length&&r.aggregations.forEach(function(r){var o=i.getColumn(r.colName);o&&f.aggregateColumn(i,o,r.aggregation.type)}),r.rowExpandedStates&&f.applyRowExpandedStates(i.grouping.groupingHeaderCache,r.rowExpandedStates))},clearGrouping:function(o){var r=f.getGrouping(o);0<r.grouping.length&&r.grouping.forEach(function(r){r.col||(r.col=o.getColumn(r.colName)),f.ungroupColumn(o,r.col)}),0<r.aggregations.length&&r.aggregations.forEach(function(r){r.col||(r.col=o.getColumn(r.colName)),f.aggregateColumn(o,r.col,null)})},tidyPriorities:function(r){void 0!==r&&void 0===r.grid||void 0===this.grid||(r=this.grid);var i=[],e=[];r.columns.forEach(function(r,o){void 0!==r.grouping&&void 0!==r.grouping.groupPriority&&0<=r.grouping.groupPriority?i.push(r):void 0!==r.sort&&void 0!==r.sort.priority&&0<=r.sort.priority&&e.push(r)}),i.sort(function(r,o){return r.grouping.groupPriority-o.grouping.groupPriority}),i.forEach(function(r,o){r.grouping.groupPriority=o,r.suppressRemoveSort=!0,void 0===r.sort&&(r.sort={}),r.sort.priority=o});var o=i.length;e.sort(function(r,o){return r.sort.priority-o.sort.priority}),e.forEach(function(r){r.sort.priority=o,r.suppressRemoveSort=r.colDef.suppressRemoveSort,o++})},groupRows:function(e){if(0===e.length)return e;var n=this;n.grouping.oldGroupingHeaderCache=n.grouping.groupingHeaderCache||{},n.grouping.groupingHeaderCache={};for(var g=f.initialiseProcessingState(n),r=function(r,o){var i=n.getCellValue(u,r.col);r.initialised&&0===p.getSortFn(n,r.col,e)(i,r.currentValue)||(f.insertGroupHeader(n,e,t,g,o),t++)},t=0;t<e.length;t++){var u=e[t];u.visible&&g.forEach(r)}return delete n.grouping.oldGroupingHeaderCache,e},initialiseProcessingState:function(r){var i=[];return f.getGrouping(r).grouping.forEach(function(r,o){i.push({fieldName:r.field,col:r.col,initialised:!1,currentValue:null,currentRow:null})}),i},getGrouping:function(r){var o=[],i=[];return r.columns.forEach(function(r){r.grouping&&void 0!==r.grouping.groupPriority&&0<=r.grouping.groupPriority&&o.push({field:r.field,col:r,groupPriority:r.grouping.groupPriority,grouping:r.grouping}),r.treeAggregation&&r.treeAggregation.type&&i.push({field:r.field,col:r,aggregation:r.treeAggregation})}),o.sort(function(r,o){return r.groupPriority-o.groupPriority}),o.forEach(function(r,o){r.grouping.groupPriority=o,r.groupPriority=o,delete r.grouping}),{grouping:o,aggregations:i}},insertGroupHeader:function(r,o,i,e,n){var g=e[n].col,t=r.getCellValue(o[i],g),u=t;function a(r){return angular.isObject(r)?JSON.stringify(r):r}null==t&&(u=r.options.groupingNullLabel);for(var p,l=r.grouping.oldGroupingHeaderCache,c=0;c<n;c++)l&&l[a(e[c].currentValue)]&&(l=l[a(e[c].currentValue)].children);for(l&&l[a(t)]?(p=l[a(t)].row).entity={}:(p=new s({},null,r),d.rowTemplateAssigner.call(r,p)),p.entity["$$"+e[n].col.uid]={groupVal:u},p.treeLevel=n,p.groupHeader=!0,p.internalRow=!0,p.enableCellEdit=!1,p.enableSelection=r.options.enableGroupHeaderSelection,e[n].initialised=!0,e[n].currentValue=t,e[n].currentRow=p,f.finaliseProcessingState(e,n+1),o.splice(i,0,p),l=r.grouping.groupingHeaderCache,c=0;c<n;c++)l=l[a(e[c].currentValue)].children;l[a(t)]={row:p,children:{}}},finaliseProcessingState:function(r,o){for(var i=o;i<r.length;i++)r[i].initialised=!1,r[i].currentRow=null,r[i].currentValue=null},getRowExpandedStates:function(r){if(void 0===r)return{};var i={};return angular.forEach(r,function(r,o){i[o]={state:r.row.treeNode.state},r.children?i[o].children=f.getRowExpandedStates(r.children):i[o].children={}}),i},applyRowExpandedStates:function(i,r){void 0!==r&&angular.forEach(r,function(r,o){i[o]&&(i[o].row.treeNode.state=r.state,r.children&&i[o].children&&f.applyRowExpandedStates(i[o].children,r.children))})}};return f}]),r.directive("uiGridGrouping",["uiGridGroupingConstants","uiGridGroupingService",function(r,n){return{replace:!0,priority:0,require:"^uiGrid",scope:!1,compile:function(){return{pre:function(r,o,i,e){!1!==e.grid.options.enableGrouping&&n.initializeGrid(e.grid,r)},post:function(r,o,i,e){}}}}}])}();
{
"name": "@ui-grid/grouping",
"version": "4.8.3",
"version": "4.8.4",
"description": "This module provides ui-grid with grouping of rows based on the data in them",
"main": "index.js",
"dependencies": {
"@ui-grid/core": "^4.8.2",
"@ui-grid/tree-base": "^4.8.3",
"angular": ">=1.4.0 1.7.x"
"@ui-grid/core": "^4.8.4",
"@ui-grid/tree-base": "^4.8.4",
"angular": ">=1.4.0 1.8.x"
},

@@ -38,3 +38,3 @@ "publishConfig": {

"license": "MIT",
"gitHead": "06f16f863aed597a91c0c40e37c2f267a161a56d"
"gitHead": "98b0f6b48b3369b57982c562d9c2d52cedcfc908"
}

@@ -750,4 +750,5 @@ (function () {

* @param {string} aggregationType of the recognised types from uiGridGroupingConstants or one of the custom aggregations from gridOptions
* @param {string} aggregationLabel to be used instead of the default label. If empty string is passed, label is omitted
*/
aggregateColumn: function( grid, column, aggregationType) {
aggregateColumn: function( grid, column, aggregationType, aggregationLabel ) {
if (typeof(column.grouping) !== 'undefined' && typeof(column.grouping.groupPriority) !== 'undefined' && column.grouping.groupPriority >= 0) {

@@ -765,3 +766,8 @@ service.ungroupColumn( grid, column );

column.treeAggregation = { type: aggregationType, label: i18nService.get().aggregation[aggregationDef.label] || aggregationDef.label };
column.treeAggregation = {
type: aggregationType,
label: ( typeof aggregationLabel === 'string') ?
aggregationLabel :
i18nService.get().aggregation[aggregationDef.label] || aggregationDef.label
};
column.treeAggregationFn = aggregationDef.aggregationFn;

@@ -768,0 +774,0 @@ column.treeAggregationFinalizerFn = aggregationDef.finalizerFn;

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc