angular-slickgrid 3.3.2 → 4.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/README.md +180 -188
  2. package/angular-slickgrid.d.ts +1 -3
  3. package/app/modules/angular-slickgrid/components/angular-slickgrid.component.d.ts +9 -6
  4. package/app/modules/angular-slickgrid/extensions/index.d.ts +1 -1
  5. package/app/modules/angular-slickgrid/extensions/{rowDetailViewExtension.d.ts → slickRowDetailView.d.ts} +40 -27
  6. package/app/modules/angular-slickgrid/index.d.ts +1 -1
  7. package/app/modules/angular-slickgrid/models/angularGridInstance.interface.d.ts +1 -1
  8. package/app/modules/angular-slickgrid/modules/angular-slickgrid.module.d.ts +7 -0
  9. package/app/modules/angular-slickgrid/services/angularUtil.service.d.ts +3 -0
  10. package/app/modules/angular-slickgrid/services/bsDropdown.service.d.ts +3 -0
  11. package/app/modules/angular-slickgrid/services/container.service.d.ts +3 -0
  12. package/app/modules/angular-slickgrid/services/translater.service.d.ts +3 -0
  13. package/docs/assets/lib/multiple-select/README.md +17 -0
  14. package/esm2020/angular-slickgrid.mjs +5 -0
  15. package/esm2020/app/modules/angular-slickgrid/components/angular-slickgrid.component.mjs +1168 -0
  16. package/{esm2015/app/modules/angular-slickgrid/constants.js → esm2020/app/modules/angular-slickgrid/constants.mjs} +0 -0
  17. package/{esm2015/app/modules/angular-slickgrid/extensions/index.js → esm2020/app/modules/angular-slickgrid/extensions/index.mjs} +2 -2
  18. package/esm2020/app/modules/angular-slickgrid/extensions/slickRowDetailView.mjs +300 -0
  19. package/esm2020/app/modules/angular-slickgrid/global-grid-options.mjs +243 -0
  20. package/{esm2015/app/modules/angular-slickgrid/index.js → esm2020/app/modules/angular-slickgrid/index.mjs} +2 -2
  21. package/{esm2015/app/modules/angular-slickgrid/models/angularComponentOutput.interface.js → esm2020/app/modules/angular-slickgrid/models/angularComponentOutput.interface.mjs} +0 -0
  22. package/esm2020/app/modules/angular-slickgrid/models/angularGridInstance.interface.mjs +2 -0
  23. package/{esm2015/app/modules/angular-slickgrid/models/externalTestingDependencies.interface.js → esm2020/app/modules/angular-slickgrid/models/externalTestingDependencies.interface.mjs} +0 -0
  24. package/{esm2015/app/modules/angular-slickgrid/models/gridOption.interface.js → esm2020/app/modules/angular-slickgrid/models/gridOption.interface.mjs} +0 -0
  25. package/{esm2015/app/modules/angular-slickgrid/models/index.js → esm2020/app/modules/angular-slickgrid/models/index.mjs} +0 -0
  26. package/{esm2015/app/modules/angular-slickgrid/models/rowDetailView.interface.js → esm2020/app/modules/angular-slickgrid/models/rowDetailView.interface.mjs} +0 -0
  27. package/{esm2015/app/modules/angular-slickgrid/models/slickGrid.interface.js → esm2020/app/modules/angular-slickgrid/models/slickGrid.interface.mjs} +0 -0
  28. package/esm2020/app/modules/angular-slickgrid/modules/angular-slickgrid.module.mjs +46 -0
  29. package/esm2020/app/modules/angular-slickgrid/services/angularUtil.service.mjs +46 -0
  30. package/esm2020/app/modules/angular-slickgrid/services/bsDropdown.service.mjs +103 -0
  31. package/esm2020/app/modules/angular-slickgrid/services/container.service.mjs +26 -0
  32. package/{esm2015/app/modules/angular-slickgrid/services/index.js → esm2020/app/modules/angular-slickgrid/services/index.mjs} +0 -0
  33. package/esm2020/app/modules/angular-slickgrid/services/translater.service.mjs +43 -0
  34. package/{esm2015/app/modules/angular-slickgrid/services/utilities.js → esm2020/app/modules/angular-slickgrid/services/utilities.mjs} +0 -0
  35. package/{esm2015/app/modules/angular-slickgrid/slickgrid-config.js → esm2020/app/modules/angular-slickgrid/slickgrid-config.mjs} +0 -0
  36. package/{esm2015/public_api.js → esm2020/public_api.mjs} +0 -0
  37. package/fesm2015/{angular-slickgrid.js → angular-slickgrid.mjs} +252 -282
  38. package/fesm2015/angular-slickgrid.mjs.map +1 -0
  39. package/fesm2020/angular-slickgrid.mjs +2066 -0
  40. package/fesm2020/angular-slickgrid.mjs.map +1 -0
  41. package/package.json +38 -23
  42. package/angular-slickgrid.metadata.json +0 -1
  43. package/bundles/angular-slickgrid.umd.js +0 -2642
  44. package/bundles/angular-slickgrid.umd.js.map +0 -1
  45. package/esm2015/angular-slickgrid.js +0 -7
  46. package/esm2015/app/modules/angular-slickgrid/components/angular-slickgrid.component.js +0 -1202
  47. package/esm2015/app/modules/angular-slickgrid/extensions/rowDetailViewExtension.js +0 -342
  48. package/esm2015/app/modules/angular-slickgrid/global-grid-options.js +0 -243
  49. package/esm2015/app/modules/angular-slickgrid/models/angularGridInstance.interface.js +0 -2
  50. package/esm2015/app/modules/angular-slickgrid/modules/angular-slickgrid.module.js +0 -37
  51. package/esm2015/app/modules/angular-slickgrid/services/angularUtil.service.js +0 -48
  52. package/esm2015/app/modules/angular-slickgrid/services/bsDropdown.service.js +0 -103
  53. package/esm2015/app/modules/angular-slickgrid/services/container.service.js +0 -24
  54. package/esm2015/app/modules/angular-slickgrid/services/translater.service.js +0 -47
  55. package/fesm2015/angular-slickgrid.js.map +0 -1
