@coolon/angular-ui-powerups 1.13.1 → 1.13.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.
- package/CHANGELOG.md +8 -0
- package/bundles/coolon-angular-ui-powerups.umd.js +415 -399
- 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/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/column-model.js +4 -20
- 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 +20 -8
- 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-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/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/column-model.js +4 -20
- package/esm5/lib/components/table/column-model.js.map +1 -1
- package/esm5/lib/components/table/table-cell-renderer/table-cell-renderer.component.js +29 -15
- package/esm5/lib/components/table/table-cell-renderer/table-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 +387 -372
- package/fesm2015/coolon-angular-ui-powerups.js.map +1 -1
- package/fesm5/coolon-angular-ui-powerups.js +414 -397
- package/fesm5/coolon-angular-ui-powerups.js.map +1 -1
- package/lib/components/table/table-cell-renderer/table-cell-renderer.component.d.ts +6 -2
- 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 { __decorate, __metadata, __param, __awaiter } 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';
|
|
@@ -1129,26 +1130,34 @@ AddItemInteractionContextComponent = __decorate([
|
|
|
1129
1130
|
], AddItemInteractionContextComponent);
|
|
1130
1131
|
|
|
1131
1132
|
let PopupInteractionContextComponent = class PopupInteractionContextComponent extends DisposableComponent {
|
|
1132
|
-
constructor(_element, _overlay) {
|
|
1133
|
+
constructor(_element, _overlay, scrollable) {
|
|
1133
1134
|
super();
|
|
1134
1135
|
this._element = _element;
|
|
1135
1136
|
this._overlay = _overlay;
|
|
1136
1137
|
this.outputPortal = new ComponentPortal(InPlaceInteractionContextComponent);
|
|
1137
1138
|
this.anchorX = 'start';
|
|
1138
1139
|
this.anchorY = 'bottom';
|
|
1140
|
+
this.scrollContainers = scrollable ? [scrollable] : [];
|
|
1139
1141
|
}
|
|
1140
1142
|
get active() {
|
|
1141
1143
|
return this.isActive();
|
|
1142
1144
|
}
|
|
1143
1145
|
startActivity(activityType, data) {
|
|
1146
|
+
// console.log({ element: this._element });
|
|
1147
|
+
const self = this;
|
|
1144
1148
|
const overlayRef = this._overlay.create({
|
|
1145
1149
|
hasBackdrop: false,
|
|
1146
1150
|
panelClass: 'aup-popup-interaction-panel',
|
|
1147
1151
|
positionStrategy: this._overlay.position()
|
|
1148
1152
|
.flexibleConnectedTo(this._element)
|
|
1153
|
+
.withPush(true)
|
|
1149
1154
|
.withPositions(this.computePositions())
|
|
1150
1155
|
.withGrowAfterOpen(true)
|
|
1156
|
+
.withScrollableContainers(self.scrollContainers) // this isn't working. sigh.
|
|
1151
1157
|
});
|
|
1158
|
+
const subs = this.scrollContainers.map(sc => sc.elementScrolled().subscribe(() => {
|
|
1159
|
+
overlayRef.updatePosition();
|
|
1160
|
+
}));
|
|
1152
1161
|
const componentRef = overlayRef.attach(this.outputPortal);
|
|
1153
1162
|
this.interactionContext = componentRef.instance;
|
|
1154
1163
|
return new Promise((resolve, reject) => {
|
|
@@ -1157,7 +1166,13 @@ let PopupInteractionContextComponent = class PopupInteractionContextComponent ex
|
|
|
1157
1166
|
this.interactionContext.startActivity(activityType, data)
|
|
1158
1167
|
.then(resolve)
|
|
1159
1168
|
.catch(reject)
|
|
1160
|
-
.finally(() =>
|
|
1169
|
+
.finally(() => {
|
|
1170
|
+
subs.forEach(s => s.unsubscribe());
|
|
1171
|
+
overlayRef.dispose();
|
|
1172
|
+
});
|
|
1173
|
+
setTimeout(() => {
|
|
1174
|
+
overlayRef.updatePosition();
|
|
1175
|
+
});
|
|
1161
1176
|
});
|
|
1162
1177
|
});
|
|
1163
1178
|
}
|
|
@@ -1184,7 +1199,8 @@ let PopupInteractionContextComponent = class PopupInteractionContextComponent ex
|
|
|
1184
1199
|
};
|
|
1185
1200
|
PopupInteractionContextComponent.ctorParameters = () => [
|
|
1186
1201
|
{ type: ElementRef },
|
|
1187
|
-
{ type: Overlay }
|
|
1202
|
+
{ type: Overlay },
|
|
1203
|
+
{ type: CdkScrollable, decorators: [{ type: Optional }, { type: SkipSelf }] }
|
|
1188
1204
|
];
|
|
1189
1205
|
__decorate([
|
|
1190
1206
|
HostBinding('class.interaction-active'),
|
|
@@ -1205,7 +1221,8 @@ PopupInteractionContextComponent = __decorate([
|
|
|
1205
1221
|
template: "<ng-content></ng-content>\n",
|
|
1206
1222
|
styles: [":host{display:inline}:host.interaction-active{background:rgba(0,0,0,.05)}"]
|
|
1207
1223
|
}),
|
|
1208
|
-
|
|
1224
|
+
__param(2, Optional()), __param(2, SkipSelf()),
|
|
1225
|
+
__metadata("design:paramtypes", [ElementRef, Overlay, CdkScrollable])
|
|
1209
1226
|
], PopupInteractionContextComponent);
|
|
1210
1227
|
|
|
1211
1228
|
let InteractionContextTriggerFor = class InteractionContextTriggerFor extends GarbageCollector {
|
|
@@ -2022,7 +2039,7 @@ let ScrollContainerComponent = class ScrollContainerComponent {
|
|
|
2022
2039
|
ScrollContainerComponent = __decorate([
|
|
2023
2040
|
Component({
|
|
2024
2041
|
selector: 'aup-scroll-container',
|
|
2025
|
-
template: "<div class=\"container\">\n <ng-content></ng-content>\n</div>\n",
|
|
2042
|
+
template: "<div class=\"container\" cdkScrollable>\n <ng-content></ng-content>\n</div>\n",
|
|
2026
2043
|
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}"]
|
|
2027
2044
|
}),
|
|
2028
2045
|
__metadata("design:paramtypes", [])
|
|
@@ -2300,381 +2317,106 @@ SelectHeaderCellRendererComponent = __decorate([
|
|
|
2300
2317
|
__metadata("design:paramtypes", [])
|
|
2301
2318
|
], SelectHeaderCellRendererComponent);
|
|
2302
2319
|
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
* });
|
|
2314
|
-
*
|
|
2315
|
-
* Editable tables
|
|
2316
|
-
* @example
|
|
2317
|
-
* const saveCommand = UnaryCommand.create((form: Form<Hero>) => {
|
|
2318
|
-
* if (form.validate()) {
|
|
2319
|
-
* // normal form save stuff
|
|
2320
|
-
* return true; // finish editing
|
|
2321
|
-
* }
|
|
2322
|
-
* return false; // continue editiing
|
|
2323
|
-
* }
|
|
2324
|
-
* const colorsNames: ListModel<string> = ...;
|
|
2325
|
-
* const model = TableModel.fromList(heroList, table => {
|
|
2326
|
-
* table.pluck("firstName").cellEditor(StringInputComponent); <-- interface CellEditor { valueModel: FormValueModel<string> | ValueModel<string>; }
|
|
2327
|
-
* table.pluck("lastName").cellEditor(StringInputComponent, {
|
|
2328
|
-
* validators: [Validator.present("We need a last name")]
|
|
2329
|
-
* });
|
|
2330
|
-
* table.pluck("age").cellEditor(NumberInputComponent);
|
|
2331
|
-
* table.pluck("favoriteColor").cellEditor(SelectInputComponent, {
|
|
2332
|
-
* initialiseComponent(component: SelectInputComponent) {
|
|
2333
|
-
* selectInput.optionsModel = colorsNames; // <- initialise our component
|
|
2334
|
-
* }
|
|
2335
|
-
* });
|
|
2336
|
-
* table.addEditControls(saveCommand); // <- required to enable editing
|
|
2337
|
-
* });
|
|
2338
|
-
*
|
|
2339
|
-
* Selection models
|
|
2340
|
-
* @example
|
|
2341
|
-
* const model = TableModel.fromList(heroList, table => {
|
|
2342
|
-
* table.addSelectionColumn(selectionModel); // <- can be single or multiple selection model
|
|
2343
|
-
* table.pluck("firstName");
|
|
2344
|
-
* table.pluck("lastName");
|
|
2345
|
-
* });
|
|
2346
|
-
*
|
|
2347
|
-
* Custom cell renderers and editors
|
|
2348
|
-
* @example
|
|
2349
|
-
* const model = TableModel.fromList(heroList, table => {
|
|
2350
|
-
* table.pluck("favoriteColor")
|
|
2351
|
-
* .cellHeaderRenderer(CellHeaderRendererComponent, (component, column) => {
|
|
2352
|
-
* // configure your component with what ever you need.
|
|
2353
|
-
* });
|
|
2354
|
-
* .cellRenderer(CellRendererComponent) // <-- interface CellEditor { value: string; }
|
|
2355
|
-
* .cellEditor(CellEditorComponent.); // <-- interface CellEditor { valueModel: FormValueModel<string> | ValueModel<string>; }
|
|
2356
|
-
* table.addCustomColumn("fullName", hero => `${hero.firstName} ${hero.lastName}`);
|
|
2357
|
-
* });
|
|
2358
|
-
*
|
|
2359
|
-
* I18n
|
|
2360
|
-
* @example
|
|
2361
|
-
* [table.yml]
|
|
2362
|
-
* table:
|
|
2363
|
-
* columns(ColumnTextProperties[]):
|
|
2364
|
-
* firstName:
|
|
2365
|
-
* headerText: "First Name"
|
|
2366
|
-
* fullName:
|
|
2367
|
-
* headerText: "Full Name"
|
|
2368
|
-
*
|
|
2369
|
-
* const model = TableModel.fromList(heroList, table => {
|
|
2370
|
-
* table.pluck("favoriteColor").cellRenderer(...).cellEditor(...);
|
|
2371
|
-
* table.addCustomColumn("fullName", hero => `${hero.firstName} ${hero.lastName}`);
|
|
2372
|
-
*
|
|
2373
|
-
* table.columnTextProperties(I18n.table.columns); // <- configures all columns
|
|
2374
|
-
* });
|
|
2375
|
-
*/
|
|
2376
|
-
let TableModel = TableModel_1 = class TableModel {
|
|
2377
|
-
constructor(sourceOfTruth) {
|
|
2378
|
-
this.sourceOfTruth = sourceOfTruth;
|
|
2379
|
-
this._garbage = new GarbageCollector();
|
|
2380
|
-
this._columns = new MutableListModel();
|
|
2381
|
-
this._editorSessions = new MutableListModel();
|
|
2382
|
-
this._createForm = (row) => new Form();
|
|
2383
|
-
this.identityOf = sourceOfTruth.identityOf;
|
|
2384
|
-
const { chain, valueOf, before, when, after, observe, switchOn } = Dsl.disposeWith(this._garbage);
|
|
2385
|
-
this._columnsById = chain(this._columns).indexBy('columnId');
|
|
2386
|
-
this._rowsBeingEdited = new MutableListModel([], {
|
|
2387
|
-
identifiedWith: this.identityOf
|
|
2388
|
-
});
|
|
2389
|
-
this._editorSessionByRowId = chain(this._editorSessions).indexBy('rowId');
|
|
2390
|
-
this.editing = chain(this._editorSessions).count().isGreaterThan(0);
|
|
2391
|
-
this.dataSource = chain(this.sourceOfTruth).replaceAll(this.rowsBeingEdited);
|
|
2320
|
+
const HEADER_CELL_RENDERER_PORTAL = Symbol('aup-cell-header-renderer-component-ref');
|
|
2321
|
+
const CELL_RENDERER_PORTAL = Symbol('aup-cell-renderer-component-ref');
|
|
2322
|
+
const CELL_EDITOR_PORTAL = Symbol('aup-cell-editor-component-ref');
|
|
2323
|
+
const PORTAL_RENDERER_COMPONENT = Symbol('aup-cell-renderer-portal-component');
|
|
2324
|
+
const PORTAL_EDITOR_COMPONENT = Symbol('aup-cell-editor-portal-component');
|
|
2325
|
+
const noop = () => {
|
|
2326
|
+
};
|
|
2327
|
+
const ɵ0 = noop;
|
|
2328
|
+
class CellPortalRef {
|
|
2329
|
+
constructor() {
|
|
2392
2330
|
}
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2331
|
+
}
|
|
2332
|
+
class CellHeaderPortalRef extends CellPortalRef {
|
|
2333
|
+
constructor(componentType, initialiseHeader) {
|
|
2334
|
+
super();
|
|
2335
|
+
this.componentType = componentType;
|
|
2336
|
+
this.initialiseHeader = initialiseHeader;
|
|
2397
2337
|
}
|
|
2398
|
-
|
|
2399
|
-
|
|
2338
|
+
initialiseHost(host, columnModel) {
|
|
2339
|
+
assert$1.isTruthy(host);
|
|
2340
|
+
host[HEADER_CELL_RENDERER_PORTAL] = new ComponentPortal(this.componentType);
|
|
2400
2341
|
}
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
return this.identityOf ? this.identityOf(item) : index;
|
|
2404
|
-
};
|
|
2342
|
+
onPortalAttached(host, portalComponent) {
|
|
2343
|
+
this.initialiseHeader(portalComponent, host.column);
|
|
2405
2344
|
}
|
|
2406
|
-
|
|
2407
|
-
|
|
2345
|
+
}
|
|
2346
|
+
class CellRendererPortalRef extends CellPortalRef {
|
|
2347
|
+
}
|
|
2348
|
+
class ComponentCellRendererPortalRef extends CellRendererPortalRef {
|
|
2349
|
+
constructor(componentType, updateComponent) {
|
|
2350
|
+
super();
|
|
2351
|
+
this.componentType = componentType;
|
|
2352
|
+
this.updateComponent = updateComponent;
|
|
2408
2353
|
}
|
|
2409
|
-
|
|
2410
|
-
|
|
2354
|
+
initialiseHost(host, columnModel) {
|
|
2355
|
+
host[CELL_RENDERER_PORTAL] = new ComponentPortal(this.componentType);
|
|
2411
2356
|
}
|
|
2412
|
-
|
|
2413
|
-
|
|
2357
|
+
onPortalAttached(host, portalComponent) {
|
|
2358
|
+
host[PORTAL_RENDERER_COMPONENT] = portalComponent;
|
|
2359
|
+
this.updateComponent(portalComponent, host.getRowData());
|
|
2414
2360
|
}
|
|
2415
|
-
|
|
2416
|
-
|
|
2361
|
+
pushState(host) {
|
|
2362
|
+
if (host[PORTAL_RENDERER_COMPONENT]) {
|
|
2363
|
+
this.updateComponent(host[PORTAL_RENDERER_COMPONENT], host.getRowData());
|
|
2364
|
+
}
|
|
2417
2365
|
}
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2366
|
+
}
|
|
2367
|
+
class CellEditorPortalRef extends CellPortalRef {
|
|
2368
|
+
constructor(componentType, initialiseEditorSession) {
|
|
2369
|
+
super();
|
|
2370
|
+
this.componentType = componentType;
|
|
2371
|
+
this.initialiseEditorSession = initialiseEditorSession;
|
|
2421
2372
|
}
|
|
2422
|
-
|
|
2423
|
-
|
|
2373
|
+
initialiseHost(host, columnModel) {
|
|
2374
|
+
assert$1.isTruthy(host);
|
|
2375
|
+
host[CELL_EDITOR_PORTAL] = new ComponentPortal(this.componentType);
|
|
2424
2376
|
}
|
|
2425
|
-
|
|
2426
|
-
|
|
2377
|
+
// @Trace()
|
|
2378
|
+
onPortalAttached(host, portalComponent) {
|
|
2379
|
+
host[PORTAL_EDITOR_COMPONENT] = portalComponent;
|
|
2380
|
+
this.initialiseEditorSession(portalComponent, host.editSession);
|
|
2427
2381
|
}
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2382
|
+
}
|
|
2383
|
+
class TemplateCellRendererPortalRef extends CellRendererPortalRef {
|
|
2384
|
+
constructor() {
|
|
2385
|
+
super();
|
|
2431
2386
|
}
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
this._columns.push(column);
|
|
2438
|
-
}
|
|
2439
|
-
return column;
|
|
2387
|
+
registerPortal(templateRef, viewContainer, fillCell, padChild) {
|
|
2388
|
+
this.templateRef = templateRef;
|
|
2389
|
+
this.viewContainer = viewContainer;
|
|
2390
|
+
this.fillCell = fillCell;
|
|
2391
|
+
this.padChild = padChild;
|
|
2440
2392
|
}
|
|
2441
|
-
|
|
2442
|
-
|
|
2393
|
+
initialiseHost(host, columnModel) {
|
|
2394
|
+
assert$1.isTruthy(host);
|
|
2443
2395
|
}
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2396
|
+
// @Trace()
|
|
2397
|
+
onPortalAttached(host, portalComponent) {
|
|
2398
|
+
// don't care
|
|
2447
2399
|
}
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
}
|
|
2453
|
-
else {
|
|
2454
|
-
const editSession = new EditSession(rowId, row, this._createForm(row), this.saveCommand);
|
|
2455
|
-
const { when } = Dsl.disposeWith(editSession);
|
|
2456
|
-
when.valueOf(editSession.liveRowValue).changes((editedValue) => {
|
|
2457
|
-
this._rowsBeingEdited.replaceOrPush(editedValue);
|
|
2458
|
-
}, { initialValue: 'triggerChangeUnlessNil' });
|
|
2459
|
-
this._editorSessions.push(editSession);
|
|
2460
|
-
editSession.onDispose(() => {
|
|
2461
|
-
this._rowsBeingEdited.remove(editSession.liveRowValue.value);
|
|
2462
|
-
this._editorSessions.remove(editSession);
|
|
2463
|
-
});
|
|
2464
|
-
return editSession;
|
|
2465
|
-
}
|
|
2400
|
+
pushState(host) {
|
|
2401
|
+
host[CELL_RENDERER_PORTAL] = this.createPortal(host.getRowData());
|
|
2402
|
+
host.fillCell = this.fillCell;
|
|
2403
|
+
host.padChild = this.padChild;
|
|
2466
2404
|
}
|
|
2467
|
-
|
|
2468
|
-
return this.
|
|
2405
|
+
createPortal(data) {
|
|
2406
|
+
return new TemplatePortal(this.templateRef, this.viewContainer, Object.assign(Object.assign({}, (data)), { $implicit: data.row }));
|
|
2469
2407
|
}
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2408
|
+
}
|
|
2409
|
+
class ColumnModel {
|
|
2410
|
+
constructor(columnId, defaults) {
|
|
2411
|
+
this.columnId = columnId;
|
|
2412
|
+
this.defaults = defaults;
|
|
2413
|
+
this.cellHeaderRenderer(DefaultHeaderCellRendererComponent, (component, column) => {
|
|
2414
|
+
component.headerText = column.getHeaderText();
|
|
2475
2415
|
});
|
|
2476
2416
|
}
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
];
|
|
2481
|
-
TableModel = TableModel_1 = __decorate([
|
|
2482
|
-
TrackExternal.Strategy(new TrackExternal.OneTimeBinding()),
|
|
2483
|
-
__metadata("design:paramtypes", [ListModel])
|
|
2484
|
-
], TableModel);
|
|
2485
|
-
|
|
2486
|
-
let TableCellRendererComponent = class TableCellRendererComponent {
|
|
2487
|
-
constructor() {
|
|
2488
|
-
this.defaultClassNames = 'aup-cell-renderer';
|
|
2489
|
-
this.fillCell = false;
|
|
2490
|
-
this.padChild = false;
|
|
2491
|
-
this.editRowCommand = Command.create(() => {
|
|
2492
|
-
this.tableModel.startEditSession(this.row);
|
|
2493
|
-
});
|
|
2494
|
-
}
|
|
2495
|
-
ngOnInit() {
|
|
2496
|
-
this.column.attachCell(this);
|
|
2497
|
-
}
|
|
2498
|
-
hasActiveEditor() {
|
|
2499
|
-
return !!this.editSession && !!this.column.hasEditorPortal();
|
|
2500
|
-
}
|
|
2501
|
-
initialiseRenderer(instance) {
|
|
2502
|
-
this.column.onRendererAttached(this, instance);
|
|
2503
|
-
}
|
|
2504
|
-
initialiseEditor(instance) {
|
|
2505
|
-
this.column.onEditorAttached(this, instance);
|
|
2506
|
-
}
|
|
2507
|
-
// @Trace()
|
|
2508
|
-
ngOnChanges(changes) {
|
|
2509
|
-
this.column.updatePortalContent(this);
|
|
2510
|
-
}
|
|
2511
|
-
getRendererPortal() {
|
|
2512
|
-
return this[CELL_RENDERER_PORTAL];
|
|
2513
|
-
}
|
|
2514
|
-
getEditorPortal() {
|
|
2515
|
-
return this[CELL_EDITOR_PORTAL];
|
|
2516
|
-
}
|
|
2517
|
-
getRowData() {
|
|
2518
|
-
return {
|
|
2519
|
-
row: this.row,
|
|
2520
|
-
editSession: this.editSession,
|
|
2521
|
-
editRowCommand: this.editRowCommand
|
|
2522
|
-
};
|
|
2523
|
-
}
|
|
2524
|
-
};
|
|
2525
|
-
__decorate([
|
|
2526
|
-
Input(),
|
|
2527
|
-
__metadata("design:type", Object)
|
|
2528
|
-
], TableCellRendererComponent.prototype, "row", void 0);
|
|
2529
|
-
__decorate([
|
|
2530
|
-
Input(),
|
|
2531
|
-
__metadata("design:type", ColumnModel)
|
|
2532
|
-
], TableCellRendererComponent.prototype, "column", void 0);
|
|
2533
|
-
__decorate([
|
|
2534
|
-
Input(),
|
|
2535
|
-
__metadata("design:type", EditSession)
|
|
2536
|
-
], TableCellRendererComponent.prototype, "editSession", void 0);
|
|
2537
|
-
__decorate([
|
|
2538
|
-
Input(),
|
|
2539
|
-
__metadata("design:type", TableModel)
|
|
2540
|
-
], TableCellRendererComponent.prototype, "tableModel", void 0);
|
|
2541
|
-
__decorate([
|
|
2542
|
-
HostBinding('class'),
|
|
2543
|
-
__metadata("design:type", Object)
|
|
2544
|
-
], TableCellRendererComponent.prototype, "defaultClassNames", void 0);
|
|
2545
|
-
__decorate([
|
|
2546
|
-
HostBinding('class.fillCell'),
|
|
2547
|
-
__metadata("design:type", Object)
|
|
2548
|
-
], TableCellRendererComponent.prototype, "fillCell", void 0);
|
|
2549
|
-
__decorate([
|
|
2550
|
-
HostBinding('class.padChild'),
|
|
2551
|
-
__metadata("design:type", Object)
|
|
2552
|
-
], TableCellRendererComponent.prototype, "padChild", void 0);
|
|
2553
|
-
__decorate([
|
|
2554
|
-
Trace(),
|
|
2555
|
-
__metadata("design:type", Function),
|
|
2556
|
-
__metadata("design:paramtypes", [Object]),
|
|
2557
|
-
__metadata("design:returntype", void 0)
|
|
2558
|
-
], TableCellRendererComponent.prototype, "initialiseEditor", null);
|
|
2559
|
-
TableCellRendererComponent = __decorate([
|
|
2560
|
-
Component({
|
|
2561
|
-
selector: 'aup-table-cell-renderer',
|
|
2562
|
-
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",
|
|
2563
|
-
styles: [""]
|
|
2564
|
-
}),
|
|
2565
|
-
__metadata("design:paramtypes", [])
|
|
2566
|
-
], TableCellRendererComponent);
|
|
2567
|
-
|
|
2568
|
-
const HEADER_CELL_RENDERER_PORTAL = Symbol('aup-cell-header-renderer-component-ref');
|
|
2569
|
-
const CELL_RENDERER_PORTAL = Symbol('aup-cell-renderer-component-ref');
|
|
2570
|
-
const CELL_EDITOR_PORTAL = Symbol('aup-cell-editor-component-ref');
|
|
2571
|
-
const PORTAL_RENDERER_COMPONENT = Symbol('aup-cell-renderer-portal-component');
|
|
2572
|
-
const PORTAL_EDITOR_COMPONENT = Symbol('aup-cell-editor-portal-component');
|
|
2573
|
-
const noop = () => {
|
|
2574
|
-
};
|
|
2575
|
-
const ɵ0 = noop;
|
|
2576
|
-
class CellPortalRef {
|
|
2577
|
-
constructor() {
|
|
2578
|
-
}
|
|
2579
|
-
}
|
|
2580
|
-
class CellHeaderPortalRef extends CellPortalRef {
|
|
2581
|
-
constructor(componentType, initialiseHeader) {
|
|
2582
|
-
super();
|
|
2583
|
-
this.componentType = componentType;
|
|
2584
|
-
this.initialiseHeader = initialiseHeader;
|
|
2585
|
-
}
|
|
2586
|
-
initialiseHost(host, columnModel) {
|
|
2587
|
-
assert$1.isTruthy(host);
|
|
2588
|
-
host[HEADER_CELL_RENDERER_PORTAL] = new ComponentPortal(this.componentType);
|
|
2589
|
-
}
|
|
2590
|
-
onPortalAttached(host, portalComponent) {
|
|
2591
|
-
this.initialiseHeader(portalComponent, host.column);
|
|
2592
|
-
}
|
|
2593
|
-
}
|
|
2594
|
-
class CellRendererPortalRef extends CellPortalRef {
|
|
2595
|
-
}
|
|
2596
|
-
class ComponentCellRendererPortalRef extends CellRendererPortalRef {
|
|
2597
|
-
constructor(componentType, updateComponent) {
|
|
2598
|
-
super();
|
|
2599
|
-
this.componentType = componentType;
|
|
2600
|
-
this.updateComponent = updateComponent;
|
|
2601
|
-
}
|
|
2602
|
-
initialiseHost(host, columnModel) {
|
|
2603
|
-
host[CELL_RENDERER_PORTAL] = new ComponentPortal(this.componentType);
|
|
2604
|
-
}
|
|
2605
|
-
onPortalAttached(host, portalComponent) {
|
|
2606
|
-
host[PORTAL_RENDERER_COMPONENT] = portalComponent;
|
|
2607
|
-
this.updateComponent(portalComponent, host.getRowData());
|
|
2608
|
-
}
|
|
2609
|
-
pushState(host) {
|
|
2610
|
-
if (host[PORTAL_RENDERER_COMPONENT]) {
|
|
2611
|
-
this.updateComponent(host[PORTAL_RENDERER_COMPONENT], host.getRowData());
|
|
2612
|
-
}
|
|
2613
|
-
}
|
|
2614
|
-
}
|
|
2615
|
-
class CellEditorPortalRef extends CellPortalRef {
|
|
2616
|
-
constructor(componentType, initialiseEditorSession) {
|
|
2617
|
-
super();
|
|
2618
|
-
this.componentType = componentType;
|
|
2619
|
-
this.initialiseEditorSession = initialiseEditorSession;
|
|
2620
|
-
}
|
|
2621
|
-
initialiseHost(host, columnModel) {
|
|
2622
|
-
assert$1.isTruthy(host);
|
|
2623
|
-
host[CELL_EDITOR_PORTAL] = new ComponentPortal(this.componentType);
|
|
2624
|
-
}
|
|
2625
|
-
onPortalAttached(host, portalComponent) {
|
|
2626
|
-
host[PORTAL_EDITOR_COMPONENT] = portalComponent;
|
|
2627
|
-
this.initialiseEditorSession(portalComponent, host.editSession);
|
|
2628
|
-
}
|
|
2629
|
-
}
|
|
2630
|
-
__decorate([
|
|
2631
|
-
Trace(),
|
|
2632
|
-
__metadata("design:type", Function),
|
|
2633
|
-
__metadata("design:paramtypes", [TableCellRendererComponent, Object]),
|
|
2634
|
-
__metadata("design:returntype", void 0)
|
|
2635
|
-
], CellEditorPortalRef.prototype, "onPortalAttached", null);
|
|
2636
|
-
class TemplateCellRendererPortalRef extends CellRendererPortalRef {
|
|
2637
|
-
constructor() {
|
|
2638
|
-
super();
|
|
2639
|
-
}
|
|
2640
|
-
registerPortal(templateRef, viewContainer, fillCell, padChild) {
|
|
2641
|
-
this.templateRef = templateRef;
|
|
2642
|
-
this.viewContainer = viewContainer;
|
|
2643
|
-
this.fillCell = fillCell;
|
|
2644
|
-
this.padChild = padChild;
|
|
2645
|
-
}
|
|
2646
|
-
initialiseHost(host, columnModel) {
|
|
2647
|
-
assert$1.isTruthy(host);
|
|
2648
|
-
}
|
|
2649
|
-
onPortalAttached(host, portalComponent) {
|
|
2650
|
-
// don't care
|
|
2651
|
-
}
|
|
2652
|
-
pushState(host) {
|
|
2653
|
-
host[CELL_RENDERER_PORTAL] = this.createPortal(host.getRowData());
|
|
2654
|
-
host.fillCell = this.fillCell;
|
|
2655
|
-
host.padChild = this.padChild;
|
|
2656
|
-
}
|
|
2657
|
-
createPortal(data) {
|
|
2658
|
-
return new TemplatePortal(this.templateRef, this.viewContainer, Object.assign(Object.assign({}, (data)), { $implicit: data.row }));
|
|
2659
|
-
}
|
|
2660
|
-
}
|
|
2661
|
-
__decorate([
|
|
2662
|
-
Trace(),
|
|
2663
|
-
__metadata("design:type", Function),
|
|
2664
|
-
__metadata("design:paramtypes", [TableCellRendererComponent, void 0]),
|
|
2665
|
-
__metadata("design:returntype", void 0)
|
|
2666
|
-
], TemplateCellRendererPortalRef.prototype, "onPortalAttached", null);
|
|
2667
|
-
class ColumnModel {
|
|
2668
|
-
constructor(columnId, defaults) {
|
|
2669
|
-
this.columnId = columnId;
|
|
2670
|
-
this.defaults = defaults;
|
|
2671
|
-
this.cellHeaderRenderer(DefaultHeaderCellRendererComponent, (component, column) => {
|
|
2672
|
-
component.headerText = column.getHeaderText();
|
|
2673
|
-
});
|
|
2674
|
-
}
|
|
2675
|
-
getHeaderText() {
|
|
2676
|
-
var _a;
|
|
2677
|
-
return ((_a = this.getColumnTextProperties()) === null || _a === void 0 ? void 0 : _a.headerText()) || this.getDefaultHeaderText();
|
|
2417
|
+
getHeaderText() {
|
|
2418
|
+
var _a;
|
|
2419
|
+
return ((_a = this.getColumnTextProperties()) === null || _a === void 0 ? void 0 : _a.headerText()) || this.getDefaultHeaderText();
|
|
2678
2420
|
}
|
|
2679
2421
|
getDefaultHeaderText() {
|
|
2680
2422
|
return this.columnId;
|
|
@@ -2717,6 +2459,7 @@ class ColumnModel {
|
|
|
2717
2459
|
onRendererAttached(host, component) {
|
|
2718
2460
|
this._cellRendererPortalRef.onPortalAttached(host, component);
|
|
2719
2461
|
}
|
|
2462
|
+
// @Trace()
|
|
2720
2463
|
onEditorAttached(host, component) {
|
|
2721
2464
|
this._cellEditorPortalRef.onPortalAttached(host, component);
|
|
2722
2465
|
}
|
|
@@ -2736,12 +2479,6 @@ __decorate([
|
|
|
2736
2479
|
__metadata("design:paramtypes", []),
|
|
2737
2480
|
__metadata("design:returntype", Object)
|
|
2738
2481
|
], ColumnModel.prototype, "getColumnTextProperties", null);
|
|
2739
|
-
__decorate([
|
|
2740
|
-
Trace(),
|
|
2741
|
-
__metadata("design:type", Function),
|
|
2742
|
-
__metadata("design:paramtypes", [TableCellRendererComponent, Object]),
|
|
2743
|
-
__metadata("design:returntype", void 0)
|
|
2744
|
-
], ColumnModel.prototype, "onEditorAttached", null);
|
|
2745
2482
|
class PropertyColumnModel extends ColumnModel {
|
|
2746
2483
|
constructor(property, defaults) {
|
|
2747
2484
|
super(property.toString(), defaults);
|
|
@@ -2868,6 +2605,190 @@ class SelectionColumnModel extends ColumnModel {
|
|
|
2868
2605
|
}
|
|
2869
2606
|
}
|
|
2870
2607
|
|
|
2608
|
+
var TableModel_1;
|
|
2609
|
+
// export type StringPropertiesOf<T> = { [K in keyof T]: T[K] extends string ? K : never }[keyof T];
|
|
2610
|
+
// export type NumberPropertiesOf<T> = { [K in keyof T]: T[K] extends number ? K : never }[keyof T];
|
|
2611
|
+
/**
|
|
2612
|
+
* Example:
|
|
2613
|
+
* @example
|
|
2614
|
+
* const model = TableModel.fromList(heroList, table => {
|
|
2615
|
+
* table.pluck("firstName");
|
|
2616
|
+
* table.pluck("lastName");
|
|
2617
|
+
* table.addCustomColumn("fullName", hero => `${hero.firstName} ${hero.lastName}`);
|
|
2618
|
+
* });
|
|
2619
|
+
*
|
|
2620
|
+
* Editable tables
|
|
2621
|
+
* @example
|
|
2622
|
+
* const saveCommand = UnaryCommand.create((form: Form<Hero>) => {
|
|
2623
|
+
* if (form.validate()) {
|
|
2624
|
+
* // normal form save stuff
|
|
2625
|
+
* return true; // finish editing
|
|
2626
|
+
* }
|
|
2627
|
+
* return false; // continue editiing
|
|
2628
|
+
* }
|
|
2629
|
+
* const colorsNames: ListModel<string> = ...;
|
|
2630
|
+
* const model = TableModel.fromList(heroList, table => {
|
|
2631
|
+
* table.pluck("firstName").cellEditor(StringInputComponent); <-- interface CellEditor { valueModel: FormValueModel<string> | ValueModel<string>; }
|
|
2632
|
+
* table.pluck("lastName").cellEditor(StringInputComponent, {
|
|
2633
|
+
* validators: [Validator.present("We need a last name")]
|
|
2634
|
+
* });
|
|
2635
|
+
* table.pluck("age").cellEditor(NumberInputComponent);
|
|
2636
|
+
* table.pluck("favoriteColor").cellEditor(SelectInputComponent, {
|
|
2637
|
+
* initialiseComponent(component: SelectInputComponent) {
|
|
2638
|
+
* selectInput.optionsModel = colorsNames; // <- initialise our component
|
|
2639
|
+
* }
|
|
2640
|
+
* });
|
|
2641
|
+
* table.addEditControls(saveCommand); // <- required to enable editing
|
|
2642
|
+
* });
|
|
2643
|
+
*
|
|
2644
|
+
* Selection models
|
|
2645
|
+
* @example
|
|
2646
|
+
* const model = TableModel.fromList(heroList, table => {
|
|
2647
|
+
* table.addSelectionColumn(selectionModel); // <- can be single or multiple selection model
|
|
2648
|
+
* table.pluck("firstName");
|
|
2649
|
+
* table.pluck("lastName");
|
|
2650
|
+
* });
|
|
2651
|
+
*
|
|
2652
|
+
* Custom cell renderers and editors
|
|
2653
|
+
* @example
|
|
2654
|
+
* const model = TableModel.fromList(heroList, table => {
|
|
2655
|
+
* table.pluck("favoriteColor")
|
|
2656
|
+
* .cellHeaderRenderer(CellHeaderRendererComponent, (component, column) => {
|
|
2657
|
+
* // configure your component with what ever you need.
|
|
2658
|
+
* });
|
|
2659
|
+
* .cellRenderer(CellRendererComponent) // <-- interface CellEditor { value: string; }
|
|
2660
|
+
* .cellEditor(CellEditorComponent.); // <-- interface CellEditor { valueModel: FormValueModel<string> | ValueModel<string>; }
|
|
2661
|
+
* table.addCustomColumn("fullName", hero => `${hero.firstName} ${hero.lastName}`);
|
|
2662
|
+
* });
|
|
2663
|
+
*
|
|
2664
|
+
* I18n
|
|
2665
|
+
* @example
|
|
2666
|
+
* [table.yml]
|
|
2667
|
+
* table:
|
|
2668
|
+
* columns(ColumnTextProperties[]):
|
|
2669
|
+
* firstName:
|
|
2670
|
+
* headerText: "First Name"
|
|
2671
|
+
* fullName:
|
|
2672
|
+
* headerText: "Full Name"
|
|
2673
|
+
*
|
|
2674
|
+
* const model = TableModel.fromList(heroList, table => {
|
|
2675
|
+
* table.pluck("favoriteColor").cellRenderer(...).cellEditor(...);
|
|
2676
|
+
* table.addCustomColumn("fullName", hero => `${hero.firstName} ${hero.lastName}`);
|
|
2677
|
+
*
|
|
2678
|
+
* table.columnTextProperties(I18n.table.columns); // <- configures all columns
|
|
2679
|
+
* });
|
|
2680
|
+
*/
|
|
2681
|
+
let TableModel = TableModel_1 = class TableModel {
|
|
2682
|
+
constructor(sourceOfTruth) {
|
|
2683
|
+
this.sourceOfTruth = sourceOfTruth;
|
|
2684
|
+
this._garbage = new GarbageCollector();
|
|
2685
|
+
this._columns = new MutableListModel();
|
|
2686
|
+
this._editorSessions = new MutableListModel();
|
|
2687
|
+
this._createForm = (row) => new Form();
|
|
2688
|
+
this.identityOf = sourceOfTruth.identityOf;
|
|
2689
|
+
const { chain, valueOf, before, when, after, observe, switchOn } = Dsl.disposeWith(this._garbage);
|
|
2690
|
+
this._columnsById = chain(this._columns).indexBy('columnId');
|
|
2691
|
+
this._rowsBeingEdited = new MutableListModel([], {
|
|
2692
|
+
identifiedWith: this.identityOf
|
|
2693
|
+
});
|
|
2694
|
+
this._editorSessionByRowId = chain(this._editorSessions).indexBy('rowId');
|
|
2695
|
+
this.editing = chain(this._editorSessions).count().isGreaterThan(0);
|
|
2696
|
+
this.dataSource = chain(this.sourceOfTruth).replaceAll(this.rowsBeingEdited);
|
|
2697
|
+
this.firstEditableColumn = chain(this.columns).select(c => c.hasEditorPortal()).first();
|
|
2698
|
+
}
|
|
2699
|
+
static fromList(sourceOfTruth, builder) {
|
|
2700
|
+
const model = new TableModel_1(sourceOfTruth);
|
|
2701
|
+
builder(model);
|
|
2702
|
+
return model;
|
|
2703
|
+
}
|
|
2704
|
+
get rowsBeingEdited() {
|
|
2705
|
+
return this._rowsBeingEdited.readonly;
|
|
2706
|
+
}
|
|
2707
|
+
getTrackByFunction() {
|
|
2708
|
+
return (index, item) => {
|
|
2709
|
+
return this.identityOf ? this.identityOf(item) : index;
|
|
2710
|
+
};
|
|
2711
|
+
}
|
|
2712
|
+
get columns() {
|
|
2713
|
+
return this._columns.readonly;
|
|
2714
|
+
}
|
|
2715
|
+
pluck(property) {
|
|
2716
|
+
return this.addColumn(new PropertyColumnModel(property, this));
|
|
2717
|
+
}
|
|
2718
|
+
pluckList(property) {
|
|
2719
|
+
return this.addColumn(new ListPropertyColumnModel(property, this));
|
|
2720
|
+
}
|
|
2721
|
+
addSelectionColumn(selectionModel) {
|
|
2722
|
+
return this.addColumn(new SelectionColumnModel('selection', this, selectionModel));
|
|
2723
|
+
}
|
|
2724
|
+
addEditControls(saveCommand) {
|
|
2725
|
+
this.saveCommand = saveCommand;
|
|
2726
|
+
return this.addColumn(new EditorControlColumnModel('editControls', saveCommand, this));
|
|
2727
|
+
}
|
|
2728
|
+
addCustomColumn(columnId, dataAccessor) {
|
|
2729
|
+
return this.addColumn(new CustomValueColumnModel(columnId, this, dataAccessor));
|
|
2730
|
+
}
|
|
2731
|
+
addTemplateColumn(columnId) {
|
|
2732
|
+
return this.addColumn(new CustomTemplateColumnModel(columnId, this));
|
|
2733
|
+
}
|
|
2734
|
+
useFormFactory(factory) {
|
|
2735
|
+
this._createForm = factory;
|
|
2736
|
+
return this;
|
|
2737
|
+
}
|
|
2738
|
+
addColumn(column) {
|
|
2739
|
+
if (this._columnsById.get(column.columnId)) {
|
|
2740
|
+
lang.illegalState(`Column with id=${column.columnId} already exists`);
|
|
2741
|
+
}
|
|
2742
|
+
else {
|
|
2743
|
+
this._columns.push(column);
|
|
2744
|
+
}
|
|
2745
|
+
return column;
|
|
2746
|
+
}
|
|
2747
|
+
columnTextProperties(columnTextProperties) {
|
|
2748
|
+
this._columnTextPropertiesLookup = columnTextProperties;
|
|
2749
|
+
}
|
|
2750
|
+
getColumnTextProperties(column) {
|
|
2751
|
+
const factory = this._columnTextPropertiesLookup ? this._columnTextPropertiesLookup[column.columnId] : undefined;
|
|
2752
|
+
return factory ? factory() : undefined;
|
|
2753
|
+
}
|
|
2754
|
+
startEditSession(row) {
|
|
2755
|
+
const rowId = this.identityOf(row);
|
|
2756
|
+
if (this._rowsBeingEdited.query().indexOf(row) > -1) {
|
|
2757
|
+
return lang.illegalState(`Row with id=${rowId} already being edited`);
|
|
2758
|
+
}
|
|
2759
|
+
else {
|
|
2760
|
+
const editSession = new EditSession(rowId, row, this._createForm(row), this.saveCommand);
|
|
2761
|
+
const { when } = Dsl.disposeWith(editSession);
|
|
2762
|
+
when.valueOf(editSession.liveRowValue).changes((editedValue) => {
|
|
2763
|
+
this._rowsBeingEdited.replaceOrPush(editedValue);
|
|
2764
|
+
}, { initialValue: 'triggerChangeUnlessNil' });
|
|
2765
|
+
this._editorSessions.push(editSession);
|
|
2766
|
+
editSession.onDispose(() => {
|
|
2767
|
+
this._rowsBeingEdited.remove(editSession.liveRowValue.value);
|
|
2768
|
+
this._editorSessions.remove(editSession);
|
|
2769
|
+
});
|
|
2770
|
+
return editSession;
|
|
2771
|
+
}
|
|
2772
|
+
}
|
|
2773
|
+
getEditSessionFor(row) {
|
|
2774
|
+
return this._editorSessionByRowId.get(this.identityOf(row));
|
|
2775
|
+
}
|
|
2776
|
+
cancelAllEditorSessions() {
|
|
2777
|
+
this._editorSessions.runInTransaction((draft) => {
|
|
2778
|
+
this._rowsBeingEdited.runInTransaction(() => {
|
|
2779
|
+
draft.value.forEach(session => session.dispose());
|
|
2780
|
+
});
|
|
2781
|
+
});
|
|
2782
|
+
}
|
|
2783
|
+
};
|
|
2784
|
+
TableModel.ctorParameters = () => [
|
|
2785
|
+
{ type: ListModel }
|
|
2786
|
+
];
|
|
2787
|
+
TableModel = TableModel_1 = __decorate([
|
|
2788
|
+
TrackExternal.Strategy(new TrackExternal.OneTimeBinding()),
|
|
2789
|
+
__metadata("design:paramtypes", [ListModel])
|
|
2790
|
+
], TableModel);
|
|
2791
|
+
|
|
2871
2792
|
/**
|
|
2872
2793
|
* Create your model:
|
|
2873
2794
|
* @example
|
|
@@ -2973,6 +2894,99 @@ ColumnTemplateDirective = __decorate([
|
|
|
2973
2894
|
ViewContainerRef])
|
|
2974
2895
|
], ColumnTemplateDirective);
|
|
2975
2896
|
|
|
2897
|
+
let TableCellRendererComponent = class TableCellRendererComponent extends DisposableComponent {
|
|
2898
|
+
constructor() {
|
|
2899
|
+
super();
|
|
2900
|
+
this.defaultClassNames = 'aup-cell-renderer';
|
|
2901
|
+
this.fillCell = false;
|
|
2902
|
+
this.padChild = false;
|
|
2903
|
+
this.editRowCommand = Command.create(() => {
|
|
2904
|
+
this.tableModel.startEditSession(this.row);
|
|
2905
|
+
});
|
|
2906
|
+
}
|
|
2907
|
+
ngOnInit() {
|
|
2908
|
+
const { chain, valueOf, before, when, after, observe, switchOn } = Dsl.disposeWith(this);
|
|
2909
|
+
this.firstEditableColumn = chain(this.tableModel.firstEditableColumn).equals(this.column); // this would break if the column changed.
|
|
2910
|
+
this.column.attachCell(this);
|
|
2911
|
+
}
|
|
2912
|
+
hasActiveEditor() {
|
|
2913
|
+
return !!this.editSession && !!this.column.hasEditorPortal();
|
|
2914
|
+
}
|
|
2915
|
+
initialiseRenderer(instance) {
|
|
2916
|
+
this.column.onRendererAttached(this, instance);
|
|
2917
|
+
}
|
|
2918
|
+
initialiseEditor(instance) {
|
|
2919
|
+
this.column.onEditorAttached(this, instance);
|
|
2920
|
+
if (this.firstEditableColumn.value) {
|
|
2921
|
+
// @see https://github.com/angular/components/issues/12070
|
|
2922
|
+
setTimeout(() => this.tryAndFocusEditor(instance));
|
|
2923
|
+
}
|
|
2924
|
+
}
|
|
2925
|
+
tryAndFocusEditor(editor) {
|
|
2926
|
+
var _a;
|
|
2927
|
+
if (editor.requestFocus) {
|
|
2928
|
+
editor.requestFocus();
|
|
2929
|
+
}
|
|
2930
|
+
else {
|
|
2931
|
+
const model = (editor['valueModel'] || editor['listModel']);
|
|
2932
|
+
(_a = model === null || model === void 0 ? void 0 : model.focusContext) === null || _a === void 0 ? void 0 : _a.requestFocus();
|
|
2933
|
+
}
|
|
2934
|
+
}
|
|
2935
|
+
// @Trace()
|
|
2936
|
+
ngOnChanges(changes) {
|
|
2937
|
+
this.column.updatePortalContent(this);
|
|
2938
|
+
}
|
|
2939
|
+
getRendererPortal() {
|
|
2940
|
+
return this[CELL_RENDERER_PORTAL];
|
|
2941
|
+
}
|
|
2942
|
+
getEditorPortal() {
|
|
2943
|
+
return this[CELL_EDITOR_PORTAL];
|
|
2944
|
+
}
|
|
2945
|
+
getRowData() {
|
|
2946
|
+
return {
|
|
2947
|
+
row: this.row,
|
|
2948
|
+
editSession: this.editSession,
|
|
2949
|
+
editRowCommand: this.editRowCommand
|
|
2950
|
+
};
|
|
2951
|
+
}
|
|
2952
|
+
};
|
|
2953
|
+
__decorate([
|
|
2954
|
+
Input(),
|
|
2955
|
+
__metadata("design:type", Object)
|
|
2956
|
+
], TableCellRendererComponent.prototype, "row", void 0);
|
|
2957
|
+
__decorate([
|
|
2958
|
+
Input(),
|
|
2959
|
+
__metadata("design:type", ColumnModel)
|
|
2960
|
+
], TableCellRendererComponent.prototype, "column", void 0);
|
|
2961
|
+
__decorate([
|
|
2962
|
+
Input(),
|
|
2963
|
+
__metadata("design:type", EditSession)
|
|
2964
|
+
], TableCellRendererComponent.prototype, "editSession", void 0);
|
|
2965
|
+
__decorate([
|
|
2966
|
+
Input(),
|
|
2967
|
+
__metadata("design:type", TableModel)
|
|
2968
|
+
], TableCellRendererComponent.prototype, "tableModel", void 0);
|
|
2969
|
+
__decorate([
|
|
2970
|
+
HostBinding('class'),
|
|
2971
|
+
__metadata("design:type", Object)
|
|
2972
|
+
], TableCellRendererComponent.prototype, "defaultClassNames", void 0);
|
|
2973
|
+
__decorate([
|
|
2974
|
+
HostBinding('class.fillCell'),
|
|
2975
|
+
__metadata("design:type", Object)
|
|
2976
|
+
], TableCellRendererComponent.prototype, "fillCell", void 0);
|
|
2977
|
+
__decorate([
|
|
2978
|
+
HostBinding('class.padChild'),
|
|
2979
|
+
__metadata("design:type", Object)
|
|
2980
|
+
], TableCellRendererComponent.prototype, "padChild", void 0);
|
|
2981
|
+
TableCellRendererComponent = __decorate([
|
|
2982
|
+
Component({
|
|
2983
|
+
selector: 'aup-table-cell-renderer',
|
|
2984
|
+
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",
|
|
2985
|
+
styles: [""]
|
|
2986
|
+
}),
|
|
2987
|
+
__metadata("design:paramtypes", [])
|
|
2988
|
+
], TableCellRendererComponent);
|
|
2989
|
+
|
|
2976
2990
|
let TableHeaderCellRendererComponent = class TableHeaderCellRendererComponent {
|
|
2977
2991
|
constructor() {
|
|
2978
2992
|
this.defaultClassNames = 'aup-header-cell-renderer';
|
|
@@ -3186,7 +3200,8 @@ ComponentsModule = __decorate([
|
|
|
3186
3200
|
MatCheckboxModule,
|
|
3187
3201
|
InteractionModule,
|
|
3188
3202
|
MatTableModule,
|
|
3189
|
-
PortalModule
|
|
3203
|
+
PortalModule,
|
|
3204
|
+
CdkScrollableModule
|
|
3190
3205
|
],
|
|
3191
3206
|
exports: [
|
|
3192
3207
|
NumberInputComponent,
|
|
@@ -5041,9 +5056,9 @@ __decorate([
|
|
|
5041
5056
|
PlaceOutletComponent = __decorate([
|
|
5042
5057
|
Component({
|
|
5043
5058
|
selector: 'aup-place-outlet',
|
|
5044
|
-
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",
|
|
5059
|
+
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",
|
|
5045
5060
|
animations: [LEFT_RIGHT_PLACE_ANIMATION],
|
|
5046
|
-
styles: [":host{display:flex;flex-direction:column;min-height:0
|
|
5061
|
+
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}"]
|
|
5047
5062
|
}),
|
|
5048
5063
|
__param(2, Optional()), __param(2, Inject(AUP_PLACE_CONFIG)),
|
|
5049
5064
|
__param(3, SkipSelf()), __param(3, Optional()),
|