var ToolPanel = (function (_super) { __extends(ToolPanel, _super); function ToolPanel() { _super.call(this, ToolPanel.TEMPLATE); } ToolPanel.prototype.agWire = function () { this.columnSelectPanel = new columnSelectPanel_1.ColumnSelectPanel(true); }; ToolPanel.prototype.init = function () { this.context.wireBean(this.columnSelectPanel); this.getGui().appendChild(this.columnSelectPanel.getGui()); }; ToolPanel.TEMPLATE = '<div class="ag-tool-panel"></div>'; __decorate([ main_3.Autowired('context'), __metadata('design:type', main_4.Context) ], ToolPanel.prototype, "context", void 0); __decorate([ main_5.PostConstruct, __metadata('design:type', Function), __metadata('design:paramtypes', []), __metadata('design:returntype', void 0) ], ToolPanel.prototype, "init", null); ToolPanel = __decorate([ main_1.Bean('toolPanel'), __metadata('design:paramtypes', []) ], ToolPanel); return ToolPanel; })(main_2.Component);
var EnterpriseBoot = (function () { function EnterpriseBoot() { } EnterpriseBoot.prototype.init = function () { this.filterManager.registerFilter('set', setFilter_1.SetFilter); this.cellEditorFactory.addCellEditor(EnterpriseBoot.RICH_SELECT, richSelectCellEditor_1.RichSelectCellEditor); this.licenseManager.validateLicense(); }; EnterpriseBoot.RICH_SELECT = 'richSelect'; __decorate([ main_1.Autowired('filterManager'), __metadata('design:type', main_1.FilterManager) ], EnterpriseBoot.prototype, "filterManager", void 0); __decorate([ main_1.Autowired('cellEditorFactory'), __metadata('design:type', main_1.CellEditorFactory) ], EnterpriseBoot.prototype, "cellEditorFactory", void 0); __decorate([ main_1.Autowired('licenseManager'), __metadata('design:type', licenseManager_1.LicenseManager) ], EnterpriseBoot.prototype, "licenseManager", void 0); __decorate([ main_1.PostConstruct, __metadata('design:type', Function), __metadata('design:paramtypes', []), __metadata('design:returntype', void 0) ], EnterpriseBoot.prototype, "init", null); EnterpriseBoot = __decorate([ main_1.Bean('enterpriseBoot'), __metadata('design:paramtypes', []) ], EnterpriseBoot); return EnterpriseBoot; })();
var ToolPanelComp = (function (_super) { __extends(ToolPanelComp, _super); function ToolPanelComp() { _super.call(this, ToolPanelComp.TEMPLATE); } ToolPanelComp.prototype.init = function () { if (!this.gridOptionsWrapper.isToolPanelSuppressPivotMode()) { this.addComponent(new pivotModePanel_1.PivotModePanel()); } this.addComponent(new columnSelectPanel_1.ColumnSelectPanel(true)); if (!this.gridOptionsWrapper.isToolPanelSuppressRowGroups()) { this.addComponent(new rowGroupColumnsPanel_1.RowGroupColumnsPanel(false)); } if (!this.gridOptionsWrapper.isToolPanelSuppressValues()) { this.addComponent(new valueColumnsPanel_1.ValuesColumnPanel(false)); } if (!this.gridOptionsWrapper.isToolPanelSuppressPivots()) { this.addComponent(new pivotColumnsPanel_1.PivotColumnsPanel(false)); } }; ToolPanelComp.prototype.addComponent = function (component) { this.context.wireBean(component); this.getGui().appendChild(component.getGui()); this.addDestroyFunc(function () { component.destroy(); }); }; ToolPanelComp.TEMPLATE = '<div class="ag-tool-panel"></div>'; __decorate([ main_1.Autowired('context'), __metadata('design:type', main_1.Context) ], ToolPanelComp.prototype, "context", void 0); __decorate([ main_1.Autowired('gridOptionsWrapper'), __metadata('design:type', main_1.GridOptionsWrapper) ], ToolPanelComp.prototype, "gridOptionsWrapper", void 0); __decorate([ main_1.PostConstruct, __metadata('design:type', Function), __metadata('design:paramtypes', []), __metadata('design:returntype', void 0) ], ToolPanelComp.prototype, "init", null); ToolPanelComp = __decorate([ main_1.Bean('toolPanel'), __metadata('design:paramtypes', []) ], ToolPanelComp); return ToolPanelComp; })(main_1.Component);
var PivotCompFactory = (function () { function PivotCompFactory() { } PivotCompFactory.prototype.create = function () { var pivotComp = new pivotColumnsPanel_1.PivotColumnsPanel(true); this.context.wireBean(pivotComp); return pivotComp; }; __decorate([ main_1.Autowired('context'), __metadata('design:type', main_1.Context) ], PivotCompFactory.prototype, "context", void 0); PivotCompFactory = __decorate([ main_1.Bean('pivotCompFactory'), __metadata('design:paramtypes', []) ], PivotCompFactory); return PivotCompFactory; })();
var ToolPanelComp = (function (_super) { __extends(ToolPanelComp, _super); function ToolPanelComp() { _super.call(this, ToolPanelComp.TEMPLATE); } ToolPanelComp.prototype.init = function () { this.columnSelectPanel = new columnSelectPanel_1.ColumnSelectPanel(true); this.context.wireBean(this.columnSelectPanel); this.addInWrapper(this.columnSelectPanel.getGui(), '100%'); var p2 = new rowGroupColumnsPanel_1.RowGroupColumnsPanel(false); var p4 = new pivotColumnsPanel_1.PivotColumnsPanel(false); this.context.wireBean(p2); this.context.wireBean(p4); // this.addInWrapper(p2.getGui(), '15%'); // this.addInWrapper(p4.getGui(), '15%'); }; ToolPanelComp.prototype.addInWrapper = function (eElement, height) { var eDiv = document.createElement('div'); eDiv.style.height = height; eDiv.appendChild(eElement); this.getGui().appendChild(eDiv); }; ToolPanelComp.TEMPLATE = '<div class="ag-tool-panel"></div>'; __decorate([ main_1.Autowired('context'), __metadata('design:type', main_1.Context) ], ToolPanelComp.prototype, "context", void 0); __decorate([ main_1.PostConstruct, __metadata('design:type', Function), __metadata('design:paramtypes', []), __metadata('design:returntype', void 0) ], ToolPanelComp.prototype, "init", null); ToolPanelComp = __decorate([ main_1.Bean('toolPanel'), __metadata('design:paramtypes', []) ], ToolPanelComp); return ToolPanelComp; })(main_1.Component);
var PivotColDefService = (function () { function PivotColDefService() { } PivotColDefService.prototype.createPivotColumnDefs = function (uniqueValues) { var pivotColumnGroupDefs = []; var pivotColumnDefs = []; var pivotColumns = this.columnController.getPivotColumns(); var levelsDeep = pivotColumns.length; var columnIdSequence = new main_1.NumberSequence(); this.recursivelyAddGroup(pivotColumnGroupDefs, pivotColumnDefs, 1, uniqueValues, [], columnIdSequence, levelsDeep); return { pivotColumnGroupDefs: pivotColumnGroupDefs, pivotColumnDefs: pivotColumnDefs }; }; // parentChildren - the list of colDefs we are adding to // @index - how far the column is from the top (also same as pivotKeys.length) // @uniqueValues - the values for which we should create a col for // @pivotKeys - the keys for the pivot, eg if pivoting on {Language,Country} then could be {English,Ireland} PivotColDefService.prototype.recursivelyAddGroup = function (parentChildren, pivotColumnDefs, index, uniqueValues, pivotKeys, columnIdSequence, levelsDeep) { var _this = this; main_1.Utils.iterateObject(uniqueValues, function (key, value) { var newPivotKeys = pivotKeys.slice(0); newPivotKeys.push(key); var createGroup = index !== levelsDeep; if (createGroup) { var groupDef = { children: [], headerName: key }; parentChildren.push(groupDef); _this.recursivelyAddGroup(groupDef.children, pivotColumnDefs, index + 1, value, newPivotKeys, columnIdSequence, levelsDeep); } else { var measureColumns = _this.columnController.getValueColumns(); var valueGroup = { children: [], headerName: key }; parentChildren.push(valueGroup); // if no value columns selected, then we insert one blank column, so the user at least sees columns // rendered. otherwise the grid would render with no columns (just empty groups) which would give the // impression that the grid is broken if (measureColumns.length === 0) { // this is the blank column, for when no value columns enabled. var colDef = _this.createColDef(null, '-', newPivotKeys, columnIdSequence, "'n/a'"); valueGroup.children.push(colDef); pivotColumnDefs.push(colDef); } else { measureColumns.forEach(function (measureColumn) { var colDef = _this.createColDef(measureColumn, measureColumn.getColDef().headerName, newPivotKeys, columnIdSequence, null); valueGroup.children.push(colDef); pivotColumnDefs.push(colDef); }); } valueGroup.children.sort(_this.headerNameComparator.bind(_this)); } parentChildren.sort(_this.headerNameComparator.bind(_this)); }); }; PivotColDefService.prototype.createColDef = function (valueColumn, headerName, pivotKeys, columnIdSequence, valueGetter) { var colDef = {}; if (valueColumn) { var colDefToCopy = valueColumn.getColDef(); main_1.Utils.assign(colDef, colDefToCopy); // even if original column was hidden, we always show the pivot value column, otherwise it would be // very confusing for people thinking the pivot is broken colDef.hide = false; } colDef.valueGetter = valueGetter; colDef.headerName = headerName; colDef.colId = 'pivot_' + columnIdSequence.next(); colDef.pivotKeys = pivotKeys; colDef.pivotValueColumn = valueColumn; return colDef; }; PivotColDefService.prototype.headerNameComparator = function (a, b) { if (a.headerName < b.headerName) { return -1; } else if (a.headerName > b.headerName) { return 1; } else { return 0; } }; __decorate([ main_1.Autowired('columnController'), __metadata('design:type', main_1.ColumnController) ], PivotColDefService.prototype, "columnController", void 0); PivotColDefService = __decorate([ main_1.Bean('pivotColDefService'), __metadata('design:paramtypes', []) ], PivotColDefService); return PivotColDefService; })();
var RowGroupPanel = (function (_super) { __extends(RowGroupPanel, _super); function RowGroupPanel() { _super.call(this, '<div class="ag-row-group-panel ag-font-style"></div>'); } RowGroupPanel.prototype.agWire = function () { this.addEmptyMessageToGui(); }; RowGroupPanel.prototype.init = function () { this.logger = this.loggerFactory.create('RowGroupPanel'); this.globalEventService.addEventListener(main_14.Events.EVENT_COLUMN_EVERYTHING_CHANGED, this.onColumnChanged.bind(this)); this.globalEventService.addEventListener(main_14.Events.EVENT_COLUMN_ROW_GROUP_CHANGE, this.onColumnChanged.bind(this)); this.setupDropTarget(); }; RowGroupPanel.prototype.setupDropTarget = function () { this.dropTarget = { eContainer: this.getGui(), onDragging: this.onDragging.bind(this), onDragEnter: this.onDragEnter.bind(this), onDragLeave: this.onDragLeave.bind(this), onDragStop: this.onDragStop.bind(this) }; this.dragAndDropService.addDropTarget(this.dropTarget); }; RowGroupPanel.prototype.onDragging = function () { }; RowGroupPanel.prototype.onDragEnter = function (draggingEvent) { // see if column is already grouped, if it is, ignore it var columnAlreadyGrouped = this.columnController.isColumnRowGrouped(draggingEvent.dragItem); var columnNotGroupable = draggingEvent.dragItem.getColDef().suppressRowGroup; if (columnAlreadyGrouped || columnNotGroupable) { // do not allow group this.dragAndDropService.setGhostIcon(null); } else { // allow group this.addPotentialDropToGui(draggingEvent.dragItem); this.dragAndDropService.setGhostIcon(main_10.DragAndDropService.ICON_GROUP); } }; RowGroupPanel.prototype.onDragLeave = function (draggingEvent) { // if the dragging started from us, we remove the group, however if it started // someplace else, then we don't, as it was only 'asking' if (draggingEvent.dragSource.dragSourceDropTarget === this.dropTarget) { this.gridPanel.turnOnAnimationForABit(); this.columnController.removeRowGroupColumn(draggingEvent.dragItem); this.columnController.setColumnVisible(draggingEvent.dragItem, true); } if (this.ePotentialDropGui) { this.removePotentialDropFromGui(); } }; RowGroupPanel.prototype.onDragStop = function (draggingEvent) { //this.columnController.addRowGroupColumn(draggingEvent.dragItem); if (this.ePotentialDropGui) { // not necessary to remove it, as the change to rowGroups results in // this panel refreshing, however my brain will be more at peace if we do this.removePotentialDropFromGui(); this.columnController.addRowGroupColumn(draggingEvent.dragItem); } }; RowGroupPanel.prototype.onColumnChanged = function () { main_1.Utils.removeAllChildren(this.getGui()); var columns = this.columnController.getRowGroupColumns(); if (columns.length > 0) { this.addColumnsToGui(columns); } else { this.addEmptyMessageToGui(); } }; RowGroupPanel.prototype.removePotentialDropFromGui = function () { this.getGui().removeChild(this.ePotentialDropGui); this.ePotentialDropGui = null; // if no groupings, need to add the empty message back in if (this.columnController.getRowGroupColumns().length === 0) { this.addEmptyMessageToGui(); } }; RowGroupPanel.prototype.addPotentialDropToGui = function (column) { this.ePotentialDropGui = document.createElement('span'); if (this.columnController.getRowGroupColumns().length === 0) { // if no groupings, need to remove the empty message main_1.Utils.removeAllChildren(this.getGui()); var eGroupIcon = svgFactory.createGroupIcon(); main_1.Utils.addCssClass(eGroupIcon, 'ag-faded'); main_1.Utils.addCssClass(eGroupIcon, 'ag-row-group-icon'); this.ePotentialDropGui.appendChild(eGroupIcon); } else { // otherwise we need to add an arrow var eArrow = document.createElement('span'); eArrow.innerHTML = '→'; this.ePotentialDropGui.appendChild(eArrow); } var cell = new RenderedGroupedColumnCell(column, this.dropTarget, true); this.context.wireBean(cell); this.ePotentialDropGui.appendChild(cell.getGui()); this.getGui().appendChild(this.ePotentialDropGui); }; RowGroupPanel.prototype.addColumnsToGui = function (columns) { var _this = this; var eGroupIcon = svgFactory.createGroupIcon(); main_1.Utils.addCssClass(eGroupIcon, 'ag-row-group-icon'); this.getGui().appendChild(eGroupIcon); columns.forEach(function (column, index) { if (index > 0) { var eArrow = document.createElement('span'); eArrow.innerHTML = '→'; _this.getGui().appendChild(eArrow); } var cell = new RenderedGroupedColumnCell(column, _this.dropTarget); _this.context.wireBean(cell); _this.getGui().appendChild(cell.getGui()); }); }; RowGroupPanel.prototype.addEmptyMessageToGui = function () { // add in faded group icon var eGroupIcon = svgFactory.createGroupIcon(); main_1.Utils.addCssClass(eGroupIcon, 'ag-faded ag-row-group-icon'); this.getGui().appendChild(eGroupIcon); // add in message var localeTextFunc = this.gridOptionsWrapper.getLocaleTextFunc(); var rowGroupColumnsEmptyMessage = localeTextFunc('rowGroupColumnsEmptyMessage', 'Drag columns here to group'); var eMessage = document.createElement('span'); eMessage.innerHTML = rowGroupColumnsEmptyMessage; main_1.Utils.addCssClass(eMessage, 'ag-row-group-empty-message'); this.getGui().appendChild(eMessage); }; __decorate([ main_5.Autowired('columnController'), __metadata('design:type', main_6.ColumnController) ], RowGroupPanel.prototype, "columnController", void 0); __decorate([ main_5.Autowired('context'), __metadata('design:type', main_8.Context) ], RowGroupPanel.prototype, "context", void 0); __decorate([ main_5.Autowired('loggerFactory'), __metadata('design:type', main_9.LoggerFactory) ], RowGroupPanel.prototype, "loggerFactory", void 0); __decorate([ main_5.Autowired('dragAndDropService'), __metadata('design:type', main_10.DragAndDropService) ], RowGroupPanel.prototype, "dragAndDropService", void 0); __decorate([ main_5.Autowired('gridOptionsWrapper'), __metadata('design:type', main_11.GridOptionsWrapper) ], RowGroupPanel.prototype, "gridOptionsWrapper", void 0); __decorate([ main_5.Autowired('gridPanel'), __metadata('design:type', main_12.GridPanel) ], RowGroupPanel.prototype, "gridPanel", void 0); __decorate([ main_5.Autowired('eventService'), __metadata('design:type', main_7.EventService) ], RowGroupPanel.prototype, "globalEventService", void 0); __decorate([ main_13.PostConstruct, __metadata('design:type', Function), __metadata('design:paramtypes', []), __metadata('design:returntype', void 0) ], RowGroupPanel.prototype, "init", null); RowGroupPanel = __decorate([ main_3.Bean('rowGroupPanel'), __metadata('design:paramtypes', []) ], RowGroupPanel); return RowGroupPanel; })(main_4.Component);
var RangeController = (function () { function RangeController() { this.bodyScrollListener = this.onBodyScroll.bind(this); this.dragging = false; } RangeController.prototype.init = function () { this.logger = this.loggerFactory.create('RangeController'); this.eventService.addEventListener(main_1.Events.EVENT_COLUMN_EVERYTHING_CHANGED, this.clearSelection.bind(this)); this.eventService.addEventListener(main_1.Events.EVENT_COLUMN_GROUP_OPENED, this.clearSelection.bind(this)); this.eventService.addEventListener(main_1.Events.EVENT_COLUMN_MOVED, this.clearSelection.bind(this)); this.eventService.addEventListener(main_1.Events.EVENT_COLUMN_PINNED, this.clearSelection.bind(this)); this.eventService.addEventListener(main_1.Events.EVENT_COLUMN_ROW_GROUP_CHANGED, this.clearSelection.bind(this)); this.eventService.addEventListener(main_1.Events.EVENT_COLUMN_VISIBLE, this.clearSelection.bind(this)); this.eventService.addEventListener(main_1.Events.EVENT_SORT_CHANGED, this.clearSelection.bind(this)); }; RangeController.prototype.setRangeToCell = function (cell) { if (!this.gridOptionsWrapper.isEnableRangeSelection()) { return; } var columns = this.updateSelectedColumns(cell.column, cell.column); if (!columns) { return; } var newRange = { start: new main_1.GridCell(cell.rowIndex, cell.floating, cell.column), end: new main_1.GridCell(cell.rowIndex, cell.floating, cell.column), columns: columns }; this.cellRanges = []; this.cellRanges.push(newRange); this.activeRange = null; this.dispatchChangedEvent(true, false); }; RangeController.prototype.setRange = function (rangeSelection) { if (!this.gridOptionsWrapper.isEnableRangeSelection()) { return; } this.cellRanges = []; this.addRange(rangeSelection); }; RangeController.prototype.addRange = function (rangeSelection) { if (!this.gridOptionsWrapper.isEnableRangeSelection()) { return; } var columnStart = this.columnController.getColumnWithValidation(rangeSelection.columnStart); var columnEnd = this.columnController.getPrimaryColumn(rangeSelection.columnEnd); if (!columnStart || !columnEnd) { return; } var columns = this.updateSelectedColumns(columnStart, columnEnd); if (!columns) { return; } var newRange = { start: new main_1.GridCell(rangeSelection.rowStart, rangeSelection.floatingStart, columnStart), end: new main_1.GridCell(rangeSelection.rowEnd, rangeSelection.floatingEnd, columnEnd), columns: columns }; if (!this.cellRanges) { this.cellRanges = []; } this.cellRanges.push(newRange); this.dispatchChangedEvent(true, false); }; RangeController.prototype.getCellRanges = function () { return this.cellRanges; }; RangeController.prototype.isEmpty = function () { return main_1.Utils.missingOrEmpty(this.cellRanges); }; RangeController.prototype.isMoreThanOneCell = function () { if (main_1.Utils.missingOrEmpty(this.cellRanges)) { return false; } else { if (this.cellRanges.length > 1) { return true; } else { var onlyRange = this.cellRanges[0]; var onlyOneCellInRange = onlyRange.start.column === onlyRange.end.column && onlyRange.start.rowIndex === onlyRange.end.rowIndex; return !onlyOneCellInRange; } } }; RangeController.prototype.clearSelection = function () { if (main_1.Utils.missing(this.cellRanges)) { return; } this.activeRange = null; this.cellRanges = null; this.dispatchChangedEvent(true, false); }; // as the user is dragging outside of the panel, the div starts to scroll, which in turn // means we are selection more (or less) cells, but the mouse isn't moving, so we recalculate // the selection my mimicking a new mouse event RangeController.prototype.onBodyScroll = function () { this.onDragging(this.lastMouseEvent); }; RangeController.prototype.isCellInAnyRange = function (cell) { return this.getCellRangeCount(cell) > 0; }; RangeController.prototype.isCellInSpecificRange = function (cell, range) { var columnInRange = range.columns.indexOf(cell.column) >= 0; var rowInRange = this.isRowInRange(cell.rowIndex, cell.floating, range); return columnInRange && rowInRange; }; // returns the number of ranges this cell is in RangeController.prototype.getCellRangeCount = function (cell) { var _this = this; if (main_1.Utils.missingOrEmpty(this.cellRanges)) { return 0; } var matchingCount = 0; this.cellRanges.forEach(function (cellRange) { if (_this.isCellInSpecificRange(cell, cellRange)) { matchingCount++; } }); return matchingCount; }; RangeController.prototype.isRowInRange = function (rowIndex, floating, cellRange) { var row1 = new main_1.GridRow(cellRange.start.rowIndex, cellRange.start.floating); var row2 = new main_1.GridRow(cellRange.end.rowIndex, cellRange.end.floating); var firstRow = row1.before(row2) ? row1 : row2; var lastRow = row1.before(row2) ? row2 : row1; var thisRow = new main_1.GridRow(rowIndex, floating); if (thisRow.equals(firstRow) || thisRow.equals(lastRow)) { return true; } else { var afterFirstRow = !thisRow.before(firstRow); var beforeLastRow = thisRow.before(lastRow); return afterFirstRow && beforeLastRow; } }; RangeController.prototype.onDragStart = function (mouseEvent) { if (!this.gridOptionsWrapper.isEnableRangeSelection()) { return; } // ctrlKey for windows, metaKey for Apple var multiSelectKeyPressed = mouseEvent.ctrlKey || mouseEvent.metaKey; if (main_1.Utils.missing(this.cellRanges) || !multiSelectKeyPressed) { this.cellRanges = []; } var cell = this.mouseEventService.getCellForMouseEvent(mouseEvent); if (main_1.Utils.missing(cell)) { // if drag wasn't on cell, then do nothing, including do not set dragging=true, // (which them means onDragging and onDragStop do nothing) return; } this.createNewActiveRange(cell); this.gridPanel.addScrollEventListener(this.bodyScrollListener); this.dragging = true; this.lastMouseEvent = mouseEvent; this.selectionChanged(false, true); }; RangeController.prototype.createNewActiveRange = function (cell) { this.activeRange = { start: new main_1.GridCell(cell.rowIndex, cell.floating, cell.column), end: new main_1.GridCell(cell.rowIndex, cell.floating, cell.column), columns: [cell.column] }; this.cellRanges.push(this.activeRange); }; RangeController.prototype.selectionChanged = function (finished, started) { this.activeRange.columns = this.updateSelectedColumns(this.activeRange.start.column, this.activeRange.end.column); this.dispatchChangedEvent(finished, started); }; RangeController.prototype.dispatchChangedEvent = function (finished, started) { this.eventService.dispatchEvent(main_1.Events.EVENT_RANGE_SELECTION_CHANGED, { finished: finished, started: started }); }; RangeController.prototype.onDragStop = function () { if (!this.dragging) { return; } this.gridPanel.removeScrollEventListener(this.bodyScrollListener); this.lastMouseEvent = null; this.dragging = false; this.dispatchChangedEvent(true, false); }; RangeController.prototype.onDragging = function (mouseEvent) { if (!this.dragging) { return; } this.lastMouseEvent = mouseEvent; var cell = this.mouseEventService.getCellForMouseEvent(mouseEvent); if (main_1.Utils.missing(cell)) { return; } var columnChanged = false; if (cell.column !== this.activeRange.end.column) { this.activeRange.end.column = cell.column; columnChanged = true; } var rowChanged = false; if (cell.rowIndex !== this.activeRange.end.rowIndex || cell.floating !== this.activeRange.end.floating) { this.activeRange.end.rowIndex = cell.rowIndex; this.activeRange.end.floating = cell.floating; rowChanged = true; } if (columnChanged || rowChanged) { this.selectionChanged(false, false); } }; RangeController.prototype.updateSelectedColumns = function (columnFrom, columnTo) { var allDisplayedColumns = this.columnController.getAllDisplayedColumns(); var fromIndex = allDisplayedColumns.indexOf(columnFrom); var toIndex = allDisplayedColumns.indexOf(columnTo); if (fromIndex < 0) { console.log('ag-Grid: column ' + columnFrom.getId() + ' is not visible'); return null; } if (toIndex < 0) { console.log('ag-Grid: column ' + columnTo.getId() + ' is not visible'); return null; } var firstIndex = Math.min(fromIndex, toIndex); var lastIndex = Math.max(fromIndex, toIndex); var columns = []; for (var i = firstIndex; i <= lastIndex; i++) { columns.push(allDisplayedColumns[i]); } return columns; }; __decorate([ main_1.Autowired('loggerFactory'), __metadata('design:type', main_1.LoggerFactory) ], RangeController.prototype, "loggerFactory", void 0); __decorate([ main_1.Autowired('gridPanel'), __metadata('design:type', main_1.GridPanel) ], RangeController.prototype, "gridPanel", void 0); __decorate([ main_1.Autowired('rowModel'), __metadata('design:type', Object) ], RangeController.prototype, "rowModel", void 0); __decorate([ main_1.Autowired('eventService'), __metadata('design:type', main_1.EventService) ], RangeController.prototype, "eventService", void 0); __decorate([ main_1.Autowired('columnController'), __metadata('design:type', main_1.ColumnController) ], RangeController.prototype, "columnController", void 0); __decorate([ main_1.Autowired('rowRenderer'), __metadata('design:type', main_1.RowRenderer) ], RangeController.prototype, "rowRenderer", void 0); __decorate([ main_1.Autowired('focusedCellController'), __metadata('design:type', main_1.FocusedCellController) ], RangeController.prototype, "focusedCellController", void 0); __decorate([ main_1.Autowired('mouseEventService'), __metadata('design:type', main_1.MouseEventService) ], RangeController.prototype, "mouseEventService", void 0); __decorate([ main_1.Autowired('gridOptionsWrapper'), __metadata('design:type', main_1.GridOptionsWrapper) ], RangeController.prototype, "gridOptionsWrapper", void 0); __decorate([ main_1.PostConstruct, __metadata('design:type', Function), __metadata('design:paramtypes', []), __metadata('design:returntype', void 0) ], RangeController.prototype, "init", null); RangeController = __decorate([ main_1.Bean('rangeController'), __metadata('design:paramtypes', []) ], RangeController); return RangeController; })();
var PivotStage = (function () { function PivotStage() { this.uniqueValues = {}; } PivotStage.prototype.execute = function (rootNode) { if (this.columnController.isPivotActive()) { this.executePivotOn(rootNode); } else { this.executePivotOff(); } }; PivotStage.prototype.executePivotOff = function () { this.aggregationColumnsHashLastTime = null; this.uniqueValues = {}; this.columnController.setSecondaryColumns(null); }; PivotStage.prototype.executePivotOn = function (rootNode) { var uniqueValues = this.bucketUpRowNodes(rootNode); var uniqueValuesChanged = this.setUniqueValues(uniqueValues); var aggregationColumns = this.columnController.getAggregationColumns(); var aggregationColumnsHash = aggregationColumns.map(function (column) { return column.getId(); }).join('#'); var aggregationColumnsChanged = this.aggregationColumnsHashLastTime !== aggregationColumnsHash; this.aggregationColumnsHashLastTime = aggregationColumnsHash; if (uniqueValuesChanged || aggregationColumnsChanged) { var result = this.pivotColDefService.createPivotColumnDefs(this.uniqueValues); this.pivotColumnGroupDefs = result.pivotColumnGroupDefs; this.pivotColumnDefs = result.pivotColumnDefs; this.columnController.setSecondaryColumns(this.pivotColumnGroupDefs); } }; PivotStage.prototype.setUniqueValues = function (newValues) { var json1 = JSON.stringify(newValues); var json2 = JSON.stringify(this.uniqueValues); var uniqueValuesChanged = json1 !== json2; // we only continue the below if the unique values are different, as otherwise // the result will be the same as the last time we did it if (uniqueValuesChanged) { this.uniqueValues = newValues; return true; } else { return false; } }; // returns true if values were different PivotStage.prototype.bucketUpRowNodes = function (rootNode) { // accessed from inside inner function var uniqueValues = {}; var that = this; recursivelySearchForLeafNodes(rootNode); return uniqueValues; // finds all leaf groups and calls mapRowNode with it function recursivelySearchForLeafNodes(rowNode) { if (rowNode.leafGroup) { that.bucketRowNode(rowNode, uniqueValues); } else { rowNode.childrenAfterFilter.forEach(function (child) { recursivelySearchForLeafNodes(child); }); } } }; PivotStage.prototype.bucketRowNode = function (rowNode, uniqueValues) { var pivotColumns = this.columnController.getPivotColumns(); if (pivotColumns.length === 0) { rowNode.childrenMapped = null; return; } rowNode.childrenMapped = this.bucketChildren(rowNode.childrenAfterFilter, pivotColumns, 0, uniqueValues); }; PivotStage.prototype.bucketChildren = function (children, pivotColumns, pivotIndex, uniqueValues) { var _this = this; var mappedChildren = {}; var pivotColumn = pivotColumns[pivotIndex]; // map the children out based on the pivot column children.forEach(function (child) { var key = _this.valueService.getValue(pivotColumn, child); if (main_1.Utils.missing(key)) { key = ''; } if (!uniqueValues[key]) { uniqueValues[key] = {}; } if (!mappedChildren[key]) { mappedChildren[key] = []; } mappedChildren[key].push(child); }); // if it's the last pivot column, return as is, otherwise go one level further in the map if (pivotIndex === pivotColumns.length - 1) { return mappedChildren; } else { var result = {}; main_1.Utils.iterateObject(mappedChildren, function (key, value) { result[key] = _this.bucketChildren(value, pivotColumns, pivotIndex + 1, uniqueValues[key]); }); return result; } }; PivotStage.prototype.getPivotColumnDefs = function () { return this.pivotColumnDefs; }; __decorate([ main_1.Autowired('rowModel'), __metadata('design:type', Object) ], PivotStage.prototype, "rowModel", void 0); __decorate([ main_1.Autowired('valueService'), __metadata('design:type', main_1.ValueService) ], PivotStage.prototype, "valueService", void 0); __decorate([ main_1.Autowired('columnController'), __metadata('design:type', main_1.ColumnController) ], PivotStage.prototype, "columnController", void 0); __decorate([ main_1.Autowired('eventService'), __metadata('design:type', main_1.EventService) ], PivotStage.prototype, "eventService", void 0); __decorate([ main_1.Autowired('pivotColDefService'), __metadata('design:type', pivotColDefService_1.PivotColDefService) ], PivotStage.prototype, "pivotColDefService", void 0); PivotStage = __decorate([ main_1.Bean('pivotStage'), __metadata('design:paramtypes', []) ], PivotStage); return PivotStage; })();
var ClipboardService = (function () { function ClipboardService() { } ClipboardService.prototype.init = function () { this.logger = this.loggerFactory.create('ClipboardService'); }; ClipboardService.prototype.pasteFromClipboard = function () { var _this = this; this.logger.log('pasteFromClipboard'); this.executeOnTempElement(function (textArea) { textArea.focus(); }, function (element) { var text = element.value; _this.finishPasteFromClipboard(text); }); }; ClipboardService.prototype.finishPasteFromClipboard = function (data) { var _this = this; if (main_16.Utils.missingOrEmpty(data)) { return; } var focusedCell = this.focusedCellController.getFocusedCell(); if (!focusedCell) { return; } var parsedData = this.dataToArray(data); if (!parsedData) { return; } // remove last row if empty, excel puts empty last row in var lastLine = parsedData[parsedData.length - 1]; if (lastLine.length === 1 && lastLine[0] === '') { main_16.Utils.removeFromArray(parsedData, lastLine); } var currentRow = new main_15.GridRow(focusedCell.rowIndex, focusedCell.floating); var cellsToFlash = {}; parsedData.forEach(function (values) { // if we have come to end of rows in grid, then skip if (!currentRow) { return; } var rowNode = _this.getRowNode(currentRow); var column = focusedCell.column; values.forEach(function (value) { if (main_16.Utils.missing(column)) { return; } if (!column.isCellEditable(rowNode)) { return; } _this.valueService.setValue(rowNode, column, value); var cellId = new main_17.GridCell(currentRow.rowIndex, currentRow.floating, column).createId(); cellsToFlash[cellId] = true; column = _this.columnController.getDisplayedColAfter(column); }); // move to next row down for next set of values currentRow = _this.cellNavigationService.getRowBelow(currentRow); }); // this is very heavy!! this.rowRenderer.refreshView(); this.eventService.dispatchEvent(main_18.Events.EVENT_FLASH_CELLS, { cells: cellsToFlash }); }; ClipboardService.prototype.copyToClipboard = function () { this.logger.log('copyToClipboard'); // default is copy range if exists, otherwise rows if (this.rangeController.isMoreThanOneCell()) { this.copySelectedRangeToClipboard(); } else if (!this.selectionController.isEmpty()) { this.copySelectedRowsToClipboard(); } else if (!this.rangeController.isEmpty()) { this.copySelectedRangeToClipboard(); } }; ClipboardService.prototype.copySelectedRangeToClipboard = function () { var _this = this; if (this.rangeController.isEmpty()) { return; } var rangeSelections = this.rangeController.getCellRanges(); // if more than one range selected, we take the first one only, we ignore the others, // in Excel, it doesn't allow multiple blocks to be copied to clipboard at same time var range = rangeSelections[0]; // get starting and ending row, remember rowEnd could be before rowStart var startRow = range.start.getGridRow(); var endRow = range.end.getGridRow(); var startRowIsFirst = startRow.before(endRow); var currentRow = startRowIsFirst ? startRow : endRow; var lastRow = startRowIsFirst ? endRow : startRow; var cellsToFlash = {}; var data = ''; while (true) { range.columns.forEach(function (column, index) { var rowNode = _this.getRowNode(currentRow); var value = _this.valueService.getValue(column, rowNode); value = _this.processRangeCell(rowNode, column, value); if (index != 0) { data += '\t'; } if (main_16.Utils.exists(value)) { data += value; } var cellId = new main_17.GridCell(currentRow.rowIndex, currentRow.floating, column).createId(); cellsToFlash[cellId] = true; }); data += '\r\n'; if (currentRow.equals(lastRow)) { break; } currentRow = this.cellNavigationService.getRowBelow(currentRow); } this.copyDataToClipboard(data); this.eventService.dispatchEvent(main_18.Events.EVENT_FLASH_CELLS, { cells: cellsToFlash }); }; ClipboardService.prototype.processRangeCell = function (rowNode, column, value) { var func = this.gridOptionsWrapper.getProcessCellForClipboardFunc(); if (func) { return func({ column: column, node: rowNode, value: value, api: this.gridOptionsWrapper.getApi(), columnApi: this.gridOptionsWrapper.getColumnApi(), context: this.gridOptionsWrapper.getContext() }); } else { return value; } }; ClipboardService.prototype.getRowNode = function (gridRow) { switch (gridRow.floating) { case main_19.Constants.FLOATING_TOP: return this.floatingRowModel.getFloatingTopRowData()[gridRow.rowIndex]; case main_19.Constants.FLOATING_BOTTOM: return this.floatingRowModel.getFloatingBottomRowData()[gridRow.rowIndex]; default: return this.rowModel.getRow(gridRow.rowIndex); } }; ClipboardService.prototype.copySelectedRowsToClipboard = function () { var data = this.csvCreator.getDataAsCsv({ skipHeader: true, skipFooters: true, columnSeparator: '\t', onlySelected: true, processCellCallback: this.gridOptionsWrapper.getProcessCellForClipboardFunc() }); this.copyDataToClipboard(data); }; ClipboardService.prototype.copyDataToClipboard = function (data) { this.executeOnTempElement(function (element) { element.value = data; element.select(); element.focus(); return document.execCommand('copy'); }); }; ClipboardService.prototype.executeOnTempElement = function (callbackNow, callbackAfter) { var eTempInput = document.createElement('textarea'); eTempInput.style.width = '1px'; eTempInput.style.height = '1px'; eTempInput.style.top = '0px'; eTempInput.style.left = '0px'; eTempInput.style.position = 'absolute'; eTempInput.style.opacity = '0.0'; document.body.appendChild(eTempInput); try { var result = callbackNow(eTempInput); this.logger.log('Clipboard operation result: ' + result); } catch (err) { this.logger.log('Browser doesn\t support document.execComment(\'copy\') for clipboard operations'); } if (callbackAfter) { setTimeout(function () { callbackAfter(eTempInput); document.body.removeChild(eTempInput); }, 0); } else { document.body.removeChild(eTempInput); } }; // From http://stackoverflow.com/questions/1293147/javascript-code-to-parse-csv-data // This will parse a delimited string into an array of // arrays. The default delimiter is the comma, but this // can be overriden in the second argument. ClipboardService.prototype.dataToArray = function (strData) { var strDelimiter = '\t'; // Create a regular expression to parse the CSV values. var objPattern = new RegExp(( // Delimiters. "(\\" + strDelimiter + "|\\r?\\n|\\r|^)" + // Quoted fields. "(?:\"([^\"]*(?:\"\"[^\"]*)*)\"|" + // Standard fields. "([^\"\\" + strDelimiter + "\\r\\n]*))"), "gi"); // Create an array to hold our data. Give the array // a default empty first row. var arrData = [[]]; // Create an array to hold our individual pattern // matching groups. var arrMatches = null; // Keep looping over the regular expression matches // until we can no longer find a match. while (arrMatches = objPattern.exec(strData)) { // Get the delimiter that was found. var strMatchedDelimiter = arrMatches[1]; // Check to see if the given delimiter has a length // (is not the start of string) and if it matches // field delimiter. If id does not, then we know // that this delimiter is a row delimiter. if (strMatchedDelimiter.length && strMatchedDelimiter !== strDelimiter) { // Since we have reached a new row of data, // add an empty row to our data array. arrData.push([]); } var strMatchedValue; // Now that we have our delimiter out of the way, // let's check to see which kind of value we // captured (quoted or unquoted). if (arrMatches[2]) { // We found a quoted value. When we capture // this value, unescape any double quotes. strMatchedValue = arrMatches[2].replace(new RegExp("\"\"", "g"), "\""); } else { // We found a non-quoted value. strMatchedValue = arrMatches[3]; } // Now that we have our value string, let's add // it to the data array. arrData[arrData.length - 1].push(strMatchedValue); } // Return the parsed data. return arrData; }; __decorate([ main_2.Autowired('csvCreator'), __metadata('design:type', main_3.CsvCreator) ], ClipboardService.prototype, "csvCreator", void 0); __decorate([ main_2.Autowired('loggerFactory'), __metadata('design:type', main_4.LoggerFactory) ], ClipboardService.prototype, "loggerFactory", void 0); __decorate([ main_2.Autowired('selectionController'), __metadata('design:type', main_5.SelectionController) ], ClipboardService.prototype, "selectionController", void 0); __decorate([ main_2.Autowired('rangeController'), __metadata('design:type', rangeController_1.RangeController) ], ClipboardService.prototype, "rangeController", void 0); __decorate([ main_2.Autowired('rowModel'), __metadata('design:type', Object) ], ClipboardService.prototype, "rowModel", void 0); __decorate([ main_2.Autowired('floatingRowModel'), __metadata('design:type', main_6.FloatingRowModel) ], ClipboardService.prototype, "floatingRowModel", void 0); __decorate([ main_2.Autowired('valueService'), __metadata('design:type', main_7.ValueService) ], ClipboardService.prototype, "valueService", void 0); __decorate([ main_2.Autowired('focusedCellController'), __metadata('design:type', main_8.FocusedCellController) ], ClipboardService.prototype, "focusedCellController", void 0); __decorate([ main_2.Autowired('rowRenderer'), __metadata('design:type', main_9.RowRenderer) ], ClipboardService.prototype, "rowRenderer", void 0); __decorate([ main_2.Autowired('columnController'), __metadata('design:type', main_10.ColumnController) ], ClipboardService.prototype, "columnController", void 0); __decorate([ main_2.Autowired('eventService'), __metadata('design:type', main_11.EventService) ], ClipboardService.prototype, "eventService", void 0); __decorate([ main_2.Autowired('cellNavigationService'), __metadata('design:type', main_12.CellNavigationService) ], ClipboardService.prototype, "cellNavigationService", void 0); __decorate([ main_2.Autowired('gridOptionsWrapper'), __metadata('design:type', main_13.GridOptionsWrapper) ], ClipboardService.prototype, "gridOptionsWrapper", void 0); __decorate([ main_14.PostConstruct, __metadata('design:type', Function), __metadata('design:paramtypes', []), __metadata('design:returntype', void 0) ], ClipboardService.prototype, "init", null); ClipboardService = __decorate([ main_1.Bean('clipboardService'), __metadata('design:paramtypes', []) ], ClipboardService); return ClipboardService; })();
var MD5 = (function () { function MD5() { this.ieCompatibility = false; } MD5.prototype.init = function () { this.ieCompatibility = (this.md5('hello') != '5d41402abc4b2a76b9719d911017c592'); }; MD5.prototype.md5cycle = function (x, k) { var a = x[0], b = x[1], c = x[2], d = x[3]; a = this.ff(a, b, c, d, k[0], 7, -680876936); d = this.ff(d, a, b, c, k[1], 12, -389564586); c = this.ff(c, d, a, b, k[2], 17, 606105819); b = this.ff(b, c, d, a, k[3], 22, -1044525330); a = this.ff(a, b, c, d, k[4], 7, -176418897); d = this.ff(d, a, b, c, k[5], 12, 1200080426); c = this.ff(c, d, a, b, k[6], 17, -1473231341); b = this.ff(b, c, d, a, k[7], 22, -45705983); a = this.ff(a, b, c, d, k[8], 7, 1770035416); d = this.ff(d, a, b, c, k[9], 12, -1958414417); c = this.ff(c, d, a, b, k[10], 17, -42063); b = this.ff(b, c, d, a, k[11], 22, -1990404162); a = this.ff(a, b, c, d, k[12], 7, 1804603682); d = this.ff(d, a, b, c, k[13], 12, -40341101); c = this.ff(c, d, a, b, k[14], 17, -1502002290); b = this.ff(b, c, d, a, k[15], 22, 1236535329); a = this.gg(a, b, c, d, k[1], 5, -165796510); d = this.gg(d, a, b, c, k[6], 9, -1069501632); c = this.gg(c, d, a, b, k[11], 14, 643717713); b = this.gg(b, c, d, a, k[0], 20, -373897302); a = this.gg(a, b, c, d, k[5], 5, -701558691); d = this.gg(d, a, b, c, k[10], 9, 38016083); c = this.gg(c, d, a, b, k[15], 14, -660478335); b = this.gg(b, c, d, a, k[4], 20, -405537848); a = this.gg(a, b, c, d, k[9], 5, 568446438); d = this.gg(d, a, b, c, k[14], 9, -1019803690); c = this.gg(c, d, a, b, k[3], 14, -187363961); b = this.gg(b, c, d, a, k[8], 20, 1163531501); a = this.gg(a, b, c, d, k[13], 5, -1444681467); d = this.gg(d, a, b, c, k[2], 9, -51403784); c = this.gg(c, d, a, b, k[7], 14, 1735328473); b = this.gg(b, c, d, a, k[12], 20, -1926607734); a = this.hh(a, b, c, d, k[5], 4, -378558); d = this.hh(d, a, b, c, k[8], 11, -2022574463); c = this.hh(c, d, a, b, k[11], 16, 1839030562); b = this.hh(b, c, d, a, k[14], 23, -35309556); a = this.hh(a, b, c, d, k[1], 4, -1530992060); d = this.hh(d, a, b, c, k[4], 11, 1272893353); c = this.hh(c, d, a, b, k[7], 16, -155497632); b = this.hh(b, c, d, a, k[10], 23, -1094730640); a = this.hh(a, b, c, d, k[13], 4, 681279174); d = this.hh(d, a, b, c, k[0], 11, -358537222); c = this.hh(c, d, a, b, k[3], 16, -722521979); b = this.hh(b, c, d, a, k[6], 23, 76029189); a = this.hh(a, b, c, d, k[9], 4, -640364487); d = this.hh(d, a, b, c, k[12], 11, -421815835); c = this.hh(c, d, a, b, k[15], 16, 530742520); b = this.hh(b, c, d, a, k[2], 23, -995338651); a = this.ii(a, b, c, d, k[0], 6, -198630844); d = this.ii(d, a, b, c, k[7], 10, 1126891415); c = this.ii(c, d, a, b, k[14], 15, -1416354905); b = this.ii(b, c, d, a, k[5], 21, -57434055); a = this.ii(a, b, c, d, k[12], 6, 1700485571); d = this.ii(d, a, b, c, k[3], 10, -1894986606); c = this.ii(c, d, a, b, k[10], 15, -1051523); b = this.ii(b, c, d, a, k[1], 21, -2054922799); a = this.ii(a, b, c, d, k[8], 6, 1873313359); d = this.ii(d, a, b, c, k[15], 10, -30611744); c = this.ii(c, d, a, b, k[6], 15, -1560198380); b = this.ii(b, c, d, a, k[13], 21, 1309151649); a = this.ii(a, b, c, d, k[4], 6, -145523070); d = this.ii(d, a, b, c, k[11], 10, -1120210379); c = this.ii(c, d, a, b, k[2], 15, 718787259); b = this.ii(b, c, d, a, k[9], 21, -343485551); x[0] = this.add32(a, x[0]); x[1] = this.add32(b, x[1]); x[2] = this.add32(c, x[2]); x[3] = this.add32(d, x[3]); }; MD5.prototype.cmn = function (q, a, b, x, s, t) { a = this.add32(this.add32(a, q), this.add32(x, t)); return this.add32((a << s) | (a >>> (32 - s)), b); }; MD5.prototype.ff = function (a, b, c, d, x, s, t) { return this.cmn((b & c) | ((~b) & d), a, b, x, s, t); }; MD5.prototype.gg = function (a, b, c, d, x, s, t) { return this.cmn((b & d) | (c & (~d)), a, b, x, s, t); }; MD5.prototype.hh = function (a, b, c, d, x, s, t) { return this.cmn(b ^ c ^ d, a, b, x, s, t); }; MD5.prototype.ii = function (a, b, c, d, x, s, t) { return this.cmn(c ^ (b | (~d)), a, b, x, s, t); }; MD5.prototype.md51 = function (s) { var n = s.length, state = [1732584193, -271733879, -1732584194, 271733878], i; for (i = 64; i <= s.length; i += 64) { this.md5cycle(state, this.md5blk(s.substring(i - 64, i))); } s = s.substring(i - 64); var tail = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; for (i = 0; i < s.length; i++) tail[i >> 2] |= s.charCodeAt(i) << ((i % 4) << 3); tail[i >> 2] |= 0x80 << ((i % 4) << 3); if (i > 55) { this.md5cycle(state, tail); for (i = 0; i < 16; i++) tail[i] = 0; } tail[14] = n * 8; this.md5cycle(state, tail); return state; }; /* there needs to be support for Unicode here, * unless we pretend that we can redefine the MD-5 * algorithm for multi-byte characters (perhaps by adding every four 16-bit characters and * shortening the sum to 32 bits). Otherwise I suthis.ggest performing MD-5 as if every character * was two bytes--e.g., 0040 0025 = @%--but then how will an ordinary MD-5 sum be matched? * There is no way to standardize text to something like UTF-8 before transformation; speed cost is * utterly prohibitive. The JavaScript standard itself needs to look at this: it should start * providing access to strings as preformed UTF-8 8-bit unsigned value arrays. */ MD5.prototype.md5blk = function (s) { var md5blks = [], i; /* Andy King said do it this way. */ for (i = 0; i < 64; i += 4) { md5blks[i >> 2] = s.charCodeAt(i) + (s.charCodeAt(i + 1) << 8) + (s.charCodeAt(i + 2) << 16) + (s.charCodeAt(i + 3) << 24); } return md5blks; }; MD5.prototype.rhex = function (n) { var hex_chr = '0123456789abcdef'.split(''); var s = '', j = 0; for (; j < 4; j++) s += hex_chr[(n >> (j * 8 + 4)) & 0x0F] + hex_chr[(n >> (j * 8)) & 0x0F]; return s; }; MD5.prototype.hex = function (x) { for (var i = 0; i < x.length; i++) x[i] = this.rhex(x[i]); return x.join(''); }; MD5.prototype.md5 = function (s) { return this.hex(this.md51(s)); }; MD5.prototype.add32 = function (a, b) { return this.ieCompatibility ? this.add32Compat(a, b) : this.add32Std(a, b); }; /* this function is much faster, so if possible we use it. Some IEs are the only ones I know of that need the idiotic second function, generated by an if clause. */ MD5.prototype.add32Std = function (a, b) { return (a + b) & 0xFFFFFFFF; }; MD5.prototype.add32Compat = function (x, y) { var lsw = (x & 0xFFFF) + (y & 0xFFFF), msw = (x >> 16) + (y >> 16) + (lsw >> 16); return (msw << 16) | (lsw & 0xFFFF); }; __decorate([ main_1.PostConstruct, __metadata('design:type', Function), __metadata('design:paramtypes', []), __metadata('design:returntype', void 0) ], MD5.prototype, "init", null); MD5 = __decorate([ main_1.Bean('md5'), __metadata('design:paramtypes', []) ], MD5); return MD5; })();
var AggFuncService = (function () { function AggFuncService() { this.aggFuncsMap = {}; this.initialised = false; } AggFuncService.prototype.init = function () { if (this.initialised) { return; } this.initialised = true; this.initialiseWithDefaultAggregations(); this.addAggFuncs(this.gridOptionsWrapper.getAggFuncs()); }; AggFuncService.prototype.initialiseWithDefaultAggregations = function () { this.aggFuncsMap[AggFuncService.AGG_SUM] = aggSum; this.aggFuncsMap[AggFuncService.AGG_FIRST] = aggFirst; this.aggFuncsMap[AggFuncService.AGG_LAST] = aggLast; this.aggFuncsMap[AggFuncService.AGG_MIN] = aggMin; this.aggFuncsMap[AggFuncService.AGG_MAX] = aggMax; this.aggFuncsMap[AggFuncService.AGG_COUNT] = aggCount; this.aggFuncsMap[AggFuncService.AGG_AVG] = aggAvg; }; AggFuncService.prototype.getDefaultAggFunc = function () { if (this.aggFuncsMap[AggFuncService.AGG_SUM]) { // use 'sum' if it's still there (ie user has not removed it) return AggFuncService.AGG_SUM; } else { var allKeys = this.getFuncNames(); if (main_1.Utils.existsAndNotEmpty(allKeys)) { return allKeys[0]; } else { return null; } } }; AggFuncService.prototype.addAggFuncs = function (aggFuncs) { main_1.Utils.iterateObject(aggFuncs, this.addAggFunc.bind(this)); }; AggFuncService.prototype.addAggFunc = function (key, aggFunc) { this.init(); this.aggFuncsMap[key] = aggFunc; }; AggFuncService.prototype.getAggFunc = function (name) { this.init(); return this.aggFuncsMap[name]; }; AggFuncService.prototype.getFuncNames = function () { return Object.keys(this.aggFuncsMap).sort(); }; AggFuncService.prototype.clear = function () { this.aggFuncsMap = {}; }; AggFuncService.AGG_SUM = 'sum'; AggFuncService.AGG_FIRST = 'first'; AggFuncService.AGG_LAST = 'last'; AggFuncService.AGG_MIN = 'min'; AggFuncService.AGG_MAX = 'max'; AggFuncService.AGG_COUNT = 'count'; AggFuncService.AGG_AVG = 'avg'; __decorate([ main_1.Autowired('gridOptionsWrapper'), __metadata('design:type', main_1.GridOptionsWrapper) ], AggFuncService.prototype, "gridOptionsWrapper", void 0); __decorate([ main_1.PostConstruct, __metadata('design:type', Function), __metadata('design:paramtypes', []), __metadata('design:returntype', void 0) ], AggFuncService.prototype, "init", null); AggFuncService = __decorate([ main_1.Bean('aggFuncService'), __metadata('design:paramtypes', []) ], AggFuncService); return AggFuncService; })();
var StatusBar = (function (_super) { __extends(StatusBar, _super); function StatusBar() { _super.call(this, StatusBar.TEMPLATE); this.aggregationsComponent = new main_1.Component('<div class="ag-status-bar-aggregations"></div>'); } StatusBar.prototype.init = function () { this.createStatusItems(); this.eventService.addEventListener(main_1.Events.EVENT_RANGE_SELECTION_CHANGED, this.onRangeSelectionChanged.bind(this)); }; StatusBar.prototype.createStatusItems = function () { var _this = this; var localeTextFunc = this.gridOptionsWrapper.getLocaleTextFunc(); this.statusItemSum = new statusItem_1.StatusItem(localeTextFunc('sum', 'Sum')); this.statusItemCount = new statusItem_1.StatusItem(localeTextFunc('count', 'Count')); this.statusItemMin = new statusItem_1.StatusItem(localeTextFunc('min', 'Min')); this.statusItemMax = new statusItem_1.StatusItem(localeTextFunc('max', 'Max')); this.statusItemAvg = new statusItem_1.StatusItem(localeTextFunc('average', 'Average')); this.forEachStatusItem(function (statusItem) { _this.context.wireBean(statusItem); _this.aggregationsComponent.appendChild(statusItem); statusItem.setVisible(false); }); this.appendChild(this.aggregationsComponent); }; StatusBar.prototype.forEachStatusItem = function (callback) { [this.statusItemAvg, this.statusItemCount, this.statusItemMin, this.statusItemMax, this.statusItemSum].forEach(callback); }; StatusBar.prototype.onRangeSelectionChanged = function () { var _this = this; var cellRanges = this.rangeController.getCellRanges(); var sum = 0; var count = 0; var numberCount = 0; var min = null; var max = null; var cellsSoFar = {}; if (!main_1.Utils.missingOrEmpty(cellRanges)) { cellRanges.forEach(function (cellRange) { // get starting and ending row, remember rowEnd could be before rowStart var startRow = cellRange.start.getGridRow(); var endRow = cellRange.end.getGridRow(); var startRowIsFirst = startRow.before(endRow); var currentRow = startRowIsFirst ? startRow : endRow; var lastRow = startRowIsFirst ? endRow : startRow; while (true) { cellRange.columns.forEach(function (column) { // we only want to include each cell once, in case a cell is in multiple ranges var cellId = currentRow.getGridCell(column).createId(); if (cellsSoFar[cellId]) { return; } cellsSoFar[cellId] = true; var rowNode = _this.getRowNode(currentRow); var value = _this.valueService.getValue(column, rowNode); // if empty cell, skip it, doesn't impact count or anything if (main_1.Utils.missing(value) || value === '') { return; } if (typeof value === 'string') { value = Number(value); } if (typeof value === 'number' && !isNaN(value)) { sum += value; if (max === null || value > max) { max = value; } if (min === null || value < min) { min = value; } numberCount++; } count++; }); if (currentRow.equals(lastRow)) { break; } currentRow = _this.cellNavigationService.getRowBelow(currentRow); } }); } var gotResult = count > 1; var gotNumberResult = numberCount > 0; // we should count even if no numbers if (gotResult) { this.statusItemCount.setValue(count); } this.statusItemCount.setVisible(gotResult); // if numbers, then show the number items if (gotNumberResult) { this.statusItemSum.setValue(sum); this.statusItemMin.setValue(min); this.statusItemMax.setValue(max); this.statusItemAvg.setValue(sum / numberCount); } this.statusItemSum.setVisible(gotNumberResult); this.statusItemMin.setVisible(gotNumberResult); this.statusItemMax.setVisible(gotNumberResult); this.statusItemAvg.setVisible(gotNumberResult); }; StatusBar.prototype.getRowNode = function (gridRow) { switch (gridRow.floating) { case main_1.Constants.FLOATING_TOP: return this.floatingRowModel.getFloatingTopRowData()[gridRow.rowIndex]; case main_1.Constants.FLOATING_BOTTOM: return this.floatingRowModel.getFloatingBottomRowData()[gridRow.rowIndex]; default: return this.rowModel.getRow(gridRow.rowIndex); } }; StatusBar.TEMPLATE = '<div class="ag-status-bar">' + '</div>'; __decorate([ main_1.Autowired('eventService'), __metadata('design:type', main_1.EventService) ], StatusBar.prototype, "eventService", void 0); __decorate([ main_1.Autowired('rangeController'), __metadata('design:type', rangeController_1.RangeController) ], StatusBar.prototype, "rangeController", void 0); __decorate([ main_1.Autowired('valueService'), __metadata('design:type', main_1.ValueService) ], StatusBar.prototype, "valueService", void 0); __decorate([ main_1.Autowired('cellNavigationService'), __metadata('design:type', main_1.CellNavigationService) ], StatusBar.prototype, "cellNavigationService", void 0); __decorate([ main_1.Autowired('floatingRowModel'), __metadata('design:type', main_1.FloatingRowModel) ], StatusBar.prototype, "floatingRowModel", void 0); __decorate([ main_1.Autowired('rowModel'), __metadata('design:type', Object) ], StatusBar.prototype, "rowModel", void 0); __decorate([ main_1.Autowired('context'), __metadata('design:type', main_1.Context) ], StatusBar.prototype, "context", void 0); __decorate([ main_1.Autowired('gridOptionsWrapper'), __metadata('design:type', main_1.GridOptionsWrapper) ], StatusBar.prototype, "gridOptionsWrapper", void 0); __decorate([ main_1.PostConstruct, __metadata('design:type', Function), __metadata('design:paramtypes', []), __metadata('design:returntype', void 0) ], StatusBar.prototype, "init", null); StatusBar = __decorate([ main_1.Bean('statusBar'), __metadata('design:paramtypes', []) ], StatusBar); return StatusBar; })(main_1.Component);
var ContextMenuFactory = (function () { function ContextMenuFactory() { } ContextMenuFactory.prototype.init = function () { }; ContextMenuFactory.prototype.getMenuItems = function (node, column, value) { var defaultMenuOptions = ['copy', 'paste', 'separator', 'toolPanel']; if (this.gridOptionsWrapper.getContextMenuItemsFunc()) { var userFunc = this.gridOptionsWrapper.getContextMenuItemsFunc(); var params = { node: node, column: column, value: value, defaultItems: defaultMenuOptions, api: this.gridOptionsWrapper.getApi(), columnApi: this.gridOptionsWrapper.getColumnApi(), context: this.gridOptionsWrapper.getContext() }; var menuItemsFromUser = userFunc(params); return menuItemsFromUser; } else { return defaultMenuOptions; } }; ContextMenuFactory.prototype.showMenu = function (node, column, value, mouseEvent) { var menuItems = this.getMenuItems(node, column, value); var menu = new ContextMenu(menuItems); this.context.wireBean(menu); var eMenuGui = menu.getGui(); // need to show filter before positioning, as only after filter // is visible can we find out what the width of it is var hidePopup = this.popupService.addAsModalPopup(eMenuGui, true, function () { return menu.destroy(); }); this.popupService.positionPopupUnderMouseEvent({ mouseEvent: mouseEvent, ePopup: eMenuGui }); menu.afterGuiAttached(hidePopup); }; __decorate([ main_1.Autowired('context'), __metadata('design:type', main_1.Context) ], ContextMenuFactory.prototype, "context", void 0); __decorate([ main_1.Autowired('popupService'), __metadata('design:type', main_1.PopupService) ], ContextMenuFactory.prototype, "popupService", void 0); __decorate([ main_1.Autowired('gridOptionsWrapper'), __metadata('design:type', main_1.GridOptionsWrapper) ], ContextMenuFactory.prototype, "gridOptionsWrapper", void 0); __decorate([ main_1.PostConstruct, __metadata('design:type', Function), __metadata('design:paramtypes', []), __metadata('design:returntype', void 0) ], ContextMenuFactory.prototype, "init", null); ContextMenuFactory = __decorate([ main_1.Bean('contextMenuFactory'), __metadata('design:paramtypes', []) ], ContextMenuFactory); return ContextMenuFactory; })();
var PivotColDefService = (function () { function PivotColDefService() { } PivotColDefService.prototype.createPivotColumnDefs = function (uniqueValues) { var pivotColumnGroupDefs = []; var pivotColumnDefs = []; var pivotColumns = this.columnController.getPivotColumns(); var levelsDeep = pivotColumns.length; var columnIdSequence = new main_1.NumberSequence(); this.recursivelyAddGroup(pivotColumnGroupDefs, pivotColumnDefs, 1, uniqueValues, [], columnIdSequence, levelsDeep); return { pivotColumnGroupDefs: pivotColumnGroupDefs, pivotColumnDefs: pivotColumnDefs }; }; // parentChildren - the list of colDefs we are adding to // @index - how far the column is from the top (also same as pivotKeys.length) // @uniqueValues - the values for which we should create a col for // @pivotKeys - the keys for the pivot, eg if pivoting on {Language,Country} then could be {English,Ireland} PivotColDefService.prototype.recursivelyAddGroup = function (parentChildren, pivotColumnDefs, index, uniqueValues, pivotKeys, columnIdSequence, levelsDeep) { var _this = this; main_1.Utils.iterateObject(uniqueValues, function (key, value) { var newPivotKeys = pivotKeys.slice(0); newPivotKeys.push(key); var createGroup = index !== levelsDeep; if (createGroup) { var groupDef = { children: [], headerName: key }; parentChildren.push(groupDef); _this.recursivelyAddGroup(groupDef.children, pivotColumnDefs, index + 1, value, newPivotKeys, columnIdSequence, levelsDeep); } else { var measureColumns = _this.columnController.getAggregationColumns(); var valueGroup = { children: [], headerName: key }; parentChildren.push(valueGroup); measureColumns.forEach(function (measureColumn) { var colDef = _this.createColDef(measureColumn, measureColumn.getColDef().headerName, newPivotKeys, columnIdSequence); valueGroup.children.push(colDef); pivotColumnDefs.push(colDef); }); valueGroup.children.sort(_this.headerNameComparator.bind(_this)); } parentChildren.sort(_this.headerNameComparator.bind(_this)); }); }; PivotColDefService.prototype.createColDef = function (valueColumn, headerName, pivotKeys, columnIdSequence) { var colDef = {}; if (valueColumn) { var colDefToCopy = valueColumn.getColDef(); main_1.Utils.assign(colDef, colDefToCopy); } colDef.valueGetter = null; colDef.headerName = headerName; colDef.colId = 'pivot_' + columnIdSequence.next(); colDef.pivotKeys = pivotKeys; colDef.pivotValueColumn = valueColumn; return colDef; }; PivotColDefService.prototype.headerNameComparator = function (a, b) { if (a.headerName < b.headerName) { return -1; } else if (a.headerName > b.headerName) { return 1; } else { return 0; } }; __decorate([ main_1.Autowired('columnController'), __metadata('design:type', main_1.ColumnController) ], PivotColDefService.prototype, "columnController", void 0); PivotColDefService = __decorate([ main_1.Bean('pivotColDefService'), __metadata('design:paramtypes', []) ], PivotColDefService); return PivotColDefService; })();
var AggregationStage = (function () { function AggregationStage() { } // it's possible to recompute the aggregate without doing the other parts // + gridApi.recomputeAggregates() AggregationStage.prototype.execute = function (rowsToAgg) { var groupAggFunction = this.gridOptionsWrapper.getGroupAggFunction(); if (typeof groupAggFunction === 'function') { this.recursivelyCreateAggData(rowsToAgg, groupAggFunction, 0); return; } var valueColumns = this.columnController.getValueColumns(); if (valueColumns && valueColumns.length > 0) { var defaultAggFunction = this.defaultGroupAggFunctionFactory(valueColumns); this.recursivelyCreateAggData(rowsToAgg, defaultAggFunction, 0); } else { // if no agg data, need to clear out any previous items, when can be left behind // if use is creating / removing columns using the tool panel. // one exception - don't do this if already grouped, as this breaks the File Explorer example!! // to fix another day - how to we reset when the user provided the data?? if (main_1.Utils.missing(this.gridOptionsWrapper.getNodeChildDetailsFunc())) { this.recursivelyClearAggData(rowsToAgg); } } return rowsToAgg; }; AggregationStage.prototype.recursivelyClearAggData = function (nodes) { for (var i = 0, l = nodes.length; i < l; i++) { var node = nodes[i]; if (node.group) { // agg function needs to start at the bottom, so traverse first this.recursivelyClearAggData(node.childrenAfterFilter); node.data = null; } } }; AggregationStage.prototype.recursivelyCreateAggData = function (nodes, groupAggFunction, level) { for (var i = 0, l = nodes.length; i < l; i++) { var node = nodes[i]; if (node.group) { // agg function needs to start at the bottom, so traverse first this.recursivelyCreateAggData(node.childrenAfterFilter, groupAggFunction, level++); // after traversal, we can now do the agg at this level var data = groupAggFunction(node.childrenAfterFilter, level); node.data = data; // if we are grouping, then it's possible there is a sibling footer // to the group, so update the data here also if there is one if (node.sibling) { node.sibling.data = data; } } } }; AggregationStage.prototype.defaultGroupAggFunctionFactory = function (valueColumns) { // make closure of variable, so is available for methods below var _valueService = this.valueService; return function groupAggFunction(rows) { var result = {}; for (var j = 0; j < valueColumns.length; j++) { var valueColumn = valueColumns[j]; var colKey = valueColumn.getColDef().field; if (!colKey) { console.log('ag-Grid: you need to provide a field for all value columns so that ' + 'the grid knows what field to store the result in. so even if using a valueGetter, ' + 'the result will not be stored in a value getter.'); } // at this point, if no values were numbers, the result is null (not zero) result[colKey] = aggregateColumn(rows, valueColumn.getAggFunc(), colKey, valueColumn); } return result; }; // if colDef is passed in, we are working off a column value, if it is not passed in, we are // working off colKeys passed in to the gridOptions function aggregateColumn(rowNodes, aggFunc, colKey, column) { var resultForColumn = null; for (var i = 0; i < rowNodes.length; i++) { var rowNode = rowNodes[i]; // if the row is a group, then it will only have an agg result value, // which means valueGetter is never used. var thisColumnValue; if (rowNode.group) { thisColumnValue = rowNode.data[colKey]; } else { thisColumnValue = _valueService.getValue(column, rowNode); } // only include if the value is a number if (typeof thisColumnValue === 'number') { var firstRow = i === 0; var lastRow = i === (rowNodes.length - 1); switch (aggFunc) { case main_7.Column.AGG_SUM: resultForColumn += thisColumnValue; break; case main_7.Column.AGG_MIN: if (resultForColumn === null) { resultForColumn = thisColumnValue; } else if (resultForColumn > thisColumnValue) { resultForColumn = thisColumnValue; } break; case main_7.Column.AGG_MAX: if (resultForColumn === null) { resultForColumn = thisColumnValue; } else if (resultForColumn < thisColumnValue) { resultForColumn = thisColumnValue; } break; case main_7.Column.AGG_FIRST: if (firstRow) { resultForColumn = thisColumnValue; } break; case main_7.Column.AGG_LAST: if (lastRow) { resultForColumn = thisColumnValue; } break; } } } return resultForColumn; } }; __decorate([ main_3.Autowired('gridOptionsWrapper'), __metadata('design:type', main_4.GridOptionsWrapper) ], AggregationStage.prototype, "gridOptionsWrapper", void 0); __decorate([ main_3.Autowired('columnController'), __metadata('design:type', main_5.ColumnController) ], AggregationStage.prototype, "columnController", void 0); __decorate([ main_3.Autowired('valueService'), __metadata('design:type', main_6.ValueService) ], AggregationStage.prototype, "valueService", void 0); AggregationStage = __decorate([ main_2.Bean('aggregationStage'), __metadata('design:paramtypes', []) ], AggregationStage); return AggregationStage; })();
var ViewportRowModel = (function () { function ViewportRowModel() { // rowRenderer tells us these this.firstRow = -1; this.lastRow = -1; // datasource tells us this this.rowCount = -1; this.rowNodesByIndex = {}; } ViewportRowModel.prototype.init = function () { this.rowHeight = this.gridOptionsWrapper.getRowHeightAsNumber(); this.eventService.addEventListener(main_1.Events.EVENT_VIEWPORT_CHANGED, this.onViewportChanged.bind(this)); var viewportEnabled = this.gridOptionsWrapper.isRowModelViewport(); if (viewportEnabled && this.gridOptionsWrapper.getViewportDatasource()) { this.setViewportDatasource(this.gridOptionsWrapper.getViewportDatasource()); } }; ViewportRowModel.prototype.destroy = function () { this.destroyCurrentDatasource(); }; ViewportRowModel.prototype.destroyCurrentDatasource = function () { if (this.viewportDatasource && this.viewportDatasource.destroy) { this.viewportDatasource.destroy(); } }; ViewportRowModel.prototype.calculateFirstRow = function (firstRenderedRow) { var bufferSize = this.gridOptionsWrapper.getViewportRowModelBufferSize(); var pageSize = this.gridOptionsWrapper.getViewportRowModelPageSize(); var afterBuffer = firstRenderedRow - bufferSize; if (afterBuffer < 0) { return 0; } else { return Math.floor(afterBuffer / pageSize) * pageSize; } }; ViewportRowModel.prototype.calculateLastRow = function (lastRenderedRow) { var bufferSize = this.gridOptionsWrapper.getViewportRowModelBufferSize(); var pageSize = this.gridOptionsWrapper.getViewportRowModelPageSize(); var afterBuffer = lastRenderedRow + bufferSize; var result = Math.ceil(afterBuffer / pageSize) * pageSize; if (result <= this.rowCount) { return result; } else { return this.rowCount; } }; ViewportRowModel.prototype.onViewportChanged = function (event) { var newFirst = this.calculateFirstRow(event.firstRow); var newLast = this.calculateLastRow(event.lastRow); if (this.firstRow !== newFirst || this.lastRow !== newLast) { this.firstRow = newFirst; this.lastRow = newLast; this.purgeRowsNotInViewport(); if (this.viewportDatasource) { this.viewportDatasource.setViewportRange(this.firstRow, this.lastRow); } } }; ViewportRowModel.prototype.purgeRowsNotInViewport = function () { var _this = this; Object.keys(this.rowNodesByIndex).forEach(function (indexStr) { var index = parseInt(indexStr); if (index < _this.firstRow || index > _this.lastRow) { delete _this.rowNodesByIndex[index]; } }); }; ViewportRowModel.prototype.setViewportDatasource = function (viewportDatasource) { this.destroyCurrentDatasource(); this.viewportDatasource = viewportDatasource; this.rowCount = 0; if (!viewportDatasource.init) { console.warn('ag-Grid: viewport is missing init method.'); } else { viewportDatasource.init({ setRowCount: this.setRowCount.bind(this), setRowData: this.setRowData.bind(this), getRow: this.getRow.bind(this) }); } }; ViewportRowModel.prototype.getType = function () { return main_1.Constants.ROW_MODEL_TYPE_VIEWPORT; }; ViewportRowModel.prototype.getRow = function (rowIndex) { if (!this.rowNodesByIndex[rowIndex]) { this.rowNodesByIndex[rowIndex] = this.createNode(null, rowIndex); } return this.rowNodesByIndex[rowIndex]; }; ViewportRowModel.prototype.getRowCount = function () { return this.rowCount; }; ViewportRowModel.prototype.getRowIndexAtPixel = function (pixel) { if (this.rowHeight !== 0) { return Math.floor(pixel / this.rowHeight); } else { return 0; } }; ViewportRowModel.prototype.getRowCombinedHeight = function () { return this.rowCount * this.rowHeight; }; ViewportRowModel.prototype.isEmpty = function () { return this.rowCount > 0; }; ViewportRowModel.prototype.isRowsToRender = function () { return this.rowCount > 0; }; ViewportRowModel.prototype.forEachNode = function (callback) { }; ViewportRowModel.prototype.setRowData = function (rowData) { var _this = this; main_1.Utils.iterateObject(rowData, function (indexStr, dataItem) { var index = parseInt(indexStr); // we should never keep rows that we didn't specifically ask for, this // guarantees the contract we have with the server. if (index >= _this.firstRow && index <= _this.lastRow) { var nodeAlreadyExists = !!_this.rowNodesByIndex[index]; if (nodeAlreadyExists) { // if the grid already asked for this row (the normal case), then we would // of put a placeholder node in place. _this.rowNodesByIndex[index].setData(dataItem); } else { // the abnormal case is we requested a row even though the grid didn't need it // as a result of the paging and buffer (ie the row is off screen), in which // case we need to create a new node now _this.rowNodesByIndex[index] = _this.createNode(dataItem, index); } } }); }; // this is duplicated in virtualPageRowModel, need to refactor ViewportRowModel.prototype.createNode = function (data, rowIndex) { var rowHeight = this.rowHeight; var top = rowHeight * rowIndex; // need to refactor this, get it in sync with VirtualPageRowController, which was not // written with the rowNode.rowUpdated in mind var rowNode = new main_1.RowNode(); this.context.wireBean(rowNode); rowNode.id = rowIndex; rowNode.data = data; rowNode.rowTop = top; rowNode.rowHeight = rowHeight; return rowNode; }; ViewportRowModel.prototype.setRowCount = function (rowCount) { if (rowCount !== this.rowCount) { this.rowCount = rowCount; this.eventService.dispatchEvent(main_1.Events.EVENT_MODEL_UPDATED); } }; __decorate([ main_1.Autowired('gridOptionsWrapper'), __metadata('design:type', main_1.GridOptionsWrapper) ], ViewportRowModel.prototype, "gridOptionsWrapper", void 0); __decorate([ main_1.Autowired('eventService'), __metadata('design:type', main_1.EventService) ], ViewportRowModel.prototype, "eventService", void 0); __decorate([ main_1.Autowired('selectionController'), __metadata('design:type', main_1.SelectionController) ], ViewportRowModel.prototype, "selectionController", void 0); __decorate([ main_1.Autowired('context'), __metadata('design:type', main_1.Context) ], ViewportRowModel.prototype, "context", void 0); __decorate([ main_1.PostConstruct, __metadata('design:type', Function), __metadata('design:paramtypes', []), __metadata('design:returntype', void 0) ], ViewportRowModel.prototype, "init", null); __decorate([ main_1.PreDestroy, __metadata('design:type', Function), __metadata('design:paramtypes', []), __metadata('design:returntype', void 0) ], ViewportRowModel.prototype, "destroy", null); ViewportRowModel = __decorate([ main_1.Bean('rowModel'), __metadata('design:paramtypes', []) ], ViewportRowModel); return ViewportRowModel; })();
var AggregationStage = (function () { function AggregationStage() { } // it's possible to recompute the aggregate without doing the other parts // + gridApi.recomputeAggregates() AggregationStage.prototype.execute = function (rootNode) { // we don't do aggregation if user provided the groups var rowsAlreadyGrouped = main_1.Utils.exists(this.gridOptionsWrapper.getNodeChildDetailsFunc()); if (rowsAlreadyGrouped) { return; } var pivotActive = this.columnController.isPivotActive(); var measureColumns = this.columnController.getValueColumns(); var pivotColumns = pivotActive ? this.columnController.getPivotColumns() : []; this.recursivelyCreateAggData(rootNode, measureColumns, pivotColumns); }; AggregationStage.prototype.recursivelyCreateAggData = function (rowNode, measureColumns, pivotColumns) { var _this = this; // aggregate all children first, as we use the result in this nodes calculations rowNode.childrenAfterFilter.forEach(function (child) { if (child.group) { _this.recursivelyCreateAggData(child, measureColumns, pivotColumns); } }); this.aggregateRowNode(rowNode, measureColumns, pivotColumns); }; AggregationStage.prototype.aggregateRowNode = function (rowNode, measureColumns, pivotColumns) { var measureColumnsMissing = measureColumns.length === 0; var pivotColumnsMissing = pivotColumns.length === 0; var userProvidedGroupRowAggNodes = this.gridOptionsWrapper.getGroupRowAggNodesFunc(); var aggResult; if (userProvidedGroupRowAggNodes) { aggResult = userProvidedGroupRowAggNodes(rowNode.childrenAfterFilter); } else if (measureColumnsMissing) { aggResult = null; } else if (pivotColumnsMissing) { aggResult = this.aggregateRowNodeUsingValuesOnly(rowNode, measureColumns); } else { aggResult = this.aggregateRowNodeUsingValuesAndPivot(rowNode); } rowNode.data = aggResult; // if we are grouping, then it's possible there is a sibling footer // to the group, so update the data here also if there is one if (rowNode.sibling) { rowNode.sibling.data = aggResult; } }; AggregationStage.prototype.aggregateRowNodeUsingValuesAndPivot = function (rowNode) { var _this = this; var result = {}; var pivotColumnDefs = this.pivotStage.getPivotColumnDefs(); pivotColumnDefs.forEach(function (pivotColumnDef) { var values; var valueColumn = pivotColumnDef.pivotValueColumn; if (rowNode.leafGroup) { // lowest level group, get the values from the mapped set var keys = pivotColumnDef.pivotKeys; values = _this.getValuesFromMappedSet(rowNode.childrenMapped, keys, valueColumn); } else { // value columns and pivot columns, non-leaf group values = _this.getValuesPivotNonLeaf(rowNode, pivotColumnDef.colId); } result[pivotColumnDef.colId] = _this.aggregateValues(values, valueColumn.getAggFunc()); }); this.putInValueForGroupNode(result, rowNode); return result; }; AggregationStage.prototype.aggregateRowNodeUsingValuesOnly = function (rowNode, valueColumns) { var _this = this; var result = {}; var values2d = this.getValuesNormal(rowNode, valueColumns); valueColumns.forEach(function (valueColumn, index) { result[valueColumn.getId()] = _this.aggregateValues(values2d[index], valueColumn.getAggFunc()); }); this.putInValueForGroupNode(result, rowNode); return result; }; // when doing copy to clipboard, the valueService is used to get the value for the cell. // the problem is that the valueService is wired to get the values directly from the data // using column ID's (rather than, eg, valueGetters), so we need to have the value of the // group key in the data, so when copy to clipboard is executed, the value is picked up correctly. AggregationStage.prototype.putInValueForGroupNode = function (result, rowNode) { result[main_1.ColumnController.GROUP_AUTO_COLUMN_ID] = rowNode.key; }; AggregationStage.prototype.getValuesPivotNonLeaf = function (rowNode, colId) { var values = []; rowNode.childrenAfterFilter.forEach(function (rowNode) { var value = rowNode.data[colId]; values.push(value); }); return values; }; AggregationStage.prototype.getValuesFromMappedSet = function (mappedSet, keys, valueColumn) { var _this = this; var mapPointer = mappedSet; keys.forEach(function (key) { return mapPointer = mapPointer ? mapPointer[key] : null; }); if (!mapPointer) { return []; } var values = []; mapPointer.forEach(function (rowNode) { var value = _this.valueService.getValue(valueColumn, rowNode); values.push(value); }); return values; }; AggregationStage.prototype.getValuesNormal = function (rowNode, valueColumns) { // create 2d array, of all values for all valueColumns var values = []; valueColumns.forEach(function () { return values.push([]); }); var valueColumnCount = valueColumns.length; var rowCount = rowNode.childrenAfterFilter.length; for (var i = 0; i < rowCount; i++) { var childNode = rowNode.childrenAfterFilter[i]; for (var j = 0; j < valueColumnCount; j++) { var valueColumn = valueColumns[j]; var value; // if the row is a group, then it will only have an agg result value, // which means valueGetter is never used. if (childNode.group) { value = childNode.data[valueColumn.getId()]; } else { value = this.valueService.getValueUsingSpecificData(valueColumn, childNode.data, childNode); } values[j].push(value); } } return values; }; AggregationStage.prototype.aggregateValues = function (values, aggFuncOrString) { var aggFunction; if (typeof aggFuncOrString === 'string') { aggFunction = this.aggFuncService.getAggFunc(aggFuncOrString); } else { aggFunction = aggFuncOrString; } if (typeof aggFunction !== 'function') { console.error("ag-Grid: unrecognised aggregation function " + aggFuncOrString); return null; } var result = aggFunction(values); return result; }; __decorate([ main_1.Autowired('gridOptionsWrapper'), __metadata('design:type', main_1.GridOptionsWrapper) ], AggregationStage.prototype, "gridOptionsWrapper", void 0); __decorate([ main_1.Autowired('columnController'), __metadata('design:type', main_1.ColumnController) ], AggregationStage.prototype, "columnController", void 0); __decorate([ main_1.Autowired('valueService'), __metadata('design:type', main_1.ValueService) ], AggregationStage.prototype, "valueService", void 0); __decorate([ main_1.Autowired('pivotStage'), __metadata('design:type', pivotStage_1.PivotStage) ], AggregationStage.prototype, "pivotStage", void 0); __decorate([ main_1.Autowired('aggFuncService'), __metadata('design:type', aggFuncService_1.AggFuncService) ], AggregationStage.prototype, "aggFuncService", void 0); AggregationStage = __decorate([ main_1.Bean('aggregationStage'), __metadata('design:paramtypes', []) ], AggregationStage); return AggregationStage; })();
var GroupStage = (function () { function GroupStage() { } GroupStage.prototype.execute = function (rowsToGroup) { var result; var groupedCols = this.columnController.getRowGroupColumns(); if (groupedCols.length > 0) { var expandByDefault; if (this.gridOptionsWrapper.isGroupSuppressRow()) { expandByDefault = -1; } else { expandByDefault = this.gridOptionsWrapper.getGroupDefaultExpanded(); } result = this.group(rowsToGroup, groupedCols, expandByDefault); } else { result = rowsToGroup; } return result; }; GroupStage.prototype.group = function (rowNodes, groupedCols, expandByDefault) { var topMostGroup = new main_1.RowNode(); this.context.wireBean(topMostGroup); topMostGroup.level = -1; topMostGroup.children = []; topMostGroup._childrenMap = {}; var allGroups = []; allGroups.push(topMostGroup); var levelToInsertChild = groupedCols.length - 1; var i; var currentLevel; var node; var currentGroup; var groupKey; var nextGroup; var includeParents = !this.gridOptionsWrapper.isSuppressParentsInRowNodes(); // start at -1 and go backwards, as all the positive indexes // are already used by the nodes. var index = -1; for (i = 0; i < rowNodes.length; i++) { node = rowNodes[i]; // all leaf nodes have the same level in this grouping, which is one level after the last group node.level = levelToInsertChild + 1; for (currentLevel = 0; currentLevel < groupedCols.length; currentLevel++) { var groupColumn = groupedCols[currentLevel]; groupKey = this.valueService.getValue(groupColumn, node); if (currentLevel === 0) { currentGroup = topMostGroup; } // if group doesn't exist yet, create it nextGroup = currentGroup._childrenMap[groupKey]; if (!nextGroup) { nextGroup = new main_1.RowNode(); this.context.wireBean(nextGroup); nextGroup.group = true; nextGroup.field = groupColumn.getColDef().field; nextGroup.id = index--; nextGroup.key = groupKey; nextGroup.expanded = this.isExpanded(expandByDefault, currentLevel); nextGroup.children = []; // for top most level, parent is null nextGroup.parent = null; nextGroup.allChildrenCount = 0; nextGroup.level = currentGroup.level + 1; // this is a temporary map, we remove at the end of this method nextGroup._childrenMap = {}; if (includeParents) { nextGroup.parent = currentGroup === topMostGroup ? null : currentGroup; } currentGroup._childrenMap[groupKey] = nextGroup; currentGroup.children.push(nextGroup); allGroups.push(nextGroup); } nextGroup.allChildrenCount++; if (currentLevel == levelToInsertChild) { if (includeParents) { node.parent = nextGroup === topMostGroup ? null : nextGroup; } nextGroup.children.push(node); } else { currentGroup = nextGroup; } } } //remove the temporary map for (i = 0; i < allGroups.length; i++) { delete allGroups[i]._childrenMap; } return topMostGroup.children; }; GroupStage.prototype.isExpanded = function (expandByDefault, level) { if (typeof expandByDefault === 'number') { if (expandByDefault === -1) { return true; } else { return level < expandByDefault; } } else { return false; } }; __decorate([ main_1.Autowired('selectionController'), __metadata('design:type', main_1.SelectionController) ], GroupStage.prototype, "selectionController", void 0); __decorate([ main_1.Autowired('gridOptionsWrapper'), __metadata('design:type', main_1.GridOptionsWrapper) ], GroupStage.prototype, "gridOptionsWrapper", void 0); __decorate([ main_1.Autowired('columnController'), __metadata('design:type', main_1.ColumnController) ], GroupStage.prototype, "columnController", void 0); __decorate([ main_1.Autowired('valueService'), __metadata('design:type', main_1.ValueService) ], GroupStage.prototype, "valueService", void 0); __decorate([ main_1.Autowired('eventService'), __metadata('design:type', main_1.EventService) ], GroupStage.prototype, "eventService", void 0); __decorate([ main_1.Autowired('context'), __metadata('design:type', main_1.Context) ], GroupStage.prototype, "context", void 0); GroupStage = __decorate([ main_1.Bean('groupStage'), __metadata('design:paramtypes', []) ], GroupStage); return GroupStage; })();
var LicenseManager = (function () { function LicenseManager() { } LicenseManager.prototype.validateLicense = function () { var gridReleaseDate = LicenseManager.getGridReleaseDate(); var valid = false; var current = false; console.log("validating license: " + LicenseManager.licenseKey); if (!main_2.Utils.missingOrEmpty(LicenseManager.licenseKey) && LicenseManager.licenseKey.length > 32) { var hashStart = LicenseManager.licenseKey.length - 32; var md5 = LicenseManager.licenseKey.substring(hashStart); var license = LicenseManager.licenseKey.substring(0, hashStart); if (md5 === this.md5.md5(license)) { var restrictionHashed = license.substring(license.lastIndexOf("_") + 1, license.length); var expiry = new Date(parseInt(LicenseManager.decode(restrictionHashed))); if (!isNaN(expiry.getTime())) { valid = true; current = (gridReleaseDate < expiry); } } } if (!valid) { LicenseManager.outputMessage("********************************************* Invalid License **************************************************", "* Your license for ag-Grid Enterprise is not valid - please contact ag-Grid support to obtain a valid license. *"); } else if (!current) { LicenseManager.outputMessage("********************* License not compatible with installed version of ag-Grid Enterprise. *********************", "Your license for ag-Grid Enterprise expired on " + LicenseManager.formatDate(expiry) + " but the version installed was released on " + LicenseManager.formatDate(gridReleaseDate) + ". Please " + "contact ag-Grid Support to renew your license"); } }; LicenseManager.outputMessage = function (header, message) { console.error("****************************************************************************************************************"); console.error("*************************************** ag-Grid Enterprise License *********************************************"); console.error(header); console.error(message); console.error("****************************************************************************************************************"); console.error("****************************************************************************************************************"); }; LicenseManager.formatDate = function (date) { var monthNames = [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ]; var day = date.getDate(); var monthIndex = date.getMonth(); var year = date.getFullYear(); return day + ' ' + monthNames[monthIndex] + ' ' + year; }; LicenseManager.getGridReleaseDate = function () { return new Date(parseInt(LicenseManager.decode(LicenseManager.RELEASE_INFORMATION))); }; ; LicenseManager.decode = function (input) { var keystr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; var t = ""; var n, r, i; var s, o, u, a; var f = 0; var e = input.replace(/[^A-Za-z0-9+/=]/g, ""); while (f < e.length) { s = keystr.indexOf(e.charAt(f++)); o = keystr.indexOf(e.charAt(f++)); u = keystr.indexOf(e.charAt(f++)); a = keystr.indexOf(e.charAt(f++)); n = s << 2 | o >> 4; r = (o & 15) << 4 | u >> 2; i = (u & 3) << 6 | a; t = t + String.fromCharCode(n); if (u != 64) { t = t + String.fromCharCode(r); } if (a != 64) { t = t + String.fromCharCode(i); } } t = LicenseManager.utf8_decode(t); return t; }; LicenseManager.utf8_decode = function (input) { input = input.replace(/rn/g, "n"); var t = ""; for (var n = 0; n < input.length; n++) { var r = input.charCodeAt(n); if (r < 128) { t += String.fromCharCode(r); } else if (r > 127 && r < 2048) { t += String.fromCharCode(r >> 6 | 192); t += String.fromCharCode(r & 63 | 128); } else { t += String.fromCharCode(r >> 12 | 224); t += String.fromCharCode(r >> 6 & 63 | 128); t += String.fromCharCode(r & 63 | 128); } } return t; }; LicenseManager.setLicenseKey = function (licenseKey) { LicenseManager.licenseKey = licenseKey; }; LicenseManager.RELEASE_INFORMATION = 'MTQ2NDM0OTI1NTM1MQ=='; __decorate([ main_1.Autowired('md5'), __metadata('design:type', md5_1.MD5) ], LicenseManager.prototype, "md5", void 0); LicenseManager = __decorate([ main_1.Bean('licenseManager'), __metadata('design:paramtypes', []) ], LicenseManager); return LicenseManager; })();
var GroupStage = (function () { function GroupStage() { } GroupStage.prototype.execute = function (rowNode) { var groupedCols = this.columnController.getRowGroupColumns(); var expandByDefault; if (this.gridOptionsWrapper.isGroupSuppressRow()) { expandByDefault = -1; } else { expandByDefault = this.gridOptionsWrapper.getGroupDefaultExpanded(); } // putting this in a wrapper, so it's pass by reference var groupId = { value: -1 }; this.recursivelyGroup(rowNode, groupedCols, 0, expandByDefault, groupId); }; GroupStage.prototype.recursivelyGroup = function (rowNode, groupColumns, level, expandByDefault, groupId) { var _this = this; var groupingThisLevel = level < groupColumns.length; rowNode.leafGroup = level === groupColumns.length; if (groupingThisLevel) { var groupColumn = groupColumns[level]; this.setChildrenAfterGroup(rowNode, groupColumn, groupId, expandByDefault, level); rowNode.childrenAfterGroup.forEach(function (child) { _this.recursivelyGroup(child, groupColumns, level + 1, expandByDefault, groupId); }); } else { rowNode.childrenAfterGroup = rowNode.allLeafChildren; rowNode.childrenAfterGroup.forEach(function (child) { child.level = level; child.parent = rowNode; }); } }; GroupStage.prototype.setChildrenAfterGroup = function (rowNode, groupColumn, groupId, expandByDefault, level) { var _this = this; rowNode.childrenAfterGroup = []; rowNode.childrenMapped = {}; rowNode.allLeafChildren.forEach(function (child) { var groupKey = _this.getKeyForNode(groupColumn, child); var groupForChild = rowNode.childrenMapped[groupKey]; if (!groupForChild) { groupForChild = _this.createGroup(groupColumn, groupKey, rowNode, groupId, expandByDefault, level); rowNode.childrenMapped[groupKey] = groupForChild; rowNode.childrenAfterGroup.push(groupForChild); } groupForChild.allLeafChildren.push(child); }); }; GroupStage.prototype.getKeyForNode = function (groupColumn, rowNode) { var value = this.valueService.getValue(groupColumn, rowNode); var result; var keyCreator = groupColumn.getColDef().keyCreator; if (keyCreator) { result = keyCreator({ value: value }); } else { result = value; } return result; }; GroupStage.prototype.createGroup = function (groupColumn, groupKey, parent, groupId, expandByDefault, level) { var nextGroup = new main_1.RowNode(); this.context.wireBean(nextGroup); nextGroup.group = true; nextGroup.field = groupColumn.getColDef().field; nextGroup.id = groupId.value--; nextGroup.key = groupKey; nextGroup.expanded = this.isExpanded(expandByDefault, level); nextGroup.allLeafChildren = []; nextGroup.allChildrenCount = 0; nextGroup.level = level; var includeParents = !this.gridOptionsWrapper.isSuppressParentsInRowNodes(); nextGroup.parent = includeParents ? parent : null; return nextGroup; }; GroupStage.prototype.isExpanded = function (expandByDefault, level) { if (expandByDefault === -1) { return true; } else { return level < expandByDefault; } }; __decorate([ main_1.Autowired('selectionController'), __metadata('design:type', main_1.SelectionController) ], GroupStage.prototype, "selectionController", void 0); __decorate([ main_1.Autowired('gridOptionsWrapper'), __metadata('design:type', main_1.GridOptionsWrapper) ], GroupStage.prototype, "gridOptionsWrapper", void 0); __decorate([ main_1.Autowired('columnController'), __metadata('design:type', main_1.ColumnController) ], GroupStage.prototype, "columnController", void 0); __decorate([ main_1.Autowired('valueService'), __metadata('design:type', main_1.ValueService) ], GroupStage.prototype, "valueService", void 0); __decorate([ main_1.Autowired('eventService'), __metadata('design:type', main_1.EventService) ], GroupStage.prototype, "eventService", void 0); __decorate([ main_1.Autowired('context'), __metadata('design:type', main_1.Context) ], GroupStage.prototype, "context", void 0); GroupStage = __decorate([ main_1.Bean('groupStage'), __metadata('design:paramtypes', []) ], GroupStage); return GroupStage; })();