@slickgrid-universal/aurelia-row-detail-plugin 0.0.1 → 10.0.0
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/LICENSE +25 -0
- package/README.md +9 -42
- package/dist/aureliaRowDetailView.d.ts +79 -0
- package/dist/aureliaRowDetailView.js +325 -0
- package/dist/aureliaRowDetailView.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/interfaces.d.ts +13 -0
- package/dist/interfaces.js +2 -0
- package/dist/interfaces.js.map +1 -0
- package/package.json +41 -7
- package/src/aureliaRowDetailView.ts +389 -0
- package/src/index.ts +1 -0
- package/src/interfaces.ts +16 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
Copyright (c) 2020-present, Ghislain B.
|
|
2
|
+
https://github.com/ghiscoding/slickgrid-universal
|
|
3
|
+
|
|
4
|
+
and the original author of SlickGrid
|
|
5
|
+
Michael Leibman, michael{dot}leibman{at}gmail{dot}com
|
|
6
|
+
http://github.com/mleibman/slickgrid
|
|
7
|
+
|
|
8
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
9
|
+
a copy of this software and associated documentation files (the
|
|
10
|
+
"Software"), to deal in the Software without restriction, including
|
|
11
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
12
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
13
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
14
|
+
the following conditions:
|
|
15
|
+
|
|
16
|
+
The above copyright notice and this permission notice shall be
|
|
17
|
+
included in all copies or substantial portions of the Software.
|
|
18
|
+
|
|
19
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
20
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
21
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
22
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
23
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
24
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
25
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,45 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
[](https://opensource.org/licenses/MIT)
|
|
2
|
+
[](http://www.typescriptlang.org/)
|
|
3
|
+
[](https://npmjs.org/package/@slickgrid-universal/aurelia-row-detail-plugin)
|
|
4
|
+
[](https://www.npmjs.com/package/@slickgrid-universal/aurelia-row-detail-plugin)
|
|
2
5
|
|
|
3
|
-
##
|
|
6
|
+
## Aurelia-Slickgrid Row Detail plugin
|
|
7
|
+
#### @slickgrid-universal/aurelia-row-detail-plugin
|
|
4
8
|
|
|
5
|
-
|
|
9
|
+
Aurelia-Slickgrid Row Detail plugin
|
|
6
10
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
## Purpose
|
|
10
|
-
|
|
11
|
-
This package exists to:
|
|
12
|
-
1. Configure OIDC trusted publishing for the package name `@slickgrid-universal/aurelia-row-detail-plugin`
|
|
13
|
-
2. Enable secure, token-less publishing from CI/CD workflows
|
|
14
|
-
3. Establish provenance for packages published under this name
|
|
15
|
-
|
|
16
|
-
## What is OIDC Trusted Publishing?
|
|
17
|
-
|
|
18
|
-
OIDC trusted publishing allows package maintainers to publish packages directly from their CI/CD workflows without needing to manage npm access tokens. Instead, it uses OpenID Connect to establish trust between the CI/CD provider (like GitHub Actions) and npm.
|
|
19
|
-
|
|
20
|
-
## Setup Instructions
|
|
21
|
-
|
|
22
|
-
To properly configure OIDC trusted publishing for this package:
|
|
23
|
-
|
|
24
|
-
1. Go to [npmjs.com](https://www.npmjs.com/) and navigate to your package settings
|
|
25
|
-
2. Configure the trusted publisher (e.g., GitHub Actions)
|
|
26
|
-
3. Specify the repository and workflow that should be allowed to publish
|
|
27
|
-
4. Use the configured workflow to publish your actual package
|
|
28
|
-
|
|
29
|
-
## DO NOT USE THIS PACKAGE
|
|
30
|
-
|
|
31
|
-
This package is a placeholder for OIDC configuration only. It:
|
|
32
|
-
- Contains no executable code
|
|
33
|
-
- Provides no functionality
|
|
34
|
-
- Should not be installed as a dependency
|
|
35
|
-
- Exists only for administrative purposes
|
|
36
|
-
|
|
37
|
-
## More Information
|
|
38
|
-
|
|
39
|
-
For more details about npm's trusted publishing feature, see:
|
|
40
|
-
- [npm Trusted Publishing Documentation](https://docs.npmjs.com/generating-provenance-statements)
|
|
41
|
-
- [GitHub Actions OIDC Documentation](https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect)
|
|
42
|
-
|
|
43
|
-
---
|
|
44
|
-
|
|
45
|
-
**Maintained for OIDC setup purposes only**
|
|
11
|
+
### Installation
|
|
12
|
+
Follow the instruction provided in the main [README](https://github.com/ghiscoding/slickgrid-universal#installation)
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { type Constructable } from '@aurelia/kernel';
|
|
2
|
+
import type { ICustomElementController } from '@aurelia/runtime-html';
|
|
3
|
+
import { SlickEventData, type EventSubscription, type OnBeforeRowDetailToggleArgs, type OnRowBackOrOutOfViewportRangeArgs, type SelectionModel, type SlickGrid } from '@slickgrid-universal/common';
|
|
4
|
+
import { EventPubSubService } from '@slickgrid-universal/event-pub-sub';
|
|
5
|
+
import { SlickRowDetailView as UniversalSlickRowDetailView } from '@slickgrid-universal/row-detail-view-plugin';
|
|
6
|
+
import type { AureliaUtilService, CreatedView, GridOption } from 'aurelia-slickgrid';
|
|
7
|
+
import type { RowDetailView } from './interfaces';
|
|
8
|
+
export declare class AureliaRowDetailView extends UniversalSlickRowDetailView {
|
|
9
|
+
protected readonly aureliaUtilService: AureliaUtilService;
|
|
10
|
+
protected readonly eventPubSubService: EventPubSubService;
|
|
11
|
+
protected readonly gridContainerElement: HTMLElement;
|
|
12
|
+
static readonly pluginName = "AureliaRowDetailView";
|
|
13
|
+
protected _preloadViewModel?: Constructable;
|
|
14
|
+
protected _preloadController?: ICustomElementController;
|
|
15
|
+
protected _slots: CreatedView[];
|
|
16
|
+
protected _subscriptions: EventSubscription[];
|
|
17
|
+
protected _userProcessFn?: (item: any) => Promise<any>;
|
|
18
|
+
protected _viewModel?: Constructable;
|
|
19
|
+
protected _timer?: any;
|
|
20
|
+
constructor(aureliaUtilService: AureliaUtilService, eventPubSubService: EventPubSubService, gridContainerElement: HTMLElement);
|
|
21
|
+
get addonOptions(): import("aurelia-slickgrid").RowDetailViewOption;
|
|
22
|
+
protected get datasetIdPropName(): string;
|
|
23
|
+
get gridOptions(): GridOption;
|
|
24
|
+
get rowDetailViewOptions(): RowDetailView | undefined;
|
|
25
|
+
/** Dispose of the RowDetailView Extension */
|
|
26
|
+
dispose(): void;
|
|
27
|
+
/** Dispose of all the opened Row Detail Panels Aurelia View Slots */
|
|
28
|
+
disposeAllViewSlot(): void;
|
|
29
|
+
/** Get the instance of the SlickGrid addon (control or plugin). */
|
|
30
|
+
getAddonInstance(): AureliaRowDetailView | null;
|
|
31
|
+
init(grid: SlickGrid): void;
|
|
32
|
+
/**
|
|
33
|
+
* Create the plugin before the Grid creation, else it will behave oddly.
|
|
34
|
+
* Mostly because the column definitions might change after the grid creation
|
|
35
|
+
*/
|
|
36
|
+
register(rowSelectionPlugin?: SelectionModel): this;
|
|
37
|
+
/** Redraw (re-render) all the expanded row detail View Slots */
|
|
38
|
+
redrawAllViewSlots(forceRedraw?: boolean): Promise<void>;
|
|
39
|
+
/** Render all the expanded row detail View Slots */
|
|
40
|
+
renderAllViewModels(): Promise<void>;
|
|
41
|
+
/** Redraw the necessary View Slot */
|
|
42
|
+
redrawViewSlot(slot: CreatedView): Promise<void>;
|
|
43
|
+
/** Render (or re-render) the View Slot (Row Detail) */
|
|
44
|
+
renderPreloadView(): Promise<void>;
|
|
45
|
+
/** Render (or re-render) the View Slot (Row Detail) */
|
|
46
|
+
renderViewModel(item: any): Promise<void>;
|
|
47
|
+
protected disposeView(item: any, removeFromArray?: boolean): void;
|
|
48
|
+
protected disposeViewSlot(expandedView: CreatedView): CreatedView | void;
|
|
49
|
+
/**
|
|
50
|
+
* Just before the row get expanded or collapsed we will do the following
|
|
51
|
+
* First determine if the row is expanding or collapsing,
|
|
52
|
+
* if it's expanding we will add it to our View Slots reference array if we don't already have it
|
|
53
|
+
* or if it's collapsing we will remove it from our View Slots reference array
|
|
54
|
+
*/
|
|
55
|
+
protected handleOnBeforeRowDetailToggle(_e: SlickEventData<OnBeforeRowDetailToggleArgs>, args: {
|
|
56
|
+
grid: SlickGrid;
|
|
57
|
+
item: any;
|
|
58
|
+
}): void;
|
|
59
|
+
/** When Row comes back to Viewport Range, we need to redraw the View */
|
|
60
|
+
protected handleOnRowBackToViewportRange(_e: SlickEventData<OnRowBackOrOutOfViewportRangeArgs>, args: {
|
|
61
|
+
item: any;
|
|
62
|
+
rowId: string | number;
|
|
63
|
+
rowIndex: number;
|
|
64
|
+
expandedRows: (string | number)[];
|
|
65
|
+
rowIdsOutOfViewport: (string | number)[];
|
|
66
|
+
grid: SlickGrid;
|
|
67
|
+
}): Promise<void>;
|
|
68
|
+
/**
|
|
69
|
+
* notify the onAsyncResponse with the "args.item" (required property)
|
|
70
|
+
* the plugin will then use item to populate the row detail panel with the "postTemplate"
|
|
71
|
+
* @param item
|
|
72
|
+
*/
|
|
73
|
+
protected notifyTemplate(item: any): void;
|
|
74
|
+
/**
|
|
75
|
+
* On Processing, we will notify the plugin with the new item detail once backend server call completes
|
|
76
|
+
* @param item
|
|
77
|
+
*/
|
|
78
|
+
protected onProcessing(item: any): Promise<void>;
|
|
79
|
+
}
|
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
import { __esDecorate, __runInitializers } from "tslib";
|
|
2
|
+
import { transient } from '@aurelia/kernel';
|
|
3
|
+
import { addToArrayWhenNotExists, createDomElement, SlickEventData, SlickHybridSelectionModel, unsubscribeAll, } from '@slickgrid-universal/common';
|
|
4
|
+
import { SlickRowDetailView as UniversalSlickRowDetailView } from '@slickgrid-universal/row-detail-view-plugin';
|
|
5
|
+
const ROW_DETAIL_CONTAINER_PREFIX = 'container_';
|
|
6
|
+
const PRELOAD_CONTAINER_PREFIX = 'container_loading';
|
|
7
|
+
let AureliaRowDetailView = (() => {
|
|
8
|
+
let _classDecorators = [transient()];
|
|
9
|
+
let _classDescriptor;
|
|
10
|
+
let _classExtraInitializers = [];
|
|
11
|
+
let _classThis;
|
|
12
|
+
let _classSuper = UniversalSlickRowDetailView;
|
|
13
|
+
var AureliaRowDetailView = class extends _classSuper {
|
|
14
|
+
static { _classThis = this; }
|
|
15
|
+
static {
|
|
16
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
17
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
18
|
+
AureliaRowDetailView = _classThis = _classDescriptor.value;
|
|
19
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
20
|
+
}
|
|
21
|
+
aureliaUtilService;
|
|
22
|
+
eventPubSubService;
|
|
23
|
+
gridContainerElement;
|
|
24
|
+
static pluginName = 'AureliaRowDetailView';
|
|
25
|
+
_preloadViewModel;
|
|
26
|
+
_preloadController;
|
|
27
|
+
_slots = [];
|
|
28
|
+
_subscriptions = [];
|
|
29
|
+
_userProcessFn;
|
|
30
|
+
_viewModel;
|
|
31
|
+
_timer;
|
|
32
|
+
constructor(aureliaUtilService, eventPubSubService, gridContainerElement) {
|
|
33
|
+
super(eventPubSubService);
|
|
34
|
+
this.aureliaUtilService = aureliaUtilService;
|
|
35
|
+
this.eventPubSubService = eventPubSubService;
|
|
36
|
+
this.gridContainerElement = gridContainerElement;
|
|
37
|
+
}
|
|
38
|
+
get addonOptions() {
|
|
39
|
+
return this.getOptions();
|
|
40
|
+
}
|
|
41
|
+
get datasetIdPropName() {
|
|
42
|
+
return this.gridOptions.datasetIdPropertyName || 'id';
|
|
43
|
+
}
|
|
44
|
+
get gridOptions() {
|
|
45
|
+
return (this._grid?.getOptions() || {});
|
|
46
|
+
}
|
|
47
|
+
get rowDetailViewOptions() {
|
|
48
|
+
return this.gridOptions.rowDetailView;
|
|
49
|
+
}
|
|
50
|
+
/** Dispose of the RowDetailView Extension */
|
|
51
|
+
dispose() {
|
|
52
|
+
clearTimeout(this._timer);
|
|
53
|
+
this.disposeAllViewSlot();
|
|
54
|
+
unsubscribeAll(this._subscriptions);
|
|
55
|
+
super.dispose();
|
|
56
|
+
}
|
|
57
|
+
/** Dispose of all the opened Row Detail Panels Aurelia View Slots */
|
|
58
|
+
disposeAllViewSlot() {
|
|
59
|
+
do {
|
|
60
|
+
const view = this._slots.pop();
|
|
61
|
+
if (view) {
|
|
62
|
+
this.disposeView(view);
|
|
63
|
+
}
|
|
64
|
+
} while (this._slots.length > 0);
|
|
65
|
+
}
|
|
66
|
+
/** Get the instance of the SlickGrid addon (control or plugin). */
|
|
67
|
+
getAddonInstance() {
|
|
68
|
+
return this;
|
|
69
|
+
}
|
|
70
|
+
init(grid) {
|
|
71
|
+
this._grid = grid;
|
|
72
|
+
super.init(grid);
|
|
73
|
+
this.register(grid.getSelectionModel());
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Create the plugin before the Grid creation, else it will behave oddly.
|
|
77
|
+
* Mostly because the column definitions might change after the grid creation
|
|
78
|
+
*/
|
|
79
|
+
register(rowSelectionPlugin) {
|
|
80
|
+
if (typeof this.gridOptions.rowDetailView?.process === 'function') {
|
|
81
|
+
// we need to keep the user "process" method and replace it with our own execution method
|
|
82
|
+
// we do this because when we get the item detail, we need to call "onAsyncResponse.notify" for the plugin to work
|
|
83
|
+
this._userProcessFn = this.gridOptions.rowDetailView.process; // keep user's process method
|
|
84
|
+
this.addonOptions.process = (item) => this.onProcessing(item); // replace process method & run our internal one
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
throw new Error('[Aurelia-Slickgrid] You need to provide a "process" function for the Row Detail Extension to work properly');
|
|
88
|
+
}
|
|
89
|
+
if (this._grid && this.gridOptions?.rowDetailView) {
|
|
90
|
+
// load the Preload & RowDetail Templates (could be straight HTML or Aurelia View/ViewModel)
|
|
91
|
+
// when those are Aurelia View/ViewModel, we need to create View Slot & provide the html containers to the Plugin (preTemplate/postTemplate methods)
|
|
92
|
+
if (!this.gridOptions.rowDetailView.preTemplate) {
|
|
93
|
+
this._preloadViewModel = this.gridOptions.rowDetailView.preloadViewModel;
|
|
94
|
+
this.addonOptions.preTemplate = () => createDomElement('div', { className: `${PRELOAD_CONTAINER_PREFIX}` });
|
|
95
|
+
}
|
|
96
|
+
if (!this.gridOptions.rowDetailView.postTemplate) {
|
|
97
|
+
this._viewModel = this.gridOptions.rowDetailView.viewModel;
|
|
98
|
+
this.addonOptions.postTemplate = (itemDetail) => createDomElement('div', { className: `${ROW_DETAIL_CONTAINER_PREFIX}${itemDetail[this.datasetIdPropName]}` });
|
|
99
|
+
}
|
|
100
|
+
if (this._grid && this.gridOptions) {
|
|
101
|
+
// this also requires the Row Selection Model to be registered as well
|
|
102
|
+
if (!rowSelectionPlugin || !this._grid.getSelectionModel()) {
|
|
103
|
+
const selectionType = this.gridOptions.selectionOptions?.selectionType || 'row';
|
|
104
|
+
const selectActiveRow = this.gridOptions.selectionOptions?.selectActiveRow ?? true;
|
|
105
|
+
rowSelectionPlugin = new SlickHybridSelectionModel({ ...this.gridOptions.selectionOptions, selectionType, selectActiveRow });
|
|
106
|
+
this._grid.setSelectionModel(rowSelectionPlugin);
|
|
107
|
+
}
|
|
108
|
+
// hook all events
|
|
109
|
+
if (this._grid && this.rowDetailViewOptions) {
|
|
110
|
+
if (this.rowDetailViewOptions.onExtensionRegistered) {
|
|
111
|
+
this.rowDetailViewOptions.onExtensionRegistered(this);
|
|
112
|
+
}
|
|
113
|
+
this._eventHandler.subscribe(this.onAsyncResponse, (event, args) => {
|
|
114
|
+
if (typeof this.rowDetailViewOptions?.onAsyncResponse === 'function') {
|
|
115
|
+
this.rowDetailViewOptions.onAsyncResponse(event, args);
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
this._eventHandler.subscribe(this.onAsyncEndUpdate, async (event, args) => {
|
|
119
|
+
// dispose preload if exists
|
|
120
|
+
this._preloadController?.dispose();
|
|
121
|
+
// triggers after backend called "onAsyncResponse.notify()"
|
|
122
|
+
// because of the preload destroy above, we need a small delay to make sure the DOM element is ready to render the Row Detail
|
|
123
|
+
queueMicrotask(async () => {
|
|
124
|
+
await this.renderViewModel(args?.item);
|
|
125
|
+
if (typeof this.rowDetailViewOptions?.onAsyncEndUpdate === 'function') {
|
|
126
|
+
this.rowDetailViewOptions.onAsyncEndUpdate(event, args);
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
});
|
|
130
|
+
this._eventHandler.subscribe(this.onAfterRowDetailToggle, async (event, args) => {
|
|
131
|
+
// display preload template & re-render all the other Detail Views after toggling
|
|
132
|
+
// the preload View will eventually go away once the data gets loaded after the "onAsyncEndUpdate" event
|
|
133
|
+
await this.renderPreloadView();
|
|
134
|
+
if (typeof this.rowDetailViewOptions?.onAfterRowDetailToggle === 'function') {
|
|
135
|
+
this.rowDetailViewOptions.onAfterRowDetailToggle(event, args);
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
this._eventHandler.subscribe(this.onBeforeRowDetailToggle, (event, args) => {
|
|
139
|
+
// before toggling row detail, we need to create View Slot if it doesn't exist
|
|
140
|
+
this.handleOnBeforeRowDetailToggle(event, args);
|
|
141
|
+
if (typeof this.rowDetailViewOptions?.onBeforeRowDetailToggle === 'function') {
|
|
142
|
+
return this.rowDetailViewOptions.onBeforeRowDetailToggle(event, args);
|
|
143
|
+
}
|
|
144
|
+
return true;
|
|
145
|
+
});
|
|
146
|
+
this._eventHandler.subscribe(this.onRowBackToViewportRange, async (event, args) => {
|
|
147
|
+
// when row is back to viewport range, we will re-render the View Slot(s)
|
|
148
|
+
await this.handleOnRowBackToViewportRange(event, args);
|
|
149
|
+
if (typeof this.rowDetailViewOptions?.onRowBackToViewportRange === 'function') {
|
|
150
|
+
this.rowDetailViewOptions.onRowBackToViewportRange(event, args);
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
this._eventHandler.subscribe(this.onBeforeRowOutOfViewportRange, (event, args) => {
|
|
154
|
+
if (typeof this.rowDetailViewOptions?.onBeforeRowOutOfViewportRange === 'function') {
|
|
155
|
+
this.rowDetailViewOptions.onBeforeRowOutOfViewportRange(event, args);
|
|
156
|
+
}
|
|
157
|
+
this.disposeView(args.item);
|
|
158
|
+
});
|
|
159
|
+
this._eventHandler.subscribe(this.onRowOutOfViewportRange, (event, args) => {
|
|
160
|
+
if (typeof this.rowDetailViewOptions?.onRowOutOfViewportRange === 'function') {
|
|
161
|
+
this.rowDetailViewOptions.onRowOutOfViewportRange(event, args);
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
// --
|
|
165
|
+
// hook some events needed by the Plugin itself
|
|
166
|
+
// we need to redraw the open detail views if we change column position (column reorder)
|
|
167
|
+
this._eventHandler.subscribe(this._grid.onColumnsReordered, this.redrawAllViewSlots.bind(this, false));
|
|
168
|
+
// on row selection changed, we also need to redraw
|
|
169
|
+
if (this.gridOptions.enableSelection || this.gridOptions.enableCheckboxSelector) {
|
|
170
|
+
this._eventHandler.subscribe(this._grid.onSelectedRowsChanged, this.redrawAllViewSlots.bind(this, false));
|
|
171
|
+
}
|
|
172
|
+
// on column sort/reorder, all row detail are collapsed so we can dispose of all the Views as well
|
|
173
|
+
this._eventHandler.subscribe(this._grid.onSort, this.disposeAllViewSlot.bind(this));
|
|
174
|
+
// redraw all Views whenever certain events are triggered
|
|
175
|
+
this._subscriptions.push(this.eventPubSubService?.subscribe(['onFilterChanged', 'onGridMenuColumnsChanged', 'onColumnPickerColumnsChanged'], this.redrawAllViewSlots.bind(this, false)), this.eventPubSubService?.subscribe(['onGridMenuClearAllFilters', 'onGridMenuClearAllSorting'], () => {
|
|
176
|
+
clearTimeout(this._timer);
|
|
177
|
+
this._timer = setTimeout(() => this.redrawAllViewSlots());
|
|
178
|
+
}));
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
return this;
|
|
183
|
+
}
|
|
184
|
+
/** Redraw (re-render) all the expanded row detail View Slots */
|
|
185
|
+
async redrawAllViewSlots(forceRedraw = false) {
|
|
186
|
+
this.resetRenderedRows();
|
|
187
|
+
const promises = [];
|
|
188
|
+
this._slots.forEach((x) => {
|
|
189
|
+
forceRedraw && x.controller?.deactivate(x.controller, null);
|
|
190
|
+
promises.push(this.redrawViewSlot(x));
|
|
191
|
+
});
|
|
192
|
+
await Promise.all(promises);
|
|
193
|
+
}
|
|
194
|
+
/** Render all the expanded row detail View Slots */
|
|
195
|
+
async renderAllViewModels() {
|
|
196
|
+
const promises = [];
|
|
197
|
+
this._slots.filter((x) => x?.dataContext).forEach((x) => promises.push(this.renderViewModel(x.dataContext)));
|
|
198
|
+
await Promise.all(promises);
|
|
199
|
+
}
|
|
200
|
+
/** Redraw the necessary View Slot */
|
|
201
|
+
async redrawViewSlot(slot) {
|
|
202
|
+
const containerElement = this.gridContainerElement.querySelector(`.${ROW_DETAIL_CONTAINER_PREFIX}${slot.id}`);
|
|
203
|
+
if (containerElement) {
|
|
204
|
+
await this.renderViewModel(slot.dataContext);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
/** Render (or re-render) the View Slot (Row Detail) */
|
|
208
|
+
async renderPreloadView() {
|
|
209
|
+
const containerElement = this.gridContainerElement.querySelector(`.${PRELOAD_CONTAINER_PREFIX}`);
|
|
210
|
+
if (this._preloadViewModel && containerElement) {
|
|
211
|
+
const preloadComp = await this.aureliaUtilService.createAureliaViewModelAddToSlot(this._preloadViewModel, undefined, containerElement);
|
|
212
|
+
this._preloadController = preloadComp?.controller;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
/** Render (or re-render) the View Slot (Row Detail) */
|
|
216
|
+
async renderViewModel(item) {
|
|
217
|
+
const containerElement = this.gridContainerElement.querySelector(`.${ROW_DETAIL_CONTAINER_PREFIX}${item[this.datasetIdPropName]}`);
|
|
218
|
+
if (this._viewModel && containerElement) {
|
|
219
|
+
// render row detail
|
|
220
|
+
const bindableData = {
|
|
221
|
+
model: item,
|
|
222
|
+
addon: this,
|
|
223
|
+
grid: this._grid,
|
|
224
|
+
dataView: this.dataView,
|
|
225
|
+
parentRef: this.rowDetailViewOptions?.parentRef,
|
|
226
|
+
};
|
|
227
|
+
const aureliaComp = await this.aureliaUtilService.createAureliaViewModelAddToSlot(this._viewModel, bindableData, containerElement);
|
|
228
|
+
const slotObj = this._slots.find((obj) => obj.id === item[this.datasetIdPropName]);
|
|
229
|
+
if (slotObj && aureliaComp) {
|
|
230
|
+
slotObj.controller = aureliaComp.controller;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
// --
|
|
235
|
+
// protected functions
|
|
236
|
+
// ------------------
|
|
237
|
+
disposeView(item, removeFromArray = false) {
|
|
238
|
+
const foundSlotIndex = this._slots.findIndex((slot) => slot.id === item[this.datasetIdPropName]);
|
|
239
|
+
if (foundSlotIndex >= 0 && this.disposeViewSlot(this._slots[foundSlotIndex])) {
|
|
240
|
+
if (removeFromArray) {
|
|
241
|
+
this._slots.splice(foundSlotIndex, 1);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
disposeViewSlot(expandedView) {
|
|
246
|
+
if (expandedView?.controller) {
|
|
247
|
+
const container = this.gridContainerElement.querySelector(`.${ROW_DETAIL_CONTAINER_PREFIX}${expandedView.id}`);
|
|
248
|
+
if (container) {
|
|
249
|
+
expandedView.controller.deactivate(expandedView.controller, null);
|
|
250
|
+
container.textContent = '';
|
|
251
|
+
return expandedView;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Just before the row get expanded or collapsed we will do the following
|
|
257
|
+
* First determine if the row is expanding or collapsing,
|
|
258
|
+
* if it's expanding we will add it to our View Slots reference array if we don't already have it
|
|
259
|
+
* or if it's collapsing we will remove it from our View Slots reference array
|
|
260
|
+
*/
|
|
261
|
+
handleOnBeforeRowDetailToggle(_e, args) {
|
|
262
|
+
// expanding
|
|
263
|
+
if (args?.item?.__collapsed) {
|
|
264
|
+
// expanding row detail
|
|
265
|
+
const viewInfo = {
|
|
266
|
+
id: args.item[this.datasetIdPropName],
|
|
267
|
+
dataContext: args.item,
|
|
268
|
+
};
|
|
269
|
+
addToArrayWhenNotExists(this._slots, viewInfo, this.datasetIdPropName);
|
|
270
|
+
}
|
|
271
|
+
else {
|
|
272
|
+
// collapsing, so dispose of the View/ViewSlot
|
|
273
|
+
this.disposeView(args.item, true);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
/** When Row comes back to Viewport Range, we need to redraw the View */
|
|
277
|
+
async handleOnRowBackToViewportRange(_e, args) {
|
|
278
|
+
const slot = this._slots.find((x) => x.id === args.rowId);
|
|
279
|
+
if (slot) {
|
|
280
|
+
this.redrawViewSlot(slot);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* notify the onAsyncResponse with the "args.item" (required property)
|
|
285
|
+
* the plugin will then use item to populate the row detail panel with the "postTemplate"
|
|
286
|
+
* @param item
|
|
287
|
+
*/
|
|
288
|
+
notifyTemplate(item) {
|
|
289
|
+
this.onAsyncResponse.notify({ item }, new SlickEventData(), this);
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* On Processing, we will notify the plugin with the new item detail once backend server call completes
|
|
293
|
+
* @param item
|
|
294
|
+
*/
|
|
295
|
+
async onProcessing(item) {
|
|
296
|
+
if (item && typeof this._userProcessFn === 'function') {
|
|
297
|
+
let awaitedItemDetail;
|
|
298
|
+
const userProcessFn = this._userProcessFn(item);
|
|
299
|
+
// wait for the "userProcessFn", once resolved we will save it into the "collection"
|
|
300
|
+
const response = await userProcessFn;
|
|
301
|
+
if (response.hasOwnProperty(this.datasetIdPropName)) {
|
|
302
|
+
awaitedItemDetail = response; // from Promise
|
|
303
|
+
}
|
|
304
|
+
else if (response instanceof Response && typeof response['json'] === 'function') {
|
|
305
|
+
awaitedItemDetail = await response['json'](); // from Fetch
|
|
306
|
+
}
|
|
307
|
+
else if (response && response['content']) {
|
|
308
|
+
awaitedItemDetail = response['content']; // from aurelia-http-client
|
|
309
|
+
}
|
|
310
|
+
if (!awaitedItemDetail || !awaitedItemDetail.hasOwnProperty(this.datasetIdPropName)) {
|
|
311
|
+
throw new Error('[Aurelia-Slickgrid] could not process the Row Detail, please make sure that your "process" callback ' +
|
|
312
|
+
`returns an item object that has an "${this.datasetIdPropName}" property`);
|
|
313
|
+
}
|
|
314
|
+
// notify the plugin with the new item details
|
|
315
|
+
this.notifyTemplate(awaitedItemDetail || {});
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
static {
|
|
319
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
320
|
+
}
|
|
321
|
+
};
|
|
322
|
+
return AureliaRowDetailView = _classThis;
|
|
323
|
+
})();
|
|
324
|
+
export { AureliaRowDetailView };
|
|
325
|
+
//# sourceMappingURL=aureliaRowDetailView.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aureliaRowDetailView.js","sourceRoot":"","sources":["../src/aureliaRowDetailView.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAsB,MAAM,iBAAiB,CAAC;AAEhE,OAAO,EACL,uBAAuB,EACvB,gBAAgB,EAChB,cAAc,EACd,yBAAyB,EACzB,cAAc,GAMf,MAAM,6BA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AC3B,MAAM,aAAa,GAAG,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;gBAEhD,oFAAoF;gBACpF,MAAM,QAAQ,GAAgB,MAAM,aAAa,CAAC;gBAElD,IAAI,QAAQ,CAAC,cAAc,CAAC,IAAI,CAAC,iBAAiB,CAAC,EAAE,CAAC;oBACpD,iBAAiB,GAAG,QAAQ,CAAC,CAAC,eAAe;gBAC/C,CAAC;qBAAM,IAAI,QAAQ,YAAY,QAAQ,IAAI,OAAO,QAAQ,CAAC,MAAM,CAAC,KAAK,UAAU,EAAE,CAAC;oBAClF,iBAAiB,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,aAAa;gBAC7D,CAAC;qBAAM,IAAI,QAAQ,IAAI,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;oBAC3C,iBAAiB,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,2BAA2B;gBACtE,CAAC;gBAED,IAAI,CAAC,iBAAiB,IAAI,CAAC,iBAAiB,CAAC,cAAc,CAAC,IAAI,CAAC,iBAAiB,CAAC,EAAE,CAAC;oBACpF,MAAM,IAAI,KAAK,CACb,sGAAsG;wBACpG,uCAAuC,IAAI,CAAC,iBAAiB,YAAY,CAC5E,CAAC;gBACJ,CAAC;gBAED,8CAA8C;gBAC9C,IAAI,CAAC,cAAc,CAAC,iBAAiB,IAAI,EAAE,CAAC,CAAC;YAC/C,CAAC;QACH,CAAC;;YA5WU,uDAAoB;;;;;SAApB,oBAAoB","sourcesContent":["import { transient, type Constructable } from '@aurelia/kernel';\nimport type { ICustomElementController } from '@aurelia/runtime-html';\nimport {\n addToArrayWhenNotExists,\n createDomElement,\n SlickEventData,\n SlickHybridSelectionModel,\n unsubscribeAll,\n type EventSubscription,\n type OnBeforeRowDetailToggleArgs,\n type OnRowBackOrOutOfViewportRangeArgs,\n type SelectionModel,\n type SlickGrid,\n} from '@slickgrid-universal/common';\nimport { EventPubSubService } from '@slickgrid-universal/event-pub-sub';\nimport { SlickRowDetailView as UniversalSlickRowDetailView } from '@slickgrid-universal/row-detail-view-plugin';\nimport type { AureliaUtilService, CreatedView, GridOption, ViewModelBindableInputData } from 'aurelia-slickgrid';\nimport type { RowDetailView } from './interfaces';\n\nconst ROW_DETAIL_CONTAINER_PREFIX = 'container_';\nconst PRELOAD_CONTAINER_PREFIX = 'container_loading';\n\n@transient()\nexport class AureliaRowDetailView extends UniversalSlickRowDetailView {\n static readonly pluginName = 'AureliaRowDetailView';\n protected _preloadViewModel?: Constructable;\n protected _preloadController?: ICustomElementController;\n protected _slots: CreatedView[] = [];\n protected _subscriptions: EventSubscription[] = [];\n protected _userProcessFn?: (item: any) => Promise<any>;\n protected _viewModel?: Constructable;\n protected _timer?: any;\n\n constructor(\n protected readonly aureliaUtilService: AureliaUtilService,\n protected readonly eventPubSubService: EventPubSubService,\n protected readonly gridContainerElement: HTMLElement\n ) {\n super(eventPubSubService);\n }\n\n get addonOptions() {\n return this.getOptions();\n }\n\n protected get datasetIdPropName(): string {\n return this.gridOptions.datasetIdPropertyName || 'id';\n }\n\n get gridOptions(): GridOption {\n return (this._grid?.getOptions() || {}) as GridOption;\n }\n\n get rowDetailViewOptions(): RowDetailView | undefined {\n return this.gridOptions.rowDetailView;\n }\n\n /** Dispose of the RowDetailView Extension */\n dispose() {\n clearTimeout(this._timer);\n this.disposeAllViewSlot();\n unsubscribeAll(this._subscriptions);\n super.dispose();\n }\n\n /** Dispose of all the opened Row Detail Panels Aurelia View Slots */\n disposeAllViewSlot() {\n do {\n const view = this._slots.pop();\n if (view) {\n this.disposeView(view);\n }\n } while (this._slots.length > 0);\n }\n\n /** Get the instance of the SlickGrid addon (control or plugin). */\n getAddonInstance(): AureliaRowDetailView | null {\n return this;\n }\n\n init(grid: SlickGrid) {\n this._grid = grid;\n super.init(grid);\n this.register(grid.getSelectionModel());\n }\n\n /**\n * Create the plugin before the Grid creation, else it will behave oddly.\n * Mostly because the column definitions might change after the grid creation\n */\n register(rowSelectionPlugin?: SelectionModel) {\n if (typeof this.gridOptions.rowDetailView?.process === 'function') {\n // we need to keep the user \"process\" method and replace it with our own execution method\n // we do this because when we get the item detail, we need to call \"onAsyncResponse.notify\" for the plugin to work\n this._userProcessFn = this.gridOptions.rowDetailView.process as (item: any) => Promise<any>; // keep user's process method\n this.addonOptions.process = (item) => this.onProcessing(item); // replace process method & run our internal one\n } else {\n throw new Error('[Aurelia-Slickgrid] You need to provide a \"process\" function for the Row Detail Extension to work properly');\n }\n\n if (this._grid && this.gridOptions?.rowDetailView) {\n // load the Preload & RowDetail Templates (could be straight HTML or Aurelia View/ViewModel)\n // when those are Aurelia View/ViewModel, we need to create View Slot & provide the html containers to the Plugin (preTemplate/postTemplate methods)\n if (!this.gridOptions.rowDetailView.preTemplate) {\n this._preloadViewModel = this.gridOptions.rowDetailView.preloadViewModel;\n this.addonOptions.preTemplate = () => createDomElement('div', { className: `${PRELOAD_CONTAINER_PREFIX}` });\n }\n if (!this.gridOptions.rowDetailView.postTemplate) {\n this._viewModel = this.gridOptions.rowDetailView.viewModel;\n this.addonOptions.postTemplate = (itemDetail: any) =>\n createDomElement('div', { className: `${ROW_DETAIL_CONTAINER_PREFIX}${itemDetail[this.datasetIdPropName]}` });\n }\n\n if (this._grid && this.gridOptions) {\n // this also requires the Row Selection Model to be registered as well\n if (!rowSelectionPlugin || !this._grid.getSelectionModel()) {\n const selectionType = this.gridOptions.selectionOptions?.selectionType || 'row';\n const selectActiveRow = this.gridOptions.selectionOptions?.selectActiveRow ?? true;\n rowSelectionPlugin = new SlickHybridSelectionModel({ ...this.gridOptions.selectionOptions, selectionType, selectActiveRow });\n this._grid.setSelectionModel(rowSelectionPlugin);\n }\n\n // hook all events\n if (this._grid && this.rowDetailViewOptions) {\n if (this.rowDetailViewOptions.onExtensionRegistered) {\n this.rowDetailViewOptions.onExtensionRegistered(this);\n }\n\n this._eventHandler.subscribe(this.onAsyncResponse, (event, args) => {\n if (typeof this.rowDetailViewOptions?.onAsyncResponse === 'function') {\n this.rowDetailViewOptions.onAsyncResponse(event, args);\n }\n });\n\n this._eventHandler.subscribe(this.onAsyncEndUpdate, async (event, args) => {\n // dispose preload if exists\n this._preloadController?.dispose();\n\n // triggers after backend called \"onAsyncResponse.notify()\"\n // because of the preload destroy above, we need a small delay to make sure the DOM element is ready to render the Row Detail\n queueMicrotask(async () => {\n await this.renderViewModel(args?.item);\n\n if (typeof this.rowDetailViewOptions?.onAsyncEndUpdate === 'function') {\n this.rowDetailViewOptions.onAsyncEndUpdate(event, args);\n }\n });\n });\n\n this._eventHandler.subscribe(this.onAfterRowDetailToggle, async (event, args) => {\n // display preload template & re-render all the other Detail Views after toggling\n // the preload View will eventually go away once the data gets loaded after the \"onAsyncEndUpdate\" event\n await this.renderPreloadView();\n\n if (typeof this.rowDetailViewOptions?.onAfterRowDetailToggle === 'function') {\n this.rowDetailViewOptions.onAfterRowDetailToggle(event, args);\n }\n });\n\n this._eventHandler.subscribe(this.onBeforeRowDetailToggle, (event, args) => {\n // before toggling row detail, we need to create View Slot if it doesn't exist\n this.handleOnBeforeRowDetailToggle(event, args);\n\n if (typeof this.rowDetailViewOptions?.onBeforeRowDetailToggle === 'function') {\n return this.rowDetailViewOptions.onBeforeRowDetailToggle(event, args);\n }\n return true;\n });\n\n this._eventHandler.subscribe(this.onRowBackToViewportRange, async (event, args) => {\n // when row is back to viewport range, we will re-render the View Slot(s)\n await this.handleOnRowBackToViewportRange(event, args);\n\n if (typeof this.rowDetailViewOptions?.onRowBackToViewportRange === 'function') {\n this.rowDetailViewOptions.onRowBackToViewportRange(event, args);\n }\n });\n\n this._eventHandler.subscribe(this.onBeforeRowOutOfViewportRange, (event, args) => {\n if (typeof this.rowDetailViewOptions?.onBeforeRowOutOfViewportRange === 'function') {\n this.rowDetailViewOptions.onBeforeRowOutOfViewportRange(event, args);\n }\n this.disposeView(args.item);\n });\n\n this._eventHandler.subscribe(this.onRowOutOfViewportRange, (event, args) => {\n if (typeof this.rowDetailViewOptions?.onRowOutOfViewportRange === 'function') {\n this.rowDetailViewOptions.onRowOutOfViewportRange(event, args);\n }\n });\n\n // --\n // hook some events needed by the Plugin itself\n\n // we need to redraw the open detail views if we change column position (column reorder)\n this._eventHandler.subscribe(this._grid.onColumnsReordered, this.redrawAllViewSlots.bind(this, false));\n\n // on row selection changed, we also need to redraw\n if (this.gridOptions.enableSelection || this.gridOptions.enableCheckboxSelector) {\n this._eventHandler.subscribe(this._grid.onSelectedRowsChanged, this.redrawAllViewSlots.bind(this, false));\n }\n\n // on column sort/reorder, all row detail are collapsed so we can dispose of all the Views as well\n this._eventHandler.subscribe(this._grid.onSort, this.disposeAllViewSlot.bind(this));\n\n // redraw all Views whenever certain events are triggered\n this._subscriptions.push(\n this.eventPubSubService?.subscribe(\n ['onFilterChanged', 'onGridMenuColumnsChanged', 'onColumnPickerColumnsChanged'],\n this.redrawAllViewSlots.bind(this, false)\n ),\n this.eventPubSubService?.subscribe(['onGridMenuClearAllFilters', 'onGridMenuClearAllSorting'], () => {\n clearTimeout(this._timer);\n this._timer = setTimeout(() => this.redrawAllViewSlots());\n })\n );\n }\n }\n }\n\n return this;\n }\n\n /** Redraw (re-render) all the expanded row detail View Slots */\n async redrawAllViewSlots(forceRedraw = false) {\n this.resetRenderedRows();\n const promises: Promise<void>[] = [];\n this._slots.forEach((x) => {\n forceRedraw && x.controller?.deactivate(x.controller, null);\n promises.push(this.redrawViewSlot(x));\n });\n await Promise.all(promises);\n }\n\n /** Render all the expanded row detail View Slots */\n async renderAllViewModels() {\n const promises: Promise<void>[] = [];\n this._slots.filter((x) => x?.dataContext).forEach((x) => promises.push(this.renderViewModel(x.dataContext)));\n await Promise.all(promises);\n }\n\n /** Redraw the necessary View Slot */\n async redrawViewSlot(slot: CreatedView) {\n const containerElement = this.gridContainerElement.querySelector(`.${ROW_DETAIL_CONTAINER_PREFIX}${slot.id}`);\n if (containerElement) {\n await this.renderViewModel(slot.dataContext);\n }\n }\n\n /** Render (or re-render) the View Slot (Row Detail) */\n async renderPreloadView() {\n const containerElement = this.gridContainerElement.querySelector<HTMLElement>(`.${PRELOAD_CONTAINER_PREFIX}`);\n if (this._preloadViewModel && containerElement) {\n const preloadComp = await this.aureliaUtilService.createAureliaViewModelAddToSlot(\n this._preloadViewModel,\n undefined,\n containerElement\n );\n this._preloadController = preloadComp?.controller;\n }\n }\n\n /** Render (or re-render) the View Slot (Row Detail) */\n async renderViewModel(item: any) {\n const containerElement = this.gridContainerElement.querySelector<HTMLElement>(\n `.${ROW_DETAIL_CONTAINER_PREFIX}${item[this.datasetIdPropName]}`\n );\n if (this._viewModel && containerElement) {\n // render row detail\n const bindableData = {\n model: item,\n addon: this,\n grid: this._grid,\n dataView: this.dataView,\n parentRef: this.rowDetailViewOptions?.parentRef,\n } as ViewModelBindableInputData;\n const aureliaComp = await this.aureliaUtilService.createAureliaViewModelAddToSlot(this._viewModel, bindableData, containerElement);\n const slotObj = this._slots.find((obj) => obj.id === item[this.datasetIdPropName]);\n\n if (slotObj && aureliaComp) {\n slotObj.controller = aureliaComp.controller;\n }\n }\n }\n\n // --\n // protected functions\n // ------------------\n\n protected disposeView(item: any, removeFromArray = false): void {\n const foundSlotIndex = this._slots.findIndex((slot: CreatedView) => slot.id === item[this.datasetIdPropName]);\n if (foundSlotIndex >= 0 && this.disposeViewSlot(this._slots[foundSlotIndex])) {\n if (removeFromArray) {\n this._slots.splice(foundSlotIndex, 1);\n }\n }\n }\n\n protected disposeViewSlot(expandedView: CreatedView): CreatedView | void {\n if (expandedView?.controller) {\n const container = this.gridContainerElement.querySelector(`.${ROW_DETAIL_CONTAINER_PREFIX}${expandedView.id}`);\n if (container) {\n expandedView.controller.deactivate(expandedView.controller, null);\n container.textContent = '';\n return expandedView;\n }\n }\n }\n\n /**\n * Just before the row get expanded or collapsed we will do the following\n * First determine if the row is expanding or collapsing,\n * if it's expanding we will add it to our View Slots reference array if we don't already have it\n * or if it's collapsing we will remove it from our View Slots reference array\n */\n protected handleOnBeforeRowDetailToggle(_e: SlickEventData<OnBeforeRowDetailToggleArgs>, args: { grid: SlickGrid; item: any }) {\n // expanding\n if (args?.item?.__collapsed) {\n // expanding row detail\n const viewInfo: CreatedView = {\n id: args.item[this.datasetIdPropName],\n dataContext: args.item,\n };\n addToArrayWhenNotExists(this._slots, viewInfo, this.datasetIdPropName);\n } else {\n // collapsing, so dispose of the View/ViewSlot\n this.disposeView(args.item, true);\n }\n }\n\n /** When Row comes back to Viewport Range, we need to redraw the View */\n protected async handleOnRowBackToViewportRange(\n _e: SlickEventData<OnRowBackOrOutOfViewportRangeArgs>,\n args: {\n item: any;\n rowId: string | number;\n rowIndex: number;\n expandedRows: (string | number)[];\n rowIdsOutOfViewport: (string | number)[];\n grid: SlickGrid;\n }\n ) {\n const slot = this._slots.find((x) => x.id === args.rowId);\n if (slot) {\n this.redrawViewSlot(slot);\n }\n }\n\n /**\n * notify the onAsyncResponse with the \"args.item\" (required property)\n * the plugin will then use item to populate the row detail panel with the \"postTemplate\"\n * @param item\n */\n protected notifyTemplate(item: any) {\n this.onAsyncResponse.notify({ item }, new SlickEventData(), this);\n }\n\n /**\n * On Processing, we will notify the plugin with the new item detail once backend server call completes\n * @param item\n */\n protected async onProcessing(item: any) {\n if (item && typeof this._userProcessFn === 'function') {\n let awaitedItemDetail: any;\n const userProcessFn = this._userProcessFn(item);\n\n // wait for the \"userProcessFn\", once resolved we will save it into the \"collection\"\n const response: any | any[] = await userProcessFn;\n\n if (response.hasOwnProperty(this.datasetIdPropName)) {\n awaitedItemDetail = response; // from Promise\n } else if (response instanceof Response && typeof response['json'] === 'function') {\n awaitedItemDetail = await response['json'](); // from Fetch\n } else if (response && response['content']) {\n awaitedItemDetail = response['content']; // from aurelia-http-client\n }\n\n if (!awaitedItemDetail || !awaitedItemDetail.hasOwnProperty(this.datasetIdPropName)) {\n throw new Error(\n '[Aurelia-Slickgrid] could not process the Row Detail, please make sure that your \"process\" callback ' +\n `returns an item object that has an \"${this.datasetIdPropName}\" property`\n );\n }\n\n // notify the plugin with the new item details\n this.notifyTemplate(awaitedItemDetail || {});\n }\n }\n}\n"]}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './aureliaRowDetailView.js';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC","sourcesContent":["export * from './aureliaRowDetailView.js';\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Constructable } from '@aurelia/kernel';
|
|
2
|
+
import type { RowDetailView as UniversalRowDetailView } from '@slickgrid-universal/common';
|
|
3
|
+
export interface RowDetailView extends UniversalRowDetailView {
|
|
4
|
+
/**
|
|
5
|
+
* Optionally pass your Parent Component reference to your Child Component (row detail component).
|
|
6
|
+
* note:: If anyone finds a better way of passing the parent to the row detail extension, please reach out and/or create a PR
|
|
7
|
+
*/
|
|
8
|
+
parentRef?: any;
|
|
9
|
+
/** View Model of the preload template which shows after opening row detail & before row detail data shows up */
|
|
10
|
+
preloadViewModel?: Constructable;
|
|
11
|
+
/** View Model template that will be loaded once the async function finishes */
|
|
12
|
+
viewModel?: Constructable;
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["import type { Constructable } from '@aurelia/kernel';\nimport type { RowDetailView as UniversalRowDetailView } from '@slickgrid-universal/common';\n\nexport interface RowDetailView extends UniversalRowDetailView {\n /**\n * Optionally pass your Parent Component reference to your Child Component (row detail component).\n * note:: If anyone finds a better way of passing the parent to the row detail extension, please reach out and/or create a PR\n */\n parentRef?: any;\n\n /** View Model of the preload template which shows after opening row detail & before row detail data shows up */\n preloadViewModel?: Constructable;\n\n /** View Model template that will be loaded once the async function finishes */\n viewModel?: Constructable;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,10 +1,44 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@slickgrid-universal/aurelia-row-detail-plugin",
|
|
3
|
-
"version": "0.0
|
|
4
|
-
"description": "
|
|
5
|
-
"
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
"
|
|
9
|
-
|
|
3
|
+
"version": "10.0.0",
|
|
4
|
+
"description": "Aurelia Row Detail Plugin for Aurelia-SlickGrid",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"default": "./dist/index.js"
|
|
11
|
+
},
|
|
12
|
+
"./package.json": "./package.json"
|
|
13
|
+
},
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"publishConfig": {
|
|
16
|
+
"access": "public"
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"/dist",
|
|
20
|
+
"/src"
|
|
21
|
+
],
|
|
22
|
+
"license": "MIT",
|
|
23
|
+
"author": "Ghislain B.",
|
|
24
|
+
"homepage": "https://github.com/ghiscoding/slickgrid-universal",
|
|
25
|
+
"repository": {
|
|
26
|
+
"type": "git",
|
|
27
|
+
"url": "git+https://github.com/ghiscoding/slickgrid-universal.git",
|
|
28
|
+
"directory": "packages/aurelia-row-detail-plugin"
|
|
29
|
+
},
|
|
30
|
+
"bugs": {
|
|
31
|
+
"url": "https://github.com/ghiscoding/slickgrid-universal/issues"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"@aurelia/kernel": "^2.0.0-rc.0",
|
|
35
|
+
"@aurelia/runtime-html": "^2.0.0-rc.0",
|
|
36
|
+
"@slickgrid-universal/common": "10.0.0",
|
|
37
|
+
"@slickgrid-universal/event-pub-sub": "10.0.0",
|
|
38
|
+
"@slickgrid-universal/row-detail-view-plugin": "10.0.0",
|
|
39
|
+
"aurelia-slickgrid": "10.0.0",
|
|
40
|
+
"rxjs": "^7.8.2",
|
|
41
|
+
"tslib": "^2.8.1"
|
|
42
|
+
},
|
|
43
|
+
"gitHead": "2da6d300a326e4fffe97c0240e0c311cc1dde2cd"
|
|
10
44
|
}
|
|
@@ -0,0 +1,389 @@
|
|
|
1
|
+
import { transient, type Constructable } from '@aurelia/kernel';
|
|
2
|
+
import type { ICustomElementController } from '@aurelia/runtime-html';
|
|
3
|
+
import {
|
|
4
|
+
addToArrayWhenNotExists,
|
|
5
|
+
createDomElement,
|
|
6
|
+
SlickEventData,
|
|
7
|
+
SlickHybridSelectionModel,
|
|
8
|
+
unsubscribeAll,
|
|
9
|
+
type EventSubscription,
|
|
10
|
+
type OnBeforeRowDetailToggleArgs,
|
|
11
|
+
type OnRowBackOrOutOfViewportRangeArgs,
|
|
12
|
+
type SelectionModel,
|
|
13
|
+
type SlickGrid,
|
|
14
|
+
} from '@slickgrid-universal/common';
|
|
15
|
+
import { EventPubSubService } from '@slickgrid-universal/event-pub-sub';
|
|
16
|
+
import { SlickRowDetailView as UniversalSlickRowDetailView } from '@slickgrid-universal/row-detail-view-plugin';
|
|
17
|
+
import type { AureliaUtilService, CreatedView, GridOption, ViewModelBindableInputData } from 'aurelia-slickgrid';
|
|
18
|
+
import type { RowDetailView } from './interfaces';
|
|
19
|
+
|
|
20
|
+
const ROW_DETAIL_CONTAINER_PREFIX = 'container_';
|
|
21
|
+
const PRELOAD_CONTAINER_PREFIX = 'container_loading';
|
|
22
|
+
|
|
23
|
+
@transient()
|
|
24
|
+
export class AureliaRowDetailView extends UniversalSlickRowDetailView {
|
|
25
|
+
static readonly pluginName = 'AureliaRowDetailView';
|
|
26
|
+
protected _preloadViewModel?: Constructable;
|
|
27
|
+
protected _preloadController?: ICustomElementController;
|
|
28
|
+
protected _slots: CreatedView[] = [];
|
|
29
|
+
protected _subscriptions: EventSubscription[] = [];
|
|
30
|
+
protected _userProcessFn?: (item: any) => Promise<any>;
|
|
31
|
+
protected _viewModel?: Constructable;
|
|
32
|
+
protected _timer?: any;
|
|
33
|
+
|
|
34
|
+
constructor(
|
|
35
|
+
protected readonly aureliaUtilService: AureliaUtilService,
|
|
36
|
+
protected readonly eventPubSubService: EventPubSubService,
|
|
37
|
+
protected readonly gridContainerElement: HTMLElement
|
|
38
|
+
) {
|
|
39
|
+
super(eventPubSubService);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
get addonOptions() {
|
|
43
|
+
return this.getOptions();
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
protected get datasetIdPropName(): string {
|
|
47
|
+
return this.gridOptions.datasetIdPropertyName || 'id';
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
get gridOptions(): GridOption {
|
|
51
|
+
return (this._grid?.getOptions() || {}) as GridOption;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
get rowDetailViewOptions(): RowDetailView | undefined {
|
|
55
|
+
return this.gridOptions.rowDetailView;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** Dispose of the RowDetailView Extension */
|
|
59
|
+
dispose() {
|
|
60
|
+
clearTimeout(this._timer);
|
|
61
|
+
this.disposeAllViewSlot();
|
|
62
|
+
unsubscribeAll(this._subscriptions);
|
|
63
|
+
super.dispose();
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** Dispose of all the opened Row Detail Panels Aurelia View Slots */
|
|
67
|
+
disposeAllViewSlot() {
|
|
68
|
+
do {
|
|
69
|
+
const view = this._slots.pop();
|
|
70
|
+
if (view) {
|
|
71
|
+
this.disposeView(view);
|
|
72
|
+
}
|
|
73
|
+
} while (this._slots.length > 0);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** Get the instance of the SlickGrid addon (control or plugin). */
|
|
77
|
+
getAddonInstance(): AureliaRowDetailView | null {
|
|
78
|
+
return this;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
init(grid: SlickGrid) {
|
|
82
|
+
this._grid = grid;
|
|
83
|
+
super.init(grid);
|
|
84
|
+
this.register(grid.getSelectionModel());
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Create the plugin before the Grid creation, else it will behave oddly.
|
|
89
|
+
* Mostly because the column definitions might change after the grid creation
|
|
90
|
+
*/
|
|
91
|
+
register(rowSelectionPlugin?: SelectionModel) {
|
|
92
|
+
if (typeof this.gridOptions.rowDetailView?.process === 'function') {
|
|
93
|
+
// we need to keep the user "process" method and replace it with our own execution method
|
|
94
|
+
// we do this because when we get the item detail, we need to call "onAsyncResponse.notify" for the plugin to work
|
|
95
|
+
this._userProcessFn = this.gridOptions.rowDetailView.process as (item: any) => Promise<any>; // keep user's process method
|
|
96
|
+
this.addonOptions.process = (item) => this.onProcessing(item); // replace process method & run our internal one
|
|
97
|
+
} else {
|
|
98
|
+
throw new Error('[Aurelia-Slickgrid] You need to provide a "process" function for the Row Detail Extension to work properly');
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (this._grid && this.gridOptions?.rowDetailView) {
|
|
102
|
+
// load the Preload & RowDetail Templates (could be straight HTML or Aurelia View/ViewModel)
|
|
103
|
+
// when those are Aurelia View/ViewModel, we need to create View Slot & provide the html containers to the Plugin (preTemplate/postTemplate methods)
|
|
104
|
+
if (!this.gridOptions.rowDetailView.preTemplate) {
|
|
105
|
+
this._preloadViewModel = this.gridOptions.rowDetailView.preloadViewModel;
|
|
106
|
+
this.addonOptions.preTemplate = () => createDomElement('div', { className: `${PRELOAD_CONTAINER_PREFIX}` });
|
|
107
|
+
}
|
|
108
|
+
if (!this.gridOptions.rowDetailView.postTemplate) {
|
|
109
|
+
this._viewModel = this.gridOptions.rowDetailView.viewModel;
|
|
110
|
+
this.addonOptions.postTemplate = (itemDetail: any) =>
|
|
111
|
+
createDomElement('div', { className: `${ROW_DETAIL_CONTAINER_PREFIX}${itemDetail[this.datasetIdPropName]}` });
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
if (this._grid && this.gridOptions) {
|
|
115
|
+
// this also requires the Row Selection Model to be registered as well
|
|
116
|
+
if (!rowSelectionPlugin || !this._grid.getSelectionModel()) {
|
|
117
|
+
const selectionType = this.gridOptions.selectionOptions?.selectionType || 'row';
|
|
118
|
+
const selectActiveRow = this.gridOptions.selectionOptions?.selectActiveRow ?? true;
|
|
119
|
+
rowSelectionPlugin = new SlickHybridSelectionModel({ ...this.gridOptions.selectionOptions, selectionType, selectActiveRow });
|
|
120
|
+
this._grid.setSelectionModel(rowSelectionPlugin);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// hook all events
|
|
124
|
+
if (this._grid && this.rowDetailViewOptions) {
|
|
125
|
+
if (this.rowDetailViewOptions.onExtensionRegistered) {
|
|
126
|
+
this.rowDetailViewOptions.onExtensionRegistered(this);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
this._eventHandler.subscribe(this.onAsyncResponse, (event, args) => {
|
|
130
|
+
if (typeof this.rowDetailViewOptions?.onAsyncResponse === 'function') {
|
|
131
|
+
this.rowDetailViewOptions.onAsyncResponse(event, args);
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
this._eventHandler.subscribe(this.onAsyncEndUpdate, async (event, args) => {
|
|
136
|
+
// dispose preload if exists
|
|
137
|
+
this._preloadController?.dispose();
|
|
138
|
+
|
|
139
|
+
// triggers after backend called "onAsyncResponse.notify()"
|
|
140
|
+
// because of the preload destroy above, we need a small delay to make sure the DOM element is ready to render the Row Detail
|
|
141
|
+
queueMicrotask(async () => {
|
|
142
|
+
await this.renderViewModel(args?.item);
|
|
143
|
+
|
|
144
|
+
if (typeof this.rowDetailViewOptions?.onAsyncEndUpdate === 'function') {
|
|
145
|
+
this.rowDetailViewOptions.onAsyncEndUpdate(event, args);
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
this._eventHandler.subscribe(this.onAfterRowDetailToggle, async (event, args) => {
|
|
151
|
+
// display preload template & re-render all the other Detail Views after toggling
|
|
152
|
+
// the preload View will eventually go away once the data gets loaded after the "onAsyncEndUpdate" event
|
|
153
|
+
await this.renderPreloadView();
|
|
154
|
+
|
|
155
|
+
if (typeof this.rowDetailViewOptions?.onAfterRowDetailToggle === 'function') {
|
|
156
|
+
this.rowDetailViewOptions.onAfterRowDetailToggle(event, args);
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
this._eventHandler.subscribe(this.onBeforeRowDetailToggle, (event, args) => {
|
|
161
|
+
// before toggling row detail, we need to create View Slot if it doesn't exist
|
|
162
|
+
this.handleOnBeforeRowDetailToggle(event, args);
|
|
163
|
+
|
|
164
|
+
if (typeof this.rowDetailViewOptions?.onBeforeRowDetailToggle === 'function') {
|
|
165
|
+
return this.rowDetailViewOptions.onBeforeRowDetailToggle(event, args);
|
|
166
|
+
}
|
|
167
|
+
return true;
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
this._eventHandler.subscribe(this.onRowBackToViewportRange, async (event, args) => {
|
|
171
|
+
// when row is back to viewport range, we will re-render the View Slot(s)
|
|
172
|
+
await this.handleOnRowBackToViewportRange(event, args);
|
|
173
|
+
|
|
174
|
+
if (typeof this.rowDetailViewOptions?.onRowBackToViewportRange === 'function') {
|
|
175
|
+
this.rowDetailViewOptions.onRowBackToViewportRange(event, args);
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
this._eventHandler.subscribe(this.onBeforeRowOutOfViewportRange, (event, args) => {
|
|
180
|
+
if (typeof this.rowDetailViewOptions?.onBeforeRowOutOfViewportRange === 'function') {
|
|
181
|
+
this.rowDetailViewOptions.onBeforeRowOutOfViewportRange(event, args);
|
|
182
|
+
}
|
|
183
|
+
this.disposeView(args.item);
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
this._eventHandler.subscribe(this.onRowOutOfViewportRange, (event, args) => {
|
|
187
|
+
if (typeof this.rowDetailViewOptions?.onRowOutOfViewportRange === 'function') {
|
|
188
|
+
this.rowDetailViewOptions.onRowOutOfViewportRange(event, args);
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
// --
|
|
193
|
+
// hook some events needed by the Plugin itself
|
|
194
|
+
|
|
195
|
+
// we need to redraw the open detail views if we change column position (column reorder)
|
|
196
|
+
this._eventHandler.subscribe(this._grid.onColumnsReordered, this.redrawAllViewSlots.bind(this, false));
|
|
197
|
+
|
|
198
|
+
// on row selection changed, we also need to redraw
|
|
199
|
+
if (this.gridOptions.enableSelection || this.gridOptions.enableCheckboxSelector) {
|
|
200
|
+
this._eventHandler.subscribe(this._grid.onSelectedRowsChanged, this.redrawAllViewSlots.bind(this, false));
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// on column sort/reorder, all row detail are collapsed so we can dispose of all the Views as well
|
|
204
|
+
this._eventHandler.subscribe(this._grid.onSort, this.disposeAllViewSlot.bind(this));
|
|
205
|
+
|
|
206
|
+
// redraw all Views whenever certain events are triggered
|
|
207
|
+
this._subscriptions.push(
|
|
208
|
+
this.eventPubSubService?.subscribe(
|
|
209
|
+
['onFilterChanged', 'onGridMenuColumnsChanged', 'onColumnPickerColumnsChanged'],
|
|
210
|
+
this.redrawAllViewSlots.bind(this, false)
|
|
211
|
+
),
|
|
212
|
+
this.eventPubSubService?.subscribe(['onGridMenuClearAllFilters', 'onGridMenuClearAllSorting'], () => {
|
|
213
|
+
clearTimeout(this._timer);
|
|
214
|
+
this._timer = setTimeout(() => this.redrawAllViewSlots());
|
|
215
|
+
})
|
|
216
|
+
);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
return this;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/** Redraw (re-render) all the expanded row detail View Slots */
|
|
225
|
+
async redrawAllViewSlots(forceRedraw = false) {
|
|
226
|
+
this.resetRenderedRows();
|
|
227
|
+
const promises: Promise<void>[] = [];
|
|
228
|
+
this._slots.forEach((x) => {
|
|
229
|
+
forceRedraw && x.controller?.deactivate(x.controller, null);
|
|
230
|
+
promises.push(this.redrawViewSlot(x));
|
|
231
|
+
});
|
|
232
|
+
await Promise.all(promises);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/** Render all the expanded row detail View Slots */
|
|
236
|
+
async renderAllViewModels() {
|
|
237
|
+
const promises: Promise<void>[] = [];
|
|
238
|
+
this._slots.filter((x) => x?.dataContext).forEach((x) => promises.push(this.renderViewModel(x.dataContext)));
|
|
239
|
+
await Promise.all(promises);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/** Redraw the necessary View Slot */
|
|
243
|
+
async redrawViewSlot(slot: CreatedView) {
|
|
244
|
+
const containerElement = this.gridContainerElement.querySelector(`.${ROW_DETAIL_CONTAINER_PREFIX}${slot.id}`);
|
|
245
|
+
if (containerElement) {
|
|
246
|
+
await this.renderViewModel(slot.dataContext);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/** Render (or re-render) the View Slot (Row Detail) */
|
|
251
|
+
async renderPreloadView() {
|
|
252
|
+
const containerElement = this.gridContainerElement.querySelector<HTMLElement>(`.${PRELOAD_CONTAINER_PREFIX}`);
|
|
253
|
+
if (this._preloadViewModel && containerElement) {
|
|
254
|
+
const preloadComp = await this.aureliaUtilService.createAureliaViewModelAddToSlot(
|
|
255
|
+
this._preloadViewModel,
|
|
256
|
+
undefined,
|
|
257
|
+
containerElement
|
|
258
|
+
);
|
|
259
|
+
this._preloadController = preloadComp?.controller;
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/** Render (or re-render) the View Slot (Row Detail) */
|
|
264
|
+
async renderViewModel(item: any) {
|
|
265
|
+
const containerElement = this.gridContainerElement.querySelector<HTMLElement>(
|
|
266
|
+
`.${ROW_DETAIL_CONTAINER_PREFIX}${item[this.datasetIdPropName]}`
|
|
267
|
+
);
|
|
268
|
+
if (this._viewModel && containerElement) {
|
|
269
|
+
// render row detail
|
|
270
|
+
const bindableData = {
|
|
271
|
+
model: item,
|
|
272
|
+
addon: this,
|
|
273
|
+
grid: this._grid,
|
|
274
|
+
dataView: this.dataView,
|
|
275
|
+
parentRef: this.rowDetailViewOptions?.parentRef,
|
|
276
|
+
} as ViewModelBindableInputData;
|
|
277
|
+
const aureliaComp = await this.aureliaUtilService.createAureliaViewModelAddToSlot(this._viewModel, bindableData, containerElement);
|
|
278
|
+
const slotObj = this._slots.find((obj) => obj.id === item[this.datasetIdPropName]);
|
|
279
|
+
|
|
280
|
+
if (slotObj && aureliaComp) {
|
|
281
|
+
slotObj.controller = aureliaComp.controller;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
// --
|
|
287
|
+
// protected functions
|
|
288
|
+
// ------------------
|
|
289
|
+
|
|
290
|
+
protected disposeView(item: any, removeFromArray = false): void {
|
|
291
|
+
const foundSlotIndex = this._slots.findIndex((slot: CreatedView) => slot.id === item[this.datasetIdPropName]);
|
|
292
|
+
if (foundSlotIndex >= 0 && this.disposeViewSlot(this._slots[foundSlotIndex])) {
|
|
293
|
+
if (removeFromArray) {
|
|
294
|
+
this._slots.splice(foundSlotIndex, 1);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
protected disposeViewSlot(expandedView: CreatedView): CreatedView | void {
|
|
300
|
+
if (expandedView?.controller) {
|
|
301
|
+
const container = this.gridContainerElement.querySelector(`.${ROW_DETAIL_CONTAINER_PREFIX}${expandedView.id}`);
|
|
302
|
+
if (container) {
|
|
303
|
+
expandedView.controller.deactivate(expandedView.controller, null);
|
|
304
|
+
container.textContent = '';
|
|
305
|
+
return expandedView;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* Just before the row get expanded or collapsed we will do the following
|
|
312
|
+
* First determine if the row is expanding or collapsing,
|
|
313
|
+
* if it's expanding we will add it to our View Slots reference array if we don't already have it
|
|
314
|
+
* or if it's collapsing we will remove it from our View Slots reference array
|
|
315
|
+
*/
|
|
316
|
+
protected handleOnBeforeRowDetailToggle(_e: SlickEventData<OnBeforeRowDetailToggleArgs>, args: { grid: SlickGrid; item: any }) {
|
|
317
|
+
// expanding
|
|
318
|
+
if (args?.item?.__collapsed) {
|
|
319
|
+
// expanding row detail
|
|
320
|
+
const viewInfo: CreatedView = {
|
|
321
|
+
id: args.item[this.datasetIdPropName],
|
|
322
|
+
dataContext: args.item,
|
|
323
|
+
};
|
|
324
|
+
addToArrayWhenNotExists(this._slots, viewInfo, this.datasetIdPropName);
|
|
325
|
+
} else {
|
|
326
|
+
// collapsing, so dispose of the View/ViewSlot
|
|
327
|
+
this.disposeView(args.item, true);
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
/** When Row comes back to Viewport Range, we need to redraw the View */
|
|
332
|
+
protected async handleOnRowBackToViewportRange(
|
|
333
|
+
_e: SlickEventData<OnRowBackOrOutOfViewportRangeArgs>,
|
|
334
|
+
args: {
|
|
335
|
+
item: any;
|
|
336
|
+
rowId: string | number;
|
|
337
|
+
rowIndex: number;
|
|
338
|
+
expandedRows: (string | number)[];
|
|
339
|
+
rowIdsOutOfViewport: (string | number)[];
|
|
340
|
+
grid: SlickGrid;
|
|
341
|
+
}
|
|
342
|
+
) {
|
|
343
|
+
const slot = this._slots.find((x) => x.id === args.rowId);
|
|
344
|
+
if (slot) {
|
|
345
|
+
this.redrawViewSlot(slot);
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
/**
|
|
350
|
+
* notify the onAsyncResponse with the "args.item" (required property)
|
|
351
|
+
* the plugin will then use item to populate the row detail panel with the "postTemplate"
|
|
352
|
+
* @param item
|
|
353
|
+
*/
|
|
354
|
+
protected notifyTemplate(item: any) {
|
|
355
|
+
this.onAsyncResponse.notify({ item }, new SlickEventData(), this);
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* On Processing, we will notify the plugin with the new item detail once backend server call completes
|
|
360
|
+
* @param item
|
|
361
|
+
*/
|
|
362
|
+
protected async onProcessing(item: any) {
|
|
363
|
+
if (item && typeof this._userProcessFn === 'function') {
|
|
364
|
+
let awaitedItemDetail: any;
|
|
365
|
+
const userProcessFn = this._userProcessFn(item);
|
|
366
|
+
|
|
367
|
+
// wait for the "userProcessFn", once resolved we will save it into the "collection"
|
|
368
|
+
const response: any | any[] = await userProcessFn;
|
|
369
|
+
|
|
370
|
+
if (response.hasOwnProperty(this.datasetIdPropName)) {
|
|
371
|
+
awaitedItemDetail = response; // from Promise
|
|
372
|
+
} else if (response instanceof Response && typeof response['json'] === 'function') {
|
|
373
|
+
awaitedItemDetail = await response['json'](); // from Fetch
|
|
374
|
+
} else if (response && response['content']) {
|
|
375
|
+
awaitedItemDetail = response['content']; // from aurelia-http-client
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
if (!awaitedItemDetail || !awaitedItemDetail.hasOwnProperty(this.datasetIdPropName)) {
|
|
379
|
+
throw new Error(
|
|
380
|
+
'[Aurelia-Slickgrid] could not process the Row Detail, please make sure that your "process" callback ' +
|
|
381
|
+
`returns an item object that has an "${this.datasetIdPropName}" property`
|
|
382
|
+
);
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
// notify the plugin with the new item details
|
|
386
|
+
this.notifyTemplate(awaitedItemDetail || {});
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './aureliaRowDetailView.js';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Constructable } from '@aurelia/kernel';
|
|
2
|
+
import type { RowDetailView as UniversalRowDetailView } from '@slickgrid-universal/common';
|
|
3
|
+
|
|
4
|
+
export interface RowDetailView extends UniversalRowDetailView {
|
|
5
|
+
/**
|
|
6
|
+
* Optionally pass your Parent Component reference to your Child Component (row detail component).
|
|
7
|
+
* note:: If anyone finds a better way of passing the parent to the row detail extension, please reach out and/or create a PR
|
|
8
|
+
*/
|
|
9
|
+
parentRef?: any;
|
|
10
|
+
|
|
11
|
+
/** View Model of the preload template which shows after opening row detail & before row detail data shows up */
|
|
12
|
+
preloadViewModel?: Constructable;
|
|
13
|
+
|
|
14
|
+
/** View Model template that will be loaded once the async function finishes */
|
|
15
|
+
viewModel?: Constructable;
|
|
16
|
+
}
|