@coolon/angular-ui-powerups 1.13.0 → 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 +15 -0
- package/bundles/coolon-angular-ui-powerups.umd.js +415 -406
- 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/forms/abstract-input.component.js +0 -4
- package/esm2015/lib/components/forms/abstract-input.component.js.map +1 -1
- package/esm2015/lib/components/forms/abstract-input.component.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/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/forms/abstract-input.component.js +0 -8
- package/esm5/lib/components/forms/abstract-input.component.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 +384 -372
- package/fesm2015/coolon-angular-ui-powerups.js.map +1 -1
- package/fesm5/coolon-angular-ui-powerups.js +414 -404
- package/fesm5/coolon-angular-ui-powerups.js.map +1 -1
- package/lib/components/forms/abstract-input.component.d.ts +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 {
|
|
@@ -1625,9 +1642,6 @@ let AbstractInputComponent = class AbstractInputComponent extends DisposableComp
|
|
|
1625
1642
|
}
|
|
1626
1643
|
};
|
|
1627
1644
|
}
|
|
1628
|
-
get inputModel() {
|
|
1629
|
-
return lang$1.abstractMethod(this.constructor, "inputModel");
|
|
1630
|
-
}
|
|
1631
1645
|
notifyClick() {
|
|
1632
1646
|
this.safelyInvoke(this.clickCommand);
|
|
1633
1647
|
}
|
|
@@ -2025,7 +2039,7 @@ let ScrollContainerComponent = class ScrollContainerComponent {
|
|
|
2025
2039
|
ScrollContainerComponent = __decorate([
|
|
2026
2040
|
Component({
|
|
2027
2041
|
selector: 'aup-scroll-container',
|
|
2028
|
-
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",
|
|
2029
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}"]
|
|
2030
2044
|
}),
|
|
2031
2045
|
__metadata("design:paramtypes", [])
|
|
@@ -2303,376 +2317,101 @@ SelectHeaderCellRendererComponent = __decorate([
|
|
|
2303
2317
|
__metadata("design:paramtypes", [])
|
|
2304
2318
|
], SelectHeaderCellRendererComponent);
|
|
2305
2319
|
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
* });
|
|
2317
|
-
*
|
|
2318
|
-
* Editable tables
|
|
2319
|
-
* @example
|
|
2320
|
-
* const saveCommand = UnaryCommand.create((form: Form<Hero>) => {
|
|
2321
|
-
* if (form.validate()) {
|
|
2322
|
-
* // normal form save stuff
|
|
2323
|
-
* return true; // finish editing
|
|
2324
|
-
* }
|
|
2325
|
-
* return false; // continue editiing
|
|
2326
|
-
* }
|
|
2327
|
-
* const colorsNames: ListModel<string> = ...;
|
|
2328
|
-
* const model = TableModel.fromList(heroList, table => {
|
|
2329
|
-
* table.pluck("firstName").cellEditor(StringInputComponent); <-- interface CellEditor { valueModel: FormValueModel<string> | ValueModel<string>; }
|
|
2330
|
-
* table.pluck("lastName").cellEditor(StringInputComponent, {
|
|
2331
|
-
* validators: [Validator.present("We need a last name")]
|
|
2332
|
-
* });
|
|
2333
|
-
* table.pluck("age").cellEditor(NumberInputComponent);
|
|
2334
|
-
* table.pluck("favoriteColor").cellEditor(SelectInputComponent, {
|
|
2335
|
-
* initialiseComponent(component: SelectInputComponent) {
|
|
2336
|
-
* selectInput.optionsModel = colorsNames; // <- initialise our component
|
|
2337
|
-
* }
|
|
2338
|
-
* });
|
|
2339
|
-
* table.addEditControls(saveCommand); // <- required to enable editing
|
|
2340
|
-
* });
|
|
2341
|
-
*
|
|
2342
|
-
* Selection models
|
|
2343
|
-
* @example
|
|
2344
|
-
* const model = TableModel.fromList(heroList, table => {
|
|
2345
|
-
* table.addSelectionColumn(selectionModel); // <- can be single or multiple selection model
|
|
2346
|
-
* table.pluck("firstName");
|
|
2347
|
-
* table.pluck("lastName");
|
|
2348
|
-
* });
|
|
2349
|
-
*
|
|
2350
|
-
* Custom cell renderers and editors
|
|
2351
|
-
* @example
|
|
2352
|
-
* const model = TableModel.fromList(heroList, table => {
|
|
2353
|
-
* table.pluck("favoriteColor")
|
|
2354
|
-
* .cellHeaderRenderer(CellHeaderRendererComponent, (component, column) => {
|
|
2355
|
-
* // configure your component with what ever you need.
|
|
2356
|
-
* });
|
|
2357
|
-
* .cellRenderer(CellRendererComponent) // <-- interface CellEditor { value: string; }
|
|
2358
|
-
* .cellEditor(CellEditorComponent.); // <-- interface CellEditor { valueModel: FormValueModel<string> | ValueModel<string>; }
|
|
2359
|
-
* table.addCustomColumn("fullName", hero => `${hero.firstName} ${hero.lastName}`);
|
|
2360
|
-
* });
|
|
2361
|
-
*
|
|
2362
|
-
* I18n
|
|
2363
|
-
* @example
|
|
2364
|
-
* [table.yml]
|
|
2365
|
-
* table:
|
|
2366
|
-
* columns(ColumnTextProperties[]):
|
|
2367
|
-
* firstName:
|
|
2368
|
-
* headerText: "First Name"
|
|
2369
|
-
* fullName:
|
|
2370
|
-
* headerText: "Full Name"
|
|
2371
|
-
*
|
|
2372
|
-
* const model = TableModel.fromList(heroList, table => {
|
|
2373
|
-
* table.pluck("favoriteColor").cellRenderer(...).cellEditor(...);
|
|
2374
|
-
* table.addCustomColumn("fullName", hero => `${hero.firstName} ${hero.lastName}`);
|
|
2375
|
-
*
|
|
2376
|
-
* table.columnTextProperties(I18n.table.columns); // <- configures all columns
|
|
2377
|
-
* });
|
|
2378
|
-
*/
|
|
2379
|
-
let TableModel = TableModel_1 = class TableModel {
|
|
2380
|
-
constructor(sourceOfTruth) {
|
|
2381
|
-
this.sourceOfTruth = sourceOfTruth;
|
|
2382
|
-
this._garbage = new GarbageCollector();
|
|
2383
|
-
this._columns = new MutableListModel();
|
|
2384
|
-
this._editorSessions = new MutableListModel();
|
|
2385
|
-
this._createForm = (row) => new Form();
|
|
2386
|
-
this.identityOf = sourceOfTruth.identityOf;
|
|
2387
|
-
const { chain, valueOf, before, when, after, observe, switchOn } = Dsl.disposeWith(this._garbage);
|
|
2388
|
-
this._columnsById = chain(this._columns).indexBy('columnId');
|
|
2389
|
-
this._rowsBeingEdited = new MutableListModel([], {
|
|
2390
|
-
identifiedWith: this.identityOf
|
|
2391
|
-
});
|
|
2392
|
-
this._editorSessionByRowId = chain(this._editorSessions).indexBy('rowId');
|
|
2393
|
-
this.editing = chain(this._editorSessions).count().isGreaterThan(0);
|
|
2394
|
-
this.dataSource = chain(this.sourceOfTruth).replaceAll(this.rowsBeingEdited);
|
|
2395
|
-
}
|
|
2396
|
-
static fromList(sourceOfTruth, builder) {
|
|
2397
|
-
const model = new TableModel_1(sourceOfTruth);
|
|
2398
|
-
builder(model);
|
|
2399
|
-
return model;
|
|
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() {
|
|
2400
2330
|
}
|
|
2401
|
-
|
|
2402
|
-
|
|
2331
|
+
}
|
|
2332
|
+
class CellHeaderPortalRef extends CellPortalRef {
|
|
2333
|
+
constructor(componentType, initialiseHeader) {
|
|
2334
|
+
super();
|
|
2335
|
+
this.componentType = componentType;
|
|
2336
|
+
this.initialiseHeader = initialiseHeader;
|
|
2403
2337
|
}
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
};
|
|
2338
|
+
initialiseHost(host, columnModel) {
|
|
2339
|
+
assert$1.isTruthy(host);
|
|
2340
|
+
host[HEADER_CELL_RENDERER_PORTAL] = new ComponentPortal(this.componentType);
|
|
2408
2341
|
}
|
|
2409
|
-
|
|
2410
|
-
|
|
2342
|
+
onPortalAttached(host, portalComponent) {
|
|
2343
|
+
this.initialiseHeader(portalComponent, host.column);
|
|
2411
2344
|
}
|
|
2412
|
-
|
|
2413
|
-
|
|
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;
|
|
2414
2353
|
}
|
|
2415
|
-
|
|
2416
|
-
|
|
2354
|
+
initialiseHost(host, columnModel) {
|
|
2355
|
+
host[CELL_RENDERER_PORTAL] = new ComponentPortal(this.componentType);
|
|
2417
2356
|
}
|
|
2418
|
-
|
|
2419
|
-
|
|
2357
|
+
onPortalAttached(host, portalComponent) {
|
|
2358
|
+
host[PORTAL_RENDERER_COMPONENT] = portalComponent;
|
|
2359
|
+
this.updateComponent(portalComponent, host.getRowData());
|
|
2420
2360
|
}
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2361
|
+
pushState(host) {
|
|
2362
|
+
if (host[PORTAL_RENDERER_COMPONENT]) {
|
|
2363
|
+
this.updateComponent(host[PORTAL_RENDERER_COMPONENT], host.getRowData());
|
|
2364
|
+
}
|
|
2424
2365
|
}
|
|
2425
|
-
|
|
2426
|
-
|
|
2366
|
+
}
|
|
2367
|
+
class CellEditorPortalRef extends CellPortalRef {
|
|
2368
|
+
constructor(componentType, initialiseEditorSession) {
|
|
2369
|
+
super();
|
|
2370
|
+
this.componentType = componentType;
|
|
2371
|
+
this.initialiseEditorSession = initialiseEditorSession;
|
|
2427
2372
|
}
|
|
2428
|
-
|
|
2429
|
-
|
|
2373
|
+
initialiseHost(host, columnModel) {
|
|
2374
|
+
assert$1.isTruthy(host);
|
|
2375
|
+
host[CELL_EDITOR_PORTAL] = new ComponentPortal(this.componentType);
|
|
2430
2376
|
}
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2377
|
+
// @Trace()
|
|
2378
|
+
onPortalAttached(host, portalComponent) {
|
|
2379
|
+
host[PORTAL_EDITOR_COMPONENT] = portalComponent;
|
|
2380
|
+
this.initialiseEditorSession(portalComponent, host.editSession);
|
|
2434
2381
|
}
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
else {
|
|
2440
|
-
this._columns.push(column);
|
|
2441
|
-
}
|
|
2442
|
-
return column;
|
|
2382
|
+
}
|
|
2383
|
+
class TemplateCellRendererPortalRef extends CellRendererPortalRef {
|
|
2384
|
+
constructor() {
|
|
2385
|
+
super();
|
|
2443
2386
|
}
|
|
2444
|
-
|
|
2445
|
-
this.
|
|
2387
|
+
registerPortal(templateRef, viewContainer, fillCell, padChild) {
|
|
2388
|
+
this.templateRef = templateRef;
|
|
2389
|
+
this.viewContainer = viewContainer;
|
|
2390
|
+
this.fillCell = fillCell;
|
|
2391
|
+
this.padChild = padChild;
|
|
2446
2392
|
}
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
return factory ? factory() : undefined;
|
|
2393
|
+
initialiseHost(host, columnModel) {
|
|
2394
|
+
assert$1.isTruthy(host);
|
|
2450
2395
|
}
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
return lang.illegalState(`Row with id=${rowId} already being edited`);
|
|
2455
|
-
}
|
|
2456
|
-
else {
|
|
2457
|
-
const editSession = new EditSession(rowId, row, this._createForm(row), this.saveCommand);
|
|
2458
|
-
const { when } = Dsl.disposeWith(editSession);
|
|
2459
|
-
when.valueOf(editSession.liveRowValue).changes((editedValue) => {
|
|
2460
|
-
this._rowsBeingEdited.replaceOrPush(editedValue);
|
|
2461
|
-
}, { initialValue: 'triggerChangeUnlessNil' });
|
|
2462
|
-
this._editorSessions.push(editSession);
|
|
2463
|
-
editSession.onDispose(() => {
|
|
2464
|
-
this._rowsBeingEdited.remove(editSession.liveRowValue.value);
|
|
2465
|
-
this._editorSessions.remove(editSession);
|
|
2466
|
-
});
|
|
2467
|
-
return editSession;
|
|
2468
|
-
}
|
|
2396
|
+
// @Trace()
|
|
2397
|
+
onPortalAttached(host, portalComponent) {
|
|
2398
|
+
// don't care
|
|
2469
2399
|
}
|
|
2470
|
-
|
|
2471
|
-
|
|
2400
|
+
pushState(host) {
|
|
2401
|
+
host[CELL_RENDERER_PORTAL] = this.createPortal(host.getRowData());
|
|
2402
|
+
host.fillCell = this.fillCell;
|
|
2403
|
+
host.padChild = this.padChild;
|
|
2472
2404
|
}
|
|
2473
|
-
|
|
2474
|
-
this.
|
|
2475
|
-
this._rowsBeingEdited.runInTransaction(() => {
|
|
2476
|
-
draft.value.forEach(session => session.dispose());
|
|
2477
|
-
});
|
|
2478
|
-
});
|
|
2405
|
+
createPortal(data) {
|
|
2406
|
+
return new TemplatePortal(this.templateRef, this.viewContainer, Object.assign(Object.assign({}, (data)), { $implicit: data.row }));
|
|
2479
2407
|
}
|
|
2480
|
-
}
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
], TableModel);
|
|
2488
|
-
|
|
2489
|
-
let TableCellRendererComponent = class TableCellRendererComponent {
|
|
2490
|
-
constructor() {
|
|
2491
|
-
this.defaultClassNames = 'aup-cell-renderer';
|
|
2492
|
-
this.fillCell = false;
|
|
2493
|
-
this.padChild = false;
|
|
2494
|
-
this.editRowCommand = Command.create(() => {
|
|
2495
|
-
this.tableModel.startEditSession(this.row);
|
|
2496
|
-
});
|
|
2497
|
-
}
|
|
2498
|
-
ngOnInit() {
|
|
2499
|
-
this.column.attachCell(this);
|
|
2500
|
-
}
|
|
2501
|
-
hasActiveEditor() {
|
|
2502
|
-
return !!this.editSession && !!this.column.hasEditorPortal();
|
|
2503
|
-
}
|
|
2504
|
-
initialiseRenderer(instance) {
|
|
2505
|
-
this.column.onRendererAttached(this, instance);
|
|
2506
|
-
}
|
|
2507
|
-
initialiseEditor(instance) {
|
|
2508
|
-
this.column.onEditorAttached(this, instance);
|
|
2509
|
-
}
|
|
2510
|
-
// @Trace()
|
|
2511
|
-
ngOnChanges(changes) {
|
|
2512
|
-
this.column.updatePortalContent(this);
|
|
2513
|
-
}
|
|
2514
|
-
getRendererPortal() {
|
|
2515
|
-
return this[CELL_RENDERER_PORTAL];
|
|
2516
|
-
}
|
|
2517
|
-
getEditorPortal() {
|
|
2518
|
-
return this[CELL_EDITOR_PORTAL];
|
|
2519
|
-
}
|
|
2520
|
-
getRowData() {
|
|
2521
|
-
return {
|
|
2522
|
-
row: this.row,
|
|
2523
|
-
editSession: this.editSession,
|
|
2524
|
-
editRowCommand: this.editRowCommand
|
|
2525
|
-
};
|
|
2526
|
-
}
|
|
2527
|
-
};
|
|
2528
|
-
__decorate([
|
|
2529
|
-
Input(),
|
|
2530
|
-
__metadata("design:type", Object)
|
|
2531
|
-
], TableCellRendererComponent.prototype, "row", void 0);
|
|
2532
|
-
__decorate([
|
|
2533
|
-
Input(),
|
|
2534
|
-
__metadata("design:type", ColumnModel)
|
|
2535
|
-
], TableCellRendererComponent.prototype, "column", void 0);
|
|
2536
|
-
__decorate([
|
|
2537
|
-
Input(),
|
|
2538
|
-
__metadata("design:type", EditSession)
|
|
2539
|
-
], TableCellRendererComponent.prototype, "editSession", void 0);
|
|
2540
|
-
__decorate([
|
|
2541
|
-
Input(),
|
|
2542
|
-
__metadata("design:type", TableModel)
|
|
2543
|
-
], TableCellRendererComponent.prototype, "tableModel", void 0);
|
|
2544
|
-
__decorate([
|
|
2545
|
-
HostBinding('class'),
|
|
2546
|
-
__metadata("design:type", Object)
|
|
2547
|
-
], TableCellRendererComponent.prototype, "defaultClassNames", void 0);
|
|
2548
|
-
__decorate([
|
|
2549
|
-
HostBinding('class.fillCell'),
|
|
2550
|
-
__metadata("design:type", Object)
|
|
2551
|
-
], TableCellRendererComponent.prototype, "fillCell", void 0);
|
|
2552
|
-
__decorate([
|
|
2553
|
-
HostBinding('class.padChild'),
|
|
2554
|
-
__metadata("design:type", Object)
|
|
2555
|
-
], TableCellRendererComponent.prototype, "padChild", void 0);
|
|
2556
|
-
__decorate([
|
|
2557
|
-
Trace(),
|
|
2558
|
-
__metadata("design:type", Function),
|
|
2559
|
-
__metadata("design:paramtypes", [Object]),
|
|
2560
|
-
__metadata("design:returntype", void 0)
|
|
2561
|
-
], TableCellRendererComponent.prototype, "initialiseEditor", null);
|
|
2562
|
-
TableCellRendererComponent = __decorate([
|
|
2563
|
-
Component({
|
|
2564
|
-
selector: 'aup-table-cell-renderer',
|
|
2565
|
-
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",
|
|
2566
|
-
styles: [""]
|
|
2567
|
-
}),
|
|
2568
|
-
__metadata("design:paramtypes", [])
|
|
2569
|
-
], TableCellRendererComponent);
|
|
2570
|
-
|
|
2571
|
-
const HEADER_CELL_RENDERER_PORTAL = Symbol('aup-cell-header-renderer-component-ref');
|
|
2572
|
-
const CELL_RENDERER_PORTAL = Symbol('aup-cell-renderer-component-ref');
|
|
2573
|
-
const CELL_EDITOR_PORTAL = Symbol('aup-cell-editor-component-ref');
|
|
2574
|
-
const PORTAL_RENDERER_COMPONENT = Symbol('aup-cell-renderer-portal-component');
|
|
2575
|
-
const PORTAL_EDITOR_COMPONENT = Symbol('aup-cell-editor-portal-component');
|
|
2576
|
-
const noop = () => {
|
|
2577
|
-
};
|
|
2578
|
-
const ɵ0 = noop;
|
|
2579
|
-
class CellPortalRef {
|
|
2580
|
-
constructor() {
|
|
2581
|
-
}
|
|
2582
|
-
}
|
|
2583
|
-
class CellHeaderPortalRef extends CellPortalRef {
|
|
2584
|
-
constructor(componentType, initialiseHeader) {
|
|
2585
|
-
super();
|
|
2586
|
-
this.componentType = componentType;
|
|
2587
|
-
this.initialiseHeader = initialiseHeader;
|
|
2588
|
-
}
|
|
2589
|
-
initialiseHost(host, columnModel) {
|
|
2590
|
-
assert$1.isTruthy(host);
|
|
2591
|
-
host[HEADER_CELL_RENDERER_PORTAL] = new ComponentPortal(this.componentType);
|
|
2592
|
-
}
|
|
2593
|
-
onPortalAttached(host, portalComponent) {
|
|
2594
|
-
this.initialiseHeader(portalComponent, host.column);
|
|
2595
|
-
}
|
|
2596
|
-
}
|
|
2597
|
-
class CellRendererPortalRef extends CellPortalRef {
|
|
2598
|
-
}
|
|
2599
|
-
class ComponentCellRendererPortalRef extends CellRendererPortalRef {
|
|
2600
|
-
constructor(componentType, updateComponent) {
|
|
2601
|
-
super();
|
|
2602
|
-
this.componentType = componentType;
|
|
2603
|
-
this.updateComponent = updateComponent;
|
|
2604
|
-
}
|
|
2605
|
-
initialiseHost(host, columnModel) {
|
|
2606
|
-
host[CELL_RENDERER_PORTAL] = new ComponentPortal(this.componentType);
|
|
2607
|
-
}
|
|
2608
|
-
onPortalAttached(host, portalComponent) {
|
|
2609
|
-
host[PORTAL_RENDERER_COMPONENT] = portalComponent;
|
|
2610
|
-
this.updateComponent(portalComponent, host.getRowData());
|
|
2611
|
-
}
|
|
2612
|
-
pushState(host) {
|
|
2613
|
-
if (host[PORTAL_RENDERER_COMPONENT]) {
|
|
2614
|
-
this.updateComponent(host[PORTAL_RENDERER_COMPONENT], host.getRowData());
|
|
2615
|
-
}
|
|
2616
|
-
}
|
|
2617
|
-
}
|
|
2618
|
-
class CellEditorPortalRef extends CellPortalRef {
|
|
2619
|
-
constructor(componentType, initialiseEditorSession) {
|
|
2620
|
-
super();
|
|
2621
|
-
this.componentType = componentType;
|
|
2622
|
-
this.initialiseEditorSession = initialiseEditorSession;
|
|
2623
|
-
}
|
|
2624
|
-
initialiseHost(host, columnModel) {
|
|
2625
|
-
assert$1.isTruthy(host);
|
|
2626
|
-
host[CELL_EDITOR_PORTAL] = new ComponentPortal(this.componentType);
|
|
2627
|
-
}
|
|
2628
|
-
onPortalAttached(host, portalComponent) {
|
|
2629
|
-
host[PORTAL_EDITOR_COMPONENT] = portalComponent;
|
|
2630
|
-
this.initialiseEditorSession(portalComponent, host.editSession);
|
|
2631
|
-
}
|
|
2632
|
-
}
|
|
2633
|
-
__decorate([
|
|
2634
|
-
Trace(),
|
|
2635
|
-
__metadata("design:type", Function),
|
|
2636
|
-
__metadata("design:paramtypes", [TableCellRendererComponent, Object]),
|
|
2637
|
-
__metadata("design:returntype", void 0)
|
|
2638
|
-
], CellEditorPortalRef.prototype, "onPortalAttached", null);
|
|
2639
|
-
class TemplateCellRendererPortalRef extends CellRendererPortalRef {
|
|
2640
|
-
constructor() {
|
|
2641
|
-
super();
|
|
2642
|
-
}
|
|
2643
|
-
registerPortal(templateRef, viewContainer, fillCell, padChild) {
|
|
2644
|
-
this.templateRef = templateRef;
|
|
2645
|
-
this.viewContainer = viewContainer;
|
|
2646
|
-
this.fillCell = fillCell;
|
|
2647
|
-
this.padChild = padChild;
|
|
2648
|
-
}
|
|
2649
|
-
initialiseHost(host, columnModel) {
|
|
2650
|
-
assert$1.isTruthy(host);
|
|
2651
|
-
}
|
|
2652
|
-
onPortalAttached(host, portalComponent) {
|
|
2653
|
-
// don't care
|
|
2654
|
-
}
|
|
2655
|
-
pushState(host) {
|
|
2656
|
-
host[CELL_RENDERER_PORTAL] = this.createPortal(host.getRowData());
|
|
2657
|
-
host.fillCell = this.fillCell;
|
|
2658
|
-
host.padChild = this.padChild;
|
|
2659
|
-
}
|
|
2660
|
-
createPortal(data) {
|
|
2661
|
-
return new TemplatePortal(this.templateRef, this.viewContainer, Object.assign(Object.assign({}, (data)), { $implicit: data.row }));
|
|
2662
|
-
}
|
|
2663
|
-
}
|
|
2664
|
-
__decorate([
|
|
2665
|
-
Trace(),
|
|
2666
|
-
__metadata("design:type", Function),
|
|
2667
|
-
__metadata("design:paramtypes", [TableCellRendererComponent, void 0]),
|
|
2668
|
-
__metadata("design:returntype", void 0)
|
|
2669
|
-
], TemplateCellRendererPortalRef.prototype, "onPortalAttached", null);
|
|
2670
|
-
class ColumnModel {
|
|
2671
|
-
constructor(columnId, defaults) {
|
|
2672
|
-
this.columnId = columnId;
|
|
2673
|
-
this.defaults = defaults;
|
|
2674
|
-
this.cellHeaderRenderer(DefaultHeaderCellRendererComponent, (component, column) => {
|
|
2675
|
-
component.headerText = column.getHeaderText();
|
|
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();
|
|
2676
2415
|
});
|
|
2677
2416
|
}
|
|
2678
2417
|
getHeaderText() {
|
|
@@ -2720,6 +2459,7 @@ class ColumnModel {
|
|
|
2720
2459
|
onRendererAttached(host, component) {
|
|
2721
2460
|
this._cellRendererPortalRef.onPortalAttached(host, component);
|
|
2722
2461
|
}
|
|
2462
|
+
// @Trace()
|
|
2723
2463
|
onEditorAttached(host, component) {
|
|
2724
2464
|
this._cellEditorPortalRef.onPortalAttached(host, component);
|
|
2725
2465
|
}
|
|
@@ -2739,12 +2479,6 @@ __decorate([
|
|
|
2739
2479
|
__metadata("design:paramtypes", []),
|
|
2740
2480
|
__metadata("design:returntype", Object)
|
|
2741
2481
|
], ColumnModel.prototype, "getColumnTextProperties", null);
|
|
2742
|
-
__decorate([
|
|
2743
|
-
Trace(),
|
|
2744
|
-
__metadata("design:type", Function),
|
|
2745
|
-
__metadata("design:paramtypes", [TableCellRendererComponent, Object]),
|
|
2746
|
-
__metadata("design:returntype", void 0)
|
|
2747
|
-
], ColumnModel.prototype, "onEditorAttached", null);
|
|
2748
2482
|
class PropertyColumnModel extends ColumnModel {
|
|
2749
2483
|
constructor(property, defaults) {
|
|
2750
2484
|
super(property.toString(), defaults);
|
|
@@ -2871,6 +2605,190 @@ class SelectionColumnModel extends ColumnModel {
|
|
|
2871
2605
|
}
|
|
2872
2606
|
}
|
|
2873
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
|
+
|
|
2874
2792
|
/**
|
|
2875
2793
|
* Create your model:
|
|
2876
2794
|
* @example
|
|
@@ -2976,6 +2894,99 @@ ColumnTemplateDirective = __decorate([
|
|
|
2976
2894
|
ViewContainerRef])
|
|
2977
2895
|
], ColumnTemplateDirective);
|
|
2978
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
|
+
|
|
2979
2990
|
let TableHeaderCellRendererComponent = class TableHeaderCellRendererComponent {
|
|
2980
2991
|
constructor() {
|
|
2981
2992
|
this.defaultClassNames = 'aup-header-cell-renderer';
|
|
@@ -3189,7 +3200,8 @@ ComponentsModule = __decorate([
|
|
|
3189
3200
|
MatCheckboxModule,
|
|
3190
3201
|
InteractionModule,
|
|
3191
3202
|
MatTableModule,
|
|
3192
|
-
PortalModule
|
|
3203
|
+
PortalModule,
|
|
3204
|
+
CdkScrollableModule
|
|
3193
3205
|
],
|
|
3194
3206
|
exports: [
|
|
3195
3207
|
NumberInputComponent,
|
|
@@ -5044,9 +5056,9 @@ __decorate([
|
|
|
5044
5056
|
PlaceOutletComponent = __decorate([
|
|
5045
5057
|
Component({
|
|
5046
5058
|
selector: 'aup-place-outlet',
|
|
5047
|
-
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",
|
|
5048
5060
|
animations: [LEFT_RIGHT_PLACE_ANIMATION],
|
|
5049
|
-
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}"]
|
|
5050
5062
|
}),
|
|
5051
5063
|
__param(2, Optional()), __param(2, Inject(AUP_PLACE_CONFIG)),
|
|
5052
5064
|
__param(3, SkipSelf()), __param(3, Optional()),
|