@@ -1,2642 +0,0 @@
1
- (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@slickgrid-universal/common'), require('@angular/core'), require('@ngx-translate/core'), require('slickgrid/plugins/slick.rowdetailview'), require('slickgrid/plugins/slick.rowselectionmodel'), require('@slickgrid-universal/event-pub-sub'), require('rxjs'), require('dompurify'), require('jquery-ui/ui/widgets/draggable'), require('jquery-ui/ui/widgets/droppable'), require('jquery-ui/ui/widgets/sortable'), require('slickgrid/lib/jquery.event.drag-2.3.0'), require('slickgrid/lib/jquery.mousewheel'), require('slickgrid/slick.core'), require('slickgrid/slick.grid'), require('slickgrid/slick.dataview'), require('slickgrid/slick.groupitemmetadataprovider'), require('@slickgrid-universal/empty-warning-component'), require('@slickgrid-universal/custom-footer-component'), require('@slickgrid-universal/pagination-component'), require('@slickgrid-universal/rxjs-observable'), require('dequal/lite'), require('@angular/common')) :
3
- typeof define === 'function' && define.amd ? define('angular-slickgrid', ['exports', '@slickgrid-universal/common', '@angular/core', '@ngx-translate/core', 'slickgrid/plugins/slick.rowdetailview', 'slickgrid/plugins/slick.rowselectionmodel', '@slickgrid-universal/event-pub-sub', 'rxjs', 'dompurify', 'jquery-ui/ui/widgets/draggable', 'jquery-ui/ui/widgets/droppable', 'jquery-ui/ui/widgets/sortable', 'slickgrid/lib/jquery.event.drag-2.3.0', 'slickgrid/lib/jquery.mousewheel', 'slickgrid/slick.core', 'slickgrid/slick.grid', 'slickgrid/slick.dataview', 'slickgrid/slick.groupitemmetadataprovider', '@slickgrid-universal/empty-warning-component', '@slickgrid-universal/custom-footer-component', '@slickgrid-universal/pagination-component', '@slickgrid-universal/rxjs-observable', 'dequal/lite', '@angular/common'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global['angular-slickgrid'] = {}, global.common, global.ng.core, global['ngx-translate-core'], null, null, global.eventPubSub, global.rxjs, global.dompurify, null, null, null, null, null, null, null, null, null, global.emptyWarningComponent, global.customFooterComponent, global.paginationComponent, global.rxjsObservable, global.lite, global.ng.common));
5
- }(this, (function (exports, common, core, core$1, slick_rowdetailview, slick_rowselectionmodel, eventPubSub, rxjs, DOMPurify_, draggable, droppable, sortable, jquery_event_drag2_3_0, jquery_mousewheel, slick_core, slick_grid, slick_dataview, slick_groupitemmetadataprovider, emptyWarningComponent, customFooterComponent, paginationComponent, rxjsObservable, lite, common$1) { 'use strict';
6
-
7
- function _interopNamespace(e) {
8
- if (e && e.__esModule) return e;
9
- var n = Object.create(null);
10
- if (e) {
11
- Object.keys(e).forEach(function (k) {
12
- if (k !== 'default') {
13
- var d = Object.getOwnPropertyDescriptor(e, k);
14
- Object.defineProperty(n, k, d.get ? d : {
15
- enumerable: true,
16
- get: function () {
17
- return e[k];
18
- }
19
- });
20
- }
21
- });
22
- }
23
- n['default'] = e;
24
- return Object.freeze(n);
25
- }
26
-
27
- var DOMPurify___namespace = /*#__PURE__*/_interopNamespace(DOMPurify_);
28
-
29
- var AngularUtilService = /** @class */ (function () {
30
- function AngularUtilService(compFactoryResolver, appRef, injector) {
31
- this.compFactoryResolver = compFactoryResolver;
32
- this.appRef = appRef;
33
- this.injector = injector;
34
- }
35
- // ref https://hackernoon.com/angular-pro-tip-how-to-dynamically-create-components-in-body-ba200cc289e6
36
- AngularUtilService.prototype.createAngularComponent = function (component) {
37
- // Create a component reference from the component
38
- var componentRef = this.compFactoryResolver
39
- .resolveComponentFactory(component)
40
- .create(this.injector);
41
- // Attach component to the appRef so that it's inside the ng component tree
42
- this.appRef.attachView(componentRef.hostView);
43
- // Get DOM element from component
44
- var domElem;
45
- var viewRef = componentRef.hostView;
46
- if (viewRef && Array.isArray(viewRef.rootNodes) && viewRef.rootNodes[0]) {
47
- domElem = viewRef.rootNodes[0];
48
- }
49
- return { componentRef: componentRef, domElement: domElem };
50
- };
51
- // ref https://hackernoon.com/angular-pro-tip-how-to-dynamically-create-components-in-body-ba200cc289e6
52
- AngularUtilService.prototype.createAngularComponentAppendToDom = function (component, targetElement, clearTargetContent) {
53
- if (clearTargetContent === void 0) { clearTargetContent = false; }
54
- var componentOutput = this.createAngularComponent(component);
55
- // Append DOM element to the HTML element specified
56
- if (targetElement && targetElement.appendChild) {
57
- if (clearTargetContent && targetElement.innerHTML) {
58
- targetElement.innerHTML = '';
59
- }
60
- targetElement.appendChild(componentOutput.domElement);
61
- }
62
- else {
63
- document.body.appendChild(componentOutput.domElement); // when no target provided, we'll simply add it to the HTML Body
64
- }
65
- return componentOutput;
66
- };
67
- return AngularUtilService;
68
- }());
69
- AngularUtilService.decorators = [
70
- { type: core.Injectable }
71
- ];
72
- AngularUtilService.ctorParameters = function () { return [
73
- { type: core.ComponentFactoryResolver },
74
- { type: core.ApplicationRef },
75
- { type: core.Injector }
76
- ]; };
77
-
78
- // Boostrap dropdown service
79
- var BsDropDownService = /** @class */ (function () {
80
- function BsDropDownService(angularUtilService) {
81
- this.angularUtilService = angularUtilService;
82
- }
83
- Object.defineProperty(BsDropDownService.prototype, "domElement", {
84
- get: function () {
85
- return this._domElement;
86
- },
87
- enumerable: false,
88
- configurable: true
89
- });
90
- Object.defineProperty(BsDropDownService.prototype, "domContainerElement", {
91
- get: function () {
92
- return this._domContainerElement;
93
- },
94
- enumerable: false,
95
- configurable: true
96
- });
97
- Object.defineProperty(BsDropDownService.prototype, "gridViewport", {
98
- get: function () {
99
- return $('.slick-viewport');
100
- },
101
- enumerable: false,
102
- configurable: true
103
- });
104
- BsDropDownService.prototype.dispose = function () {
105
- if (this._domElement && this._domElement.remove) {
106
- this._domElement.remove();
107
- }
108
- };
109
- BsDropDownService.prototype.dropContainerShow = function () {
110
- if (this._domContainerElement && this._domContainerElement.show) {
111
- this._domContainerElement.show();
112
- }
113
- };
114
- BsDropDownService.prototype.render = function (dropdownParams) {
115
- var _this = this;
116
- return new Promise(function (resolve) {
117
- var component = dropdownParams.component, args = dropdownParams.args, parent = dropdownParams.parent, offsetTop = dropdownParams.offsetTop, offsetLeft = dropdownParams.offsetLeft, offsetDropupBottom = dropdownParams.offsetDropupBottom;
118
- var cell = args.cell;
119
- var row = args.row;
120
- _this._domContainerElement = $("#myDrop-r" + row + "-c" + cell);
121
- if (_this._domContainerElement) {
122
- // hide the dropdown we created as a formatter Component, we'll redisplay it later
123
- var cellPos_1 = _this._domContainerElement.offset();
124
- var componentOutput_1 = _this.angularUtilService.createAngularComponent(component);
125
- var componentInstance = componentOutput_1 && componentOutput_1.componentRef && componentOutput_1.componentRef.instance;
126
- if (componentInstance) {
127
- var myDropId_1 = componentInstance.dropdownId || 'myDrop';
128
- var dropDownToggleId_1 = componentInstance.dropDownToggleId || 'dropdownMenu1';
129
- _this._domElement = $("#" + myDropId_1);
130
- if (_this._domElement) {
131
- // make sure to remove any previous Action dropdown elements, to avoid having multiple element of the same on top of each other
132
- _this.dispose();
133
- // assign the row data to the dropdown component instance
134
- Object.assign(componentInstance, { parent: parent, row: args.row, dataContext: args.grid.getDataItem(args.row) });
135
- // use a delay to make sure Angular ran at least a full cycle and make sure it finished rendering the Component before using it
136
- setTimeout(function () {
137
- // create a new dropdown element
138
- _this._domElement = $(componentOutput_1.domElement);
139
- var topPos = (cellPos_1 && cellPos_1.top || 0) + 30 + (offsetTop || 0);
140
- var leftPos = (cellPos_1 && cellPos_1.left || 0) + (offsetLeft || 0);
141
- _this._domElement.appendTo('body');
142
- _this._domElement.css('position', 'absolute');
143
- _this._domElement.css('top', topPos);
144
- _this._domElement.css('left', leftPos);
145
- $("#" + myDropId_1).addClass('open');
146
- $("#" + dropDownToggleId_1).hide();
147
- // check if it should drop Up or Down
148
- var offset = 35;
149
- var iElement = $('.dropdown-menu');
150
- var iElementWrapper = iElement.parent();
151
- var iElementWrapperOffset = iElementWrapper.offset() || {};
152
- var iElementWrapperOffsetTop = iElementWrapperOffset.top || iElementWrapper && iElementWrapper.length > 0 && iElementWrapper[0].offsetTop;
153
- var iElementHeight = iElement.height();
154
- var windowHeight = window.innerHeight;
155
- var shouldDropUp = (windowHeight - iElementHeight - offset) < iElementWrapperOffsetTop;
156
- var menuMarginTop = '0px';
157
- if (shouldDropUp) {
158
- var offsetBottom = offsetDropupBottom || 0;
159
- menuMarginTop = '-'.concat("" + (iElementHeight + offset + offsetBottom + 5), 'px');
160
- }
161
- _this._domElement.css({ 'margin-top': menuMarginTop });
162
- // set dropdown margin left according to the document width
163
- var parentOffset = iElementWrapperOffset.left;
164
- var leftMargin = parentOffset - $(document).width();
165
- _this._domElement.css({ 'margin-left': (_this._domElement.width() + leftMargin + 60) + 'px' });
166
- try {
167
- _this._domElement.dropdown('show'); // required for Bootstrap 4 only
168
- }
169
- catch (e) {
170
- // Bootstrap 3 wil throw an error since that method doesn't exist, we can safely disregard it
171
- }
172
- _this._domElement.on('hidden.bs.dropdown', function () { return _this.dropContainerShow(); });
173
- // hide dropdown menu on grid scroll
174
- _this.gridViewport.on('scroll', function () { return _this.dispose(); });
175
- // hide on dropdown click
176
- _this._domElement.on('click', function () { return _this.dispose(); });
177
- resolve(true);
178
- });
179
- }
180
- }
181
- }
182
- });
183
- };
184
- return BsDropDownService;
185
- }());
186
- BsDropDownService.decorators = [
187
- { type: core.Injectable }
188
- ];
189
- BsDropDownService.ctorParameters = function () { return [
190
- { type: AngularUtilService }
191
- ]; };
192
-
193
- var ContainerService = /** @class */ (function () {
194
- function ContainerService() {
195
- this.dependencies = [];
196
- }
197
- ContainerService.prototype.get = function (key) {
198
- var dependency = this.dependencies.find(function (dep) { return dep.key === key; });
199
- if (dependency === null || dependency === void 0 ? void 0 : dependency.instance) {
200
- return dependency.instance;
201
- }
202
- return null;
203
- };
204
- ContainerService.prototype.registerInstance = function (key, instance) {
205
- var dependency = this.dependencies.some(function (dep) { return dep.key === key; });
206
- if (!dependency) {
207
- this.dependencies.push({ key: key, instance: instance });
208
- }
209
- };
210
- return ContainerService;
211
- }());
212
- ContainerService.decorators = [
213
- { type: core.Injectable }
214
- ];
215
- ContainerService.ctorParameters = function () { return []; };
216
-
217
- /*! *****************************************************************************
218
- Copyright (c) Microsoft Corporation.
219
-
220
- Permission to use, copy, modify, and/or distribute this software for any
221
- purpose with or without fee is hereby granted.
222
-
223
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
224
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
225
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
226
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
227
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
228
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
229
- PERFORMANCE OF THIS SOFTWARE.
230
- ***************************************************************************** */
231
- /* global Reflect, Promise */
232
- var extendStatics = function (d, b) {
233
- extendStatics = Object.setPrototypeOf ||
234
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
235
- function (d, b) { for (var p in b)
236
- if (Object.prototype.hasOwnProperty.call(b, p))
237
- d[p] = b[p]; };
238
- return extendStatics(d, b);
239
- };
240
- function __extends(d, b) {
241
- if (typeof b !== "function" && b !== null)
242
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
243
- extendStatics(d, b);
244
- function __() { this.constructor = d; }
245
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
246
- }
247
- var __assign = function () {
248
- __assign = Object.assign || function __assign(t) {
249
- for (var s, i = 1, n = arguments.length; i < n; i++) {
250
- s = arguments[i];
251
- for (var p in s)
252
- if (Object.prototype.hasOwnProperty.call(s, p))
253
- t[p] = s[p];
254
- }
255
- return t;
256
- };
257
- return __assign.apply(this, arguments);
258
- };
259
- function __rest(s, e) {
260
- var t = {};
261
- for (var p in s)
262
- if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
263
- t[p] = s[p];
264
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
265
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
266
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
267
- t[p[i]] = s[p[i]];
268
- }
269
- return t;
270
- }
271
- function __decorate(decorators, target, key, desc) {
272
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
273
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
274
- r = Reflect.decorate(decorators, target, key, desc);
275
- else
276
- for (var i = decorators.length - 1; i >= 0; i--)
277
- if (d = decorators[i])
278
- r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
279
- return c > 3 && r && Object.defineProperty(target, key, r), r;
280
- }
281
- function __param(paramIndex, decorator) {
282
- return function (target, key) { decorator(target, key, paramIndex); };
283
- }
284
- function __metadata(metadataKey, metadataValue) {
285
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
286
- return Reflect.metadata(metadataKey, metadataValue);
287
- }
288
- function __awaiter(thisArg, _arguments, P, generator) {
289
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
290
- return new (P || (P = Promise))(function (resolve, reject) {
291
- function fulfilled(value) { try {
292
- step(generator.next(value));
293
- }
294
- catch (e) {
295
- reject(e);
296
- } }
297
- function rejected(value) { try {
298
- step(generator["throw"](value));
299
- }
300
- catch (e) {
301
- reject(e);
302
- } }
303
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
304
- step((generator = generator.apply(thisArg, _arguments || [])).next());
305
- });
306
- }
307
- function __generator(thisArg, body) {
308
- var _ = { label: 0, sent: function () { if (t[0] & 1)
309
- throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
310
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
311
- function verb(n) { return function (v) { return step([n, v]); }; }
312
- function step(op) {
313
- if (f)
314
- throw new TypeError("Generator is already executing.");
315
- while (_)
316
- try {
317
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
318
- return t;
319
- if (y = 0, t)
320
- op = [op[0] & 2, t.value];
321
- switch (op[0]) {
322
- case 0:
323
- case 1:
324
- t = op;
325
- break;
326
- case 4:
327
- _.label++;
328
- return { value: op[1], done: false };
329
- case 5:
330
- _.label++;
331
- y = op[1];
332
- op = [0];
333
- continue;
334
- case 7:
335
- op = _.ops.pop();
336
- _.trys.pop();
337
- continue;
338
- default:
339
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
340
- _ = 0;
341
- continue;
342
- }
343
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
344
- _.label = op[1];
345
- break;
346
- }
347
- if (op[0] === 6 && _.label < t[1]) {
348
- _.label = t[1];
349
- t = op;
350
- break;
351
- }
352
- if (t && _.label < t[2]) {
353
- _.label = t[2];
354
- _.ops.push(op);
355
- break;
356
- }
357
- if (t[2])
358
- _.ops.pop();
359
- _.trys.pop();
360
- continue;
361
- }
362
- op = body.call(thisArg, _);
363
- }
364
- catch (e) {
365
- op = [6, e];
366
- y = 0;
367
- }
368
- finally {
369
- f = t = 0;
370
- }
371
- if (op[0] & 5)
372
- throw op[1];
373
- return { value: op[0] ? op[1] : void 0, done: true };
374
- }
375
- }
376
- var __createBinding = Object.create ? (function (o, m, k, k2) {
377
- if (k2 === undefined)
378
- k2 = k;
379
- Object.defineProperty(o, k2, { enumerable: true, get: function () { return m[k]; } });
380
- }) : (function (o, m, k, k2) {
381
- if (k2 === undefined)
382
- k2 = k;
383
- o[k2] = m[k];
384
- });
385
- function __exportStar(m, o) {
386
- for (var p in m)
387
- if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p))
388
- __createBinding(o, m, p);
389
- }
390
- function __values(o) {
391
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
392
- if (m)
393
- return m.call(o);
394
- if (o && typeof o.length === "number")
395
- return {
396
- next: function () {
397
- if (o && i >= o.length)
398
- o = void 0;
399
- return { value: o && o[i++], done: !o };
400
- }
401
- };
402
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
403
- }
404
- function __read(o, n) {
405
- var m = typeof Symbol === "function" && o[Symbol.iterator];
406
- if (!m)
407
- return o;
408
- var i = m.call(o), r, ar = [], e;
409
- try {
410
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
411
- ar.push(r.value);
412
- }
413
- catch (error) {
414
- e = { error: error };
415
- }
416
- finally {
417
- try {
418
- if (r && !r.done && (m = i["return"]))
419
- m.call(i);
420
- }
421
- finally {
422
- if (e)
423
- throw e.error;
424
- }
425
- }
426
- return ar;
427
- }
428
- /** @deprecated */
429
- function __spread() {
430
- for (var ar = [], i = 0; i < arguments.length; i++)
431
- ar = ar.concat(__read(arguments[i]));
432
- return ar;
433
- }
434
- /** @deprecated */
435
- function __spreadArrays() {
436
- for (var s = 0, i = 0, il = arguments.length; i < il; i++)
437
- s += arguments[i].length;
438
- for (var r = Array(s), k = 0, i = 0; i < il; i++)
439
- for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
440
- r[k] = a[j];
441
- return r;
442
- }
443
- function __spreadArray(to, from, pack) {
444
- if (pack || arguments.length === 2)
445
- for (var i = 0, l = from.length, ar; i < l; i++) {
446
- if (ar || !(i in from)) {
447
- if (!ar)
448
- ar = Array.prototype.slice.call(from, 0, i);
449
- ar[i] = from[i];
450
- }
451
- }
452
- return to.concat(ar || Array.prototype.slice.call(from));
453
- }
454
- function __await(v) {
455
- return this instanceof __await ? (this.v = v, this) : new __await(v);
456
- }
457
- function __asyncGenerator(thisArg, _arguments, generator) {
458
- if (!Symbol.asyncIterator)
459
- throw new TypeError("Symbol.asyncIterator is not defined.");
460
- var g = generator.apply(thisArg, _arguments || []), i, q = [];
461
- return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
462
- function verb(n) { if (g[n])
463
- i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
464
- function resume(n, v) { try {
465
- step(g[n](v));
466
- }
467
- catch (e) {
468
- settle(q[0][3], e);
469
- } }
470
- function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
471
- function fulfill(value) { resume("next", value); }
472
- function reject(value) { resume("throw", value); }
473
- function settle(f, v) { if (f(v), q.shift(), q.length)
474
- resume(q[0][0], q[0][1]); }
475
- }
476
- function __asyncDelegator(o) {
477
- var i, p;
478
- return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
479
- function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
480
- }
481
- function __asyncValues(o) {
482
- if (!Symbol.asyncIterator)
483
- throw new TypeError("Symbol.asyncIterator is not defined.");
484
- var m = o[Symbol.asyncIterator], i;
485
- return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
486
- function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
487
- function settle(resolve, reject, d, v) { Promise.resolve(v).then(function (v) { resolve({ value: v, done: d }); }, reject); }
488
- }
489
- function __makeTemplateObject(cooked, raw) {
490
- if (Object.defineProperty) {
491
- Object.defineProperty(cooked, "raw", { value: raw });
492
- }
493
- else {
494
- cooked.raw = raw;
495
- }
496
- return cooked;
497
- }
498
- ;
499
- var __setModuleDefault = Object.create ? (function (o, v) {
500
- Object.defineProperty(o, "default", { enumerable: true, value: v });
501
- }) : function (o, v) {
502
- o["default"] = v;
503
- };
504
- function __importStar(mod) {
505
- if (mod && mod.__esModule)
506
- return mod;
507
- var result = {};
508
- if (mod != null)
509
- for (var k in mod)
510
- if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
511
- __createBinding(result, mod, k);
512
- __setModuleDefault(result, mod);
513
- return result;
514
- }
515
- function __importDefault(mod) {
516
- return (mod && mod.__esModule) ? mod : { default: mod };
517
- }
518
- function __classPrivateFieldGet(receiver, state, kind, f) {
519
- if (kind === "a" && !f)
520
- throw new TypeError("Private accessor was defined without a getter");
521
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
522
- throw new TypeError("Cannot read private member from an object whose class did not declare it");
523
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
524
- }
525
- function __classPrivateFieldSet(receiver, state, value, kind, f) {
526
- if (kind === "m")
527
- throw new TypeError("Private method is not writable");
528
- if (kind === "a" && !f)
529
- throw new TypeError("Private accessor was defined without a setter");
530
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
531
- throw new TypeError("Cannot write private member to an object whose class did not declare it");
532
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
533
- }
534
-
535
- /**
536
- * This is a Translate Service Wrapper for Slickgrid-Universal monorepo lib to work properly,
537
- * it must implement Slickgrid-Universal TranslaterService interface to work properly
538
- */
539
- var TranslaterService = /** @class */ (function () {
540
- function TranslaterService(translateService) {
541
- this.translateService = translateService;
542
- }
543
- /**
544
- * Method to return the current language used by the App
545
- * @return {string} current language
546
- */
547
- TranslaterService.prototype.getCurrentLanguage = function () {
548
- var _a, _b;
549
- return (_b = (_a = this.translateService) === null || _a === void 0 ? void 0 : _a.currentLang) !== null && _b !== void 0 ? _b : '';
550
- };
551
- /**
552
- * Method to set the language to use in the App and Translate Service
553
- * @param {string} language
554
- * @return {Promise} output
555
- */
556
- TranslaterService.prototype.use = function (newLang) {
557
- var _a, _b;
558
- return __awaiter(this, void 0, void 0, function () {
559
- return __generator(this, function (_c) {
560
- return [2 /*return*/, (_b = (_a = this.translateService) === null || _a === void 0 ? void 0 : _a.use) === null || _b === void 0 ? void 0 : _b.call(_a, newLang)];
561
- });
562
- });
563
- };
564
- /**
565
- * Method which receives a translation key and returns the translated value assigned to that key
566
- * @param {string} translation key
567
- * @return {string} translated value
568
- */
569
- TranslaterService.prototype.translate = function (translationKey) {
570
- var _a, _b;
571
- return (_b = (_a = this.translateService) === null || _a === void 0 ? void 0 : _a.instant) === null || _b === void 0 ? void 0 : _b.call(_a, translationKey || ' ');
572
- };
573
- return TranslaterService;
574
- }());
575
- TranslaterService.decorators = [
576
- { type: core.Injectable }
577
- ];
578
- TranslaterService.ctorParameters = function () { return [
579
- { type: core$1.TranslateService, decorators: [{ type: core.Optional }] }
580
- ]; };
581
-
582
- /**
583
- * Unsubscribe all Observables Subscriptions
584
- * It will return an empty array if it all went well
585
- * @param subscriptions
586
- */
587
- function unsubscribeAllObservables(subscriptions) {
588
- if (Array.isArray(subscriptions)) {
589
- subscriptions.forEach(function (subscription) {
590
- if (subscription && subscription.unsubscribe) {
591
- subscription.unsubscribe();
592
- }
593
- });
594
- subscriptions = [];
595
- }
596
- return subscriptions;
597
- }
598
-
599
- var DOMPurify = DOMPurify___namespace['default'] || DOMPurify___namespace; // patch to fix rollup to work
600
- var ROW_DETAIL_CONTAINER_PREFIX = 'container_';
601
- var PRELOAD_CONTAINER_PREFIX = 'container_loading';
602
- var RowDetailViewExtension = /** @class */ (function () {
603
- function RowDetailViewExtension(angularUtilService, appRef, eventPubSubService, sharedService, rxjs) {
604
- this.angularUtilService = angularUtilService;
605
- this.appRef = appRef;
606
- this.eventPubSubService = eventPubSubService;
607
- this.sharedService = sharedService;
608
- this.rxjs = rxjs;
609
- this._views = [];
610
- this._subscriptions = [];
611
- this._eventHandler = new Slick.EventHandler();
612
- }
613
- Object.defineProperty(RowDetailViewExtension.prototype, "datasetIdPropName", {
614
- get: function () {
615
- return this.gridOptions.datasetIdPropertyName || 'id';
616
- },
617
- enumerable: false,
618
- configurable: true
619
- });
620
- Object.defineProperty(RowDetailViewExtension.prototype, "eventHandler", {
621
- get: function () {
622
- return this._eventHandler;
623
- },
624
- enumerable: false,
625
- configurable: true
626
- });
627
- Object.defineProperty(RowDetailViewExtension.prototype, "gridOptions", {
628
- get: function () {
629
- var _a, _b;
630
- return ((_b = (_a = this.sharedService) === null || _a === void 0 ? void 0 : _a.gridOptions) !== null && _b !== void 0 ? _b : {});
631
- },
632
- enumerable: false,
633
- configurable: true
634
- });
635
- Object.defineProperty(RowDetailViewExtension.prototype, "rowDetailViewOptions", {
636
- get: function () {
637
- return this.gridOptions.rowDetailView;
638
- },
639
- enumerable: false,
640
- configurable: true
641
- });
642
- RowDetailViewExtension.prototype.addRxJsResource = function (rxjs) {
643
- this.rxjs = rxjs;
644
- };
645
- /** Dispose of the RowDetailView Extension */
646
- RowDetailViewExtension.prototype.dispose = function () {
647
- // unsubscribe all SlickGrid events
648
- this._eventHandler.unsubscribeAll();
649
- if (this._addon && this._addon.destroy) {
650
- this._addon.destroy();
651
- }
652
- this._addonOptions = null;
653
- // also unsubscribe all RxJS subscriptions
654
- this._subscriptions = unsubscribeAllObservables(this._subscriptions);
655
- this.disposeAllViewComponents();
656
- };
657
- /** Dispose of all the opened Row Detail Panels Angular View Components */
658
- RowDetailViewExtension.prototype.disposeAllViewComponents = function () {
659
- var _this = this;
660
- this._views.forEach(function (compRef) { return _this.disposeViewComponent(compRef); });
661
- this._views = [];
662
- };
663
- /**
664
- * Create the plugin before the Grid creation, else it will behave oddly.
665
- * Mostly because the column definitions might change after the grid creation
666
- */
667
- RowDetailViewExtension.prototype.create = function (columnDefinitions, gridOptions) {
668
- var _this = this;
669
- var _a, _b;
670
- if (columnDefinitions && gridOptions) {
671
- if (!gridOptions.rowDetailView) {
672
- throw new Error('The Row Detail View requires options to be passed via the "rowDetailView" property of the Grid Options');
673
- }
674
- if (gridOptions === null || gridOptions === void 0 ? void 0 : gridOptions.rowDetailView) {
675
- if (!this._addon) {
676
- if (typeof gridOptions.rowDetailView.process === 'function') {
677
- // we need to keep the user "process" method and replace it with our own execution method
678
- // we do this because when we get the item detail, we need to call "onAsyncResponse.notify" for the plugin to work
679
- this._userProcessFn = gridOptions.rowDetailView.process; // keep user's process method
680
- gridOptions.rowDetailView.process = function (item) { return _this.onProcessing(item); }; // replace process method & run our internal one
681
- }
682
- else {
683
- throw new Error('You need to provide a "process" function for the Row Detail Extension to work properly');
684
- }
685
- // load the Preload & RowDetail Templates (could be straight HTML or Angular View/ViewModel)
686
- // when those are Angular View/ViewModel, we need to create View Component & provide the html containers to the Plugin (preTemplate/postTemplate methods)
687
- if (!gridOptions.rowDetailView.preTemplate) {
688
- this._preloadComponent = (_a = gridOptions === null || gridOptions === void 0 ? void 0 : gridOptions.rowDetailView) === null || _a === void 0 ? void 0 : _a.preloadComponent;
689
- gridOptions.rowDetailView.preTemplate = function () { return DOMPurify.sanitize("<div class=\"" + PRELOAD_CONTAINER_PREFIX + "\"></div>"); };
690
- }
691
- if (!gridOptions.rowDetailView.postTemplate) {
692
- this._viewComponent = (_b = gridOptions === null || gridOptions === void 0 ? void 0 : gridOptions.rowDetailView) === null || _b === void 0 ? void 0 : _b.viewComponent;
693
- gridOptions.rowDetailView.postTemplate = function (itemDetail) { return DOMPurify.sanitize("<div class=\"" + ROW_DETAIL_CONTAINER_PREFIX + itemDetail[_this.datasetIdPropName] + "\"></div>"); };
694
- }
695
- // finally register the Row Detail View Plugin
696
- this._addonOptions = gridOptions.rowDetailView;
697
- this._addon = new Slick.Plugins.RowDetailView(this._addonOptions);
698
- }
699
- var iconColumn = this._addon.getColumnDefinition();
700
- if (typeof iconColumn === 'object') {
701
- iconColumn.excludeFromExport = true;
702
- iconColumn.excludeFromColumnPicker = true;
703
- iconColumn.excludeFromGridMenu = true;
704
- iconColumn.excludeFromQuery = true;
705
- iconColumn.excludeFromHeaderMenu = true;
706
- // column index position in the grid
707
- var columnPosition = gridOptions && gridOptions.rowDetailView && gridOptions.rowDetailView.columnIndexPosition || 0;
708
- if (columnPosition > 0) {
709
- columnDefinitions.splice(columnPosition, 0, iconColumn);
710
- }
711
- else {
712
- columnDefinitions.unshift(iconColumn);
713
- }
714
- }
715
- }
716
- return this._addon;
717
- }
718
- return null;
719
- };
720
- /** Get the instance of the SlickGrid addon (control or plugin). */
721
- RowDetailViewExtension.prototype.getAddonInstance = function () {
722
- return this._addon;
723
- };
724
- RowDetailViewExtension.prototype.register = function (rowSelectionPlugin) {
725
- var _this = this;
726
- var _a;
727
- if (((_a = this.sharedService) === null || _a === void 0 ? void 0 : _a.slickGrid) && this.sharedService.gridOptions) {
728
- // the plugin has to be created BEFORE the grid (else it behaves oddly), but we can only watch grid events AFTER the grid is created
729
- this.sharedService.slickGrid.registerPlugin(this._addon);
730
- // this also requires the Row Selection Model to be registered as well
731
- if (!rowSelectionPlugin || !this.sharedService.slickGrid.getSelectionModel()) {
732
- rowSelectionPlugin = new Slick.RowSelectionModel(this.sharedService.gridOptions.rowSelectionOptions || { selectActiveRow: true });
733
- this.sharedService.slickGrid.setSelectionModel(rowSelectionPlugin);
734
- }
735
- // hook all events
736
- if (this.sharedService.slickGrid && this.rowDetailViewOptions) {
737
- if (this.rowDetailViewOptions.onExtensionRegistered) {
738
- this.rowDetailViewOptions.onExtensionRegistered(this._addon);
739
- }
740
- this._eventHandler.subscribe(this._addon.onAsyncResponse, function (e, args) {
741
- if (_this.rowDetailViewOptions && typeof _this.rowDetailViewOptions.onAsyncResponse === 'function') {
742
- _this.rowDetailViewOptions.onAsyncResponse(e, args);
743
- }
744
- });
745
- this._eventHandler.subscribe(this._addon.onAsyncEndUpdate, function (e, args) {
746
- // triggers after backend called "onAsyncResponse.notify()"
747
- _this.renderViewModel(args && args.item);
748
- if (_this.rowDetailViewOptions && typeof _this.rowDetailViewOptions.onAsyncEndUpdate === 'function') {
749
- _this.rowDetailViewOptions.onAsyncEndUpdate(e, args);
750
- }
751
- });
752
- this._eventHandler.subscribe(this._addon.onAfterRowDetailToggle, function (e, args) {
753
- // display preload template & re-render all the other Detail Views after toggling
754
- // the preload View will eventually go away once the data gets loaded after the "onAsyncEndUpdate" event
755
- _this.renderPreloadView();
756
- _this.renderAllViewComponents();
757
- if (_this.rowDetailViewOptions && typeof _this.rowDetailViewOptions.onAfterRowDetailToggle === 'function') {
758
- _this.rowDetailViewOptions.onAfterRowDetailToggle(e, args);
759
- }
760
- });
761
- this._eventHandler.subscribe(this._addon.onBeforeRowDetailToggle, function (e, args) {
762
- // before toggling row detail, we need to create View Component if it doesn't exist
763
- _this.onBeforeRowDetailToggle(e, args);
764
- if (_this.rowDetailViewOptions && typeof _this.rowDetailViewOptions.onBeforeRowDetailToggle === 'function') {
765
- _this.rowDetailViewOptions.onBeforeRowDetailToggle(e, args);
766
- }
767
- });
768
- this._eventHandler.subscribe(this._addon.onRowBackToViewportRange, function (e, args) {
769
- // when row is back to viewport range, we will re-render the View Component(s)
770
- _this.onRowBackToViewportRange(e, args);
771
- if (_this.rowDetailViewOptions && typeof _this.rowDetailViewOptions.onRowBackToViewportRange === 'function') {
772
- _this.rowDetailViewOptions.onRowBackToViewportRange(e, args);
773
- }
774
- });
775
- this._eventHandler.subscribe(this._addon.onRowOutOfViewportRange, function (e, args) {
776
- if (_this.rowDetailViewOptions && typeof _this.rowDetailViewOptions.onRowOutOfViewportRange === 'function') {
777
- _this.rowDetailViewOptions.onRowOutOfViewportRange(e, args);
778
- }
779
- });
780
- // --
781
- // hook some events needed by the Plugin itself
782
- // we need to redraw the open detail views if we change column position (column reorder)
783
- this._eventHandler.subscribe(this.sharedService.slickGrid.onColumnsReordered, this.redrawAllViewComponents.bind(this));
784
- // on row selection changed, we also need to redraw
785
- if (this.gridOptions.enableRowSelection || this.gridOptions.enableCheckboxSelector) {
786
- this._eventHandler.subscribe(this.sharedService.slickGrid.onSelectedRowsChanged, this.redrawAllViewComponents.bind(this));
787
- }
788
- // on sort, all row detail are collapsed so we can dispose of all the Views as well
789
- this._eventHandler.subscribe(this.sharedService.slickGrid.onSort, this.disposeAllViewComponents.bind(this));
790
- // on filter changed, we need to re-render all Views
791
- this._subscriptions.push(this.eventPubSubService.subscribe('onFilterChanged', this.redrawAllViewComponents.bind(this)));
792
- }
793
- return this._addon;
794
- }
795
- return null;
796
- };
797
- /** Redraw (re-render) all the expanded row detail View Components */
798
- RowDetailViewExtension.prototype.redrawAllViewComponents = function () {
799
- var _this = this;
800
- this._views.forEach(function (compRef) {
801
- _this.redrawViewComponent(compRef);
802
- });
803
- };
804
- /** Render all the expanded row detail View Components */
805
- RowDetailViewExtension.prototype.renderAllViewComponents = function () {
806
- var _this = this;
807
- this._views.forEach(function (view) {
808
- if (view && view.dataContext) {
809
- _this.renderViewModel(view.dataContext);
810
- }
811
- });
812
- };
813
- /** Redraw the necessary View Component */
814
- RowDetailViewExtension.prototype.redrawViewComponent = function (createdView) {
815
- var containerElements = document.getElementsByClassName("" + ROW_DETAIL_CONTAINER_PREFIX + createdView.id);
816
- if (containerElements && containerElements.length >= 0) {
817
- this.renderViewModel(createdView.dataContext);
818
- }
819
- };
820
- /** Render (or re-render) the View Component (Row Detail) */
821
- RowDetailViewExtension.prototype.renderPreloadView = function () {
822
- var containerElements = document.getElementsByClassName("" + PRELOAD_CONTAINER_PREFIX);
823
- if (containerElements && containerElements.length >= 0) {
824
- this.angularUtilService.createAngularComponentAppendToDom(this._preloadComponent, containerElements[containerElements.length - 1], true);
825
- }
826
- };
827
- /** Render (or re-render) the View Component (Row Detail) */
828
- RowDetailViewExtension.prototype.renderViewModel = function (item) {
829
- var _this = this;
830
- var containerElements = document.getElementsByClassName("" + ROW_DETAIL_CONTAINER_PREFIX + item[this.datasetIdPropName]);
831
- if (containerElements && containerElements.length > 0) {
832
- var componentOutput = this.angularUtilService.createAngularComponentAppendToDom(this._viewComponent, containerElements[containerElements.length - 1], true);
833
- if (componentOutput && componentOutput.componentRef && componentOutput.componentRef.instance) {
834
- // pass a few properties to the Row Detail template component
835
- Object.assign(componentOutput.componentRef.instance, {
836
- model: item,
837
- addon: this._addon,
838
- grid: this.sharedService.slickGrid,
839
- dataView: this.sharedService.dataView,
840
- parent: this.rowDetailViewOptions && this.rowDetailViewOptions.parent,
841
- });
842
- var viewObj = this._views.find(function (obj) { return obj.id === item[_this.datasetIdPropName]; });
843
- if (viewObj) {
844
- viewObj.componentRef = componentOutput.componentRef;
845
- }
846
- return viewObj;
847
- }
848
- }
849
- return undefined;
850
- };
851
- // --
852
- // private functions
853
- // ------------------
854
- RowDetailViewExtension.prototype.disposeViewComponent = function (expandedView) {
855
- var compRef = expandedView === null || expandedView === void 0 ? void 0 : expandedView.componentRef;
856
- if (compRef) {
857
- this.appRef.detachView(compRef.hostView);
858
- if (compRef === null || compRef === void 0 ? void 0 : compRef.destroy) {
859
- compRef.destroy();
860
- }
861
- return expandedView;
862
- }
863
- return null;
864
- };
865
- /**
866
- * notify the onAsyncResponse with the "args.item" (required property)
867
- * the plugin will then use item to populate the row detail panel with the "postTemplate"
868
- * @param item
869
- */
870
- RowDetailViewExtension.prototype.notifyTemplate = function (item) {
871
- if (this._addon) {
872
- this._addon.onAsyncResponse.notify({ item: item }, undefined, this);
873
- }
874
- };
875
- /**
876
- * On Processing, we will notify the plugin with the new item detail once backend server call completes
877
- * @param item
878
- */
879
- RowDetailViewExtension.prototype.onProcessing = function (item) {
880
- return __awaiter(this, void 0, void 0, function () {
881
- var awaitedItemDetail, userProcessFn, response;
882
- return __generator(this, function (_c) {
883
- switch (_c.label) {
884
- case 0:
885
- if (!(item && typeof this._userProcessFn === 'function')) return [3 /*break*/, 5];
886
- awaitedItemDetail = void 0;
887
- userProcessFn = this._userProcessFn(item);
888
- return [4 /*yield*/, userProcessFn];
889
- case 1:
890
- response = _c.sent();
891
- if (!response.hasOwnProperty(this.datasetIdPropName)) return [3 /*break*/, 2];
892
- awaitedItemDetail = response; // from Promise
893
- return [3 /*break*/, 4];
894
- case 2:
895
- if (!(response && response instanceof rxjs.Observable || response instanceof Promise)) return [3 /*break*/, 4];
896
- return [4 /*yield*/, common.castObservableToPromise(this.rxjs, response)];
897
- case 3:
898
- awaitedItemDetail = _c.sent(); // from Angular-http-client
899
- _c.label = 4;
900
- case 4:
901
- if (!awaitedItemDetail || !awaitedItemDetail.hasOwnProperty(this.datasetIdPropName)) {
902
- throw new Error("[Angular-Slickgrid] could not process the Row Detail, you must make sure that your \"process\" callback\n (a Promise or an HttpClient call returning an Observable) returns an item object that has an \"" + this.datasetIdPropName + "\" property");
903
- }
904
- // notify the plugin with the new item details
905
- this.notifyTemplate(awaitedItemDetail || {});
906
- _c.label = 5;
907
- case 5: return [2 /*return*/];
908
- }
909
- });
910
- });
911
- };
912
- /**
913
- * Just before the row get expanded or collapsed we will do the following
914
- * First determine if the row is expanding or collapsing,
915
- * if it's expanding we will add it to our View Components reference array if we don't already have it
916
- * or if it's collapsing we will remove it from our View Components reference array
917
- */
918
- RowDetailViewExtension.prototype.onBeforeRowDetailToggle = function (e, args) {
919
- var _this = this;
920
- // expanding
921
- if (args && args.item && args.item.__collapsed) {
922
- // expanding row detail
923
- var viewInfo = {
924
- id: args.item[this.datasetIdPropName],
925
- dataContext: args.item
926
- };
927
- var idPropName = this.gridOptions.datasetIdPropertyName || 'id';
928
- common.addToArrayWhenNotExists(this._views, viewInfo, idPropName);
929
- }
930
- else {
931
- // collapsing, so dispose of the View/Component
932
- var foundViewIndex = this._views.findIndex(function (view) { return view.id === args.item[_this.datasetIdPropName]; });
933
- if (foundViewIndex >= 0 && this._views.hasOwnProperty(foundViewIndex)) {
934
- var compRef = this._views[foundViewIndex].componentRef;
935
- if (compRef) {
936
- this.appRef.detachView(compRef.hostView);
937
- compRef.destroy();
938
- }
939
- this._views.splice(foundViewIndex, 1);
940
- }
941
- }
942
- };
943
- /** When Row comes back to Viewport Range, we need to redraw the View */
944
- RowDetailViewExtension.prototype.onRowBackToViewportRange = function (e, args) {
945
- var _this = this;
946
- if (args && args.item) {
947
- this._views.forEach(function (view) {
948
- if (view.id === args.item[_this.datasetIdPropName]) {
949
- _this.redrawViewComponent(view);
950
- }
951
- });
952
- }
953
- };
954
- return RowDetailViewExtension;
955
- }());
956
- RowDetailViewExtension.decorators = [
957
- { type: core.Injectable }
958
- ];
959
- RowDetailViewExtension.ctorParameters = function () { return [
960
- { type: AngularUtilService },
961
- { type: core.ApplicationRef },
962
- { type: eventPubSub.EventPubSubService },
963
- { type: common.SharedService },
964
- { type: common.RxJsFacade }
965
- ]; };
966
-
967
- /** Global Grid Options Defaults */
968
- var GlobalGridOptions = {
969
- alwaysShowVerticalScroll: true,
970
- autoEdit: false,
971
- asyncEditorLoading: false,
972
- autoFitColumnsOnFirstLoad: true,
973
- autoResize: {
974
- applyResizeToContainer: true,
975
- calculateAvailableSizeBy: 'window',
976
- bottomPadding: 20,
977
- minHeight: 180,
978
- minWidth: 300,
979
- rightPadding: 0
980
- },
981
- cellHighlightCssClass: 'slick-cell-modified',
982
- checkboxSelector: {
983
- cssClass: 'slick-cell-checkboxsel'
984
- },
985
- columnPicker: {
986
- fadeSpeed: 0,
987
- hideForceFitButton: false,
988
- hideSyncResizeButton: true,
989
- headerColumnValueExtractor: pickerHeaderColumnValueExtractor
990
- },
991
- cellMenu: {
992
- autoAdjustDrop: true,
993
- autoAlignSide: true,
994
- hideCloseButton: true,
995
- hideCommandSection: false,
996
- hideOptionSection: false,
997
- },
998
- contextMenu: {
999
- autoAdjustDrop: true,
1000
- autoAlignSide: true,
1001
- hideCloseButton: true,
1002
- hideClearAllGrouping: false,
1003
- hideCollapseAllGroups: false,
1004
- hideCommandSection: false,
1005
- hideCopyCellValueCommand: false,
1006
- hideExpandAllGroups: false,
1007
- hideExportCsvCommand: false,
1008
- hideExportExcelCommand: false,
1009
- hideExportTextDelimitedCommand: true,
1010
- hideMenuOnScroll: true,
1011
- hideOptionSection: false,
1012
- iconCopyCellValueCommand: 'fa fa-clone',
1013
- iconExportCsvCommand: 'fa fa-download',
1014
- iconExportExcelCommand: 'fa fa-file-excel-o text-success',
1015
- iconExportTextDelimitedCommand: 'fa fa-download',
1016
- width: 200,
1017
- },
1018
- customFooterOptions: {
1019
- dateFormat: 'YYYY-MM-DD, hh:mm a',
1020
- hideRowSelectionCount: false,
1021
- hideTotalItemCount: false,
1022
- hideLastUpdateTimestamp: true,
1023
- footerHeight: 25,
1024
- leftContainerClass: 'col-xs-12 col-sm-5',
1025
- rightContainerClass: 'col-xs-6 col-sm-7',
1026
- metricSeparator: '|',
1027
- metricTexts: {
1028
- items: 'items',
1029
- itemsKey: 'ITEMS',
1030
- itemsSelected: 'items selected',
1031
- itemsSelectedKey: 'ITEMS_SELECTED',
1032
- of: 'of',
1033
- ofKey: 'OF',
1034
- }
1035
- },
1036
- dataView: {
1037
- syncGridSelection: true,
1038
- syncGridSelectionWithBackendService: false, // but disable it when using backend services
1039
- },
1040
- datasetIdPropertyName: 'id',
1041
- defaultFilter: common.Filters.input,
1042
- defaultBackendServiceFilterTypingDebounce: 500,
1043
- defaultColumnSortFieldId: 'id',
1044
- defaultFilterPlaceholder: '🔎︎',
1045
- defaultFilterRangeOperator: common.OperatorType.rangeInclusive,
1046
- editable: false,
1047
- enableAutoResize: true,
1048
- enableAutoSizeColumns: true,
1049
- enableCellNavigation: false,
1050
- enableColumnPicker: true,
1051
- enableColumnReorder: true,
1052
- enableColumnResizeOnDoubleClick: true,
1053
- enableContextMenu: true,
1054
- enableExcelExport: true,
1055
- enableExport: false,
1056
- enableFilterTrimWhiteSpace: false,
1057
- enableGridMenu: true,
1058
- enableHeaderMenu: true,
1059
- enableEmptyDataWarningMessage: true,
1060
- emptyDataWarning: {
1061
- className: 'slick-empty-data-warning',
1062
- message: 'No data to display.',
1063
- messageKey: 'EMPTY_DATA_WARNING_MESSAGE',
1064
- hideFrozenLeftWarning: false,
1065
- hideFrozenRightWarning: false,
1066
- leftViewportMarginLeft: '40%',
1067
- rightViewportMarginLeft: '40%',
1068
- frozenLeftViewportMarginLeft: '0px',
1069
- frozenRightViewportMarginLeft: '40%',
1070
- },
1071
- enableMouseHoverHighlightRow: true,
1072
- enableSorting: true,
1073
- enableTextSelectionOnCells: true,
1074
- eventNamingStyle: common.EventNamingStyle.camelCase,
1075
- explicitInitialization: true,
1076
- excelExportOptions: {
1077
- addGroupIndentation: true,
1078
- exportWithFormatter: false,
1079
- filename: 'export',
1080
- format: common.FileType.xlsx,
1081
- groupingColumnHeaderTitle: 'Group By',
1082
- groupCollapsedSymbol: '⮞',
1083
- groupExpandedSymbol: '⮟',
1084
- groupingAggregatorRowText: '',
1085
- sanitizeDataExport: false,
1086
- },
1087
- exportOptions: {
1088
- delimiter: common.DelimiterType.comma,
1089
- exportWithFormatter: false,
1090
- filename: 'export',
1091
- format: common.FileType.csv,
1092
- groupingColumnHeaderTitle: 'Group By',
1093
- groupingAggregatorRowText: '',
1094
- sanitizeDataExport: false,
1095
- useUtf8WithBom: true
1096
- },
1097
- filterTypingDebounce: 0,
1098
- forceFitColumns: false,
1099
- frozenHeaderWidthCalcDifferential: 0,
1100
- gridMenu: {
1101
- commandLabels: {
1102
- clearAllFiltersCommandKey: 'CLEAR_ALL_FILTERS',
1103
- clearAllSortingCommandKey: 'CLEAR_ALL_SORTING',
1104
- clearFrozenColumnsCommandKey: 'CLEAR_PINNING',
1105
- exportCsvCommandKey: 'EXPORT_TO_CSV',
1106
- exportExcelCommandKey: 'EXPORT_TO_EXCEL',
1107
- exportTextDelimitedCommandKey: 'EXPORT_TO_TAB_DELIMITED',
1108
- refreshDatasetCommandKey: 'REFRESH_DATASET',
1109
- toggleFilterCommandKey: 'TOGGLE_FILTER_ROW',
1110
- togglePreHeaderCommandKey: 'TOGGLE_PRE_HEADER_ROW',
1111
- },
1112
- hideClearAllFiltersCommand: false,
1113
- hideClearAllSortingCommand: false,
1114
- hideClearFrozenColumnsCommand: true,
1115
- hideExportCsvCommand: false,
1116
- hideExportExcelCommand: false,
1117
- hideExportTextDelimitedCommand: true,
1118
- hideForceFitButton: false,
1119
- hideRefreshDatasetCommand: false,
1120
- hideSyncResizeButton: true,
1121
- hideToggleFilterCommand: false,
1122
- hideTogglePreHeaderCommand: false,
1123
- iconCssClass: 'fa fa-bars',
1124
- iconClearAllFiltersCommand: 'fa fa-filter text-danger',
1125
- iconClearAllSortingCommand: 'fa fa-unsorted text-danger',
1126
- iconClearFrozenColumnsCommand: 'fa fa-times',
1127
- iconExportCsvCommand: 'fa fa-download',
1128
- iconExportExcelCommand: 'fa fa-file-excel-o text-success',
1129
- iconExportTextDelimitedCommand: 'fa fa-download',
1130
- iconRefreshDatasetCommand: 'fa fa-refresh',
1131
- iconToggleFilterCommand: 'fa fa-random',
1132
- iconTogglePreHeaderCommand: 'fa fa-random',
1133
- menuWidth: 16,
1134
- resizeOnShowHeaderRow: true,
1135
- useClickToRepositionMenu: false,
1136
- headerColumnValueExtractor: pickerHeaderColumnValueExtractor
1137
- },
1138
- headerMenu: {
1139
- autoAlign: true,
1140
- autoAlignOffset: 12,
1141
- minWidth: 140,
1142
- iconClearFilterCommand: 'fa fa-filter text-danger',
1143
- iconClearSortCommand: 'fa fa-unsorted',
1144
- iconFreezeColumns: 'fa fa-thumb-tack',
1145
- iconSortAscCommand: 'fa fa-sort-amount-asc',
1146
- iconSortDescCommand: 'fa fa-sort-amount-desc',
1147
- iconColumnHideCommand: 'fa fa-times',
1148
- iconColumnResizeByContentCommand: 'fa fa-arrows-h',
1149
- hideColumnResizeByContentCommand: false,
1150
- hideColumnHideCommand: false,
1151
- hideClearFilterCommand: false,
1152
- hideClearSortCommand: false,
1153
- hideFreezeColumnsCommand: true,
1154
- hideSortCommands: false
1155
- },
1156
- headerRowHeight: 35,
1157
- multiColumnSort: true,
1158
- numberedMultiColumnSort: true,
1159
- tristateMultiColumnSort: false,
1160
- sortColNumberInSeparateSpan: true,
1161
- suppressActiveCellChangeOnEdit: true,
1162
- pagination: {
1163
- pageSizes: [10, 15, 20, 25, 30, 40, 50, 75, 100],
1164
- pageSize: 25,
1165
- totalItems: 0
1166
- },
1167
- // technically speaking the Row Detail requires the process & viewComponent but we'll ignore it just to set certain options
1168
- rowDetailView: {
1169
- cssClass: 'detail-view-toggle',
1170
- panelRows: 1,
1171
- keyPrefix: '__',
1172
- useRowClick: false,
1173
- useSimpleViewportCalc: true,
1174
- saveDetailViewOnScroll: false,
1175
- },
1176
- rowHeight: 35,
1177
- topPanelHeight: 35,
1178
- translationNamespaceSeparator: ':',
1179
- resetFilterSearchValueAfterOnBeforeCancellation: true,
1180
- resizeByContentOnlyOnFirstLoad: true,
1181
- resizeByContentOptions: {
1182
- alwaysRecalculateColumnWidth: false,
1183
- cellCharWidthInPx: 7.8,
1184
- cellPaddingWidthInPx: 14,
1185
- defaultRatioForStringType: 0.88,
1186
- formatterPaddingWidthInPx: 0,
1187
- maxItemToInspectCellContentWidth: 1000,
1188
- maxItemToInspectSingleColumnWidthByContent: 5000,
1189
- widthToRemoveFromExceededWidthReadjustment: 50,
1190
- },
1191
- treeDataOptions: {
1192
- exportIndentMarginLeft: 5,
1193
- exportIndentationLeadingChar: '͏͏͏͏͏͏͏͏͏·',
1194
- }
1195
- };
1196
- /**
1197
- * Value Extractor for both ColumnPicker & GridMenu Picker
1198
- * when using Column Header Grouping, we'll prefix the column group title
1199
- * else we'll simply return the column name title
1200
- */
1201
- function pickerHeaderColumnValueExtractor(column) {
1202
- var headerGroup = column && column.columnGroup || '';
1203
- if (headerGroup) {
1204
- return headerGroup + ' - ' + column.name;
1205
- }
1206
- return column && column.name || '';
1207
- }
1208
-
1209
- var SlickgridConfig = /** @class */ (function () {
1210
- function SlickgridConfig() {
1211
- this.options = GlobalGridOptions;
1212
- }
1213
- return SlickgridConfig;
1214
- }());
1215
-
1216
- var Constants = /** @class */ (function () {
1217
- function Constants() {
1218
- }
1219
- return Constants;
1220
- }());
1221
- // English Locale texts when using only 1 Locale instead of I18N
1222
- Constants.locales = {
1223
- TEXT_ALL_SELECTED: 'All Selected',
1224
- TEXT_ALL_X_RECORDS_SELECTED: 'All {{x}} records selected',
1225
- TEXT_APPLY_MASS_UPDATE: 'Apply Mass Update',
1226
- TEXT_APPLY_TO_SELECTION: 'Update Selection',
1227
- TEXT_CANCEL: 'Cancel',
1228
- TEXT_CLEAR_ALL_FILTERS: 'Clear all Filters',
1229
- TEXT_CLEAR_ALL_GROUPING: 'Clear all Grouping',
1230
- TEXT_CLEAR_ALL_SORTING: 'Clear all Sorting',
1231
- TEXT_CLEAR_PINNING: 'Unfreeze Columns/Rows',
1232
- TEXT_CLONE: 'Clone',
1233
- TEXT_COLLAPSE_ALL_GROUPS: 'Collapse all Groups',
1234
- TEXT_CONTAINS: 'Contains',
1235
- TEXT_COLUMNS: 'Columns',
1236
- TEXT_COLUMN_RESIZE_BY_CONTENT: 'Resize by Content',
1237
- TEXT_COMMANDS: 'Commands',
1238
- TEXT_COPY: 'Copy',
1239
- TEXT_EQUALS: 'Equals',
1240
- TEXT_EQUAL_TO: 'Equal to',
1241
- TEXT_ENDS_WITH: 'Ends With',
1242
- TEXT_ERROR_EDITABLE_GRID_REQUIRED: 'Your grid must be editable in order to use the Composite Editor Modal.',
1243
- TEXT_ERROR_ENABLE_CELL_NAVIGATION_REQUIRED: 'Composite Editor requires the flag "enableCellNavigation" to be set to True in your Grid Options.',
1244
- TEXT_ERROR_NO_CHANGES_DETECTED: 'Sorry we could not detect any changes.',
1245
- TEXT_ERROR_NO_EDITOR_FOUND: 'We could not find any Editor in your Column Definition.',
1246
- TEXT_ERROR_NO_RECORD_FOUND: 'No records selected for edit or clone operation.',
1247
- TEXT_ERROR_ROW_NOT_EDITABLE: 'Current row is not editable.',
1248
- TEXT_ERROR_ROW_SELECTION_REQUIRED: 'You must select some rows before trying to apply new value(s).',
1249
- TEXT_EXPAND_ALL_GROUPS: 'Expand all Groups',
1250
- TEXT_EXPORT_TO_CSV: 'Export in CSV format',
1251
- TEXT_EXPORT_TO_TEXT_FORMAT: 'Export in Text format (Tab delimited)',
1252
- TEXT_EXPORT_TO_EXCEL: 'Export to Excel',
1253
- TEXT_EXPORT_TO_TAB_DELIMITED: 'Export in Text format (Tab delimited)',
1254
- TEXT_FORCE_FIT_COLUMNS: 'Force fit columns',
1255
- TEXT_FREEZE_COLUMNS: 'Freeze Columns',
1256
- TEXT_GREATER_THAN: 'Greater than',
1257
- TEXT_GREATER_THAN_OR_EQUAL_TO: 'Greater than or equal to',
1258
- TEXT_GROUP_BY: 'Group By',
1259
- TEXT_HIDE_COLUMN: 'Hide Column',
1260
- TEXT_ITEMS: 'items',
1261
- TEXT_ITEMS_PER_PAGE: 'items per page',
1262
- TEXT_ITEMS_SELECTED: 'items selected',
1263
- TEXT_OF: 'of',
1264
- TEXT_OK: 'OK',
1265
- TEXT_LAST_UPDATE: 'Last Update',
1266
- TEXT_LESS_THAN: 'Less than',
1267
- TEXT_LESS_THAN_OR_EQUAL_TO: 'Less than or equal to',
1268
- TEXT_NOT_CONTAINS: 'Not contains',
1269
- TEXT_NOT_EQUAL_TO: 'Not equal to',
1270
- TEXT_PAGE: 'Page',
1271
- TEXT_REFRESH_DATASET: 'Refresh Dataset',
1272
- TEXT_REMOVE_FILTER: 'Remove Filter',
1273
- TEXT_REMOVE_SORT: 'Remove Sort',
1274
- TEXT_SAVE: 'Save',
1275
- TEXT_SELECT_ALL: 'Select All',
1276
- TEXT_SYNCHRONOUS_RESIZE: 'Synchronous resize',
1277
- TEXT_SORT_ASCENDING: 'Sort Ascending',
1278
- TEXT_SORT_DESCENDING: 'Sort Descending',
1279
- TEXT_STARTS_WITH: 'Starts With',
1280
- TEXT_TOGGLE_FILTER_ROW: 'Toggle Filter Row',
1281
- TEXT_TOGGLE_PRE_HEADER_ROW: 'Toggle Pre-Header Row',
1282
- TEXT_X_OF_Y_SELECTED: '# of % selected',
1283
- TEXT_X_OF_Y_MASS_SELECTED: '{{x}} of {{y}} selected',
1284
- };
1285
- Constants.treeDataProperties = {
1286
- CHILDREN_PROP: 'children',
1287
- COLLAPSED_PROP: '__collapsed',
1288
- HAS_CHILDREN_PROP: '__hasChildren',
1289
- TREE_LEVEL_PROP: '__treeLevel',
1290
- PARENT_PROP: '__parentId',
1291
- };
1292
- // some Validation default texts
1293
- Constants.VALIDATION_REQUIRED_FIELD = 'Field is required';
1294
- Constants.VALIDATION_EDITOR_VALID_NUMBER = 'Please enter a valid number';
1295
- Constants.VALIDATION_EDITOR_VALID_INTEGER = 'Please enter a valid integer number';
1296
- Constants.VALIDATION_EDITOR_INTEGER_BETWEEN = 'Please enter a valid integer number between {{minValue}} and {{maxValue}}';
1297
- Constants.VALIDATION_EDITOR_INTEGER_MAX = 'Please enter a valid integer number that is lower than {{maxValue}}';
1298
- Constants.VALIDATION_EDITOR_INTEGER_MAX_INCLUSIVE = 'Please enter a valid integer number that is lower than or equal to {{maxValue}}';
1299
- Constants.VALIDATION_EDITOR_INTEGER_MIN = 'Please enter a valid integer number that is greater than {{minValue}}';
1300
- Constants.VALIDATION_EDITOR_INTEGER_MIN_INCLUSIVE = 'Please enter a valid integer number that is greater than or equal to {{minValue}}';
1301
- Constants.VALIDATION_EDITOR_NUMBER_BETWEEN = 'Please enter a valid number between {{minValue}} and {{maxValue}}';
1302
- Constants.VALIDATION_EDITOR_NUMBER_MAX = 'Please enter a valid number that is lower than {{maxValue}}';
1303
- Constants.VALIDATION_EDITOR_NUMBER_MAX_INCLUSIVE = 'Please enter a valid number that is lower than or equal to {{maxValue}}';
1304
- Constants.VALIDATION_EDITOR_NUMBER_MIN = 'Please enter a valid number that is greater than {{minValue}}';
1305
- Constants.VALIDATION_EDITOR_NUMBER_MIN_INCLUSIVE = 'Please enter a valid number that is greater than or equal to {{minValue}}';
1306
- Constants.VALIDATION_EDITOR_DECIMAL_BETWEEN = 'Please enter a valid number with a maximum of {{maxDecimal}} decimals';
1307
- Constants.VALIDATION_EDITOR_TEXT_LENGTH_BETWEEN = 'Please make sure your text length is between {{minLength}} and {{maxLength}} characters';
1308
- Constants.VALIDATION_EDITOR_TEXT_MAX_LENGTH = 'Please make sure your text is less than {{maxLength}} characters';
1309
- Constants.VALIDATION_EDITOR_TEXT_MAX_LENGTH_INCLUSIVE = 'Please make sure your text is less than or equal to {{maxLength}} characters';
1310
- Constants.VALIDATION_EDITOR_TEXT_MIN_LENGTH = 'Please make sure your text is more than {{minLength}} character(s)';
1311
- Constants.VALIDATION_EDITOR_TEXT_MIN_LENGTH_INCLUSIVE = 'Please make sure your text is at least {{minLength}} character(s)';
1312
-
1313
- var AngularSlickgridComponent = /** @class */ (function () {
1314
- function AngularSlickgridComponent(angularUtilService, appRef, cd, containerService, elm, translate, translaterService, forRootConfig, externalServices) {
1315
- var _a, _b, _c, _d, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
1316
- this.angularUtilService = angularUtilService;
1317
- this.appRef = appRef;
1318
- this.cd = cd;
1319
- this.containerService = containerService;
1320
- this.elm = elm;
1321
- this.translate = translate;
1322
- this.translaterService = translaterService;
1323
- this.forRootConfig = forRootConfig;
1324
- this._currentDatasetLength = 0;
1325
- this._eventHandler = new Slick.EventHandler();
1326
- this._hideHeaderRowAfterPageLoad = false;
1327
- this._isGridInitialized = false;
1328
- this._isDatasetInitialized = false;
1329
- this._isDatasetHierarchicalInitialized = false;
1330
- this._isPaginationInitialized = false;
1331
- this._isLocalGrid = true;
1332
- this._registeredResources = [];
1333
- this.groupingDefinition = {};
1334
- this.showPagination = false;
1335
- this.serviceList = [];
1336
- this.totalItems = 0;
1337
- this.subscriptions = [];
1338
- this.gridId = '';
1339
- var slickgridConfig = new common.SlickgridConfig();
1340
- // initialize and assign all Service Dependencies
1341
- this._eventPubSubService = (_a = externalServices === null || externalServices === void 0 ? void 0 : externalServices.eventPubSubService) !== null && _a !== void 0 ? _a : new eventPubSub.EventPubSubService(this.elm.nativeElement);
1342
- this._eventPubSubService.eventNamingStyle = common.EventNamingStyle.camelCase;
1343
- this.backendUtilityService = (_b = externalServices === null || externalServices === void 0 ? void 0 : externalServices.backendUtilityService) !== null && _b !== void 0 ? _b : new common.BackendUtilityService();
1344
- this.gridEventService = (_c = externalServices === null || externalServices === void 0 ? void 0 : externalServices.gridEventService) !== null && _c !== void 0 ? _c : new common.GridEventService();
1345
- this.sharedService = (_d = externalServices === null || externalServices === void 0 ? void 0 : externalServices.sharedService) !== null && _d !== void 0 ? _d : new common.SharedService();
1346
- this.collectionService = (_f = externalServices === null || externalServices === void 0 ? void 0 : externalServices.collectionService) !== null && _f !== void 0 ? _f : new common.CollectionService(this.translaterService);
1347
- this.extensionUtility = (_g = externalServices === null || externalServices === void 0 ? void 0 : externalServices.extensionUtility) !== null && _g !== void 0 ? _g : new common.ExtensionUtility(this.sharedService, this.translaterService);
1348
- this.filterFactory = new common.FilterFactory(slickgridConfig, this.translaterService, this.collectionService);
1349
- this.filterService = (_h = externalServices === null || externalServices === void 0 ? void 0 : externalServices.filterService) !== null && _h !== void 0 ? _h : new common.FilterService(this.filterFactory, this._eventPubSubService, this.sharedService, this.backendUtilityService);
1350
- this.resizerService = (_j = externalServices === null || externalServices === void 0 ? void 0 : externalServices.resizerService) !== null && _j !== void 0 ? _j : new common.ResizerService(this._eventPubSubService);
1351
- this.sortService = (_k = externalServices === null || externalServices === void 0 ? void 0 : externalServices.sortService) !== null && _k !== void 0 ? _k : new common.SortService(this.sharedService, this._eventPubSubService, this.backendUtilityService);
1352
- this.treeDataService = (_l = externalServices === null || externalServices === void 0 ? void 0 : externalServices.treeDataService) !== null && _l !== void 0 ? _l : new common.TreeDataService(this._eventPubSubService, this.sharedService, this.sortService);
1353
- this.paginationService = (_m = externalServices === null || externalServices === void 0 ? void 0 : externalServices.paginationService) !== null && _m !== void 0 ? _m : new common.PaginationService(this._eventPubSubService, this.sharedService, this.backendUtilityService);
1354
- // extensions
1355
- var autoTooltipExtension = new common.AutoTooltipExtension(this.sharedService);
1356
- var cellExternalCopyManagerExtension = new common.CellExternalCopyManagerExtension(this.extensionUtility, this.sharedService);
1357
- var cellMenuExtension = new common.CellMenuExtension(this.extensionUtility, this.sharedService, this.translaterService);
1358
- var contextMenuExtension = new common.ContextMenuExtension(this.extensionUtility, this._eventPubSubService, this.sharedService, this.treeDataService, this.translaterService);
1359
- var columnPickerExtension = new common.ColumnPickerExtension(this.extensionUtility, this.sharedService);
1360
- var checkboxExtension = new common.CheckboxSelectorExtension(this.sharedService);
1361
- var draggableGroupingExtension = new common.DraggableGroupingExtension(this.extensionUtility, this._eventPubSubService, this.sharedService);
1362
- var gridMenuExtension = new common.GridMenuExtension(this.extensionUtility, this.filterService, this._eventPubSubService, this.sharedService, this.sortService, this.backendUtilityService, this.translaterService);
1363
- var groupItemMetaProviderExtension = new common.GroupItemMetaProviderExtension(this.sharedService);
1364
- var headerButtonExtension = new common.HeaderButtonExtension(this.extensionUtility, this.sharedService);
1365
- var headerMenuExtension = new common.HeaderMenuExtension(this.extensionUtility, this.filterService, this._eventPubSubService, this.sharedService, this.sortService, this.translaterService);
1366
- var rowDetailViewExtension = new RowDetailViewExtension(this.angularUtilService, this.appRef, this._eventPubSubService, this.sharedService, this.rxjs);
1367
- var rowMoveManagerExtension = new common.RowMoveManagerExtension(this.sharedService);
1368
- var rowSelectionExtension = new common.RowSelectionExtension(this.sharedService);
1369
- this.extensionService = (_o = externalServices === null || externalServices === void 0 ? void 0 : externalServices.extensionService) !== null && _o !== void 0 ? _o : new common.ExtensionService(autoTooltipExtension, cellExternalCopyManagerExtension, cellMenuExtension, checkboxExtension, columnPickerExtension, contextMenuExtension, draggableGroupingExtension, gridMenuExtension, groupItemMetaProviderExtension, headerButtonExtension, headerMenuExtension, rowDetailViewExtension, rowMoveManagerExtension, rowSelectionExtension, this.sharedService, this.translaterService);
1370
- this.gridStateService = (_p = externalServices === null || externalServices === void 0 ? void 0 : externalServices.gridStateService) !== null && _p !== void 0 ? _p : new common.GridStateService(this.extensionService, this.filterService, this._eventPubSubService, this.sharedService, this.sortService, this.treeDataService);
1371
- this.gridService = (_q = externalServices === null || externalServices === void 0 ? void 0 : externalServices.gridService) !== null && _q !== void 0 ? _q : new common.GridService(this.gridStateService, this.filterService, this._eventPubSubService, this.paginationService, this.sharedService, this.sortService, this.treeDataService);
1372
- this.groupingService = (_r = externalServices === null || externalServices === void 0 ? void 0 : externalServices.groupingAndColspanService) !== null && _r !== void 0 ? _r : new common.GroupingAndColspanService(this.extensionUtility, this.extensionService, this._eventPubSubService);
1373
- this.serviceList = [
1374
- this.extensionService,
1375
- this.filterService,
1376
- this.gridEventService,
1377
- this.gridService,
1378
- this.gridStateService,
1379
- this.groupingService,
1380
- this.paginationService,
1381
- this.resizerService,
1382
- this.sortService,
1383
- this.treeDataService,
1384
- ];
1385
- // register all Service instances in the container
1386
- this.containerService.registerInstance('ExtensionUtility', this.extensionUtility);
1387
- this.containerService.registerInstance('FilterService', this.filterService);
1388
- this.containerService.registerInstance('CollectionService', this.collectionService);
1389
- this.containerService.registerInstance('ExtensionService', this.extensionService);
1390
- this.containerService.registerInstance('GridEventService', this.gridEventService);
1391
- this.containerService.registerInstance('GridService', this.gridService);
1392
- this.containerService.registerInstance('GridStateService', this.gridStateService);
1393
- this.containerService.registerInstance('GroupingAndColspanService', this.groupingService);
1394
- this.containerService.registerInstance('PaginationService', this.paginationService);
1395
- this.containerService.registerInstance('ResizerService', this.resizerService);
1396
- this.containerService.registerInstance('SharedService', this.sharedService);
1397
- this.containerService.registerInstance('SortService', this.sortService);
1398
- this.containerService.registerInstance('EventPubSubService', this._eventPubSubService);
1399
- this.containerService.registerInstance('PubSubService', this._eventPubSubService);
1400
- this.containerService.registerInstance('TranslaterService', this.translaterService);
1401
- this.containerService.registerInstance('TreeDataService', this.treeDataService);
1402
- }
1403
- Object.defineProperty(AngularSlickgridComponent.prototype, "paginationOptions", {
1404
- get: function () {
1405
- return this._paginationOptions;
1406
- },
1407
- set: function (newPaginationOptions) {
1408
- var _a, _b, _c;
1409
- if (newPaginationOptions && this._paginationOptions) {
1410
- this._paginationOptions = Object.assign(Object.assign(Object.assign({}, this.gridOptions.pagination), this._paginationOptions), newPaginationOptions);
1411
- }
1412
- else {
1413
- this._paginationOptions = newPaginationOptions;
1414
- }
1415
- this.gridOptions.pagination = (_a = this._paginationOptions) !== null && _a !== void 0 ? _a : this.gridOptions.pagination;
1416
- this.paginationService.updateTotalItems((_c = (_b = this.gridOptions.pagination) === null || _b === void 0 ? void 0 : _b.totalItems) !== null && _c !== void 0 ? _c : 0, true);
1417
- },
1418
- enumerable: false,
1419
- configurable: true
1420
- });
1421
- Object.defineProperty(AngularSlickgridComponent.prototype, "columnDefinitions", {
1422
- get: function () {
1423
- return this._columnDefinitions;
1424
- },
1425
- set: function (columnDefinitions) {
1426
- this._columnDefinitions = columnDefinitions;
1427
- if (this._isGridInitialized) {
1428
- this.updateColumnDefinitionsList(columnDefinitions);
1429
- }
1430
- if (columnDefinitions.length > 0) {
1431
- this.copyColumnWidthsReference(columnDefinitions);
1432
- }
1433
- },
1434
- enumerable: false,
1435
- configurable: true
1436
- });
1437
- Object.defineProperty(AngularSlickgridComponent.prototype, "dataset", {
1438
- get: function () {
1439
- var _a, _b, _c, _d;
1440
- return (this.customDataView ? (_b = (_a = this.slickGrid) === null || _a === void 0 ? void 0 : _a.getData) === null || _b === void 0 ? void 0 : _b.call(_a) : (_d = (_c = this.dataView) === null || _c === void 0 ? void 0 : _c.getItems) === null || _d === void 0 ? void 0 : _d.call(_c)) || [];
1441
- },
1442
- set: function (newDataset) {
1443
- var _a, _b;
1444
- var prevDatasetLn = this._currentDatasetLength;
1445
- var isDatasetEqual = lite.dequal(newDataset, this._dataset || []);
1446
- var data = newDataset;
1447
- // when Tree Data is enabled and we don't yet have the hierarchical dataset filled, we can force a convert+sort of the array
1448
- if (this.slickGrid && ((_a = this.gridOptions) === null || _a === void 0 ? void 0 : _a.enableTreeData) && Array.isArray(newDataset) && (newDataset.length > 0 || newDataset.length !== prevDatasetLn || !isDatasetEqual)) {
1449
- this._isDatasetHierarchicalInitialized = false;
1450
- data = this.sortTreeDataset(newDataset, !isDatasetEqual); // if dataset changed, then force a refresh anyway
1451
- }
1452
- this._dataset = data;
1453
- this.refreshGridData(data || []);
1454
- this._currentDatasetLength = (newDataset || []).length;
1455
- // expand/autofit columns on first page load
1456
- // we can assume that if the prevDataset was empty then we are on first load
1457
- if (((_b = this.gridOptions) === null || _b === void 0 ? void 0 : _b.autoFitColumnsOnFirstLoad) && prevDatasetLn === 0) {
1458
- this.slickGrid.autosizeColumns();
1459
- }
1460
- },
1461
- enumerable: false,
1462
- configurable: true
1463
- });
1464
- Object.defineProperty(AngularSlickgridComponent.prototype, "datasetHierarchical", {
1465
- get: function () {
1466
- return this.sharedService.hierarchicalDataset;
1467
- },
1468
- set: function (newHierarchicalDataset) {
1469
- var _this = this;
1470
- var _a, _b, _c, _d, _f;
1471
- var isDatasetEqual = lite.dequal(newHierarchicalDataset, (_b = (_a = this.sharedService) === null || _a === void 0 ? void 0 : _a.hierarchicalDataset) !== null && _b !== void 0 ? _b : []);
1472
- var prevFlatDatasetLn = this._currentDatasetLength;
1473
- this.sharedService.hierarchicalDataset = newHierarchicalDataset;
1474
- if (newHierarchicalDataset && this.columnDefinitions && ((_c = this.filterService) === null || _c === void 0 ? void 0 : _c.clearFilters)) {
1475
- this.filterService.clearFilters();
1476
- }
1477
- // when a hierarchical dataset is set afterward, we can reset the flat dataset and call a tree data sort that will overwrite the flat dataset
1478
- if (newHierarchicalDataset && this.slickGrid && ((_d = this.sortService) === null || _d === void 0 ? void 0 : _d.processTreeDataInitialSort)) {
1479
- this.dataView.setItems([], (_f = this.gridOptions.datasetIdPropertyName) !== null && _f !== void 0 ? _f : 'id');
1480
- this.sortService.processTreeDataInitialSort();
1481
- // we also need to reset/refresh the Tree Data filters because if we inserted new item(s) then it might not show up without doing this refresh
1482
- // however we need 1 cpu cycle before having the DataView refreshed, so we need to wrap this check in a setTimeout
1483
- setTimeout(function () {
1484
- var flatDatasetLn = _this.dataView.getItemCount();
1485
- if (flatDatasetLn > 0 && (flatDatasetLn !== prevFlatDatasetLn || !isDatasetEqual)) {
1486
- _this.filterService.refreshTreeDataFilters();
1487
- }
1488
- });
1489
- this._isDatasetHierarchicalInitialized = true;
1490
- }
1491
- },
1492
- enumerable: false,
1493
- configurable: true
1494
- });
1495
- Object.defineProperty(AngularSlickgridComponent.prototype, "elementRef", {
1496
- get: function () {
1497
- return this.elm;
1498
- },
1499
- enumerable: false,
1500
- configurable: true
1501
- });
1502
- Object.defineProperty(AngularSlickgridComponent.prototype, "eventHandler", {
1503
- get: function () {
1504
- return this._eventHandler;
1505
- },
1506
- enumerable: false,
1507
- configurable: true
1508
- });
1509
- Object.defineProperty(AngularSlickgridComponent.prototype, "gridContainerElement", {
1510
- get: function () {
1511
- return document.querySelector("#" + (this.gridOptions.gridContainerId || ''));
1512
- },
1513
- enumerable: false,
1514
- configurable: true
1515
- });
1516
- Object.defineProperty(AngularSlickgridComponent.prototype, "isDatasetInitialized", {
1517
- /** GETTER to know if dataset was initialized or not */
1518
- get: function () {
1519
- return this._isDatasetInitialized;
1520
- },
1521
- /** SETTER to change if dataset was initialized or not (stringly used for unit testing purposes) */
1522
- set: function (isInitialized) {
1523
- this._isDatasetInitialized = isInitialized;
1524
- },
1525
- enumerable: false,
1526
- configurable: true
1527
- });
1528
- Object.defineProperty(AngularSlickgridComponent.prototype, "isDatasetHierarchicalInitialized", {
1529
- set: function (isInitialized) {
1530
- this._isDatasetHierarchicalInitialized = isInitialized;
1531
- },
1532
- enumerable: false,
1533
- configurable: true
1534
- });
1535
- Object.defineProperty(AngularSlickgridComponent.prototype, "registeredResources", {
1536
- get: function () {
1537
- return this._registeredResources;
1538
- },
1539
- enumerable: false,
1540
- configurable: true
1541
- });
1542
- AngularSlickgridComponent.prototype.ngAfterViewInit = function () {
1543
- this.initialization(this._eventHandler);
1544
- this._isGridInitialized = true;
1545
- // recheck the empty warning message after grid is shown so that it works in every use case
1546
- if (this.gridOptions && this.gridOptions.enableEmptyDataWarningMessage && Array.isArray(this.dataset)) {
1547
- var finalTotalCount = this.dataset.length;
1548
- this.displayEmptyDataWarning(finalTotalCount < 1);
1549
- }
1550
- };
1551
- AngularSlickgridComponent.prototype.ngOnDestroy = function () {
1552
- this._eventPubSubService.publish('onBeforeGridDestroy', this.slickGrid);
1553
- this.destroy();
1554
- this._eventPubSubService.publish('onAfterGridDestroyed', true);
1555
- };
1556
- AngularSlickgridComponent.prototype.destroy = function (shouldEmptyDomElementContainer) {
1557
- var e_1, _s, e_2, _t, e_3, _u;
1558
- if (shouldEmptyDomElementContainer === void 0) { shouldEmptyDomElementContainer = false; }
1559
- var _a, _b, _c, _d, _f, _g, _h;
1560
- // dispose of all Services
1561
- this.serviceList.forEach(function (service) {
1562
- if (service && service.dispose) {
1563
- service.dispose();
1564
- }
1565
- });
1566
- this.serviceList = [];
1567
- // dispose all registered external resources
1568
- if (Array.isArray(this._registeredResources)) {
1569
- while (this._registeredResources.length > 0) {
1570
- var resource = this._registeredResources.pop();
1571
- if (resource === null || resource === void 0 ? void 0 : resource.dispose) {
1572
- resource.dispose();
1573
- }
1574
- }
1575
- this._registeredResources = [];
1576
- }
1577
- // dispose the Components
1578
- (_a = this.slickEmptyWarning) === null || _a === void 0 ? void 0 : _a.dispose();
1579
- (_b = this.slickFooter) === null || _b === void 0 ? void 0 : _b.dispose();
1580
- (_c = this.slickPagination) === null || _c === void 0 ? void 0 : _c.dispose();
1581
- if ((_d = this._eventHandler) === null || _d === void 0 ? void 0 : _d.unsubscribeAll) {
1582
- this._eventHandler.unsubscribeAll();
1583
- }
1584
- (_f = this._eventPubSubService) === null || _f === void 0 ? void 0 : _f.unsubscribeAll();
1585
- if (this.dataView) {
1586
- if ((_g = this.dataView) === null || _g === void 0 ? void 0 : _g.setItems) {
1587
- this.dataView.setItems([]);
1588
- }
1589
- if (this.dataView.destroy) {
1590
- this.dataView.destroy();
1591
- }
1592
- }
1593
- if ((_h = this.slickGrid) === null || _h === void 0 ? void 0 : _h.destroy) {
1594
- this.slickGrid.destroy(shouldEmptyDomElementContainer);
1595
- }
1596
- if (this.backendServiceApi) {
1597
- try {
1598
- for (var _v = __values(Object.keys(this.backendServiceApi)), _w = _v.next(); !_w.done; _w = _v.next()) {
1599
- var prop = _w.value;
1600
- delete this.backendServiceApi[prop];
1601
- }
1602
- }
1603
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
1604
- finally {
1605
- try {
1606
- if (_w && !_w.done && (_s = _v.return)) _s.call(_v);
1607
- }
1608
- finally { if (e_1) throw e_1.error; }
1609
- }
1610
- this.backendServiceApi = undefined;
1611
- }
1612
- try {
1613
- for (var _x = __values(Object.keys(this.columnDefinitions)), _y = _x.next(); !_y.done; _y = _x.next()) {
1614
- var prop = _y.value;
1615
- this.columnDefinitions[prop] = null;
1616
- }
1617
- }
1618
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
1619
- finally {
1620
- try {
1621
- if (_y && !_y.done && (_t = _x.return)) _t.call(_x);
1622
- }
1623
- finally { if (e_2) throw e_2.error; }
1624
- }
1625
- try {
1626
- for (var _z = __values(Object.keys(this.sharedService)), _0 = _z.next(); !_0.done; _0 = _z.next()) {
1627
- var prop = _0.value;
1628
- this.sharedService[prop] = null;
1629
- }
1630
- }
1631
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
1632
- finally {
1633
- try {
1634
- if (_0 && !_0.done && (_u = _z.return)) _u.call(_z);
1635
- }
1636
- finally { if (e_3) throw e_3.error; }
1637
- }
1638
- // we could optionally also empty the content of the grid container DOM element
1639
- if (shouldEmptyDomElementContainer) {
1640
- this.emptyGridContainerElm();
1641
- }
1642
- // also unsubscribe all RxJS subscriptions
1643
- this.subscriptions = unsubscribeAllObservables(this.subscriptions);
1644
- this._dataset = null;
1645
- this.datasetHierarchical = undefined;
1646
- this._columnDefinitions = [];
1647
- this._angularGridInstances = undefined;
1648
- };
1649
- AngularSlickgridComponent.prototype.emptyGridContainerElm = function () {
1650
- var _a, _b;
1651
- var gridContainerId = (_b = (_a = this.gridOptions) === null || _a === void 0 ? void 0 : _a.gridContainerId) !== null && _b !== void 0 ? _b : 'grid1';
1652
- var gridContainerElm = document.querySelector("#" + gridContainerId);
1653
- common.emptyElement(gridContainerElm);
1654
- };
1655
- /**
1656
- * Define our internal Post Process callback, it will execute internally after we get back result from the Process backend call
1657
- * For now, this is GraphQL Service ONLY feature and it will basically refresh the Dataset & Pagination without having the user to create his own PostProcess every time
1658
- */
1659
- AngularSlickgridComponent.prototype.createBackendApiInternalPostProcessCallback = function (gridOptions) {
1660
- var _this = this;
1661
- var backendApi = gridOptions && gridOptions.backendServiceApi;
1662
- if (backendApi && backendApi.service) {
1663
- var backendApiService_1 = backendApi.service;
1664
- // internalPostProcess only works (for now) with a GraphQL Service, so make sure it is of that type
1665
- if (typeof backendApiService_1.getDatasetName === 'function') {
1666
- backendApi.internalPostProcess = function (processResult) {
1667
- var datasetName = (backendApi && backendApiService_1 && typeof backendApiService_1.getDatasetName === 'function') ? backendApiService_1.getDatasetName() : '';
1668
- if (processResult === null || processResult === void 0 ? void 0 : processResult.data[datasetName]) {
1669
- var data = processResult.data[datasetName].hasOwnProperty('nodes') ? processResult.data[datasetName].nodes : processResult.data[datasetName];
1670
- var totalCount = processResult.data[datasetName].hasOwnProperty('totalCount') ? processResult.data[datasetName].totalCount : processResult.data[datasetName].length;
1671
- _this.refreshGridData(data, totalCount || 0);
1672
- }
1673
- };
1674
- }
1675
- }
1676
- };
1677
- AngularSlickgridComponent.prototype.initialization = function (eventHandler) {
1678
- var _a, _b, _c, _d, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
1679
- this.gridOptions.translater = this.translaterService;
1680
- this._eventHandler = eventHandler;
1681
- // when detecting a frozen grid, we'll automatically enable the mousewheel scroll handler so that we can scroll from both left/right frozen containers
1682
- if (this.gridOptions && ((this.gridOptions.frozenRow !== undefined && this.gridOptions.frozenRow >= 0) || this.gridOptions.frozenColumn !== undefined && this.gridOptions.frozenColumn >= 0) && this.gridOptions.enableMouseWheelScrollHandler === undefined) {
1683
- this.gridOptions.enableMouseWheelScrollHandler = true;
1684
- }
1685
- this._eventPubSubService.eventNamingStyle = (_b = (_a = this.gridOptions) === null || _a === void 0 ? void 0 : _a.eventNamingStyle) !== null && _b !== void 0 ? _b : common.EventNamingStyle.camelCase;
1686
- this._eventPubSubService.publish('onBeforeGridCreate', true);
1687
- // make sure the dataset is initialized (if not it will throw an error that it cannot getLength of null)
1688
- this._dataset = this._dataset || [];
1689
- this.gridOptions = this.mergeGridOptions(this.gridOptions);
1690
- this._paginationOptions = (_c = this.gridOptions) === null || _c === void 0 ? void 0 : _c.pagination;
1691
- this.locales = (_f = (_d = this.gridOptions) === null || _d === void 0 ? void 0 : _d.locales) !== null && _f !== void 0 ? _f : Constants.locales;
1692
- this.backendServiceApi = (_g = this.gridOptions) === null || _g === void 0 ? void 0 : _g.backendServiceApi;
1693
- this._isLocalGrid = !this.backendServiceApi; // considered a local grid if it doesn't have a backend service set
1694
- this.createBackendApiInternalPostProcessCallback(this.gridOptions);
1695
- if (!this.customDataView) {
1696
- var dataviewInlineFilters = this.gridOptions.dataView && this.gridOptions.dataView.inlineFilters || false;
1697
- var dataViewOptions = { inlineFilters: dataviewInlineFilters };
1698
- if (this.gridOptions.draggableGrouping || this.gridOptions.enableGrouping) {
1699
- this.groupItemMetadataProvider = new Slick.Data.GroupItemMetadataProvider();
1700
- this.sharedService.groupItemMetadataProvider = this.groupItemMetadataProvider;
1701
- dataViewOptions = Object.assign(Object.assign({}, dataViewOptions), { groupItemMetadataProvider: this.groupItemMetadataProvider });
1702
- }
1703
- this.dataView = new Slick.Data.DataView(dataViewOptions);
1704
- this._eventPubSubService.publish('onDataviewCreated', this.dataView);
1705
- }
1706
- // get any possible Services that user want to register which don't require SlickGrid to be instantiated
1707
- // RxJS Resource is in this lot because it has to be registered before anything else and doesn't require SlickGrid to be initialized
1708
- this.preRegisterResources();
1709
- // for convenience to the user, we provide the property "editor" as an Angular-Slickgrid editor complex object
1710
- // however "editor" is used internally by SlickGrid for it's own Editor Factory
1711
- // so in our lib we will swap "editor" and copy it into a new property called "internalColumnEditor"
1712
- // then take back "editor.model" and make it the new "editor" so that SlickGrid Editor Factory still works
1713
- this._columnDefinitions = this.swapInternalEditorToSlickGridFactoryEditor(this._columnDefinitions);
1714
- // if the user wants to automatically add a Custom Editor Formatter, we need to call the auto add function again
1715
- if (this.gridOptions.autoAddCustomEditorFormatter) {
1716
- common.autoAddEditorFormatterToColumnsWithEditor(this._columnDefinitions, this.gridOptions.autoAddCustomEditorFormatter);
1717
- }
1718
- // save reference for all columns before they optionally become hidden/visible
1719
- this.sharedService.allColumns = this._columnDefinitions;
1720
- this.sharedService.visibleColumns = this._columnDefinitions;
1721
- this.extensionService.createExtensionsBeforeGridCreation(this._columnDefinitions, this.gridOptions);
1722
- // if user entered some Pinning/Frozen "presets", we need to apply them in the grid options
1723
- if ((_h = this.gridOptions.presets) === null || _h === void 0 ? void 0 : _h.pinning) {
1724
- this.gridOptions = Object.assign(Object.assign({}, this.gridOptions), this.gridOptions.presets.pinning);
1725
- }
1726
- // build SlickGrid Grid, also user might optionally pass a custom dataview (e.g. remote model)
1727
- this.slickGrid = new Slick.Grid("#" + this.gridId, this.customDataView || this.dataView, this._columnDefinitions, this.gridOptions);
1728
- this.sharedService.dataView = this.dataView;
1729
- this.sharedService.slickGrid = this.slickGrid;
1730
- this.extensionService.bindDifferentExtensions();
1731
- this.bindDifferentHooks(this.slickGrid, this.gridOptions, this.dataView);
1732
- // when it's a frozen grid, we need to keep the frozen column id for reference if we ever show/hide column from ColumnPicker/GridMenu afterward
1733
- var frozenColumnIndex = this.gridOptions.frozenColumn !== undefined ? this.gridOptions.frozenColumn : -1;
1734
- if (frozenColumnIndex >= 0 && frozenColumnIndex <= this._columnDefinitions.length) {
1735
- this.sharedService.frozenVisibleColumnId = this._columnDefinitions[frozenColumnIndex].id || '';
1736
- }
1737
- // get any possible Services that user want to register
1738
- this.registerResources();
1739
- // initialize the SlickGrid grid
1740
- this.slickGrid.init();
1741
- // initialized the resizer service only after SlickGrid is initialized
1742
- // if we don't we end up binding our resize to a grid element that doesn't yet exist in the DOM and the resizer service will fail silently (because it has a try/catch that unbinds the resize without throwing back)
1743
- if (this.gridContainerElement) {
1744
- this.resizerService.init(this.slickGrid, this.gridContainerElement);
1745
- }
1746
- // user could show a custom footer with the data metrics (dataset length and last updated timestamp)
1747
- if (!this.gridOptions.enablePagination && this.gridOptions.showCustomFooter && this.gridOptions.customFooterOptions && this.gridContainerElement) {
1748
- this.slickFooter = new customFooterComponent.SlickFooterComponent(this.slickGrid, this.gridOptions.customFooterOptions, this._eventPubSubService, this.translaterService);
1749
- this.slickFooter.renderFooter(this.gridContainerElement);
1750
- }
1751
- if (!this.customDataView && this.dataView) {
1752
- // load the data in the DataView (unless it's a hierarchical dataset, if so it will be loaded after the initial tree sort)
1753
- var initialDataset = ((_j = this.gridOptions) === null || _j === void 0 ? void 0 : _j.enableTreeData) ? this.sortTreeDataset(this._dataset) : this._dataset;
1754
- this.dataView.beginUpdate();
1755
- this.dataView.setItems(initialDataset || [], (_k = this.gridOptions.datasetIdPropertyName) !== null && _k !== void 0 ? _k : 'id');
1756
- this.dataView.endUpdate();
1757
- // if you don't want the items that are not visible (due to being filtered out or being on a different page)
1758
- // to stay selected, pass 'false' to the second arg
1759
- var selectionModel = this.slickGrid && this.slickGrid.getSelectionModel();
1760
- if (selectionModel && this.gridOptions && this.gridOptions.dataView && this.gridOptions.dataView.hasOwnProperty('syncGridSelection')) {
1761
- // if we are using a Backend Service, we will do an extra flag check, the reason is because it might have some unintended behaviors
1762
- // with the BackendServiceApi because technically the data in the page changes the DataView on every page change.
1763
- var preservedRowSelectionWithBackend = false;
1764
- if (this.gridOptions.backendServiceApi && this.gridOptions.dataView.hasOwnProperty('syncGridSelectionWithBackendService')) {
1765
- preservedRowSelectionWithBackend = this.gridOptions.dataView.syncGridSelectionWithBackendService;
1766
- }
1767
- var syncGridSelection = this.gridOptions.dataView.syncGridSelection;
1768
- if (typeof syncGridSelection === 'boolean') {
1769
- var preservedRowSelection = syncGridSelection;
1770
- if (!this._isLocalGrid) {
1771
- // when using BackendServiceApi, we'll be using the "syncGridSelectionWithBackendService" flag BUT "syncGridSelection" must also be set to True
1772
- preservedRowSelection = syncGridSelection && preservedRowSelectionWithBackend;
1773
- }
1774
- this.dataView.syncGridSelection(this.slickGrid, preservedRowSelection);
1775
- }
1776
- else if (typeof syncGridSelection === 'object') {
1777
- this.dataView.syncGridSelection(this.slickGrid, syncGridSelection.preserveHidden, syncGridSelection.preserveHiddenOnSelectionChange);
1778
- }
1779
- }
1780
- var datasetLn = this.dataView.getLength() || this._dataset && this._dataset.length || 0;
1781
- if (datasetLn > 0) {
1782
- if (!this._isDatasetInitialized && (this.gridOptions.enableCheckboxSelector || this.gridOptions.enableRowSelection)) {
1783
- this.loadRowSelectionPresetWhenExists();
1784
- }
1785
- this.loadFilterPresetsWhenDatasetInitialized();
1786
- this._isDatasetInitialized = true;
1787
- }
1788
- }
1789
- // user might want to hide the header row on page load but still have `enableFiltering: true`
1790
- // if that is the case, we need to hide the headerRow ONLY AFTER all filters got created & dataView exist
1791
- if (this._hideHeaderRowAfterPageLoad) {
1792
- this.showHeaderRow(false);
1793
- this.sharedService.hideHeaderRowAfterPageLoad = this._hideHeaderRowAfterPageLoad;
1794
- }
1795
- // publish & dispatch certain events
1796
- this._eventPubSubService.publish('onGridCreated', this.slickGrid);
1797
- // after the DataView is created & updated execute some processes
1798
- if (!this.customDataView) {
1799
- this.executeAfterDataviewCreated(this.slickGrid, this.gridOptions);
1800
- }
1801
- // bind resize ONLY after the dataView is ready
1802
- this.bindResizeHook(this.slickGrid, this.gridOptions);
1803
- // bind the Backend Service API callback functions only after the grid is initialized
1804
- // because the preProcess() and onInit() might get triggered
1805
- if ((_l = this.gridOptions) === null || _l === void 0 ? void 0 : _l.backendServiceApi) {
1806
- this.bindBackendCallbackFunctions(this.gridOptions);
1807
- }
1808
- // local grid, check if we need to show the Pagination
1809
- // if so then also check if there's any presets and finally initialize the PaginationService
1810
- // a local grid with Pagination presets will potentially have a different total of items, we'll need to get it from the DataView and update our total
1811
- if (((_m = this.gridOptions) === null || _m === void 0 ? void 0 : _m.enablePagination) && this._isLocalGrid) {
1812
- this.showPagination = true;
1813
- this.loadLocalGridPagination(this.dataset);
1814
- }
1815
- this._angularGridInstances = {
1816
- // Slick Grid & DataView objects
1817
- dataView: this.dataView,
1818
- slickGrid: this.slickGrid,
1819
- extensions: (_o = this.extensionService) === null || _o === void 0 ? void 0 : _o.extensionList,
1820
- // public methods
1821
- destroy: this.destroy.bind(this),
1822
- // return all available Services (non-singleton)
1823
- backendService: (_q = (_p = this.gridOptions) === null || _p === void 0 ? void 0 : _p.backendServiceApi) === null || _q === void 0 ? void 0 : _q.service,
1824
- filterService: this.filterService,
1825
- gridEventService: this.gridEventService,
1826
- gridStateService: this.gridStateService,
1827
- gridService: this.gridService,
1828
- groupingService: this.groupingService,
1829
- extensionService: this.extensionService,
1830
- paginationService: this.paginationService,
1831
- resizerService: this.resizerService,
1832
- sortService: this.sortService,
1833
- treeDataService: this.treeDataService,
1834
- };
1835
- // all instances (SlickGrid, DataView & all Services)
1836
- this._eventPubSubService.publish('onAngularGridCreated', this._angularGridInstances);
1837
- };
1838
- /**
1839
- * On a Pagination changed, we will trigger a Grid State changed with the new pagination info
1840
- * Also if we use Row Selection or the Checkbox Selector, we need to reset any selection
1841
- */
1842
- AngularSlickgridComponent.prototype.paginationChanged = function (pagination) {
1843
- var _a, _b;
1844
- var isSyncGridSelectionEnabled = (_b = (_a = this.gridStateService) === null || _a === void 0 ? void 0 : _a.needToPreserveRowSelection()) !== null && _b !== void 0 ? _b : false;
1845
- if (!isSyncGridSelectionEnabled && (this.gridOptions.enableRowSelection || this.gridOptions.enableCheckboxSelector)) {
1846
- this.slickGrid.setSelectedRows([]);
1847
- }
1848
- var pageNumber = pagination.pageNumber, pageSize = pagination.pageSize;
1849
- if (this.sharedService) {
1850
- if (pageSize !== undefined && pageNumber !== undefined) {
1851
- this.sharedService.currentPagination = { pageNumber: pageNumber, pageSize: pageSize };
1852
- }
1853
- }
1854
- this._eventPubSubService.publish('onGridStateChanged', {
1855
- change: { newValues: { pageNumber: pageNumber, pageSize: pageSize }, type: common.GridStateType.pagination },
1856
- gridState: this.gridStateService.getCurrentGridState()
1857
- });
1858
- this.cd.markForCheck();
1859
- };
1860
- /**
1861
- * When dataset changes, we need to refresh the entire grid UI & possibly resize it as well
1862
- * @param dataset
1863
- */
1864
- AngularSlickgridComponent.prototype.refreshGridData = function (dataset, totalCount) {
1865
- var _a, _b, _c, _d, _f, _g;
1866
- if (this.gridOptions && this.gridOptions.enableEmptyDataWarningMessage && Array.isArray(dataset)) {
1867
- var finalTotalCount = totalCount || dataset.length;
1868
- this.displayEmptyDataWarning(finalTotalCount < 1);
1869
- }
1870
- if (Array.isArray(dataset) && this.slickGrid && ((_a = this.dataView) === null || _a === void 0 ? void 0 : _a.setItems)) {
1871
- this.dataView.setItems(dataset, (_b = this.gridOptions.datasetIdPropertyName) !== null && _b !== void 0 ? _b : 'id');
1872
- if (!this.gridOptions.backendServiceApi && !this.gridOptions.enableTreeData) {
1873
- this.dataView.reSort();
1874
- }
1875
- if (dataset.length > 0) {
1876
- if (!this._isDatasetInitialized) {
1877
- this.loadFilterPresetsWhenDatasetInitialized();
1878
- if (this.gridOptions.enableCheckboxSelector) {
1879
- this.loadRowSelectionPresetWhenExists();
1880
- }
1881
- }
1882
- this._isDatasetInitialized = true;
1883
- }
1884
- if (dataset) {
1885
- this.slickGrid.invalidate();
1886
- }
1887
- // display the Pagination component only after calling this refresh data first, we call it here so that if we preset pagination page number it will be shown correctly
1888
- this.showPagination = (this.gridOptions && (this.gridOptions.enablePagination || (this.gridOptions.backendServiceApi && this.gridOptions.enablePagination === undefined))) ? true : false;
1889
- if (this._paginationOptions && ((_c = this.gridOptions) === null || _c === void 0 ? void 0 : _c.pagination) && ((_d = this.gridOptions) === null || _d === void 0 ? void 0 : _d.backendServiceApi)) {
1890
- var paginationOptions = this.setPaginationOptionsWhenPresetDefined(this.gridOptions, this._paginationOptions);
1891
- // when we have a totalCount use it, else we'll take it from the pagination object
1892
- // only update the total items if it's different to avoid refreshing the UI
1893
- var totalRecords = (totalCount !== undefined) ? totalCount : ((_g = (_f = this.gridOptions) === null || _f === void 0 ? void 0 : _f.pagination) === null || _g === void 0 ? void 0 : _g.totalItems);
1894
- if (totalRecords !== undefined && totalRecords !== this.totalItems) {
1895
- this.totalItems = +totalRecords;
1896
- }
1897
- // initialize the Pagination Service with new pagination options (which might have presets)
1898
- if (!this._isPaginationInitialized) {
1899
- this.initializePaginationService(paginationOptions);
1900
- }
1901
- else {
1902
- // update the pagination service with the new total
1903
- this.paginationService.updateTotalItems(this.totalItems);
1904
- }
1905
- }
1906
- // resize the grid inside a slight timeout, in case other DOM element changed prior to the resize (like a filter/pagination changed)
1907
- if (this.slickGrid && this.gridOptions.enableAutoResize) {
1908
- var delay = this.gridOptions.autoResize && this.gridOptions.autoResize.delay;
1909
- this.resizerService.resizeGrid(delay || 10);
1910
- }
1911
- }
1912
- };
1913
- /**
1914
- * Check if there's any Pagination Presets defined in the Grid Options,
1915
- * if there are then load them in the paginationOptions object
1916
- */
1917
- AngularSlickgridComponent.prototype.setPaginationOptionsWhenPresetDefined = function (gridOptions, paginationOptions) {
1918
- var _a;
1919
- if (((_a = gridOptions.presets) === null || _a === void 0 ? void 0 : _a.pagination) && paginationOptions && !this._isPaginationInitialized) {
1920
- paginationOptions.pageSize = gridOptions.presets.pagination.pageSize;
1921
- paginationOptions.pageNumber = gridOptions.presets.pagination.pageNumber;
1922
- }
1923
- return paginationOptions;
1924
- };
1925
- /**
1926
- * Dynamically change or update the column definitions list.
1927
- * We will re-render the grid so that the new header and data shows up correctly.
1928
- * If using i18n, we also need to trigger a re-translate of the column headers
1929
- */
1930
- AngularSlickgridComponent.prototype.updateColumnDefinitionsList = function (newColumnDefinitions) {
1931
- var _a, _b, _c;
1932
- // map/swap the internal library Editor to the SlickGrid Editor factory
1933
- newColumnDefinitions = this.swapInternalEditorToSlickGridFactoryEditor(newColumnDefinitions);
1934
- if (this.gridOptions.enableTranslate) {
1935
- this.extensionService.translateColumnHeaders(false, newColumnDefinitions);
1936
- }
1937
- else {
1938
- this.extensionService.renderColumnHeaders(newColumnDefinitions, true);
1939
- }
1940
- if ((_a = this.gridOptions) === null || _a === void 0 ? void 0 : _a.enableAutoSizeColumns) {
1941
- this.slickGrid.autosizeColumns();
1942
- }
1943
- else if (((_b = this.gridOptions) === null || _b === void 0 ? void 0 : _b.enableAutoResizeColumnsByCellContent) && ((_c = this.resizerService) === null || _c === void 0 ? void 0 : _c.resizeColumnsByCellContent)) {
1944
- this.resizerService.resizeColumnsByCellContent();
1945
- }
1946
- };
1947
- /**
1948
- * Show the filter row displayed on first row, we can optionally pass false to hide it.
1949
- * @param showing
1950
- */
1951
- AngularSlickgridComponent.prototype.showHeaderRow = function (showing) {
1952
- if (showing === void 0) { showing = true; }
1953
- this.slickGrid.setHeaderRowVisibility(showing, false);
1954
- if (showing === true && this._isGridInitialized) {
1955
- this.slickGrid.setColumns(this.columnDefinitions);
1956
- }
1957
- return showing;
1958
- };
1959
- //
1960
- // private functions
1961
- // ------------------
1962
- /**
1963
- * Loop through all column definitions and copy the original optional `width` properties optionally provided by the user.
1964
- * We will use this when doing a resize by cell content, if user provided a `width` it won't override it.
1965
- */
1966
- AngularSlickgridComponent.prototype.copyColumnWidthsReference = function (columnDefinitions) {
1967
- columnDefinitions.forEach(function (col) { return col.originalWidth = col.width; });
1968
- };
1969
- AngularSlickgridComponent.prototype.displayEmptyDataWarning = function (showWarning) {
1970
- if (showWarning === void 0) { showWarning = true; }
1971
- var _a;
1972
- (_a = this.slickEmptyWarning) === null || _a === void 0 ? void 0 : _a.showEmptyDataMessage(showWarning);
1973
- };
1974
- AngularSlickgridComponent.prototype.bindDifferentHooks = function (grid, gridOptions, dataView) {
1975
- var _this = this;
1976
- var _a, _b, _c, _d;
1977
- // on locale change, we have to manually translate the Headers, GridMenu
1978
- if ((_a = this.translate) === null || _a === void 0 ? void 0 : _a.onLangChange) {
1979
- // translate some of them on first load, then on each language change
1980
- if (gridOptions.enableTranslate) {
1981
- this.translateColumnHeaderTitleKeys();
1982
- this.translateColumnGroupKeys();
1983
- }
1984
- this.subscriptions.push(this.translate.onLangChange.subscribe(function () {
1985
- // publish event of the same name that Slickgrid-Universal uses on a language change event
1986
- _this._eventPubSubService.publish('onLanguageChange');
1987
- if (gridOptions.enableTranslate) {
1988
- _this.extensionService.translateCellMenu();
1989
- _this.extensionService.translateColumnHeaders();
1990
- _this.extensionService.translateColumnPicker();
1991
- _this.extensionService.translateContextMenu();
1992
- _this.extensionService.translateGridMenu();
1993
- _this.extensionService.translateHeaderMenu();
1994
- _this.translateColumnHeaderTitleKeys();
1995
- _this.translateColumnGroupKeys();
1996
- if (gridOptions.createPreHeaderPanel && !gridOptions.enableDraggableGrouping) {
1997
- _this.groupingService.translateGroupingAndColSpan();
1998
- }
1999
- }
2000
- }));
2001
- }
2002
- // if user set an onInit Backend, we'll run it right away (and if so, we also need to run preProcess, internalPostProcess & postProcess)
2003
- if (gridOptions.backendServiceApi) {
2004
- var backendApi = gridOptions.backendServiceApi;
2005
- if ((_b = backendApi === null || backendApi === void 0 ? void 0 : backendApi.service) === null || _b === void 0 ? void 0 : _b.init) {
2006
- backendApi.service.init(backendApi.options, gridOptions.pagination, this.slickGrid, this.sharedService);
2007
- }
2008
- }
2009
- if (dataView && grid) {
2010
- var slickgridEventPrefix_1 = (_d = (_c = this.gridOptions) === null || _c === void 0 ? void 0 : _c.defaultSlickgridEventPrefix) !== null && _d !== void 0 ? _d : '';
2011
- var _loop_1 = function (prop) {
2012
- if (grid.hasOwnProperty(prop) && prop.startsWith('on')) {
2013
- var gridEventHandler = grid[prop];
2014
- var gridEventName_1 = this_1._eventPubSubService.getEventNameByNamingConvention(prop, slickgridEventPrefix_1);
2015
- this_1._eventHandler.subscribe(gridEventHandler, function (event, args) {
2016
- return _this._eventPubSubService.dispatchCustomEvent(gridEventName_1, { eventData: event, args: args });
2017
- });
2018
- }
2019
- };
2020
- var this_1 = this;
2021
- // expose all Slick Grid Events through dispatch
2022
- for (var prop in grid) {
2023
- _loop_1(prop);
2024
- }
2025
- var _loop_2 = function (prop) {
2026
- if (dataView.hasOwnProperty(prop) && prop.startsWith('on')) {
2027
- var dataViewEventHandler = dataView[prop];
2028
- this_2._eventHandler.subscribe(dataViewEventHandler, function (event, args) {
2029
- var dataViewEventName = _this._eventPubSubService.getEventNameByNamingConvention(prop, slickgridEventPrefix_1);
2030
- return _this._eventPubSubService.dispatchCustomEvent(dataViewEventName, { eventData: event, args: args });
2031
- });
2032
- }
2033
- };
2034
- var this_2 = this;
2035
- // expose all Slick DataView Events through dispatch
2036
- for (var prop in dataView) {
2037
- _loop_2(prop);
2038
- }
2039
- // on cell click, mainly used with the columnDef.action callback
2040
- this.gridEventService.bindOnCellChange(grid);
2041
- this.gridEventService.bindOnClick(grid);
2042
- if (dataView && grid) {
2043
- // bind external sorting (backend) when available or default onSort (dataView)
2044
- if (gridOptions.enableSorting) {
2045
- // bind external sorting (backend) unless specified to use the local one
2046
- if (gridOptions.backendServiceApi && !gridOptions.backendServiceApi.useLocalSorting) {
2047
- this.sortService.bindBackendOnSort(grid);
2048
- }
2049
- else {
2050
- this.sortService.bindLocalOnSort(grid);
2051
- }
2052
- }
2053
- // bind external filter (backend) when available or default onFilter (dataView)
2054
- if (gridOptions.enableFiltering) {
2055
- this.filterService.init(grid);
2056
- // bind external filter (backend) unless specified to use the local one
2057
- if (gridOptions.backendServiceApi && !gridOptions.backendServiceApi.useLocalFiltering) {
2058
- this.filterService.bindBackendOnFilter(grid);
2059
- }
2060
- else {
2061
- this.filterService.bindLocalOnFilter(grid);
2062
- }
2063
- }
2064
- // load any presets if any (after dataset is initialized)
2065
- this.loadColumnPresetsWhenDatasetInitialized();
2066
- this.loadFilterPresetsWhenDatasetInitialized();
2067
- // When data changes in the DataView, we need to refresh the metrics and/or display a warning if the dataset is empty
2068
- var onRowCountChangedHandler = dataView.onRowCountChanged;
2069
- this._eventHandler.subscribe(onRowCountChangedHandler, function (_e, args) {
2070
- grid.invalidate();
2071
- _this.handleOnItemCountChanged(_this.dataView.getFilteredItemCount() || 0, dataView.getItemCount());
2072
- });
2073
- var onSetItemsCalledHandler = dataView.onSetItemsCalled;
2074
- this._eventHandler.subscribe(onSetItemsCalledHandler, function (_e, args) {
2075
- var _a;
2076
- grid.invalidate();
2077
- _this.handleOnItemCountChanged(_this.dataView.getFilteredItemCount(), args.itemCount);
2078
- // when user has resize by content enabled, we'll force a full width calculation since we change our entire dataset
2079
- if (args.itemCount > 0 && (_this.gridOptions.autosizeColumnsByCellContentOnFirstLoad || _this.gridOptions.enableAutoResizeColumnsByCellContent)) {
2080
- _this.resizerService.resizeColumnsByCellContent(!((_a = _this.gridOptions) === null || _a === void 0 ? void 0 : _a.resizeByContentOnlyOnFirstLoad));
2081
- }
2082
- });
2083
- var onRowsChangedHandler = dataView.onRowsChanged;
2084
- this._eventHandler.subscribe(onRowsChangedHandler, function (_e, args) {
2085
- // filtering data with local dataset will not always show correctly unless we call this updateRow/render
2086
- // also don't use "invalidateRows" since it destroys the entire row and as bad user experience when updating a row
2087
- // see commit: https://github.com/ghiscoding/aurelia-slickgrid/commit/8c503a4d45fba11cbd8d8cc467fae8d177cc4f60
2088
- if (gridOptions && gridOptions.enableFiltering && !gridOptions.enableRowDetailView) {
2089
- if ((args === null || args === void 0 ? void 0 : args.rows) && Array.isArray(args.rows)) {
2090
- args.rows.forEach(function (row) { return grid.updateRow(row); });
2091
- grid.render();
2092
- }
2093
- }
2094
- });
2095
- }
2096
- }
2097
- // did the user add a colspan callback? If so, hook it into the DataView getItemMetadata
2098
- if (gridOptions && gridOptions.colspanCallback && dataView && dataView.getItem && dataView.getItemMetadata) {
2099
- dataView.getItemMetadata = function (rowNumber) {
2100
- var callbackResult = null;
2101
- if (gridOptions.colspanCallback && gridOptions.colspanCallback) {
2102
- callbackResult = gridOptions.colspanCallback(dataView.getItem(rowNumber));
2103
- }
2104
- return callbackResult;
2105
- };
2106
- }
2107
- };
2108
- AngularSlickgridComponent.prototype.bindBackendCallbackFunctions = function (gridOptions) {
2109
- var _this = this;
2110
- var _a;
2111
- var backendApi = gridOptions.backendServiceApi;
2112
- var backendApiService = backendApi && backendApi.service;
2113
- var serviceOptions = (_a = backendApiService === null || backendApiService === void 0 ? void 0 : backendApiService.options) !== null && _a !== void 0 ? _a : {};
2114
- var isExecuteCommandOnInit = (!serviceOptions) ? false : ((serviceOptions && serviceOptions.hasOwnProperty('executeProcessCommandOnInit')) ? serviceOptions['executeProcessCommandOnInit'] : true);
2115
- if (backendApiService) {
2116
- // update backend filters (if need be) BEFORE the query runs (via the onInit command a few lines below)
2117
- // if user entered some any "presets", we need to reflect them all in the grid
2118
- if (gridOptions && gridOptions.presets) {
2119
- // Filters "presets"
2120
- if (backendApiService.updateFilters && Array.isArray(gridOptions.presets.filters) && gridOptions.presets.filters.length > 0) {
2121
- backendApiService.updateFilters(gridOptions.presets.filters, true);
2122
- }
2123
- // Sorters "presets"
2124
- if (backendApiService.updateSorters && Array.isArray(gridOptions.presets.sorters) && gridOptions.presets.sorters.length > 0) {
2125
- // when using multi-column sort, we can have multiple but on single sort then only grab the first sort provided
2126
- var sortColumns = this.gridOptions.multiColumnSort ? gridOptions.presets.sorters : gridOptions.presets.sorters.slice(0, 1);
2127
- backendApiService.updateSorters(undefined, sortColumns);
2128
- }
2129
- // Pagination "presets"
2130
- if (backendApiService.updatePagination && gridOptions.presets.pagination) {
2131
- var _s = gridOptions.presets.pagination, pageNumber = _s.pageNumber, pageSize = _s.pageSize;
2132
- backendApiService.updatePagination(pageNumber, pageSize);
2133
- }
2134
- }
2135
- else {
2136
- var columnFilters = this.filterService.getColumnFilters();
2137
- if (columnFilters && backendApiService.updateFilters) {
2138
- backendApiService.updateFilters(columnFilters, false);
2139
- }
2140
- }
2141
- // execute onInit command when necessary
2142
- if (backendApi && backendApiService && (backendApi.onInit || isExecuteCommandOnInit)) {
2143
- var query = (typeof backendApiService.buildQuery === 'function') ? backendApiService.buildQuery() : '';
2144
- var process_1 = (isExecuteCommandOnInit) ? (backendApi.process && backendApi.process(query) || null) : (backendApi.onInit && backendApi.onInit(query) || null);
2145
- // wrap this inside a setTimeout to avoid timing issue since the gridOptions needs to be ready before running this onInit
2146
- setTimeout(function () {
2147
- var _a, _b, _c, _d;
2148
- var backendUtilityService = _this.backendUtilityService;
2149
- // keep start time & end timestamps & return it after process execution
2150
- var startTime = new Date();
2151
- // run any pre-process, if defined, for example a spinner
2152
- if (backendApi.preProcess) {
2153
- backendApi.preProcess();
2154
- }
2155
- // the processes can be a Promise (like Http)
2156
- var totalItems = (_c = (_b = (_a = _this.gridOptions) === null || _a === void 0 ? void 0 : _a.pagination) === null || _b === void 0 ? void 0 : _b.totalItems) !== null && _c !== void 0 ? _c : 0;
2157
- if (process_1 instanceof Promise) {
2158
- process_1
2159
- .then(function (processResult) { return backendUtilityService.executeBackendProcessesCallback(startTime, processResult, backendApi, totalItems); })
2160
- .catch(function (error) { return backendUtilityService.onBackendError(error, backendApi); });
2161
- }
2162
- else if (process_1 && ((_d = _this.rxjs) === null || _d === void 0 ? void 0 : _d.isObservable(process_1))) {
2163
- _this.subscriptions.push(process_1.subscribe({
2164
- next: function (processResult) { return backendUtilityService.executeBackendProcessesCallback(startTime, processResult, backendApi, totalItems); },
2165
- error: function (error) { return backendUtilityService.onBackendError(error, backendApi); }
2166
- }));
2167
- }
2168
- });
2169
- }
2170
- }
2171
- };
2172
- AngularSlickgridComponent.prototype.bindResizeHook = function (grid, options) {
2173
- if ((options.autoFitColumnsOnFirstLoad && options.autosizeColumnsByCellContentOnFirstLoad) || (options.enableAutoSizeColumns && options.enableAutoResizeColumnsByCellContent)) {
2174
- throw new Error("[Angular-Slickgrid] You cannot enable both autosize/fit viewport & resize by content, you must choose which resize technique to use. You can enable these 2 options (\"autoFitColumnsOnFirstLoad\" and \"enableAutoSizeColumns\") OR these other 2 options (\"autosizeColumnsByCellContentOnFirstLoad\" and \"enableAutoResizeColumnsByCellContent\").");
2175
- }
2176
- // expand/autofit columns on first page load
2177
- if (grid && options.autoFitColumnsOnFirstLoad && options.enableAutoSizeColumns) {
2178
- grid.autosizeColumns();
2179
- }
2180
- // auto-resize grid on browser resize
2181
- if (options.gridHeight || options.gridWidth) {
2182
- this.resizerService.resizeGrid(0, { height: options.gridHeight, width: options.gridWidth });
2183
- }
2184
- else {
2185
- this.resizerService.resizeGrid();
2186
- }
2187
- if (options.enableAutoResize) {
2188
- if (grid && options.autoFitColumnsOnFirstLoad && options.enableAutoSizeColumns) {
2189
- grid.autosizeColumns();
2190
- }
2191
- }
2192
- };
2193
- AngularSlickgridComponent.prototype.executeAfterDataviewCreated = function (_grid, gridOptions) {
2194
- // if user entered some Sort "presets", we need to reflect them all in the DOM
2195
- if (gridOptions.enableSorting) {
2196
- if (gridOptions.presets && Array.isArray(gridOptions.presets.sorters)) {
2197
- // when using multi-column sort, we can have multiple but on single sort then only grab the first sort provided
2198
- var sortColumns = this.gridOptions.multiColumnSort ? gridOptions.presets.sorters : gridOptions.presets.sorters.slice(0, 1);
2199
- this.sortService.loadGridSorters(sortColumns);
2200
- }
2201
- }
2202
- };
2203
- /** When data changes in the DataView, we'll refresh the metrics and/or display a warning if the dataset is empty */
2204
- AngularSlickgridComponent.prototype.handleOnItemCountChanged = function (currentPageRowItemCount, totalItemCount) {
2205
- var _a;
2206
- this._currentDatasetLength = totalItemCount;
2207
- this.metrics = {
2208
- startTime: new Date(),
2209
- endTime: new Date(),
2210
- itemCount: currentPageRowItemCount,
2211
- totalItemCount: totalItemCount
2212
- };
2213
- // if custom footer is enabled, then we'll update its metrics
2214
- if (this.slickFooter) {
2215
- this.slickFooter.metrics = this.metrics;
2216
- }
2217
- // when using local (in-memory) dataset, we'll display a warning message when filtered data is empty
2218
- if (this._isLocalGrid && ((_a = this.gridOptions) === null || _a === void 0 ? void 0 : _a.enableEmptyDataWarningMessage)) {
2219
- this.displayEmptyDataWarning(currentPageRowItemCount === 0);
2220
- }
2221
- };
2222
- AngularSlickgridComponent.prototype.initializePaginationService = function (paginationOptions) {
2223
- var _this = this;
2224
- if (this.gridOptions) {
2225
- this.paginationData = {
2226
- gridOptions: this.gridOptions,
2227
- paginationService: this.paginationService,
2228
- };
2229
- this.paginationService.totalItems = this.totalItems;
2230
- this.paginationService.init(this.slickGrid, paginationOptions, this.backendServiceApi);
2231
- this.subscriptions.push(this._eventPubSubService.subscribe('onPaginationChanged', function (paginationChanges) {
2232
- _this.paginationChanged(paginationChanges);
2233
- }), this._eventPubSubService.subscribe('onPaginationVisibilityChanged', function (visibility) {
2234
- var _a, _b, _c;
2235
- _this.showPagination = (_a = visibility === null || visibility === void 0 ? void 0 : visibility.visible) !== null && _a !== void 0 ? _a : false;
2236
- if ((_b = _this.gridOptions) === null || _b === void 0 ? void 0 : _b.backendServiceApi) {
2237
- (_c = _this.backendUtilityService) === null || _c === void 0 ? void 0 : _c.refreshBackendDataset(_this.gridOptions);
2238
- }
2239
- _this.renderPagination(_this.showPagination);
2240
- }));
2241
- // also initialize (render) the pagination component
2242
- this.renderPagination();
2243
- this._isPaginationInitialized = true;
2244
- }
2245
- this.cd.detectChanges();
2246
- };
2247
- /** Load the Editor Collection asynchronously and replace the "collection" property when Observable resolves */
2248
- AngularSlickgridComponent.prototype.loadEditorCollectionAsync = function (column) {
2249
- var _this = this;
2250
- var collectionAsync = column && column.editor && column.editor.collectionAsync;
2251
- if (collectionAsync instanceof rxjs.Observable) {
2252
- this.subscriptions.push(collectionAsync.subscribe(function (resolvedCollection) { return _this.updateEditorCollection(column, resolvedCollection); }));
2253
- }
2254
- else if (collectionAsync instanceof Promise) {
2255
- // wait for the "collectionAsync", once resolved we will save it into the "collection"
2256
- // the collectionAsync can be of 3 types HttpClient, HttpFetch or a Promise
2257
- collectionAsync.then(function (response) {
2258
- if (Array.isArray(response)) {
2259
- _this.updateEditorCollection(column, response); // from Promise
2260
- }
2261
- });
2262
- }
2263
- };
2264
- /** Load any possible Columns Grid Presets */
2265
- AngularSlickgridComponent.prototype.loadColumnPresetsWhenDatasetInitialized = function () {
2266
- // if user entered some Columns "presets", we need to reflect them all in the grid
2267
- if (this.gridOptions.presets && Array.isArray(this.gridOptions.presets.columns) && this.gridOptions.presets.columns.length > 0) {
2268
- var gridColumns = this.gridStateService.getAssociatedGridColumns(this.slickGrid, this.gridOptions.presets.columns);
2269
- if (gridColumns && Array.isArray(gridColumns) && gridColumns.length > 0) {
2270
- // make sure that the checkbox selector is also visible if it is enabled
2271
- if (this.gridOptions.enableCheckboxSelector) {
2272
- var checkboxColumn = (Array.isArray(this._columnDefinitions) && this._columnDefinitions.length > 0) ? this._columnDefinitions[0] : null;
2273
- if (checkboxColumn && checkboxColumn.id === '_checkbox_selector' && gridColumns[0].id !== '_checkbox_selector') {
2274
- gridColumns.unshift(checkboxColumn);
2275
- }
2276
- }
2277
- // keep copy the original optional `width` properties optionally provided by the user.
2278
- // We will use this when doing a resize by cell content, if user provided a `width` it won't override it.
2279
- gridColumns.forEach(function (col) { return col.originalWidth = col.width; });
2280
- // finally set the new presets columns (including checkbox selector if need be)
2281
- this.slickGrid.setColumns(gridColumns);
2282
- this.sharedService.visibleColumns = gridColumns;
2283
- }
2284
- }
2285
- };
2286
- /** Load any possible Filters Grid Presets */
2287
- AngularSlickgridComponent.prototype.loadFilterPresetsWhenDatasetInitialized = function () {
2288
- var _a, _b, _c;
2289
- if (this.gridOptions && !this.customDataView) {
2290
- // if user entered some Filter "presets", we need to reflect them all in the DOM
2291
- // also note that a presets of Tree Data Toggling will also call this method because Tree Data toggling does work with data filtering
2292
- // (collapsing a parent will basically use Filter for hidding (aka collapsing) away the child underneat it)
2293
- if (this.gridOptions.presets && (Array.isArray(this.gridOptions.presets.filters) || Array.isArray((_b = (_a = this.gridOptions.presets) === null || _a === void 0 ? void 0 : _a.treeData) === null || _b === void 0 ? void 0 : _b.toggledItems))) {
2294
- this.filterService.populateColumnFilterSearchTermPresets(((_c = this.gridOptions.presets) === null || _c === void 0 ? void 0 : _c.filters) || []);
2295
- }
2296
- }
2297
- };
2298
- /**
2299
- * local grid, check if we need to show the Pagination
2300
- * if so then also check if there's any presets and finally initialize the PaginationService
2301
- * a local grid with Pagination presets will potentially have a different total of items, we'll need to get it from the DataView and update our total
2302
- */
2303
- AngularSlickgridComponent.prototype.loadLocalGridPagination = function (dataset) {
2304
- var _a;
2305
- if (this.gridOptions && this._paginationOptions) {
2306
- this.totalItems = Array.isArray(dataset) ? dataset.length : 0;
2307
- if (this._paginationOptions && ((_a = this.dataView) === null || _a === void 0 ? void 0 : _a.getPagingInfo)) {
2308
- var slickPagingInfo = this.dataView.getPagingInfo();
2309
- if ((slickPagingInfo === null || slickPagingInfo === void 0 ? void 0 : slickPagingInfo.hasOwnProperty('totalRows')) && this._paginationOptions.totalItems !== slickPagingInfo.totalRows) {
2310
- this.totalItems = slickPagingInfo.totalRows || 0;
2311
- }
2312
- }
2313
- this._paginationOptions.totalItems = this.totalItems;
2314
- var paginationOptions = this.setPaginationOptionsWhenPresetDefined(this.gridOptions, this._paginationOptions);
2315
- this.initializePaginationService(paginationOptions);
2316
- }
2317
- };
2318
- /** Load any Row Selections into the DataView that were presets by the user */
2319
- AngularSlickgridComponent.prototype.loadRowSelectionPresetWhenExists = function () {
2320
- var _this = this;
2321
- var _a, _b, _c;
2322
- // if user entered some Row Selections "presets"
2323
- var presets = (_a = this.gridOptions) === null || _a === void 0 ? void 0 : _a.presets;
2324
- var selectionModel = (_c = (_b = this.slickGrid) === null || _b === void 0 ? void 0 : _b.getSelectionModel) === null || _c === void 0 ? void 0 : _c.call(_b);
2325
- var enableRowSelection = this.gridOptions && (this.gridOptions.enableCheckboxSelector || this.gridOptions.enableRowSelection);
2326
- if (enableRowSelection && selectionModel && presets && presets.rowSelection && (Array.isArray(presets.rowSelection.gridRowIndexes) || Array.isArray(presets.rowSelection.dataContextIds))) {
2327
- var dataContextIds = presets.rowSelection.dataContextIds;
2328
- var gridRowIndexes_1 = presets.rowSelection.gridRowIndexes;
2329
- // maps the IDs to the Grid Rows and vice versa, the "dataContextIds" has precedence over the other
2330
- if (Array.isArray(dataContextIds) && dataContextIds.length > 0) {
2331
- gridRowIndexes_1 = this.dataView.mapIdsToRows(dataContextIds) || [];
2332
- }
2333
- else if (Array.isArray(gridRowIndexes_1) && gridRowIndexes_1.length > 0) {
2334
- dataContextIds = this.dataView.mapRowsToIds(gridRowIndexes_1) || [];
2335
- }
2336
- this.gridStateService.selectedRowDataContextIds = dataContextIds;
2337
- // change the selected rows except UNLESS it's a Local Grid with Pagination
2338
- // local Pagination uses the DataView and that also trigger a change/refresh
2339
- // and we don't want to trigger 2 Grid State changes just 1
2340
- if ((this._isLocalGrid && !this.gridOptions.enablePagination) || !this._isLocalGrid) {
2341
- setTimeout(function () {
2342
- if (_this.slickGrid && Array.isArray(gridRowIndexes_1)) {
2343
- _this.slickGrid.setSelectedRows(gridRowIndexes_1);
2344
- }
2345
- });
2346
- }
2347
- }
2348
- };
2349
- AngularSlickgridComponent.prototype.mergeGridOptions = function (gridOptions) {
2350
- gridOptions.gridId = this.gridId;
2351
- gridOptions.gridContainerId = "slickGridContainer-" + this.gridId;
2352
- // if we have a backendServiceApi and the enablePagination is undefined, we'll assume that we do want to see it, else get that defined value
2353
- gridOptions.enablePagination = ((gridOptions.backendServiceApi && gridOptions.enablePagination === undefined) ? true : gridOptions.enablePagination) || false;
2354
- // use jquery extend to deep merge & copy to avoid immutable properties being changed in GlobalGridOptions after a route change
2355
- var options = $.extend(true, {}, GlobalGridOptions, this.forRootConfig, gridOptions);
2356
- // using jQuery extend to do a deep clone has an unwanted side on objects and pageSizes but ES6 spread has other worst side effects
2357
- // so we will just overwrite the pageSizes when needed, this is the only one causing issues so far.
2358
- // jQuery wrote this on their docs:: On a deep extend, Object and Array are extended, but object wrappers on primitive types such as String, Boolean, and Number are not.
2359
- if ((options === null || options === void 0 ? void 0 : options.pagination) && (gridOptions.enablePagination || gridOptions.backendServiceApi) && gridOptions.pagination && Array.isArray(gridOptions.pagination.pageSizes)) {
2360
- options.pagination.pageSizes = gridOptions.pagination.pageSizes;
2361
- }
2362
- // also make sure to show the header row if user have enabled filtering
2363
- this._hideHeaderRowAfterPageLoad = (options.showHeaderRow === false);
2364
- if (options.enableFiltering && !options.showHeaderRow) {
2365
- options.showHeaderRow = options.enableFiltering;
2366
- }
2367
- // when we use Pagination on Local Grid, it doesn't seem to work without enableFiltering
2368
- // so we'll enable the filtering but we'll keep the header row hidden
2369
- if (options && !options.enableFiltering && options.enablePagination && this._isLocalGrid) {
2370
- options.enableFiltering = true;
2371
- options.showHeaderRow = false;
2372
- this._hideHeaderRowAfterPageLoad = true;
2373
- if (this.sharedService) {
2374
- this.sharedService.hideHeaderRowAfterPageLoad = true;
2375
- }
2376
- }
2377
- return options;
2378
- };
2379
- /** Pre-Register any Resource that don't require SlickGrid to be instantiated (for example RxJS Resource) */
2380
- AngularSlickgridComponent.prototype.preRegisterResources = function () {
2381
- this._registeredResources = this.gridOptions.registerExternalResources || [];
2382
- // Angular-Slickgrid requires RxJS, so we'll register it as the first resource
2383
- this.registerRxJsResource(new rxjsObservable.RxJsResource());
2384
- };
2385
- AngularSlickgridComponent.prototype.registerResources = function () {
2386
- var e_4, _s;
2387
- // at this point, we consider all the registered services as external services, anything else registered afterward aren't external
2388
- if (Array.isArray(this._registeredResources)) {
2389
- this.sharedService.externalRegisteredResources = this._registeredResources;
2390
- }
2391
- // push all other Services that we want to be registered
2392
- this._registeredResources.push(this.gridService, this.gridStateService);
2393
- // when using Grouping/DraggableGrouping/Colspan register its Service
2394
- if (this.gridOptions.createPreHeaderPanel && !this.gridOptions.enableDraggableGrouping) {
2395
- this._registeredResources.push(this.groupingService);
2396
- }
2397
- // when using Tree Data View, register its Service
2398
- if (this.gridOptions.enableTreeData) {
2399
- this._registeredResources.push(this.treeDataService);
2400
- }
2401
- // when user enables translation, we need to translate Headers on first pass & subsequently in the bindDifferentHooks
2402
- if (this.gridOptions.enableTranslate) {
2403
- this.extensionService.translateColumnHeaders();
2404
- }
2405
- // also initialize (render) the empty warning component
2406
- this.slickEmptyWarning = new emptyWarningComponent.SlickEmptyWarningComponent();
2407
- this._registeredResources.push(this.slickEmptyWarning);
2408
- // bind & initialize all Components/Services that were tagged as enabled
2409
- // register all services by executing their init method and providing them with the Grid object
2410
- if (Array.isArray(this._registeredResources)) {
2411
- try {
2412
- for (var _t = __values(this._registeredResources), _u = _t.next(); !_u.done; _u = _t.next()) {
2413
- var resource = _u.value;
2414
- if (typeof resource.init === 'function') {
2415
- resource.init(this.slickGrid, this.containerService);
2416
- }
2417
- }
2418
- }
2419
- catch (e_4_1) { e_4 = { error: e_4_1 }; }
2420
- finally {
2421
- try {
2422
- if (_u && !_u.done && (_s = _t.return)) _s.call(_t);
2423
- }
2424
- finally { if (e_4) throw e_4.error; }
2425
- }
2426
- }
2427
- };
2428
- /** Register the RxJS Resource in all necessary services which uses */
2429
- AngularSlickgridComponent.prototype.registerRxJsResource = function (resource) {
2430
- this.rxjs = resource;
2431
- this.backendUtilityService.addRxJsResource(this.rxjs);
2432
- this.filterFactory.addRxJsResource(this.rxjs);
2433
- this.filterService.addRxJsResource(this.rxjs);
2434
- this.sortService.addRxJsResource(this.rxjs);
2435
- this.paginationService.addRxJsResource(this.rxjs);
2436
- this.containerService.registerInstance('RxJsResource', this.rxjs);
2437
- };
2438
- /**
2439
- * Render (or dispose) the Pagination Component, user can optionally provide False (to not show it) which will in term dispose of the Pagination,
2440
- * also while disposing we can choose to omit the disposable of the Pagination Service (if we are simply toggling the Pagination, we want to keep the Service alive)
2441
- * @param {Boolean} showPagination - show (new render) or not (dispose) the Pagination
2442
- * @param {Boolean} shouldDisposePaginationService - when disposing the Pagination, do we also want to dispose of the Pagination Service? (defaults to True)
2443
- */
2444
- AngularSlickgridComponent.prototype.renderPagination = function (showPagination) {
2445
- if (showPagination === void 0) { showPagination = true; }
2446
- var _a;
2447
- if (((_a = this.gridOptions) === null || _a === void 0 ? void 0 : _a.enablePagination) && !this._isPaginationInitialized && showPagination) {
2448
- this.slickPagination = new paginationComponent.SlickPaginationComponent(this.paginationService, this._eventPubSubService, this.sharedService, this.translaterService);
2449
- this.slickPagination.renderPagination(this.gridContainerElement);
2450
- this._isPaginationInitialized = true;
2451
- }
2452
- else if (!showPagination) {
2453
- if (this.slickPagination) {
2454
- this.slickPagination.dispose();
2455
- }
2456
- this._isPaginationInitialized = false;
2457
- }
2458
- };
2459
- /**
2460
- * Takes a flat dataset with parent/child relationship, sort it (via its tree structure) and return the sorted flat array
2461
- * @param {Array<Object>} flatDatasetInput - flat dataset input
2462
- * @param {Boolean} forceGridRefresh - optionally force a full grid refresh
2463
- * @returns {Array<Object>} sort flat parent/child dataset
2464
- */
2465
- AngularSlickgridComponent.prototype.sortTreeDataset = function (flatDatasetInput, forceGridRefresh) {
2466
- if (forceGridRefresh === void 0) { forceGridRefresh = false; }
2467
- var _a, _b;
2468
- var prevDatasetLn = this._currentDatasetLength;
2469
- var sortedDatasetResult;
2470
- var flatDatasetOutput = [];
2471
- // if the hierarchical dataset was already initialized then no need to re-convert it, we can use it directly from the shared service ref
2472
- if (this._isDatasetHierarchicalInitialized && this.datasetHierarchical) {
2473
- sortedDatasetResult = this.treeDataService.sortHierarchicalDataset(this.datasetHierarchical);
2474
- flatDatasetOutput = sortedDatasetResult.flat;
2475
- }
2476
- else if (Array.isArray(flatDatasetInput) && flatDatasetInput.length > 0) {
2477
- if ((_b = (_a = this.gridOptions) === null || _a === void 0 ? void 0 : _a.treeDataOptions) === null || _b === void 0 ? void 0 : _b.initialSort) {
2478
- // else we need to first convert the flat dataset to a hierarchical dataset and then sort
2479
- sortedDatasetResult = this.treeDataService.convertFlatParentChildToTreeDatasetAndSort(flatDatasetInput, this._columnDefinitions, this.gridOptions);
2480
- this.sharedService.hierarchicalDataset = sortedDatasetResult.hierarchical;
2481
- flatDatasetOutput = sortedDatasetResult.flat;
2482
- }
2483
- else {
2484
- // else we assume that the user provided an array that is already sorted (user's responsability)
2485
- // and so we can simply convert the array to a tree structure and we're done, no need to sort
2486
- this.sharedService.hierarchicalDataset = this.treeDataService.convertFlatParentChildToTreeDataset(flatDatasetInput, this.gridOptions);
2487
- flatDatasetOutput = flatDatasetInput || [];
2488
- }
2489
- }
2490
- // if we add/remove item(s) from the dataset, we need to also refresh our tree data filters
2491
- if (flatDatasetInput.length > 0 && (forceGridRefresh || flatDatasetInput.length !== prevDatasetLn)) {
2492
- this.filterService.refreshTreeDataFilters(flatDatasetOutput);
2493
- }
2494
- return flatDatasetOutput;
2495
- };
2496
- /**
2497
- * For convenience to the user, we provide the property "editor" as an Angular-Slickgrid editor complex object
2498
- * however "editor" is used internally by SlickGrid for it's own Editor Factory
2499
- * so in our lib we will swap "editor" and copy it into a new property called "internalColumnEditor"
2500
- * then take back "editor.model" and make it the new "editor" so that SlickGrid Editor Factory still works
2501
- */
2502
- AngularSlickgridComponent.prototype.swapInternalEditorToSlickGridFactoryEditor = function (columnDefinitions) {
2503
- var _this = this;
2504
- if (columnDefinitions.some(function (col) { return ("" + col.id).includes('.'); })) {
2505
- console.error('[Angular-Slickgrid] Make sure that none of your Column Definition "id" property includes a dot in its name because that will cause some problems with the Editors. For example if your column definition "field" property is "user.firstName" then use "firstName" as the column "id".');
2506
- }
2507
- return columnDefinitions.map(function (column) {
2508
- // on every Editor that have a "collectionAsync", resolve the data and assign it to the "collection" property
2509
- if (column && column.editor && column.editor.collectionAsync) {
2510
- _this.loadEditorCollectionAsync(column);
2511
- }
2512
- return Object.assign(Object.assign({}, column), { editor: column.editor && column.editor.model, internalColumnEditor: Object.assign({}, column.editor) });
2513
- });
2514
- };
2515
- AngularSlickgridComponent.prototype.translateColumnHeaderTitleKeys = function () {
2516
- // translate all columns (including hidden columns)
2517
- this.extensionUtility.translateItems(this.sharedService.allColumns, 'nameKey', 'name');
2518
- };
2519
- AngularSlickgridComponent.prototype.translateColumnGroupKeys = function () {
2520
- // translate all column groups (including hidden columns)
2521
- this.extensionUtility.translateItems(this.sharedService.allColumns, 'columnGroupKey', 'columnGroup');
2522
- };
2523
- /**
2524
- * Update the "internalColumnEditor.collection" property.
2525
- * Since this is called after the async call resolves, the pointer will not be the same as the "column" argument passed.
2526
- * Once we found the new pointer, we will reassign the "editor" and "collection" to the "internalColumnEditor" so it has newest collection
2527
- */
2528
- AngularSlickgridComponent.prototype.updateEditorCollection = function (column, newCollection) {
2529
- column.editor.collection = newCollection;
2530
- column.editor.disabled = false;
2531
- // find the new column reference pointer & re-assign the new editor to the internalColumnEditor
2532
- var columns = this.slickGrid.getColumns();
2533
- if (Array.isArray(columns)) {
2534
- var columnRef = columns.find(function (col) { return col.id === column.id; });
2535
- if (columnRef) {
2536
- columnRef.internalColumnEditor = column.editor;
2537
- }
2538
- }
2539
- // get current Editor, remove it from the DOM then re-enable it and re-render it with the new collection.
2540
- var currentEditor = this.slickGrid.getCellEditor();
2541
- if ((currentEditor === null || currentEditor === void 0 ? void 0 : currentEditor.disable) && (currentEditor === null || currentEditor === void 0 ? void 0 : currentEditor.renderDomElement)) {
2542
- currentEditor.destroy();
2543
- currentEditor.disable(false);
2544
- currentEditor.renderDomElement(newCollection);
2545
- }
2546
- };
2547
- return AngularSlickgridComponent;
2548
- }());
2549
- AngularSlickgridComponent.decorators = [
2550
- { type: core.Component, args: [{
2551
- selector: 'angular-slickgrid',
2552
- template: "<div id=\"slickGridContainer-{{gridId}}\" class=\"gridPane\">\r\n <div attr.id='{{gridId}}' class=\"slickgrid-container\" style=\"width: 100%\">\r\n </div>\r\n</div>",
2553
- providers: [
2554
- // make everything transient (non-singleton)
2555
- AngularUtilService,
2556
- core.ApplicationRef,
2557
- RowDetailViewExtension,
2558
- TranslaterService,
2559
- ]
2560
- },] }
2561
- ];
2562
- AngularSlickgridComponent.ctorParameters = function () { return [
2563
- { type: AngularUtilService },
2564
- { type: core.ApplicationRef },
2565
- { type: core.ChangeDetectorRef },
2566
- { type: ContainerService },
2567
- { type: core.ElementRef },
2568
- { type: core$1.TranslateService, decorators: [{ type: core.Optional }] },
2569
- { type: TranslaterService, decorators: [{ type: core.Optional }] },
2570
- { type: undefined, decorators: [{ type: core.Inject, args: ['config',] }] },
2571
- { type: undefined, decorators: [{ type: core.Inject, args: ['externalService',] }] }
2572
- ]; };
2573
- AngularSlickgridComponent.propDecorators = {
2574
- customDataView: [{ type: core.Input }],
2575
- gridId: [{ type: core.Input }],
2576
- gridOptions: [{ type: core.Input }],
2577
- paginationOptions: [{ type: core.Input }],
2578
- columnDefinitions: [{ type: core.Input }],
2579
- dataset: [{ type: core.Input }],
2580
- datasetHierarchical: [{ type: core.Input }]
2581
- };
2582
-
2583
- var AngularSlickgridModule = /** @class */ (function () {
2584
- function AngularSlickgridModule() {
2585
- }
2586
- AngularSlickgridModule.forRoot = function (config) {
2587
- if (config === void 0) { config = {}; }
2588
- return {
2589
- ngModule: AngularSlickgridModule,
2590
- providers: [
2591
- { provide: 'config', useValue: config },
2592
- { provide: 'externalService', useValue: null },
2593
- AngularUtilService,
2594
- BsDropDownService,
2595
- ContainerService,
2596
- ]
2597
- };
2598
- };
2599
- return AngularSlickgridModule;
2600
- }());
2601
- AngularSlickgridModule.decorators = [
2602
- { type: core.NgModule, args: [{
2603
- imports: [
2604
- common$1.CommonModule,
2605
- core$1.TranslateModule
2606
- ],
2607
- declarations: [
2608
- AngularSlickgridComponent,
2609
- ],
2610
- exports: [
2611
- AngularSlickgridComponent,
2612
- ],
2613
- entryComponents: [AngularSlickgridComponent]
2614
- },] }
2615
- ];
2616
-
2617
- /**
2618
- * Generated bundle index. Do not edit.
2619
- */
2620
-
2621
- exports.AngularSlickgridComponent = AngularSlickgridComponent;
2622
- exports.AngularSlickgridModule = AngularSlickgridModule;
2623
- exports.AngularUtilService = AngularUtilService;
2624
- exports.BsDropDownService = BsDropDownService;
2625
- exports.RowDetailViewExtension = RowDetailViewExtension;
2626
- exports.SlickgridConfig = SlickgridConfig;
2627
- exports.unsubscribeAllObservables = unsubscribeAllObservables;
2628
- exports.ɵb = ContainerService;
2629
- exports.ɵc = TranslaterService;
2630
- Object.keys(common).forEach(function (k) {
2631
- if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, {
2632
- enumerable: true,
2633
- get: function () {
2634
- return common[k];
2635
- }
2636
- });
2637
- });
2638
-
2639
- Object.defineProperty(exports, '__esModule', { value: true });
2640
-
2641
- })));
2642
- //# sourceMappingURL=angular-slickgrid.umd.js.map