UNPKG

ag-grid-enterprise

Version:

ag-Grid Enterprise Features

156 lines (155 loc) 7.32 kB
// ag-grid-enterprise v19.1.4 "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); } return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; Object.defineProperty(exports, "__esModule", { value: true }); var main_1 = require("ag-grid-community/main"); var baseDropZonePanel_1 = require("../dropZone/baseDropZonePanel"); var PivotDropZonePanel = /** @class */ (function (_super) { __extends(PivotDropZonePanel, _super); function PivotDropZonePanel(horizontal) { return _super.call(this, horizontal, false, 'pivot') || this; } PivotDropZonePanel.prototype.passBeansUp = function () { _super.prototype.setBeans.call(this, { gridOptionsWrapper: this.gridOptionsWrapper, eventService: this.eventService, context: this.context, loggerFactory: this.loggerFactory, dragAndDropService: this.dragAndDropService }); var localeTextFunc = this.gridOptionsWrapper.getLocaleTextFunc(); var emptyMessage = localeTextFunc('pivotColumnsEmptyMessage', 'Drag here to set column labels'); var title = localeTextFunc('pivots', 'Column Labels'); _super.prototype.init.call(this, { dragAndDropIcon: main_1.DragAndDropService.ICON_GROUP, icon: main_1.Utils.createIconNoSpan('pivotPanel', this.gridOptionsWrapper, null), emptyMessage: emptyMessage, title: title }); this.addDestroyableEventListener(this.eventService, main_1.Events.EVENT_COLUMN_EVERYTHING_CHANGED, this.refresh.bind(this)); this.addDestroyableEventListener(this.eventService, main_1.Events.EVENT_COLUMN_PIVOT_CHANGED, this.refresh.bind(this)); this.addDestroyableEventListener(this.eventService, main_1.Events.EVENT_COLUMN_PIVOT_MODE_CHANGED, this.checkVisibility.bind(this)); this.refresh(); }; PivotDropZonePanel.prototype.refresh = function () { this.checkVisibility(); this.refreshGui(); }; PivotDropZonePanel.prototype.checkVisibility = function () { var pivotMode = this.columnController.isPivotMode(); if (this.isHorizontal()) { // what we do for horizontal (ie the pivot panel at the top) depends // on the user property as well as pivotMode. switch (this.gridOptionsWrapper.getPivotPanelShow()) { case 'always': this.setVisible(pivotMode); break; case 'onlyWhenPivoting': var pivotActive = this.columnController.isPivotActive(); this.setVisible(pivotMode && pivotActive); break; default: // never show it this.setVisible(false); break; } } else { // in toolPanel, the pivot panel is always shown when pivot mode is on this.setVisible(pivotMode); } }; PivotDropZonePanel.prototype.isColumnDroppable = function (column) { if (this.gridOptionsWrapper.isFunctionsReadOnly()) { return false; } // we never allow grouping of secondary columns if (!column.isPrimary()) { return false; } var allowPivot = column.isAllowPivot(); var columnNotAlreadyPivoted = !column.isPivotActive(); return allowPivot && columnNotAlreadyPivoted; }; PivotDropZonePanel.prototype.updateColumns = function (columns) { if (this.gridOptionsWrapper.isFunctionsPassive()) { var event_1 = { type: main_1.Events.EVENT_COLUMN_PIVOT_CHANGE_REQUEST, columns: columns, api: this.gridApi, columnApi: this.columnApi }; this.eventService.dispatchEvent(event_1); } else { this.columnController.setPivotColumns(columns, "toolPanelUi"); } }; PivotDropZonePanel.prototype.getIconName = function () { return this.isPotentialDndColumns() ? main_1.DragAndDropService.ICON_PIVOT : main_1.DragAndDropService.ICON_NOT_ALLOWED; }; PivotDropZonePanel.prototype.getExistingColumns = function () { return this.columnController.getPivotColumns(); }; __decorate([ main_1.Autowired('columnController'), __metadata("design:type", main_1.ColumnController) ], PivotDropZonePanel.prototype, "columnController", void 0); __decorate([ main_1.Autowired('eventService'), __metadata("design:type", main_1.EventService) ], PivotDropZonePanel.prototype, "eventService", void 0); __decorate([ main_1.Autowired('gridOptionsWrapper'), __metadata("design:type", main_1.GridOptionsWrapper) ], PivotDropZonePanel.prototype, "gridOptionsWrapper", void 0); __decorate([ main_1.Autowired('context'), __metadata("design:type", main_1.Context) ], PivotDropZonePanel.prototype, "context", void 0); __decorate([ main_1.Autowired('loggerFactory'), __metadata("design:type", main_1.LoggerFactory) ], PivotDropZonePanel.prototype, "loggerFactory", void 0); __decorate([ main_1.Autowired('dragAndDropService'), __metadata("design:type", main_1.DragAndDropService) ], PivotDropZonePanel.prototype, "dragAndDropService", void 0); __decorate([ main_1.Autowired('columnApi'), __metadata("design:type", main_1.ColumnApi) ], PivotDropZonePanel.prototype, "columnApi", void 0); __decorate([ main_1.Autowired('gridApi'), __metadata("design:type", main_1.GridApi) ], PivotDropZonePanel.prototype, "gridApi", void 0); __decorate([ main_1.PostConstruct, __metadata("design:type", Function), __metadata("design:paramtypes", []), __metadata("design:returntype", void 0) ], PivotDropZonePanel.prototype, "passBeansUp", null); return PivotDropZonePanel; }(baseDropZonePanel_1.BaseDropZonePanel)); exports.PivotDropZonePanel = PivotDropZonePanel;