@mintplayer/ng-spark 22.22.0 → 22.24.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.
Files changed (68) hide show
  1. package/README.md +181 -0
  2. package/fesm2022/mintplayer-ng-spark-attribute-description.mjs +100 -47
  3. package/fesm2022/mintplayer-ng-spark-attribute-description.mjs.map +1 -1
  4. package/fesm2022/mintplayer-ng-spark-client-operations.mjs +308 -329
  5. package/fesm2022/mintplayer-ng-spark-client-operations.mjs.map +1 -1
  6. package/fesm2022/mintplayer-ng-spark-column-filter.mjs +175 -135
  7. package/fesm2022/mintplayer-ng-spark-column-filter.mjs.map +1 -1
  8. package/fesm2022/mintplayer-ng-spark-grid.mjs +2259 -1117
  9. package/fesm2022/mintplayer-ng-spark-grid.mjs.map +1 -1
  10. package/fesm2022/mintplayer-ng-spark-history.mjs +611 -0
  11. package/fesm2022/mintplayer-ng-spark-history.mjs.map +1 -0
  12. package/fesm2022/mintplayer-ng-spark-icon.mjs +64 -27
  13. package/fesm2022/mintplayer-ng-spark-icon.mjs.map +1 -1
  14. package/fesm2022/mintplayer-ng-spark-models.mjs +365 -753
  15. package/fesm2022/mintplayer-ng-spark-models.mjs.map +1 -1
  16. package/fesm2022/mintplayer-ng-spark-moderation.mjs +1212 -0
  17. package/fesm2022/mintplayer-ng-spark-moderation.mjs.map +1 -0
  18. package/fesm2022/mintplayer-ng-spark-panels.mjs +52 -0
  19. package/fesm2022/mintplayer-ng-spark-panels.mjs.map +1 -0
  20. package/fesm2022/mintplayer-ng-spark-pipes.mjs +1122 -765
  21. package/fesm2022/mintplayer-ng-spark-pipes.mjs.map +1 -1
  22. package/fesm2022/mintplayer-ng-spark-po-create.mjs +273 -169
  23. package/fesm2022/mintplayer-ng-spark-po-create.mjs.map +1 -1
  24. package/fesm2022/mintplayer-ng-spark-po-detail.mjs +786 -410
  25. package/fesm2022/mintplayer-ng-spark-po-detail.mjs.map +1 -1
  26. package/fesm2022/mintplayer-ng-spark-po-edit.mjs +292 -284
  27. package/fesm2022/mintplayer-ng-spark-po-edit.mjs.map +1 -1
  28. package/fesm2022/mintplayer-ng-spark-po-form.mjs +2187 -1225
  29. package/fesm2022/mintplayer-ng-spark-po-form.mjs.map +1 -1
  30. package/fesm2022/mintplayer-ng-spark-query-list.mjs +516 -303
  31. package/fesm2022/mintplayer-ng-spark-query-list.mjs.map +1 -1
  32. package/fesm2022/mintplayer-ng-spark-renderers.mjs +17 -55
  33. package/fesm2022/mintplayer-ng-spark-renderers.mjs.map +1 -1
  34. package/fesm2022/mintplayer-ng-spark-retry-action-modal.mjs +216 -177
  35. package/fesm2022/mintplayer-ng-spark-retry-action-modal.mjs.map +1 -1
  36. package/fesm2022/mintplayer-ng-spark-routes.mjs +24 -28
  37. package/fesm2022/mintplayer-ng-spark-routes.mjs.map +1 -1
  38. package/fesm2022/mintplayer-ng-spark-services.mjs +625 -640
  39. package/fesm2022/mintplayer-ng-spark-services.mjs.map +1 -1
  40. package/fesm2022/mintplayer-ng-spark-shell.mjs +1013 -397
  41. package/fesm2022/mintplayer-ng-spark-shell.mjs.map +1 -1
  42. package/fesm2022/mintplayer-ng-spark-soft-delete.mjs +294 -0
  43. package/fesm2022/mintplayer-ng-spark-soft-delete.mjs.map +1 -0
  44. package/fesm2022/mintplayer-ng-spark.mjs +13 -50
  45. package/fesm2022/mintplayer-ng-spark.mjs.map +1 -1
  46. package/package.json +17 -1
  47. package/types/mintplayer-ng-spark-attribute-description.d.ts +25 -18
  48. package/types/mintplayer-ng-spark-client-operations.d.ts +133 -160
  49. package/types/mintplayer-ng-spark-column-filter.d.ts +73 -55
  50. package/types/mintplayer-ng-spark-grid.d.ts +885 -448
  51. package/types/mintplayer-ng-spark-history.d.ts +223 -0
  52. package/types/mintplayer-ng-spark-icon.d.ts +15 -13
  53. package/types/mintplayer-ng-spark-models.d.ts +624 -573
  54. package/types/mintplayer-ng-spark-moderation.d.ts +402 -0
  55. package/types/mintplayer-ng-spark-panels.d.ts +108 -0
  56. package/types/mintplayer-ng-spark-pipes.d.ts +120 -149
  57. package/types/mintplayer-ng-spark-po-create.d.ts +46 -37
  58. package/types/mintplayer-ng-spark-po-detail.d.ts +177 -117
  59. package/types/mintplayer-ng-spark-po-edit.d.ts +64 -65
  60. package/types/mintplayer-ng-spark-po-form.d.ts +507 -371
  61. package/types/mintplayer-ng-spark-query-list.d.ts +118 -82
  62. package/types/mintplayer-ng-spark-renderers.d.ts +79 -85
  63. package/types/mintplayer-ng-spark-retry-action-modal.d.ts +31 -34
  64. package/types/mintplayer-ng-spark-routes.d.ts +7 -11
  65. package/types/mintplayer-ng-spark-services.d.ts +377 -261
  66. package/types/mintplayer-ng-spark-shell.d.ts +209 -128
  67. package/types/mintplayer-ng-spark-soft-delete.d.ts +90 -0
  68. package/types/mintplayer-ng-spark.d.ts +7 -12
