@masterteam/client-components 0.0.113 → 0.0.115
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/README.md +206 -0
- package/assets/client-components.css +1 -1
- package/fesm2022/masterteam-client-components-client-list.mjs +143 -3
- package/fesm2022/masterteam-client-components-client-list.mjs.map +1 -1
- package/fesm2022/masterteam-client-components-studio.mjs +2882 -0
- package/fesm2022/masterteam-client-components-studio.mjs.map +1 -0
- package/package.json +9 -5
- package/types/masterteam-client-components-client-list.d.ts +36 -1
- package/types/masterteam-client-components-studio.d.ts +232 -0
|
@@ -0,0 +1,2882 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { InjectionToken, signal, computed, Injectable, inject, untracked, DestroyRef, effect, ElementRef, afterNextRender, Directive, input, ChangeDetectionStrategy, Component, viewChild, afterRenderEffect, output, linkedSignal, Injector } from '@angular/core';
|
|
3
|
+
import { queryClientRows, createExcelWorkbook, applyGridViewState, captureGridViewState, chartMeasure, MtGridChartScope } from '@masterteam/data-grid';
|
|
4
|
+
import { MT_GRID_CHART_STORE, MT_DATA_TABLE_CONFIGURATION as MT_DATA_TABLE_CONFIGURATION$1 } from '@masterteam/data-table/config';
|
|
5
|
+
import { HttpErrorResponse, HttpClient } from '@angular/common/http';
|
|
6
|
+
import { MT_DATA_TABLE_CONFIGURATION, MtTablePreferences, MtDatasetScheduler, MtDatasetCache, MtTableText, loadMtTableResult, mtTablePrintConfiguration } from '@masterteam/data-table/legacy';
|
|
7
|
+
import { mtEntityColumn, mtEntityCellValues, MtServerChartStore, MtLocalChartStore, MT_GRID_SERVER_CHARTS_OPTIONS, mtEntityExportValue, MtDataTableEntityCell, MtStandardGridComponent } from '@masterteam/data-table';
|
|
8
|
+
import { currencyUnitOf } from '@masterteam/components/entities';
|
|
9
|
+
import { mergeStakeholderPreviewEntities } from '@masterteam/client-components/client-list';
|
|
10
|
+
import { Tabs } from '@masterteam/components/tabs';
|
|
11
|
+
import { Button } from '@masterteam/components/button';
|
|
12
|
+
import { TableExportService } from '@masterteam/components/table';
|
|
13
|
+
import { toSignal, takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
14
|
+
import { TranslocoService } from '@jsverse/transloco';
|
|
15
|
+
import { merge, take } from 'rxjs';
|
|
16
|
+
import { provideEntityListTablePreview } from '@masterteam/components/business-fields';
|
|
17
|
+
import { ModalService } from '@masterteam/components/modal';
|
|
18
|
+
|
|
19
|
+
const STUDIO_INITIAL_QUERY = {
|
|
20
|
+
offset: 0,
|
|
21
|
+
limit: 1000,
|
|
22
|
+
sort: [],
|
|
23
|
+
filters: {},
|
|
24
|
+
search: '',
|
|
25
|
+
groupColumns: [],
|
|
26
|
+
groupKeys: [],
|
|
27
|
+
valueColumns: [],
|
|
28
|
+
pivotColumns: [],
|
|
29
|
+
};
|
|
30
|
+
const OPERATORS = new Set([
|
|
31
|
+
'contains',
|
|
32
|
+
'notContains',
|
|
33
|
+
'equals',
|
|
34
|
+
'notEqual',
|
|
35
|
+
'startsWith',
|
|
36
|
+
'endsWith',
|
|
37
|
+
'blank',
|
|
38
|
+
'notBlank',
|
|
39
|
+
'greaterThan',
|
|
40
|
+
'greaterThanOrEqual',
|
|
41
|
+
'lessThan',
|
|
42
|
+
'lessThanOrEqual',
|
|
43
|
+
'inRange',
|
|
44
|
+
]);
|
|
45
|
+
function filterExpression(field, model) {
|
|
46
|
+
if (model.filterType === 'set')
|
|
47
|
+
return { kind: 'condition', field, operator: 'in', values: model.values };
|
|
48
|
+
if (model.filterType === 'multi')
|
|
49
|
+
return {
|
|
50
|
+
kind: 'and',
|
|
51
|
+
expressions: model.filterModels.flatMap((filter) => filter ? [filterExpression(field, filter)] : []),
|
|
52
|
+
};
|
|
53
|
+
if ('operator' in model)
|
|
54
|
+
return {
|
|
55
|
+
kind: model.operator === 'AND' ? 'and' : 'or',
|
|
56
|
+
expressions: model.conditions.map((condition) => filterExpression(field, condition)),
|
|
57
|
+
};
|
|
58
|
+
if (!OPERATORS.has(model.type))
|
|
59
|
+
throw new Error(`Studio does not support the filter operation: ${model.type}`);
|
|
60
|
+
if (model.type === 'blank' || model.type === 'notBlank')
|
|
61
|
+
return { kind: 'condition', field, operator: model.type };
|
|
62
|
+
return model.filterType === 'date'
|
|
63
|
+
? {
|
|
64
|
+
kind: 'condition',
|
|
65
|
+
field,
|
|
66
|
+
operator: model.type,
|
|
67
|
+
value: model.dateFrom ?? null,
|
|
68
|
+
upper: model.dateTo ?? null,
|
|
69
|
+
}
|
|
70
|
+
: {
|
|
71
|
+
kind: 'condition',
|
|
72
|
+
field,
|
|
73
|
+
operator: model.type,
|
|
74
|
+
value: model.filter ?? null,
|
|
75
|
+
upper: model.filterTo ?? null,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
function studioFilter(model) {
|
|
79
|
+
const expressions = Object.entries(model).map(([field, filter]) => filterExpression(field, filter));
|
|
80
|
+
return expressions.length ? { kind: 'and', expressions } : null;
|
|
81
|
+
}
|
|
82
|
+
function studioQuery(scope, propertyKeys, query, options = {}) {
|
|
83
|
+
return {
|
|
84
|
+
scope,
|
|
85
|
+
propertyKeys,
|
|
86
|
+
filter: studioFilter(query.filters),
|
|
87
|
+
search: query.search,
|
|
88
|
+
sort: query.sort.map((sort) => ({
|
|
89
|
+
field: sort.colId,
|
|
90
|
+
direction: sort.sort,
|
|
91
|
+
})),
|
|
92
|
+
paging: { offset: query.offset, limit: query.limit },
|
|
93
|
+
grouping: { fields: query.groupColumns, path: query.groupKeys },
|
|
94
|
+
values: query.valueColumns.map((value) => ({
|
|
95
|
+
field: value.colId,
|
|
96
|
+
aggregation: value.aggFunc,
|
|
97
|
+
})),
|
|
98
|
+
pivot: query.pivotColumns,
|
|
99
|
+
includeDescendants: options.includeDescendants ?? false,
|
|
100
|
+
summaries: options.summaries ?? [],
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
const studioRecordKey = (levelId, recordId) => `level:${levelId}/record:${recordId}`;
|
|
104
|
+
/** Browser configuration is untrusted. Never broaden a stale predicate. */
|
|
105
|
+
function validStudioFilter(value, fields, depth = 0) {
|
|
106
|
+
if (value === null)
|
|
107
|
+
return true;
|
|
108
|
+
if (!value || typeof value !== 'object' || depth > 6)
|
|
109
|
+
return false;
|
|
110
|
+
const filter = value;
|
|
111
|
+
if (filter['kind'] === 'and' || filter['kind'] === 'or')
|
|
112
|
+
return (Array.isArray(filter['expressions']) &&
|
|
113
|
+
filter['expressions'].length <= 32 &&
|
|
114
|
+
filter['expressions'].every((item) => validStudioFilter(item, fields, depth + 1)));
|
|
115
|
+
if (filter['kind'] !== 'condition' ||
|
|
116
|
+
typeof filter['field'] !== 'string' ||
|
|
117
|
+
!fields.has(filter['field']))
|
|
118
|
+
return false;
|
|
119
|
+
const scalar = (item) => item == null ||
|
|
120
|
+
typeof item === 'boolean' ||
|
|
121
|
+
(typeof item === 'number' && Number.isFinite(item)) ||
|
|
122
|
+
(typeof item === 'string' && item.length <= 2048);
|
|
123
|
+
if (filter['operator'] === 'in')
|
|
124
|
+
return (Array.isArray(filter['values']) &&
|
|
125
|
+
filter['values'].length <= 10000 &&
|
|
126
|
+
filter['values'].every(scalar));
|
|
127
|
+
return (typeof filter['operator'] === 'string' &&
|
|
128
|
+
OPERATORS.has(filter['operator']) &&
|
|
129
|
+
scalar(filter['value']) &&
|
|
130
|
+
scalar(filter['upper']));
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/** Only a server-produced PDF is embedded for print; arbitrary export content is never executed. */
|
|
134
|
+
async function studioFile(blob, format, fileName, signal) {
|
|
135
|
+
signal.throwIfAborted();
|
|
136
|
+
if (format === 'print' && blob.type.split(';')[0] !== 'application/pdf')
|
|
137
|
+
throw new Error('Print requires a PDF response.');
|
|
138
|
+
const url = URL.createObjectURL(blob);
|
|
139
|
+
if (format !== 'print') {
|
|
140
|
+
const link = document.createElement('a');
|
|
141
|
+
link.href = url;
|
|
142
|
+
link.download = fileName.replace(/[\\/:*?"<>|]/g, '-').slice(0, 180);
|
|
143
|
+
link.click();
|
|
144
|
+
setTimeout(() => URL.revokeObjectURL(url), 60000);
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
await new Promise((resolve, reject) => {
|
|
148
|
+
const frame = document.createElement('iframe');
|
|
149
|
+
frame.style.cssText =
|
|
150
|
+
'position:fixed;width:1px;height:1px;inset:0;opacity:0;pointer-events:none';
|
|
151
|
+
frame.title = fileName;
|
|
152
|
+
const cleanup = () => {
|
|
153
|
+
clearTimeout(timer);
|
|
154
|
+
signal.removeEventListener('abort', abort);
|
|
155
|
+
frame.remove();
|
|
156
|
+
URL.revokeObjectURL(url);
|
|
157
|
+
};
|
|
158
|
+
const abort = () => {
|
|
159
|
+
cleanup();
|
|
160
|
+
reject(signal.reason);
|
|
161
|
+
};
|
|
162
|
+
const timer = setTimeout(() => {
|
|
163
|
+
cleanup();
|
|
164
|
+
reject(new Error('Print preview timed out.'));
|
|
165
|
+
}, 60000);
|
|
166
|
+
signal.addEventListener('abort', abort, { once: true });
|
|
167
|
+
frame.addEventListener('load', () => {
|
|
168
|
+
if (signal.aborted)
|
|
169
|
+
return;
|
|
170
|
+
try {
|
|
171
|
+
frame.contentWindow?.focus();
|
|
172
|
+
frame.contentWindow?.print();
|
|
173
|
+
resolve();
|
|
174
|
+
}
|
|
175
|
+
catch (error) {
|
|
176
|
+
cleanup();
|
|
177
|
+
reject(error);
|
|
178
|
+
}
|
|
179
|
+
}, { once: true });
|
|
180
|
+
frame.addEventListener('error', () => {
|
|
181
|
+
cleanup();
|
|
182
|
+
reject(new Error('Print preview unavailable.'));
|
|
183
|
+
}, { once: true });
|
|
184
|
+
frame.src = url;
|
|
185
|
+
document.body.appendChild(frame);
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/** Today's pplus routes. Another product overrides only what differs through `provideClientStudio`. */
|
|
190
|
+
const CLIENT_STUDIO_DEFAULT_ENDPOINTS = {
|
|
191
|
+
catalog: (contextKey) => `fetch/catalog?contextKey=${encodeURIComponent(contextKey)}`,
|
|
192
|
+
layout: (schemaId) => `levels/${schemaId}/workspaceBuilder`,
|
|
193
|
+
layoutMapper: (raw) => raw,
|
|
194
|
+
moduleSettings: (schemaId, moduleId) => `LevelData/levels/${schemaId}/modules/${moduleId}/table-display-settings/catalog?surfaceKey=table`,
|
|
195
|
+
recordState: (recordId) => `LevelData/${recordId}/workspace-state`,
|
|
196
|
+
query: 'fetch/query',
|
|
197
|
+
chartsEndpoint: 'grid-charts/me',
|
|
198
|
+
};
|
|
199
|
+
const MT_CLIENT_STUDIO_ENDPOINTS = new InjectionToken('MT_CLIENT_STUDIO_ENDPOINTS', {
|
|
200
|
+
providedIn: 'root',
|
|
201
|
+
factory: () => CLIENT_STUDIO_DEFAULT_ENDPOINTS,
|
|
202
|
+
});
|
|
203
|
+
/**
|
|
204
|
+
* Installs Studio's endpoint adapter. Unset entries keep the pplus defaults.
|
|
205
|
+
* Works in application, route and component `providers`.
|
|
206
|
+
*/
|
|
207
|
+
function provideClientStudio(config = {}) {
|
|
208
|
+
const overrides = Object.fromEntries(Object.entries(config).filter(([, value]) => value !== undefined));
|
|
209
|
+
return [
|
|
210
|
+
{
|
|
211
|
+
provide: MT_CLIENT_STUDIO_ENDPOINTS,
|
|
212
|
+
useValue: { ...CLIENT_STUDIO_DEFAULT_ENDPOINTS, ...overrides },
|
|
213
|
+
},
|
|
214
|
+
];
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
function studioEntity(row, property) {
|
|
218
|
+
if (['internal_username', 'email'].includes(property.normalizedKey) &&
|
|
219
|
+
row.properties?.some((item) => item.normalizedKey === 'external_username')) {
|
|
220
|
+
const entities = row.properties.flatMap((item) => {
|
|
221
|
+
const entity = studioRawEntity(row, item);
|
|
222
|
+
return entity ? [entity] : [];
|
|
223
|
+
});
|
|
224
|
+
return (mergeStakeholderPreviewEntities(entities).find((entity) => entity.normalizedKey === property.normalizedKey) ?? null);
|
|
225
|
+
}
|
|
226
|
+
return studioRawEntity(row, property);
|
|
227
|
+
}
|
|
228
|
+
function studioRawEntity(row, property) {
|
|
229
|
+
property =
|
|
230
|
+
row.properties?.find((item) => item.normalizedKey === property.normalizedKey) ?? property;
|
|
231
|
+
const cell = row.values[property.key];
|
|
232
|
+
if (!cell)
|
|
233
|
+
return null;
|
|
234
|
+
return {
|
|
235
|
+
id: row.recordId,
|
|
236
|
+
propertyId: property.propertyId ?? undefined,
|
|
237
|
+
key: property.key,
|
|
238
|
+
normalizedKey: property.normalizedKey,
|
|
239
|
+
name: property.label,
|
|
240
|
+
viewType: property.viewType,
|
|
241
|
+
configuration: { ...property.configuration, hideLabel: true },
|
|
242
|
+
propertyConfiguration: property.propertyConfiguration ?? undefined,
|
|
243
|
+
nestedProperties: [...property.nestedProperties],
|
|
244
|
+
order: property.order,
|
|
245
|
+
value: cell.value,
|
|
246
|
+
rawValue: cell.raw == null
|
|
247
|
+
? undefined
|
|
248
|
+
: typeof cell.raw === 'object'
|
|
249
|
+
? JSON.stringify(cell.raw)
|
|
250
|
+
: String(cell.raw),
|
|
251
|
+
color: cell.color,
|
|
252
|
+
comparison: cell.comparison,
|
|
253
|
+
runtimeContext: {
|
|
254
|
+
levelId: row.owner?.levelId ?? row.levelId,
|
|
255
|
+
levelDataId: row.owner?.recordId ?? row.recordId,
|
|
256
|
+
ownerKind: row.owner ? 'ModuleData' : 'LevelData',
|
|
257
|
+
ownerId: row.recordId,
|
|
258
|
+
},
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
function studioColumns(properties, defaultKeys, records = false) {
|
|
262
|
+
const defaults = new Set(defaultKeys), ordered = [...properties].sort((a, b) => {
|
|
263
|
+
const ai = defaultKeys.indexOf(a.key), bi = defaultKeys.indexOf(b.key);
|
|
264
|
+
return ((ai < 0 ? Number.MAX_SAFE_INTEGER : ai) -
|
|
265
|
+
(bi < 0 ? Number.MAX_SAFE_INTEGER : bi) || a.order - b.order);
|
|
266
|
+
});
|
|
267
|
+
return ordered
|
|
268
|
+
.filter((property) => property.viewType !== 'Section')
|
|
269
|
+
.map((property) => {
|
|
270
|
+
// Studio replaces immutable rows on field/locale/scope loads. Reuse their
|
|
271
|
+
// entity projection across sorting, filtering and rendering; release this
|
|
272
|
+
// column's cache with the grid rather than retaining it in the data cache.
|
|
273
|
+
const entities = new WeakMap();
|
|
274
|
+
const entity = (row) => {
|
|
275
|
+
if (!entities.has(row))
|
|
276
|
+
entities.set(row, studioEntity(row, property));
|
|
277
|
+
return entities.get(row);
|
|
278
|
+
};
|
|
279
|
+
const column = mtEntityColumn({
|
|
280
|
+
key: property.key,
|
|
281
|
+
label: property.label,
|
|
282
|
+
viewType: property.viewType,
|
|
283
|
+
entity,
|
|
284
|
+
hidden: !defaults.has(property.key),
|
|
285
|
+
capabilities: property.capabilities,
|
|
286
|
+
});
|
|
287
|
+
return records && property.key === defaultKeys[0]
|
|
288
|
+
? {
|
|
289
|
+
...column,
|
|
290
|
+
cellRenderer: 'group',
|
|
291
|
+
initialWidth: 320,
|
|
292
|
+
cellRendererParams: {
|
|
293
|
+
...column.cellRendererParams,
|
|
294
|
+
innerRenderer: column.cellRenderer,
|
|
295
|
+
},
|
|
296
|
+
}
|
|
297
|
+
: column;
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
function studioOwnerColumns(recordLabel, levelLabel) {
|
|
301
|
+
return [
|
|
302
|
+
['$owner.name', recordLabel, false],
|
|
303
|
+
['$owner.levelName', levelLabel, true],
|
|
304
|
+
].map(([key, label, level]) => {
|
|
305
|
+
const names = new Map();
|
|
306
|
+
const name = (row) => (level ? row.owner?.levelName : row.owner?.name) ?? '';
|
|
307
|
+
return mtEntityColumn({
|
|
308
|
+
key,
|
|
309
|
+
label,
|
|
310
|
+
width: level ? 200 : 240,
|
|
311
|
+
pinned: level ? null : 'left',
|
|
312
|
+
viewType: 'Text',
|
|
313
|
+
entity: (row) => ({ viewType: 'Text', value: name(row) }),
|
|
314
|
+
valueGetter: ({ data }) => {
|
|
315
|
+
const identity = level
|
|
316
|
+
? String(data.owner?.levelId ?? '')
|
|
317
|
+
: `${data.owner?.levelId}:${data.owner?.recordId}`;
|
|
318
|
+
names.set(identity, name(data));
|
|
319
|
+
return identity;
|
|
320
|
+
},
|
|
321
|
+
valueFormatter: ({ data, value }) => data?.owner ? name(data) : (names.get(String(value)) ?? ''),
|
|
322
|
+
comparator: (a, b) => (names.get(String(a)) ?? '').localeCompare(names.get(String(b)) ?? ''),
|
|
323
|
+
});
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
/** A shared field name does not establish compatible units across different level catalogs. */
|
|
327
|
+
function compatibleStudioProperties(properties, rows) {
|
|
328
|
+
// A chart can combine several measures. Check every loaded monetary field,
|
|
329
|
+
// not just each column separately, before offering a common numeric axis.
|
|
330
|
+
const currencies = properties.filter((property) => property.viewType === 'Currency');
|
|
331
|
+
const units = new Set();
|
|
332
|
+
const loadedCurrencyFields = new Set();
|
|
333
|
+
for (const property of currencies) {
|
|
334
|
+
for (const row of rows) {
|
|
335
|
+
const entity = studioEntity(row, property);
|
|
336
|
+
if (!entity)
|
|
337
|
+
continue;
|
|
338
|
+
const values = mtEntityCellValues(entity);
|
|
339
|
+
if (values.aggregate === null)
|
|
340
|
+
continue;
|
|
341
|
+
loadedCurrencyFields.add(property.key);
|
|
342
|
+
units.add(currencyUnitOf(values.display));
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
const commonCurrency = units.size === 1 && !units.has('');
|
|
346
|
+
return properties.map((property) => {
|
|
347
|
+
const currency = property.viewType === 'Currency';
|
|
348
|
+
if (!currency && !property.capabilities.aggregate)
|
|
349
|
+
return property;
|
|
350
|
+
const configurations = new Set(rows.flatMap((row) => {
|
|
351
|
+
const own = row.properties?.find((item) => item.normalizedKey === property.normalizedKey);
|
|
352
|
+
return own ? [JSON.stringify(own.propertyConfiguration)] : [];
|
|
353
|
+
}));
|
|
354
|
+
const compatible = configurations.size <= 1 &&
|
|
355
|
+
(!currency || (commonCurrency && loadedCurrencyFields.has(property.key)));
|
|
356
|
+
return !compatible
|
|
357
|
+
? {
|
|
358
|
+
...property,
|
|
359
|
+
capabilities: {
|
|
360
|
+
...property.capabilities,
|
|
361
|
+
aggregate: false,
|
|
362
|
+
chart: false,
|
|
363
|
+
},
|
|
364
|
+
}
|
|
365
|
+
: currency
|
|
366
|
+
? {
|
|
367
|
+
...property,
|
|
368
|
+
capabilities: {
|
|
369
|
+
...property.capabilities,
|
|
370
|
+
aggregate: true,
|
|
371
|
+
chart: true,
|
|
372
|
+
pivot: false,
|
|
373
|
+
},
|
|
374
|
+
}
|
|
375
|
+
: property;
|
|
376
|
+
});
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
/** Reuse the engine's predicates; grouping identities and date semantics stay identical to the visible table. */
|
|
380
|
+
function filterStudioRows(rows, properties, filter) {
|
|
381
|
+
if (!filter)
|
|
382
|
+
return rows;
|
|
383
|
+
if (filter.kind === 'and')
|
|
384
|
+
return filter.expressions.reduce((result, expression) => filterStudioRows(result, properties, expression), rows);
|
|
385
|
+
if (filter.kind === 'or') {
|
|
386
|
+
const ids = new Set(filter.expressions.flatMap((expression) => filterStudioRows(rows, properties, expression).map((row) => row.id)));
|
|
387
|
+
return rows.filter((row) => ids.has(row.id));
|
|
388
|
+
}
|
|
389
|
+
if (filter.kind !== 'condition')
|
|
390
|
+
throw new Error('Invalid Studio predicate.');
|
|
391
|
+
const property = properties.find((item) => item.key === filter.field);
|
|
392
|
+
if (!property)
|
|
393
|
+
throw new Error('The filtered property is no longer available.');
|
|
394
|
+
const model = filter.operator === 'in'
|
|
395
|
+
? { filterType: 'set', values: filter.values }
|
|
396
|
+
: property.viewType === 'Date' || property.viewType === 'DateTime'
|
|
397
|
+
? {
|
|
398
|
+
filterType: 'date',
|
|
399
|
+
type: filter.operator,
|
|
400
|
+
dateFrom: filter.value,
|
|
401
|
+
dateTo: filter.upper,
|
|
402
|
+
}
|
|
403
|
+
: {
|
|
404
|
+
filterType: property.capabilities.aggregate ? 'number' : 'text',
|
|
405
|
+
type: filter.operator,
|
|
406
|
+
filter: filter.value,
|
|
407
|
+
filterTo: filter.upper,
|
|
408
|
+
};
|
|
409
|
+
return queryClientRows(rows, studioColumns(properties, properties.map((item) => item.key)), {
|
|
410
|
+
filters: {
|
|
411
|
+
[filter.field]: model,
|
|
412
|
+
},
|
|
413
|
+
}, (row) => row.id);
|
|
414
|
+
}
|
|
415
|
+
function studioSummaryCell(rows, properties, summary) {
|
|
416
|
+
const matching = filterStudioRows(rows, properties, summary.filter);
|
|
417
|
+
if (summary.aggregation === 'count')
|
|
418
|
+
return {
|
|
419
|
+
raw: matching.length,
|
|
420
|
+
value: String(matching.length),
|
|
421
|
+
missingValueCount: 0,
|
|
422
|
+
};
|
|
423
|
+
const property = properties.find((item) => item.key === summary.propertyKey && item.capabilities.aggregate);
|
|
424
|
+
if (!property)
|
|
425
|
+
throw new Error('The measure is no longer available.');
|
|
426
|
+
const values = matching.flatMap((row) => {
|
|
427
|
+
const entity = studioEntity(row, property), value = entity ? mtEntityCellValues(entity).aggregate : null;
|
|
428
|
+
return value === null ? [] : [value];
|
|
429
|
+
});
|
|
430
|
+
const missingValueCount = matching.length - values.length;
|
|
431
|
+
const raw = !values.length
|
|
432
|
+
? null
|
|
433
|
+
: summary.aggregation === 'sum'
|
|
434
|
+
? values.reduce((a, b) => a + b, 0)
|
|
435
|
+
: summary.aggregation === 'avg'
|
|
436
|
+
? values.reduce((a, b) => a + b, 0) / values.length
|
|
437
|
+
: summary.aggregation === 'min'
|
|
438
|
+
? Math.min(...values)
|
|
439
|
+
: Math.max(...values);
|
|
440
|
+
return { raw, value: raw === null ? '' : String(raw), missingValueCount };
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
/** A record as the host sees it in `dataLoaded`: everything the backend sent except `values`. */
|
|
444
|
+
function studioRecordMeta(record) {
|
|
445
|
+
const { values: _values, ...rest } = record;
|
|
446
|
+
return rest;
|
|
447
|
+
}
|
|
448
|
+
const CAPABILITIES = {
|
|
449
|
+
sort: true,
|
|
450
|
+
filter: true,
|
|
451
|
+
group: true,
|
|
452
|
+
pivot: true,
|
|
453
|
+
charts: true,
|
|
454
|
+
exportAll: true,
|
|
455
|
+
};
|
|
456
|
+
const COLLECTIONS = new Set([
|
|
457
|
+
'Attachment',
|
|
458
|
+
'MultiUser',
|
|
459
|
+
'LookupMultiSelect',
|
|
460
|
+
'LookupModuleCheckList',
|
|
461
|
+
'LeafDetails',
|
|
462
|
+
'Connection',
|
|
463
|
+
'EntityList',
|
|
464
|
+
'ScheduleItemSelector',
|
|
465
|
+
'Location',
|
|
466
|
+
'Section',
|
|
467
|
+
]);
|
|
468
|
+
const NUMBERS = new Set(['Number', 'Percentage', 'PerformanceScore']);
|
|
469
|
+
/** Collections whose members are category identities; charts count a record once per member. */
|
|
470
|
+
const MULTI_VALUE_CATEGORIES = new Set(['MultiUser', 'LookupMultiSelect']);
|
|
471
|
+
const normal = (key) => key.replaceAll('_', '').toLowerCase();
|
|
472
|
+
/**
|
|
473
|
+
* A schema's context key. The host's own schema keeps its opaque key; another
|
|
474
|
+
* schema (a connected level, a descendant) takes the same grammar with its id,
|
|
475
|
+
* e.g. `Level:3` beside `Level:12`. Without a host context it is `Level:{id}`.
|
|
476
|
+
*/
|
|
477
|
+
function studioLevelContext(context, levelId) {
|
|
478
|
+
if (context?.contextKey && context.schemaId === levelId)
|
|
479
|
+
return context.contextKey;
|
|
480
|
+
const kind = context?.contextKey.split('/')[0].split(':')[0] || 'Level';
|
|
481
|
+
return `${kind}:${levelId}`;
|
|
482
|
+
}
|
|
483
|
+
/** A module's context key is always `${schema context}/Module:{id}`. */
|
|
484
|
+
function studioModuleContext(context, levelId, moduleId) {
|
|
485
|
+
return `${studioLevelContext(context, levelId)}/Module:${moduleId}`;
|
|
486
|
+
}
|
|
487
|
+
function studioProperties(catalog) {
|
|
488
|
+
return catalog.properties.map((property) => ({
|
|
489
|
+
propertyId: property.id,
|
|
490
|
+
key: property.key,
|
|
491
|
+
normalizedKey: property.normalizedKey,
|
|
492
|
+
label: property.label,
|
|
493
|
+
viewType: property.viewType,
|
|
494
|
+
configuration: null,
|
|
495
|
+
propertyConfiguration: property.configuration ?? null,
|
|
496
|
+
nestedProperties: (catalog.nestedProperties?.[property.key] ?? []).map((nested) => ({
|
|
497
|
+
...nested,
|
|
498
|
+
viewType: nested.viewType,
|
|
499
|
+
})),
|
|
500
|
+
order: property.order,
|
|
501
|
+
capabilities: {
|
|
502
|
+
sort: !COLLECTIONS.has(property.viewType),
|
|
503
|
+
filter: !COLLECTIONS.has(property.viewType),
|
|
504
|
+
group: !COLLECTIONS.has(property.viewType),
|
|
505
|
+
aggregate: NUMBERS.has(property.viewType),
|
|
506
|
+
pivot: !COLLECTIONS.has(property.viewType) && !NUMBERS.has(property.viewType),
|
|
507
|
+
// Currency charts as a numeric series named with its unit ("Amount (SAR)").
|
|
508
|
+
chart: !COLLECTIONS.has(property.viewType) ||
|
|
509
|
+
MULTI_VALUE_CATEGORIES.has(property.viewType),
|
|
510
|
+
export: true,
|
|
511
|
+
},
|
|
512
|
+
}));
|
|
513
|
+
}
|
|
514
|
+
/** Resolve identities, never translated labels or assumed numeric property IDs. */
|
|
515
|
+
function studioRecordDefaults(properties) {
|
|
516
|
+
return ['name', 'startdate', 'finishdate', 'status'].flatMap((identity) => {
|
|
517
|
+
const property = properties.find((item) => normal(item.normalizedKey) === identity);
|
|
518
|
+
return property ? [property.key] : [];
|
|
519
|
+
});
|
|
520
|
+
}
|
|
521
|
+
function studioRuntimeRow(record, levelId, properties, owner = null, contextKey = studioLevelContext(null, levelId)) {
|
|
522
|
+
return {
|
|
523
|
+
id: `${owner?.contextKey ?? contextKey}/record:${record.id}`,
|
|
524
|
+
recordId: record.id,
|
|
525
|
+
levelId,
|
|
526
|
+
name: record.name ?? '',
|
|
527
|
+
owner,
|
|
528
|
+
properties,
|
|
529
|
+
values: Object.fromEntries(properties.flatMap((property) => {
|
|
530
|
+
// Table projections normalize keys; other projections retain the catalog key.
|
|
531
|
+
const cell = record.values[property.normalizedKey] ?? record.values[property.key];
|
|
532
|
+
return cell
|
|
533
|
+
? [
|
|
534
|
+
[
|
|
535
|
+
property.key,
|
|
536
|
+
{
|
|
537
|
+
raw: cell.raw,
|
|
538
|
+
value: cell.value,
|
|
539
|
+
color: cell.color ?? undefined,
|
|
540
|
+
comparison: cell.comparison,
|
|
541
|
+
},
|
|
542
|
+
],
|
|
543
|
+
]
|
|
544
|
+
: [];
|
|
545
|
+
})),
|
|
546
|
+
};
|
|
547
|
+
}
|
|
548
|
+
/** The existing authorized runtime contract. No proposed Studio routes or alternate data. */
|
|
549
|
+
class StudioRuntime {
|
|
550
|
+
request;
|
|
551
|
+
layouts = new Map();
|
|
552
|
+
catalogs = new Map();
|
|
553
|
+
workspaces = new Map();
|
|
554
|
+
endpoints;
|
|
555
|
+
context;
|
|
556
|
+
constructor(request, config = {}) {
|
|
557
|
+
this.request = request;
|
|
558
|
+
this.endpoints = config.endpoints ?? CLIENT_STUDIO_DEFAULT_ENDPOINTS;
|
|
559
|
+
this.context = config.context ?? (() => null);
|
|
560
|
+
}
|
|
561
|
+
levelContext(levelId) {
|
|
562
|
+
return studioLevelContext(this.context(), levelId);
|
|
563
|
+
}
|
|
564
|
+
moduleContext(levelId, moduleId) {
|
|
565
|
+
return studioModuleContext(this.context(), levelId, moduleId);
|
|
566
|
+
}
|
|
567
|
+
/** Host scope applies to the root schema's records query only. */
|
|
568
|
+
rootFilters(levelId) {
|
|
569
|
+
const context = this.context();
|
|
570
|
+
return context && context.schemaId === levelId ? [...context.filters] : [];
|
|
571
|
+
}
|
|
572
|
+
clear() {
|
|
573
|
+
this.layouts.clear();
|
|
574
|
+
this.catalogs.clear();
|
|
575
|
+
this.workspaces.clear();
|
|
576
|
+
}
|
|
577
|
+
async catalog(levelId, signal, locale) {
|
|
578
|
+
signal.throwIfAborted();
|
|
579
|
+
const key = `${levelId}:${locale}`;
|
|
580
|
+
const cached = this.catalogs.get(key);
|
|
581
|
+
if (cached)
|
|
582
|
+
return cached;
|
|
583
|
+
const [catalog, rawLayout] = await Promise.all([
|
|
584
|
+
this.request('GET', this.endpoints.catalog(this.levelContext(levelId)), null, signal),
|
|
585
|
+
this.request('GET', this.endpoints.layout(levelId), null, signal),
|
|
586
|
+
]);
|
|
587
|
+
const layout = this.endpoints.layoutMapper(rawLayout, levelId);
|
|
588
|
+
this.layouts.set(key, layout);
|
|
589
|
+
const properties = studioProperties(catalog);
|
|
590
|
+
const modules = (await Promise.all([...layout.tabs]
|
|
591
|
+
.sort((a, b) => a.order - b.order)
|
|
592
|
+
.flatMap((tab) => {
|
|
593
|
+
if (tab.type === 'group')
|
|
594
|
+
return [...(tab.modules ?? [])]
|
|
595
|
+
.sort((a, b) => (a.order ?? 0) - (b.order ?? 0))
|
|
596
|
+
.map((module) => this.module(levelId, {
|
|
597
|
+
...module,
|
|
598
|
+
type: 'module',
|
|
599
|
+
name: module.name ?? tab.name,
|
|
600
|
+
order: module.order ?? 0,
|
|
601
|
+
}, tab, signal));
|
|
602
|
+
return tab.type === 'module'
|
|
603
|
+
? [this.module(levelId, tab, null, signal)]
|
|
604
|
+
: [];
|
|
605
|
+
}))).filter((module) => module !== null);
|
|
606
|
+
signal.throwIfAborted();
|
|
607
|
+
const result = {
|
|
608
|
+
levelId,
|
|
609
|
+
name: catalog.schemas[0]?.name ?? '',
|
|
610
|
+
properties,
|
|
611
|
+
defaultColumnKeys: studioRecordDefaults(properties),
|
|
612
|
+
modules,
|
|
613
|
+
capabilities: CAPABILITIES,
|
|
614
|
+
exportFormats: ['csv', 'excel', 'pdf', 'print'],
|
|
615
|
+
};
|
|
616
|
+
this.catalogs.set(key, result);
|
|
617
|
+
return result;
|
|
618
|
+
}
|
|
619
|
+
async module(levelId, item, group, signal) {
|
|
620
|
+
if (item.moduleTypeGroup === 'Informative')
|
|
621
|
+
return null;
|
|
622
|
+
const moduleId = Number(item.id);
|
|
623
|
+
if (!Number.isSafeInteger(moduleId) || moduleId <= 0)
|
|
624
|
+
return null;
|
|
625
|
+
try {
|
|
626
|
+
const catalog = await this.request('GET', this.endpoints.catalog(this.moduleContext(levelId, moduleId)), null, signal);
|
|
627
|
+
const settings = await this.request('GET', this.endpoints.moduleSettings(levelId, moduleId), null, signal);
|
|
628
|
+
const properties = studioProperties(catalog).map((property) => ({
|
|
629
|
+
...property,
|
|
630
|
+
configuration: settings.effectiveColumns.find((column) => column.columnKey.toLowerCase() === property.key.toLowerCase() ||
|
|
631
|
+
column.columnKey.toLowerCase() ===
|
|
632
|
+
property.normalizedKey.toLowerCase())?.configuration ?? null,
|
|
633
|
+
}));
|
|
634
|
+
const defaultColumnKeys = settings.effectiveColumns
|
|
635
|
+
.filter((column) => column.isVisible)
|
|
636
|
+
.sort((a, b) => a.order - b.order)
|
|
637
|
+
.flatMap((column) => {
|
|
638
|
+
const property = properties.find((item) => item.key.toLowerCase() === column.columnKey.toLowerCase() ||
|
|
639
|
+
item.normalizedKey.toLowerCase() ===
|
|
640
|
+
column.columnKey.toLowerCase());
|
|
641
|
+
return property ? [property.key] : [];
|
|
642
|
+
});
|
|
643
|
+
return {
|
|
644
|
+
id: `${levelId}:${moduleId}`,
|
|
645
|
+
moduleId,
|
|
646
|
+
moduleKey: catalog.schemas[0]?.key ?? item.moduleKey ?? '',
|
|
647
|
+
name: catalog.schemas[0]?.name ?? item.name.display,
|
|
648
|
+
order: item.order,
|
|
649
|
+
group: group
|
|
650
|
+
? { id: group.id, name: group.name.display, order: group.order }
|
|
651
|
+
: null,
|
|
652
|
+
properties,
|
|
653
|
+
defaultColumnKeys,
|
|
654
|
+
capabilities: CAPABILITIES,
|
|
655
|
+
exportFormats: ['csv', 'excel', 'pdf', 'print'],
|
|
656
|
+
};
|
|
657
|
+
}
|
|
658
|
+
catch (error) {
|
|
659
|
+
if (error instanceof HttpErrorResponse && error.status === 403)
|
|
660
|
+
return null;
|
|
661
|
+
throw error;
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
async workspace(levelId, recordId, signal, locale) {
|
|
665
|
+
const key = `${levelId}:${recordId}:${locale}`;
|
|
666
|
+
const cached = this.workspaces.get(key);
|
|
667
|
+
if (cached) {
|
|
668
|
+
signal.throwIfAborted();
|
|
669
|
+
return cached;
|
|
670
|
+
}
|
|
671
|
+
const [catalog, state, response] = await Promise.all([
|
|
672
|
+
this.catalog(levelId, signal, locale),
|
|
673
|
+
this.request('GET', this.endpoints.recordState(recordId), null, signal),
|
|
674
|
+
this.records(this.levelContext(levelId), [], [{ key: 'id', operator: 'Equals', value: String(recordId) }], signal),
|
|
675
|
+
]);
|
|
676
|
+
const record = response.records[0];
|
|
677
|
+
if (!record)
|
|
678
|
+
throw new Error('The record is no longer readable.');
|
|
679
|
+
const workspace = {
|
|
680
|
+
record: {
|
|
681
|
+
recordId,
|
|
682
|
+
levelId,
|
|
683
|
+
name: record.name ?? '',
|
|
684
|
+
levelName: catalog.name,
|
|
685
|
+
contextKey: this.levelContext(levelId),
|
|
686
|
+
},
|
|
687
|
+
canExport: true,
|
|
688
|
+
modules: catalog.modules.filter((module) => state.modules?.some((entry) => entry.moduleId === module.moduleId && entry.visible === true)),
|
|
689
|
+
children: [
|
|
690
|
+
...new Map((this.layouts.get(`${levelId}:${locale}`)?.childLevels ?? []).map((child) => [child.levelId, child])).values(),
|
|
691
|
+
]
|
|
692
|
+
.sort((a, b) => a.order - b.order)
|
|
693
|
+
.map((child) => ({ ...child, name: child.name.display })),
|
|
694
|
+
};
|
|
695
|
+
signal.throwIfAborted();
|
|
696
|
+
this.workspaces.delete(key);
|
|
697
|
+
this.workspaces.set(key, workspace);
|
|
698
|
+
while (this.workspaces.size > 20)
|
|
699
|
+
this.workspaces.delete(this.workspaces.keys().next().value);
|
|
700
|
+
return workspace;
|
|
701
|
+
}
|
|
702
|
+
rows(scope, keys, signal, locale, options = {}) {
|
|
703
|
+
return this.load(scope, keys, signal, locale, options);
|
|
704
|
+
}
|
|
705
|
+
/**
|
|
706
|
+
* The rows of the root records query plus what the host receives as `dataLoaded`.
|
|
707
|
+
* Only the Studio's own root grid asks for this; internal reads of the same scope
|
|
708
|
+
* (cross-record analysis) go through `rows()` and never report.
|
|
709
|
+
*/
|
|
710
|
+
async rootRows(scope, keys, signal, locale, options = {}) {
|
|
711
|
+
let meta;
|
|
712
|
+
const rows = await this.load(scope, keys, signal, locale, options, (value) => (meta = value));
|
|
713
|
+
if (!meta)
|
|
714
|
+
throw new Error('The root records did not load.');
|
|
715
|
+
return { rows, meta };
|
|
716
|
+
}
|
|
717
|
+
async load(scope, keys, signal, locale, options, onRoot) {
|
|
718
|
+
signal.throwIfAborted();
|
|
719
|
+
const catalog = await this.catalog(scope.levelId, signal, locale);
|
|
720
|
+
if (scope.kind === 'module') {
|
|
721
|
+
const module = catalog.modules.find((item) => item.moduleKey === scope.moduleKey);
|
|
722
|
+
if (!module)
|
|
723
|
+
throw new Error('The module is no longer readable.');
|
|
724
|
+
const workspace = await this.workspace(scope.levelId, scope.recordId, signal, locale);
|
|
725
|
+
if (!workspace.modules.some((item) => item.moduleId === module.moduleId))
|
|
726
|
+
throw new Error('The module is not available for this record.');
|
|
727
|
+
const owner = {
|
|
728
|
+
...workspace.record,
|
|
729
|
+
moduleId: module.moduleId,
|
|
730
|
+
contextKey: this.moduleContext(scope.levelId, module.moduleId),
|
|
731
|
+
};
|
|
732
|
+
const fields = new Set(keys);
|
|
733
|
+
const stakeholderName = module.properties.find((property) => property.normalizedKey === 'internal_username');
|
|
734
|
+
if (stakeholderName &&
|
|
735
|
+
(fields.has(stakeholderName.key) ||
|
|
736
|
+
module.properties.some((property) => property.normalizedKey === 'email' && fields.has(property.key))))
|
|
737
|
+
for (const property of module.properties)
|
|
738
|
+
if ([
|
|
739
|
+
'internal_username',
|
|
740
|
+
'external_username',
|
|
741
|
+
'position',
|
|
742
|
+
'email',
|
|
743
|
+
].includes(property.normalizedKey))
|
|
744
|
+
fields.add(property.key);
|
|
745
|
+
const { records } = await this.records(owner.contextKey, [...fields], [
|
|
746
|
+
{
|
|
747
|
+
key: 'levelDataId',
|
|
748
|
+
operator: 'Equals',
|
|
749
|
+
value: String(scope.recordId),
|
|
750
|
+
},
|
|
751
|
+
], signal);
|
|
752
|
+
return records.map((record) => studioRuntimeRow(record, scope.levelId, module.properties, owner));
|
|
753
|
+
}
|
|
754
|
+
if (scope.kind === 'crossRecord') {
|
|
755
|
+
const records = await this.rows({ kind: 'records', levelId: scope.levelId }, catalog.defaultColumnKeys, signal, locale);
|
|
756
|
+
const selected = new Set(scope.recordIds);
|
|
757
|
+
const owners = await this.owners(records.filter((row) => selected.has(row.recordId)), options.includeDescendants ?? false, signal, locale);
|
|
758
|
+
const sourceModule = catalog.modules.find((item) => item.moduleKey === scope.moduleKey);
|
|
759
|
+
if (!sourceModule)
|
|
760
|
+
throw new Error('The module is no longer readable.');
|
|
761
|
+
const sets = await Promise.all(owners.map(async (owner) => {
|
|
762
|
+
const workspace = await this.workspace(owner.levelId, owner.recordId, signal, locale);
|
|
763
|
+
const module = workspace.modules.find((item) => item.moduleKey === scope.moduleKey);
|
|
764
|
+
if (!module)
|
|
765
|
+
return [];
|
|
766
|
+
const fields = keys.flatMap((key) => {
|
|
767
|
+
const normalized = sourceModule.properties.find((item) => item.key === key)?.normalizedKey;
|
|
768
|
+
const property = module.properties.find((item) => item.normalizedKey === normalized);
|
|
769
|
+
return property ? [property.key] : [];
|
|
770
|
+
});
|
|
771
|
+
const rows = await this.rows({
|
|
772
|
+
kind: 'module',
|
|
773
|
+
levelId: owner.levelId,
|
|
774
|
+
recordId: owner.recordId,
|
|
775
|
+
moduleKey: module.moduleKey,
|
|
776
|
+
}, fields, signal, locale);
|
|
777
|
+
return rows.map((row) => ({
|
|
778
|
+
...row,
|
|
779
|
+
values: {
|
|
780
|
+
...row.values,
|
|
781
|
+
...Object.fromEntries(sourceModule.properties.flatMap((property) => {
|
|
782
|
+
const own = module.properties.find((item) => item.normalizedKey === property.normalizedKey);
|
|
783
|
+
return own && row.values[own.key]
|
|
784
|
+
? [[property.key, row.values[own.key]]]
|
|
785
|
+
: [];
|
|
786
|
+
})),
|
|
787
|
+
},
|
|
788
|
+
}));
|
|
789
|
+
}));
|
|
790
|
+
return sets.flat();
|
|
791
|
+
}
|
|
792
|
+
const filters = scope.kind === 'children'
|
|
793
|
+
? [
|
|
794
|
+
{
|
|
795
|
+
key: 'sourceLevelDataId',
|
|
796
|
+
operator: 'Equals',
|
|
797
|
+
value: String(scope.parentRecordId),
|
|
798
|
+
},
|
|
799
|
+
]
|
|
800
|
+
: scope.kind === 'record'
|
|
801
|
+
? [{ key: 'id', operator: 'Equals', value: String(scope.recordId) }]
|
|
802
|
+
: this.rootFilters(scope.levelId);
|
|
803
|
+
const contextKey = this.levelContext(scope.levelId);
|
|
804
|
+
const page = await this.records(contextKey, keys, filters, signal);
|
|
805
|
+
if (scope.kind === 'records')
|
|
806
|
+
onRoot?.({
|
|
807
|
+
contextKey,
|
|
808
|
+
key: this.context()?.key ?? '',
|
|
809
|
+
schemaId: scope.levelId,
|
|
810
|
+
schemas: page.schemas,
|
|
811
|
+
records: page.records.map(studioRecordMeta),
|
|
812
|
+
totalCount: page.totalCount,
|
|
813
|
+
});
|
|
814
|
+
const rows = page.records.map((record) => ({
|
|
815
|
+
...studioRuntimeRow(record, scope.levelId, catalog.properties, null, contextKey),
|
|
816
|
+
levelName: catalog.name,
|
|
817
|
+
}));
|
|
818
|
+
if (!options.summaries?.length)
|
|
819
|
+
return rows;
|
|
820
|
+
return Promise.all(rows.map(async (row) => {
|
|
821
|
+
const workspace = await this.workspace(row.levelId, row.recordId, signal, locale);
|
|
822
|
+
const values = { ...row.values };
|
|
823
|
+
for (const summary of options.summaries ?? []) {
|
|
824
|
+
const module = workspace.modules.find((item) => item.moduleKey === summary.moduleKey);
|
|
825
|
+
if (!module) {
|
|
826
|
+
values[summary.key] = { raw: null, value: '' };
|
|
827
|
+
continue;
|
|
828
|
+
}
|
|
829
|
+
const moduleRows = await this.rows({
|
|
830
|
+
kind: 'module',
|
|
831
|
+
levelId: row.levelId,
|
|
832
|
+
recordId: row.recordId,
|
|
833
|
+
moduleKey: module.moduleKey,
|
|
834
|
+
}, module.properties.map((item) => item.key), signal, locale);
|
|
835
|
+
values[summary.key] = studioSummaryCell(moduleRows, module.properties, summary);
|
|
836
|
+
}
|
|
837
|
+
return { ...row, values };
|
|
838
|
+
}));
|
|
839
|
+
}
|
|
840
|
+
async owners(roots, descendants, signal, locale) {
|
|
841
|
+
const result = [], seen = new Set();
|
|
842
|
+
const visit = async (rows) => {
|
|
843
|
+
for (const row of rows) {
|
|
844
|
+
const key = `${row.levelId}:${row.recordId}`;
|
|
845
|
+
if (seen.has(key))
|
|
846
|
+
continue;
|
|
847
|
+
seen.add(key);
|
|
848
|
+
result.push(row);
|
|
849
|
+
if (!descendants)
|
|
850
|
+
continue;
|
|
851
|
+
const workspace = await this.workspace(row.levelId, row.recordId, signal, locale);
|
|
852
|
+
for (const child of workspace.children) {
|
|
853
|
+
try {
|
|
854
|
+
await visit(await this.rows({
|
|
855
|
+
kind: 'children',
|
|
856
|
+
levelId: child.levelId,
|
|
857
|
+
parentLevelId: row.levelId,
|
|
858
|
+
parentRecordId: row.recordId,
|
|
859
|
+
referenceId: child.referenceId,
|
|
860
|
+
}, [], signal, locale));
|
|
861
|
+
}
|
|
862
|
+
catch (error) {
|
|
863
|
+
if (!(error instanceof HttpErrorResponse && error.status === 403))
|
|
864
|
+
throw error;
|
|
865
|
+
}
|
|
866
|
+
}
|
|
867
|
+
}
|
|
868
|
+
};
|
|
869
|
+
await visit(roots);
|
|
870
|
+
return result;
|
|
871
|
+
}
|
|
872
|
+
/** Honor server page caps, reject overlap/drift, never silently truncate a dataset. */
|
|
873
|
+
async records(contextKey, propertyKeys, filters, signal) {
|
|
874
|
+
const rows = [], ids = new Set();
|
|
875
|
+
let schemas = [];
|
|
876
|
+
let page = 1, pageSize = 500, total;
|
|
877
|
+
do {
|
|
878
|
+
const response = await this.request('POST', this.endpoints.query, {
|
|
879
|
+
contextKey,
|
|
880
|
+
projection: contextKey.includes('/Module:') ? 'Table' : 'Flat',
|
|
881
|
+
surfaceKey: 'table',
|
|
882
|
+
...(propertyKeys.length ? { propertyKeys } : {}),
|
|
883
|
+
filters,
|
|
884
|
+
page,
|
|
885
|
+
pageSize,
|
|
886
|
+
sort: [{ key: 'id', direction: 'Asc' }],
|
|
887
|
+
}, signal);
|
|
888
|
+
const paging = response.pagination;
|
|
889
|
+
if (!paging ||
|
|
890
|
+
paging.page !== page ||
|
|
891
|
+
!Number.isSafeInteger(paging.totalCount) ||
|
|
892
|
+
paging.totalCount < 0 ||
|
|
893
|
+
!Number.isSafeInteger(paging.pageSize) ||
|
|
894
|
+
paging.pageSize <= 0 ||
|
|
895
|
+
(total !== undefined &&
|
|
896
|
+
(total !== paging.totalCount || pageSize !== paging.pageSize)))
|
|
897
|
+
throw new Error('The dataset changed while loading. Retry to read a consistent result.');
|
|
898
|
+
total = paging.totalCount;
|
|
899
|
+
pageSize = paging.pageSize;
|
|
900
|
+
if (page === 1)
|
|
901
|
+
schemas = response.schemas ?? [];
|
|
902
|
+
const records = response.records ?? [];
|
|
903
|
+
if (records.length !== Math.min(pageSize, total - rows.length))
|
|
904
|
+
throw new Error('The dataset is incomplete.');
|
|
905
|
+
for (const record of records) {
|
|
906
|
+
if (ids.has(record.id))
|
|
907
|
+
throw new Error('Overlapping runtime pages.');
|
|
908
|
+
ids.add(record.id);
|
|
909
|
+
rows.push(record);
|
|
910
|
+
}
|
|
911
|
+
page++;
|
|
912
|
+
} while (rows.length < total);
|
|
913
|
+
signal.throwIfAborted();
|
|
914
|
+
return { records: rows, schemas, totalCount: total ?? rows.length };
|
|
915
|
+
}
|
|
916
|
+
}
|
|
917
|
+
|
|
918
|
+
function remapSummary(summary, source, target) {
|
|
919
|
+
if (!source || !target)
|
|
920
|
+
return null;
|
|
921
|
+
const field = (key) => {
|
|
922
|
+
const property = source.properties.find((item) => item.key === key);
|
|
923
|
+
return target.properties.find((item) => item.normalizedKey === property?.normalizedKey);
|
|
924
|
+
};
|
|
925
|
+
const measure = summary.propertyKey ? field(summary.propertyKey) : null;
|
|
926
|
+
if (summary.propertyKey) {
|
|
927
|
+
const original = source.properties.find((item) => item.key === summary.propertyKey);
|
|
928
|
+
if (!measure?.capabilities.aggregate ||
|
|
929
|
+
JSON.stringify(original?.propertyConfiguration) !==
|
|
930
|
+
JSON.stringify(measure.propertyConfiguration))
|
|
931
|
+
return null;
|
|
932
|
+
}
|
|
933
|
+
const filter = (value) => {
|
|
934
|
+
if (!value)
|
|
935
|
+
return null;
|
|
936
|
+
if (value.kind === 'condition') {
|
|
937
|
+
const property = field(value.field);
|
|
938
|
+
return property?.capabilities.filter
|
|
939
|
+
? { ...value, field: property.key }
|
|
940
|
+
: undefined;
|
|
941
|
+
}
|
|
942
|
+
const expressions = value.expressions.map(filter);
|
|
943
|
+
// Dropping an unavailable condition would broaden a user's summary.
|
|
944
|
+
return expressions.some((item) => item === undefined)
|
|
945
|
+
? undefined
|
|
946
|
+
: { ...value, expressions: expressions };
|
|
947
|
+
};
|
|
948
|
+
const mappedFilter = filter(summary.filter);
|
|
949
|
+
return mappedFilter === undefined
|
|
950
|
+
? null
|
|
951
|
+
: {
|
|
952
|
+
...summary,
|
|
953
|
+
propertyKey: measure?.key ?? null,
|
|
954
|
+
filter: mappedFilter,
|
|
955
|
+
};
|
|
956
|
+
}
|
|
957
|
+
function studioSheet(name, rows, properties, owner, locale = 'en') {
|
|
958
|
+
return {
|
|
959
|
+
name,
|
|
960
|
+
headers: [
|
|
961
|
+
...(owner
|
|
962
|
+
? locale.startsWith('ar')
|
|
963
|
+
? ['السجل', 'المستوى']
|
|
964
|
+
: ['Record', 'Level']
|
|
965
|
+
: []),
|
|
966
|
+
...properties.map((property) => property.label),
|
|
967
|
+
],
|
|
968
|
+
rows: rows.map((row) => [
|
|
969
|
+
...(owner
|
|
970
|
+
? [row.owner?.name ?? row.name, row.owner?.levelName ?? '']
|
|
971
|
+
: []),
|
|
972
|
+
...properties.map((property) => {
|
|
973
|
+
const entity = studioEntity(row, property);
|
|
974
|
+
return entity ? mtEntityCellValues(entity).export : null;
|
|
975
|
+
}),
|
|
976
|
+
]),
|
|
977
|
+
};
|
|
978
|
+
}
|
|
979
|
+
/** Fetch unopened sections too. Nothing is exported from partial pages or another actor's cached scope. */
|
|
980
|
+
async function studioWorkbook(runtime, scope, keys, query, options, signal, progress, state = () => null) {
|
|
981
|
+
signal.throwIfAborted();
|
|
982
|
+
const locale = options.locale ?? 'en', catalog = await runtime.catalog(scope.levelId, signal, locale);
|
|
983
|
+
const rootRows = await runtime.rows(scope, catalog.properties.map((property) => property.key), signal, locale, options);
|
|
984
|
+
const summaryProperties = (options.summaries ?? []).map((summary, order) => {
|
|
985
|
+
const module = catalog.modules.find((item) => item.moduleKey === summary.moduleKey);
|
|
986
|
+
const property = module?.properties.find((item) => item.key === summary.propertyKey);
|
|
987
|
+
return {
|
|
988
|
+
propertyId: null,
|
|
989
|
+
key: summary.key,
|
|
990
|
+
normalizedKey: summary.key,
|
|
991
|
+
label: `${module?.name ?? ''} · ${property?.label ?? (locale.startsWith('ar') ? 'السجلات' : 'Records')} (${summary.aggregation})`,
|
|
992
|
+
viewType: 'Number',
|
|
993
|
+
configuration: null,
|
|
994
|
+
propertyConfiguration: null,
|
|
995
|
+
nestedProperties: [],
|
|
996
|
+
order,
|
|
997
|
+
capabilities: {
|
|
998
|
+
sort: true,
|
|
999
|
+
filter: true,
|
|
1000
|
+
group: true,
|
|
1001
|
+
aggregate: true,
|
|
1002
|
+
pivot: false,
|
|
1003
|
+
chart: true,
|
|
1004
|
+
export: true,
|
|
1005
|
+
},
|
|
1006
|
+
};
|
|
1007
|
+
});
|
|
1008
|
+
const properties = [...catalog.properties, ...summaryProperties];
|
|
1009
|
+
const matching = queryClientRows(rootRows, studioColumns(properties, keys.length ? keys : catalog.defaultColumnKeys), query, (row) => row.id);
|
|
1010
|
+
const owners = await runtime.owners(matching, options.includeDescendants ?? false, signal, locale);
|
|
1011
|
+
const selectedKeys = keys.length ? keys : catalog.defaultColumnKeys;
|
|
1012
|
+
const selectedProperties = selectedKeys.flatMap((key) => properties.filter((property) => property.key === key));
|
|
1013
|
+
const loaded = new Set(matching.map((row) => `${row.levelId}:${row.recordId}`));
|
|
1014
|
+
// Discovery only loads a child's defaults. Export explicitly requests the
|
|
1015
|
+
// selected semantic fields from that child's own authorized catalog.
|
|
1016
|
+
const records = await Promise.all(owners.map(async (owner) => {
|
|
1017
|
+
if (loaded.has(`${owner.levelId}:${owner.recordId}`))
|
|
1018
|
+
return owner;
|
|
1019
|
+
const ownCatalog = await runtime.catalog(owner.levelId, signal, locale);
|
|
1020
|
+
const fields = ownCatalog.properties
|
|
1021
|
+
.filter((property) => selectedProperties.some((selected) => selected.normalizedKey === property.normalizedKey))
|
|
1022
|
+
.map((property) => property.key);
|
|
1023
|
+
const summaries = (options.summaries ?? []).flatMap((summary) => {
|
|
1024
|
+
const mapped = remapSummary(summary, catalog.modules.find((item) => item.moduleKey === summary.moduleKey), ownCatalog.modules.find((item) => item.moduleKey === summary.moduleKey));
|
|
1025
|
+
return mapped ? [mapped] : [];
|
|
1026
|
+
});
|
|
1027
|
+
const [record] = await runtime.rows({ kind: 'record', levelId: owner.levelId, recordId: owner.recordId }, fields, signal, locale, { summaries });
|
|
1028
|
+
if (!record)
|
|
1029
|
+
throw new Error('An exported record is no longer readable.');
|
|
1030
|
+
return record;
|
|
1031
|
+
}));
|
|
1032
|
+
const recordsSheet = studioSheet(locale.startsWith('ar') ? 'السجلات' : 'Records', records, selectedProperties, false);
|
|
1033
|
+
const sheets = [
|
|
1034
|
+
{
|
|
1035
|
+
...recordsSheet,
|
|
1036
|
+
headers: [
|
|
1037
|
+
'ID',
|
|
1038
|
+
locale.startsWith('ar') ? 'المستوى' : 'Level',
|
|
1039
|
+
...recordsSheet.headers,
|
|
1040
|
+
],
|
|
1041
|
+
rows: recordsSheet.rows.map((row, index) => [
|
|
1042
|
+
records[index].recordId,
|
|
1043
|
+
records[index].levelName ?? catalog.name,
|
|
1044
|
+
...row,
|
|
1045
|
+
]),
|
|
1046
|
+
},
|
|
1047
|
+
];
|
|
1048
|
+
const modules = new Map();
|
|
1049
|
+
for (let index = 0; index < owners.length; index++) {
|
|
1050
|
+
signal.throwIfAborted();
|
|
1051
|
+
const owner = owners[index], workspace = await runtime.workspace(owner.levelId, owner.recordId, signal, locale);
|
|
1052
|
+
for (const module of workspace.modules) {
|
|
1053
|
+
let sheet = modules.get(module.moduleKey);
|
|
1054
|
+
if (!sheet) {
|
|
1055
|
+
sheet = { name: module.name, properties: new Map(), rows: [] };
|
|
1056
|
+
modules.set(module.moduleKey, sheet);
|
|
1057
|
+
}
|
|
1058
|
+
const saved = state(owner.levelId, module.moduleKey);
|
|
1059
|
+
const visible = saved
|
|
1060
|
+
? saved.columns
|
|
1061
|
+
.filter((column) => !column.hide)
|
|
1062
|
+
.map((column) => column.colId)
|
|
1063
|
+
: module.defaultColumnKeys;
|
|
1064
|
+
const columns = visible.flatMap((key) => module.properties.filter((property) => property.key === key));
|
|
1065
|
+
for (const property of columns)
|
|
1066
|
+
sheet.properties.set(property.normalizedKey, property);
|
|
1067
|
+
const moduleRows = await runtime.rows({
|
|
1068
|
+
kind: 'module',
|
|
1069
|
+
levelId: owner.levelId,
|
|
1070
|
+
recordId: owner.recordId,
|
|
1071
|
+
moduleKey: module.moduleKey,
|
|
1072
|
+
}, module.properties.map((property) => property.key), signal, locale);
|
|
1073
|
+
sheet.rows.push(...queryClientRows(moduleRows, studioColumns(module.properties, visible), { filters: saved?.filters, sort: saved?.sort }, (row) => row.id));
|
|
1074
|
+
}
|
|
1075
|
+
progress(Math.round(((index + 1) / Math.max(1, owners.length)) * 90));
|
|
1076
|
+
}
|
|
1077
|
+
for (const module of modules.values())
|
|
1078
|
+
sheets.push(studioSheet(module.name, module.rows, [...module.properties.values()], true, locale));
|
|
1079
|
+
signal.throwIfAborted();
|
|
1080
|
+
const workbook = await createExcelWorkbook(sheets, locale.startsWith('ar'));
|
|
1081
|
+
signal.throwIfAborted();
|
|
1082
|
+
return workbook;
|
|
1083
|
+
}
|
|
1084
|
+
|
|
1085
|
+
/**
|
|
1086
|
+
* The title the grid shows for a row. Root and connected-level records carry their name;
|
|
1087
|
+
* a module row usually does not (the backend sends `name: ""` and the title lives in the
|
|
1088
|
+
* module's `Name` property), so fall back to that property's displayed value.
|
|
1089
|
+
*/
|
|
1090
|
+
function studioRecordTitle(row) {
|
|
1091
|
+
if (row.name)
|
|
1092
|
+
return row.name;
|
|
1093
|
+
const property = row.properties?.find((item) => item.normalizedKey.toLowerCase() === 'name');
|
|
1094
|
+
const cell = property ? row.values[property.key] : undefined;
|
|
1095
|
+
for (const value of [cell?.value, cell?.raw]) {
|
|
1096
|
+
if (typeof value === 'string' && value.trim())
|
|
1097
|
+
return value;
|
|
1098
|
+
if (typeof value === 'number')
|
|
1099
|
+
return String(value);
|
|
1100
|
+
}
|
|
1101
|
+
return '';
|
|
1102
|
+
}
|
|
1103
|
+
/** The "Open record" row-menu item. Empty unless the host enabled `options.recordOpen`. */
|
|
1104
|
+
function studioOpenRecordItems(host, text, row) {
|
|
1105
|
+
if (!host?.recordOpenEnabled())
|
|
1106
|
+
return [];
|
|
1107
|
+
return [
|
|
1108
|
+
{
|
|
1109
|
+
name: text.text('openRecord'),
|
|
1110
|
+
icon: 'eye',
|
|
1111
|
+
action: () => host.openRecord(row),
|
|
1112
|
+
},
|
|
1113
|
+
];
|
|
1114
|
+
}
|
|
1115
|
+
|
|
1116
|
+
/**
|
|
1117
|
+
* Connection tabs (the connected child levels of a record) are hidden by
|
|
1118
|
+
* default, at the user's request (2026-10-25), until a better way to present
|
|
1119
|
+
* connections is found. The workspace contract still delivers `children`;
|
|
1120
|
+
* `ClientStudioOptions.showConnections` shows them again as the first tabs.
|
|
1121
|
+
*/
|
|
1122
|
+
const STUDIO_SHOW_CONNECTIONS = false;
|
|
1123
|
+
/** `Level:12` → 12, `ComponentSchema:7/Module:3` → 7. */
|
|
1124
|
+
function studioSchemaId(contextKey) {
|
|
1125
|
+
const id = Number(contextKey.split('/')[0].split(':')[1]);
|
|
1126
|
+
return Number.isSafeInteger(id) && id > 0 ? id : null;
|
|
1127
|
+
}
|
|
1128
|
+
function resolveClientStudioContext(value) {
|
|
1129
|
+
const context = typeof value === 'string'
|
|
1130
|
+
? { contextKey: value }
|
|
1131
|
+
: (value ?? { contextKey: '' });
|
|
1132
|
+
const contextKey = (context.contextKey ?? '').trim();
|
|
1133
|
+
const explicit = Number(context.schemaId);
|
|
1134
|
+
return {
|
|
1135
|
+
contextKey,
|
|
1136
|
+
schemaId: context.schemaId != null && Number.isSafeInteger(explicit) && explicit > 0
|
|
1137
|
+
? explicit
|
|
1138
|
+
: studioSchemaId(contextKey),
|
|
1139
|
+
filters: [...(context.filters ?? [])],
|
|
1140
|
+
key: context.key ?? '',
|
|
1141
|
+
};
|
|
1142
|
+
}
|
|
1143
|
+
const sameStudioContext = (a, b) => JSON.stringify(a) === JSON.stringify(b);
|
|
1144
|
+
/**
|
|
1145
|
+
* The host's context and options, provided by `mt-client-studio` to everything
|
|
1146
|
+
* inside it, including detail renderers created by the grid. Without a host
|
|
1147
|
+
* (unit tests, standalone pieces) Studio keeps the pplus `Level:{id}` contexts.
|
|
1148
|
+
*/
|
|
1149
|
+
class StudioHost {
|
|
1150
|
+
binding = signal({ context: () => null, options: () => ({}) }, ...(ngDevMode ? [{ debugName: "binding" }] : /* istanbul ignore next */ []));
|
|
1151
|
+
context = computed(() => this.binding().context(), { ...(ngDevMode ? { debugName: "context" } : /* istanbul ignore next */ {}), equal: (a, b) => a === b || (!!a && !!b && sameStudioContext(a, b)) });
|
|
1152
|
+
options = computed(() => this.binding().options(), ...(ngDevMode ? [{ debugName: "options" }] : /* istanbul ignore next */ []));
|
|
1153
|
+
recordOpenEnabled = computed(() => this.options().recordOpen === true, ...(ngDevMode ? [{ debugName: "recordOpenEnabled" }] : /* istanbul ignore next */ []));
|
|
1154
|
+
recordOpenHandler = null;
|
|
1155
|
+
showConnections = computed(() => this.options().showConnections ?? STUDIO_SHOW_CONNECTIONS, ...(ngDevMode ? [{ debugName: "showConnections" }] : /* istanbul ignore next */ []));
|
|
1156
|
+
bind(context, options, recordOpen) {
|
|
1157
|
+
this.binding.set({ context, options });
|
|
1158
|
+
this.recordOpenHandler = recordOpen ?? null;
|
|
1159
|
+
}
|
|
1160
|
+
/** Reports a row the user chose to open. Does nothing unless the host enabled `recordOpen`. */
|
|
1161
|
+
openRecord(row) {
|
|
1162
|
+
if (!this.recordOpenEnabled())
|
|
1163
|
+
return;
|
|
1164
|
+
this.recordOpenHandler?.({
|
|
1165
|
+
recordId: row.recordId,
|
|
1166
|
+
schemaId: row.levelId,
|
|
1167
|
+
name: studioRecordTitle(row),
|
|
1168
|
+
owner: row.owner,
|
|
1169
|
+
});
|
|
1170
|
+
}
|
|
1171
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: StudioHost, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1172
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: StudioHost });
|
|
1173
|
+
}
|
|
1174
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: StudioHost, decorators: [{
|
|
1175
|
+
type: Injectable
|
|
1176
|
+
}] });
|
|
1177
|
+
|
|
1178
|
+
/** Unsubscribing HttpClient aborts the actual transport, including delegated requests. */
|
|
1179
|
+
function studioRequest(request, signal) {
|
|
1180
|
+
return new Promise((resolve, reject) => {
|
|
1181
|
+
signal.throwIfAborted();
|
|
1182
|
+
const transport = {};
|
|
1183
|
+
let received = false;
|
|
1184
|
+
const abort = () => {
|
|
1185
|
+
transport.subscription?.unsubscribe();
|
|
1186
|
+
reject(signal.reason ?? new DOMException('Aborted', 'AbortError'));
|
|
1187
|
+
};
|
|
1188
|
+
signal.addEventListener('abort', abort, { once: true });
|
|
1189
|
+
transport.subscription = request.subscribe({
|
|
1190
|
+
next: (value) => {
|
|
1191
|
+
received = true;
|
|
1192
|
+
signal.removeEventListener('abort', abort);
|
|
1193
|
+
resolve(value);
|
|
1194
|
+
},
|
|
1195
|
+
error: (error) => {
|
|
1196
|
+
signal.removeEventListener('abort', abort);
|
|
1197
|
+
reject(error);
|
|
1198
|
+
},
|
|
1199
|
+
complete: () => {
|
|
1200
|
+
signal.removeEventListener('abort', abort);
|
|
1201
|
+
if (!received)
|
|
1202
|
+
reject(new Error('The Studio request completed without a response.'));
|
|
1203
|
+
},
|
|
1204
|
+
});
|
|
1205
|
+
if (signal.aborted)
|
|
1206
|
+
abort();
|
|
1207
|
+
});
|
|
1208
|
+
}
|
|
1209
|
+
/** Scoped to one Studio. Configuration lives separately in the wrapper's personal state. */
|
|
1210
|
+
class StudioApiService {
|
|
1211
|
+
http = inject(HttpClient);
|
|
1212
|
+
configuration = inject(MT_DATA_TABLE_CONFIGURATION);
|
|
1213
|
+
preferences = inject(MtTablePreferences);
|
|
1214
|
+
endpoints = inject(MT_CLIENT_STUDIO_ENDPOINTS);
|
|
1215
|
+
host = inject(StudioHost, { optional: true });
|
|
1216
|
+
revision = signal(0, ...(ngDevMode ? [{ debugName: "revision" }] : /* istanbul ignore next */ []));
|
|
1217
|
+
/** A host context change (key, filters, cache salt) is a new scope, like an actor change. */
|
|
1218
|
+
scopeIdentity = computed(() => JSON.stringify([
|
|
1219
|
+
this.configuration.identity(),
|
|
1220
|
+
this.revision(),
|
|
1221
|
+
this.host?.context() ?? null,
|
|
1222
|
+
]), ...(ngDevMode ? [{ debugName: "scopeIdentity" }] : /* istanbul ignore next */ []));
|
|
1223
|
+
refresh() {
|
|
1224
|
+
this.revision.update((value) => value + 1);
|
|
1225
|
+
this.ensureScope();
|
|
1226
|
+
}
|
|
1227
|
+
cacheIdentity;
|
|
1228
|
+
scheduler = new MtDatasetScheduler(4);
|
|
1229
|
+
runtime = new StudioRuntime(async (method, url, body, signal) => {
|
|
1230
|
+
const response = await this.schedule(this.http.request(method, url, { body }), signal);
|
|
1231
|
+
return response.data;
|
|
1232
|
+
}, {
|
|
1233
|
+
endpoints: this.endpoints,
|
|
1234
|
+
context: () => untracked(() => this.host?.context() ?? null),
|
|
1235
|
+
});
|
|
1236
|
+
workspaces = new MtDatasetCache(20);
|
|
1237
|
+
catalogs = new Map();
|
|
1238
|
+
datasets = new Map();
|
|
1239
|
+
requests = new Set();
|
|
1240
|
+
pending = new Map();
|
|
1241
|
+
clock = 0;
|
|
1242
|
+
constructor() {
|
|
1243
|
+
inject(DestroyRef).onDestroy(() => {
|
|
1244
|
+
for (const controller of this.requests)
|
|
1245
|
+
controller.abort();
|
|
1246
|
+
this.datasets.clear();
|
|
1247
|
+
this.catalogs.clear();
|
|
1248
|
+
this.workspaces.clear();
|
|
1249
|
+
});
|
|
1250
|
+
}
|
|
1251
|
+
async catalog(levelId, signal, locale = 'en') {
|
|
1252
|
+
const identity = this.ensureScope();
|
|
1253
|
+
signal.throwIfAborted();
|
|
1254
|
+
const key = `${levelId}:${locale}`;
|
|
1255
|
+
const cached = this.catalogs.get(key);
|
|
1256
|
+
if (cached)
|
|
1257
|
+
return cached;
|
|
1258
|
+
const catalog = await this.runtime.catalog(levelId, signal, locale);
|
|
1259
|
+
this.assertScope(identity);
|
|
1260
|
+
signal.throwIfAborted();
|
|
1261
|
+
this.catalogs.set(key, catalog);
|
|
1262
|
+
return catalog;
|
|
1263
|
+
}
|
|
1264
|
+
async workspace(levelId, recordId, signal, locale = 'en') {
|
|
1265
|
+
const identity = this.ensureScope();
|
|
1266
|
+
signal.throwIfAborted();
|
|
1267
|
+
const key = `${levelId}:${recordId}:${locale}`;
|
|
1268
|
+
const cached = this.workspaces.get(key);
|
|
1269
|
+
if (cached)
|
|
1270
|
+
return cached;
|
|
1271
|
+
const value = await this.runtime.workspace(levelId, recordId, signal, locale);
|
|
1272
|
+
this.assertScope(identity);
|
|
1273
|
+
signal.throwIfAborted();
|
|
1274
|
+
this.workspaces.set(key, value);
|
|
1275
|
+
return value;
|
|
1276
|
+
}
|
|
1277
|
+
source(scope, propertyKeys, capabilities, options = {}) {
|
|
1278
|
+
const identity = this.ensureScope();
|
|
1279
|
+
const scopeKey = JSON.stringify([
|
|
1280
|
+
identity,
|
|
1281
|
+
scope,
|
|
1282
|
+
options.includeDescendants ?? false,
|
|
1283
|
+
options.locale ?? 'en',
|
|
1284
|
+
]);
|
|
1285
|
+
const key = JSON.stringify([identity, scope, propertyKeys, options]);
|
|
1286
|
+
return {
|
|
1287
|
+
processing: 'client',
|
|
1288
|
+
scopeKey,
|
|
1289
|
+
viewScopeKey: JSON.stringify([
|
|
1290
|
+
scope,
|
|
1291
|
+
options.includeDescendants ?? false,
|
|
1292
|
+
]),
|
|
1293
|
+
key,
|
|
1294
|
+
capabilities,
|
|
1295
|
+
load: async (query, signal) => {
|
|
1296
|
+
this.assertScope(identity);
|
|
1297
|
+
signal.throwIfAborted();
|
|
1298
|
+
const request = studioQuery(scope, propertyKeys, query, options);
|
|
1299
|
+
let dataset = this.datasets.get(key);
|
|
1300
|
+
if (!dataset) {
|
|
1301
|
+
dataset = { pages: new Map(), active: 0, used: ++this.clock };
|
|
1302
|
+
this.datasets.set(key, dataset);
|
|
1303
|
+
}
|
|
1304
|
+
dataset.used = ++this.clock;
|
|
1305
|
+
const pageKey = JSON.stringify(request);
|
|
1306
|
+
const cached = dataset.pages.get(pageKey);
|
|
1307
|
+
if (cached) {
|
|
1308
|
+
signal.throwIfAborted();
|
|
1309
|
+
return cached;
|
|
1310
|
+
}
|
|
1311
|
+
const pendingKey = JSON.stringify([key, pageKey]);
|
|
1312
|
+
let pending = this.pending.get(pendingKey);
|
|
1313
|
+
if (pending?.controller.signal.aborted)
|
|
1314
|
+
pending = undefined;
|
|
1315
|
+
if (!pending) {
|
|
1316
|
+
const controller = new AbortController();
|
|
1317
|
+
dataset.active++;
|
|
1318
|
+
const entry = dataset;
|
|
1319
|
+
const locale = options.locale ?? 'en';
|
|
1320
|
+
const loading = scope.kind === 'records'
|
|
1321
|
+
? this.runtime.rootRows(scope, propertyKeys, controller.signal, locale, options)
|
|
1322
|
+
: this.runtime
|
|
1323
|
+
.rows(scope, propertyKeys, controller.signal, locale, options)
|
|
1324
|
+
.then((rows) => ({ rows, meta: undefined }));
|
|
1325
|
+
const result = loading
|
|
1326
|
+
.then(({ rows, meta }) => {
|
|
1327
|
+
this.assertScope(identity);
|
|
1328
|
+
controller.signal.throwIfAborted();
|
|
1329
|
+
const data = {
|
|
1330
|
+
rows,
|
|
1331
|
+
totalCount: rows.length,
|
|
1332
|
+
complete: true,
|
|
1333
|
+
...(meta ? { rootMeta: meta } : {}),
|
|
1334
|
+
};
|
|
1335
|
+
entry.pages.set(pageKey, data);
|
|
1336
|
+
while (entry.pages.size > 20)
|
|
1337
|
+
entry.pages.delete(entry.pages.keys().next().value);
|
|
1338
|
+
return data;
|
|
1339
|
+
})
|
|
1340
|
+
.finally(() => {
|
|
1341
|
+
if (this.pending.get(pendingKey)?.controller === controller)
|
|
1342
|
+
this.pending.delete(pendingKey);
|
|
1343
|
+
entry.active--;
|
|
1344
|
+
this.evict();
|
|
1345
|
+
});
|
|
1346
|
+
pending = { controller, result, consumers: 0 };
|
|
1347
|
+
this.pending.set(pendingKey, pending);
|
|
1348
|
+
}
|
|
1349
|
+
return this.consume(pending, signal);
|
|
1350
|
+
},
|
|
1351
|
+
};
|
|
1352
|
+
}
|
|
1353
|
+
consume(pending, signal) {
|
|
1354
|
+
pending.consumers++;
|
|
1355
|
+
return new Promise((resolve, reject) => {
|
|
1356
|
+
const abort = () => {
|
|
1357
|
+
cleanup();
|
|
1358
|
+
reject(signal.reason ?? new DOMException('Aborted', 'AbortError'));
|
|
1359
|
+
};
|
|
1360
|
+
const cleanup = () => {
|
|
1361
|
+
signal.removeEventListener('abort', abort);
|
|
1362
|
+
if (--pending.consumers === 0)
|
|
1363
|
+
pending.controller.abort();
|
|
1364
|
+
};
|
|
1365
|
+
signal.addEventListener('abort', abort, { once: true });
|
|
1366
|
+
if (signal.aborted) {
|
|
1367
|
+
abort();
|
|
1368
|
+
return;
|
|
1369
|
+
}
|
|
1370
|
+
pending.result.then((value) => {
|
|
1371
|
+
if (!signal.aborted) {
|
|
1372
|
+
cleanup();
|
|
1373
|
+
resolve(value);
|
|
1374
|
+
}
|
|
1375
|
+
}, (error) => {
|
|
1376
|
+
if (!signal.aborted) {
|
|
1377
|
+
cleanup();
|
|
1378
|
+
reject(error);
|
|
1379
|
+
}
|
|
1380
|
+
});
|
|
1381
|
+
});
|
|
1382
|
+
}
|
|
1383
|
+
retain(key) {
|
|
1384
|
+
this.ensureScope();
|
|
1385
|
+
let dataset = this.datasets.get(key);
|
|
1386
|
+
if (!dataset) {
|
|
1387
|
+
dataset = { pages: new Map(), active: 0, used: ++this.clock };
|
|
1388
|
+
this.datasets.set(key, dataset);
|
|
1389
|
+
}
|
|
1390
|
+
dataset.active++;
|
|
1391
|
+
dataset.used = ++this.clock;
|
|
1392
|
+
let released = false;
|
|
1393
|
+
return () => {
|
|
1394
|
+
if (released)
|
|
1395
|
+
return;
|
|
1396
|
+
released = true;
|
|
1397
|
+
dataset.active = Math.max(0, dataset.active - 1);
|
|
1398
|
+
dataset.used = ++this.clock;
|
|
1399
|
+
this.evict();
|
|
1400
|
+
};
|
|
1401
|
+
}
|
|
1402
|
+
evict() {
|
|
1403
|
+
const inactive = [...this.datasets]
|
|
1404
|
+
.filter(([, dataset]) => dataset.active === 0)
|
|
1405
|
+
.sort((a, b) => a[1].used - b[1].used);
|
|
1406
|
+
for (const [key] of inactive.slice(0, Math.max(0, inactive.length - 20)))
|
|
1407
|
+
this.datasets.delete(key);
|
|
1408
|
+
}
|
|
1409
|
+
async schedule(request, signal, identity = this.ensureScope()) {
|
|
1410
|
+
this.assertScope(identity);
|
|
1411
|
+
const controller = new AbortController();
|
|
1412
|
+
const abort = () => controller.abort(signal.reason);
|
|
1413
|
+
signal.addEventListener('abort', abort, { once: true });
|
|
1414
|
+
if (signal.aborted)
|
|
1415
|
+
abort();
|
|
1416
|
+
this.requests.add(controller);
|
|
1417
|
+
try {
|
|
1418
|
+
const value = await this.scheduler.run(() => studioRequest(request, controller.signal), controller.signal);
|
|
1419
|
+
this.assertScope(identity);
|
|
1420
|
+
return value;
|
|
1421
|
+
}
|
|
1422
|
+
finally {
|
|
1423
|
+
signal.removeEventListener('abort', abort);
|
|
1424
|
+
this.requests.delete(controller);
|
|
1425
|
+
}
|
|
1426
|
+
}
|
|
1427
|
+
exporter(scope, propertyKeys, options = {}, scopeKind = 'table', onProgress) {
|
|
1428
|
+
const identity = this.ensureScope();
|
|
1429
|
+
return {
|
|
1430
|
+
export: async (request, signal) => {
|
|
1431
|
+
this.assertScope(identity);
|
|
1432
|
+
if (request.format !== 'excel' || scopeKind === 'table')
|
|
1433
|
+
throw new Error('Individual tables export through their native grid API.');
|
|
1434
|
+
const report = (progress, state = 'processing') => {
|
|
1435
|
+
this.assertScope(identity);
|
|
1436
|
+
onProgress?.({
|
|
1437
|
+
id: 'local',
|
|
1438
|
+
state,
|
|
1439
|
+
progress,
|
|
1440
|
+
fileName: request.title,
|
|
1441
|
+
error: null,
|
|
1442
|
+
});
|
|
1443
|
+
};
|
|
1444
|
+
const blob = await studioWorkbook(this.runtime, scope, propertyKeys, request.query, options, signal, report, (level, module) => this.preferences.read({ level, module, role: 'studio-module' }));
|
|
1445
|
+
this.assertScope(identity);
|
|
1446
|
+
signal.throwIfAborted();
|
|
1447
|
+
await studioFile(blob, 'excel', `${request.title || 'Studio'}.xlsx`, signal);
|
|
1448
|
+
report(100, 'completed');
|
|
1449
|
+
},
|
|
1450
|
+
};
|
|
1451
|
+
}
|
|
1452
|
+
/** Partition synchronously: an actor change must never reuse an earlier actor's cache. */
|
|
1453
|
+
ensureScope() {
|
|
1454
|
+
const identity = this.scopeIdentity();
|
|
1455
|
+
if (identity !== this.cacheIdentity) {
|
|
1456
|
+
this.cacheIdentity = identity;
|
|
1457
|
+
for (const controller of this.requests)
|
|
1458
|
+
controller.abort();
|
|
1459
|
+
for (const pending of this.pending.values())
|
|
1460
|
+
pending.controller.abort();
|
|
1461
|
+
this.pending.clear();
|
|
1462
|
+
this.datasets.clear();
|
|
1463
|
+
this.catalogs.clear();
|
|
1464
|
+
this.workspaces.clear();
|
|
1465
|
+
this.runtime.clear();
|
|
1466
|
+
}
|
|
1467
|
+
return identity;
|
|
1468
|
+
}
|
|
1469
|
+
assertScope(identity) {
|
|
1470
|
+
if (this.ensureScope() !== identity)
|
|
1471
|
+
throw new DOMException('The Studio actor or application changed.', 'AbortError');
|
|
1472
|
+
}
|
|
1473
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: StudioApiService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1474
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: StudioApiService });
|
|
1475
|
+
}
|
|
1476
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: StudioApiService, decorators: [{
|
|
1477
|
+
type: Injectable
|
|
1478
|
+
}], ctorParameters: () => [] });
|
|
1479
|
+
|
|
1480
|
+
/**
|
|
1481
|
+
* The chart store of every Studio grid: the backend set (`MtServerChartStore` at the
|
|
1482
|
+
* `chartsEndpoint` of `provideClientStudio`, with the browser copy first), or the browser
|
|
1483
|
+
* only when the host sets `options.chartStore: 'local'`. The option is read on each call.
|
|
1484
|
+
*/
|
|
1485
|
+
class StudioChartStore {
|
|
1486
|
+
host = inject(StudioHost);
|
|
1487
|
+
server = inject(MtServerChartStore);
|
|
1488
|
+
local = inject(MtLocalChartStore);
|
|
1489
|
+
/** The store the Studio's options choose now. */
|
|
1490
|
+
get store() {
|
|
1491
|
+
return this.host.options().chartStore === 'local'
|
|
1492
|
+
? this.local
|
|
1493
|
+
: this.server;
|
|
1494
|
+
}
|
|
1495
|
+
read(key, onRemoteChange) {
|
|
1496
|
+
return this.store.read(key, onRemoteChange);
|
|
1497
|
+
}
|
|
1498
|
+
write(key, charts) {
|
|
1499
|
+
this.store.write(key, charts);
|
|
1500
|
+
}
|
|
1501
|
+
clear(key) {
|
|
1502
|
+
this.store.clear(key);
|
|
1503
|
+
}
|
|
1504
|
+
prefetch(hint) {
|
|
1505
|
+
return this.store.prefetch?.(hint) ?? Promise.resolve();
|
|
1506
|
+
}
|
|
1507
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: StudioChartStore, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1508
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: StudioChartStore });
|
|
1509
|
+
}
|
|
1510
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: StudioChartStore, decorators: [{
|
|
1511
|
+
type: Injectable
|
|
1512
|
+
}] });
|
|
1513
|
+
/**
|
|
1514
|
+
* `mt-client-studio`'s own providers: its grids keep their charts in `StudioChartStore`. Both
|
|
1515
|
+
* stores are provided here so they read the identity Studio sees (a route may provide one).
|
|
1516
|
+
*/
|
|
1517
|
+
function provideStudioChartStore() {
|
|
1518
|
+
return [
|
|
1519
|
+
MtLocalChartStore,
|
|
1520
|
+
{
|
|
1521
|
+
provide: MT_GRID_SERVER_CHARTS_OPTIONS,
|
|
1522
|
+
useFactory: () => ({
|
|
1523
|
+
endpoint: inject(MT_CLIENT_STUDIO_ENDPOINTS).chartsEndpoint,
|
|
1524
|
+
}),
|
|
1525
|
+
},
|
|
1526
|
+
MtServerChartStore,
|
|
1527
|
+
StudioChartStore,
|
|
1528
|
+
{ provide: MT_GRID_CHART_STORE, useExisting: StudioChartStore },
|
|
1529
|
+
];
|
|
1530
|
+
}
|
|
1531
|
+
|
|
1532
|
+
/** Product query and personalisation controller. Every view renders the one standard grid (mt-standard-grid). */
|
|
1533
|
+
class StudioGridController {
|
|
1534
|
+
source;
|
|
1535
|
+
columns;
|
|
1536
|
+
identity;
|
|
1537
|
+
fields;
|
|
1538
|
+
exporter;
|
|
1539
|
+
formats;
|
|
1540
|
+
title;
|
|
1541
|
+
enabled;
|
|
1542
|
+
preferences = inject(MtTablePreferences);
|
|
1543
|
+
print = inject(TableExportService);
|
|
1544
|
+
text = inject(MtTableText);
|
|
1545
|
+
api = signal(null, ...(ngDevMode ? [{ debugName: "api" }] : /* istanbul ignore next */ []));
|
|
1546
|
+
rows = signal([], ...(ngDevMode ? [{ debugName: "rows" }] : /* istanbul ignore next */ []));
|
|
1547
|
+
total = signal(0, ...(ngDevMode ? [{ debugName: "total" }] : /* istanbul ignore next */ []));
|
|
1548
|
+
complete = signal(false, ...(ngDevMode ? [{ debugName: "complete" }] : /* istanbul ignore next */ []));
|
|
1549
|
+
loading = signal(false, ...(ngDevMode ? [{ debugName: "loading" }] : /* istanbul ignore next */ []));
|
|
1550
|
+
failed = signal(false, ...(ngDevMode ? [{ debugName: "failed" }] : /* istanbul ignore next */ []));
|
|
1551
|
+
/** Successful loads so far; hosts announce the first one (`mt-client-studio (loaded)`). */
|
|
1552
|
+
loads = signal(0, ...(ngDevMode ? [{ debugName: "loads" }] : /* istanbul ignore next */ []));
|
|
1553
|
+
/** The root load behind the current rows (root records scope only); a new object for every completed load. */
|
|
1554
|
+
rootMeta = signal(undefined, ...(ngDevMode ? [{ debugName: "rootMeta" }] : /* istanbul ignore next */ []));
|
|
1555
|
+
exporting = signal(false, ...(ngDevMode ? [{ debugName: "exporting" }] : /* istanbul ignore next */ []));
|
|
1556
|
+
query = signal({ ...STUDIO_INITIAL_QUERY, limit: 50 }, ...(ngDevMode ? [{ debugName: "query" }] : /* istanbul ignore next */ []));
|
|
1557
|
+
selected = signal([], ...(ngDevMode ? [{ debugName: "selected" }] : /* istanbul ignore next */ []));
|
|
1558
|
+
statusBar = {
|
|
1559
|
+
panels: [
|
|
1560
|
+
'totalAndFilteredRowCount',
|
|
1561
|
+
'selectedRowCount',
|
|
1562
|
+
'aggregation',
|
|
1563
|
+
],
|
|
1564
|
+
};
|
|
1565
|
+
sideBar = computed(() => ({
|
|
1566
|
+
toolPanels: ['columns', 'filters'],
|
|
1567
|
+
position: this.text.language().startsWith('ar')
|
|
1568
|
+
? 'left'
|
|
1569
|
+
: 'right',
|
|
1570
|
+
}), ...(ngDevMode ? [{ debugName: "sideBar" }] : /* istanbul ignore next */ []));
|
|
1571
|
+
renderColumns = computed(() => this.complete()
|
|
1572
|
+
? this.columns()
|
|
1573
|
+
: this.columns().map((column) => ({
|
|
1574
|
+
...column,
|
|
1575
|
+
enableRowGroup: false,
|
|
1576
|
+
enableValue: false,
|
|
1577
|
+
enablePivot: false,
|
|
1578
|
+
chartDataType: 'excluded',
|
|
1579
|
+
})), ...(ngDevMode ? [{ debugName: "renderColumns" }] : /* istanbul ignore next */ []));
|
|
1580
|
+
/**
|
|
1581
|
+
* The grid's `chartPersistence`: the view and its data scope (`viewScopeKey`, the key
|
|
1582
|
+
* Studio's version-1 charts used, so they migrate). Studio charts the complete result
|
|
1583
|
+
* only, so a partial (server-paged) result keeps none; going partial or changing scope
|
|
1584
|
+
* removes the grid's charts without saving that removal.
|
|
1585
|
+
*/
|
|
1586
|
+
chartPersistence = computed(() => {
|
|
1587
|
+
const source = this.source();
|
|
1588
|
+
return source && this.complete()
|
|
1589
|
+
? {
|
|
1590
|
+
view: this.identity(),
|
|
1591
|
+
scope: source.viewScopeKey ?? source.scopeKey,
|
|
1592
|
+
}
|
|
1593
|
+
: null;
|
|
1594
|
+
}, { ...(ngDevMode ? { debugName: "chartPersistence" } : /* istanbul ignore next */ {}), equal: (a, b) => JSON.stringify(a) === JSON.stringify(b) });
|
|
1595
|
+
revision = signal(0, ...(ngDevMode ? [{ debugName: "revision" }] : /* istanbul ignore next */ []));
|
|
1596
|
+
hydrated = null;
|
|
1597
|
+
scope;
|
|
1598
|
+
serverScope = false;
|
|
1599
|
+
loadedQuery = '';
|
|
1600
|
+
restoring = false;
|
|
1601
|
+
exportController;
|
|
1602
|
+
rowId = (row) => row.id;
|
|
1603
|
+
constructor(source, columns, identity, fields, exporter, formats, title, enabled = () => true) {
|
|
1604
|
+
this.source = source;
|
|
1605
|
+
this.columns = columns;
|
|
1606
|
+
this.identity = identity;
|
|
1607
|
+
this.fields = fields;
|
|
1608
|
+
this.exporter = exporter;
|
|
1609
|
+
this.formats = formats;
|
|
1610
|
+
this.title = title;
|
|
1611
|
+
this.enabled = enabled;
|
|
1612
|
+
effect((cleanup) => {
|
|
1613
|
+
const source = this.source();
|
|
1614
|
+
const query = this.query();
|
|
1615
|
+
this.revision();
|
|
1616
|
+
const abort = new AbortController();
|
|
1617
|
+
cleanup(() => abort.abort());
|
|
1618
|
+
if (!this.enabled()) {
|
|
1619
|
+
this.rows.set([]);
|
|
1620
|
+
this.api.set(null);
|
|
1621
|
+
this.loading.set(false);
|
|
1622
|
+
return;
|
|
1623
|
+
}
|
|
1624
|
+
if (!source) {
|
|
1625
|
+
this.rootMeta.set(undefined);
|
|
1626
|
+
this.api.set(null);
|
|
1627
|
+
this.loading.set(false);
|
|
1628
|
+
this.scope = undefined;
|
|
1629
|
+
this.loadedQuery = '';
|
|
1630
|
+
this.rows.set([]);
|
|
1631
|
+
this.total.set(0);
|
|
1632
|
+
this.complete.set(false);
|
|
1633
|
+
return;
|
|
1634
|
+
}
|
|
1635
|
+
if (source.scopeKey !== this.scope) {
|
|
1636
|
+
this.scope = source.scopeKey;
|
|
1637
|
+
this.rootMeta.set(undefined);
|
|
1638
|
+
this.serverScope = false;
|
|
1639
|
+
this.rows.set([]);
|
|
1640
|
+
this.selected.set([]);
|
|
1641
|
+
this.complete.set(false);
|
|
1642
|
+
this.hydrated = null;
|
|
1643
|
+
if (query !== STUDIO_INITIAL_QUERY &&
|
|
1644
|
+
(query.offset ||
|
|
1645
|
+
query.search ||
|
|
1646
|
+
Object.keys(query.filters).length ||
|
|
1647
|
+
query.sort.length)) {
|
|
1648
|
+
this.query.set({ ...STUDIO_INITIAL_QUERY, limit: query.limit });
|
|
1649
|
+
return;
|
|
1650
|
+
}
|
|
1651
|
+
}
|
|
1652
|
+
const queryKey = JSON.stringify(query);
|
|
1653
|
+
if (queryKey !== this.loadedQuery) {
|
|
1654
|
+
this.rows.set([]);
|
|
1655
|
+
this.selected.set([]);
|
|
1656
|
+
this.loadedQuery = queryKey;
|
|
1657
|
+
}
|
|
1658
|
+
this.loading.set(true);
|
|
1659
|
+
this.failed.set(false);
|
|
1660
|
+
void loadMtTableResult(source, query, abort.signal, this.rowId).then((result) => {
|
|
1661
|
+
if (abort.signal.aborted)
|
|
1662
|
+
return;
|
|
1663
|
+
this.rootMeta.set(result
|
|
1664
|
+
.rootMeta);
|
|
1665
|
+
this.rows.set(result.rows);
|
|
1666
|
+
this.total.set(result.totalCount);
|
|
1667
|
+
this.serverScope ||= !result.complete;
|
|
1668
|
+
this.complete.set(result.complete && !this.serverScope);
|
|
1669
|
+
this.loading.set(false);
|
|
1670
|
+
this.loads.update((count) => count + 1);
|
|
1671
|
+
}, () => {
|
|
1672
|
+
if (!abort.signal.aborted) {
|
|
1673
|
+
this.failed.set(true);
|
|
1674
|
+
this.loading.set(false);
|
|
1675
|
+
}
|
|
1676
|
+
});
|
|
1677
|
+
});
|
|
1678
|
+
effect(() => {
|
|
1679
|
+
const api = this.api(), identity = this.identity(), key = this.preferences.key(identity);
|
|
1680
|
+
const stamp = JSON.stringify([
|
|
1681
|
+
key,
|
|
1682
|
+
this.source()?.viewScopeKey ?? this.source()?.scopeKey,
|
|
1683
|
+
]);
|
|
1684
|
+
this.columns();
|
|
1685
|
+
if (!api || !key || this.loading() || this.hydrated === stamp)
|
|
1686
|
+
return;
|
|
1687
|
+
untracked(() => {
|
|
1688
|
+
this.restoring = true;
|
|
1689
|
+
try {
|
|
1690
|
+
const state = this.preferences.read(identity);
|
|
1691
|
+
if (state)
|
|
1692
|
+
applyGridViewState(api, this.complete()
|
|
1693
|
+
? state
|
|
1694
|
+
: {
|
|
1695
|
+
...state,
|
|
1696
|
+
rowGroups: [],
|
|
1697
|
+
values: [],
|
|
1698
|
+
pivot: { enabled: false, columns: [] },
|
|
1699
|
+
});
|
|
1700
|
+
this.hydrated = stamp;
|
|
1701
|
+
this.requestFields();
|
|
1702
|
+
}
|
|
1703
|
+
finally {
|
|
1704
|
+
this.restoring = false;
|
|
1705
|
+
}
|
|
1706
|
+
this.changed();
|
|
1707
|
+
});
|
|
1708
|
+
});
|
|
1709
|
+
effect((cleanup) => {
|
|
1710
|
+
this.source();
|
|
1711
|
+
cleanup(() => this.exportController?.abort());
|
|
1712
|
+
});
|
|
1713
|
+
}
|
|
1714
|
+
ready(event) {
|
|
1715
|
+
this.hydrated = null;
|
|
1716
|
+
this.api.set(event.api);
|
|
1717
|
+
}
|
|
1718
|
+
retry() {
|
|
1719
|
+
this.revision.update((value) => value + 1);
|
|
1720
|
+
}
|
|
1721
|
+
getQuery() {
|
|
1722
|
+
const api = this.api();
|
|
1723
|
+
if (!api)
|
|
1724
|
+
return this.query();
|
|
1725
|
+
const state = captureGridViewState(api);
|
|
1726
|
+
return {
|
|
1727
|
+
...this.query(),
|
|
1728
|
+
sort: state.sort,
|
|
1729
|
+
filters: state.filters,
|
|
1730
|
+
search: api.getQuickFilter() ?? '',
|
|
1731
|
+
groupColumns: state.rowGroups,
|
|
1732
|
+
valueColumns: state.values,
|
|
1733
|
+
pivotColumns: state.pivot.enabled ? state.pivot.columns : [],
|
|
1734
|
+
};
|
|
1735
|
+
}
|
|
1736
|
+
changed() {
|
|
1737
|
+
const api = this.api();
|
|
1738
|
+
if (!api || this.restoring || !this.hydrated)
|
|
1739
|
+
return;
|
|
1740
|
+
this.preferences.write(this.identity(), captureGridViewState(api));
|
|
1741
|
+
this.requestFields();
|
|
1742
|
+
if (!this.complete()) {
|
|
1743
|
+
const next = { ...this.getQuery(), offset: 0 };
|
|
1744
|
+
if (JSON.stringify(next) !== JSON.stringify(this.query()))
|
|
1745
|
+
this.query.set(next);
|
|
1746
|
+
}
|
|
1747
|
+
}
|
|
1748
|
+
requestFields() {
|
|
1749
|
+
const api = this.api();
|
|
1750
|
+
const visible = api
|
|
1751
|
+
?.getColumnState()
|
|
1752
|
+
.filter((column) => !column.hide)
|
|
1753
|
+
.map((column) => column.colId) ?? [];
|
|
1754
|
+
this.fields([
|
|
1755
|
+
...new Set([
|
|
1756
|
+
...visible,
|
|
1757
|
+
...(api?.getRowGroupColumns() ?? []),
|
|
1758
|
+
...(api?.getValueColumns() ?? []),
|
|
1759
|
+
...(api?.getPivotColumns() ?? []),
|
|
1760
|
+
...Object.keys(api?.getFilterModel() ?? {}),
|
|
1761
|
+
...(api?.getSortModel().map((sort) => sort.colId) ?? []),
|
|
1762
|
+
...studioChartColumns(api?.getChartStates() ?? []),
|
|
1763
|
+
]),
|
|
1764
|
+
]);
|
|
1765
|
+
}
|
|
1766
|
+
page(event) {
|
|
1767
|
+
if (!this.complete()) {
|
|
1768
|
+
const query = this.query(), next = {
|
|
1769
|
+
...query,
|
|
1770
|
+
offset: event.currentPage * event.pageSize,
|
|
1771
|
+
limit: event.pageSize,
|
|
1772
|
+
};
|
|
1773
|
+
if (next.offset !== query.offset || next.limit !== query.limit)
|
|
1774
|
+
this.query.set(next);
|
|
1775
|
+
}
|
|
1776
|
+
}
|
|
1777
|
+
selection() {
|
|
1778
|
+
this.selected.set(this.api()?.getSelectedRows() ?? []);
|
|
1779
|
+
}
|
|
1780
|
+
comparisonRows() {
|
|
1781
|
+
const api = this.api();
|
|
1782
|
+
if (!api)
|
|
1783
|
+
return [];
|
|
1784
|
+
// Explicit row checkboxes take precedence over a retained cell range.
|
|
1785
|
+
const selected = api.getSelectedRows();
|
|
1786
|
+
if (selected.length)
|
|
1787
|
+
return selected;
|
|
1788
|
+
const indices = new Set();
|
|
1789
|
+
for (const range of api.getCellRanges()) {
|
|
1790
|
+
for (let index = Math.min(range.startRow, range.endRow); index <= Math.max(range.startRow, range.endRow); index++) {
|
|
1791
|
+
indices.add(index);
|
|
1792
|
+
}
|
|
1793
|
+
}
|
|
1794
|
+
const rows = new Map();
|
|
1795
|
+
for (const index of [...indices].sort((a, b) => a - b)) {
|
|
1796
|
+
const node = api.getDisplayedRowAtIndex(index);
|
|
1797
|
+
if (node?.data && !node.group && !node.detail && !node.footer)
|
|
1798
|
+
rows.set(node.id, node.data);
|
|
1799
|
+
}
|
|
1800
|
+
return [...rows.values()];
|
|
1801
|
+
}
|
|
1802
|
+
matchingRows() {
|
|
1803
|
+
const rows = new Map();
|
|
1804
|
+
this.api()?.forEachNodeAfterFilterAndSort((node) => {
|
|
1805
|
+
if (node.detail || node.footer)
|
|
1806
|
+
return;
|
|
1807
|
+
for (const leaf of node.group ? (node.allLeafChildren ?? []) : [node])
|
|
1808
|
+
if (leaf.data)
|
|
1809
|
+
rows.set(leaf.id, leaf.data);
|
|
1810
|
+
});
|
|
1811
|
+
return [...rows.values()];
|
|
1812
|
+
}
|
|
1813
|
+
/** A chart was restored, made or changed: load the columns it shows. */
|
|
1814
|
+
chartsChanged() {
|
|
1815
|
+
this.requestFields();
|
|
1816
|
+
}
|
|
1817
|
+
/** The standard Export menu shows once the complete result is loaded. */
|
|
1818
|
+
exportReady = computed(() => this.complete() && !this.loading() && !this.failed() && !this.exporting(), ...(ngDevMode ? [{ debugName: "exportReady" }] : /* istanbul ignore next */ []));
|
|
1819
|
+
/** The catalog's export formats in the standard menu's terms (print is its PDF). */
|
|
1820
|
+
exportFormats = computed(() => {
|
|
1821
|
+
const offered = new Set(this.formats().map((format) => (format === 'print' ? 'pdf' : format)));
|
|
1822
|
+
return ['csv', 'excel', 'pdf'].filter((format) => offered.has(format));
|
|
1823
|
+
}, ...(ngDevMode ? [{ debugName: "exportFormats" }] : /* istanbul ignore next */ []));
|
|
1824
|
+
/** The standard Export menu runs Studio's own export (title, entity labels, print). */
|
|
1825
|
+
exportAs = (format) => {
|
|
1826
|
+
void this.export(format === 'pdf' && !this.formats().includes('pdf') ? 'print' : format);
|
|
1827
|
+
};
|
|
1828
|
+
async export(format) {
|
|
1829
|
+
this.exportController?.abort();
|
|
1830
|
+
const controller = (this.exportController = new AbortController());
|
|
1831
|
+
this.exporting.set(true);
|
|
1832
|
+
try {
|
|
1833
|
+
const api = this.api();
|
|
1834
|
+
if (api && this.complete()) {
|
|
1835
|
+
const params = {
|
|
1836
|
+
fileName: this.title(),
|
|
1837
|
+
processCellCallback: (mtEntityExportValue),
|
|
1838
|
+
};
|
|
1839
|
+
if (format === 'csv')
|
|
1840
|
+
api.exportDataAsCsv(params);
|
|
1841
|
+
else if (format === 'excel')
|
|
1842
|
+
await api.exportDataAsExcel(params);
|
|
1843
|
+
else
|
|
1844
|
+
this.print.printPdf(mtTablePrintConfiguration(api, this.columns(), this.title()));
|
|
1845
|
+
return;
|
|
1846
|
+
}
|
|
1847
|
+
await this.exporter().export({
|
|
1848
|
+
format,
|
|
1849
|
+
title: this.title(),
|
|
1850
|
+
query: this.getQuery(),
|
|
1851
|
+
rows: this.rows(),
|
|
1852
|
+
complete: this.complete(),
|
|
1853
|
+
visibleColumns: this.api()
|
|
1854
|
+
?.getColumnState()
|
|
1855
|
+
.filter((column) => !column.hide)
|
|
1856
|
+
.map((column) => column.colId) ?? [],
|
|
1857
|
+
}, controller.signal);
|
|
1858
|
+
}
|
|
1859
|
+
catch {
|
|
1860
|
+
if (!controller.signal.aborted)
|
|
1861
|
+
this.failed.set(true);
|
|
1862
|
+
}
|
|
1863
|
+
finally {
|
|
1864
|
+
if (this.exportController === controller)
|
|
1865
|
+
this.exporting.set(false);
|
|
1866
|
+
}
|
|
1867
|
+
}
|
|
1868
|
+
}
|
|
1869
|
+
/**
|
|
1870
|
+
* The columns a chart shows: its category, its series (a synthetic measure's counted
|
|
1871
|
+
* column, never the measure id itself) and its ranges.
|
|
1872
|
+
*/
|
|
1873
|
+
function studioChartColumns(states) {
|
|
1874
|
+
const columns = new Set();
|
|
1875
|
+
for (const state of states) {
|
|
1876
|
+
if (state.categoryId && !state.categoryId.startsWith('__'))
|
|
1877
|
+
columns.add(state.categoryId);
|
|
1878
|
+
for (const id of state.seriesIds ?? []) {
|
|
1879
|
+
const measure = chartMeasure(id);
|
|
1880
|
+
if (!measure)
|
|
1881
|
+
columns.add(id);
|
|
1882
|
+
else if (measure.columnId)
|
|
1883
|
+
columns.add(measure.columnId);
|
|
1884
|
+
}
|
|
1885
|
+
for (const range of state.ranges)
|
|
1886
|
+
for (const column of range.columns)
|
|
1887
|
+
columns.add(column);
|
|
1888
|
+
}
|
|
1889
|
+
return [...columns];
|
|
1890
|
+
}
|
|
1891
|
+
|
|
1892
|
+
/** Share the available detail space at every depth; scrolling never changes its budget. */
|
|
1893
|
+
function observeStudioDetailSize(host, resized, minimumHeight = 0) {
|
|
1894
|
+
const viewport = host.closest('.mt-grid-viewport');
|
|
1895
|
+
const detail = host.closest('.mt-grid-detail-cell');
|
|
1896
|
+
const record = detail?.parentElement?.previousElementSibling;
|
|
1897
|
+
const header = viewport?.querySelector('.mt-grid-header-band');
|
|
1898
|
+
const workspace = host.closest('mt-client-studio-record-workspace');
|
|
1899
|
+
const ownViewport = host.querySelector('.mt-grid-viewport');
|
|
1900
|
+
const ownHeader = host.querySelector('.mt-grid-header-band');
|
|
1901
|
+
const headerHeight = (band) => band.getBoundingClientRect().height ||
|
|
1902
|
+
band.querySelector('.mt-grid-header').getBoundingClientRect().height;
|
|
1903
|
+
const resize = () => {
|
|
1904
|
+
const renderedHeight = host.getBoundingClientRect().height;
|
|
1905
|
+
if (!viewport || !detail || !record || !header) {
|
|
1906
|
+
resized(null, renderedHeight);
|
|
1907
|
+
return;
|
|
1908
|
+
}
|
|
1909
|
+
const minimum = Math.ceil(Math.max(minimumHeight, renderedHeight -
|
|
1910
|
+
ownViewport.clientHeight +
|
|
1911
|
+
headerHeight(ownHeader) +
|
|
1912
|
+
44));
|
|
1913
|
+
const aboveTable = host.getBoundingClientRect().top - detail.getBoundingClientRect().top;
|
|
1914
|
+
const padding = parseFloat(getComputedStyle(detail).paddingBottom);
|
|
1915
|
+
resized(Math.max(minimum, Math.floor(viewport.clientHeight -
|
|
1916
|
+
headerHeight(header) -
|
|
1917
|
+
record.getBoundingClientRect().height -
|
|
1918
|
+
aboveTable -
|
|
1919
|
+
padding -
|
|
1920
|
+
2)), renderedHeight);
|
|
1921
|
+
};
|
|
1922
|
+
const observer = new ResizeObserver(resize);
|
|
1923
|
+
for (const element of [host, ownHeader, viewport, header, record, workspace])
|
|
1924
|
+
if (element)
|
|
1925
|
+
observer.observe(element);
|
|
1926
|
+
resize();
|
|
1927
|
+
return () => observer.disconnect();
|
|
1928
|
+
}
|
|
1929
|
+
|
|
1930
|
+
/** Headings and section space stay present while off-screen grid instances are released. */
|
|
1931
|
+
class StudioViewport {
|
|
1932
|
+
near = signal(false, ...(ngDevMode ? [{ debugName: "near" }] : /* istanbul ignore next */ []));
|
|
1933
|
+
constructor() {
|
|
1934
|
+
const host = inject(ElementRef), destroy = inject(DestroyRef);
|
|
1935
|
+
afterNextRender(() => {
|
|
1936
|
+
const observer = new IntersectionObserver((entries) => this.near.set(entries.some((entry) => entry.isIntersecting)), { rootMargin: '600px 0px' });
|
|
1937
|
+
observer.observe(host.nativeElement);
|
|
1938
|
+
destroy.onDestroy(() => observer.disconnect());
|
|
1939
|
+
});
|
|
1940
|
+
}
|
|
1941
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: StudioViewport, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
1942
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.8", type: StudioViewport, isStandalone: true, selector: "[mtClientStudioViewport]", exportAs: ["studioViewport"], ngImport: i0 });
|
|
1943
|
+
}
|
|
1944
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: StudioViewport, decorators: [{
|
|
1945
|
+
type: Directive,
|
|
1946
|
+
args: [{ selector: '[mtClientStudioViewport]', exportAs: 'studioViewport' }]
|
|
1947
|
+
}], ctorParameters: () => [] });
|
|
1948
|
+
|
|
1949
|
+
const LABELS = {
|
|
1950
|
+
count: ['Count', 'العدد'],
|
|
1951
|
+
missingValues: ['missing values', 'قيم مفقودة'],
|
|
1952
|
+
sum: ['Sum', 'المجموع'],
|
|
1953
|
+
avg: ['Average', 'المتوسط'],
|
|
1954
|
+
min: ['Minimum', 'الحد الأدنى'],
|
|
1955
|
+
max: ['Maximum', 'الحد الأقصى'],
|
|
1956
|
+
useModuleFilters: [
|
|
1957
|
+
'Use this module’s current filters',
|
|
1958
|
+
'استخدام عوامل تصفية الوحدة الحالية',
|
|
1959
|
+
],
|
|
1960
|
+
cancel: ['Cancel', 'إلغاء'],
|
|
1961
|
+
excel: ['Excel workbook', 'مصنف إكسل'],
|
|
1962
|
+
owner: ['Owning record', 'السجل المالك'],
|
|
1963
|
+
level: ['Level', 'المستوى'],
|
|
1964
|
+
summaries: ['Module summaries', 'ملخصات الوحدات'],
|
|
1965
|
+
measure: ['Measure', 'المقياس'],
|
|
1966
|
+
addSummary: ['Add summary', 'إضافة ملخص'],
|
|
1967
|
+
remove: ['Remove', 'إزالة'],
|
|
1968
|
+
title: ['Studio', 'استوديو'],
|
|
1969
|
+
modules: ['Record modules', 'وحدات السجل'],
|
|
1970
|
+
children: ['Connected levels', 'المستويات المرتبطة'],
|
|
1971
|
+
loading: ['Loading…', 'جارٍ التحميل…'],
|
|
1972
|
+
failed: ['Unable to load this section.', 'تعذر تحميل هذا القسم.'],
|
|
1973
|
+
retry: ['Try again', 'إعادة المحاولة'],
|
|
1974
|
+
refresh: ['Refresh records', 'تحديث السجلات'],
|
|
1975
|
+
empty: [
|
|
1976
|
+
'No readable connections or modules are configured for this record.',
|
|
1977
|
+
'لا توجد مستويات مرتبطة أو وحدات متاحة للقراءة لهذا السجل.',
|
|
1978
|
+
],
|
|
1979
|
+
records: ['Records', 'السجلات'],
|
|
1980
|
+
exportRecord: ['Export record and modules', 'تصدير السجل ووحداته'],
|
|
1981
|
+
exportLevel: ['Export level', 'تصدير المستوى'],
|
|
1982
|
+
descendants: ['Include descendants', 'تضمين المستويات الفرعية'],
|
|
1983
|
+
exportFailed: ['Export failed. Try again.', 'تعذر التصدير. حاول مرة أخرى.'],
|
|
1984
|
+
analysis: ['Analyse a module across records', 'تحليل وحدة عبر السجلات'],
|
|
1985
|
+
selectModule: ['Choose a module', 'اختر وحدة'],
|
|
1986
|
+
back: ['Back to records', 'العودة إلى السجلات'],
|
|
1987
|
+
comparing: ['Compare records', 'مقارنة السجلات'],
|
|
1988
|
+
compare: ['Compare selected records', 'مقارنة السجلات المحددة'],
|
|
1989
|
+
openRecord: ['Open record', 'فتح السجل'],
|
|
1990
|
+
selectForComparison: [
|
|
1991
|
+
'Select at least 2 records using checkboxes or highlight cells across records, then right-click to compare.',
|
|
1992
|
+
'حدد سجلين على الأقل بمربعات الاختيار أو ظلّل خلايا عبر السجلات، ثم انقر بزر الفأرة الأيمن للمقارنة.',
|
|
1993
|
+
],
|
|
1994
|
+
comparisonHint: [
|
|
1995
|
+
'Properties are shown in rows. Each column is one selected record.',
|
|
1996
|
+
'تظهر الخصائص في الصفوف، ويمثل كل عمود سجلاً محدداً.',
|
|
1997
|
+
],
|
|
1998
|
+
property: ['Property', 'الخاصية'],
|
|
1999
|
+
close: ['Close', 'إغلاق'],
|
|
2000
|
+
readOnly: ['Read-only exploration', 'استعراض للقراءة فقط'],
|
|
2001
|
+
};
|
|
2002
|
+
/** `components.clientComponents.studio.*` (components i18n); the built-in labels are the fallback. */
|
|
2003
|
+
class StudioText {
|
|
2004
|
+
transloco = inject(TranslocoService);
|
|
2005
|
+
language = toSignal(this.transloco.langChanges$, {
|
|
2006
|
+
initialValue: this.transloco.getActiveLang(),
|
|
2007
|
+
});
|
|
2008
|
+
text(key) {
|
|
2009
|
+
const language = this.language(), path = `components.clientComponents.studio.${key}`;
|
|
2010
|
+
const value = this.transloco.translate(path);
|
|
2011
|
+
return value !== path
|
|
2012
|
+
? value
|
|
2013
|
+
: LABELS[key][language.startsWith('ar') ? 1 : 0];
|
|
2014
|
+
}
|
|
2015
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: StudioText, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2016
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: StudioText });
|
|
2017
|
+
}
|
|
2018
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: StudioText, decorators: [{
|
|
2019
|
+
type: Injectable
|
|
2020
|
+
}] });
|
|
2021
|
+
|
|
2022
|
+
/** Owns the contextual comparison and closes its snapshot with the owning scope. */
|
|
2023
|
+
class StudioComparisonController {
|
|
2024
|
+
rows;
|
|
2025
|
+
properties;
|
|
2026
|
+
available;
|
|
2027
|
+
modal = inject(ModalService);
|
|
2028
|
+
text = inject(StudioText);
|
|
2029
|
+
destroyRef = inject(DestroyRef);
|
|
2030
|
+
dialog = null;
|
|
2031
|
+
constructor(rows, properties, available, scope) {
|
|
2032
|
+
this.rows = rows;
|
|
2033
|
+
this.properties = properties;
|
|
2034
|
+
this.available = available;
|
|
2035
|
+
effect(() => {
|
|
2036
|
+
scope();
|
|
2037
|
+
untracked(() => this.close());
|
|
2038
|
+
});
|
|
2039
|
+
this.destroyRef.onDestroy(() => this.close());
|
|
2040
|
+
}
|
|
2041
|
+
menuItem() {
|
|
2042
|
+
return {
|
|
2043
|
+
name: `${this.text.text('compare')} (${this.rows().length})`,
|
|
2044
|
+
icon: 'columns',
|
|
2045
|
+
tooltip: this.text.text('selectForComparison'),
|
|
2046
|
+
disabled: !this.canCompare(),
|
|
2047
|
+
action: () => this.open(),
|
|
2048
|
+
};
|
|
2049
|
+
}
|
|
2050
|
+
canCompare() {
|
|
2051
|
+
const count = this.rows().length;
|
|
2052
|
+
return this.available() && count >= 2;
|
|
2053
|
+
}
|
|
2054
|
+
open() {
|
|
2055
|
+
// Recheck when invoked: selection or scope may have changed since menu creation.
|
|
2056
|
+
if (!this.canCompare())
|
|
2057
|
+
return;
|
|
2058
|
+
this.close();
|
|
2059
|
+
const rows = [...this.rows()];
|
|
2060
|
+
const dialog = this.modal.openModal(StudioComparison, 'dialog', {
|
|
2061
|
+
header: `${this.text.text('comparing')} · ${rows.length}`,
|
|
2062
|
+
width: 'min(96rem, calc(100vw - 2rem))',
|
|
2063
|
+
modal: true,
|
|
2064
|
+
draggable: false,
|
|
2065
|
+
resizable: false,
|
|
2066
|
+
inputValues: { rows, properties: [...this.properties()] },
|
|
2067
|
+
});
|
|
2068
|
+
this.dialog = dialog;
|
|
2069
|
+
merge(dialog.onClose, dialog.onDestroy)
|
|
2070
|
+
.pipe(take(1), takeUntilDestroyed(this.destroyRef))
|
|
2071
|
+
.subscribe(() => {
|
|
2072
|
+
if (this.dialog === dialog)
|
|
2073
|
+
this.dialog = null;
|
|
2074
|
+
});
|
|
2075
|
+
}
|
|
2076
|
+
close() {
|
|
2077
|
+
// Scope changes and owner teardown must remove the snapshot immediately.
|
|
2078
|
+
this.dialog?.destroy();
|
|
2079
|
+
this.dialog = null;
|
|
2080
|
+
}
|
|
2081
|
+
}
|
|
2082
|
+
class StudioComparison {
|
|
2083
|
+
rows = input.required(...(ngDevMode ? [{ debugName: "rows" }] : /* istanbul ignore next */ []));
|
|
2084
|
+
properties = input.required(...(ngDevMode ? [{ debugName: "properties" }] : /* istanbul ignore next */ []));
|
|
2085
|
+
text = inject(StudioText);
|
|
2086
|
+
height = signal(this.viewportHeight(), ...(ngDevMode ? [{ debugName: "height" }] : /* istanbul ignore next */ []));
|
|
2087
|
+
resize() {
|
|
2088
|
+
this.height.set(this.viewportHeight());
|
|
2089
|
+
}
|
|
2090
|
+
viewportHeight() {
|
|
2091
|
+
return Math.max(240, Math.min(600, window.innerHeight - 240));
|
|
2092
|
+
}
|
|
2093
|
+
fields = computed(() => this.properties().map((property) => ({
|
|
2094
|
+
id: property.key,
|
|
2095
|
+
property,
|
|
2096
|
+
name: property.label,
|
|
2097
|
+
})), ...(ngDevMode ? [{ debugName: "fields" }] : /* istanbul ignore next */ []));
|
|
2098
|
+
fieldId = (field) => field.id;
|
|
2099
|
+
columns = computed(() => [
|
|
2100
|
+
{
|
|
2101
|
+
field: 'name',
|
|
2102
|
+
headerName: this.text.text('property'),
|
|
2103
|
+
pinned: this.text.language().startsWith('ar') ? 'right' : 'left',
|
|
2104
|
+
width: 220,
|
|
2105
|
+
suppressSizeToFit: true,
|
|
2106
|
+
},
|
|
2107
|
+
...this.rows().map((row) => ({
|
|
2108
|
+
colId: `record-${row.id}`,
|
|
2109
|
+
headerName: this.rows().filter((other) => other.name === row.name).length > 1
|
|
2110
|
+
? `${row.name} · #${row.recordId}`
|
|
2111
|
+
: row.name,
|
|
2112
|
+
width: 240,
|
|
2113
|
+
minWidth: 180,
|
|
2114
|
+
valueGetter: ({ data }) => {
|
|
2115
|
+
const value = studioEntity(row, data.property);
|
|
2116
|
+
return value ? mtEntityCellValues(value).display : '';
|
|
2117
|
+
},
|
|
2118
|
+
cellRenderer: (MtDataTableEntityCell),
|
|
2119
|
+
cellRendererParams: {
|
|
2120
|
+
entity: (field) => studioEntity(row, field.property),
|
|
2121
|
+
},
|
|
2122
|
+
})),
|
|
2123
|
+
], ...(ngDevMode ? [{ debugName: "columns" }] : /* istanbul ignore next */ []));
|
|
2124
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: StudioComparison, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2125
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.2.8", type: StudioComparison, isStandalone: true, selector: "mt-client-studio-comparison", inputs: { rows: { classPropertyName: "rows", publicName: "rows", isSignal: true, isRequired: true, transformFunction: null }, properties: { classPropertyName: "properties", publicName: "properties", isSignal: true, isRequired: true, transformFunction: null } }, host: { listeners: { "window:resize": "resize()" } }, providers: [StudioText, provideEntityListTablePreview()], ngImport: i0, template: "<section class=\"studio-comparison\">\r\n <p class=\"studio-comparison-hint\">{{ text.text(\"comparisonHint\") }}</p>\r\n <mt-standard-grid\r\n [rows]=\"fields()\"\r\n [columns]=\"columns()\"\r\n [rowId]=\"fieldId\"\r\n [label]=\"text.text('comparing')\"\r\n [height]=\"height()\"\r\n [paged]=\"false\"\r\n [exportName]=\"text.text('comparing')\"\r\n />\r\n</section>\r\n", styles: [":host{display:block;min-width:0;font:inherit;color:var(--p-text-color, #27364b)}.studio-workspace{display:grid;gap:12px;padding:0;min-width:0}.studio-empty{color:var(--p-text-muted-color, #667085);font-size:12px}.studio-group-heading{margin:12px 0 0;padding-inline-start:10px;border-inline-start:3px solid var(--p-primary-color, #2aaec0);font-size:15px;font-weight:600}.studio-module,.studio-child-level{min-width:0;scroll-margin-block-start:20px}.studio-grid-placeholder{min-height:420px;display:grid;align-content:center;justify-items:center;gap:12px;border:1px solid var(--p-content-border-color, #e4e7ec);border-radius:6px;color:var(--p-text-muted-color, #667085);background:var(--p-content-background, #fff)}.studio-section-error{display:flex;min-height:120px;flex-wrap:wrap;align-items:center;justify-content:center;gap:16px}@media(max-width:1100px){.studio-workspace{gap:0}}@media(max-width:640px){.studio-workspace{padding:0;gap:0}:host .studio-command-content{position:fixed;inset-inline:12px;inset-block-start:20dvh;min-width:0;max-height:60dvh}}.studio-commands{display:flex;align-items:center;flex-wrap:wrap;gap:.75rem;margin-block:.75rem}.studio-command-menu{position:relative;font-size:.875rem}.studio-command-menu>summary{cursor:pointer;padding:.5rem .75rem;border:1px solid var(--p-content-border-color, #ddd);border-radius:.375rem}.studio-command-content{position:absolute;inset-block-start:100%;inset-inline-end:0;z-index:30;min-width:18rem;max-height:24rem;overflow:auto;background:var(--p-content-background, white);color:var(--p-text-color, #334155);padding:.75rem;border:1px solid var(--p-content-border-color, #ddd);border-radius:.375rem;display:grid;gap:.75rem}.studio-command-content label{display:flex;align-items:center;gap:.5rem;flex-wrap:wrap}.studio-command-content select{width:100%;padding:.5rem;border:1px solid var(--p-content-border-color, #ddd);background:inherit;color:inherit;border-radius:.375rem}.studio-command-content button{text-align:start;padding:.5rem;cursor:pointer}.studio-comparison{min-width:0}.studio-comparison-hint{margin:0 0 1rem;color:var(--p-text-muted-color, #667085);font-size:.875rem}button:focus-visible,summary:focus-visible,select:focus-visible{outline:2px solid var(--p-primary-color, #2aaec0);outline-offset:2px}\n"], dependencies: [{ kind: "component", type: MtStandardGridComponent, selector: "mt-standard-grid", inputs: ["rows", "columns", "rowId", "label", "loading", "height", "rowHeight", "selection", "exportable", "exportButtons", "exportName", "exportFormats", "exporter", "rowMenuItems", "rowMenuLeadItems", "server", "paged", "pageSize", "clickableRows", "cellClickFilter", "rowClass", "detail", "chartContext", "search", "emptyTitle", "emptyDescription", "view", "chartPersistence"], outputs: ["gridReady", "rowClicked", "selectionChanged", "sortChanged", "filterChanged", "paginationChanged", "rowGroupOpened", "viewChanged", "chartsChanged"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
2126
|
+
}
|
|
2127
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: StudioComparison, decorators: [{
|
|
2128
|
+
type: Component,
|
|
2129
|
+
args: [{ selector: 'mt-client-studio-comparison', imports: [MtStandardGridComponent], providers: [StudioText, provideEntityListTablePreview()], host: { '(window:resize)': 'resize()' }, changeDetection: ChangeDetectionStrategy.OnPush, template: "<section class=\"studio-comparison\">\r\n <p class=\"studio-comparison-hint\">{{ text.text(\"comparisonHint\") }}</p>\r\n <mt-standard-grid\r\n [rows]=\"fields()\"\r\n [columns]=\"columns()\"\r\n [rowId]=\"fieldId\"\r\n [label]=\"text.text('comparing')\"\r\n [height]=\"height()\"\r\n [paged]=\"false\"\r\n [exportName]=\"text.text('comparing')\"\r\n />\r\n</section>\r\n", styles: [":host{display:block;min-width:0;font:inherit;color:var(--p-text-color, #27364b)}.studio-workspace{display:grid;gap:12px;padding:0;min-width:0}.studio-empty{color:var(--p-text-muted-color, #667085);font-size:12px}.studio-group-heading{margin:12px 0 0;padding-inline-start:10px;border-inline-start:3px solid var(--p-primary-color, #2aaec0);font-size:15px;font-weight:600}.studio-module,.studio-child-level{min-width:0;scroll-margin-block-start:20px}.studio-grid-placeholder{min-height:420px;display:grid;align-content:center;justify-items:center;gap:12px;border:1px solid var(--p-content-border-color, #e4e7ec);border-radius:6px;color:var(--p-text-muted-color, #667085);background:var(--p-content-background, #fff)}.studio-section-error{display:flex;min-height:120px;flex-wrap:wrap;align-items:center;justify-content:center;gap:16px}@media(max-width:1100px){.studio-workspace{gap:0}}@media(max-width:640px){.studio-workspace{padding:0;gap:0}:host .studio-command-content{position:fixed;inset-inline:12px;inset-block-start:20dvh;min-width:0;max-height:60dvh}}.studio-commands{display:flex;align-items:center;flex-wrap:wrap;gap:.75rem;margin-block:.75rem}.studio-command-menu{position:relative;font-size:.875rem}.studio-command-menu>summary{cursor:pointer;padding:.5rem .75rem;border:1px solid var(--p-content-border-color, #ddd);border-radius:.375rem}.studio-command-content{position:absolute;inset-block-start:100%;inset-inline-end:0;z-index:30;min-width:18rem;max-height:24rem;overflow:auto;background:var(--p-content-background, white);color:var(--p-text-color, #334155);padding:.75rem;border:1px solid var(--p-content-border-color, #ddd);border-radius:.375rem;display:grid;gap:.75rem}.studio-command-content label{display:flex;align-items:center;gap:.5rem;flex-wrap:wrap}.studio-command-content select{width:100%;padding:.5rem;border:1px solid var(--p-content-border-color, #ddd);background:inherit;color:inherit;border-radius:.375rem}.studio-command-content button{text-align:start;padding:.5rem;cursor:pointer}.studio-comparison{min-width:0}.studio-comparison-hint{margin:0 0 1rem;color:var(--p-text-muted-color, #667085);font-size:.875rem}button:focus-visible,summary:focus-visible,select:focus-visible{outline:2px solid var(--p-primary-color, #2aaec0);outline-offset:2px}\n"] }]
|
|
2130
|
+
}], propDecorators: { rows: [{ type: i0.Input, args: [{ isSignal: true, alias: "rows", required: true }] }], properties: [{ type: i0.Input, args: [{ isSignal: true, alias: "properties", required: true }] }] } });
|
|
2131
|
+
|
|
2132
|
+
class StudioModuleTable {
|
|
2133
|
+
module = input.required(...(ngDevMode ? [{ debugName: "module" }] : /* istanbul ignore next */ []));
|
|
2134
|
+
owner = input.required(...(ngDevMode ? [{ debugName: "owner" }] : /* istanbul ignore next */ []));
|
|
2135
|
+
scopeOverride = input(null, ...(ngDevMode ? [{ debugName: "scopeOverride" }] : /* istanbul ignore next */ []));
|
|
2136
|
+
sectionId = input('', ...(ngDevMode ? [{ debugName: "sectionId" }] : /* istanbul ignore next */ []));
|
|
2137
|
+
sourcePath = input('', ...(ngDevMode ? [{ debugName: "sourcePath" }] : /* istanbul ignore next */ []));
|
|
2138
|
+
includeDescendants = input(false, ...(ngDevMode ? [{ debugName: "includeDescendants" }] : /* istanbul ignore next */ []));
|
|
2139
|
+
chartContext = computed(() => this.sourcePath() ||
|
|
2140
|
+
[this.owner().levelName, this.owner().name, this.module().name]
|
|
2141
|
+
.filter(Boolean)
|
|
2142
|
+
.join(' · '), ...(ngDevMode ? [{ debugName: "chartContext" }] : /* istanbul ignore next */ []));
|
|
2143
|
+
api = inject(StudioApiService);
|
|
2144
|
+
text = inject(StudioText);
|
|
2145
|
+
height = signal(480, ...(ngDevMode ? [{ debugName: "height" }] : /* istanbul ignore next */ []));
|
|
2146
|
+
reservedHeight = signal(480, ...(ngDevMode ? [{ debugName: "reservedHeight" }] : /* istanbul ignore next */ []));
|
|
2147
|
+
tableHost = viewChild('tableHost', { ...(ngDevMode ? { debugName: "tableHost" } : /* istanbul ignore next */ {}), read: (ElementRef) });
|
|
2148
|
+
table = viewChild(MtStandardGridComponent, ...(ngDevMode ? [{ debugName: "table" }] : /* istanbul ignore next */ []));
|
|
2149
|
+
comparisonProperties = computed(() => this.module().properties.filter((property) => this.properties().includes(property.key)), ...(ngDevMode ? [{ debugName: "comparisonProperties" }] : /* istanbul ignore next */ []));
|
|
2150
|
+
prefetchError = signal(false, ...(ngDevMode ? [{ debugName: "prefetchError" }] : /* istanbul ignore next */ []));
|
|
2151
|
+
prefetching = signal(false, ...(ngDevMode ? [{ debugName: "prefetching" }] : /* istanbul ignore next */ []));
|
|
2152
|
+
additionalFields = signal(new Set(), ...(ngDevMode ? [{ debugName: "additionalFields" }] : /* istanbul ignore next */ []));
|
|
2153
|
+
retryVersion = signal(0, ...(ngDevMode ? [{ debugName: "retryVersion" }] : /* istanbul ignore next */ []));
|
|
2154
|
+
scope = computed(() => this.scopeOverride() ?? {
|
|
2155
|
+
kind: 'module',
|
|
2156
|
+
levelId: this.owner().levelId,
|
|
2157
|
+
recordId: this.owner().recordId,
|
|
2158
|
+
moduleKey: this.module().moduleKey,
|
|
2159
|
+
}, ...(ngDevMode ? [{ debugName: "scope" }] : /* istanbul ignore next */ []));
|
|
2160
|
+
properties = computed(() => [
|
|
2161
|
+
...new Set([
|
|
2162
|
+
...this.module().defaultColumnKeys,
|
|
2163
|
+
...[...this.additionalFields()].filter((key) => this.module().properties.some((property) => property.key === key)),
|
|
2164
|
+
]),
|
|
2165
|
+
], ...(ngDevMode ? [{ debugName: "properties" }] : /* istanbul ignore next */ []));
|
|
2166
|
+
source = computed(() => this.api.source(this.scope(), this.properties(), this.module().capabilities, {
|
|
2167
|
+
includeDescendants: this.includeDescendants(),
|
|
2168
|
+
locale: this.text.language(),
|
|
2169
|
+
}), ...(ngDevMode ? [{ debugName: "source" }] : /* istanbul ignore next */ []));
|
|
2170
|
+
columns = computed(() => [
|
|
2171
|
+
...(this.scopeOverride()
|
|
2172
|
+
? studioOwnerColumns(this.text.text('owner'), this.text.text('level'))
|
|
2173
|
+
: []),
|
|
2174
|
+
...studioColumns(compatibleStudioProperties(this.module().properties, this.grid.rows()), this.module().defaultColumnKeys),
|
|
2175
|
+
], ...(ngDevMode ? [{ debugName: "columns" }] : /* istanbul ignore next */ []));
|
|
2176
|
+
exportFields = computed(() => this.properties().filter((key) => this.module().properties.some((property) => property.key === key && property.capabilities.export)), ...(ngDevMode ? [{ debugName: "exportFields" }] : /* istanbul ignore next */ []));
|
|
2177
|
+
exporter = computed(() => this.api.exporter(this.scope(), this.exportFields(), {
|
|
2178
|
+
includeDescendants: this.includeDescendants(),
|
|
2179
|
+
}), ...(ngDevMode ? [{ debugName: "exporter" }] : /* istanbul ignore next */ []));
|
|
2180
|
+
viewIdentity = computed(() => ({
|
|
2181
|
+
level: this.owner().levelId,
|
|
2182
|
+
module: this.module().moduleKey,
|
|
2183
|
+
role: this.scopeOverride() ? 'studio-cross-record' : 'studio-module',
|
|
2184
|
+
}), ...(ngDevMode ? [{ debugName: "viewIdentity" }] : /* istanbul ignore next */ []));
|
|
2185
|
+
grid = new StudioGridController(this.source, this.columns, this.viewIdentity, (keys) => keys.forEach((key) => this.fieldRequested(key)), this.exporter, () => this.module().exportFormats, () => this.module().name, () => !!this.table());
|
|
2186
|
+
comparison = new StudioComparisonController(() => this.grid.comparisonRows(), this.comparisonProperties, () => !this.grid.loading() && !this.grid.failed(), () => [
|
|
2187
|
+
this.scope(),
|
|
2188
|
+
this.includeDescendants(),
|
|
2189
|
+
this.api.scopeIdentity(),
|
|
2190
|
+
this.text.language(),
|
|
2191
|
+
]);
|
|
2192
|
+
host = inject(StudioHost, { optional: true });
|
|
2193
|
+
/** "Open record" leads the row menu, above the standard items (host opt-in). */
|
|
2194
|
+
openRecordMenu = (row) => studioOpenRecordItems(this.host, this.text, row);
|
|
2195
|
+
comparisonMenu = () => [this.comparison.menuItem()];
|
|
2196
|
+
/** A partial result pages on the server; a complete one pages in the grid. */
|
|
2197
|
+
modulePage = computed(() => ({
|
|
2198
|
+
total: this.grid.total(),
|
|
2199
|
+
page: this.grid.query().offset / this.grid.query().limit,
|
|
2200
|
+
pageSize: this.grid.query().limit,
|
|
2201
|
+
}), ...(ngDevMode ? [{ debugName: "modulePage" }] : /* istanbul ignore next */ []));
|
|
2202
|
+
rowId = (row) => row.id;
|
|
2203
|
+
constructor() {
|
|
2204
|
+
let revealed = false;
|
|
2205
|
+
afterRenderEffect(() => {
|
|
2206
|
+
const host = this.tableHost()?.nativeElement;
|
|
2207
|
+
if (!host || revealed)
|
|
2208
|
+
return;
|
|
2209
|
+
revealed = true;
|
|
2210
|
+
const records = host.closest('mt-client-studio-records-table');
|
|
2211
|
+
if (records?.parentElement?.closest('mt-client-studio-records-table'))
|
|
2212
|
+
host.scrollIntoView({ block: 'nearest', inline: 'nearest' });
|
|
2213
|
+
});
|
|
2214
|
+
effect((onCleanup) => {
|
|
2215
|
+
const host = this.tableHost()?.nativeElement;
|
|
2216
|
+
if (!host)
|
|
2217
|
+
return;
|
|
2218
|
+
onCleanup(observeStudioDetailSize(host, (height, renderedHeight) => {
|
|
2219
|
+
if (renderedHeight > 0)
|
|
2220
|
+
this.reservedHeight.set(renderedHeight);
|
|
2221
|
+
if (height !== null)
|
|
2222
|
+
this.height.set(height);
|
|
2223
|
+
}));
|
|
2224
|
+
});
|
|
2225
|
+
effect((onCleanup) => {
|
|
2226
|
+
const source = this.source();
|
|
2227
|
+
if (this.table())
|
|
2228
|
+
onCleanup(this.api.retain(source.key));
|
|
2229
|
+
});
|
|
2230
|
+
effect((onCleanup) => {
|
|
2231
|
+
const source = this.source();
|
|
2232
|
+
this.retryVersion();
|
|
2233
|
+
const controller = new AbortController();
|
|
2234
|
+
onCleanup(() => controller.abort());
|
|
2235
|
+
this.prefetching.set(true);
|
|
2236
|
+
this.prefetchError.set(false);
|
|
2237
|
+
void loadMtTableResult(source, { ...STUDIO_INITIAL_QUERY, limit: 50 }, controller.signal, this.rowId).then(() => {
|
|
2238
|
+
if (!controller.signal.aborted)
|
|
2239
|
+
this.prefetching.set(false);
|
|
2240
|
+
}, () => {
|
|
2241
|
+
if (!controller.signal.aborted) {
|
|
2242
|
+
this.prefetchError.set(true);
|
|
2243
|
+
this.prefetching.set(false);
|
|
2244
|
+
}
|
|
2245
|
+
});
|
|
2246
|
+
});
|
|
2247
|
+
}
|
|
2248
|
+
fieldRequested(key) {
|
|
2249
|
+
if (!this.module().properties.some((property) => property.key === key) ||
|
|
2250
|
+
this.properties().includes(key))
|
|
2251
|
+
return;
|
|
2252
|
+
this.additionalFields.update((fields) => new Set([...fields, key]));
|
|
2253
|
+
}
|
|
2254
|
+
retry() {
|
|
2255
|
+
this.retryVersion.update((value) => value + 1);
|
|
2256
|
+
}
|
|
2257
|
+
getQuery() {
|
|
2258
|
+
return this.grid.getQuery() ?? STUDIO_INITIAL_QUERY;
|
|
2259
|
+
}
|
|
2260
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: StudioModuleTable, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2261
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.8", type: StudioModuleTable, isStandalone: true, selector: "mt-client-studio-module-table", inputs: { module: { classPropertyName: "module", publicName: "module", isSignal: true, isRequired: true, transformFunction: null }, owner: { classPropertyName: "owner", publicName: "owner", isSignal: true, isRequired: true, transformFunction: null }, scopeOverride: { classPropertyName: "scopeOverride", publicName: "scopeOverride", isSignal: true, isRequired: false, transformFunction: null }, sectionId: { classPropertyName: "sectionId", publicName: "sectionId", isSignal: true, isRequired: false, transformFunction: null }, sourcePath: { classPropertyName: "sourcePath", publicName: "sourcePath", isSignal: true, isRequired: false, transformFunction: null }, includeDescendants: { classPropertyName: "includeDescendants", publicName: "includeDescendants", isSignal: true, isRequired: false, transformFunction: null } }, viewQueries: [{ propertyName: "tableHost", first: true, predicate: ["tableHost"], descendants: true, read: ElementRef, isSignal: true }, { propertyName: "table", first: true, predicate: MtStandardGridComponent, descendants: true, isSignal: true }], ngImport: i0, template: "<section\n class=\"studio-module\"\n [attr.aria-label]=\"module().name\"\n [id]=\"sectionId()\"\n mtClientStudioViewport\n #viewport=\"studioViewport\"\n>\n @if (viewport.near()) {\n @if (grid.failed()) {\n <div class=\"studio-section-error\" role=\"alert\">\n {{ text.text(\"failed\") }}\n <mt-button\n [label]=\"text.text('retry')\"\n severity=\"secondary\"\n (onClick)=\"grid.retry()\"\n />\n </div>\n }\n <mt-standard-grid\n #tableHost\n [rows]=\"grid.rows()\"\n [columns]=\"grid.renderColumns()\"\n [rowId]=\"rowId\"\n [server]=\"grid.complete() ? null : modulePage()\"\n [pageSize]=\"grid.query().limit\"\n [loading]=\"grid.loading()\"\n [selection]=\"true\"\n [label]=\"module().name\"\n [chartContext]=\"chartContext()\"\n [height]=\"height()\"\n [exportable]=\"grid.exportReady()\"\n [exportFormats]=\"grid.exportFormats()\"\n [exporter]=\"grid.exportAs\"\n [exportName]=\"module().name\"\n [rowMenuLeadItems]=\"openRecordMenu\"\n [rowMenuItems]=\"comparisonMenu\"\n (gridReady)=\"grid.ready($event)\"\n (viewChanged)=\"grid.changed()\"\n (paginationChanged)=\"grid.page($event)\"\n (selectionChanged)=\"grid.selection()\"\n [chartPersistence]=\"grid.chartPersistence()\"\n (chartsChanged)=\"grid.chartsChanged()\"\n />\n } @else {\n <div\n class=\"studio-grid-placeholder\"\n [attr.aria-busy]=\"prefetching()\"\n [style.min-height.px]=\"reservedHeight()\"\n >\n @if (prefetchError()) {\n <p role=\"alert\">{{ text.text(\"failed\") }}</p>\n <mt-button\n [label]=\"text.text('retry')\"\n (onClick)=\"retry()\"\n severity=\"secondary\"\n />\n } @else if (prefetching()) {\n <span>{{ text.text(\"loading\") }}</span>\n }\n </div>\n }\n</section>\n", styles: [":host{display:block;min-width:0;font:inherit;color:var(--p-text-color, #27364b)}.studio-workspace{display:grid;gap:12px;padding:0;min-width:0}.studio-empty{color:var(--p-text-muted-color, #667085);font-size:12px}.studio-group-heading{margin:12px 0 0;padding-inline-start:10px;border-inline-start:3px solid var(--p-primary-color, #2aaec0);font-size:15px;font-weight:600}.studio-module,.studio-child-level{min-width:0;scroll-margin-block-start:20px}.studio-grid-placeholder{min-height:420px;display:grid;align-content:center;justify-items:center;gap:12px;border:1px solid var(--p-content-border-color, #e4e7ec);border-radius:6px;color:var(--p-text-muted-color, #667085);background:var(--p-content-background, #fff)}.studio-section-error{display:flex;min-height:120px;flex-wrap:wrap;align-items:center;justify-content:center;gap:16px}@media(max-width:1100px){.studio-workspace{gap:0}}@media(max-width:640px){.studio-workspace{padding:0;gap:0}:host .studio-command-content{position:fixed;inset-inline:12px;inset-block-start:20dvh;min-width:0;max-height:60dvh}}.studio-commands{display:flex;align-items:center;flex-wrap:wrap;gap:.75rem;margin-block:.75rem}.studio-command-menu{position:relative;font-size:.875rem}.studio-command-menu>summary{cursor:pointer;padding:.5rem .75rem;border:1px solid var(--p-content-border-color, #ddd);border-radius:.375rem}.studio-command-content{position:absolute;inset-block-start:100%;inset-inline-end:0;z-index:30;min-width:18rem;max-height:24rem;overflow:auto;background:var(--p-content-background, white);color:var(--p-text-color, #334155);padding:.75rem;border:1px solid var(--p-content-border-color, #ddd);border-radius:.375rem;display:grid;gap:.75rem}.studio-command-content label{display:flex;align-items:center;gap:.5rem;flex-wrap:wrap}.studio-command-content select{width:100%;padding:.5rem;border:1px solid var(--p-content-border-color, #ddd);background:inherit;color:inherit;border-radius:.375rem}.studio-command-content button{text-align:start;padding:.5rem;cursor:pointer}.studio-comparison{min-width:0}.studio-comparison-hint{margin:0 0 1rem;color:var(--p-text-muted-color, #667085);font-size:.875rem}button:focus-visible,summary:focus-visible,select:focus-visible{outline:2px solid var(--p-primary-color, #2aaec0);outline-offset:2px}\n"], dependencies: [{ kind: "component", type: MtStandardGridComponent, selector: "mt-standard-grid", inputs: ["rows", "columns", "rowId", "label", "loading", "height", "rowHeight", "selection", "exportable", "exportButtons", "exportName", "exportFormats", "exporter", "rowMenuItems", "rowMenuLeadItems", "server", "paged", "pageSize", "clickableRows", "cellClickFilter", "rowClass", "detail", "chartContext", "search", "emptyTitle", "emptyDescription", "view", "chartPersistence"], outputs: ["gridReady", "rowClicked", "selectionChanged", "sortChanged", "filterChanged", "paginationChanged", "rowGroupOpened", "viewChanged", "chartsChanged"] }, { kind: "directive", type: StudioViewport, selector: "[mtClientStudioViewport]", exportAs: ["studioViewport"] }, { kind: "component", type: Button, selector: "mt-button", inputs: ["icon", "label", "tooltip", "class", "type", "styleClass", "severity", "badge", "variant", "badgeSeverity", "size", "iconPos", "autofocus", "fluid", "raised", "rounded", "text", "plain", "outlined", "link", "disabled", "loading", "pInputs", "ariaLabel"], outputs: ["onClick", "onFocus", "onBlur"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
2262
|
+
}
|
|
2263
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: StudioModuleTable, decorators: [{
|
|
2264
|
+
type: Component,
|
|
2265
|
+
args: [{ selector: 'mt-client-studio-module-table', imports: [MtStandardGridComponent, StudioViewport, Button], changeDetection: ChangeDetectionStrategy.OnPush, template: "<section\n class=\"studio-module\"\n [attr.aria-label]=\"module().name\"\n [id]=\"sectionId()\"\n mtClientStudioViewport\n #viewport=\"studioViewport\"\n>\n @if (viewport.near()) {\n @if (grid.failed()) {\n <div class=\"studio-section-error\" role=\"alert\">\n {{ text.text(\"failed\") }}\n <mt-button\n [label]=\"text.text('retry')\"\n severity=\"secondary\"\n (onClick)=\"grid.retry()\"\n />\n </div>\n }\n <mt-standard-grid\n #tableHost\n [rows]=\"grid.rows()\"\n [columns]=\"grid.renderColumns()\"\n [rowId]=\"rowId\"\n [server]=\"grid.complete() ? null : modulePage()\"\n [pageSize]=\"grid.query().limit\"\n [loading]=\"grid.loading()\"\n [selection]=\"true\"\n [label]=\"module().name\"\n [chartContext]=\"chartContext()\"\n [height]=\"height()\"\n [exportable]=\"grid.exportReady()\"\n [exportFormats]=\"grid.exportFormats()\"\n [exporter]=\"grid.exportAs\"\n [exportName]=\"module().name\"\n [rowMenuLeadItems]=\"openRecordMenu\"\n [rowMenuItems]=\"comparisonMenu\"\n (gridReady)=\"grid.ready($event)\"\n (viewChanged)=\"grid.changed()\"\n (paginationChanged)=\"grid.page($event)\"\n (selectionChanged)=\"grid.selection()\"\n [chartPersistence]=\"grid.chartPersistence()\"\n (chartsChanged)=\"grid.chartsChanged()\"\n />\n } @else {\n <div\n class=\"studio-grid-placeholder\"\n [attr.aria-busy]=\"prefetching()\"\n [style.min-height.px]=\"reservedHeight()\"\n >\n @if (prefetchError()) {\n <p role=\"alert\">{{ text.text(\"failed\") }}</p>\n <mt-button\n [label]=\"text.text('retry')\"\n (onClick)=\"retry()\"\n severity=\"secondary\"\n />\n } @else if (prefetching()) {\n <span>{{ text.text(\"loading\") }}</span>\n }\n </div>\n }\n</section>\n", styles: [":host{display:block;min-width:0;font:inherit;color:var(--p-text-color, #27364b)}.studio-workspace{display:grid;gap:12px;padding:0;min-width:0}.studio-empty{color:var(--p-text-muted-color, #667085);font-size:12px}.studio-group-heading{margin:12px 0 0;padding-inline-start:10px;border-inline-start:3px solid var(--p-primary-color, #2aaec0);font-size:15px;font-weight:600}.studio-module,.studio-child-level{min-width:0;scroll-margin-block-start:20px}.studio-grid-placeholder{min-height:420px;display:grid;align-content:center;justify-items:center;gap:12px;border:1px solid var(--p-content-border-color, #e4e7ec);border-radius:6px;color:var(--p-text-muted-color, #667085);background:var(--p-content-background, #fff)}.studio-section-error{display:flex;min-height:120px;flex-wrap:wrap;align-items:center;justify-content:center;gap:16px}@media(max-width:1100px){.studio-workspace{gap:0}}@media(max-width:640px){.studio-workspace{padding:0;gap:0}:host .studio-command-content{position:fixed;inset-inline:12px;inset-block-start:20dvh;min-width:0;max-height:60dvh}}.studio-commands{display:flex;align-items:center;flex-wrap:wrap;gap:.75rem;margin-block:.75rem}.studio-command-menu{position:relative;font-size:.875rem}.studio-command-menu>summary{cursor:pointer;padding:.5rem .75rem;border:1px solid var(--p-content-border-color, #ddd);border-radius:.375rem}.studio-command-content{position:absolute;inset-block-start:100%;inset-inline-end:0;z-index:30;min-width:18rem;max-height:24rem;overflow:auto;background:var(--p-content-background, white);color:var(--p-text-color, #334155);padding:.75rem;border:1px solid var(--p-content-border-color, #ddd);border-radius:.375rem;display:grid;gap:.75rem}.studio-command-content label{display:flex;align-items:center;gap:.5rem;flex-wrap:wrap}.studio-command-content select{width:100%;padding:.5rem;border:1px solid var(--p-content-border-color, #ddd);background:inherit;color:inherit;border-radius:.375rem}.studio-command-content button{text-align:start;padding:.5rem;cursor:pointer}.studio-comparison{min-width:0}.studio-comparison-hint{margin:0 0 1rem;color:var(--p-text-muted-color, #667085);font-size:.875rem}button:focus-visible,summary:focus-visible,select:focus-visible{outline:2px solid var(--p-primary-color, #2aaec0);outline-offset:2px}\n"] }]
|
|
2266
|
+
}], ctorParameters: () => [], propDecorators: { module: [{ type: i0.Input, args: [{ isSignal: true, alias: "module", required: true }] }], owner: [{ type: i0.Input, args: [{ isSignal: true, alias: "owner", required: true }] }], scopeOverride: [{ type: i0.Input, args: [{ isSignal: true, alias: "scopeOverride", required: false }] }], sectionId: [{ type: i0.Input, args: [{ isSignal: true, alias: "sectionId", required: false }] }], sourcePath: [{ type: i0.Input, args: [{ isSignal: true, alias: "sourcePath", required: false }] }], includeDescendants: [{ type: i0.Input, args: [{ isSignal: true, alias: "includeDescendants", required: false }] }], tableHost: [{ type: i0.ViewChild, args: ['tableHost', { ...{
|
|
2267
|
+
read: (ElementRef),
|
|
2268
|
+
}, isSignal: true }] }], table: [{ type: i0.ViewChild, args: [i0.forwardRef(() => MtStandardGridComponent), { isSignal: true }] }] } });
|
|
2269
|
+
|
|
2270
|
+
/** Reconcile optional analysis configuration against today's authorized catalog. */
|
|
2271
|
+
function studioSummaries(value, catalog) {
|
|
2272
|
+
if (!Array.isArray(value) || value.length > 256)
|
|
2273
|
+
return [];
|
|
2274
|
+
const keys = new Set();
|
|
2275
|
+
return value.flatMap((summary) => {
|
|
2276
|
+
if (!summary ||
|
|
2277
|
+
typeof summary !== 'object' ||
|
|
2278
|
+
!['count', 'sum', 'avg', 'min', 'max'].includes(summary.aggregation))
|
|
2279
|
+
return [];
|
|
2280
|
+
const module = catalog.modules.find((module) => module.moduleKey === summary.moduleKey);
|
|
2281
|
+
if (!module ||
|
|
2282
|
+
(summary.aggregation !== 'count' &&
|
|
2283
|
+
!module.properties.some((property) => property.key === summary.propertyKey &&
|
|
2284
|
+
property.capabilities.aggregate)))
|
|
2285
|
+
return [];
|
|
2286
|
+
if (!validStudioFilter(summary.filter, new Set(module.properties
|
|
2287
|
+
.filter((property) => property.capabilities.filter)
|
|
2288
|
+
.map((property) => property.key))))
|
|
2289
|
+
return [];
|
|
2290
|
+
const propertyKey = summary.aggregation === 'count' ? null : summary.propertyKey;
|
|
2291
|
+
const key = `summary:${module.moduleKey}:${propertyKey ?? '*'}:${summary.aggregation}`;
|
|
2292
|
+
if (keys.has(key))
|
|
2293
|
+
return [];
|
|
2294
|
+
keys.add(key);
|
|
2295
|
+
return [
|
|
2296
|
+
{
|
|
2297
|
+
key,
|
|
2298
|
+
moduleKey: module.moduleKey,
|
|
2299
|
+
propertyKey,
|
|
2300
|
+
aggregation: summary.aggregation,
|
|
2301
|
+
filter: summary.filter,
|
|
2302
|
+
},
|
|
2303
|
+
];
|
|
2304
|
+
});
|
|
2305
|
+
}
|
|
2306
|
+
|
|
2307
|
+
class StudioExport {
|
|
2308
|
+
scope = input.required(...(ngDevMode ? [{ debugName: "scope" }] : /* istanbul ignore next */ []));
|
|
2309
|
+
propertyKeys = input([], ...(ngDevMode ? [{ debugName: "propertyKeys" }] : /* istanbul ignore next */ []));
|
|
2310
|
+
summaries = input([], ...(ngDevMode ? [{ debugName: "summaries" }] : /* istanbul ignore next */ []));
|
|
2311
|
+
query = input(STUDIO_INITIAL_QUERY, ...(ngDevMode ? [{ debugName: "query" }] : /* istanbul ignore next */ []));
|
|
2312
|
+
kind = input.required(...(ngDevMode ? [{ debugName: "kind" }] : /* istanbul ignore next */ []));
|
|
2313
|
+
title = input('', ...(ngDevMode ? [{ debugName: "title" }] : /* istanbul ignore next */ []));
|
|
2314
|
+
text = inject(StudioText);
|
|
2315
|
+
api = inject(StudioApiService);
|
|
2316
|
+
descendants = signal(false, ...(ngDevMode ? [{ debugName: "descendants" }] : /* istanbul ignore next */ []));
|
|
2317
|
+
busy = signal(false, ...(ngDevMode ? [{ debugName: "busy" }] : /* istanbul ignore next */ []));
|
|
2318
|
+
failed = signal(false, ...(ngDevMode ? [{ debugName: "failed" }] : /* istanbul ignore next */ []));
|
|
2319
|
+
progress = signal(0, ...(ngDevMode ? [{ debugName: "progress" }] : /* istanbul ignore next */ []));
|
|
2320
|
+
controller = null;
|
|
2321
|
+
constructor() {
|
|
2322
|
+
inject(DestroyRef).onDestroy(() => this.controller?.abort());
|
|
2323
|
+
}
|
|
2324
|
+
async export() {
|
|
2325
|
+
if (this.busy())
|
|
2326
|
+
return;
|
|
2327
|
+
const controller = new AbortController();
|
|
2328
|
+
this.controller = controller;
|
|
2329
|
+
this.busy.set(true);
|
|
2330
|
+
this.failed.set(false);
|
|
2331
|
+
this.progress.set(0);
|
|
2332
|
+
try {
|
|
2333
|
+
await this.api
|
|
2334
|
+
.exporter(this.scope(), this.propertyKeys(), {
|
|
2335
|
+
includeDescendants: this.descendants(),
|
|
2336
|
+
summaries: this.summaries(),
|
|
2337
|
+
locale: this.text.language(),
|
|
2338
|
+
}, this.kind(), (job) => this.progress.set(job.progress))
|
|
2339
|
+
.export({
|
|
2340
|
+
format: 'excel',
|
|
2341
|
+
title: this.title(),
|
|
2342
|
+
query: this.query(),
|
|
2343
|
+
rows: [],
|
|
2344
|
+
complete: false,
|
|
2345
|
+
visibleColumns: this.propertyKeys(),
|
|
2346
|
+
}, controller.signal);
|
|
2347
|
+
}
|
|
2348
|
+
catch {
|
|
2349
|
+
if (!controller.signal.aborted)
|
|
2350
|
+
this.failed.set(true);
|
|
2351
|
+
}
|
|
2352
|
+
finally {
|
|
2353
|
+
if (!controller.signal.aborted)
|
|
2354
|
+
this.busy.set(false);
|
|
2355
|
+
}
|
|
2356
|
+
}
|
|
2357
|
+
cancel() {
|
|
2358
|
+
this.controller?.abort();
|
|
2359
|
+
this.busy.set(false);
|
|
2360
|
+
}
|
|
2361
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: StudioExport, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2362
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.8", type: StudioExport, isStandalone: true, selector: "mt-client-studio-export", inputs: { scope: { classPropertyName: "scope", publicName: "scope", isSignal: true, isRequired: true, transformFunction: null }, propertyKeys: { classPropertyName: "propertyKeys", publicName: "propertyKeys", isSignal: true, isRequired: false, transformFunction: null }, summaries: { classPropertyName: "summaries", publicName: "summaries", isSignal: true, isRequired: false, transformFunction: null }, query: { classPropertyName: "query", publicName: "query", isSignal: true, isRequired: false, transformFunction: null }, kind: { classPropertyName: "kind", publicName: "kind", isSignal: true, isRequired: true, transformFunction: null }, title: { classPropertyName: "title", publicName: "title", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: "<details class=\"studio-command-menu\">\r\n <summary>\r\n {{ text.text(kind() === \"record\" ? \"exportRecord\" : \"exportLevel\") }}\r\n </summary>\r\n <div class=\"studio-command-content\">\r\n <label\r\n ><input\r\n type=\"checkbox\"\r\n [checked]=\"descendants()\"\r\n (change)=\"descendants.set($any($event.target).checked)\"\r\n />{{ text.text(\"descendants\") }}</label\r\n >\r\n <mt-button\r\n [label]=\"text.text('excel')\"\r\n [loading]=\"busy()\"\r\n (onClick)=\"export()\"\r\n severity=\"secondary\"\r\n size=\"small\"\r\n />\r\n @if (busy()) {\r\n <span role=\"status\">{{ progress() }}%</span\r\n ><mt-button\r\n [label]=\"text.text('cancel')\"\r\n severity=\"secondary\"\r\n size=\"small\"\r\n (onClick)=\"cancel()\"\r\n />\r\n }\r\n @if (failed()) {\r\n <p role=\"alert\">{{ text.text(\"exportFailed\") }}</p>\r\n }\r\n </div>\r\n</details>\r\n", styles: [":host{display:block;min-width:0;font:inherit;color:var(--p-text-color, #27364b)}.studio-workspace{display:grid;gap:12px;padding:0;min-width:0}.studio-empty{color:var(--p-text-muted-color, #667085);font-size:12px}.studio-group-heading{margin:12px 0 0;padding-inline-start:10px;border-inline-start:3px solid var(--p-primary-color, #2aaec0);font-size:15px;font-weight:600}.studio-module,.studio-child-level{min-width:0;scroll-margin-block-start:20px}.studio-grid-placeholder{min-height:420px;display:grid;align-content:center;justify-items:center;gap:12px;border:1px solid var(--p-content-border-color, #e4e7ec);border-radius:6px;color:var(--p-text-muted-color, #667085);background:var(--p-content-background, #fff)}.studio-section-error{display:flex;min-height:120px;flex-wrap:wrap;align-items:center;justify-content:center;gap:16px}@media(max-width:1100px){.studio-workspace{gap:0}}@media(max-width:640px){.studio-workspace{padding:0;gap:0}:host .studio-command-content{position:fixed;inset-inline:12px;inset-block-start:20dvh;min-width:0;max-height:60dvh}}.studio-commands{display:flex;align-items:center;flex-wrap:wrap;gap:.75rem;margin-block:.75rem}.studio-command-menu{position:relative;font-size:.875rem}.studio-command-menu>summary{cursor:pointer;padding:.5rem .75rem;border:1px solid var(--p-content-border-color, #ddd);border-radius:.375rem}.studio-command-content{position:absolute;inset-block-start:100%;inset-inline-end:0;z-index:30;min-width:18rem;max-height:24rem;overflow:auto;background:var(--p-content-background, white);color:var(--p-text-color, #334155);padding:.75rem;border:1px solid var(--p-content-border-color, #ddd);border-radius:.375rem;display:grid;gap:.75rem}.studio-command-content label{display:flex;align-items:center;gap:.5rem;flex-wrap:wrap}.studio-command-content select{width:100%;padding:.5rem;border:1px solid var(--p-content-border-color, #ddd);background:inherit;color:inherit;border-radius:.375rem}.studio-command-content button{text-align:start;padding:.5rem;cursor:pointer}.studio-comparison{min-width:0}.studio-comparison-hint{margin:0 0 1rem;color:var(--p-text-muted-color, #667085);font-size:.875rem}button:focus-visible,summary:focus-visible,select:focus-visible{outline:2px solid var(--p-primary-color, #2aaec0);outline-offset:2px}\n"], dependencies: [{ kind: "component", type: Button, selector: "mt-button", inputs: ["icon", "label", "tooltip", "class", "type", "styleClass", "severity", "badge", "variant", "badgeSeverity", "size", "iconPos", "autofocus", "fluid", "raised", "rounded", "text", "plain", "outlined", "link", "disabled", "loading", "pInputs", "ariaLabel"], outputs: ["onClick", "onFocus", "onBlur"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
2363
|
+
}
|
|
2364
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: StudioExport, decorators: [{
|
|
2365
|
+
type: Component,
|
|
2366
|
+
args: [{ selector: 'mt-client-studio-export', imports: [Button], changeDetection: ChangeDetectionStrategy.OnPush, template: "<details class=\"studio-command-menu\">\r\n <summary>\r\n {{ text.text(kind() === \"record\" ? \"exportRecord\" : \"exportLevel\") }}\r\n </summary>\r\n <div class=\"studio-command-content\">\r\n <label\r\n ><input\r\n type=\"checkbox\"\r\n [checked]=\"descendants()\"\r\n (change)=\"descendants.set($any($event.target).checked)\"\r\n />{{ text.text(\"descendants\") }}</label\r\n >\r\n <mt-button\r\n [label]=\"text.text('excel')\"\r\n [loading]=\"busy()\"\r\n (onClick)=\"export()\"\r\n severity=\"secondary\"\r\n size=\"small\"\r\n />\r\n @if (busy()) {\r\n <span role=\"status\">{{ progress() }}%</span\r\n ><mt-button\r\n [label]=\"text.text('cancel')\"\r\n severity=\"secondary\"\r\n size=\"small\"\r\n (onClick)=\"cancel()\"\r\n />\r\n }\r\n @if (failed()) {\r\n <p role=\"alert\">{{ text.text(\"exportFailed\") }}</p>\r\n }\r\n </div>\r\n</details>\r\n", styles: [":host{display:block;min-width:0;font:inherit;color:var(--p-text-color, #27364b)}.studio-workspace{display:grid;gap:12px;padding:0;min-width:0}.studio-empty{color:var(--p-text-muted-color, #667085);font-size:12px}.studio-group-heading{margin:12px 0 0;padding-inline-start:10px;border-inline-start:3px solid var(--p-primary-color, #2aaec0);font-size:15px;font-weight:600}.studio-module,.studio-child-level{min-width:0;scroll-margin-block-start:20px}.studio-grid-placeholder{min-height:420px;display:grid;align-content:center;justify-items:center;gap:12px;border:1px solid var(--p-content-border-color, #e4e7ec);border-radius:6px;color:var(--p-text-muted-color, #667085);background:var(--p-content-background, #fff)}.studio-section-error{display:flex;min-height:120px;flex-wrap:wrap;align-items:center;justify-content:center;gap:16px}@media(max-width:1100px){.studio-workspace{gap:0}}@media(max-width:640px){.studio-workspace{padding:0;gap:0}:host .studio-command-content{position:fixed;inset-inline:12px;inset-block-start:20dvh;min-width:0;max-height:60dvh}}.studio-commands{display:flex;align-items:center;flex-wrap:wrap;gap:.75rem;margin-block:.75rem}.studio-command-menu{position:relative;font-size:.875rem}.studio-command-menu>summary{cursor:pointer;padding:.5rem .75rem;border:1px solid var(--p-content-border-color, #ddd);border-radius:.375rem}.studio-command-content{position:absolute;inset-block-start:100%;inset-inline-end:0;z-index:30;min-width:18rem;max-height:24rem;overflow:auto;background:var(--p-content-background, white);color:var(--p-text-color, #334155);padding:.75rem;border:1px solid var(--p-content-border-color, #ddd);border-radius:.375rem;display:grid;gap:.75rem}.studio-command-content label{display:flex;align-items:center;gap:.5rem;flex-wrap:wrap}.studio-command-content select{width:100%;padding:.5rem;border:1px solid var(--p-content-border-color, #ddd);background:inherit;color:inherit;border-radius:.375rem}.studio-command-content button{text-align:start;padding:.5rem;cursor:pointer}.studio-comparison{min-width:0}.studio-comparison-hint{margin:0 0 1rem;color:var(--p-text-muted-color, #667085);font-size:.875rem}button:focus-visible,summary:focus-visible,select:focus-visible{outline:2px solid var(--p-primary-color, #2aaec0);outline-offset:2px}\n"] }]
|
|
2367
|
+
}], ctorParameters: () => [], propDecorators: { scope: [{ type: i0.Input, args: [{ isSignal: true, alias: "scope", required: true }] }], propertyKeys: [{ type: i0.Input, args: [{ isSignal: true, alias: "propertyKeys", required: false }] }], summaries: [{ type: i0.Input, args: [{ isSignal: true, alias: "summaries", required: false }] }], query: [{ type: i0.Input, args: [{ isSignal: true, alias: "query", required: false }] }], kind: [{ type: i0.Input, args: [{ isSignal: true, alias: "kind", required: true }] }], title: [{ type: i0.Input, args: [{ isSignal: true, alias: "title", required: false }] }] } });
|
|
2368
|
+
|
|
2369
|
+
const STUDIO_WORKSPACE_RENDERER = new InjectionToken('STUDIO_WORKSPACE_RENDERER');
|
|
2370
|
+
|
|
2371
|
+
class StudioRecordsTable {
|
|
2372
|
+
levelId = input.required(...(ngDevMode ? [{ debugName: "levelId" }] : /* istanbul ignore next */ []));
|
|
2373
|
+
scopeOverride = input(null, ...(ngDevMode ? [{ debugName: "scopeOverride" }] : /* istanbul ignore next */ []));
|
|
2374
|
+
ancestorKeys = input([], ...(ngDevMode ? [{ debugName: "ancestorKeys" }] : /* istanbul ignore next */ []));
|
|
2375
|
+
title = input('', ...(ngDevMode ? [{ debugName: "title" }] : /* istanbul ignore next */ []));
|
|
2376
|
+
chartContext = input('', ...(ngDevMode ? [{ debugName: "chartContext" }] : /* istanbul ignore next */ []));
|
|
2377
|
+
height = input(600, ...(ngDevMode ? [{ debugName: "height" }] : /* istanbul ignore next */ []));
|
|
2378
|
+
/** A records load finished (every successful load; the root Studio announces the first). */
|
|
2379
|
+
recordsLoaded = output();
|
|
2380
|
+
/** The root records load finished: what the host receives as `dataLoaded`. */
|
|
2381
|
+
dataLoaded = output();
|
|
2382
|
+
/** The catalog or the records failed; the section shows its error and retry. */
|
|
2383
|
+
recordsFailed = output();
|
|
2384
|
+
tableHost = viewChild('tableHost', { ...(ngDevMode ? { debugName: "tableHost" } : /* istanbul ignore next */ {}), read: (ElementRef) });
|
|
2385
|
+
detailHeight = signal(null, ...(ngDevMode ? [{ debugName: "detailHeight" }] : /* istanbul ignore next */ []));
|
|
2386
|
+
gridHeight = computed(() => this.detailHeight() ?? this.height(), ...(ngDevMode ? [{ debugName: "gridHeight" }] : /* istanbul ignore next */ []));
|
|
2387
|
+
api = inject(StudioApiService);
|
|
2388
|
+
preferences = inject(MtTablePreferences);
|
|
2389
|
+
summaryPreferenceKey = null;
|
|
2390
|
+
summaryCatalog = null;
|
|
2391
|
+
useModuleFilters = signal(false, ...(ngDevMode ? [{ debugName: "useModuleFilters" }] : /* istanbul ignore next */ []));
|
|
2392
|
+
moduleTable = viewChild(StudioModuleTable, ...(ngDevMode ? [{ debugName: "moduleTable" }] : /* istanbul ignore next */ []));
|
|
2393
|
+
text = inject(StudioText);
|
|
2394
|
+
aggregationChoices = [
|
|
2395
|
+
'count',
|
|
2396
|
+
'sum',
|
|
2397
|
+
'avg',
|
|
2398
|
+
'min',
|
|
2399
|
+
'max',
|
|
2400
|
+
];
|
|
2401
|
+
renderer = inject(STUDIO_WORKSPACE_RENDERER);
|
|
2402
|
+
catalog = signal(null, ...(ngDevMode ? [{ debugName: "catalog" }] : /* istanbul ignore next */ []));
|
|
2403
|
+
failed = signal(false, ...(ngDevMode ? [{ debugName: "failed" }] : /* istanbul ignore next */ []));
|
|
2404
|
+
toolsOpen = signal(false, ...(ngDevMode ? [{ debugName: "toolsOpen" }] : /* istanbul ignore next */ []));
|
|
2405
|
+
analysisModuleKey = signal('', ...(ngDevMode ? [{ debugName: "analysisModuleKey" }] : /* istanbul ignore next */ []));
|
|
2406
|
+
includeDescendants = signal(false, ...(ngDevMode ? [{ debugName: "includeDescendants" }] : /* istanbul ignore next */ []));
|
|
2407
|
+
analysisScope = computed(() => {
|
|
2408
|
+
const moduleKey = this.analysisModuleKey();
|
|
2409
|
+
if (!moduleKey)
|
|
2410
|
+
return null;
|
|
2411
|
+
const query = this.currentQuery();
|
|
2412
|
+
return {
|
|
2413
|
+
kind: 'crossRecord',
|
|
2414
|
+
levelId: this.levelId(),
|
|
2415
|
+
moduleKey,
|
|
2416
|
+
levelFilter: studioFilter(query.filters),
|
|
2417
|
+
levelSearch: query.search,
|
|
2418
|
+
recordIds: this.grid.matchingRows().map((row) => row.recordId),
|
|
2419
|
+
};
|
|
2420
|
+
}, ...(ngDevMode ? [{ debugName: "analysisScope" }] : /* istanbul ignore next */ []));
|
|
2421
|
+
summaries = signal([], ...(ngDevMode ? [{ debugName: "summaries" }] : /* istanbul ignore next */ []));
|
|
2422
|
+
summaryModuleKey = signal('', ...(ngDevMode ? [{ debugName: "summaryModuleKey" }] : /* istanbul ignore next */ []));
|
|
2423
|
+
summaryPropertyKey = signal('', ...(ngDevMode ? [{ debugName: "summaryPropertyKey" }] : /* istanbul ignore next */ []));
|
|
2424
|
+
summaryAggregation = signal('count', ...(ngDevMode ? [{ debugName: "summaryAggregation" }] : /* istanbul ignore next */ []));
|
|
2425
|
+
analysisModule = computed(() => this.catalog()?.modules.find((module) => module.moduleKey === this.analysisModuleKey()) ?? null, ...(ngDevMode ? [{ debugName: "analysisModule" }] : /* istanbul ignore next */ []));
|
|
2426
|
+
analysisOwner = computed(() => ({
|
|
2427
|
+
levelId: this.levelId(),
|
|
2428
|
+
recordId: 0,
|
|
2429
|
+
name: '',
|
|
2430
|
+
levelName: this.catalog()?.name ?? '',
|
|
2431
|
+
contextKey: '',
|
|
2432
|
+
}), ...(ngDevMode ? [{ debugName: "analysisOwner" }] : /* istanbul ignore next */ []));
|
|
2433
|
+
summaryModule = computed(() => this.catalog()?.modules.find((module) => module.moduleKey === this.summaryModuleKey()) ?? null, ...(ngDevMode ? [{ debugName: "summaryModule" }] : /* istanbul ignore next */ []));
|
|
2434
|
+
summaryProperties = computed(() => this.summaryModule()?.properties.filter((property) => property.capabilities.aggregate) ?? [], ...(ngDevMode ? [{ debugName: "summaryProperties" }] : /* istanbul ignore next */ []));
|
|
2435
|
+
comparisonProperties = computed(() => this.catalog()?.properties.filter((property) => this.fields().includes(property.key)) ?? [], ...(ngDevMode ? [{ debugName: "comparisonProperties" }] : /* istanbul ignore next */ []));
|
|
2436
|
+
retryVersion = signal(0, ...(ngDevMode ? [{ debugName: "retryVersion" }] : /* istanbul ignore next */ []));
|
|
2437
|
+
additionalFields = signal(new Set(), ...(ngDevMode ? [{ debugName: "additionalFields" }] : /* istanbul ignore next */ []));
|
|
2438
|
+
scope = computed(() => this.scopeOverride() ?? { kind: 'records', levelId: this.levelId() }, ...(ngDevMode ? [{ debugName: "scope" }] : /* istanbul ignore next */ []));
|
|
2439
|
+
fields = computed(() => [
|
|
2440
|
+
...new Set([
|
|
2441
|
+
...(this.catalog()?.defaultColumnKeys ?? []),
|
|
2442
|
+
...this.additionalFields(),
|
|
2443
|
+
]),
|
|
2444
|
+
], ...(ngDevMode ? [{ debugName: "fields" }] : /* istanbul ignore next */ []));
|
|
2445
|
+
source = computed(() => this.catalog()
|
|
2446
|
+
? this.api.source(this.scope(), this.fields(), this.catalog().capabilities, { summaries: this.summaries(), locale: this.text.language() })
|
|
2447
|
+
: null, ...(ngDevMode ? [{ debugName: "source" }] : /* istanbul ignore next */ []));
|
|
2448
|
+
columns = computed(() => [
|
|
2449
|
+
...studioColumns(compatibleStudioProperties(this.catalog()?.properties ?? [], this.grid.rows()), this.catalog()?.defaultColumnKeys ?? [], true),
|
|
2450
|
+
...this.summaries().map((summary) => ({
|
|
2451
|
+
colId: summary.key,
|
|
2452
|
+
headerName: this.summaryLabel(summary),
|
|
2453
|
+
filter: 'number',
|
|
2454
|
+
sortable: true,
|
|
2455
|
+
type: 'numericColumn',
|
|
2456
|
+
width: 180,
|
|
2457
|
+
valueGetter: ({ data }) => data.values[summary.key]?.raw ?? null,
|
|
2458
|
+
valueFormatter: ({ data, value, }) => {
|
|
2459
|
+
const missing = data?.values[summary.key]?.missingValueCount ?? 0;
|
|
2460
|
+
return `${value ?? '—'}${missing ? ` · ${missing} ${this.text.text('missingValues')}` : ''}`;
|
|
2461
|
+
},
|
|
2462
|
+
})),
|
|
2463
|
+
], ...(ngDevMode ? [{ debugName: "columns" }] : /* istanbul ignore next */ []));
|
|
2464
|
+
exportFields = computed(() => (this.grid
|
|
2465
|
+
.api()
|
|
2466
|
+
?.getColumnState()
|
|
2467
|
+
.filter((column) => !column.hide)
|
|
2468
|
+
.map((column) => column.colId) ?? this.fields()).filter((key) => this.catalog()?.properties.some((property) => property.key === key && property.capabilities.export) || this.summaries().some((summary) => summary.key === key)), ...(ngDevMode ? [{ debugName: "exportFields" }] : /* istanbul ignore next */ []));
|
|
2469
|
+
exporter = computed(() => this.api.exporter(this.scope(), this.exportFields(), {
|
|
2470
|
+
summaries: this.summaries(),
|
|
2471
|
+
locale: this.text.language(),
|
|
2472
|
+
}), ...(ngDevMode ? [{ debugName: "exporter" }] : /* istanbul ignore next */ []));
|
|
2473
|
+
rendererParams = computed(() => ({
|
|
2474
|
+
ancestorKeys: this.ancestorKeys(),
|
|
2475
|
+
chartContext: this.chartContext() || this.title() || this.catalog()?.name || '',
|
|
2476
|
+
}), ...(ngDevMode ? [{ debugName: "rendererParams" }] : /* istanbul ignore next */ []));
|
|
2477
|
+
viewIdentity = computed(() => ({
|
|
2478
|
+
level: this.levelId(),
|
|
2479
|
+
role: this.scopeOverride() ? 'studio-connected-level' : 'studio-records',
|
|
2480
|
+
}), ...(ngDevMode ? [{ debugName: "viewIdentity" }] : /* istanbul ignore next */ []));
|
|
2481
|
+
grid = new StudioGridController(this.source, this.columns, this.viewIdentity, (keys) => keys.forEach((key) => this.fieldRequested(key)), this.exporter, () => this.catalog()?.exportFormats ?? [], () => this.title() || this.catalog()?.name || '');
|
|
2482
|
+
comparison = new StudioComparisonController(() => this.grid.comparisonRows(), this.comparisonProperties, () => !this.grid.loading() && !this.grid.failed(), () => [this.scope(), this.api.scopeIdentity(), this.text.language()]);
|
|
2483
|
+
host = inject(StudioHost, { optional: true });
|
|
2484
|
+
/** "Open record" leads the row menu, above the standard items (host opt-in). */
|
|
2485
|
+
openRecordMenu = (row) => studioOpenRecordItems(this.host, this.text, row);
|
|
2486
|
+
comparisonMenu = () => [this.comparison.menuItem()];
|
|
2487
|
+
exportRecord = signal(null, ...(ngDevMode ? [{ debugName: "exportRecord" }] : /* istanbul ignore next */ []));
|
|
2488
|
+
rowId = (row) => row.id;
|
|
2489
|
+
expandable = (row) => !this.ancestorKeys().includes(studioRecordKey(row.levelId, row.recordId));
|
|
2490
|
+
detail = computed(() => ({
|
|
2491
|
+
renderer: this.renderer,
|
|
2492
|
+
params: this.rendererParams(),
|
|
2493
|
+
isRowMaster: this.expandable,
|
|
2494
|
+
}), ...(ngDevMode ? [{ debugName: "detail" }] : /* istanbul ignore next */ []));
|
|
2495
|
+
/** Partial results are server-owned: sort, filter and grouping go to the query. */
|
|
2496
|
+
recordsPage = computed(() => ({
|
|
2497
|
+
total: this.grid.total(),
|
|
2498
|
+
page: 0,
|
|
2499
|
+
pageSize: this.grid.query().limit,
|
|
2500
|
+
}), ...(ngDevMode ? [{ debugName: "recordsPage" }] : /* istanbul ignore next */ []));
|
|
2501
|
+
failure = computed(() => this.failed() || this.grid.failed(), ...(ngDevMode ? [{ debugName: "failure" }] : /* istanbul ignore next */ []));
|
|
2502
|
+
constructor() {
|
|
2503
|
+
effect(() => {
|
|
2504
|
+
if (this.grid.loads())
|
|
2505
|
+
untracked(() => this.recordsLoaded.emit());
|
|
2506
|
+
});
|
|
2507
|
+
effect(() => {
|
|
2508
|
+
const meta = this.grid.rootMeta();
|
|
2509
|
+
if (!meta || this.scopeOverride())
|
|
2510
|
+
return;
|
|
2511
|
+
untracked(() => {
|
|
2512
|
+
// A load a later context change has replaced is not the host's data any more.
|
|
2513
|
+
const context = this.host?.context();
|
|
2514
|
+
if (context &&
|
|
2515
|
+
(context.contextKey !== meta.contextKey || context.key !== meta.key))
|
|
2516
|
+
return;
|
|
2517
|
+
this.dataLoaded.emit(meta);
|
|
2518
|
+
});
|
|
2519
|
+
});
|
|
2520
|
+
effect(() => {
|
|
2521
|
+
if (this.failure())
|
|
2522
|
+
untracked(() => this.recordsFailed.emit());
|
|
2523
|
+
});
|
|
2524
|
+
effect((onCleanup) => {
|
|
2525
|
+
const host = this.tableHost()?.nativeElement;
|
|
2526
|
+
if (host)
|
|
2527
|
+
onCleanup(observeStudioDetailSize(host, (height) => this.detailHeight.set(height), 400));
|
|
2528
|
+
});
|
|
2529
|
+
effect(() => {
|
|
2530
|
+
const catalog = this.catalog(), key = this.preferences.key(this.viewIdentity());
|
|
2531
|
+
if (!catalog || !key)
|
|
2532
|
+
return;
|
|
2533
|
+
const storageKey = `${key}:summaries:v1`;
|
|
2534
|
+
if (this.summaryPreferenceKey !== storageKey ||
|
|
2535
|
+
this.summaryCatalog !== catalog) {
|
|
2536
|
+
this.summaryCatalog = catalog;
|
|
2537
|
+
this.summaryPreferenceKey = storageKey;
|
|
2538
|
+
try {
|
|
2539
|
+
const text = localStorage.getItem(storageKey);
|
|
2540
|
+
this.summaries.set(text && text.length <= 131072
|
|
2541
|
+
? studioSummaries(JSON.parse(text), catalog)
|
|
2542
|
+
: []);
|
|
2543
|
+
}
|
|
2544
|
+
catch {
|
|
2545
|
+
this.summaries.set([]);
|
|
2546
|
+
}
|
|
2547
|
+
}
|
|
2548
|
+
const definitions = this.summaries();
|
|
2549
|
+
try {
|
|
2550
|
+
localStorage.setItem(storageKey, JSON.stringify(definitions));
|
|
2551
|
+
}
|
|
2552
|
+
catch {
|
|
2553
|
+
/* Optional personalization. */
|
|
2554
|
+
}
|
|
2555
|
+
});
|
|
2556
|
+
effect((onCleanup) => {
|
|
2557
|
+
const levelId = this.levelId(), locale = this.text.language();
|
|
2558
|
+
this.api.scopeIdentity();
|
|
2559
|
+
this.retryVersion();
|
|
2560
|
+
const controller = new AbortController();
|
|
2561
|
+
onCleanup(() => controller.abort());
|
|
2562
|
+
this.catalog.set(null);
|
|
2563
|
+
this.failed.set(false);
|
|
2564
|
+
this.additionalFields.set(new Set());
|
|
2565
|
+
this.grid.selected.set([]);
|
|
2566
|
+
this.toolsOpen.set(false);
|
|
2567
|
+
this.exportRecord.set(null);
|
|
2568
|
+
this.analysisModuleKey.set('');
|
|
2569
|
+
this.includeDescendants.set(false);
|
|
2570
|
+
this.useModuleFilters.set(false);
|
|
2571
|
+
this.summaries.set([]);
|
|
2572
|
+
void this.api.catalog(levelId, controller.signal, locale).then((catalog) => {
|
|
2573
|
+
if (!controller.signal.aborted)
|
|
2574
|
+
this.catalog.set(catalog);
|
|
2575
|
+
}, () => {
|
|
2576
|
+
if (!controller.signal.aborted)
|
|
2577
|
+
this.failed.set(true);
|
|
2578
|
+
});
|
|
2579
|
+
});
|
|
2580
|
+
}
|
|
2581
|
+
currentQuery() {
|
|
2582
|
+
return this.grid.getQuery() ?? STUDIO_INITIAL_QUERY;
|
|
2583
|
+
}
|
|
2584
|
+
analyse(moduleKey) {
|
|
2585
|
+
this.analysisModuleKey.set(moduleKey);
|
|
2586
|
+
}
|
|
2587
|
+
addSummary() {
|
|
2588
|
+
const moduleKey = this.summaryModuleKey(), aggregation = this.summaryAggregation();
|
|
2589
|
+
const propertyKey = aggregation === 'count' ? null : this.summaryPropertyKey();
|
|
2590
|
+
if (!this.summaryModule() ||
|
|
2591
|
+
(aggregation !== 'count' &&
|
|
2592
|
+
!this.summaryProperties().some((property) => property.key === propertyKey)))
|
|
2593
|
+
return;
|
|
2594
|
+
const key = `summary:${moduleKey}:${propertyKey ?? '*'}:${aggregation}`;
|
|
2595
|
+
const filter = this.useModuleFilters() && this.analysisModuleKey() === moduleKey
|
|
2596
|
+
? studioFilter(this.moduleTable()?.getQuery().filters ?? {})
|
|
2597
|
+
: null;
|
|
2598
|
+
this.summaries.update((summaries) => [
|
|
2599
|
+
...summaries.filter((summary) => summary.key !== key),
|
|
2600
|
+
{ key, moduleKey, propertyKey, aggregation, filter },
|
|
2601
|
+
]);
|
|
2602
|
+
}
|
|
2603
|
+
removeSummary(key) {
|
|
2604
|
+
this.summaries.update((summaries) => summaries.filter((summary) => summary.key !== key));
|
|
2605
|
+
}
|
|
2606
|
+
summaryLabel(summary) {
|
|
2607
|
+
const module = this.catalog()?.modules.find((module) => module.moduleKey === summary.moduleKey);
|
|
2608
|
+
const property = module?.properties.find((property) => property.key === summary.propertyKey);
|
|
2609
|
+
return `${module?.name ?? ''} · ${property?.label ?? this.text.text('records')} (${this.text.text(summary.aggregation)})`;
|
|
2610
|
+
}
|
|
2611
|
+
fieldRequested(key) {
|
|
2612
|
+
if (!this.catalog()?.properties.some((property) => property.key === key) ||
|
|
2613
|
+
this.fields().includes(key))
|
|
2614
|
+
return;
|
|
2615
|
+
this.additionalFields.update((fields) => new Set([...fields, key]));
|
|
2616
|
+
}
|
|
2617
|
+
retry() {
|
|
2618
|
+
this.retryVersion.update((value) => value + 1);
|
|
2619
|
+
}
|
|
2620
|
+
refresh() {
|
|
2621
|
+
this.api.refresh();
|
|
2622
|
+
}
|
|
2623
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: StudioRecordsTable, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2624
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.8", type: StudioRecordsTable, isStandalone: true, selector: "mt-client-studio-records-table", inputs: { levelId: { classPropertyName: "levelId", publicName: "levelId", isSignal: true, isRequired: true, transformFunction: null }, scopeOverride: { classPropertyName: "scopeOverride", publicName: "scopeOverride", isSignal: true, isRequired: false, transformFunction: null }, ancestorKeys: { classPropertyName: "ancestorKeys", publicName: "ancestorKeys", isSignal: true, isRequired: false, transformFunction: null }, title: { classPropertyName: "title", publicName: "title", isSignal: true, isRequired: false, transformFunction: null }, chartContext: { classPropertyName: "chartContext", publicName: "chartContext", isSignal: true, isRequired: false, transformFunction: null }, height: { classPropertyName: "height", publicName: "height", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { recordsLoaded: "recordsLoaded", dataLoaded: "dataLoaded", recordsFailed: "recordsFailed" }, providers: [provideEntityListTablePreview()], viewQueries: [{ propertyName: "tableHost", first: true, predicate: ["tableHost"], descendants: true, read: ElementRef, isSignal: true }, { propertyName: "moduleTable", first: true, predicate: StudioModuleTable, descendants: true, isSignal: true }], ngImport: i0, template: "@if (catalog(); as data) {\n @if (toolsOpen()) {\n <div class=\"studio-commands\">\n @if (exportRecord(); as record) {\n <mt-client-studio-export\n [scope]=\"{\n kind: 'record',\n levelId: record.levelId,\n recordId: record.recordId,\n }\"\n kind=\"record\"\n [title]=\"record.name\"\n />\n }\n <mt-button\n [label]=\"text.text('close')\"\n severity=\"secondary\"\n size=\"small\"\n (onClick)=\"toolsOpen.set(false)\"\n />\n <mt-button\n [label]=\"text.text('refresh')\"\n icon=\"arrow.refresh-cw-01\"\n severity=\"secondary\"\n size=\"small\"\n (onClick)=\"refresh()\"\n />\n <details class=\"studio-command-menu\">\n <summary>{{ text.text(\"summaries\") }}</summary>\n <div class=\"studio-command-content\">\n <label\n >{{ text.text(\"selectModule\")\n }}<select\n [value]=\"summaryModuleKey()\"\n (change)=\"\n summaryModuleKey.set($any($event.target).value);\n summaryPropertyKey.set('')\n \"\n >\n <option value=\"\"></option>\n @for (module of data.modules; track module.id) {\n <option [value]=\"module.moduleKey\">{{ module.name }}</option>\n }\n </select></label\n >\n <label\n >{{ text.text(\"measure\")\n }}<select\n [value]=\"summaryAggregation()\"\n (change)=\"summaryAggregation.set($any($event.target).value)\"\n >\n @for (aggregation of aggregationChoices; track aggregation) {\n <option [value]=\"aggregation\">\n {{ text.text(aggregation) }}\n </option>\n }\n </select></label\n >\n @if (summaryAggregation() !== \"count\") {\n <label\n >{{ text.text(\"property\")\n }}<select\n [value]=\"summaryPropertyKey()\"\n (change)=\"summaryPropertyKey.set($any($event.target).value)\"\n >\n <option value=\"\"></option>\n @for (property of summaryProperties(); track property.key) {\n <option [value]=\"property.key\">{{ property.label }}</option>\n }\n </select></label\n >\n }\n <mt-button\n [label]=\"text.text('addSummary')\"\n severity=\"secondary\"\n size=\"small\"\n (onClick)=\"addSummary()\"\n />\n @if (\n analysisModuleKey() && summaryModuleKey() === analysisModuleKey()\n ) {\n <label\n ><input\n type=\"checkbox\"\n [checked]=\"useModuleFilters()\"\n (change)=\"useModuleFilters.set($any($event.target).checked)\"\n />{{ text.text(\"useModuleFilters\") }}</label\n >\n }\n @for (summary of summaries(); track summary.key) {\n <button type=\"button\" (click)=\"removeSummary(summary.key)\">\n {{ summaryLabel(summary) }} \u00B7 {{ text.text(\"remove\") }}\n </button>\n }\n </div>\n </details>\n @if (data.capabilities.exportAll) {\n <mt-client-studio-export\n [scope]=\"scope()\"\n [propertyKeys]=\"exportFields()\"\n [summaries]=\"summaries()\"\n [query]=\"currentQuery()\"\n kind=\"level\"\n [title]=\"data.name\"\n />\n }\n </div>\n }\n @if (analysisModule(); as module) {\n <div class=\"studio-commands\">\n <mt-button\n [label]=\"text.text('back')\"\n severity=\"secondary\"\n size=\"small\"\n (onClick)=\"analysisModuleKey.set('')\"\n /><label\n ><input\n type=\"checkbox\"\n [checked]=\"includeDescendants()\"\n (change)=\"includeDescendants.set($any($event.target).checked)\"\n />{{ text.text(\"descendants\") }}</label\n >\n </div>\n <mt-client-studio-module-table\n [module]=\"module\"\n [owner]=\"analysisOwner()\"\n [scopeOverride]=\"analysisScope()\"\n [includeDescendants]=\"includeDescendants()\"\n />\n }\n <div [hidden]=\"!!analysisModule()\">\n @if (grid.failed()) {\n <div class=\"studio-section-error\" role=\"alert\">\n {{ text.text(\"failed\") }}\n <mt-button\n [label]=\"text.text('retry')\"\n severity=\"secondary\"\n (onClick)=\"grid.retry()\"\n />\n </div>\n }\n <mt-standard-grid\n #tableHost\n [rows]=\"grid.rows()\"\n [columns]=\"grid.renderColumns()\"\n [rowId]=\"rowId\"\n [server]=\"grid.complete() ? null : recordsPage()\"\n [paged]=\"false\"\n [loading]=\"grid.loading()\"\n [selection]=\"true\"\n [label]=\"title() || data.name || text.text('title')\"\n [chartContext]=\"chartContext() || title() || data.name\"\n [height]=\"gridHeight()\"\n [detail]=\"detail()\"\n [exportable]=\"grid.exportReady()\"\n [exportFormats]=\"grid.exportFormats()\"\n [exporter]=\"grid.exportAs\"\n [exportName]=\"title() || data.name\"\n [rowMenuLeadItems]=\"openRecordMenu\"\n [rowMenuItems]=\"comparisonMenu\"\n (gridReady)=\"grid.ready($event)\"\n (viewChanged)=\"grid.changed()\"\n (selectionChanged)=\"grid.selection()\"\n [chartPersistence]=\"grid.chartPersistence()\"\n (chartsChanged)=\"grid.chartsChanged()\"\n />\n </div>\n} @else if (failed()) {\n <div class=\"studio-section-error\" role=\"alert\">\n <p>{{ text.text(\"failed\") }}</p>\n <mt-button\n [label]=\"text.text('retry')\"\n (onClick)=\"retry()\"\n severity=\"secondary\"\n />\n </div>\n} @else {\n <div class=\"studio-grid-placeholder\" role=\"status\">\n {{ text.text(\"loading\") }}\n </div>\n}\n", styles: [":host{display:block;min-width:0;font:inherit;color:var(--p-text-color, #27364b)}.studio-workspace{display:grid;gap:12px;padding:0;min-width:0}.studio-empty{color:var(--p-text-muted-color, #667085);font-size:12px}.studio-group-heading{margin:12px 0 0;padding-inline-start:10px;border-inline-start:3px solid var(--p-primary-color, #2aaec0);font-size:15px;font-weight:600}.studio-module,.studio-child-level{min-width:0;scroll-margin-block-start:20px}.studio-grid-placeholder{min-height:420px;display:grid;align-content:center;justify-items:center;gap:12px;border:1px solid var(--p-content-border-color, #e4e7ec);border-radius:6px;color:var(--p-text-muted-color, #667085);background:var(--p-content-background, #fff)}.studio-section-error{display:flex;min-height:120px;flex-wrap:wrap;align-items:center;justify-content:center;gap:16px}@media(max-width:1100px){.studio-workspace{gap:0}}@media(max-width:640px){.studio-workspace{padding:0;gap:0}:host .studio-command-content{position:fixed;inset-inline:12px;inset-block-start:20dvh;min-width:0;max-height:60dvh}}.studio-commands{display:flex;align-items:center;flex-wrap:wrap;gap:.75rem;margin-block:.75rem}.studio-command-menu{position:relative;font-size:.875rem}.studio-command-menu>summary{cursor:pointer;padding:.5rem .75rem;border:1px solid var(--p-content-border-color, #ddd);border-radius:.375rem}.studio-command-content{position:absolute;inset-block-start:100%;inset-inline-end:0;z-index:30;min-width:18rem;max-height:24rem;overflow:auto;background:var(--p-content-background, white);color:var(--p-text-color, #334155);padding:.75rem;border:1px solid var(--p-content-border-color, #ddd);border-radius:.375rem;display:grid;gap:.75rem}.studio-command-content label{display:flex;align-items:center;gap:.5rem;flex-wrap:wrap}.studio-command-content select{width:100%;padding:.5rem;border:1px solid var(--p-content-border-color, #ddd);background:inherit;color:inherit;border-radius:.375rem}.studio-command-content button{text-align:start;padding:.5rem;cursor:pointer}.studio-comparison{min-width:0}.studio-comparison-hint{margin:0 0 1rem;color:var(--p-text-muted-color, #667085);font-size:.875rem}button:focus-visible,summary:focus-visible,select:focus-visible{outline:2px solid var(--p-primary-color, #2aaec0);outline-offset:2px}\n"], dependencies: [{ kind: "component", type: MtStandardGridComponent, selector: "mt-standard-grid", inputs: ["rows", "columns", "rowId", "label", "loading", "height", "rowHeight", "selection", "exportable", "exportButtons", "exportName", "exportFormats", "exporter", "rowMenuItems", "rowMenuLeadItems", "server", "paged", "pageSize", "clickableRows", "cellClickFilter", "rowClass", "detail", "chartContext", "search", "emptyTitle", "emptyDescription", "view", "chartPersistence"], outputs: ["gridReady", "rowClicked", "selectionChanged", "sortChanged", "filterChanged", "paginationChanged", "rowGroupOpened", "viewChanged", "chartsChanged"] }, { kind: "component", type: Button, selector: "mt-button", inputs: ["icon", "label", "tooltip", "class", "type", "styleClass", "severity", "badge", "variant", "badgeSeverity", "size", "iconPos", "autofocus", "fluid", "raised", "rounded", "text", "plain", "outlined", "link", "disabled", "loading", "pInputs", "ariaLabel"], outputs: ["onClick", "onFocus", "onBlur"] }, { kind: "component", type: StudioModuleTable, selector: "mt-client-studio-module-table", inputs: ["module", "owner", "scopeOverride", "sectionId", "sourcePath", "includeDescendants"] }, { kind: "component", type: StudioExport, selector: "mt-client-studio-export", inputs: ["scope", "propertyKeys", "summaries", "query", "kind", "title"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
2625
|
+
}
|
|
2626
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: StudioRecordsTable, decorators: [{
|
|
2627
|
+
type: Component,
|
|
2628
|
+
args: [{ selector: 'mt-client-studio-records-table', providers: [provideEntityListTablePreview()], imports: [MtStandardGridComponent, Button, StudioModuleTable, StudioExport], changeDetection: ChangeDetectionStrategy.OnPush, template: "@if (catalog(); as data) {\n @if (toolsOpen()) {\n <div class=\"studio-commands\">\n @if (exportRecord(); as record) {\n <mt-client-studio-export\n [scope]=\"{\n kind: 'record',\n levelId: record.levelId,\n recordId: record.recordId,\n }\"\n kind=\"record\"\n [title]=\"record.name\"\n />\n }\n <mt-button\n [label]=\"text.text('close')\"\n severity=\"secondary\"\n size=\"small\"\n (onClick)=\"toolsOpen.set(false)\"\n />\n <mt-button\n [label]=\"text.text('refresh')\"\n icon=\"arrow.refresh-cw-01\"\n severity=\"secondary\"\n size=\"small\"\n (onClick)=\"refresh()\"\n />\n <details class=\"studio-command-menu\">\n <summary>{{ text.text(\"summaries\") }}</summary>\n <div class=\"studio-command-content\">\n <label\n >{{ text.text(\"selectModule\")\n }}<select\n [value]=\"summaryModuleKey()\"\n (change)=\"\n summaryModuleKey.set($any($event.target).value);\n summaryPropertyKey.set('')\n \"\n >\n <option value=\"\"></option>\n @for (module of data.modules; track module.id) {\n <option [value]=\"module.moduleKey\">{{ module.name }}</option>\n }\n </select></label\n >\n <label\n >{{ text.text(\"measure\")\n }}<select\n [value]=\"summaryAggregation()\"\n (change)=\"summaryAggregation.set($any($event.target).value)\"\n >\n @for (aggregation of aggregationChoices; track aggregation) {\n <option [value]=\"aggregation\">\n {{ text.text(aggregation) }}\n </option>\n }\n </select></label\n >\n @if (summaryAggregation() !== \"count\") {\n <label\n >{{ text.text(\"property\")\n }}<select\n [value]=\"summaryPropertyKey()\"\n (change)=\"summaryPropertyKey.set($any($event.target).value)\"\n >\n <option value=\"\"></option>\n @for (property of summaryProperties(); track property.key) {\n <option [value]=\"property.key\">{{ property.label }}</option>\n }\n </select></label\n >\n }\n <mt-button\n [label]=\"text.text('addSummary')\"\n severity=\"secondary\"\n size=\"small\"\n (onClick)=\"addSummary()\"\n />\n @if (\n analysisModuleKey() && summaryModuleKey() === analysisModuleKey()\n ) {\n <label\n ><input\n type=\"checkbox\"\n [checked]=\"useModuleFilters()\"\n (change)=\"useModuleFilters.set($any($event.target).checked)\"\n />{{ text.text(\"useModuleFilters\") }}</label\n >\n }\n @for (summary of summaries(); track summary.key) {\n <button type=\"button\" (click)=\"removeSummary(summary.key)\">\n {{ summaryLabel(summary) }} \u00B7 {{ text.text(\"remove\") }}\n </button>\n }\n </div>\n </details>\n @if (data.capabilities.exportAll) {\n <mt-client-studio-export\n [scope]=\"scope()\"\n [propertyKeys]=\"exportFields()\"\n [summaries]=\"summaries()\"\n [query]=\"currentQuery()\"\n kind=\"level\"\n [title]=\"data.name\"\n />\n }\n </div>\n }\n @if (analysisModule(); as module) {\n <div class=\"studio-commands\">\n <mt-button\n [label]=\"text.text('back')\"\n severity=\"secondary\"\n size=\"small\"\n (onClick)=\"analysisModuleKey.set('')\"\n /><label\n ><input\n type=\"checkbox\"\n [checked]=\"includeDescendants()\"\n (change)=\"includeDescendants.set($any($event.target).checked)\"\n />{{ text.text(\"descendants\") }}</label\n >\n </div>\n <mt-client-studio-module-table\n [module]=\"module\"\n [owner]=\"analysisOwner()\"\n [scopeOverride]=\"analysisScope()\"\n [includeDescendants]=\"includeDescendants()\"\n />\n }\n <div [hidden]=\"!!analysisModule()\">\n @if (grid.failed()) {\n <div class=\"studio-section-error\" role=\"alert\">\n {{ text.text(\"failed\") }}\n <mt-button\n [label]=\"text.text('retry')\"\n severity=\"secondary\"\n (onClick)=\"grid.retry()\"\n />\n </div>\n }\n <mt-standard-grid\n #tableHost\n [rows]=\"grid.rows()\"\n [columns]=\"grid.renderColumns()\"\n [rowId]=\"rowId\"\n [server]=\"grid.complete() ? null : recordsPage()\"\n [paged]=\"false\"\n [loading]=\"grid.loading()\"\n [selection]=\"true\"\n [label]=\"title() || data.name || text.text('title')\"\n [chartContext]=\"chartContext() || title() || data.name\"\n [height]=\"gridHeight()\"\n [detail]=\"detail()\"\n [exportable]=\"grid.exportReady()\"\n [exportFormats]=\"grid.exportFormats()\"\n [exporter]=\"grid.exportAs\"\n [exportName]=\"title() || data.name\"\n [rowMenuLeadItems]=\"openRecordMenu\"\n [rowMenuItems]=\"comparisonMenu\"\n (gridReady)=\"grid.ready($event)\"\n (viewChanged)=\"grid.changed()\"\n (selectionChanged)=\"grid.selection()\"\n [chartPersistence]=\"grid.chartPersistence()\"\n (chartsChanged)=\"grid.chartsChanged()\"\n />\n </div>\n} @else if (failed()) {\n <div class=\"studio-section-error\" role=\"alert\">\n <p>{{ text.text(\"failed\") }}</p>\n <mt-button\n [label]=\"text.text('retry')\"\n (onClick)=\"retry()\"\n severity=\"secondary\"\n />\n </div>\n} @else {\n <div class=\"studio-grid-placeholder\" role=\"status\">\n {{ text.text(\"loading\") }}\n </div>\n}\n", styles: [":host{display:block;min-width:0;font:inherit;color:var(--p-text-color, #27364b)}.studio-workspace{display:grid;gap:12px;padding:0;min-width:0}.studio-empty{color:var(--p-text-muted-color, #667085);font-size:12px}.studio-group-heading{margin:12px 0 0;padding-inline-start:10px;border-inline-start:3px solid var(--p-primary-color, #2aaec0);font-size:15px;font-weight:600}.studio-module,.studio-child-level{min-width:0;scroll-margin-block-start:20px}.studio-grid-placeholder{min-height:420px;display:grid;align-content:center;justify-items:center;gap:12px;border:1px solid var(--p-content-border-color, #e4e7ec);border-radius:6px;color:var(--p-text-muted-color, #667085);background:var(--p-content-background, #fff)}.studio-section-error{display:flex;min-height:120px;flex-wrap:wrap;align-items:center;justify-content:center;gap:16px}@media(max-width:1100px){.studio-workspace{gap:0}}@media(max-width:640px){.studio-workspace{padding:0;gap:0}:host .studio-command-content{position:fixed;inset-inline:12px;inset-block-start:20dvh;min-width:0;max-height:60dvh}}.studio-commands{display:flex;align-items:center;flex-wrap:wrap;gap:.75rem;margin-block:.75rem}.studio-command-menu{position:relative;font-size:.875rem}.studio-command-menu>summary{cursor:pointer;padding:.5rem .75rem;border:1px solid var(--p-content-border-color, #ddd);border-radius:.375rem}.studio-command-content{position:absolute;inset-block-start:100%;inset-inline-end:0;z-index:30;min-width:18rem;max-height:24rem;overflow:auto;background:var(--p-content-background, white);color:var(--p-text-color, #334155);padding:.75rem;border:1px solid var(--p-content-border-color, #ddd);border-radius:.375rem;display:grid;gap:.75rem}.studio-command-content label{display:flex;align-items:center;gap:.5rem;flex-wrap:wrap}.studio-command-content select{width:100%;padding:.5rem;border:1px solid var(--p-content-border-color, #ddd);background:inherit;color:inherit;border-radius:.375rem}.studio-command-content button{text-align:start;padding:.5rem;cursor:pointer}.studio-comparison{min-width:0}.studio-comparison-hint{margin:0 0 1rem;color:var(--p-text-muted-color, #667085);font-size:.875rem}button:focus-visible,summary:focus-visible,select:focus-visible{outline:2px solid var(--p-primary-color, #2aaec0);outline-offset:2px}\n"] }]
|
|
2629
|
+
}], ctorParameters: () => [], propDecorators: { levelId: [{ type: i0.Input, args: [{ isSignal: true, alias: "levelId", required: true }] }], scopeOverride: [{ type: i0.Input, args: [{ isSignal: true, alias: "scopeOverride", required: false }] }], ancestorKeys: [{ type: i0.Input, args: [{ isSignal: true, alias: "ancestorKeys", required: false }] }], title: [{ type: i0.Input, args: [{ isSignal: true, alias: "title", required: false }] }], chartContext: [{ type: i0.Input, args: [{ isSignal: true, alias: "chartContext", required: false }] }], height: [{ type: i0.Input, args: [{ isSignal: true, alias: "height", required: false }] }], recordsLoaded: [{ type: i0.Output, args: ["recordsLoaded"] }], dataLoaded: [{ type: i0.Output, args: ["dataLoaded"] }], recordsFailed: [{ type: i0.Output, args: ["recordsFailed"] }], tableHost: [{ type: i0.ViewChild, args: ['tableHost', { ...{
|
|
2630
|
+
read: (ElementRef),
|
|
2631
|
+
}, isSignal: true }] }], moduleTable: [{ type: i0.ViewChild, args: [i0.forwardRef(() => StudioModuleTable), { isSignal: true }] }] } });
|
|
2632
|
+
|
|
2633
|
+
class StudioRecordWorkspace {
|
|
2634
|
+
params = input.required(...(ngDevMode ? [{ debugName: "params" }] : /* istanbul ignore next */ []));
|
|
2635
|
+
api = inject(StudioApiService);
|
|
2636
|
+
host = inject(StudioHost, { optional: true });
|
|
2637
|
+
text = inject(StudioText);
|
|
2638
|
+
/** `ClientStudioOptions.showConnections`; hidden by default (2026-10-25). */
|
|
2639
|
+
showConnections = computed(() => this.host?.showConnections() ?? STUDIO_SHOW_CONNECTIONS, ...(ngDevMode ? [{ debugName: "showConnections" }] : /* istanbul ignore next */ []));
|
|
2640
|
+
workspace = signal(null, ...(ngDevMode ? [{ debugName: "workspace" }] : /* istanbul ignore next */ []));
|
|
2641
|
+
failed = signal(false, ...(ngDevMode ? [{ debugName: "failed" }] : /* istanbul ignore next */ []));
|
|
2642
|
+
retryVersion = signal(0, ...(ngDevMode ? [{ debugName: "retryVersion" }] : /* istanbul ignore next */ []));
|
|
2643
|
+
ancestorKeys = computed(() => [
|
|
2644
|
+
...this.params()['ancestorKeys'],
|
|
2645
|
+
studioRecordKey(this.params().data.levelId, this.params().data.recordId),
|
|
2646
|
+
], ...(ngDevMode ? [{ debugName: "ancestorKeys" }] : /* istanbul ignore next */ []));
|
|
2647
|
+
chartContext = computed(() => [this.params()['chartContext'], this.workspace()?.record.name]
|
|
2648
|
+
.filter(Boolean)
|
|
2649
|
+
.join(' · '), ...(ngDevMode ? [{ debugName: "chartContext" }] : /* istanbul ignore next */ []));
|
|
2650
|
+
groups = computed(() => {
|
|
2651
|
+
const groups = new Map();
|
|
2652
|
+
for (const module of this.workspace()?.modules ?? []) {
|
|
2653
|
+
const id = module.group
|
|
2654
|
+
? `group:${module.group.id}`
|
|
2655
|
+
: `module:${module.id}`;
|
|
2656
|
+
let group = groups.get(id);
|
|
2657
|
+
if (!group) {
|
|
2658
|
+
group = {
|
|
2659
|
+
id,
|
|
2660
|
+
name: module.group?.name ?? '',
|
|
2661
|
+
order: module.group?.order ?? module.order,
|
|
2662
|
+
modules: [],
|
|
2663
|
+
};
|
|
2664
|
+
groups.set(id, group);
|
|
2665
|
+
}
|
|
2666
|
+
group.modules.push(module);
|
|
2667
|
+
}
|
|
2668
|
+
return [...groups.values()]
|
|
2669
|
+
.sort((a, b) => a.order - b.order)
|
|
2670
|
+
.map((group) => ({
|
|
2671
|
+
...group,
|
|
2672
|
+
modules: [...group.modules].sort((a, b) => a.order - b.order),
|
|
2673
|
+
}));
|
|
2674
|
+
}, ...(ngDevMode ? [{ debugName: "groups" }] : /* istanbul ignore next */ []));
|
|
2675
|
+
tabs = computed(() => [
|
|
2676
|
+
...(this.showConnections() ? (this.workspace()?.children ?? []) : []).map((child) => ({
|
|
2677
|
+
kind: 'connection',
|
|
2678
|
+
key: `connection:${child.referenceId}`,
|
|
2679
|
+
label: child.name,
|
|
2680
|
+
child,
|
|
2681
|
+
})),
|
|
2682
|
+
...this.groups().map((group) => ({
|
|
2683
|
+
kind: 'modules',
|
|
2684
|
+
key: group.id,
|
|
2685
|
+
label: group.name || group.modules[0].name,
|
|
2686
|
+
modules: group.modules,
|
|
2687
|
+
})),
|
|
2688
|
+
], ...(ngDevMode ? [{ debugName: "tabs" }] : /* istanbul ignore next */ []));
|
|
2689
|
+
tabOptions = computed(() => this.tabs().map((tab) => ({ value: tab.key, label: tab.label })), ...(ngDevMode ? [{ debugName: "tabOptions" }] : /* istanbul ignore next */ []));
|
|
2690
|
+
activeTab = linkedSignal({ ...(ngDevMode ? { debugName: "activeTab" } : /* istanbul ignore next */ {}), source: this.tabs,
|
|
2691
|
+
computation: (tabs, previous) => tabs.some((tab) => tab.key === previous?.value)
|
|
2692
|
+
? previous.value
|
|
2693
|
+
: (tabs[0]?.key ?? '') });
|
|
2694
|
+
activeSection = computed(() => this.tabs().find((tab) => tab.key === this.activeTab()), ...(ngDevMode ? [{ debugName: "activeSection" }] : /* istanbul ignore next */ []));
|
|
2695
|
+
activeConnection = computed(() => {
|
|
2696
|
+
const section = this.activeSection();
|
|
2697
|
+
return section?.kind === 'connection' ? section.child : null;
|
|
2698
|
+
}, ...(ngDevMode ? [{ debugName: "activeConnection" }] : /* istanbul ignore next */ []));
|
|
2699
|
+
connectionScope = computed(() => {
|
|
2700
|
+
const child = this.activeConnection(), row = this.params().data;
|
|
2701
|
+
return child
|
|
2702
|
+
? {
|
|
2703
|
+
kind: 'children',
|
|
2704
|
+
levelId: child.levelId,
|
|
2705
|
+
parentLevelId: row.levelId,
|
|
2706
|
+
parentRecordId: row.recordId,
|
|
2707
|
+
referenceId: child.referenceId,
|
|
2708
|
+
}
|
|
2709
|
+
: null;
|
|
2710
|
+
}, ...(ngDevMode ? [{ debugName: "connectionScope" }] : /* istanbul ignore next */ []));
|
|
2711
|
+
activeModules = computed(() => {
|
|
2712
|
+
const section = this.activeSection();
|
|
2713
|
+
return section?.kind === 'modules' ? section.modules : [];
|
|
2714
|
+
}, ...(ngDevMode ? [{ debugName: "activeModules" }] : /* istanbul ignore next */ []));
|
|
2715
|
+
moduleOptions = computed(() => this.activeModules().map((module) => ({
|
|
2716
|
+
value: module.id,
|
|
2717
|
+
label: module.name,
|
|
2718
|
+
})), ...(ngDevMode ? [{ debugName: "moduleOptions" }] : /* istanbul ignore next */ []));
|
|
2719
|
+
activeModuleId = linkedSignal({ ...(ngDevMode ? { debugName: "activeModuleId" } : /* istanbul ignore next */ {}), source: this.moduleOptions,
|
|
2720
|
+
computation: (modules, previous) => modules.some((module) => module.value === previous?.value)
|
|
2721
|
+
? previous.value
|
|
2722
|
+
: (modules[0]?.value ?? '') });
|
|
2723
|
+
activeModule = computed(() => this.activeModules().find((module) => module.id === this.activeModuleId()), ...(ngDevMode ? [{ debugName: "activeModule" }] : /* istanbul ignore next */ []));
|
|
2724
|
+
constructor() {
|
|
2725
|
+
effect((onCleanup) => {
|
|
2726
|
+
const row = this.params().data;
|
|
2727
|
+
const locale = this.text.language();
|
|
2728
|
+
this.api.scopeIdentity();
|
|
2729
|
+
this.retryVersion();
|
|
2730
|
+
const controller = new AbortController();
|
|
2731
|
+
onCleanup(() => controller.abort());
|
|
2732
|
+
this.workspace.set(null);
|
|
2733
|
+
this.failed.set(false);
|
|
2734
|
+
void this.api
|
|
2735
|
+
.workspace(row.levelId, row.recordId, controller.signal, locale)
|
|
2736
|
+
.then((workspace) => {
|
|
2737
|
+
if (!controller.signal.aborted)
|
|
2738
|
+
this.workspace.set(workspace);
|
|
2739
|
+
}, () => {
|
|
2740
|
+
if (!controller.signal.aborted)
|
|
2741
|
+
this.failed.set(true);
|
|
2742
|
+
});
|
|
2743
|
+
});
|
|
2744
|
+
}
|
|
2745
|
+
retry() {
|
|
2746
|
+
this.retryVersion.update((value) => value + 1);
|
|
2747
|
+
}
|
|
2748
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: StudioRecordWorkspace, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2749
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.8", type: StudioRecordWorkspace, isStandalone: true, selector: "mt-client-studio-record-workspace", inputs: { params: { classPropertyName: "params", publicName: "params", isSignal: true, isRequired: true, transformFunction: null } }, ngImport: i0, template: "@if (workspace(); as data) {\r\n <div class=\"studio-workspace\">\r\n @if (tabs().length) {\r\n <mt-tabs\r\n mode=\"underline\"\r\n [options]=\"tabOptions()\"\r\n [(active)]=\"activeTab\"\r\n fluid\r\n />\r\n @if (activeConnection(); as child) {\r\n @for (\r\n entry of [child];\r\n track params().data.id + \":\" + entry.referenceId\r\n ) {\r\n <mt-client-studio-records-table\r\n [levelId]=\"entry.levelId\"\r\n [scopeOverride]=\"connectionScope()\"\r\n [ancestorKeys]=\"ancestorKeys()\"\r\n [title]=\"entry.name\"\r\n [chartContext]=\"chartContext() + ' \u00B7 ' + entry.name\"\r\n />\r\n }\r\n } @else {\r\n @if (moduleOptions().length > 1) {\r\n <mt-tabs\r\n mode=\"underline\"\r\n size=\"small\"\r\n [options]=\"moduleOptions()\"\r\n [(active)]=\"activeModuleId\"\r\n fluid\r\n />\r\n }\r\n @if (activeModule(); as module) {\r\n @for (entry of [module]; track params().data.id + \":\" + entry.id) {\r\n <mt-client-studio-module-table\r\n [module]=\"entry\"\r\n [owner]=\"data.record\"\r\n [sourcePath]=\"chartContext() + ' \u00B7 ' + entry.name\"\r\n />\r\n }\r\n }\r\n }\r\n } @else {\r\n <p class=\"studio-empty\">{{ text.text(\"empty\") }}</p>\r\n }\r\n </div>\r\n} @else if (failed()) {\r\n <div class=\"studio-section-error\" role=\"alert\">\r\n <p>{{ text.text(\"failed\") }}</p>\r\n <mt-button\r\n [label]=\"text.text('retry')\"\r\n severity=\"secondary\"\r\n (onClick)=\"retry()\"\r\n />\r\n </div>\r\n} @else {\r\n <div class=\"studio-grid-placeholder\" role=\"status\">\r\n {{ text.text(\"loading\") }}\r\n </div>\r\n}\r\n", styles: [":host{display:block;min-width:0;font:inherit;color:var(--p-text-color, #27364b)}.studio-workspace{display:grid;gap:12px;padding:0;min-width:0}.studio-empty{color:var(--p-text-muted-color, #667085);font-size:12px}.studio-group-heading{margin:12px 0 0;padding-inline-start:10px;border-inline-start:3px solid var(--p-primary-color, #2aaec0);font-size:15px;font-weight:600}.studio-module,.studio-child-level{min-width:0;scroll-margin-block-start:20px}.studio-grid-placeholder{min-height:420px;display:grid;align-content:center;justify-items:center;gap:12px;border:1px solid var(--p-content-border-color, #e4e7ec);border-radius:6px;color:var(--p-text-muted-color, #667085);background:var(--p-content-background, #fff)}.studio-section-error{display:flex;min-height:120px;flex-wrap:wrap;align-items:center;justify-content:center;gap:16px}@media(max-width:1100px){.studio-workspace{gap:0}}@media(max-width:640px){.studio-workspace{padding:0;gap:0}:host .studio-command-content{position:fixed;inset-inline:12px;inset-block-start:20dvh;min-width:0;max-height:60dvh}}.studio-commands{display:flex;align-items:center;flex-wrap:wrap;gap:.75rem;margin-block:.75rem}.studio-command-menu{position:relative;font-size:.875rem}.studio-command-menu>summary{cursor:pointer;padding:.5rem .75rem;border:1px solid var(--p-content-border-color, #ddd);border-radius:.375rem}.studio-command-content{position:absolute;inset-block-start:100%;inset-inline-end:0;z-index:30;min-width:18rem;max-height:24rem;overflow:auto;background:var(--p-content-background, white);color:var(--p-text-color, #334155);padding:.75rem;border:1px solid var(--p-content-border-color, #ddd);border-radius:.375rem;display:grid;gap:.75rem}.studio-command-content label{display:flex;align-items:center;gap:.5rem;flex-wrap:wrap}.studio-command-content select{width:100%;padding:.5rem;border:1px solid var(--p-content-border-color, #ddd);background:inherit;color:inherit;border-radius:.375rem}.studio-command-content button{text-align:start;padding:.5rem;cursor:pointer}.studio-comparison{min-width:0}.studio-comparison-hint{margin:0 0 1rem;color:var(--p-text-muted-color, #667085);font-size:.875rem}button:focus-visible,summary:focus-visible,select:focus-visible{outline:2px solid var(--p-primary-color, #2aaec0);outline-offset:2px}\n"], dependencies: [{ kind: "component", type: StudioModuleTable, selector: "mt-client-studio-module-table", inputs: ["module", "owner", "scopeOverride", "sectionId", "sourcePath", "includeDescendants"] }, { kind: "component", type: StudioRecordsTable, selector: "mt-client-studio-records-table", inputs: ["levelId", "scopeOverride", "ancestorKeys", "title", "chartContext", "height"], outputs: ["recordsLoaded", "dataLoaded", "recordsFailed"] }, { kind: "component", type: Button, selector: "mt-button", inputs: ["icon", "label", "tooltip", "class", "type", "styleClass", "severity", "badge", "variant", "badgeSeverity", "size", "iconPos", "autofocus", "fluid", "raised", "rounded", "text", "plain", "outlined", "link", "disabled", "loading", "pInputs", "ariaLabel"], outputs: ["onClick", "onFocus", "onBlur"] }, { kind: "component", type: Tabs, selector: "mt-tabs", inputs: ["options", "optionLabel", "optionValue", "active", "mode", "moreLabel", "defaultIcon", "size", "fluid", "disabled", "searchThreshold"], outputs: ["activeChange", "onChange"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
2750
|
+
}
|
|
2751
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: StudioRecordWorkspace, decorators: [{
|
|
2752
|
+
type: Component,
|
|
2753
|
+
args: [{ selector: 'mt-client-studio-record-workspace', imports: [StudioModuleTable, StudioRecordsTable, Button, Tabs], changeDetection: ChangeDetectionStrategy.OnPush, template: "@if (workspace(); as data) {\r\n <div class=\"studio-workspace\">\r\n @if (tabs().length) {\r\n <mt-tabs\r\n mode=\"underline\"\r\n [options]=\"tabOptions()\"\r\n [(active)]=\"activeTab\"\r\n fluid\r\n />\r\n @if (activeConnection(); as child) {\r\n @for (\r\n entry of [child];\r\n track params().data.id + \":\" + entry.referenceId\r\n ) {\r\n <mt-client-studio-records-table\r\n [levelId]=\"entry.levelId\"\r\n [scopeOverride]=\"connectionScope()\"\r\n [ancestorKeys]=\"ancestorKeys()\"\r\n [title]=\"entry.name\"\r\n [chartContext]=\"chartContext() + ' \u00B7 ' + entry.name\"\r\n />\r\n }\r\n } @else {\r\n @if (moduleOptions().length > 1) {\r\n <mt-tabs\r\n mode=\"underline\"\r\n size=\"small\"\r\n [options]=\"moduleOptions()\"\r\n [(active)]=\"activeModuleId\"\r\n fluid\r\n />\r\n }\r\n @if (activeModule(); as module) {\r\n @for (entry of [module]; track params().data.id + \":\" + entry.id) {\r\n <mt-client-studio-module-table\r\n [module]=\"entry\"\r\n [owner]=\"data.record\"\r\n [sourcePath]=\"chartContext() + ' \u00B7 ' + entry.name\"\r\n />\r\n }\r\n }\r\n }\r\n } @else {\r\n <p class=\"studio-empty\">{{ text.text(\"empty\") }}</p>\r\n }\r\n </div>\r\n} @else if (failed()) {\r\n <div class=\"studio-section-error\" role=\"alert\">\r\n <p>{{ text.text(\"failed\") }}</p>\r\n <mt-button\r\n [label]=\"text.text('retry')\"\r\n severity=\"secondary\"\r\n (onClick)=\"retry()\"\r\n />\r\n </div>\r\n} @else {\r\n <div class=\"studio-grid-placeholder\" role=\"status\">\r\n {{ text.text(\"loading\") }}\r\n </div>\r\n}\r\n", styles: [":host{display:block;min-width:0;font:inherit;color:var(--p-text-color, #27364b)}.studio-workspace{display:grid;gap:12px;padding:0;min-width:0}.studio-empty{color:var(--p-text-muted-color, #667085);font-size:12px}.studio-group-heading{margin:12px 0 0;padding-inline-start:10px;border-inline-start:3px solid var(--p-primary-color, #2aaec0);font-size:15px;font-weight:600}.studio-module,.studio-child-level{min-width:0;scroll-margin-block-start:20px}.studio-grid-placeholder{min-height:420px;display:grid;align-content:center;justify-items:center;gap:12px;border:1px solid var(--p-content-border-color, #e4e7ec);border-radius:6px;color:var(--p-text-muted-color, #667085);background:var(--p-content-background, #fff)}.studio-section-error{display:flex;min-height:120px;flex-wrap:wrap;align-items:center;justify-content:center;gap:16px}@media(max-width:1100px){.studio-workspace{gap:0}}@media(max-width:640px){.studio-workspace{padding:0;gap:0}:host .studio-command-content{position:fixed;inset-inline:12px;inset-block-start:20dvh;min-width:0;max-height:60dvh}}.studio-commands{display:flex;align-items:center;flex-wrap:wrap;gap:.75rem;margin-block:.75rem}.studio-command-menu{position:relative;font-size:.875rem}.studio-command-menu>summary{cursor:pointer;padding:.5rem .75rem;border:1px solid var(--p-content-border-color, #ddd);border-radius:.375rem}.studio-command-content{position:absolute;inset-block-start:100%;inset-inline-end:0;z-index:30;min-width:18rem;max-height:24rem;overflow:auto;background:var(--p-content-background, white);color:var(--p-text-color, #334155);padding:.75rem;border:1px solid var(--p-content-border-color, #ddd);border-radius:.375rem;display:grid;gap:.75rem}.studio-command-content label{display:flex;align-items:center;gap:.5rem;flex-wrap:wrap}.studio-command-content select{width:100%;padding:.5rem;border:1px solid var(--p-content-border-color, #ddd);background:inherit;color:inherit;border-radius:.375rem}.studio-command-content button{text-align:start;padding:.5rem;cursor:pointer}.studio-comparison{min-width:0}.studio-comparison-hint{margin:0 0 1rem;color:var(--p-text-muted-color, #667085);font-size:.875rem}button:focus-visible,summary:focus-visible,select:focus-visible{outline:2px solid var(--p-primary-color, #2aaec0);outline-offset:2px}\n"] }]
|
|
2754
|
+
}], ctorParameters: () => [], propDecorators: { params: [{ type: i0.Input, args: [{ isSignal: true, alias: "params", required: true }] }] } });
|
|
2755
|
+
|
|
2756
|
+
/**
|
|
2757
|
+
* Studio: one page, no navigation. A records grid whose detail row is the
|
|
2758
|
+
* record's workspace (module tabs), module grids paged at 50 rows on the
|
|
2759
|
+
* client, cross-record comparison, summaries and the combined export.
|
|
2760
|
+
*
|
|
2761
|
+
* The context is opaque, like `mt-client-list`: `'Level:12'` (pplus) or
|
|
2762
|
+
* `{ contextKey: 'ComponentSchema:7' }` (splus). Endpoints come from
|
|
2763
|
+
* `provideClientStudio()`; the defaults are the pplus routes.
|
|
2764
|
+
*
|
|
2765
|
+
* Every grid keeps its charts through `mt-standard-grid [chartPersistence]`; Studio
|
|
2766
|
+
* provides the store: the backend set at `chartsEndpoint` (default `grid-charts/me`) after
|
|
2767
|
+
* the browser copy, or the browser only with `options.chartStore: 'local'`. A visit warms
|
|
2768
|
+
* the schema's sets with one level request.
|
|
2769
|
+
*
|
|
2770
|
+
* Load it from a lazy route: this entry pulls in the grid, and
|
|
2771
|
+
* `@masterteam/client-components` (the main entry) never imports it.
|
|
2772
|
+
*/
|
|
2773
|
+
class ClientStudio {
|
|
2774
|
+
/** `'Level:12'` is shorthand for `{ contextKey: 'Level:12' }`. */
|
|
2775
|
+
context = input.required(...(ngDevMode ? [{ debugName: "context" }] : /* istanbul ignore next */ []));
|
|
2776
|
+
options = input({}, ...(ngDevMode ? [{ debugName: "options" }] : /* istanbul ignore next */ []));
|
|
2777
|
+
/** `'fill'` fills the window below the Studio's top (minimum 400px). */
|
|
2778
|
+
height = input('fill', ...(ngDevMode ? [{ debugName: "height" }] : /* istanbul ignore next */ []));
|
|
2779
|
+
/** The first records load of a context finished. */
|
|
2780
|
+
loaded = output();
|
|
2781
|
+
/** The catalog or the records failed, with the message the section shows. */
|
|
2782
|
+
errored = output();
|
|
2783
|
+
/**
|
|
2784
|
+
* The user chose "Open record" on a row of any Studio grid. Only offered when
|
|
2785
|
+
* `options.recordOpen` is `true`; the host decides what opening means.
|
|
2786
|
+
*/
|
|
2787
|
+
recordOpen = output();
|
|
2788
|
+
/**
|
|
2789
|
+
* The root records load finished (and again after a reload or a context or `key`
|
|
2790
|
+
* change): the root query's `schemas` and each record without its `values`. Tagged
|
|
2791
|
+
* with the context it was loaded for, so a host can discard a stale load.
|
|
2792
|
+
*/
|
|
2793
|
+
dataLoaded = output();
|
|
2794
|
+
resolved = computed(() => resolveClientStudioContext(this.context()), { ...(ngDevMode ? { debugName: "resolved" } : /* istanbul ignore next */ {}), equal: sameStudioContext });
|
|
2795
|
+
schemaId = computed(() => this.resolved().schemaId, ...(ngDevMode ? [{ debugName: "schemaId" }] : /* istanbul ignore next */ []));
|
|
2796
|
+
title = computed(() => this.options().title ?? '', ...(ngDevMode ? [{ debugName: "title" }] : /* istanbul ignore next */ []));
|
|
2797
|
+
measured = signal(600, ...(ngDevMode ? [{ debugName: "measured" }] : /* istanbul ignore next */ []));
|
|
2798
|
+
gridHeight = computed(() => {
|
|
2799
|
+
const height = this.height();
|
|
2800
|
+
return typeof height === 'number' ? height : this.measured();
|
|
2801
|
+
}, ...(ngDevMode ? [{ debugName: "gridHeight" }] : /* istanbul ignore next */ []));
|
|
2802
|
+
text = inject(StudioText);
|
|
2803
|
+
announced = null;
|
|
2804
|
+
constructor() {
|
|
2805
|
+
inject(StudioHost).bind(() => this.resolved(), () => this.options(), (event) => this.recordOpen.emit(event));
|
|
2806
|
+
const chartScope = inject(MtGridChartScope), chartStore = inject(MT_GRID_CHART_STORE), configuration = inject(MT_DATA_TABLE_CONFIGURATION$1), injector = inject(Injector);
|
|
2807
|
+
let previousScope;
|
|
2808
|
+
effect(() => {
|
|
2809
|
+
const schemaId = this.schemaId(), identity = configuration.identity(), scope = JSON.stringify([schemaId, identity]);
|
|
2810
|
+
if (scope === previousScope)
|
|
2811
|
+
return;
|
|
2812
|
+
// A new schema or actor. Each grid drops its own charts unsaved (a new chart key);
|
|
2813
|
+
// the popups kept from grids already torn down close once this render has removed
|
|
2814
|
+
// the old grids, so no live grid reports their removal as a change to save.
|
|
2815
|
+
if (previousScope !== undefined)
|
|
2816
|
+
afterNextRender(() => chartScope.clear(), { injector });
|
|
2817
|
+
previousScope = scope;
|
|
2818
|
+
// One request for every chart set saved at the schema, instead of one per grid.
|
|
2819
|
+
if (schemaId !== null && identity)
|
|
2820
|
+
untracked(() => void chartStore.prefetch?.({ level: schemaId }));
|
|
2821
|
+
});
|
|
2822
|
+
const host = inject(ElementRef), destroy = inject(DestroyRef);
|
|
2823
|
+
afterNextRender(() => {
|
|
2824
|
+
const resize = () => {
|
|
2825
|
+
chartScope.themeSource =
|
|
2826
|
+
host.nativeElement.querySelector('mt-data-grid') ??
|
|
2827
|
+
host.nativeElement;
|
|
2828
|
+
this.measured.set(Math.max(400, window.innerHeight -
|
|
2829
|
+
host.nativeElement.getBoundingClientRect().top -
|
|
2830
|
+
24));
|
|
2831
|
+
};
|
|
2832
|
+
const observer = new ResizeObserver(resize);
|
|
2833
|
+
observer.observe(host.nativeElement.parentElement ?? host.nativeElement);
|
|
2834
|
+
window.addEventListener('resize', resize, { passive: true });
|
|
2835
|
+
resize();
|
|
2836
|
+
destroy.onDestroy(() => {
|
|
2837
|
+
observer.disconnect();
|
|
2838
|
+
window.removeEventListener('resize', resize);
|
|
2839
|
+
});
|
|
2840
|
+
});
|
|
2841
|
+
}
|
|
2842
|
+
recordsLoaded() {
|
|
2843
|
+
const identity = JSON.stringify(this.resolved());
|
|
2844
|
+
if (this.announced === identity)
|
|
2845
|
+
return;
|
|
2846
|
+
this.announced = identity;
|
|
2847
|
+
this.loaded.emit();
|
|
2848
|
+
}
|
|
2849
|
+
rootLoaded(event) {
|
|
2850
|
+
this.dataLoaded.emit(event);
|
|
2851
|
+
}
|
|
2852
|
+
recordsFailed() {
|
|
2853
|
+
this.errored.emit({ message: this.text.text('failed') });
|
|
2854
|
+
}
|
|
2855
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: ClientStudio, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2856
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.8", type: ClientStudio, isStandalone: true, selector: "mt-client-studio", inputs: { context: { classPropertyName: "context", publicName: "context", isSignal: true, isRequired: true, transformFunction: null }, options: { classPropertyName: "options", publicName: "options", isSignal: true, isRequired: false, transformFunction: null }, height: { classPropertyName: "height", publicName: "height", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { loaded: "loaded", errored: "errored", recordOpen: "recordOpen", dataLoaded: "dataLoaded" }, host: { styleAttribute: "display:block;min-width:0" }, providers: [
|
|
2857
|
+
StudioHost,
|
|
2858
|
+
StudioApiService,
|
|
2859
|
+
MtGridChartScope,
|
|
2860
|
+
provideStudioChartStore(),
|
|
2861
|
+
StudioText,
|
|
2862
|
+
{ provide: STUDIO_WORKSPACE_RENDERER, useValue: StudioRecordWorkspace },
|
|
2863
|
+
], ngImport: i0, template: "@if (schemaId(); as id) {\r\n <mt-client-studio-records-table\r\n [levelId]=\"id\"\r\n [height]=\"gridHeight()\"\r\n [title]=\"title()\"\r\n (recordsLoaded)=\"recordsLoaded()\"\r\n (dataLoaded)=\"rootLoaded($event)\"\r\n (recordsFailed)=\"recordsFailed()\"\r\n />\r\n}\r\n", dependencies: [{ kind: "component", type: StudioRecordsTable, selector: "mt-client-studio-records-table", inputs: ["levelId", "scopeOverride", "ancestorKeys", "title", "chartContext", "height"], outputs: ["recordsLoaded", "dataLoaded", "recordsFailed"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
2864
|
+
}
|
|
2865
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: ClientStudio, decorators: [{
|
|
2866
|
+
type: Component,
|
|
2867
|
+
args: [{ selector: 'mt-client-studio', imports: [StudioRecordsTable], providers: [
|
|
2868
|
+
StudioHost,
|
|
2869
|
+
StudioApiService,
|
|
2870
|
+
MtGridChartScope,
|
|
2871
|
+
provideStudioChartStore(),
|
|
2872
|
+
StudioText,
|
|
2873
|
+
{ provide: STUDIO_WORKSPACE_RENDERER, useValue: StudioRecordWorkspace },
|
|
2874
|
+
], host: { style: 'display:block;min-width:0' }, changeDetection: ChangeDetectionStrategy.OnPush, template: "@if (schemaId(); as id) {\r\n <mt-client-studio-records-table\r\n [levelId]=\"id\"\r\n [height]=\"gridHeight()\"\r\n [title]=\"title()\"\r\n (recordsLoaded)=\"recordsLoaded()\"\r\n (dataLoaded)=\"rootLoaded($event)\"\r\n (recordsFailed)=\"recordsFailed()\"\r\n />\r\n}\r\n" }]
|
|
2875
|
+
}], ctorParameters: () => [], propDecorators: { context: [{ type: i0.Input, args: [{ isSignal: true, alias: "context", required: true }] }], options: [{ type: i0.Input, args: [{ isSignal: true, alias: "options", required: false }] }], height: [{ type: i0.Input, args: [{ isSignal: true, alias: "height", required: false }] }], loaded: [{ type: i0.Output, args: ["loaded"] }], errored: [{ type: i0.Output, args: ["errored"] }], recordOpen: [{ type: i0.Output, args: ["recordOpen"] }], dataLoaded: [{ type: i0.Output, args: ["dataLoaded"] }] } });
|
|
2876
|
+
|
|
2877
|
+
/**
|
|
2878
|
+
* Generated bundle index. Do not edit.
|
|
2879
|
+
*/
|
|
2880
|
+
|
|
2881
|
+
export { CLIENT_STUDIO_DEFAULT_ENDPOINTS, ClientStudio, MT_CLIENT_STUDIO_ENDPOINTS, provideClientStudio, resolveClientStudioContext, studioSchemaId };
|
|
2882
|
+
//# sourceMappingURL=masterteam-client-components-studio.mjs.map
|