@coolon/angular-ui-powerups 1.13.1 → 1.13.3
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.
- package/CHANGELOG.md +15 -0
- package/bundles/coolon-angular-ui-powerups.umd.js +557 -540
- package/bundles/coolon-angular-ui-powerups.umd.js.map +1 -1
- package/bundles/coolon-angular-ui-powerups.umd.min.js +2 -2
- package/bundles/coolon-angular-ui-powerups.umd.min.js.map +1 -1
- package/coolon-angular-ui-powerups.metadata.json +1 -1
- package/esm2015/lib/components/components.module.js +3 -1
- package/esm2015/lib/components/components.module.js.map +1 -1
- package/esm2015/lib/components/components.module.metadata.json +1 -1
- package/esm2015/lib/components/components.module.ngfactory.js.map +1 -1
- package/esm2015/lib/components/index.js +1 -0
- package/esm2015/lib/components/index.js.map +1 -1
- package/esm2015/lib/components/index.metadata.json +1 -1
- package/esm2015/lib/components/scroll-container/scroll-container.component.js +1 -1
- package/esm2015/lib/components/scroll-container/scroll-container.component.js.map +1 -1
- package/esm2015/lib/components/scroll-container/scroll-container.component.metadata.json +1 -1
- package/esm2015/lib/components/table/cell-editors.js.map +1 -1
- package/esm2015/lib/components/table/cell-protal-ref.js +89 -0
- package/esm2015/lib/components/table/cell-protal-ref.js.map +1 -0
- package/esm2015/lib/components/table/cell-protal-ref.metadata.json +1 -0
- package/esm2015/lib/components/table/column-model.js +3 -105
- package/esm2015/lib/components/table/column-model.js.map +1 -1
- package/esm2015/lib/components/table/column-model.metadata.json +1 -1
- package/esm2015/lib/components/table/table-cell-renderer/table-cell-renderer.component.js +22 -9
- package/esm2015/lib/components/table/table-cell-renderer/table-cell-renderer.component.js.map +1 -1
- package/esm2015/lib/components/table/table-cell-renderer/table-cell-renderer.component.metadata.json +1 -1
- package/esm2015/lib/components/table/table-header-cell-renderer/table-header-cell-renderer.component.js +2 -1
- package/esm2015/lib/components/table/table-header-cell-renderer/table-header-cell-renderer.component.js.map +1 -1
- package/esm2015/lib/components/table/table-header-cell-renderer/table-header-cell-renderer.component.metadata.json +1 -1
- package/esm2015/lib/components/table/table-model.js +2 -1
- package/esm2015/lib/components/table/table-model.js.map +1 -1
- package/esm2015/lib/components/table/table-model.metadata.json +1 -1
- package/esm2015/lib/interaction/components/popup-interaction-context/popup-interaction-context.component.js +23 -7
- package/esm2015/lib/interaction/components/popup-interaction-context/popup-interaction-context.component.js.map +1 -1
- package/esm2015/lib/interaction/components/popup-interaction-context/popup-interaction-context.component.metadata.json +1 -1
- package/esm2015/lib/place/components/place-outlet/place-outlet.component.js +2 -2
- package/esm2015/lib/place/components/place-outlet/place-outlet.component.js.map +1 -1
- package/esm2015/lib/place/components/place-outlet/place-outlet.component.metadata.json +1 -1
- package/esm5/lib/components/components.module.js +3 -1
- package/esm5/lib/components/components.module.js.map +1 -1
- package/esm5/lib/components/components.module.ngfactory.js.map +1 -1
- package/esm5/lib/components/index.js +1 -0
- package/esm5/lib/components/index.js.map +1 -1
- package/esm5/lib/components/scroll-container/scroll-container.component.js +1 -1
- package/esm5/lib/components/scroll-container/scroll-container.component.js.map +1 -1
- package/esm5/lib/components/table/cell-editors.js.map +1 -1
- package/esm5/lib/components/table/cell-protal-ref.js +113 -0
- package/esm5/lib/components/table/cell-protal-ref.js.map +1 -0
- package/esm5/lib/components/table/column-model.js +4 -129
- package/esm5/lib/components/table/column-model.js.map +1 -1
- package/esm5/lib/components/table/table-cell-renderer/table-cell-renderer.component.js +31 -16
- package/esm5/lib/components/table/table-cell-renderer/table-cell-renderer.component.js.map +1 -1
- package/esm5/lib/components/table/table-header-cell-renderer/table-header-cell-renderer.component.js +2 -1
- package/esm5/lib/components/table/table-header-cell-renderer/table-header-cell-renderer.component.js.map +1 -1
- package/esm5/lib/components/table/table-model.js +2 -1
- package/esm5/lib/components/table/table-model.js.map +1 -1
- package/esm5/lib/interaction/components/popup-interaction-context/popup-interaction-context.component.js +23 -7
- package/esm5/lib/interaction/components/popup-interaction-context/popup-interaction-context.component.js.map +1 -1
- package/esm5/lib/place/components/place-outlet/place-outlet.component.js +2 -2
- package/esm5/lib/place/components/place-outlet/place-outlet.component.js.map +1 -1
- package/fesm2015/coolon-angular-ui-powerups.js +527 -511
- package/fesm2015/coolon-angular-ui-powerups.js.map +1 -1
- package/fesm5/coolon-angular-ui-powerups.js +556 -538
- package/fesm5/coolon-angular-ui-powerups.js.map +1 -1
- package/lib/components/index.d.ts +1 -0
- package/lib/components/table/cell-protal-ref.d.ts +53 -0
- package/lib/components/table/column-model.d.ts +2 -48
- package/lib/components/table/table-cell-renderer/table-cell-renderer.component.d.ts +8 -3
- package/lib/components/table/table-header-cell-renderer/table-header-cell-renderer.component.d.ts +2 -1
- package/lib/components/table/table-model.d.ts +2 -1
- package/lib/interaction/components/popup-interaction-context/popup-interaction-context.component.d.ts +3 -2
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __extends, __decorate, __metadata, __param, __awaiter, __generator, __assign, __spread } from 'tslib';
|
|
2
2
|
import { DOCUMENT, CommonModule, Location } from '@angular/common';
|
|
3
|
-
import { ElementRef, Inject, Input, HostListener, Directive, NgZone, ɵɵdefineInjectable, ɵɵinject, Injectable, NgModule, HostBinding, Component, InjectionToken, Injector, ComponentFactoryResolver, ViewContainerRef, ViewChild, ViewChildren, QueryList, Optional, EventEmitter, Output, ContentChild, TemplateRef, Self, ChangeDetectorRef, ContentChildren
|
|
3
|
+
import { ElementRef, Inject, Input, HostListener, Directive, NgZone, ɵɵdefineInjectable, ɵɵinject, Injectable, NgModule, HostBinding, Component, InjectionToken, Injector, ComponentFactoryResolver, ViewContainerRef, ViewChild, ViewChildren, QueryList, Optional, SkipSelf, EventEmitter, Output, ContentChild, TemplateRef, Self, ChangeDetectorRef, ContentChildren } from '@angular/core';
|
|
4
4
|
import { FormsModule } from '@angular/forms';
|
|
5
5
|
import { MatFormFieldModule } from '@angular/material/form-field';
|
|
6
6
|
import { MatInputModule } from '@angular/material/input';
|
|
@@ -8,6 +8,7 @@ import { MatSelectModule } from '@angular/material/select';
|
|
|
8
8
|
import { MatTabsModule, MatTabGroup, MAT_TABS_CONFIG } from '@angular/material/tabs';
|
|
9
9
|
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
|
10
10
|
import { ComponentPortal, PortalModule, TemplatePortal } from '@angular/cdk/portal';
|
|
11
|
+
import { CdkScrollableModule } from '@angular/cdk/scrolling';
|
|
11
12
|
import { MatButtonModule } from '@angular/material/button';
|
|
12
13
|
import { MatCheckboxModule } from '@angular/material/checkbox';
|
|
13
14
|
import { MatIconModule } from '@angular/material/icon';
|
|
@@ -18,7 +19,7 @@ import { MatDialogModule, MatDialog, MatDialogConfig, MAT_DIALOG_DEFAULT_OPTIONS
|
|
|
18
19
|
import { RouterModule, UrlSegment, Router, UrlSerializer, NavigationStart, NavigationEnd, NavigationError, NavigationCancel, RouterOutlet } from '@angular/router';
|
|
19
20
|
import ___default, { isEqual, isNil } from 'lodash';
|
|
20
21
|
import { assert as assert$1, lang as lang$1, Opts, Klass } from '@coolon/typescript-utilities';
|
|
21
|
-
import { Overlay } from '@angular/cdk/overlay';
|
|
22
|
+
import { Overlay, CdkScrollable } from '@angular/cdk/overlay';
|
|
22
23
|
import { Memoize } from '@typescript-plus/fast-memoize-decorator/dist/src';
|
|
23
24
|
import produce from 'immer';
|
|
24
25
|
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
|
|
@@ -1271,13 +1272,14 @@ var AddItemInteractionContextComponent = /** @class */ (function (_super) {
|
|
|
1271
1272
|
|
|
1272
1273
|
var PopupInteractionContextComponent = /** @class */ (function (_super) {
|
|
1273
1274
|
__extends(PopupInteractionContextComponent, _super);
|
|
1274
|
-
function PopupInteractionContextComponent(_element, _overlay) {
|
|
1275
|
+
function PopupInteractionContextComponent(_element, _overlay, scrollable) {
|
|
1275
1276
|
var _this = _super.call(this) || this;
|
|
1276
1277
|
_this._element = _element;
|
|
1277
1278
|
_this._overlay = _overlay;
|
|
1278
1279
|
_this.outputPortal = new ComponentPortal(InPlaceInteractionContextComponent);
|
|
1279
1280
|
_this.anchorX = 'start';
|
|
1280
1281
|
_this.anchorY = 'bottom';
|
|
1282
|
+
_this.scrollContainers = scrollable ? [scrollable] : [];
|
|
1281
1283
|
return _this;
|
|
1282
1284
|
}
|
|
1283
1285
|
Object.defineProperty(PopupInteractionContextComponent.prototype, "active", {
|
|
@@ -1289,14 +1291,21 @@ var PopupInteractionContextComponent = /** @class */ (function (_super) {
|
|
|
1289
1291
|
});
|
|
1290
1292
|
PopupInteractionContextComponent.prototype.startActivity = function (activityType, data) {
|
|
1291
1293
|
var _this = this;
|
|
1294
|
+
// console.log({ element: this._element });
|
|
1295
|
+
var self = this;
|
|
1292
1296
|
var overlayRef = this._overlay.create({
|
|
1293
1297
|
hasBackdrop: false,
|
|
1294
1298
|
panelClass: 'aup-popup-interaction-panel',
|
|
1295
1299
|
positionStrategy: this._overlay.position()
|
|
1296
1300
|
.flexibleConnectedTo(this._element)
|
|
1301
|
+
.withPush(true)
|
|
1297
1302
|
.withPositions(this.computePositions())
|
|
1298
1303
|
.withGrowAfterOpen(true)
|
|
1304
|
+
.withScrollableContainers(self.scrollContainers) // this isn't working. sigh.
|
|
1299
1305
|
});
|
|
1306
|
+
var subs = this.scrollContainers.map(function (sc) { return sc.elementScrolled().subscribe(function () {
|
|
1307
|
+
overlayRef.updatePosition();
|
|
1308
|
+
}); });
|
|
1300
1309
|
var componentRef = overlayRef.attach(this.outputPortal);
|
|
1301
1310
|
this.interactionContext = componentRef.instance;
|
|
1302
1311
|
return new Promise(function (resolve, reject) {
|
|
@@ -1305,7 +1314,13 @@ var PopupInteractionContextComponent = /** @class */ (function (_super) {
|
|
|
1305
1314
|
_this.interactionContext.startActivity(activityType, data)
|
|
1306
1315
|
.then(resolve)
|
|
1307
1316
|
.catch(reject)
|
|
1308
|
-
.finally(function () {
|
|
1317
|
+
.finally(function () {
|
|
1318
|
+
subs.forEach(function (s) { return s.unsubscribe(); });
|
|
1319
|
+
overlayRef.dispose();
|
|
1320
|
+
});
|
|
1321
|
+
setTimeout(function () {
|
|
1322
|
+
overlayRef.updatePosition();
|
|
1323
|
+
});
|
|
1309
1324
|
});
|
|
1310
1325
|
});
|
|
1311
1326
|
};
|
|
@@ -1331,7 +1346,8 @@ var PopupInteractionContextComponent = /** @class */ (function (_super) {
|
|
|
1331
1346
|
};
|
|
1332
1347
|
PopupInteractionContextComponent.ctorParameters = function () { return [
|
|
1333
1348
|
{ type: ElementRef },
|
|
1334
|
-
{ type: Overlay }
|
|
1349
|
+
{ type: Overlay },
|
|
1350
|
+
{ type: CdkScrollable, decorators: [{ type: Optional }, { type: SkipSelf }] }
|
|
1335
1351
|
]; };
|
|
1336
1352
|
__decorate([
|
|
1337
1353
|
HostBinding('class.interaction-active'),
|
|
@@ -1352,7 +1368,8 @@ var PopupInteractionContextComponent = /** @class */ (function (_super) {
|
|
|
1352
1368
|
template: "<ng-content></ng-content>\n",
|
|
1353
1369
|
styles: [":host{display:inline}:host.interaction-active{background:rgba(0,0,0,.05)}"]
|
|
1354
1370
|
}),
|
|
1355
|
-
|
|
1371
|
+
__param(2, Optional()), __param(2, SkipSelf()),
|
|
1372
|
+
__metadata("design:paramtypes", [ElementRef, Overlay, CdkScrollable])
|
|
1356
1373
|
], PopupInteractionContextComponent);
|
|
1357
1374
|
return PopupInteractionContextComponent;
|
|
1358
1375
|
}(DisposableComponent));
|
|
@@ -2243,7 +2260,7 @@ var ScrollContainerComponent = /** @class */ (function () {
|
|
|
2243
2260
|
ScrollContainerComponent = __decorate([
|
|
2244
2261
|
Component({
|
|
2245
2262
|
selector: 'aup-scroll-container',
|
|
2246
|
-
template: "<div class=\"container\">\n <ng-content></ng-content>\n</div>\n",
|
|
2263
|
+
template: "<div class=\"container\" cdkScrollable>\n <ng-content></ng-content>\n</div>\n",
|
|
2247
2264
|
styles: [":host{display:flex;flex-direction:column;min-height:0;align-items:stretch}.container{display:flex;flex-direction:column;flex:1;flex-basis:0;overflow-y:scroll;align-items:stretch}"]
|
|
2248
2265
|
}),
|
|
2249
2266
|
__metadata("design:paramtypes", [])
|
|
@@ -2387,6 +2404,110 @@ var SwitchCaseComponent = /** @class */ (function (_super) {
|
|
|
2387
2404
|
return SwitchCaseComponent;
|
|
2388
2405
|
}(DisposableComponent));
|
|
2389
2406
|
|
|
2407
|
+
var HEADER_CELL_RENDERER_PORTAL = Symbol('aup-cell-header-renderer-component-ref');
|
|
2408
|
+
var CELL_RENDERER_PORTAL = Symbol('aup-cell-renderer-component-ref');
|
|
2409
|
+
var CELL_EDITOR_PORTAL = Symbol('aup-cell-editor-component-ref');
|
|
2410
|
+
var PORTAL_RENDERER_COMPONENT = Symbol('aup-cell-renderer-portal-component');
|
|
2411
|
+
var PORTAL_EDITOR_COMPONENT = Symbol('aup-cell-editor-portal-component');
|
|
2412
|
+
var CellPortalRef = /** @class */ (function () {
|
|
2413
|
+
function CellPortalRef() {
|
|
2414
|
+
}
|
|
2415
|
+
return CellPortalRef;
|
|
2416
|
+
}());
|
|
2417
|
+
var CellHeaderPortalRef = /** @class */ (function (_super) {
|
|
2418
|
+
__extends(CellHeaderPortalRef, _super);
|
|
2419
|
+
function CellHeaderPortalRef(componentType, initialiseHeader) {
|
|
2420
|
+
var _this = _super.call(this) || this;
|
|
2421
|
+
_this.componentType = componentType;
|
|
2422
|
+
_this.initialiseHeader = initialiseHeader;
|
|
2423
|
+
return _this;
|
|
2424
|
+
}
|
|
2425
|
+
CellHeaderPortalRef.prototype.initialiseHost = function (host, columnModel) {
|
|
2426
|
+
assert$1.isTruthy(host);
|
|
2427
|
+
host[HEADER_CELL_RENDERER_PORTAL] = new ComponentPortal(this.componentType);
|
|
2428
|
+
};
|
|
2429
|
+
CellHeaderPortalRef.prototype.onPortalAttached = function (host, portalComponent) {
|
|
2430
|
+
this.initialiseHeader(portalComponent, host.column);
|
|
2431
|
+
};
|
|
2432
|
+
return CellHeaderPortalRef;
|
|
2433
|
+
}(CellPortalRef));
|
|
2434
|
+
var CellRendererPortalRef = /** @class */ (function (_super) {
|
|
2435
|
+
__extends(CellRendererPortalRef, _super);
|
|
2436
|
+
function CellRendererPortalRef() {
|
|
2437
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
2438
|
+
}
|
|
2439
|
+
return CellRendererPortalRef;
|
|
2440
|
+
}(CellPortalRef));
|
|
2441
|
+
var ComponentCellRendererPortalRef = /** @class */ (function (_super) {
|
|
2442
|
+
__extends(ComponentCellRendererPortalRef, _super);
|
|
2443
|
+
function ComponentCellRendererPortalRef(componentType, updateComponent) {
|
|
2444
|
+
var _this = _super.call(this) || this;
|
|
2445
|
+
_this.componentType = componentType;
|
|
2446
|
+
_this.updateComponent = updateComponent;
|
|
2447
|
+
return _this;
|
|
2448
|
+
}
|
|
2449
|
+
ComponentCellRendererPortalRef.prototype.initialiseHost = function (host, columnModel) {
|
|
2450
|
+
host[CELL_RENDERER_PORTAL] = new ComponentPortal(this.componentType);
|
|
2451
|
+
};
|
|
2452
|
+
ComponentCellRendererPortalRef.prototype.onPortalAttached = function (host, portalComponent) {
|
|
2453
|
+
host[PORTAL_RENDERER_COMPONENT] = portalComponent;
|
|
2454
|
+
this.updateComponent(portalComponent, host.getRowData());
|
|
2455
|
+
};
|
|
2456
|
+
ComponentCellRendererPortalRef.prototype.pushState = function (host) {
|
|
2457
|
+
if (host[PORTAL_RENDERER_COMPONENT]) {
|
|
2458
|
+
this.updateComponent(host[PORTAL_RENDERER_COMPONENT], host.getRowData());
|
|
2459
|
+
}
|
|
2460
|
+
};
|
|
2461
|
+
return ComponentCellRendererPortalRef;
|
|
2462
|
+
}(CellRendererPortalRef));
|
|
2463
|
+
var CellEditorPortalRef = /** @class */ (function (_super) {
|
|
2464
|
+
__extends(CellEditorPortalRef, _super);
|
|
2465
|
+
function CellEditorPortalRef(componentType, initialiseEditorSession) {
|
|
2466
|
+
var _this = _super.call(this) || this;
|
|
2467
|
+
_this.componentType = componentType;
|
|
2468
|
+
_this.initialiseEditorSession = initialiseEditorSession;
|
|
2469
|
+
return _this;
|
|
2470
|
+
}
|
|
2471
|
+
CellEditorPortalRef.prototype.initialiseHost = function (host, columnModel) {
|
|
2472
|
+
assert$1.isTruthy(host);
|
|
2473
|
+
host[CELL_EDITOR_PORTAL] = new ComponentPortal(this.componentType);
|
|
2474
|
+
};
|
|
2475
|
+
// @Trace()
|
|
2476
|
+
CellEditorPortalRef.prototype.onPortalAttached = function (host, portalComponent) {
|
|
2477
|
+
host[PORTAL_EDITOR_COMPONENT] = portalComponent;
|
|
2478
|
+
this.initialiseEditorSession(portalComponent, host.editSession);
|
|
2479
|
+
};
|
|
2480
|
+
return CellEditorPortalRef;
|
|
2481
|
+
}(CellPortalRef));
|
|
2482
|
+
var TemplateCellRendererPortalRef = /** @class */ (function (_super) {
|
|
2483
|
+
__extends(TemplateCellRendererPortalRef, _super);
|
|
2484
|
+
function TemplateCellRendererPortalRef() {
|
|
2485
|
+
return _super.call(this) || this;
|
|
2486
|
+
}
|
|
2487
|
+
TemplateCellRendererPortalRef.prototype.registerPortal = function (templateRef, viewContainer, fillCell, padChild) {
|
|
2488
|
+
this.templateRef = templateRef;
|
|
2489
|
+
this.viewContainer = viewContainer;
|
|
2490
|
+
this.fillCell = fillCell;
|
|
2491
|
+
this.padChild = padChild;
|
|
2492
|
+
};
|
|
2493
|
+
TemplateCellRendererPortalRef.prototype.initialiseHost = function (host, columnModel) {
|
|
2494
|
+
assert$1.isTruthy(host);
|
|
2495
|
+
};
|
|
2496
|
+
// @Trace()
|
|
2497
|
+
TemplateCellRendererPortalRef.prototype.onPortalAttached = function (host, portalComponent) {
|
|
2498
|
+
// don't care
|
|
2499
|
+
};
|
|
2500
|
+
TemplateCellRendererPortalRef.prototype.pushState = function (host) {
|
|
2501
|
+
host[CELL_RENDERER_PORTAL] = this.createPortal(host.getRowData());
|
|
2502
|
+
host.fillCell = this.fillCell;
|
|
2503
|
+
host.padChild = this.padChild;
|
|
2504
|
+
};
|
|
2505
|
+
TemplateCellRendererPortalRef.prototype.createPortal = function (data) {
|
|
2506
|
+
return new TemplatePortal(this.templateRef, this.viewContainer, __assign(__assign({}, (data)), { $implicit: data.row }));
|
|
2507
|
+
};
|
|
2508
|
+
return TemplateCellRendererPortalRef;
|
|
2509
|
+
}(CellRendererPortalRef));
|
|
2510
|
+
|
|
2390
2511
|
var DefaultCellRendererComponent = /** @class */ (function () {
|
|
2391
2512
|
function DefaultCellRendererComponent() {
|
|
2392
2513
|
}
|
|
@@ -2564,432 +2685,39 @@ var SelectHeaderCellRendererComponent = /** @class */ (function (_super) {
|
|
|
2564
2685
|
return SelectHeaderCellRendererComponent;
|
|
2565
2686
|
}(DisposableComponent));
|
|
2566
2687
|
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
* });
|
|
2577
|
-
*
|
|
2578
|
-
* Editable tables
|
|
2579
|
-
* @example
|
|
2580
|
-
* const saveCommand = UnaryCommand.create((form: Form<Hero>) => {
|
|
2581
|
-
* if (form.validate()) {
|
|
2582
|
-
* // normal form save stuff
|
|
2583
|
-
* return true; // finish editing
|
|
2584
|
-
* }
|
|
2585
|
-
* return false; // continue editiing
|
|
2586
|
-
* }
|
|
2587
|
-
* const colorsNames: ListModel<string> = ...;
|
|
2588
|
-
* const model = TableModel.fromList(heroList, table => {
|
|
2589
|
-
* table.pluck("firstName").cellEditor(StringInputComponent); <-- interface CellEditor { valueModel: FormValueModel<string> | ValueModel<string>; }
|
|
2590
|
-
* table.pluck("lastName").cellEditor(StringInputComponent, {
|
|
2591
|
-
* validators: [Validator.present("We need a last name")]
|
|
2592
|
-
* });
|
|
2593
|
-
* table.pluck("age").cellEditor(NumberInputComponent);
|
|
2594
|
-
* table.pluck("favoriteColor").cellEditor(SelectInputComponent, {
|
|
2595
|
-
* initialiseComponent(component: SelectInputComponent) {
|
|
2596
|
-
* selectInput.optionsModel = colorsNames; // <- initialise our component
|
|
2597
|
-
* }
|
|
2598
|
-
* });
|
|
2599
|
-
* table.addEditControls(saveCommand); // <- required to enable editing
|
|
2600
|
-
* });
|
|
2601
|
-
*
|
|
2602
|
-
* Selection models
|
|
2603
|
-
* @example
|
|
2604
|
-
* const model = TableModel.fromList(heroList, table => {
|
|
2605
|
-
* table.addSelectionColumn(selectionModel); // <- can be single or multiple selection model
|
|
2606
|
-
* table.pluck("firstName");
|
|
2607
|
-
* table.pluck("lastName");
|
|
2608
|
-
* });
|
|
2609
|
-
*
|
|
2610
|
-
* Custom cell renderers and editors
|
|
2611
|
-
* @example
|
|
2612
|
-
* const model = TableModel.fromList(heroList, table => {
|
|
2613
|
-
* table.pluck("favoriteColor")
|
|
2614
|
-
* .cellHeaderRenderer(CellHeaderRendererComponent, (component, column) => {
|
|
2615
|
-
* // configure your component with what ever you need.
|
|
2616
|
-
* });
|
|
2617
|
-
* .cellRenderer(CellRendererComponent) // <-- interface CellEditor { value: string; }
|
|
2618
|
-
* .cellEditor(CellEditorComponent.); // <-- interface CellEditor { valueModel: FormValueModel<string> | ValueModel<string>; }
|
|
2619
|
-
* table.addCustomColumn("fullName", hero => `${hero.firstName} ${hero.lastName}`);
|
|
2620
|
-
* });
|
|
2621
|
-
*
|
|
2622
|
-
* I18n
|
|
2623
|
-
* @example
|
|
2624
|
-
* [table.yml]
|
|
2625
|
-
* table:
|
|
2626
|
-
* columns(ColumnTextProperties[]):
|
|
2627
|
-
* firstName:
|
|
2628
|
-
* headerText: "First Name"
|
|
2629
|
-
* fullName:
|
|
2630
|
-
* headerText: "Full Name"
|
|
2631
|
-
*
|
|
2632
|
-
* const model = TableModel.fromList(heroList, table => {
|
|
2633
|
-
* table.pluck("favoriteColor").cellRenderer(...).cellEditor(...);
|
|
2634
|
-
* table.addCustomColumn("fullName", hero => `${hero.firstName} ${hero.lastName}`);
|
|
2635
|
-
*
|
|
2636
|
-
* table.columnTextProperties(I18n.table.columns); // <- configures all columns
|
|
2637
|
-
* });
|
|
2638
|
-
*/
|
|
2639
|
-
var TableModel = /** @class */ (function () {
|
|
2640
|
-
function TableModel(sourceOfTruth) {
|
|
2641
|
-
this.sourceOfTruth = sourceOfTruth;
|
|
2642
|
-
this._garbage = new GarbageCollector();
|
|
2643
|
-
this._columns = new MutableListModel();
|
|
2644
|
-
this._editorSessions = new MutableListModel();
|
|
2645
|
-
this._createForm = function (row) { return new Form(); };
|
|
2646
|
-
this.identityOf = sourceOfTruth.identityOf;
|
|
2647
|
-
var _a = Dsl.disposeWith(this._garbage), chain = _a.chain, valueOf = _a.valueOf, before = _a.before, when = _a.when, after = _a.after, observe = _a.observe, switchOn = _a.switchOn;
|
|
2648
|
-
this._columnsById = chain(this._columns).indexBy('columnId');
|
|
2649
|
-
this._rowsBeingEdited = new MutableListModel([], {
|
|
2650
|
-
identifiedWith: this.identityOf
|
|
2688
|
+
var noop = function () {
|
|
2689
|
+
};
|
|
2690
|
+
var ɵ0 = noop;
|
|
2691
|
+
var ColumnModel = /** @class */ (function () {
|
|
2692
|
+
function ColumnModel(columnId, defaults) {
|
|
2693
|
+
this.columnId = columnId;
|
|
2694
|
+
this.defaults = defaults;
|
|
2695
|
+
this.cellHeaderRenderer(DefaultHeaderCellRendererComponent, function (component, column) {
|
|
2696
|
+
component.headerText = column.getHeaderText();
|
|
2651
2697
|
});
|
|
2652
|
-
this._editorSessionByRowId = chain(this._editorSessions).indexBy('rowId');
|
|
2653
|
-
this.editing = chain(this._editorSessions).count().isGreaterThan(0);
|
|
2654
|
-
this.dataSource = chain(this.sourceOfTruth).replaceAll(this.rowsBeingEdited);
|
|
2655
2698
|
}
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
builder(model);
|
|
2660
|
-
return model;
|
|
2699
|
+
ColumnModel.prototype.getHeaderText = function () {
|
|
2700
|
+
var _a;
|
|
2701
|
+
return ((_a = this.getColumnTextProperties()) === null || _a === void 0 ? void 0 : _a.headerText()) || this.getDefaultHeaderText();
|
|
2661
2702
|
};
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
return this._rowsBeingEdited.readonly;
|
|
2665
|
-
},
|
|
2666
|
-
enumerable: true,
|
|
2667
|
-
configurable: true
|
|
2668
|
-
});
|
|
2669
|
-
TableModel.prototype.getTrackByFunction = function () {
|
|
2670
|
-
var _this = this;
|
|
2671
|
-
return function (index, item) {
|
|
2672
|
-
return _this.identityOf ? _this.identityOf(item) : index;
|
|
2673
|
-
};
|
|
2703
|
+
ColumnModel.prototype.getDefaultHeaderText = function () {
|
|
2704
|
+
return this.columnId;
|
|
2674
2705
|
};
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
return this._columns.readonly;
|
|
2678
|
-
},
|
|
2679
|
-
enumerable: true,
|
|
2680
|
-
configurable: true
|
|
2681
|
-
});
|
|
2682
|
-
TableModel.prototype.pluck = function (property) {
|
|
2683
|
-
return this.addColumn(new PropertyColumnModel(property, this));
|
|
2706
|
+
ColumnModel.prototype.getColumnTextProperties = function () {
|
|
2707
|
+
return this._columnTextProperties || this.defaults.getColumnTextProperties(this);
|
|
2684
2708
|
};
|
|
2685
|
-
|
|
2686
|
-
|
|
2709
|
+
ColumnModel.prototype.textProperties = function (columnTextProperties) {
|
|
2710
|
+
this._columnTextProperties = columnTextProperties;
|
|
2711
|
+
return this;
|
|
2687
2712
|
};
|
|
2688
|
-
|
|
2689
|
-
|
|
2713
|
+
ColumnModel.prototype.configureHeaderRenderer = function (config) {
|
|
2714
|
+
this._columnHeaderPortalRef = config;
|
|
2690
2715
|
};
|
|
2691
|
-
|
|
2692
|
-
this.
|
|
2693
|
-
return this.addColumn(new EditorControlColumnModel('editControls', saveCommand, this));
|
|
2716
|
+
ColumnModel.prototype.configureCellRenderer = function (config) {
|
|
2717
|
+
this._cellRendererPortalRef = config;
|
|
2694
2718
|
};
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
};
|
|
2698
|
-
TableModel.prototype.addTemplateColumn = function (columnId) {
|
|
2699
|
-
return this.addColumn(new CustomTemplateColumnModel(columnId, this));
|
|
2700
|
-
};
|
|
2701
|
-
TableModel.prototype.useFormFactory = function (factory) {
|
|
2702
|
-
this._createForm = factory;
|
|
2703
|
-
return this;
|
|
2704
|
-
};
|
|
2705
|
-
TableModel.prototype.addColumn = function (column) {
|
|
2706
|
-
if (this._columnsById.get(column.columnId)) {
|
|
2707
|
-
lang.illegalState("Column with id=" + column.columnId + " already exists");
|
|
2708
|
-
}
|
|
2709
|
-
else {
|
|
2710
|
-
this._columns.push(column);
|
|
2711
|
-
}
|
|
2712
|
-
return column;
|
|
2713
|
-
};
|
|
2714
|
-
TableModel.prototype.columnTextProperties = function (columnTextProperties) {
|
|
2715
|
-
this._columnTextPropertiesLookup = columnTextProperties;
|
|
2716
|
-
};
|
|
2717
|
-
TableModel.prototype.getColumnTextProperties = function (column) {
|
|
2718
|
-
var factory = this._columnTextPropertiesLookup ? this._columnTextPropertiesLookup[column.columnId] : undefined;
|
|
2719
|
-
return factory ? factory() : undefined;
|
|
2720
|
-
};
|
|
2721
|
-
TableModel.prototype.startEditSession = function (row) {
|
|
2722
|
-
var _this = this;
|
|
2723
|
-
var rowId = this.identityOf(row);
|
|
2724
|
-
if (this._rowsBeingEdited.query().indexOf(row) > -1) {
|
|
2725
|
-
return lang.illegalState("Row with id=" + rowId + " already being edited");
|
|
2726
|
-
}
|
|
2727
|
-
else {
|
|
2728
|
-
var editSession_1 = new EditSession(rowId, row, this._createForm(row), this.saveCommand);
|
|
2729
|
-
var when = Dsl.disposeWith(editSession_1).when;
|
|
2730
|
-
when.valueOf(editSession_1.liveRowValue).changes(function (editedValue) {
|
|
2731
|
-
_this._rowsBeingEdited.replaceOrPush(editedValue);
|
|
2732
|
-
}, { initialValue: 'triggerChangeUnlessNil' });
|
|
2733
|
-
this._editorSessions.push(editSession_1);
|
|
2734
|
-
editSession_1.onDispose(function () {
|
|
2735
|
-
_this._rowsBeingEdited.remove(editSession_1.liveRowValue.value);
|
|
2736
|
-
_this._editorSessions.remove(editSession_1);
|
|
2737
|
-
});
|
|
2738
|
-
return editSession_1;
|
|
2739
|
-
}
|
|
2740
|
-
};
|
|
2741
|
-
TableModel.prototype.getEditSessionFor = function (row) {
|
|
2742
|
-
return this._editorSessionByRowId.get(this.identityOf(row));
|
|
2743
|
-
};
|
|
2744
|
-
TableModel.prototype.cancelAllEditorSessions = function () {
|
|
2745
|
-
var _this = this;
|
|
2746
|
-
this._editorSessions.runInTransaction(function (draft) {
|
|
2747
|
-
_this._rowsBeingEdited.runInTransaction(function () {
|
|
2748
|
-
draft.value.forEach(function (session) { return session.dispose(); });
|
|
2749
|
-
});
|
|
2750
|
-
});
|
|
2751
|
-
};
|
|
2752
|
-
var TableModel_1;
|
|
2753
|
-
TableModel.ctorParameters = function () { return [
|
|
2754
|
-
{ type: ListModel }
|
|
2755
|
-
]; };
|
|
2756
|
-
TableModel = TableModel_1 = __decorate([
|
|
2757
|
-
TrackExternal.Strategy(new TrackExternal.OneTimeBinding()),
|
|
2758
|
-
__metadata("design:paramtypes", [ListModel])
|
|
2759
|
-
], TableModel);
|
|
2760
|
-
return TableModel;
|
|
2761
|
-
}());
|
|
2762
|
-
|
|
2763
|
-
var TableCellRendererComponent = /** @class */ (function () {
|
|
2764
|
-
function TableCellRendererComponent() {
|
|
2765
|
-
var _this = this;
|
|
2766
|
-
this.defaultClassNames = 'aup-cell-renderer';
|
|
2767
|
-
this.fillCell = false;
|
|
2768
|
-
this.padChild = false;
|
|
2769
|
-
this.editRowCommand = Command.create(function () {
|
|
2770
|
-
_this.tableModel.startEditSession(_this.row);
|
|
2771
|
-
});
|
|
2772
|
-
}
|
|
2773
|
-
TableCellRendererComponent.prototype.ngOnInit = function () {
|
|
2774
|
-
this.column.attachCell(this);
|
|
2775
|
-
};
|
|
2776
|
-
TableCellRendererComponent.prototype.hasActiveEditor = function () {
|
|
2777
|
-
return !!this.editSession && !!this.column.hasEditorPortal();
|
|
2778
|
-
};
|
|
2779
|
-
TableCellRendererComponent.prototype.initialiseRenderer = function (instance) {
|
|
2780
|
-
this.column.onRendererAttached(this, instance);
|
|
2781
|
-
};
|
|
2782
|
-
TableCellRendererComponent.prototype.initialiseEditor = function (instance) {
|
|
2783
|
-
this.column.onEditorAttached(this, instance);
|
|
2784
|
-
};
|
|
2785
|
-
// @Trace()
|
|
2786
|
-
TableCellRendererComponent.prototype.ngOnChanges = function (changes) {
|
|
2787
|
-
this.column.updatePortalContent(this);
|
|
2788
|
-
};
|
|
2789
|
-
TableCellRendererComponent.prototype.getRendererPortal = function () {
|
|
2790
|
-
return this[CELL_RENDERER_PORTAL];
|
|
2791
|
-
};
|
|
2792
|
-
TableCellRendererComponent.prototype.getEditorPortal = function () {
|
|
2793
|
-
return this[CELL_EDITOR_PORTAL];
|
|
2794
|
-
};
|
|
2795
|
-
TableCellRendererComponent.prototype.getRowData = function () {
|
|
2796
|
-
return {
|
|
2797
|
-
row: this.row,
|
|
2798
|
-
editSession: this.editSession,
|
|
2799
|
-
editRowCommand: this.editRowCommand
|
|
2800
|
-
};
|
|
2801
|
-
};
|
|
2802
|
-
__decorate([
|
|
2803
|
-
Input(),
|
|
2804
|
-
__metadata("design:type", Object)
|
|
2805
|
-
], TableCellRendererComponent.prototype, "row", void 0);
|
|
2806
|
-
__decorate([
|
|
2807
|
-
Input(),
|
|
2808
|
-
__metadata("design:type", ColumnModel)
|
|
2809
|
-
], TableCellRendererComponent.prototype, "column", void 0);
|
|
2810
|
-
__decorate([
|
|
2811
|
-
Input(),
|
|
2812
|
-
__metadata("design:type", EditSession)
|
|
2813
|
-
], TableCellRendererComponent.prototype, "editSession", void 0);
|
|
2814
|
-
__decorate([
|
|
2815
|
-
Input(),
|
|
2816
|
-
__metadata("design:type", TableModel)
|
|
2817
|
-
], TableCellRendererComponent.prototype, "tableModel", void 0);
|
|
2818
|
-
__decorate([
|
|
2819
|
-
HostBinding('class'),
|
|
2820
|
-
__metadata("design:type", Object)
|
|
2821
|
-
], TableCellRendererComponent.prototype, "defaultClassNames", void 0);
|
|
2822
|
-
__decorate([
|
|
2823
|
-
HostBinding('class.fillCell'),
|
|
2824
|
-
__metadata("design:type", Object)
|
|
2825
|
-
], TableCellRendererComponent.prototype, "fillCell", void 0);
|
|
2826
|
-
__decorate([
|
|
2827
|
-
HostBinding('class.padChild'),
|
|
2828
|
-
__metadata("design:type", Object)
|
|
2829
|
-
], TableCellRendererComponent.prototype, "padChild", void 0);
|
|
2830
|
-
__decorate([
|
|
2831
|
-
Trace(),
|
|
2832
|
-
__metadata("design:type", Function),
|
|
2833
|
-
__metadata("design:paramtypes", [Object]),
|
|
2834
|
-
__metadata("design:returntype", void 0)
|
|
2835
|
-
], TableCellRendererComponent.prototype, "initialiseEditor", null);
|
|
2836
|
-
TableCellRendererComponent = __decorate([
|
|
2837
|
-
Component({
|
|
2838
|
-
selector: 'aup-table-cell-renderer',
|
|
2839
|
-
template: "<ng-container *ngIf=\"!hasActiveEditor()\" [cdkPortalOutlet]=\"getRendererPortal()\" (attached)=\"initialiseRenderer($event.instance)\"></ng-container>\n<ng-container *ngIf=\"hasActiveEditor()\" [cdkPortalOutlet]=\"getEditorPortal()\" (attached)=\"initialiseEditor($event.instance)\"></ng-container>\n",
|
|
2840
|
-
styles: [""]
|
|
2841
|
-
}),
|
|
2842
|
-
__metadata("design:paramtypes", [])
|
|
2843
|
-
], TableCellRendererComponent);
|
|
2844
|
-
return TableCellRendererComponent;
|
|
2845
|
-
}());
|
|
2846
|
-
|
|
2847
|
-
var HEADER_CELL_RENDERER_PORTAL = Symbol('aup-cell-header-renderer-component-ref');
|
|
2848
|
-
var CELL_RENDERER_PORTAL = Symbol('aup-cell-renderer-component-ref');
|
|
2849
|
-
var CELL_EDITOR_PORTAL = Symbol('aup-cell-editor-component-ref');
|
|
2850
|
-
var PORTAL_RENDERER_COMPONENT = Symbol('aup-cell-renderer-portal-component');
|
|
2851
|
-
var PORTAL_EDITOR_COMPONENT = Symbol('aup-cell-editor-portal-component');
|
|
2852
|
-
var noop = function () {
|
|
2853
|
-
};
|
|
2854
|
-
var ɵ0 = noop;
|
|
2855
|
-
var CellPortalRef = /** @class */ (function () {
|
|
2856
|
-
function CellPortalRef() {
|
|
2857
|
-
}
|
|
2858
|
-
return CellPortalRef;
|
|
2859
|
-
}());
|
|
2860
|
-
var CellHeaderPortalRef = /** @class */ (function (_super) {
|
|
2861
|
-
__extends(CellHeaderPortalRef, _super);
|
|
2862
|
-
function CellHeaderPortalRef(componentType, initialiseHeader) {
|
|
2863
|
-
var _this = _super.call(this) || this;
|
|
2864
|
-
_this.componentType = componentType;
|
|
2865
|
-
_this.initialiseHeader = initialiseHeader;
|
|
2866
|
-
return _this;
|
|
2867
|
-
}
|
|
2868
|
-
CellHeaderPortalRef.prototype.initialiseHost = function (host, columnModel) {
|
|
2869
|
-
assert$1.isTruthy(host);
|
|
2870
|
-
host[HEADER_CELL_RENDERER_PORTAL] = new ComponentPortal(this.componentType);
|
|
2871
|
-
};
|
|
2872
|
-
CellHeaderPortalRef.prototype.onPortalAttached = function (host, portalComponent) {
|
|
2873
|
-
this.initialiseHeader(portalComponent, host.column);
|
|
2874
|
-
};
|
|
2875
|
-
return CellHeaderPortalRef;
|
|
2876
|
-
}(CellPortalRef));
|
|
2877
|
-
var CellRendererPortalRef = /** @class */ (function (_super) {
|
|
2878
|
-
__extends(CellRendererPortalRef, _super);
|
|
2879
|
-
function CellRendererPortalRef() {
|
|
2880
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
2881
|
-
}
|
|
2882
|
-
return CellRendererPortalRef;
|
|
2883
|
-
}(CellPortalRef));
|
|
2884
|
-
var ComponentCellRendererPortalRef = /** @class */ (function (_super) {
|
|
2885
|
-
__extends(ComponentCellRendererPortalRef, _super);
|
|
2886
|
-
function ComponentCellRendererPortalRef(componentType, updateComponent) {
|
|
2887
|
-
var _this = _super.call(this) || this;
|
|
2888
|
-
_this.componentType = componentType;
|
|
2889
|
-
_this.updateComponent = updateComponent;
|
|
2890
|
-
return _this;
|
|
2891
|
-
}
|
|
2892
|
-
ComponentCellRendererPortalRef.prototype.initialiseHost = function (host, columnModel) {
|
|
2893
|
-
host[CELL_RENDERER_PORTAL] = new ComponentPortal(this.componentType);
|
|
2894
|
-
};
|
|
2895
|
-
ComponentCellRendererPortalRef.prototype.onPortalAttached = function (host, portalComponent) {
|
|
2896
|
-
host[PORTAL_RENDERER_COMPONENT] = portalComponent;
|
|
2897
|
-
this.updateComponent(portalComponent, host.getRowData());
|
|
2898
|
-
};
|
|
2899
|
-
ComponentCellRendererPortalRef.prototype.pushState = function (host) {
|
|
2900
|
-
if (host[PORTAL_RENDERER_COMPONENT]) {
|
|
2901
|
-
this.updateComponent(host[PORTAL_RENDERER_COMPONENT], host.getRowData());
|
|
2902
|
-
}
|
|
2903
|
-
};
|
|
2904
|
-
return ComponentCellRendererPortalRef;
|
|
2905
|
-
}(CellRendererPortalRef));
|
|
2906
|
-
var CellEditorPortalRef = /** @class */ (function (_super) {
|
|
2907
|
-
__extends(CellEditorPortalRef, _super);
|
|
2908
|
-
function CellEditorPortalRef(componentType, initialiseEditorSession) {
|
|
2909
|
-
var _this = _super.call(this) || this;
|
|
2910
|
-
_this.componentType = componentType;
|
|
2911
|
-
_this.initialiseEditorSession = initialiseEditorSession;
|
|
2912
|
-
return _this;
|
|
2913
|
-
}
|
|
2914
|
-
CellEditorPortalRef.prototype.initialiseHost = function (host, columnModel) {
|
|
2915
|
-
assert$1.isTruthy(host);
|
|
2916
|
-
host[CELL_EDITOR_PORTAL] = new ComponentPortal(this.componentType);
|
|
2917
|
-
};
|
|
2918
|
-
CellEditorPortalRef.prototype.onPortalAttached = function (host, portalComponent) {
|
|
2919
|
-
host[PORTAL_EDITOR_COMPONENT] = portalComponent;
|
|
2920
|
-
this.initialiseEditorSession(portalComponent, host.editSession);
|
|
2921
|
-
};
|
|
2922
|
-
__decorate([
|
|
2923
|
-
Trace(),
|
|
2924
|
-
__metadata("design:type", Function),
|
|
2925
|
-
__metadata("design:paramtypes", [TableCellRendererComponent, Object]),
|
|
2926
|
-
__metadata("design:returntype", void 0)
|
|
2927
|
-
], CellEditorPortalRef.prototype, "onPortalAttached", null);
|
|
2928
|
-
return CellEditorPortalRef;
|
|
2929
|
-
}(CellPortalRef));
|
|
2930
|
-
var TemplateCellRendererPortalRef = /** @class */ (function (_super) {
|
|
2931
|
-
__extends(TemplateCellRendererPortalRef, _super);
|
|
2932
|
-
function TemplateCellRendererPortalRef() {
|
|
2933
|
-
return _super.call(this) || this;
|
|
2934
|
-
}
|
|
2935
|
-
TemplateCellRendererPortalRef.prototype.registerPortal = function (templateRef, viewContainer, fillCell, padChild) {
|
|
2936
|
-
this.templateRef = templateRef;
|
|
2937
|
-
this.viewContainer = viewContainer;
|
|
2938
|
-
this.fillCell = fillCell;
|
|
2939
|
-
this.padChild = padChild;
|
|
2940
|
-
};
|
|
2941
|
-
TemplateCellRendererPortalRef.prototype.initialiseHost = function (host, columnModel) {
|
|
2942
|
-
assert$1.isTruthy(host);
|
|
2943
|
-
};
|
|
2944
|
-
TemplateCellRendererPortalRef.prototype.onPortalAttached = function (host, portalComponent) {
|
|
2945
|
-
// don't care
|
|
2946
|
-
};
|
|
2947
|
-
TemplateCellRendererPortalRef.prototype.pushState = function (host) {
|
|
2948
|
-
host[CELL_RENDERER_PORTAL] = this.createPortal(host.getRowData());
|
|
2949
|
-
host.fillCell = this.fillCell;
|
|
2950
|
-
host.padChild = this.padChild;
|
|
2951
|
-
};
|
|
2952
|
-
TemplateCellRendererPortalRef.prototype.createPortal = function (data) {
|
|
2953
|
-
return new TemplatePortal(this.templateRef, this.viewContainer, __assign(__assign({}, (data)), { $implicit: data.row }));
|
|
2954
|
-
};
|
|
2955
|
-
__decorate([
|
|
2956
|
-
Trace(),
|
|
2957
|
-
__metadata("design:type", Function),
|
|
2958
|
-
__metadata("design:paramtypes", [TableCellRendererComponent, void 0]),
|
|
2959
|
-
__metadata("design:returntype", void 0)
|
|
2960
|
-
], TemplateCellRendererPortalRef.prototype, "onPortalAttached", null);
|
|
2961
|
-
return TemplateCellRendererPortalRef;
|
|
2962
|
-
}(CellRendererPortalRef));
|
|
2963
|
-
var ColumnModel = /** @class */ (function () {
|
|
2964
|
-
function ColumnModel(columnId, defaults) {
|
|
2965
|
-
this.columnId = columnId;
|
|
2966
|
-
this.defaults = defaults;
|
|
2967
|
-
this.cellHeaderRenderer(DefaultHeaderCellRendererComponent, function (component, column) {
|
|
2968
|
-
component.headerText = column.getHeaderText();
|
|
2969
|
-
});
|
|
2970
|
-
}
|
|
2971
|
-
ColumnModel.prototype.getHeaderText = function () {
|
|
2972
|
-
var _a;
|
|
2973
|
-
return ((_a = this.getColumnTextProperties()) === null || _a === void 0 ? void 0 : _a.headerText()) || this.getDefaultHeaderText();
|
|
2974
|
-
};
|
|
2975
|
-
ColumnModel.prototype.getDefaultHeaderText = function () {
|
|
2976
|
-
return this.columnId;
|
|
2977
|
-
};
|
|
2978
|
-
ColumnModel.prototype.getColumnTextProperties = function () {
|
|
2979
|
-
return this._columnTextProperties || this.defaults.getColumnTextProperties(this);
|
|
2980
|
-
};
|
|
2981
|
-
ColumnModel.prototype.textProperties = function (columnTextProperties) {
|
|
2982
|
-
this._columnTextProperties = columnTextProperties;
|
|
2983
|
-
return this;
|
|
2984
|
-
};
|
|
2985
|
-
ColumnModel.prototype.configureHeaderRenderer = function (config) {
|
|
2986
|
-
this._columnHeaderPortalRef = config;
|
|
2987
|
-
};
|
|
2988
|
-
ColumnModel.prototype.configureCellRenderer = function (config) {
|
|
2989
|
-
this._cellRendererPortalRef = config;
|
|
2990
|
-
};
|
|
2991
|
-
ColumnModel.prototype.configureCellEditor = function (cellEditor) {
|
|
2992
|
-
this._cellEditorPortalRef = cellEditor;
|
|
2719
|
+
ColumnModel.prototype.configureCellEditor = function (cellEditor) {
|
|
2720
|
+
this._cellEditorPortalRef = cellEditor;
|
|
2993
2721
|
};
|
|
2994
2722
|
ColumnModel.prototype.cellHeaderRenderer = function (componentType, initialiser) {
|
|
2995
2723
|
this.configureHeaderRenderer(new CellHeaderPortalRef(componentType, initialiser));
|
|
@@ -3013,6 +2741,7 @@ var ColumnModel = /** @class */ (function () {
|
|
|
3013
2741
|
ColumnModel.prototype.onRendererAttached = function (host, component) {
|
|
3014
2742
|
this._cellRendererPortalRef.onPortalAttached(host, component);
|
|
3015
2743
|
};
|
|
2744
|
+
// @Trace()
|
|
3016
2745
|
ColumnModel.prototype.onEditorAttached = function (host, component) {
|
|
3017
2746
|
this._cellEditorPortalRef.onPortalAttached(host, component);
|
|
3018
2747
|
};
|
|
@@ -3031,12 +2760,6 @@ var ColumnModel = /** @class */ (function () {
|
|
|
3031
2760
|
__metadata("design:paramtypes", []),
|
|
3032
2761
|
__metadata("design:returntype", Object)
|
|
3033
2762
|
], ColumnModel.prototype, "getColumnTextProperties", null);
|
|
3034
|
-
__decorate([
|
|
3035
|
-
Trace(),
|
|
3036
|
-
__metadata("design:type", Function),
|
|
3037
|
-
__metadata("design:paramtypes", [TableCellRendererComponent, Object]),
|
|
3038
|
-
__metadata("design:returntype", void 0)
|
|
3039
|
-
], ColumnModel.prototype, "onEditorAttached", null);
|
|
3040
2763
|
return ColumnModel;
|
|
3041
2764
|
}());
|
|
3042
2765
|
var PropertyColumnModel = /** @class */ (function (_super) {
|
|
@@ -3071,122 +2794,319 @@ var PropertyColumnModel = /** @class */ (function (_super) {
|
|
|
3071
2794
|
}));
|
|
3072
2795
|
return this;
|
|
3073
2796
|
};
|
|
3074
|
-
PropertyColumnModel.prototype.format = function (formatter) {
|
|
3075
|
-
assert$1.isFunction(formatter);
|
|
3076
|
-
this._format = formatter;
|
|
3077
|
-
return this;
|
|
2797
|
+
PropertyColumnModel.prototype.format = function (formatter) {
|
|
2798
|
+
assert$1.isFunction(formatter);
|
|
2799
|
+
this._format = formatter;
|
|
2800
|
+
return this;
|
|
2801
|
+
};
|
|
2802
|
+
return PropertyColumnModel;
|
|
2803
|
+
}(ColumnModel));
|
|
2804
|
+
var ListPropertyColumnModel = /** @class */ (function (_super) {
|
|
2805
|
+
__extends(ListPropertyColumnModel, _super);
|
|
2806
|
+
function ListPropertyColumnModel(property, defaults) {
|
|
2807
|
+
var _this = _super.call(this, property.toString(), defaults) || this;
|
|
2808
|
+
_this.property = property;
|
|
2809
|
+
_this._format = function (value) { return value.map(function (v) { return v === null || v === void 0 ? void 0 : v.toString(); }).join(', '); };
|
|
2810
|
+
_this.cellRenderer(DefaultCellRendererComponent);
|
|
2811
|
+
return _this;
|
|
2812
|
+
}
|
|
2813
|
+
ListPropertyColumnModel.prototype.cellRenderer = function (componentType) {
|
|
2814
|
+
var _this = this;
|
|
2815
|
+
this.configureCellRenderer(new ComponentCellRendererPortalRef(componentType, function (component, rowData) {
|
|
2816
|
+
component.value = _this._format(rowData.row[_this.property]);
|
|
2817
|
+
}));
|
|
2818
|
+
return this;
|
|
2819
|
+
};
|
|
2820
|
+
ListPropertyColumnModel.prototype.cellEditor = function (editor, validatorsOrInitialiser, initialiseComponent) {
|
|
2821
|
+
var _this = this;
|
|
2822
|
+
var validators = Array.isArray(validatorsOrInitialiser) ? validatorsOrInitialiser : undefined;
|
|
2823
|
+
var initialiser = ___default.isFunction(validatorsOrInitialiser) ? validatorsOrInitialiser : initialiseComponent;
|
|
2824
|
+
this.configureCellEditor(new CellEditorPortalRef(editor, function (component, editSession) {
|
|
2825
|
+
var formListModel = editSession.form.pluckList(_this.property);
|
|
2826
|
+
if (validators) {
|
|
2827
|
+
formListModel.validateUsing(validators);
|
|
2828
|
+
}
|
|
2829
|
+
component.listModel = formListModel;
|
|
2830
|
+
if (initialiser) {
|
|
2831
|
+
initialiser(component);
|
|
2832
|
+
}
|
|
2833
|
+
}));
|
|
2834
|
+
return this;
|
|
2835
|
+
};
|
|
2836
|
+
ListPropertyColumnModel.prototype.format = function (formatter) {
|
|
2837
|
+
assert$1.isFunction(formatter);
|
|
2838
|
+
this._format = formatter;
|
|
2839
|
+
return this;
|
|
2840
|
+
};
|
|
2841
|
+
return ListPropertyColumnModel;
|
|
2842
|
+
}(ColumnModel));
|
|
2843
|
+
var CustomValueColumnModel = /** @class */ (function (_super) {
|
|
2844
|
+
__extends(CustomValueColumnModel, _super);
|
|
2845
|
+
function CustomValueColumnModel(columnId, defaults, getValue) {
|
|
2846
|
+
var _this = _super.call(this, columnId, defaults) || this;
|
|
2847
|
+
_this.getValue = getValue;
|
|
2848
|
+
_this.cellRenderer(DefaultCellRendererComponent);
|
|
2849
|
+
return _this;
|
|
2850
|
+
}
|
|
2851
|
+
CustomValueColumnModel.prototype.cellRenderer = function (componentType) {
|
|
2852
|
+
var _this = this;
|
|
2853
|
+
this.configureCellRenderer(new ComponentCellRendererPortalRef(componentType, function (component, rowData) {
|
|
2854
|
+
component.value = _this.getValue(rowData.row);
|
|
2855
|
+
}));
|
|
2856
|
+
return this;
|
|
2857
|
+
};
|
|
2858
|
+
return CustomValueColumnModel;
|
|
2859
|
+
}(ColumnModel));
|
|
2860
|
+
var EditorControlColumnModel = /** @class */ (function (_super) {
|
|
2861
|
+
__extends(EditorControlColumnModel, _super);
|
|
2862
|
+
function EditorControlColumnModel(columnId, saveCommand, defaults) {
|
|
2863
|
+
var _this = _super.call(this, columnId, defaults) || this;
|
|
2864
|
+
_this.cellRenderer(EditRowControls);
|
|
2865
|
+
return _this;
|
|
2866
|
+
}
|
|
2867
|
+
EditorControlColumnModel.prototype.cellRenderer = function (componentType) {
|
|
2868
|
+
this.configureCellRenderer(new ComponentCellRendererPortalRef(componentType, function (component, rowData) {
|
|
2869
|
+
component.row = rowData.row;
|
|
2870
|
+
component.editSession = rowData.editSession;
|
|
2871
|
+
component.editRowCommand = rowData.editRowCommand;
|
|
2872
|
+
}));
|
|
2873
|
+
return this;
|
|
2874
|
+
};
|
|
2875
|
+
EditorControlColumnModel.prototype.getDefaultHeaderText = function () {
|
|
2876
|
+
return '';
|
|
2877
|
+
};
|
|
2878
|
+
return EditorControlColumnModel;
|
|
2879
|
+
}(ColumnModel));
|
|
2880
|
+
var CustomTemplateColumnModel = /** @class */ (function (_super) {
|
|
2881
|
+
__extends(CustomTemplateColumnModel, _super);
|
|
2882
|
+
function CustomTemplateColumnModel(columnId, defaults) {
|
|
2883
|
+
var _this = _super.call(this, columnId, defaults) || this;
|
|
2884
|
+
_this.config = new TemplateCellRendererPortalRef();
|
|
2885
|
+
_this.configureCellRenderer(_this.config);
|
|
2886
|
+
return _this;
|
|
2887
|
+
}
|
|
2888
|
+
CustomTemplateColumnModel.prototype.setTemplate = function (templateRef, viewContainer, fillCell, padChild) {
|
|
2889
|
+
this.config.registerPortal(templateRef, viewContainer, fillCell, padChild);
|
|
2890
|
+
};
|
|
2891
|
+
return CustomTemplateColumnModel;
|
|
2892
|
+
}(ColumnModel));
|
|
2893
|
+
var SelectionColumnModel = /** @class */ (function (_super) {
|
|
2894
|
+
__extends(SelectionColumnModel, _super);
|
|
2895
|
+
function SelectionColumnModel(columnId, defaults, selectionModel) {
|
|
2896
|
+
var _this = _super.call(this, columnId, defaults) || this;
|
|
2897
|
+
if (selectionModel instanceof MultipleSelectionModel) {
|
|
2898
|
+
_this.cellHeaderRenderer(SelectHeaderCellRendererComponent, function (component) {
|
|
2899
|
+
component.selectionModel = selectionModel;
|
|
2900
|
+
});
|
|
2901
|
+
}
|
|
2902
|
+
_this.configureCellRenderer(new ComponentCellRendererPortalRef(SelectCellRendererComponent, function (component, rowData) {
|
|
2903
|
+
component.row = rowData.row;
|
|
2904
|
+
component.selectionModel = selectionModel;
|
|
2905
|
+
}));
|
|
2906
|
+
return _this;
|
|
2907
|
+
}
|
|
2908
|
+
SelectionColumnModel.prototype.getDefaultHeaderText = function () {
|
|
2909
|
+
return '';
|
|
2910
|
+
};
|
|
2911
|
+
return SelectionColumnModel;
|
|
2912
|
+
}(ColumnModel));
|
|
2913
|
+
|
|
2914
|
+
// export type StringPropertiesOf<T> = { [K in keyof T]: T[K] extends string ? K : never }[keyof T];
|
|
2915
|
+
// export type NumberPropertiesOf<T> = { [K in keyof T]: T[K] extends number ? K : never }[keyof T];
|
|
2916
|
+
/**
|
|
2917
|
+
* Example:
|
|
2918
|
+
* @example
|
|
2919
|
+
* const model = TableModel.fromList(heroList, table => {
|
|
2920
|
+
* table.pluck("firstName");
|
|
2921
|
+
* table.pluck("lastName");
|
|
2922
|
+
* table.addCustomColumn("fullName", hero => `${hero.firstName} ${hero.lastName}`);
|
|
2923
|
+
* });
|
|
2924
|
+
*
|
|
2925
|
+
* Editable tables
|
|
2926
|
+
* @example
|
|
2927
|
+
* const saveCommand = UnaryCommand.create((form: Form<Hero>) => {
|
|
2928
|
+
* if (form.validate()) {
|
|
2929
|
+
* // normal form save stuff
|
|
2930
|
+
* return true; // finish editing
|
|
2931
|
+
* }
|
|
2932
|
+
* return false; // continue editiing
|
|
2933
|
+
* }
|
|
2934
|
+
* const colorsNames: ListModel<string> = ...;
|
|
2935
|
+
* const model = TableModel.fromList(heroList, table => {
|
|
2936
|
+
* table.pluck("firstName").cellEditor(StringInputComponent); <-- interface CellEditor { valueModel: FormValueModel<string> | ValueModel<string>; }
|
|
2937
|
+
* table.pluck("lastName").cellEditor(StringInputComponent, {
|
|
2938
|
+
* validators: [Validator.present("We need a last name")]
|
|
2939
|
+
* });
|
|
2940
|
+
* table.pluck("age").cellEditor(NumberInputComponent);
|
|
2941
|
+
* table.pluck("favoriteColor").cellEditor(SelectInputComponent, {
|
|
2942
|
+
* initialiseComponent(component: SelectInputComponent) {
|
|
2943
|
+
* selectInput.optionsModel = colorsNames; // <- initialise our component
|
|
2944
|
+
* }
|
|
2945
|
+
* });
|
|
2946
|
+
* table.addEditControls(saveCommand); // <- required to enable editing
|
|
2947
|
+
* });
|
|
2948
|
+
*
|
|
2949
|
+
* Selection models
|
|
2950
|
+
* @example
|
|
2951
|
+
* const model = TableModel.fromList(heroList, table => {
|
|
2952
|
+
* table.addSelectionColumn(selectionModel); // <- can be single or multiple selection model
|
|
2953
|
+
* table.pluck("firstName");
|
|
2954
|
+
* table.pluck("lastName");
|
|
2955
|
+
* });
|
|
2956
|
+
*
|
|
2957
|
+
* Custom cell renderers and editors
|
|
2958
|
+
* @example
|
|
2959
|
+
* const model = TableModel.fromList(heroList, table => {
|
|
2960
|
+
* table.pluck("favoriteColor")
|
|
2961
|
+
* .cellHeaderRenderer(CellHeaderRendererComponent, (component, column) => {
|
|
2962
|
+
* // configure your component with what ever you need.
|
|
2963
|
+
* });
|
|
2964
|
+
* .cellRenderer(CellRendererComponent) // <-- interface CellEditor { value: string; }
|
|
2965
|
+
* .cellEditor(CellEditorComponent.); // <-- interface CellEditor { valueModel: FormValueModel<string> | ValueModel<string>; }
|
|
2966
|
+
* table.addCustomColumn("fullName", hero => `${hero.firstName} ${hero.lastName}`);
|
|
2967
|
+
* });
|
|
2968
|
+
*
|
|
2969
|
+
* I18n
|
|
2970
|
+
* @example
|
|
2971
|
+
* [table.yml]
|
|
2972
|
+
* table:
|
|
2973
|
+
* columns(ColumnTextProperties[]):
|
|
2974
|
+
* firstName:
|
|
2975
|
+
* headerText: "First Name"
|
|
2976
|
+
* fullName:
|
|
2977
|
+
* headerText: "Full Name"
|
|
2978
|
+
*
|
|
2979
|
+
* const model = TableModel.fromList(heroList, table => {
|
|
2980
|
+
* table.pluck("favoriteColor").cellRenderer(...).cellEditor(...);
|
|
2981
|
+
* table.addCustomColumn("fullName", hero => `${hero.firstName} ${hero.lastName}`);
|
|
2982
|
+
*
|
|
2983
|
+
* table.columnTextProperties(I18n.table.columns); // <- configures all columns
|
|
2984
|
+
* });
|
|
2985
|
+
*/
|
|
2986
|
+
var TableModel = /** @class */ (function () {
|
|
2987
|
+
function TableModel(sourceOfTruth) {
|
|
2988
|
+
this.sourceOfTruth = sourceOfTruth;
|
|
2989
|
+
this._garbage = new GarbageCollector();
|
|
2990
|
+
this._columns = new MutableListModel();
|
|
2991
|
+
this._editorSessions = new MutableListModel();
|
|
2992
|
+
this._createForm = function (row) { return new Form(); };
|
|
2993
|
+
this.identityOf = sourceOfTruth.identityOf;
|
|
2994
|
+
var _a = Dsl.disposeWith(this._garbage), chain = _a.chain, valueOf = _a.valueOf, before = _a.before, when = _a.when, after = _a.after, observe = _a.observe, switchOn = _a.switchOn;
|
|
2995
|
+
this._columnsById = chain(this._columns).indexBy('columnId');
|
|
2996
|
+
this._rowsBeingEdited = new MutableListModel([], {
|
|
2997
|
+
identifiedWith: this.identityOf
|
|
2998
|
+
});
|
|
2999
|
+
this._editorSessionByRowId = chain(this._editorSessions).indexBy('rowId');
|
|
3000
|
+
this.editing = chain(this._editorSessions).count().isGreaterThan(0);
|
|
3001
|
+
this.dataSource = chain(this.sourceOfTruth).replaceAll(this.rowsBeingEdited);
|
|
3002
|
+
this.firstEditableColumn = chain(this.columns).select(function (c) { return c.hasEditorPortal(); }).first();
|
|
3003
|
+
}
|
|
3004
|
+
TableModel_1 = TableModel;
|
|
3005
|
+
TableModel.fromList = function (sourceOfTruth, builder) {
|
|
3006
|
+
var model = new TableModel_1(sourceOfTruth);
|
|
3007
|
+
builder(model);
|
|
3008
|
+
return model;
|
|
3009
|
+
};
|
|
3010
|
+
Object.defineProperty(TableModel.prototype, "rowsBeingEdited", {
|
|
3011
|
+
get: function () {
|
|
3012
|
+
return this._rowsBeingEdited.readonly;
|
|
3013
|
+
},
|
|
3014
|
+
enumerable: true,
|
|
3015
|
+
configurable: true
|
|
3016
|
+
});
|
|
3017
|
+
TableModel.prototype.getTrackByFunction = function () {
|
|
3018
|
+
var _this = this;
|
|
3019
|
+
return function (index, item) {
|
|
3020
|
+
return _this.identityOf ? _this.identityOf(item) : index;
|
|
3021
|
+
};
|
|
3022
|
+
};
|
|
3023
|
+
Object.defineProperty(TableModel.prototype, "columns", {
|
|
3024
|
+
get: function () {
|
|
3025
|
+
return this._columns.readonly;
|
|
3026
|
+
},
|
|
3027
|
+
enumerable: true,
|
|
3028
|
+
configurable: true
|
|
3029
|
+
});
|
|
3030
|
+
TableModel.prototype.pluck = function (property) {
|
|
3031
|
+
return this.addColumn(new PropertyColumnModel(property, this));
|
|
3032
|
+
};
|
|
3033
|
+
TableModel.prototype.pluckList = function (property) {
|
|
3034
|
+
return this.addColumn(new ListPropertyColumnModel(property, this));
|
|
3078
3035
|
};
|
|
3079
|
-
|
|
3080
|
-
|
|
3081
|
-
var ListPropertyColumnModel = /** @class */ (function (_super) {
|
|
3082
|
-
__extends(ListPropertyColumnModel, _super);
|
|
3083
|
-
function ListPropertyColumnModel(property, defaults) {
|
|
3084
|
-
var _this = _super.call(this, property.toString(), defaults) || this;
|
|
3085
|
-
_this.property = property;
|
|
3086
|
-
_this._format = function (value) { return value.map(function (v) { return v === null || v === void 0 ? void 0 : v.toString(); }).join(', '); };
|
|
3087
|
-
_this.cellRenderer(DefaultCellRendererComponent);
|
|
3088
|
-
return _this;
|
|
3089
|
-
}
|
|
3090
|
-
ListPropertyColumnModel.prototype.cellRenderer = function (componentType) {
|
|
3091
|
-
var _this = this;
|
|
3092
|
-
this.configureCellRenderer(new ComponentCellRendererPortalRef(componentType, function (component, rowData) {
|
|
3093
|
-
component.value = _this._format(rowData.row[_this.property]);
|
|
3094
|
-
}));
|
|
3095
|
-
return this;
|
|
3036
|
+
TableModel.prototype.addSelectionColumn = function (selectionModel) {
|
|
3037
|
+
return this.addColumn(new SelectionColumnModel('selection', this, selectionModel));
|
|
3096
3038
|
};
|
|
3097
|
-
|
|
3098
|
-
|
|
3099
|
-
|
|
3100
|
-
var initialiser = ___default.isFunction(validatorsOrInitialiser) ? validatorsOrInitialiser : initialiseComponent;
|
|
3101
|
-
this.configureCellEditor(new CellEditorPortalRef(editor, function (component, editSession) {
|
|
3102
|
-
var formListModel = editSession.form.pluckList(_this.property);
|
|
3103
|
-
if (validators) {
|
|
3104
|
-
formListModel.validateUsing(validators);
|
|
3105
|
-
}
|
|
3106
|
-
component.listModel = formListModel;
|
|
3107
|
-
if (initialiser) {
|
|
3108
|
-
initialiser(component);
|
|
3109
|
-
}
|
|
3110
|
-
}));
|
|
3111
|
-
return this;
|
|
3039
|
+
TableModel.prototype.addEditControls = function (saveCommand) {
|
|
3040
|
+
this.saveCommand = saveCommand;
|
|
3041
|
+
return this.addColumn(new EditorControlColumnModel('editControls', saveCommand, this));
|
|
3112
3042
|
};
|
|
3113
|
-
|
|
3114
|
-
|
|
3115
|
-
this._format = formatter;
|
|
3116
|
-
return this;
|
|
3043
|
+
TableModel.prototype.addCustomColumn = function (columnId, dataAccessor) {
|
|
3044
|
+
return this.addColumn(new CustomValueColumnModel(columnId, this, dataAccessor));
|
|
3117
3045
|
};
|
|
3118
|
-
|
|
3119
|
-
|
|
3120
|
-
var CustomValueColumnModel = /** @class */ (function (_super) {
|
|
3121
|
-
__extends(CustomValueColumnModel, _super);
|
|
3122
|
-
function CustomValueColumnModel(columnId, defaults, getValue) {
|
|
3123
|
-
var _this = _super.call(this, columnId, defaults) || this;
|
|
3124
|
-
_this.getValue = getValue;
|
|
3125
|
-
_this.cellRenderer(DefaultCellRendererComponent);
|
|
3126
|
-
return _this;
|
|
3127
|
-
}
|
|
3128
|
-
CustomValueColumnModel.prototype.cellRenderer = function (componentType) {
|
|
3129
|
-
var _this = this;
|
|
3130
|
-
this.configureCellRenderer(new ComponentCellRendererPortalRef(componentType, function (component, rowData) {
|
|
3131
|
-
component.value = _this.getValue(rowData.row);
|
|
3132
|
-
}));
|
|
3133
|
-
return this;
|
|
3046
|
+
TableModel.prototype.addTemplateColumn = function (columnId) {
|
|
3047
|
+
return this.addColumn(new CustomTemplateColumnModel(columnId, this));
|
|
3134
3048
|
};
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
var EditorControlColumnModel = /** @class */ (function (_super) {
|
|
3138
|
-
__extends(EditorControlColumnModel, _super);
|
|
3139
|
-
function EditorControlColumnModel(columnId, saveCommand, defaults) {
|
|
3140
|
-
var _this = _super.call(this, columnId, defaults) || this;
|
|
3141
|
-
_this.cellRenderer(EditRowControls);
|
|
3142
|
-
return _this;
|
|
3143
|
-
}
|
|
3144
|
-
EditorControlColumnModel.prototype.cellRenderer = function (componentType) {
|
|
3145
|
-
this.configureCellRenderer(new ComponentCellRendererPortalRef(componentType, function (component, rowData) {
|
|
3146
|
-
component.row = rowData.row;
|
|
3147
|
-
component.editSession = rowData.editSession;
|
|
3148
|
-
component.editRowCommand = rowData.editRowCommand;
|
|
3149
|
-
}));
|
|
3049
|
+
TableModel.prototype.useFormFactory = function (factory) {
|
|
3050
|
+
this._createForm = factory;
|
|
3150
3051
|
return this;
|
|
3151
3052
|
};
|
|
3152
|
-
|
|
3153
|
-
|
|
3053
|
+
TableModel.prototype.addColumn = function (column) {
|
|
3054
|
+
if (this._columnsById.get(column.columnId)) {
|
|
3055
|
+
lang.illegalState("Column with id=" + column.columnId + " already exists");
|
|
3056
|
+
}
|
|
3057
|
+
else {
|
|
3058
|
+
this._columns.push(column);
|
|
3059
|
+
}
|
|
3060
|
+
return column;
|
|
3154
3061
|
};
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
var CustomTemplateColumnModel = /** @class */ (function (_super) {
|
|
3158
|
-
__extends(CustomTemplateColumnModel, _super);
|
|
3159
|
-
function CustomTemplateColumnModel(columnId, defaults) {
|
|
3160
|
-
var _this = _super.call(this, columnId, defaults) || this;
|
|
3161
|
-
_this.config = new TemplateCellRendererPortalRef();
|
|
3162
|
-
_this.configureCellRenderer(_this.config);
|
|
3163
|
-
return _this;
|
|
3164
|
-
}
|
|
3165
|
-
CustomTemplateColumnModel.prototype.setTemplate = function (templateRef, viewContainer, fillCell, padChild) {
|
|
3166
|
-
this.config.registerPortal(templateRef, viewContainer, fillCell, padChild);
|
|
3062
|
+
TableModel.prototype.columnTextProperties = function (columnTextProperties) {
|
|
3063
|
+
this._columnTextPropertiesLookup = columnTextProperties;
|
|
3167
3064
|
};
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
function
|
|
3173
|
-
var _this =
|
|
3174
|
-
|
|
3175
|
-
|
|
3176
|
-
|
|
3065
|
+
TableModel.prototype.getColumnTextProperties = function (column) {
|
|
3066
|
+
var factory = this._columnTextPropertiesLookup ? this._columnTextPropertiesLookup[column.columnId] : undefined;
|
|
3067
|
+
return factory ? factory() : undefined;
|
|
3068
|
+
};
|
|
3069
|
+
TableModel.prototype.startEditSession = function (row) {
|
|
3070
|
+
var _this = this;
|
|
3071
|
+
var rowId = this.identityOf(row);
|
|
3072
|
+
if (this._rowsBeingEdited.query().indexOf(row) > -1) {
|
|
3073
|
+
return lang.illegalState("Row with id=" + rowId + " already being edited");
|
|
3074
|
+
}
|
|
3075
|
+
else {
|
|
3076
|
+
var editSession_1 = new EditSession(rowId, row, this._createForm(row), this.saveCommand);
|
|
3077
|
+
var when = Dsl.disposeWith(editSession_1).when;
|
|
3078
|
+
when.valueOf(editSession_1.liveRowValue).changes(function (editedValue) {
|
|
3079
|
+
_this._rowsBeingEdited.replaceOrPush(editedValue);
|
|
3080
|
+
}, { initialValue: 'triggerChangeUnlessNil' });
|
|
3081
|
+
this._editorSessions.push(editSession_1);
|
|
3082
|
+
editSession_1.onDispose(function () {
|
|
3083
|
+
_this._rowsBeingEdited.remove(editSession_1.liveRowValue.value);
|
|
3084
|
+
_this._editorSessions.remove(editSession_1);
|
|
3177
3085
|
});
|
|
3086
|
+
return editSession_1;
|
|
3178
3087
|
}
|
|
3179
|
-
_this.configureCellRenderer(new ComponentCellRendererPortalRef(SelectCellRendererComponent, function (component, rowData) {
|
|
3180
|
-
component.row = rowData.row;
|
|
3181
|
-
component.selectionModel = selectionModel;
|
|
3182
|
-
}));
|
|
3183
|
-
return _this;
|
|
3184
|
-
}
|
|
3185
|
-
SelectionColumnModel.prototype.getDefaultHeaderText = function () {
|
|
3186
|
-
return '';
|
|
3187
3088
|
};
|
|
3188
|
-
|
|
3189
|
-
|
|
3089
|
+
TableModel.prototype.getEditSessionFor = function (row) {
|
|
3090
|
+
return this._editorSessionByRowId.get(this.identityOf(row));
|
|
3091
|
+
};
|
|
3092
|
+
TableModel.prototype.cancelAllEditorSessions = function () {
|
|
3093
|
+
var _this = this;
|
|
3094
|
+
this._editorSessions.runInTransaction(function (draft) {
|
|
3095
|
+
_this._rowsBeingEdited.runInTransaction(function () {
|
|
3096
|
+
draft.value.forEach(function (session) { return session.dispose(); });
|
|
3097
|
+
});
|
|
3098
|
+
});
|
|
3099
|
+
};
|
|
3100
|
+
var TableModel_1;
|
|
3101
|
+
TableModel.ctorParameters = function () { return [
|
|
3102
|
+
{ type: ListModel }
|
|
3103
|
+
]; };
|
|
3104
|
+
TableModel = TableModel_1 = __decorate([
|
|
3105
|
+
TrackExternal.Strategy(new TrackExternal.OneTimeBinding()),
|
|
3106
|
+
__metadata("design:paramtypes", [ListModel])
|
|
3107
|
+
], TableModel);
|
|
3108
|
+
return TableModel;
|
|
3109
|
+
}());
|
|
3190
3110
|
|
|
3191
3111
|
/**
|
|
3192
3112
|
* Create your model:
|
|
@@ -3296,6 +3216,103 @@ var ColumnTemplateDirective = /** @class */ (function () {
|
|
|
3296
3216
|
return ColumnTemplateDirective;
|
|
3297
3217
|
}());
|
|
3298
3218
|
|
|
3219
|
+
var TableCellRendererComponent = /** @class */ (function (_super) {
|
|
3220
|
+
__extends(TableCellRendererComponent, _super);
|
|
3221
|
+
function TableCellRendererComponent() {
|
|
3222
|
+
var _this = _super.call(this) || this;
|
|
3223
|
+
_this.defaultClassNames = 'aup-cell-renderer';
|
|
3224
|
+
_this.fillCell = false;
|
|
3225
|
+
_this.padChild = false;
|
|
3226
|
+
_this.editRowCommand = Command.create(function () {
|
|
3227
|
+
_this.tableModel.startEditSession(_this.row);
|
|
3228
|
+
});
|
|
3229
|
+
return _this;
|
|
3230
|
+
}
|
|
3231
|
+
TableCellRendererComponent.prototype.ngOnInit = function () {
|
|
3232
|
+
var _a = Dsl.disposeWith(this), chain = _a.chain, valueOf = _a.valueOf, before = _a.before, when = _a.when, after = _a.after, observe = _a.observe, switchOn = _a.switchOn;
|
|
3233
|
+
this.firstEditableColumn = chain(this.tableModel.firstEditableColumn).equals(this.column); // this would break if the column changed.
|
|
3234
|
+
this.column.attachCell(this);
|
|
3235
|
+
};
|
|
3236
|
+
TableCellRendererComponent.prototype.hasActiveEditor = function () {
|
|
3237
|
+
return !!this.editSession && !!this.column.hasEditorPortal();
|
|
3238
|
+
};
|
|
3239
|
+
TableCellRendererComponent.prototype.initialiseRenderer = function (instance) {
|
|
3240
|
+
this.column.onRendererAttached(this, instance);
|
|
3241
|
+
};
|
|
3242
|
+
TableCellRendererComponent.prototype.initialiseEditor = function (instance) {
|
|
3243
|
+
var _this = this;
|
|
3244
|
+
this.column.onEditorAttached(this, instance);
|
|
3245
|
+
if (this.firstEditableColumn.value) {
|
|
3246
|
+
// @see https://github.com/angular/components/issues/12070
|
|
3247
|
+
setTimeout(function () { return _this.tryAndFocusEditor(instance); });
|
|
3248
|
+
}
|
|
3249
|
+
};
|
|
3250
|
+
TableCellRendererComponent.prototype.tryAndFocusEditor = function (editor) {
|
|
3251
|
+
var _a;
|
|
3252
|
+
if (editor.requestFocus) {
|
|
3253
|
+
editor.requestFocus();
|
|
3254
|
+
}
|
|
3255
|
+
else {
|
|
3256
|
+
var model = (editor['valueModel'] || editor['listModel']);
|
|
3257
|
+
(_a = model === null || model === void 0 ? void 0 : model.focusContext) === null || _a === void 0 ? void 0 : _a.requestFocus();
|
|
3258
|
+
}
|
|
3259
|
+
};
|
|
3260
|
+
// @Trace()
|
|
3261
|
+
TableCellRendererComponent.prototype.ngOnChanges = function (changes) {
|
|
3262
|
+
this.column.updatePortalContent(this);
|
|
3263
|
+
};
|
|
3264
|
+
TableCellRendererComponent.prototype.getRendererPortal = function () {
|
|
3265
|
+
return this[CELL_RENDERER_PORTAL];
|
|
3266
|
+
};
|
|
3267
|
+
TableCellRendererComponent.prototype.getEditorPortal = function () {
|
|
3268
|
+
return this[CELL_EDITOR_PORTAL];
|
|
3269
|
+
};
|
|
3270
|
+
TableCellRendererComponent.prototype.getRowData = function () {
|
|
3271
|
+
return {
|
|
3272
|
+
row: this.row,
|
|
3273
|
+
editSession: this.editSession,
|
|
3274
|
+
editRowCommand: this.editRowCommand
|
|
3275
|
+
};
|
|
3276
|
+
};
|
|
3277
|
+
__decorate([
|
|
3278
|
+
Input(),
|
|
3279
|
+
__metadata("design:type", Object)
|
|
3280
|
+
], TableCellRendererComponent.prototype, "row", void 0);
|
|
3281
|
+
__decorate([
|
|
3282
|
+
Input(),
|
|
3283
|
+
__metadata("design:type", ColumnModel)
|
|
3284
|
+
], TableCellRendererComponent.prototype, "column", void 0);
|
|
3285
|
+
__decorate([
|
|
3286
|
+
Input(),
|
|
3287
|
+
__metadata("design:type", EditSession)
|
|
3288
|
+
], TableCellRendererComponent.prototype, "editSession", void 0);
|
|
3289
|
+
__decorate([
|
|
3290
|
+
Input(),
|
|
3291
|
+
__metadata("design:type", TableModel)
|
|
3292
|
+
], TableCellRendererComponent.prototype, "tableModel", void 0);
|
|
3293
|
+
__decorate([
|
|
3294
|
+
HostBinding('class'),
|
|
3295
|
+
__metadata("design:type", Object)
|
|
3296
|
+
], TableCellRendererComponent.prototype, "defaultClassNames", void 0);
|
|
3297
|
+
__decorate([
|
|
3298
|
+
HostBinding('class.fillCell'),
|
|
3299
|
+
__metadata("design:type", Object)
|
|
3300
|
+
], TableCellRendererComponent.prototype, "fillCell", void 0);
|
|
3301
|
+
__decorate([
|
|
3302
|
+
HostBinding('class.padChild'),
|
|
3303
|
+
__metadata("design:type", Object)
|
|
3304
|
+
], TableCellRendererComponent.prototype, "padChild", void 0);
|
|
3305
|
+
TableCellRendererComponent = __decorate([
|
|
3306
|
+
Component({
|
|
3307
|
+
selector: 'aup-table-cell-renderer',
|
|
3308
|
+
template: "<ng-container *ngIf=\"!hasActiveEditor()\" [cdkPortalOutlet]=\"getRendererPortal()\" (attached)=\"initialiseRenderer($event.instance)\"></ng-container>\n<ng-container *ngIf=\"hasActiveEditor()\" [cdkPortalOutlet]=\"getEditorPortal()\" (attached)=\"initialiseEditor($event.instance)\"></ng-container>\n",
|
|
3309
|
+
styles: [""]
|
|
3310
|
+
}),
|
|
3311
|
+
__metadata("design:paramtypes", [])
|
|
3312
|
+
], TableCellRendererComponent);
|
|
3313
|
+
return TableCellRendererComponent;
|
|
3314
|
+
}(DisposableComponent));
|
|
3315
|
+
|
|
3299
3316
|
var TableHeaderCellRendererComponent = /** @class */ (function () {
|
|
3300
3317
|
function TableHeaderCellRendererComponent() {
|
|
3301
3318
|
this.defaultClassNames = 'aup-header-cell-renderer';
|
|
@@ -3517,7 +3534,8 @@ var ComponentsModule = /** @class */ (function () {
|
|
|
3517
3534
|
MatCheckboxModule,
|
|
3518
3535
|
InteractionModule,
|
|
3519
3536
|
MatTableModule,
|
|
3520
|
-
PortalModule
|
|
3537
|
+
PortalModule,
|
|
3538
|
+
CdkScrollableModule
|
|
3521
3539
|
],
|
|
3522
3540
|
exports: [
|
|
3523
3541
|
NumberInputComponent,
|
|
@@ -5574,9 +5592,9 @@ var PlaceOutletComponent = /** @class */ (function (_super) {
|
|
|
5574
5592
|
PlaceOutletComponent = __decorate([
|
|
5575
5593
|
Component({
|
|
5576
5594
|
selector: 'aup-place-outlet',
|
|
5577
|
-
template: "<ng-container *ngIf=\"animateModel.value\">\n <div class=\"router-outlet-container\"\n [@routeAnimations]=\"{value: getAnimationOrder(), params:{duration: animationDuration}}\"\n (@routeAnimations.start)=\"animationStarted()\"\n (@routeAnimations.done)=\"animationDone()\"\n >\n <router-outlet #routerOutlet=\"outlet\"\n (activate)=\"onOutletActivated(routerOutlet, $event)\"\n (deactivate)=\"onOutletDeactivated()\">\n </router-outlet>\n </div>\n</ng-container>\n\n<ng-container *ngIf=\"!animateModel.value\">\n <div class=\"router-outlet-container\">\n <router-outlet #routerOutlet=\"outlet\"\n (activate)=\"onOutletActivated(routerOutlet, $event)\"\n (deactivate)=\"onOutletDeactivated()\">\n </router-outlet>\n </div>\n</ng-container>\n\n",
|
|
5595
|
+
template: "<ng-container *ngIf=\"animateModel.value\">\n <div class=\"router-outlet-container\" cdkScrollable\n [@routeAnimations]=\"{value: getAnimationOrder(), params:{duration: animationDuration}}\"\n (@routeAnimations.start)=\"animationStarted()\"\n (@routeAnimations.done)=\"animationDone()\"\n >\n <router-outlet #routerOutlet=\"outlet\"\n (activate)=\"onOutletActivated(routerOutlet, $event)\"\n (deactivate)=\"onOutletDeactivated()\">\n </router-outlet>\n </div>\n</ng-container>\n\n<ng-container *ngIf=\"!animateModel.value\">\n <div class=\"router-outlet-container\" cdkScrollable>\n <router-outlet #routerOutlet=\"outlet\"\n (activate)=\"onOutletActivated(routerOutlet, $event)\"\n (deactivate)=\"onOutletDeactivated()\">\n </router-outlet>\n </div>\n</ng-container>\n\n",
|
|
5578
5596
|
animations: [LEFT_RIGHT_PLACE_ANIMATION],
|
|
5579
|
-
styles: [":host{display:flex;flex-direction:column;min-height:0
|
|
5597
|
+
styles: [":host{display:flex;flex-direction:column;min-height:0}.router-outlet-container{flex:1;display:block;position:relative;min-height:0;overflow-x:hidden;overflow-y:scroll}router-outlet{display:none}"]
|
|
5580
5598
|
}),
|
|
5581
5599
|
__param(2, Optional()), __param(2, Inject(AUP_PLACE_CONFIG)),
|
|
5582
5600
|
__param(3, SkipSelf()), __param(3, Optional()),
|