@@ -1,304 +1,517 @@
1
- import * as i0 from '@angular/core';
2
- import { inject, DestroyRef, input, output, signal, viewChild, computed, effect, ChangeDetectionStrategy, Component } from '@angular/core';
3
- import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
4
- import * as i1 from '@angular/common';
5
- import { CommonModule, NgTemplateOutlet } from '@angular/common';
6
- import * as i2 from '@angular/forms';
7
- import { FormsModule } from '@angular/forms';
8
- import { ActivatedRoute, Router } from '@angular/router';
9
- import { Color } from '@mintplayer/ng-bootstrap';
10
- import { BsBadgeComponent } from '@mintplayer/ng-bootstrap/badge';
11
- import { BsAlertComponent } from '@mintplayer/ng-bootstrap/alert';
12
- import { BsFormComponent, BsFormControlDirective } from '@mintplayer/ng-bootstrap/form';
13
- import { BsGridComponent, BsGridRowDirective, BsGridColumnDirective } from '@mintplayer/ng-bootstrap/grid';
14
- import { BsInputGroupComponent } from '@mintplayer/ng-bootstrap/input-group';
15
- import { BsPriorityNavComponent, BsPriorityNavItemDirective } from '@mintplayer/ng-bootstrap/priority-nav';
16
- import { BsSpinnerComponent } from '@mintplayer/ng-bootstrap/spinner';
17
- import { SparkService, SparkStreamingService, SparkLanguageService } from '@mintplayer/ng-spark/services';
18
- import { ResolveTranslationPipe, TranslateKeyPipe } from '@mintplayer/ng-spark/pipes';
19
- import { SparkIconComponent } from '@mintplayer/ng-spark/icon';
20
- import { SparkQueryGridComponent } from '@mintplayer/ng-spark/grid';
21
-
22
- /**
23
- * The routed query page: chrome around one {@link SparkQueryGridComponent}.
24
- *
25
- * It owns what is genuinely page-shaped and route-shaped, and nothing else:
26
- *
27
- * - **Route resolution.** It has no `queryId` input; it reads `paramMap`, and it serves two
28
- * routes — `query/:queryId`, and `po/:type`, which resolves an entity type to a query. That
29
- * second one is type-to-query resolution, not query rendering, and is why this component still
30
- * exists rather than the router pointing at the grid.
31
- * - **Streaming.** The websocket lives here so it stays out of every PO detail page's bundle;
32
- * the snapshot is filtered and sorted client-side and handed to the grid as `[data]`.
33
- * - The action bar, the caption, the LIVE badge, the search box and the New button.
34
- *
35
- * The grid itself — columns, cells, paging, the row link, selection, custom-action execution —
36
- * is the shared component. This page previously wrote out `<bs-datatable>` twice, once per
37
- * transport, with a shared row template between them; both are gone.
38
- */
39
- class SparkQueryListComponent {
40
- route = inject(ActivatedRoute);
41
- router = inject(Router);
42
- sparkService = inject(SparkService);
43
- streamingService = inject(SparkStreamingService);
44
- destroyRef = inject(DestroyRef);
45
- lang = inject(SparkLanguageService);
46
- extraActionsTemplate = input(null, /* @ts-ignore */
47
- ...(ngDevMode ? [{ debugName: "extraActionsTemplate" }] : /* istanbul ignore next */ []));
48
- showCustomActions = input(true, /* @ts-ignore */
49
- ...(ngDevMode ? [{ debugName: "showCustomActions" }] : /* istanbul ignore next */ []));
50
- /**
51
- * Forwarded to the grid, so a query PAGE can replace its row links — the same reason the card
52
- * forwards it. Without this the escape hatch existed only for a directly-embedded grid.
53
- */
54
- rowRoute = input(null, /* @ts-ignore */
55
- ...(ngDevMode ? [{ debugName: "rowRoute" }] : /* istanbul ignore next */ []));
56
- rowClicked = output();
57
- createClicked = output();
58
- customActionExecuted = output();
59
- colors = Color;
60
- /** The query the grid should render, resolved from the route. Null until it is known. */
61
- queryId = signal(null, /* @ts-ignore */
62
- ...(ngDevMode ? [{ debugName: "queryId" }] : /* istanbul ignore next */ []));
63
- errorMessage = signal(null, /* @ts-ignore */
64
- ...(ngDevMode ? [{ debugName: "errorMessage" }] : /* istanbul ignore next */ []));
65
- searchTerm = signal('', /* @ts-ignore */
66
- ...(ngDevMode ? [{ debugName: "searchTerm" }] : /* istanbul ignore next */ []));
67
- grid = viewChild(SparkQueryGridComponent, /* @ts-ignore */
68
- ...(ngDevMode ? [{ debugName: "grid" }] : /* istanbul ignore next */ []));
69
- /**
70
- * Grid state, surfaced for this page's chrome.
71
- *
72
- * Optional `viewChild`, read defensively: the action bar and caption render above the grid, so
73
- * on the first change-detection pass the query has not resolved yet.
74
- */
75
- query = computed(() => this.grid()?.query() ?? null, /* @ts-ignore */
76
- ...(ngDevMode ? [{ debugName: "query" }] : /* istanbul ignore next */ []));
77
- entityType = computed(() => this.grid()?.entityType() ?? null, /* @ts-ignore */
78
- ...(ngDevMode ? [{ debugName: "entityType" }] : /* istanbul ignore next */ []));
79
- customActions = computed(() => this.grid()?.customActions() ?? [], /* @ts-ignore */
80
- ...(ngDevMode ? [{ debugName: "customActions" }] : /* istanbul ignore next */ []));
81
- canCreate = computed(() => this.grid()?.canCreate() ?? false, /* @ts-ignore */
82
- ...(ngDevMode ? [{ debugName: "canCreate" }] : /* istanbul ignore next */ []));
83
- resultCount = computed(() => this.grid()?.resultCount() ?? null, /* @ts-ignore */
84
- ...(ngDevMode ? [{ debugName: "resultCount" }] : /* istanbul ignore next */ []));
85
- isVirtualScrolling = computed(() => this.grid()?.isVirtualScrolling() ?? false, /* @ts-ignore */
86
- ...(ngDevMode ? [{ debugName: "isVirtualScrolling" }] : /* istanbul ignore next */ []));
87
- gridError = computed(() => this.grid()?.errorMessage() ?? null, /* @ts-ignore */
88
- ...(ngDevMode ? [{ debugName: "gridError" }] : /* istanbul ignore next */ []));
89
- /** Whether an action's selection rule is satisfied. Delegated: the grid holds the selection. */
90
- /** @see SparkPoDetailComponent.customActionClass — same allow-list, same default. */
91
- customActionClass(action) {
92
- const variant = action.variant?.toLowerCase();
93
- switch (variant) {
94
- case 'danger':
95
- case 'warning':
96
- case 'primary':
97
- case 'secondary':
98
- case 'success':
99
- return `btn btn-${variant}`;
100
- default:
101
- return 'btn btn-outline-primary';
102
- }
103
- }
104
- isActionEnabled(action) {
105
- return this.grid()?.isActionEnabled(action) ?? false;
106
- }
107
- // --- streaming ---------------------------------------------------------------
108
- isStreaming = signal(false, /* @ts-ignore */
109
- ...(ngDevMode ? [{ debugName: "isStreaming" }] : /* istanbul ignore next */ []));
110
- streamingSub = null;
111
- /** Columns as sent with the stream's snapshot; empty until it arrives. */
112
- streamColumns = signal([], /* @ts-ignore */
113
- ...(ngDevMode ? [{ debugName: "streamColumns" }] : /* istanbul ignore next */ []));
114
- allItems = signal([], /* @ts-ignore */
115
- ...(ngDevMode ? [{ debugName: "allItems" }] : /* istanbul ignore next */ []));
116
- streamItems = signal([], /* @ts-ignore */
117
- ...(ngDevMode ? [{ debugName: "streamItems" }] : /* istanbul ignore next */ []));
118
- /**
119
- * Rows handed to the grid, or `null` to let it fetch for itself.
120
- *
121
- * Null for a normal query — an empty array would read as "here are no rows" and suppress the
122
- * fetch entirely.
123
- */
124
- gridData = computed(() => this.query()?.isStreamingQuery ? this.streamItems() : null, /* @ts-ignore */
125
- ...(ngDevMode ? [{ debugName: "gridData" }] : /* istanbul ignore next */ []));
126
- constructor() {
127
- this.route.paramMap.pipe(takeUntilDestroyed()).subscribe(params => {
128
- // The handler is async and this is a subscribe, so a rejection lands nowhere: the metadata
129
- // load would reject, the query would stay null, and the template would render a spinner
130
- // FOREVER — while this component has had an errorMessage surface all along that only the
131
- // fetch path ever reached.
132
- this.onParamsChange(params).catch((e) => this.reportLoadFailure(e));
133
- });
134
- this.destroyRef.onDestroy(() => this.disconnectStreaming());
135
- // Connect the socket once the grid has resolved a streaming query, and disconnect whenever it
136
- // resolves anything else. The grid knows not to fetch for a streaming query, so there is no
137
- // window in which both transports are live.
138
- effect(() => {
139
- const q = this.query();
140
- if (q?.isStreamingQuery) {
141
- this.connectStreaming(q.id);
142
- }
143
- else {
144
- this.disconnectStreaming();
145
- }
146
- });
147
- // Client-side filter and sort for the streaming snapshot. The server never sees these: there
148
- // is no request to attach them to.
149
- effect(() => {
150
- this.searchTerm();
151
- this.grid()?.settings();
152
- this.allItems();
153
- if (this.isStreaming())
154
- this.applyFilter();
155
- });
156
- }
157
- async onParamsChange(params) {
158
- this.errorMessage.set(null);
159
- this.queryId.set(null);
160
- this.allItems.set([]);
161
- this.streamItems.set([]);
162
- this.streamColumns.set([]);
163
- this.disconnectStreaming();
164
- const queryId = params.get('queryId');
165
- const typeParam = params.get('type');
166
- if (queryId) {
167
- this.queryId.set(queryId);
168
- return;
169
- }
170
- if (!typeParam)
171
- return;
172
- // `po/:type` — the route names an entity type, so find the query that lists it. The grid takes
173
- // a query, and this translation is the only reason it cannot take the route directly.
174
- const [entityTypes, queries] = await Promise.all([
175
- this.sparkService.getEntityTypes(),
176
- this.sparkService.getQueries(),
177
- ]);
178
- const entityType = entityTypes.find(t => t.id === typeParam || t.alias === typeParam);
179
- if (!entityType) {
180
- this.reportLoadFailure({ status: 404 });
181
- return;
182
- }
183
- const singularName = entityType.name;
184
- const match = queries.find(q => {
185
- if (q.entityType === singularName)
186
- return true;
187
- const sourceName = q.source.includes('.') ? q.source.substring(q.source.indexOf('.') + 1) : q.source;
188
- return sourceName === singularName || sourceName === singularName + 's';
189
- });
190
- if (match)
191
- this.queryId.set(match.alias || match.id);
192
- else
193
- this.reportLoadFailure({ status: 404 });
194
- }
195
- /**
196
- * A load failure has to render, not just be swallowed: a denied query answers 404 (audit M-3, so
197
- * existence is not leaked), which is indistinguishable from a missing one — hence a deliberately
198
- * generic message rather than a guess at which it was.
199
- */
200
- reportLoadFailure(err) {
201
- this.errorMessage.set(err?.status === 404
202
- ? (this.lang.t('spark.query.unavailable') || 'This list is not available.')
203
- : (err?.error?.error || err?.message || 'An unexpected error occurred'));
204
- }
205
- async onCustomAction(action) {
206
- await this.grid()?.onCustomAction(action);
207
- }
208
- onCreate() {
209
- this.createClicked.emit();
210
- const et = this.entityType();
211
- if (et)
212
- this.router.navigate(['/po', et.alias || et.id, 'new']);
213
- }
214
- clearSearch() {
215
- this.searchTerm.set('');
216
- }
217
- connectStreaming(queryId) {
218
- if (this.streamingSub)
219
- return;
220
- this.isStreaming.set(true);
221
- this.streamingSub = this.streamingService.connectToStreamingQuery(queryId).subscribe({
222
- next: (message) => this.handleStreamingMessage(message),
223
- error: (err) => {
224
- this.errorMessage.set(err?.message || 'Streaming connection failed');
225
- this.isStreaming.set(false);
226
- },
227
- complete: () => this.isStreaming.set(false),
228
- });
229
- }
230
- disconnectStreaming() {
231
- if (this.streamingSub) {
232
- this.streamingSub.unsubscribe();
233
- this.streamingSub = null;
234
- }
235
- this.isStreaming.set(false);
236
- }
237
- handleStreamingMessage(message) {
238
- switch (message.type) {
239
- case 'snapshot':
240
- this.errorMessage.set(null);
241
- // Columns come with the snapshot and never change for the life of the stream, so they are
242
- // stored once and handed to the grid alongside the rows — a projection cannot describe
243
- // itself, and the grid has no entity-type metadata to fall back on any more.
244
- this.streamColumns.set(message.columns);
245
- this.allItems.set(message.data);
246
- break;
247
- case 'patch':
248
- if (message.updated.length > 0) {
249
- this.allItems.update(items => items.map(item => {
250
- const patch = message.updated.find(u => u.id === item.id);
251
- if (!patch)
252
- return item;
253
- return {
254
- ...item,
255
- values: item.values.map(v => v.key in patch.values ? { ...v, value: patch.values[v.key] } : v),
256
- };
257
- }));
258
- }
259
- break;
260
- case 'error':
261
- this.errorMessage.set(message.message);
262
- break;
263
- }
264
- }
265
- applyFilter() {
266
- let items = this.allItems();
267
- const term = this.searchTerm().toLowerCase();
268
- if (term) {
269
- items = items.filter(item => item.values.some(v => String(v.value ?? '').toLowerCase().includes(term)));
270
- }
271
- // The datatable in `[data]` mode also sorts on header clicks, but the sort must survive a
272
- // patch: re-deriving from `allItems` without re-applying it would silently reorder the grid
273
- // under the user on every update.
274
- const sortCols = this.grid()?.settings().sortColumns ?? [];
275
- if (sortCols.length > 0) {
276
- items = [...items].sort((a, b) => {
277
- for (const col of sortCols) {
278
- const aVal = a.values.find(v => v.key === col.property)?.value ?? '';
279
- const bVal = b.values.find(v => v.key === col.property)?.value ?? '';
280
- const cmp = String(aVal).localeCompare(String(bVal));
281
- if (cmp !== 0)
282
- return col.direction === 'descending' ? -cmp : cmp;
283
- }
284
- return 0;
285
- });
286
- }
287
- this.streamItems.set(items);
288
- }
289
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: SparkQueryListComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
290
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.3", type: SparkQueryListComponent, isStandalone: true, selector: "spark-query-list", inputs: { extraActionsTemplate: { classPropertyName: "extraActionsTemplate", publicName: "extraActionsTemplate", isSignal: true, isRequired: false, transformFunction: null }, showCustomActions: { classPropertyName: "showCustomActions", publicName: "showCustomActions", isSignal: true, isRequired: false, transformFunction: null }, rowRoute: { classPropertyName: "rowRoute", publicName: "rowRoute", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { rowClicked: "rowClicked", createClicked: "createClicked", customActionExecuted: "customActionExecuted" }, host: { properties: { "class.virtual-scrolling": "isVirtualScrolling()" } }, viewQueries: [{ propertyName: "grid", first: true, predicate: SparkQueryGridComponent, descendants: true, isSignal: true }], ngImport: i0, template: "<div class=\"d-flex flex-column h-100\">\n <div class=\"spark-actionbar py-2 flex-shrink-0\" [class.spark-actionbar-wide]=\"isVirtualScrolling()\">\n <bs-priority-nav [moreLabel]=\"lang.t('common.more')\" [collapseAt]=\"'sm'\">\n @if (canCreate()) {\n <button *bsPriorityNavItem=\"1\" class=\"btn btn-primary\" (click)=\"onCreate()\">\n <spark-icon name=\"plus-lg\" /> {{ 'common.new' | t }}\n </button>\n }\n @if (showCustomActions()) {\n @for (action of customActions(); track action.name) {\n <!-- Disabled, not hidden: hiding makes the affordance undiscoverable and reflows the\n priority nav on every selection change. The server enforces the same rule. -->\n <button *bsPriorityNavItem=\"10 + action.offset\" [class]=\"customActionClass(action)\"\n [disabled]=\"!isActionEnabled(action)\" (click)=\"onCustomAction(action)\">\n {{ action.displayName | resolveTranslation }}\n </button>\n }\n }\n @if (extraActionsTemplate(); as extraActionsTpl) {\n <ng-container *bsPriorityNavItem=\"50\">\n <ng-container *ngTemplateOutlet=\"extraActionsTpl\"></ng-container>\n </ng-container>\n }\n </bs-priority-nav>\n </div>\n\n <h2 class=\"mb-4 flex-shrink-0\" [class.px-4]=\"isVirtualScrolling()\">\n {{ (query()?.description | resolveTranslation) || query()?.name || ('common.loading' | t) }}\n @if (isStreaming()) {\n <bs-badge [type]=\"colors.success\" class=\"ms-2 align-middle spark-live-badge\">LIVE</bs-badge>\n }\n </h2>\n\n @if (errorMessage(); as err) {\n <!-- The route could not be resolved to a query at all. A failure INSIDE the grid renders in\n the grid; this is the one it cannot report, because it never got a query id. -->\n <bs-alert [type]=\"colors.danger\" class=\"m-3 d-block\">\n {{ err }}\n </bs-alert>\n } @else if (queryId(); as qId) {\n <div class=\"flex-shrink-0\" [class.px-4]=\"isVirtualScrolling()\">\n <bs-form>\n <bs-grid>\n <div bsRow class=\"mb-3\">\n <div [md]=\"12\">\n <bs-input-group>\n <span class=\"addon\">\n <spark-icon name=\"search\" />\n </span>\n <input\n type=\"text\"\n [placeholder]=\"'common.search' | t\"\n [ngModel]=\"searchTerm()\"\n (ngModelChange)=\"searchTerm.set($event)\">\n @if (searchTerm()) {\n <button\n type=\"button\"\n class=\"btn btn-outline-secondary\"\n (click)=\"clearSearch()\">\n <spark-icon name=\"x-lg\" />\n </button>\n }\n </bs-input-group>\n </div>\n <!-- Its own full-width row rather than a column beside the box: the count is\n occasional, and reserving 8 columns for it shrank the search permanently. The\n @if moved out of the column so nothing reserves vertical space when absent. -->\n @if (searchTerm() && resultCount() !== null) {\n <div [md]=\"12\" class=\"text-end mt-1\">\n <span class=\"text-muted\">\n {{ resultCount() }} {{ resultCount() === 1 ? ('common.resultFound' | t) : ('common.resultsFound' | t) }}\n </span>\n </div>\n }\n </div>\n </bs-grid>\n </bs-form>\n </div>\n\n <!--\n One grid, both transports. `data` is null for a normal query, so the grid fetches and pages\n server-side; for a streaming query this page owns the socket and hands the filtered snapshot\n in. This used to be two near-identical <bs-datatable> blocks with a shared row template.\n -->\n <spark-query-grid class=\"flex-grow-1\"\n [queryId]=\"qId\"\n [data]=\"gridData()\"\n [columns]=\"gridData() ? streamColumns() : null\"\n [search]=\"searchTerm()\"\n [rowRoute]=\"rowRoute()\"\n (rowClicked)=\"rowClicked.emit($event)\"\n (customActionExecuted)=\"customActionExecuted.emit($event)\" />\n } @else {\n <div class=\"text-center p-5\">\n <bs-spinner />\n </div>\n }\n</div>\n", styles: [".spark-actionbar{--_bleed-block: var(--spark-content-inset-block, 0px);--_bleed-inline: var(--spark-content-inset-inline, 0px);--_gutter: var(--spark-actionbar-gutter, 1rem);position:sticky;top:calc(-1 * var(--_bleed-block));z-index:400;background-color:var(--bs-tertiary-bg);border-bottom:1px solid var(--bs-border-color);margin-bottom:1rem;margin-inline:calc(-1 * var(--_bleed-inline));padding-inline:calc(var(--_bleed-inline) + var(--_gutter))}.spark-actionbar .btn{border-radius:0}.spark-actionbar-wide{--spark-actionbar-gutter: 1.5rem}:host{display:flex;flex-direction:column;flex:1;min-height:0}:host.virtual-scrolling{margin:0 calc(-1 * var(--spark-main-padding, 1.5rem)) calc(-1 * var(--spark-main-padding, 1.5rem));--spark-content-inset-inline: 0px}:host.virtual-scrolling spark-query-grid{display:flex;flex-direction:column;min-height:0}:host.virtual-scrolling ::ng-deep bs-datatable{display:flex;flex-direction:column;min-height:0;--mp-datatable-virtual-max-height: 100%}:host.virtual-scrolling ::ng-deep bs-datatable mp-datatable{flex:1 1 auto;min-height:0}tr:hover{background-color:#0000000d}td input[type=checkbox]:disabled{opacity:1;pointer-events:none}.spark-live-badge{font-size:.6em}\n"], dependencies: [{ kind: "component", type: BsBadgeComponent, selector: "bs-badge", inputs: ["type", "unit", "decorative"] }, { kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i2.DefaultValueAccessor, selector: "input:not([type=checkbox]):not([ngNoCva])[formControlName],textarea:not([ngNoCva])[formControlName],input:not([type=checkbox]):not([ngNoCva])[formControl],textarea:not([ngNoCva])[formControl],input:not([type=checkbox]):not([ngNoCva])[ngModel],textarea:not([ngNoCva])[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "component", type: BsAlertComponent, selector: "bs-alert", inputs: ["type", "announce", "isVisible"], outputs: ["isVisibleChange", "afterOpenedOrClosed"] }, { kind: "component", type: BsFormComponent, selector: "bs-form", inputs: ["action", "method"], outputs: ["submitted"] }, { kind: "directive", type: BsFormControlDirective, selector: "bs-form input:not(.no-form-control), bs-form textarea:not(.no-form-control)" }, { kind: "component", type: BsGridComponent, selector: "bs-grid", inputs: ["stopFullWidthAt"] }, { kind: "directive", type: BsGridRowDirective, selector: "[bsRow]" }, { kind: "directive", type: BsGridColumnDirective, selector: "[xxs],[xs],[sm],[md],[lg],[xl],[xxl]", inputs: ["xxs", "xs", "sm", "md", "lg", "xl", "xxl"] }, { kind: "component", type: BsInputGroupComponent, selector: "bs-input-group", inputs: ["size"] }, { kind: "component", type: BsPriorityNavComponent, selector: "bs-priority-nav", inputs: ["moreLabel", "moreLabelTemplate", "collapseAt", "overflowFrom", "hideEmptyMore", "ariaLabel"], outputs: ["overflowChange"] }, { kind: "directive", type: BsPriorityNavItemDirective, selector: "[bsPriorityNavItem]", inputs: ["bsPriorityNavItem", "bsPriorityNavItemHideBelow"] }, { kind: "component", type: BsSpinnerComponent, selector: "bs-spinner", inputs: ["type", "color"] }, { kind: "component", type: SparkIconComponent, selector: "spark-icon", inputs: ["name"] }, { kind: "component", type: SparkQueryGridComponent, selector: "spark-query-grid", inputs: ["queryId", "parentId", "parentType", "data", "search", "columns", "reloadToken", "settings", "selection", "rowRoute"], outputs: ["settingsChange", "selectionChange", "error", "rowClicked", "customActionExecuted"] }, { kind: "pipe", type: ResolveTranslationPipe, name: "resolveTranslation" }, { kind: "pipe", type: TranslateKeyPipe, name: "t" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
291
- }
292
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: SparkQueryListComponent, decorators: [{
293
- type: Component,
294
- args: [{ selector: 'spark-query-list', imports: [BsBadgeComponent, CommonModule, NgTemplateOutlet, FormsModule, BsAlertComponent, BsFormComponent, BsFormControlDirective, BsGridComponent, BsGridRowDirective, BsGridColumnDirective, BsInputGroupComponent, BsPriorityNavComponent, BsPriorityNavItemDirective, BsSpinnerComponent, SparkIconComponent, SparkQueryGridComponent, ResolveTranslationPipe, TranslateKeyPipe], changeDetection: ChangeDetectionStrategy.OnPush, host: {
295
- '[class.virtual-scrolling]': 'isVirtualScrolling()'
296
- }, template: "<div class=\"d-flex flex-column h-100\">\n <div class=\"spark-actionbar py-2 flex-shrink-0\" [class.spark-actionbar-wide]=\"isVirtualScrolling()\">\n <bs-priority-nav [moreLabel]=\"lang.t('common.more')\" [collapseAt]=\"'sm'\">\n @if (canCreate()) {\n <button *bsPriorityNavItem=\"1\" class=\"btn btn-primary\" (click)=\"onCreate()\">\n <spark-icon name=\"plus-lg\" /> {{ 'common.new' | t }}\n </button>\n }\n @if (showCustomActions()) {\n @for (action of customActions(); track action.name) {\n <!-- Disabled, not hidden: hiding makes the affordance undiscoverable and reflows the\n priority nav on every selection change. The server enforces the same rule. -->\n <button *bsPriorityNavItem=\"10 + action.offset\" [class]=\"customActionClass(action)\"\n [disabled]=\"!isActionEnabled(action)\" (click)=\"onCustomAction(action)\">\n {{ action.displayName | resolveTranslation }}\n </button>\n }\n }\n @if (extraActionsTemplate(); as extraActionsTpl) {\n <ng-container *bsPriorityNavItem=\"50\">\n <ng-container *ngTemplateOutlet=\"extraActionsTpl\"></ng-container>\n </ng-container>\n }\n </bs-priority-nav>\n </div>\n\n <h2 class=\"mb-4 flex-shrink-0\" [class.px-4]=\"isVirtualScrolling()\">\n {{ (query()?.description | resolveTranslation) || query()?.name || ('common.loading' | t) }}\n @if (isStreaming()) {\n <bs-badge [type]=\"colors.success\" class=\"ms-2 align-middle spark-live-badge\">LIVE</bs-badge>\n }\n </h2>\n\n @if (errorMessage(); as err) {\n <!-- The route could not be resolved to a query at all. A failure INSIDE the grid renders in\n the grid; this is the one it cannot report, because it never got a query id. -->\n <bs-alert [type]=\"colors.danger\" class=\"m-3 d-block\">\n {{ err }}\n </bs-alert>\n } @else if (queryId(); as qId) {\n <div class=\"flex-shrink-0\" [class.px-4]=\"isVirtualScrolling()\">\n <bs-form>\n <bs-grid>\n <div bsRow class=\"mb-3\">\n <div [md]=\"12\">\n <bs-input-group>\n <span class=\"addon\">\n <spark-icon name=\"search\" />\n </span>\n <input\n type=\"text\"\n [placeholder]=\"'common.search' | t\"\n [ngModel]=\"searchTerm()\"\n (ngModelChange)=\"searchTerm.set($event)\">\n @if (searchTerm()) {\n <button\n type=\"button\"\n class=\"btn btn-outline-secondary\"\n (click)=\"clearSearch()\">\n <spark-icon name=\"x-lg\" />\n </button>\n }\n </bs-input-group>\n </div>\n <!-- Its own full-width row rather than a column beside the box: the count is\n occasional, and reserving 8 columns for it shrank the search permanently. The\n @if moved out of the column so nothing reserves vertical space when absent. -->\n @if (searchTerm() && resultCount() !== null) {\n <div [md]=\"12\" class=\"text-end mt-1\">\n <span class=\"text-muted\">\n {{ resultCount() }} {{ resultCount() === 1 ? ('common.resultFound' | t) : ('common.resultsFound' | t) }}\n </span>\n </div>\n }\n </div>\n </bs-grid>\n </bs-form>\n </div>\n\n <!--\n One grid, both transports. `data` is null for a normal query, so the grid fetches and pages\n server-side; for a streaming query this page owns the socket and hands the filtered snapshot\n in. This used to be two near-identical <bs-datatable> blocks with a shared row template.\n -->\n <spark-query-grid class=\"flex-grow-1\"\n [queryId]=\"qId\"\n [data]=\"gridData()\"\n [columns]=\"gridData() ? streamColumns() : null\"\n [search]=\"searchTerm()\"\n [rowRoute]=\"rowRoute()\"\n (rowClicked)=\"rowClicked.emit($event)\"\n (customActionExecuted)=\"customActionExecuted.emit($event)\" />\n } @else {\n <div class=\"text-center p-5\">\n <bs-spinner />\n </div>\n }\n</div>\n", styles: [".spark-actionbar{--_bleed-block: var(--spark-content-inset-block, 0px);--_bleed-inline: var(--spark-content-inset-inline, 0px);--_gutter: var(--spark-actionbar-gutter, 1rem);position:sticky;top:calc(-1 * var(--_bleed-block));z-index:400;background-color:var(--bs-tertiary-bg);border-bottom:1px solid var(--bs-border-color);margin-bottom:1rem;margin-inline:calc(-1 * var(--_bleed-inline));padding-inline:calc(var(--_bleed-inline) + var(--_gutter))}.spark-actionbar .btn{border-radius:0}.spark-actionbar-wide{--spark-actionbar-gutter: 1.5rem}:host{display:flex;flex-direction:column;flex:1;min-height:0}:host.virtual-scrolling{margin:0 calc(-1 * var(--spark-main-padding, 1.5rem)) calc(-1 * var(--spark-main-padding, 1.5rem));--spark-content-inset-inline: 0px}:host.virtual-scrolling spark-query-grid{display:flex;flex-direction:column;min-height:0}:host.virtual-scrolling ::ng-deep bs-datatable{display:flex;flex-direction:column;min-height:0;--mp-datatable-virtual-max-height: 100%}:host.virtual-scrolling ::ng-deep bs-datatable mp-datatable{flex:1 1 auto;min-height:0}tr:hover{background-color:#0000000d}td input[type=checkbox]:disabled{opacity:1;pointer-events:none}.spark-live-badge{font-size:.6em}\n"] }]
297
- }], ctorParameters: () => [], propDecorators: { extraActionsTemplate: [{ type: i0.Input, args: [{ isSignal: true, alias: "extraActionsTemplate", required: false }] }], showCustomActions: [{ type: i0.Input, args: [{ isSignal: true, alias: "showCustomActions", required: false }] }], rowRoute: [{ type: i0.Input, args: [{ isSignal: true, alias: "rowRoute", required: false }] }], rowClicked: [{ type: i0.Output, args: ["rowClicked"] }], createClicked: [{ type: i0.Output, args: ["createClicked"] }], customActionExecuted: [{ type: i0.Output, args: ["customActionExecuted"] }], grid: [{ type: i0.ViewChild, args: [i0.forwardRef(() => SparkQueryGridComponent), { isSignal: true }] }] } });
298
-
299
- /**
300
- * Generated bundle index. Do not edit.
301
- */
302
-
1
+ import * as i0 from "@angular/core";
2
+ import { ChangeDetectionStrategy, Component, DestroyRef, computed, effect, inject, input, output, signal, viewChild } from "@angular/core";
3
+ import { takeUntilDestroyed } from "@angular/core/rxjs-interop";
4
+ import * as i1 from "@angular/common";
5
+ import { CommonModule, NgComponentOutlet, NgTemplateOutlet } from "@angular/common";
6
+ import { ActivatedRoute, Router } from "@angular/router";
7
+ import { Color } from "@mintplayer/ng-bootstrap";
8
+ import { BsBadgeComponent } from "@mintplayer/ng-bootstrap/badge";
9
+ import { BsAlertComponent } from "@mintplayer/ng-bootstrap/alert";
10
+ import { BsGridColumnDirective, BsGridComponent, BsGridRowDirective } from "@mintplayer/ng-bootstrap/grid";
11
+ import { BsPriorityNavComponent, BsPriorityNavItemDirective } from "@mintplayer/ng-bootstrap/priority-nav";
12
+ import { BsSpinnerComponent } from "@mintplayer/ng-bootstrap/spinner";
13
+ import { SparkLanguageService, SparkService, SparkStreamingService } from "@mintplayer/ng-spark/services";
14
+ import { ResolveTranslationPipe, TranslateKeyPipe } from "@mintplayer/ng-spark/pipes";
15
+ import { SparkIconComponent } from "@mintplayer/ng-spark/icon";
16
+ import { SparkQueryGridComponent, SparkSearchBoxComponent, sparkActionClass } from "@mintplayer/ng-spark/grid";
17
+ import { SPARK_QUERY_LIST_ACTIONS, orderSparkExtensions, parseSparkDeletedParam } from "@mintplayer/ng-spark/panels";
18
+ var SparkQueryListComponent = class SparkQueryListComponent {
19
+ route = inject(ActivatedRoute);
20
+ router = inject(Router);
21
+ sparkService = inject(SparkService);
22
+ streamingService = inject(SparkStreamingService);
23
+ destroyRef = inject(DestroyRef);
24
+ lang = inject(SparkLanguageService);
25
+ extraActionsTemplate = input(null, ...ngDevMode ? [{ debugName: "extraActionsTemplate" }] : /* istanbul ignore next */ []);
26
+ showCustomActions = input(true, ...ngDevMode ? [{ debugName: "showCustomActions" }] : /* istanbul ignore next */ []);
27
+ rowRoute = input(null, ...ngDevMode ? [{ debugName: "rowRoute" }] : /* istanbul ignore next */ []);
28
+ rowClicked = output();
29
+ createClicked = output();
30
+ customActionExecuted = output();
31
+ colors = Color;
32
+ queryId = signal(null, ...ngDevMode ? [{ debugName: "queryId" }] : /* istanbul ignore next */ []);
33
+ errorMessage = signal(null, ...ngDevMode ? [{ debugName: "errorMessage" }] : /* istanbul ignore next */ []);
34
+ searchTerm = signal("", ...ngDevMode ? [{ debugName: "searchTerm" }] : /* istanbul ignore next */ []);
35
+ grid = viewChild(SparkQueryGridComponent, ...ngDevMode ? [{ debugName: "grid" }] : /* istanbul ignore next */ []);
36
+ query = computed(() => this.grid()?.query() ?? null, ...ngDevMode ? [{ debugName: "query" }] : /* istanbul ignore next */ []);
37
+ entityType = computed(() => this.grid()?.entityType() ?? null, ...ngDevMode ? [{ debugName: "entityType" }] : /* istanbul ignore next */ []);
38
+ customActions = computed(() => this.grid()?.customActions() ?? [], ...ngDevMode ? [{ debugName: "customActions" }] : /* istanbul ignore next */ []);
39
+ canCreate = computed(() => this.grid()?.offersCreate() ?? false, ...ngDevMode ? [{ debugName: "canCreate" }] : /* istanbul ignore next */ []);
40
+ resultCount = computed(() => this.grid()?.resultCount() ?? null, ...ngDevMode ? [{ debugName: "resultCount" }] : /* istanbul ignore next */ []);
41
+ isVirtualScrolling = computed(() => this.grid()?.isVirtualScrolling() ?? false, ...ngDevMode ? [{ debugName: "isVirtualScrolling" }] : /* istanbul ignore next */ []);
42
+ gridError = computed(() => this.grid()?.errorMessage() ?? null, ...ngDevMode ? [{ debugName: "gridError" }] : /* istanbul ignore next */ []);
43
+ permissions = computed(() => this.grid()?.permissions() ?? null, ...ngDevMode ? [{ debugName: "permissions" }] : /* istanbul ignore next */ []);
44
+ listActions = orderSparkExtensions(inject(SPARK_QUERY_LIST_ACTIONS, { optional: true }), (a) => a.priority ?? 60);
45
+ deletedMode = signal("exclude", ...ngDevMode ? [{ debugName: "deletedMode" }] : /* istanbul ignore next */ []);
46
+ reloadToken = signal(0, ...ngDevMode ? [{ debugName: "reloadToken" }] : /* istanbul ignore next */ []);
47
+ listContext = computed(() => {
48
+ const query = this.query();
49
+ if (!query) return null;
50
+ return {
51
+ query,
52
+ entityType: this.entityType(),
53
+ permissions: this.permissions(),
54
+ deleted: this.deletedMode(),
55
+ setDeleted: (mode) => this.setDeleted(mode),
56
+ reload: () => this.reloadToken.update((n) => n + 1)
57
+ };
58
+ }, ...ngDevMode ? [{ debugName: "listContext" }] : /* istanbul ignore next */ []);
59
+ gridReloadToken = this.reloadToken.asReadonly();
60
+ setDeleted(mode) {
61
+ this.router.navigate([], {
62
+ relativeTo: this.route,
63
+ queryParams: { deleted: mode === "exclude" ? null : mode },
64
+ queryParamsHandling: "merge",
65
+ replaceUrl: true
66
+ });
67
+ }
68
+ customActionClass(action) {
69
+ const variant = action.variant?.toLowerCase();
70
+ switch (variant) {
71
+ case "danger":
72
+ case "warning":
73
+ case "primary":
74
+ case "secondary":
75
+ case "success": return `btn btn-${variant}`;
76
+ default: return "btn btn-outline-primary";
77
+ }
78
+ }
79
+ toolbarActions = computed(() => this.grid()?.toolbarActions() ?? [], ...ngDevMode ? [{ debugName: "toolbarActions" }] : /* istanbul ignore next */ []);
80
+ toolbarActionClass(action) {
81
+ return action.kind === "new" ? "btn btn-primary" : sparkActionClass(action.definition);
82
+ }
83
+ isToolbarActionEnabled(action) {
84
+ return this.grid()?.isToolbarActionEnabled(action) ?? false;
85
+ }
86
+ runToolbarAction(action) {
87
+ if (action.kind === "new") {
88
+ this.onCreate();
89
+ return;
90
+ }
91
+ this.grid()?.runToolbarAction(action);
92
+ }
93
+ isActionEnabled(action) {
94
+ return this.grid()?.isActionEnabled(action) ?? false;
95
+ }
96
+ isStreaming = signal(false, ...ngDevMode ? [{ debugName: "isStreaming" }] : /* istanbul ignore next */ []);
97
+ streamingSub = null;
98
+ streamColumns = signal([], ...ngDevMode ? [{ debugName: "streamColumns" }] : /* istanbul ignore next */ []);
99
+ allItems = signal([], ...ngDevMode ? [{ debugName: "allItems" }] : /* istanbul ignore next */ []);
100
+ streamItems = signal([], ...ngDevMode ? [{ debugName: "streamItems" }] : /* istanbul ignore next */ []);
101
+ gridData = computed(() => this.query()?.isStreamingQuery ? this.streamItems() : null, ...ngDevMode ? [{ debugName: "gridData" }] : /* istanbul ignore next */ []);
102
+ constructor() {
103
+ this.route.paramMap.pipe(takeUntilDestroyed()).subscribe((params) => {
104
+ this.onParamsChange(params).catch((e) => this.reportLoadFailure(e));
105
+ });
106
+ this.route.queryParamMap.pipe(takeUntilDestroyed()).subscribe((query) => this.deletedMode.set(parseSparkDeletedParam(query.get("deleted")) ?? "exclude"));
107
+ this.destroyRef.onDestroy(() => this.disconnectStreaming());
108
+ effect(() => {
109
+ const q = this.query();
110
+ if (q?.isStreamingQuery) this.connectStreaming(q.id);
111
+ else this.disconnectStreaming();
112
+ });
113
+ effect(() => {
114
+ this.searchTerm();
115
+ this.grid()?.settings();
116
+ this.allItems();
117
+ if (this.isStreaming()) this.applyFilter();
118
+ });
119
+ }
120
+ async onParamsChange(params) {
121
+ this.errorMessage.set(null);
122
+ this.queryId.set(null);
123
+ this.allItems.set([]);
124
+ this.streamItems.set([]);
125
+ this.streamColumns.set([]);
126
+ this.disconnectStreaming();
127
+ const queryId = params.get("queryId");
128
+ const typeParam = params.get("type");
129
+ if (queryId) {
130
+ this.queryId.set(queryId);
131
+ return;
132
+ }
133
+ if (!typeParam) return;
134
+ const [entityTypes, queries] = await Promise.all([this.sparkService.getEntityTypes(), this.sparkService.getQueries()]);
135
+ const entityType = entityTypes.find((t) => t.id === typeParam || t.alias === typeParam);
136
+ if (!entityType) {
137
+ this.reportLoadFailure({ status: 404 });
138
+ return;
139
+ }
140
+ const singularName = entityType.name;
141
+ const match = queries.find((q) => {
142
+ if (q.entityType === singularName) return true;
143
+ const sourceName = q.source.includes(".") ? q.source.substring(q.source.indexOf(".") + 1) : q.source;
144
+ return sourceName === singularName || sourceName === singularName + "s";
145
+ });
146
+ if (match) this.queryId.set(match.alias || match.id);
147
+ else this.reportLoadFailure({ status: 404 });
148
+ }
149
+ reportLoadFailure(err) {
150
+ this.errorMessage.set(err?.status === 404 ? this.lang.t("spark.query.unavailable") || "This list is not available." : err?.error?.error || err?.message || "An unexpected error occurred");
151
+ }
152
+ async onCustomAction(action) {
153
+ await this.grid()?.onCustomAction(action);
154
+ }
155
+ onCreate() {
156
+ this.createClicked.emit();
157
+ const et = this.entityType();
158
+ if (et) this.router.navigate([
159
+ "/po",
160
+ et.alias || et.id,
161
+ "new"
162
+ ]);
163
+ }
164
+ clearSearch() {
165
+ this.searchTerm.set("");
166
+ }
167
+ connectStreaming(queryId) {
168
+ if (this.streamingSub) return;
169
+ this.isStreaming.set(true);
170
+ this.streamingSub = this.streamingService.connectToStreamingQuery(queryId).subscribe({
171
+ next: (message) => this.handleStreamingMessage(message),
172
+ error: (err) => {
173
+ this.errorMessage.set(err?.message || "Streaming connection failed");
174
+ this.isStreaming.set(false);
175
+ },
176
+ complete: () => this.isStreaming.set(false)
177
+ });
178
+ }
179
+ disconnectStreaming() {
180
+ if (this.streamingSub) {
181
+ this.streamingSub.unsubscribe();
182
+ this.streamingSub = null;
183
+ }
184
+ this.isStreaming.set(false);
185
+ }
186
+ handleStreamingMessage(message) {
187
+ switch (message.type) {
188
+ case "snapshot":
189
+ this.errorMessage.set(null);
190
+ this.streamColumns.set(message.columns);
191
+ this.allItems.set(message.data);
192
+ break;
193
+ case "patch":
194
+ if (message.updated.length > 0) this.allItems.update((items) => items.map((item) => {
195
+ const patch = message.updated.find((u) => u.id === item.id);
196
+ if (!patch) return item;
197
+ return {
198
+ ...item,
199
+ values: item.values.map((v) => v.key in patch.values ? {
200
+ ...v,
201
+ value: patch.values[v.key]
202
+ } : v)
203
+ };
204
+ }));
205
+ break;
206
+ case "error": this.errorMessage.set(message.message);
207
+ }
208
+ }
209
+ applyFilter() {
210
+ let items = this.allItems();
211
+ const term = this.searchTerm().toLowerCase();
212
+ if (term) items = items.filter((item) => item.values.some((v) => String(v.value ?? "").toLowerCase().includes(term)));
213
+ const sortCols = this.grid()?.settings().sortColumns ?? [];
214
+ if (sortCols.length > 0) items = [...items].sort((a, b) => {
215
+ for (const col of sortCols) {
216
+ const aVal = a.values.find((v) => v.key === col.property)?.value ?? "";
217
+ const bVal = b.values.find((v) => v.key === col.property)?.value ?? "";
218
+ const cmp = String(aVal).localeCompare(String(bVal));
219
+ if (cmp !== 0) return col.direction === "descending" ? -cmp : cmp;
220
+ }
221
+ return 0;
222
+ });
223
+ this.streamItems.set(items);
224
+ }
225
+ static ɵfac = i0.ɵɵngDeclareFactory({
226
+ minVersion: "12.0.0",
227
+ version: "22.2.0",
228
+ ngImport: i0,
229
+ type: SparkQueryListComponent,
230
+ deps: [],
231
+ target: i0.ɵɵFactoryTarget.Component
232
+ });
233
+ static ɵcmp = i0.ɵɵngDeclareComponent({
234
+ minVersion: "17.0.0",
235
+ version: "22.2.0",
236
+ type: SparkQueryListComponent,
237
+ isStandalone: true,
238
+ selector: "spark-query-list",
239
+ inputs: {
240
+ extraActionsTemplate: {
241
+ classPropertyName: "extraActionsTemplate",
242
+ publicName: "extraActionsTemplate",
243
+ isSignal: true,
244
+ isRequired: false,
245
+ transformFunction: null
246
+ },
247
+ showCustomActions: {
248
+ classPropertyName: "showCustomActions",
249
+ publicName: "showCustomActions",
250
+ isSignal: true,
251
+ isRequired: false,
252
+ transformFunction: null
253
+ },
254
+ rowRoute: {
255
+ classPropertyName: "rowRoute",
256
+ publicName: "rowRoute",
257
+ isSignal: true,
258
+ isRequired: false,
259
+ transformFunction: null
260
+ }
261
+ },
262
+ outputs: {
263
+ rowClicked: "rowClicked",
264
+ createClicked: "createClicked",
265
+ customActionExecuted: "customActionExecuted"
266
+ },
267
+ host: { properties: { "class.virtual-scrolling": "isVirtualScrolling()" } },
268
+ viewQueries: [{
269
+ propertyName: "grid",
270
+ first: true,
271
+ predicate: SparkQueryGridComponent,
272
+ descendants: true,
273
+ isSignal: true
274
+ }],
275
+ ngImport: i0,
276
+ template: "<div class=\"d-flex flex-column h-100\">\n <div class=\"spark-actionbar py-2 flex-shrink-0\" [class.spark-actionbar-wide]=\"isVirtualScrolling()\">\n <bs-priority-nav [moreLabel]=\"lang.t('common.more')\" [collapseAt]=\"'sm'\">\n <!-- The grid's toolbar model (#460, M15): New, Delete and the custom actions — the list the\n sub-query card renders too. Disabled, not hidden: hiding makes the affordance\n undiscoverable and reflows the priority nav on every selection change. The server\n enforces the same rules. -->\n @for (action of toolbarActions(); track action.name) {\n @if (action.kind !== 'custom' || showCustomActions()) {\n <button *bsPriorityNavItem=\"action.priority\" type=\"button\" [class]=\"toolbarActionClass(action)\"\n [attr.data-action]=\"action.name\"\n [disabled]=\"!isToolbarActionEnabled(action)\" (click)=\"runToolbarAction(action)\">\n @if (action.kind === 'new') {\n <spark-icon name=\"plus-lg\" /> {{ 'common.new' | t }}\n } @else {\n @if (action.definition.icon && action.kind === 'delete') {\n <spark-icon [name]=\"action.definition.icon\" />\n }\n {{ action.definition.displayName | resolveTranslation }}\n }\n </button>\n }\n }\n @if (extraActionsTemplate(); as extraActionsTpl) {\n <ng-container *bsPriorityNavItem=\"50\">\n <ng-container *ngTemplateOutlet=\"extraActionsTpl\"></ng-container>\n </ng-container>\n }\n <!-- Add-on actions (SPARK_QUERY_LIST_ACTIONS), e.g. the soft-delete Deleted toggle. -->\n @if (listContext(); as ctx) {\n @for (action of listActions; track action.id) {\n <ng-container *bsPriorityNavItem=\"action.priority ?? 60\">\n <ng-container *ngComponentOutlet=\"action.component; inputs: { context: ctx }\" />\n </ng-container>\n }\n }\n </bs-priority-nav>\n </div>\n\n <h2 class=\"mb-4 flex-shrink-0\" [class.px-4]=\"isVirtualScrolling()\">\n {{ (query()?.description | resolveTranslation) || query()?.name || ('common.loading' | t) }}\n @if (isStreaming()) {\n <bs-badge [type]=\"colors.success\" class=\"ms-2 align-middle spark-live-badge\">LIVE</bs-badge>\n }\n @if (deletedMode() === 'only') {\n <bs-badge [type]=\"colors.secondary\" class=\"ms-2 align-middle spark-deleted-badge\">{{ 'softDelete.deleted' | t }}</bs-badge>\n }\n </h2>\n\n @if (errorMessage(); as err) {\n <!-- The route could not be resolved to a query at all. A failure INSIDE the grid renders in\n the grid; this is the one it cannot report, because it never got a query id. -->\n <bs-alert [type]=\"colors.danger\" class=\"m-3 d-block\">\n {{ err }}\n </bs-alert>\n } @else if (queryId(); as qId) {\n <div class=\"flex-shrink-0\" [class.px-4]=\"isVirtualScrolling()\">\n <bs-grid>\n <div bsRow class=\"mb-3\">\n <div [md]=\"12\">\n <!-- The same box as the sub-query card's header (#460 M15): debounce, clear button. -->\n <spark-search-box [(term)]=\"searchTerm\" />\n </div>\n <!-- Its own full-width row rather than a column beside the box: the count is\n occasional, and reserving 8 columns for it shrank the search permanently. The\n @if moved out of the column so nothing reserves vertical space when absent. -->\n @if (searchTerm() && resultCount() !== null) {\n <div [md]=\"12\" class=\"text-end mt-1\">\n <span class=\"text-muted\">\n {{ resultCount() }} {{ resultCount() === 1 ? ('common.resultFound' | t) : ('common.resultsFound' | t) }}\n </span>\n </div>\n }\n </div>\n </bs-grid>\n </div>\n\n <!--\n One grid, both transports. `data` is null for a normal query, so the grid fetches and pages\n server-side; for a streaming query this page owns the socket and hands the filtered snapshot\n in. This used to be two near-identical <bs-datatable> blocks with a shared row template.\n -->\n <spark-query-grid class=\"flex-grow-1\"\n [queryId]=\"qId\"\n [data]=\"gridData()\"\n [columns]=\"gridData() ? streamColumns() : null\"\n [search]=\"searchTerm()\"\n [deleted]=\"deletedMode()\"\n [reloadToken]=\"gridReloadToken()\"\n [rowRoute]=\"rowRoute()\"\n (rowClicked)=\"rowClicked.emit($event)\"\n (customActionExecuted)=\"customActionExecuted.emit($event)\" />\n } @else {\n <div class=\"text-center p-5\">\n <bs-spinner />\n </div>\n }\n</div>\n",
277
+ styles: [".spark-actionbar{--_bleed-block: var(--spark-content-inset-block, 0px);--_bleed-inline: var(--spark-content-inset-inline, 0px);--_gutter: var(--spark-actionbar-gutter, 1rem);position:sticky;top:calc(-1 * var(--_bleed-block));z-index:400;background-color:var(--bs-tertiary-bg);border-bottom:1px solid var(--bs-border-color);margin-bottom:1rem;margin-inline:calc(-1 * var(--_bleed-inline));padding-inline:calc(var(--_bleed-inline) + var(--_gutter))}.spark-actionbar .btn{border-radius:0}.spark-actionbar-wide{--spark-actionbar-gutter: 1.5rem}:host{display:flex;flex-direction:column;flex:1;min-height:0}:host.virtual-scrolling{margin:0 calc(-1 * var(--spark-main-padding, 1.5rem)) calc(-1 * var(--spark-main-padding, 1.5rem));--spark-content-inset-inline: 0px}:host.virtual-scrolling spark-query-grid{display:flex;flex-direction:column;min-height:0}:host.virtual-scrolling ::ng-deep bs-datatable{display:flex;flex-direction:column;min-height:0;--mp-datatable-virtual-max-height: 100%}:host.virtual-scrolling ::ng-deep bs-datatable mp-datatable{flex:1 1 auto;min-height:0}tr:hover{background-color:#0000000d}td input[type=checkbox]:disabled{opacity:1;pointer-events:none}.spark-live-badge{font-size:.6em}\n"],
278
+ dependencies: [
279
+ {
280
+ kind: "component",
281
+ type: BsBadgeComponent,
282
+ selector: "bs-badge",
283
+ inputs: [
284
+ "type",
285
+ "unit",
286
+ "decorative"
287
+ ]
288
+ },
289
+ {
290
+ kind: "ngmodule",
291
+ type: CommonModule
292
+ },
293
+ {
294
+ kind: "directive",
295
+ type: i1.NgComponentOutlet,
296
+ selector: "[ngComponentOutlet]",
297
+ inputs: [
298
+ "ngComponentOutlet",
299
+ "ngComponentOutletInputs",
300
+ "ngComponentOutletInjector",
301
+ "ngComponentOutletEnvironmentInjector",
302
+ "ngComponentOutletContent",
303
+ "ngComponentOutletNgModule"
304
+ ],
305
+ exportAs: ["ngComponentOutlet"]
306
+ },
307
+ {
308
+ kind: "directive",
309
+ type: i1.NgTemplateOutlet,
310
+ selector: "[ngTemplateOutlet]",
311
+ inputs: [
312
+ "ngTemplateOutletContext",
313
+ "ngTemplateOutlet",
314
+ "ngTemplateOutletInjector"
315
+ ]
316
+ },
317
+ {
318
+ kind: "component",
319
+ type: BsAlertComponent,
320
+ selector: "bs-alert",
321
+ inputs: [
322
+ "type",
323
+ "announce",
324
+ "isVisible"
325
+ ],
326
+ outputs: ["isVisibleChange", "afterOpenedOrClosed"]
327
+ },
328
+ {
329
+ kind: "component",
330
+ type: BsGridComponent,
331
+ selector: "bs-grid",
332
+ inputs: ["stopFullWidthAt"]
333
+ },
334
+ {
335
+ kind: "directive",
336
+ type: BsGridRowDirective,
337
+ selector: "[bsRow]"
338
+ },
339
+ {
340
+ kind: "directive",
341
+ type: BsGridColumnDirective,
342
+ selector: "[xxs],[xs],[sm],[md],[lg],[xl],[xxl]",
343
+ inputs: [
344
+ "xxs",
345
+ "xs",
346
+ "sm",
347
+ "md",
348
+ "lg",
349
+ "xl",
350
+ "xxl"
351
+ ]
352
+ },
353
+ {
354
+ kind: "component",
355
+ type: BsPriorityNavComponent,
356
+ selector: "bs-priority-nav",
357
+ inputs: [
358
+ "moreLabel",
359
+ "moreLabelTemplate",
360
+ "collapseAt",
361
+ "overflowFrom",
362
+ "hideEmptyMore",
363
+ "ariaLabel"
364
+ ],
365
+ outputs: ["overflowChange"]
366
+ },
367
+ {
368
+ kind: "directive",
369
+ type: BsPriorityNavItemDirective,
370
+ selector: "[bsPriorityNavItem]",
371
+ inputs: ["bsPriorityNavItem", "bsPriorityNavItemHideBelow"]
372
+ },
373
+ {
374
+ kind: "component",
375
+ type: BsSpinnerComponent,
376
+ selector: "bs-spinner",
377
+ inputs: ["type", "color"]
378
+ },
379
+ {
380
+ kind: "component",
381
+ type: SparkIconComponent,
382
+ selector: "spark-icon",
383
+ inputs: ["name"]
384
+ },
385
+ {
386
+ kind: "component",
387
+ type: SparkQueryGridComponent,
388
+ selector: "spark-query-grid",
389
+ inputs: [
390
+ "queryId",
391
+ "parentId",
392
+ "parentType",
393
+ "data",
394
+ "search",
395
+ "columns",
396
+ "reloadToken",
397
+ "deleted",
398
+ "parentDeleted",
399
+ "settings",
400
+ "selection",
401
+ "rowRoute",
402
+ "selectionModeSetting"
403
+ ],
404
+ outputs: [
405
+ "settingsChange",
406
+ "selectionChange",
407
+ "error",
408
+ "rowClicked",
409
+ "customActionExecuted",
410
+ "createClicked"
411
+ ]
412
+ },
413
+ {
414
+ kind: "component",
415
+ type: SparkSearchBoxComponent,
416
+ selector: "spark-search-box",
417
+ inputs: [
418
+ "term",
419
+ "size",
420
+ "debounce"
421
+ ],
422
+ outputs: ["termChange"]
423
+ },
424
+ {
425
+ kind: "pipe",
426
+ type: ResolveTranslationPipe,
427
+ name: "resolveTranslation"
428
+ },
429
+ {
430
+ kind: "pipe",
431
+ type: TranslateKeyPipe,
432
+ name: "t"
433
+ }
434
+ ],
435
+ changeDetection: i0.ChangeDetectionStrategy.OnPush
436
+ });
437
+ };
438
+ i0.ɵɵngDeclareClassMetadata({
439
+ minVersion: "12.0.0",
440
+ version: "22.2.0",
441
+ ngImport: i0,
442
+ type: SparkQueryListComponent,
443
+ decorators: [{
444
+ type: Component,
445
+ args: [{
446
+ selector: "spark-query-list",
447
+ imports: [
448
+ BsBadgeComponent,
449
+ CommonModule,
450
+ NgTemplateOutlet,
451
+ NgComponentOutlet,
452
+ BsAlertComponent,
453
+ BsGridComponent,
454
+ BsGridRowDirective,
455
+ BsGridColumnDirective,
456
+ BsPriorityNavComponent,
457
+ BsPriorityNavItemDirective,
458
+ BsSpinnerComponent,
459
+ SparkIconComponent,
460
+ SparkQueryGridComponent,
461
+ SparkSearchBoxComponent,
462
+ ResolveTranslationPipe,
463
+ TranslateKeyPipe
464
+ ],
465
+ changeDetection: ChangeDetectionStrategy.OnPush,
466
+ host: { "[class.virtual-scrolling]": "isVirtualScrolling()" },
467
+ template: "<div class=\"d-flex flex-column h-100\">\n <div class=\"spark-actionbar py-2 flex-shrink-0\" [class.spark-actionbar-wide]=\"isVirtualScrolling()\">\n <bs-priority-nav [moreLabel]=\"lang.t('common.more')\" [collapseAt]=\"'sm'\">\n <!-- The grid's toolbar model (#460, M15): New, Delete and the custom actions — the list the\n sub-query card renders too. Disabled, not hidden: hiding makes the affordance\n undiscoverable and reflows the priority nav on every selection change. The server\n enforces the same rules. -->\n @for (action of toolbarActions(); track action.name) {\n @if (action.kind !== 'custom' || showCustomActions()) {\n <button *bsPriorityNavItem=\"action.priority\" type=\"button\" [class]=\"toolbarActionClass(action)\"\n [attr.data-action]=\"action.name\"\n [disabled]=\"!isToolbarActionEnabled(action)\" (click)=\"runToolbarAction(action)\">\n @if (action.kind === 'new') {\n <spark-icon name=\"plus-lg\" /> {{ 'common.new' | t }}\n } @else {\n @if (action.definition.icon && action.kind === 'delete') {\n <spark-icon [name]=\"action.definition.icon\" />\n }\n {{ action.definition.displayName | resolveTranslation }}\n }\n </button>\n }\n }\n @if (extraActionsTemplate(); as extraActionsTpl) {\n <ng-container *bsPriorityNavItem=\"50\">\n <ng-container *ngTemplateOutlet=\"extraActionsTpl\"></ng-container>\n </ng-container>\n }\n <!-- Add-on actions (SPARK_QUERY_LIST_ACTIONS), e.g. the soft-delete Deleted toggle. -->\n @if (listContext(); as ctx) {\n @for (action of listActions; track action.id) {\n <ng-container *bsPriorityNavItem=\"action.priority ?? 60\">\n <ng-container *ngComponentOutlet=\"action.component; inputs: { context: ctx }\" />\n </ng-container>\n }\n }\n </bs-priority-nav>\n </div>\n\n <h2 class=\"mb-4 flex-shrink-0\" [class.px-4]=\"isVirtualScrolling()\">\n {{ (query()?.description | resolveTranslation) || query()?.name || ('common.loading' | t) }}\n @if (isStreaming()) {\n <bs-badge [type]=\"colors.success\" class=\"ms-2 align-middle spark-live-badge\">LIVE</bs-badge>\n }\n @if (deletedMode() === 'only') {\n <bs-badge [type]=\"colors.secondary\" class=\"ms-2 align-middle spark-deleted-badge\">{{ 'softDelete.deleted' | t }}</bs-badge>\n }\n </h2>\n\n @if (errorMessage(); as err) {\n <!-- The route could not be resolved to a query at all. A failure INSIDE the grid renders in\n the grid; this is the one it cannot report, because it never got a query id. -->\n <bs-alert [type]=\"colors.danger\" class=\"m-3 d-block\">\n {{ err }}\n </bs-alert>\n } @else if (queryId(); as qId) {\n <div class=\"flex-shrink-0\" [class.px-4]=\"isVirtualScrolling()\">\n <bs-grid>\n <div bsRow class=\"mb-3\">\n <div [md]=\"12\">\n <!-- The same box as the sub-query card's header (#460 M15): debounce, clear button. -->\n <spark-search-box [(term)]=\"searchTerm\" />\n </div>\n <!-- Its own full-width row rather than a column beside the box: the count is\n occasional, and reserving 8 columns for it shrank the search permanently. The\n @if moved out of the column so nothing reserves vertical space when absent. -->\n @if (searchTerm() && resultCount() !== null) {\n <div [md]=\"12\" class=\"text-end mt-1\">\n <span class=\"text-muted\">\n {{ resultCount() }} {{ resultCount() === 1 ? ('common.resultFound' | t) : ('common.resultsFound' | t) }}\n </span>\n </div>\n }\n </div>\n </bs-grid>\n </div>\n\n <!--\n One grid, both transports. `data` is null for a normal query, so the grid fetches and pages\n server-side; for a streaming query this page owns the socket and hands the filtered snapshot\n in. This used to be two near-identical <bs-datatable> blocks with a shared row template.\n -->\n <spark-query-grid class=\"flex-grow-1\"\n [queryId]=\"qId\"\n [data]=\"gridData()\"\n [columns]=\"gridData() ? streamColumns() : null\"\n [search]=\"searchTerm()\"\n [deleted]=\"deletedMode()\"\n [reloadToken]=\"gridReloadToken()\"\n [rowRoute]=\"rowRoute()\"\n (rowClicked)=\"rowClicked.emit($event)\"\n (customActionExecuted)=\"customActionExecuted.emit($event)\" />\n } @else {\n <div class=\"text-center p-5\">\n <bs-spinner />\n </div>\n }\n</div>\n",
468
+ styles: [".spark-actionbar{--_bleed-block: var(--spark-content-inset-block, 0px);--_bleed-inline: var(--spark-content-inset-inline, 0px);--_gutter: var(--spark-actionbar-gutter, 1rem);position:sticky;top:calc(-1 * var(--_bleed-block));z-index:400;background-color:var(--bs-tertiary-bg);border-bottom:1px solid var(--bs-border-color);margin-bottom:1rem;margin-inline:calc(-1 * var(--_bleed-inline));padding-inline:calc(var(--_bleed-inline) + var(--_gutter))}.spark-actionbar .btn{border-radius:0}.spark-actionbar-wide{--spark-actionbar-gutter: 1.5rem}:host{display:flex;flex-direction:column;flex:1;min-height:0}:host.virtual-scrolling{margin:0 calc(-1 * var(--spark-main-padding, 1.5rem)) calc(-1 * var(--spark-main-padding, 1.5rem));--spark-content-inset-inline: 0px}:host.virtual-scrolling spark-query-grid{display:flex;flex-direction:column;min-height:0}:host.virtual-scrolling ::ng-deep bs-datatable{display:flex;flex-direction:column;min-height:0;--mp-datatable-virtual-max-height: 100%}:host.virtual-scrolling ::ng-deep bs-datatable mp-datatable{flex:1 1 auto;min-height:0}tr:hover{background-color:#0000000d}td input[type=checkbox]:disabled{opacity:1;pointer-events:none}.spark-live-badge{font-size:.6em}\n"]
469
+ }]
470
+ }],
471
+ ctorParameters: () => [],
472
+ propDecorators: {
473
+ extraActionsTemplate: [{
474
+ type: i0.Input,
475
+ args: [{
476
+ isSignal: true,
477
+ alias: "extraActionsTemplate",
478
+ required: false
479
+ }]
480
+ }],
481
+ showCustomActions: [{
482
+ type: i0.Input,
483
+ args: [{
484
+ isSignal: true,
485
+ alias: "showCustomActions",
486
+ required: false
487
+ }]
488
+ }],
489
+ rowRoute: [{
490
+ type: i0.Input,
491
+ args: [{
492
+ isSignal: true,
493
+ alias: "rowRoute",
494
+ required: false
495
+ }]
496
+ }],
497
+ rowClicked: [{
498
+ type: i0.Output,
499
+ args: ["rowClicked"]
500
+ }],
501
+ createClicked: [{
502
+ type: i0.Output,
503
+ args: ["createClicked"]
504
+ }],
505
+ customActionExecuted: [{
506
+ type: i0.Output,
507
+ args: ["customActionExecuted"]
508
+ }],
509
+ grid: [{
510
+ type: i0.ViewChild,
511
+ args: [i0.forwardRef(() => SparkQueryGridComponent), { isSignal: true }]
512
+ }]
513
+ }
514
+ });
303
515
  export { SparkQueryListComponent };
304
- //# sourceMappingURL=mintplayer-ng-spark-query-list.mjs.map
516
+
517
+ //# sourceMappingURL=mintplayer-ng-spark-query-list.mjs.map