1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 | "use strict";
|
8 | var __extends = (this && this.__extends) || (function () {
|
9 | var extendStatics = Object.setPrototypeOf ||
|
10 | ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
11 | function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
12 | return function (d, b) {
|
13 | extendStatics(d, b);
|
14 | function __() { this.constructor = d; }
|
15 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
16 | };
|
17 | })();
|
18 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
19 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
20 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
21 | 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;
|
22 | return c > 3 && r && Object.defineProperty(target, key, r), r;
|
23 | };
|
24 | var __metadata = (this && this.__metadata) || function (k, v) {
|
25 | if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
26 | };
|
27 | Object.defineProperty(exports, "__esModule", { value: true });
|
28 | var gridOptionsWrapper_1 = require("./gridOptionsWrapper");
|
29 | var columnApi_1 = require("./columnController/columnApi");
|
30 | var columnController_1 = require("./columnController/columnController");
|
31 | var rowRenderer_1 = require("./rendering/rowRenderer");
|
32 | var filterManager_1 = require("./filter/filterManager");
|
33 | var eventService_1 = require("./eventService");
|
34 | var gridPanel_1 = require("./gridPanel/gridPanel");
|
35 | var logger_1 = require("./logger");
|
36 | var popupService_1 = require("./widgets/popupService");
|
37 | var utils_1 = require("./utils");
|
38 | var context_1 = require("./context/context");
|
39 | var focusedCellController_1 = require("./focusedCellController");
|
40 | var component_1 = require("./widgets/component");
|
41 | var gridApi_1 = require("./gridApi");
|
42 | var componentAnnotations_1 = require("./widgets/componentAnnotations");
|
43 | var resizeObserver_1 = require("./resizeObserver");
|
44 | var events_1 = require("./events");
|
45 | var GridCore = (function (_super) {
|
46 | __extends(GridCore, _super);
|
47 | function GridCore() {
|
48 | return _super.call(this) || this;
|
49 | }
|
50 | GridCore_1 = GridCore;
|
51 | GridCore.prototype.init = function () {
|
52 | var _this = this;
|
53 | this.logger = this.loggerFactory.create('GridCore');
|
54 | var template = this.enterprise ? GridCore_1.TEMPLATE_ENTERPRISE : GridCore_1.TEMPLATE_NORMAL;
|
55 | this.setTemplate(template);
|
56 | this.instantiate(this.context);
|
57 | if (this.enterprise) {
|
58 | this.toolPanelComp.registerGridComp(this.gridPanel);
|
59 | this.statusBar.registerGridPanel(this.gridPanel);
|
60 | }
|
61 | this.gridOptionsWrapper.addLayoutElement(this.getGui());
|
62 |
|
63 | this.showToolPanel(this.gridOptionsWrapper.isShowToolPanel());
|
64 | this.eGridDiv.appendChild(this.getGui());
|
65 | this.addDestroyFunc(function () {
|
66 | _this.eGridDiv.removeChild(_this.getGui());
|
67 | });
|
68 |
|
69 | if (this.$scope) {
|
70 | var quickFilterUnregisterFn = this.$scope.$watch(this.quickFilterOnScope, function (newFilter) { return _this.filterManager.setQuickFilter(newFilter); });
|
71 | this.addDestroyFunc(quickFilterUnregisterFn);
|
72 | }
|
73 |
|
74 |
|
75 | this.addRtlSupport();
|
76 | this.finished = false;
|
77 | this.addDestroyFunc(function () { return _this.finished = true; });
|
78 | this.logger.log('ready');
|
79 | this.gridOptionsWrapper.addLayoutElement(this.eRootWrapperBody);
|
80 | var unsubscribeFromResize = resizeObserver_1.observeResize(this.eGridDiv, this.onGridSizeChanged.bind(this));
|
81 | this.addDestroyFunc(function () { return unsubscribeFromResize(); });
|
82 | };
|
83 | GridCore.prototype.onGridSizeChanged = function () {
|
84 | var event = {
|
85 | type: events_1.Events.EVENT_GRID_SIZE_CHANGED,
|
86 | api: this.gridApi,
|
87 | columnApi: this.columnApi,
|
88 | clientWidth: this.eGridDiv.clientWidth,
|
89 | clientHeight: this.eGridDiv.clientHeight
|
90 | };
|
91 | this.eventService.dispatchEvent(event);
|
92 | };
|
93 | GridCore.prototype.getPreferredWidth = function () {
|
94 | var widthForCols = this.columnController.getBodyContainerWidth()
|
95 | + this.columnController.getPinnedLeftContainerWidth()
|
96 | + this.columnController.getPinnedRightContainerWidth();
|
97 | var widthForToolpanel = this.toolPanelComp ? this.toolPanelComp.getPreferredWidth() : 0;
|
98 | return widthForCols + widthForToolpanel;
|
99 | };
|
100 | GridCore.prototype.addRtlSupport = function () {
|
101 | var cssClass = this.gridOptionsWrapper.isEnableRtl() ? 'ag-rtl' : 'ag-ltr';
|
102 | utils_1.Utils.addCssClass(this.getGui(), cssClass);
|
103 | };
|
104 | GridCore.prototype.getRootGui = function () {
|
105 | return this.getGui();
|
106 | };
|
107 | GridCore.prototype.showToolPanel = function (show) {
|
108 | if (!this.toolPanelComp) {
|
109 | if (show) {
|
110 | console.warn('ag-Grid: toolPanel is only available in ag-Grid Enterprise');
|
111 | }
|
112 | return;
|
113 | }
|
114 | this.toolPanelComp.showToolPanel(show);
|
115 | };
|
116 | GridCore.prototype.isToolPanelShowing = function () {
|
117 | return this.toolPanelComp.isToolPanelShowing();
|
118 | };
|
119 |
|
120 | GridCore.prototype.destroy = function () {
|
121 | _super.prototype.destroy.call(this);
|
122 | this.logger.log('Grid DOM removed');
|
123 | };
|
124 |
|
125 | GridCore.prototype.ensureNodeVisible = function (comparator, position) {
|
126 | if (position === void 0) { position = 'top'; }
|
127 | if (this.doingVirtualPaging) {
|
128 | throw 'Cannot use ensureNodeVisible when doing virtual paging, as we cannot check rows that are not in memory';
|
129 | }
|
130 |
|
131 | var rowCount = this.rowModel.getPageLastRow() + 1;
|
132 | var comparatorIsAFunction = typeof comparator === 'function';
|
133 | var indexToSelect = -1;
|
134 |
|
135 | for (var i = 0; i < rowCount; i++) {
|
136 | var node = this.rowModel.getRow(i);
|
137 | if (comparatorIsAFunction) {
|
138 | if (comparator(node)) {
|
139 | indexToSelect = i;
|
140 | break;
|
141 | }
|
142 | }
|
143 | else {
|
144 |
|
145 | if (comparator === node || comparator === node.data) {
|
146 | indexToSelect = i;
|
147 | break;
|
148 | }
|
149 | }
|
150 | }
|
151 | if (indexToSelect >= 0) {
|
152 | this.gridPanel.ensureIndexVisible(indexToSelect, position);
|
153 | }
|
154 | };
|
155 | GridCore.TEMPLATE_NORMAL = "<div class=\"ag-root-wrapper\">\n <div class=\"ag-root-wrapper-body\" ref=\"rootWrapperBody\">\n <ag-grid-comp ref=\"gridPanel\"></ag-grid-comp>\n </div>\n <ag-pagination></ag-pagination>\n </div>";
|
156 | GridCore.TEMPLATE_ENTERPRISE = "<div class=\"ag-root-wrapper\">\n <ag-header-column-drop></ag-header-column-drop>\n <div ref=\"rootWrapperBody\" class=\"ag-root-wrapper-body\">\n <ag-grid-comp ref=\"gridPanel\"></ag-grid-comp>\n <ag-tool-panel ref=\"toolPanel\"></ag-tool-panel>\n </div>\n <ag-status-bar ref=\"statusBar\"></ag-status-bar>\n <ag-pagination></ag-pagination>\n </div>";
|
157 | __decorate([
|
158 | context_1.Autowired('enterprise'),
|
159 | __metadata("design:type", Boolean)
|
160 | ], GridCore.prototype, "enterprise", void 0);
|
161 | __decorate([
|
162 | context_1.Autowired('gridOptions'),
|
163 | __metadata("design:type", Object)
|
164 | ], GridCore.prototype, "gridOptions", void 0);
|
165 | __decorate([
|
166 | context_1.Autowired('gridOptionsWrapper'),
|
167 | __metadata("design:type", gridOptionsWrapper_1.GridOptionsWrapper)
|
168 | ], GridCore.prototype, "gridOptionsWrapper", void 0);
|
169 | __decorate([
|
170 | context_1.Autowired('rowModel'),
|
171 | __metadata("design:type", Object)
|
172 | ], GridCore.prototype, "rowModel", void 0);
|
173 | __decorate([
|
174 | context_1.Autowired('frameworkFactory'),
|
175 | __metadata("design:type", Object)
|
176 | ], GridCore.prototype, "frameworkFactory", void 0);
|
177 | __decorate([
|
178 | context_1.Autowired('columnController'),
|
179 | __metadata("design:type", columnController_1.ColumnController)
|
180 | ], GridCore.prototype, "columnController", void 0);
|
181 | __decorate([
|
182 | context_1.Autowired('rowRenderer'),
|
183 | __metadata("design:type", rowRenderer_1.RowRenderer)
|
184 | ], GridCore.prototype, "rowRenderer", void 0);
|
185 | __decorate([
|
186 | context_1.Autowired('filterManager'),
|
187 | __metadata("design:type", filterManager_1.FilterManager)
|
188 | ], GridCore.prototype, "filterManager", void 0);
|
189 | __decorate([
|
190 | context_1.Autowired('eventService'),
|
191 | __metadata("design:type", eventService_1.EventService)
|
192 | ], GridCore.prototype, "eventService", void 0);
|
193 | __decorate([
|
194 | context_1.Autowired('eGridDiv'),
|
195 | __metadata("design:type", HTMLElement)
|
196 | ], GridCore.prototype, "eGridDiv", void 0);
|
197 | __decorate([
|
198 | context_1.Autowired('$scope'),
|
199 | __metadata("design:type", Object)
|
200 | ], GridCore.prototype, "$scope", void 0);
|
201 | __decorate([
|
202 | context_1.Autowired('quickFilterOnScope'),
|
203 | __metadata("design:type", String)
|
204 | ], GridCore.prototype, "quickFilterOnScope", void 0);
|
205 | __decorate([
|
206 | context_1.Autowired('popupService'),
|
207 | __metadata("design:type", popupService_1.PopupService)
|
208 | ], GridCore.prototype, "popupService", void 0);
|
209 | __decorate([
|
210 | context_1.Autowired('focusedCellController'),
|
211 | __metadata("design:type", focusedCellController_1.FocusedCellController)
|
212 | ], GridCore.prototype, "focusedCellController", void 0);
|
213 | __decorate([
|
214 | context_1.Autowired('context'),
|
215 | __metadata("design:type", context_1.Context)
|
216 | ], GridCore.prototype, "context", void 0);
|
217 | __decorate([
|
218 | context_1.Autowired('loggerFactory'),
|
219 | __metadata("design:type", logger_1.LoggerFactory)
|
220 | ], GridCore.prototype, "loggerFactory", void 0);
|
221 | __decorate([
|
222 | context_1.Autowired('columnApi'),
|
223 | __metadata("design:type", columnApi_1.ColumnApi)
|
224 | ], GridCore.prototype, "columnApi", void 0);
|
225 | __decorate([
|
226 | context_1.Autowired('gridApi'),
|
227 | __metadata("design:type", gridApi_1.GridApi)
|
228 | ], GridCore.prototype, "gridApi", void 0);
|
229 | __decorate([
|
230 | context_1.Optional('rowGroupCompFactory'),
|
231 | __metadata("design:type", Object)
|
232 | ], GridCore.prototype, "rowGroupCompFactory", void 0);
|
233 | __decorate([
|
234 | context_1.Optional('pivotCompFactory'),
|
235 | __metadata("design:type", Object)
|
236 | ], GridCore.prototype, "pivotCompFactory", void 0);
|
237 | __decorate([
|
238 | componentAnnotations_1.RefSelector('statusBar'),
|
239 | __metadata("design:type", Object)
|
240 | ], GridCore.prototype, "statusBar", void 0);
|
241 | __decorate([
|
242 | componentAnnotations_1.RefSelector('gridPanel'),
|
243 | __metadata("design:type", gridPanel_1.GridPanel)
|
244 | ], GridCore.prototype, "gridPanel", void 0);
|
245 | __decorate([
|
246 | componentAnnotations_1.RefSelector('toolPanel'),
|
247 | __metadata("design:type", Object)
|
248 | ], GridCore.prototype, "toolPanelComp", void 0);
|
249 | __decorate([
|
250 | componentAnnotations_1.RefSelector('rootWrapperBody'),
|
251 | __metadata("design:type", HTMLElement)
|
252 | ], GridCore.prototype, "eRootWrapperBody", void 0);
|
253 | __decorate([
|
254 | context_1.PostConstruct,
|
255 | __metadata("design:type", Function),
|
256 | __metadata("design:paramtypes", []),
|
257 | __metadata("design:returntype", void 0)
|
258 | ], GridCore.prototype, "init", null);
|
259 | __decorate([
|
260 | context_1.PreDestroy,
|
261 | __metadata("design:type", Function),
|
262 | __metadata("design:paramtypes", []),
|
263 | __metadata("design:returntype", void 0)
|
264 | ], GridCore.prototype, "destroy", null);
|
265 | GridCore = GridCore_1 = __decorate([
|
266 | context_1.Bean('gridCore'),
|
267 | __metadata("design:paramtypes", [])
|
268 | ], GridCore);
|
269 | return GridCore;
|
270 | var GridCore_1;
|
271 | }(component_1.Component));
|
272 | exports.GridCore = GridCore;
|