@masterteam/dashboard-builder 0.0.116 → 0.0.118
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 +65 -75
- package/assets/dashboard-builder.css +2 -2
- package/assets/i18n/ar.json +3 -1
- package/assets/i18n/en.json +3 -1
- package/fesm2022/{masterteam-dashboard-builder-dashboard-dialog.component-BDNd7eud.mjs → masterteam-dashboard-builder-dashboard-dialog.component-DFy4sv6t.mjs} +2 -2
- package/fesm2022/{masterteam-dashboard-builder-dashboard-dialog.component-BDNd7eud.mjs.map → masterteam-dashboard-builder-dashboard-dialog.component-DFy4sv6t.mjs.map} +1 -1
- package/fesm2022/{masterteam-dashboard-builder-masterteam-dashboard-builder-BjNTcvqc.mjs → masterteam-dashboard-builder-masterteam-dashboard-builder-2MrkLmtr.mjs} +943 -2425
- package/fesm2022/masterteam-dashboard-builder-masterteam-dashboard-builder-2MrkLmtr.mjs.map +1 -0
- package/fesm2022/masterteam-dashboard-builder-table-card.component-CKAm_KXn.mjs +1431 -0
- package/fesm2022/masterteam-dashboard-builder-table-card.component-CKAm_KXn.mjs.map +1 -0
- package/fesm2022/masterteam-dashboard-builder.mjs +1 -1
- package/package.json +7 -6
- package/types/masterteam-dashboard-builder.d.ts +92 -169
- package/fesm2022/masterteam-dashboard-builder-masterteam-dashboard-builder-BjNTcvqc.mjs.map +0 -1
- package/fesm2022/masterteam-dashboard-builder-riyadh.geo-CE3Amxoa.mjs +0 -3902
- package/fesm2022/masterteam-dashboard-builder-riyadh.geo-CE3Amxoa.mjs.map +0 -1
- package/fesm2022/masterteam-dashboard-builder-saudi.geo-C_9VzPCF.mjs +0 -2530
- package/fesm2022/masterteam-dashboard-builder-saudi.geo-C_9VzPCF.mjs.map +0 -1
|
@@ -0,0 +1,1431 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { input, computed, ChangeDetectionStrategy, Component, inject, output, signal, viewChildren, viewChild, effect, afterRenderEffect, untracked } from '@angular/core';
|
|
3
|
+
import { mtEntityColumn, mtEntityCellValues, MtTemplateCell, MtStandardGridComponent } from '@masterteam/data-table';
|
|
4
|
+
import { E as EntityInfoComponent, D as DashboardItemStoreService, f as formatValue, a as fillColorForPercentageProperty, d as dynamicReorder, n as normalizePhaseGatePropertyIdentity, r as resolvePhaseGateResponseKey, b as resolveLegendColorOverride, o as orderLegendItems, g as getLegendOverrideOrder, C as ClickDispatcher, h as hasDoubleClickAction, c as CardContentComponent } from './masterteam-dashboard-builder-masterteam-dashboard-builder-2MrkLmtr.mjs';
|
|
5
|
+
import * as i1 from '@angular/common';
|
|
6
|
+
import { CommonModule } from '@angular/common';
|
|
7
|
+
import { Subscription } from 'rxjs';
|
|
8
|
+
import { TranslocoService, TranslocoDirective } from '@jsverse/transloco';
|
|
9
|
+
|
|
10
|
+
/** A group row of a dashboard table: the group's entity value and the server's aggregates. */
|
|
11
|
+
class TableCardGroupValue {
|
|
12
|
+
params = input.required(...(ngDevMode ? [{ debugName: "params" }] : /* istanbul ignore next */ []));
|
|
13
|
+
first = computed(() => this.params().node.allLeafChildren?.[0]?.data, ...(ngDevMode ? [{ debugName: "first" }] : /* istanbul ignore next */ []));
|
|
14
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: TableCardGroupValue, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
15
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.8", type: TableCardGroupValue, isStandalone: true, selector: "mt-table-card-group-value", inputs: { params: { classPropertyName: "params", publicName: "params", isSignal: true, isRequired: true, transformFunction: null } }, ngImport: i0, template: "@if (first(); as row) {\r\n <span class=\"inline-flex flex-wrap items-center gap-x-4 gap-y-1\">\r\n <mt-entity-info\r\n [data]=\"{\r\n viewType: row.__mtgroup?.viewType,\r\n value: row.__mtgroup?.value,\r\n }\"\r\n displayType=\"inTable\"\r\n />\r\n @if (row.__mtaggregates) {\r\n <span class=\"text-xs font-medium whitespace-pre-wrap\">{{\r\n row.__mtaggregates\r\n }}</span>\r\n }\r\n </span>\r\n}\r\n", dependencies: [{ kind: "component", type: EntityInfoComponent, selector: "mt-entity-info", inputs: ["data", "displayType", "extraInfoData", "limitWords", "customClass"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
16
|
+
}
|
|
17
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: TableCardGroupValue, decorators: [{
|
|
18
|
+
type: Component,
|
|
19
|
+
args: [{ selector: 'mt-table-card-group-value', imports: [EntityInfoComponent], changeDetection: ChangeDetectionStrategy.OnPush, template: "@if (first(); as row) {\r\n <span class=\"inline-flex flex-wrap items-center gap-x-4 gap-y-1\">\r\n <mt-entity-info\r\n [data]=\"{\r\n viewType: row.__mtgroup?.viewType,\r\n value: row.__mtgroup?.value,\r\n }\"\r\n displayType=\"inTable\"\r\n />\r\n @if (row.__mtaggregates) {\r\n <span class=\"text-xs font-medium whitespace-pre-wrap\">{{\r\n row.__mtaggregates\r\n }}</span>\r\n }\r\n </span>\r\n}\r\n" }]
|
|
20
|
+
}], propDecorators: { params: [{ type: i0.Input, args: [{ isSignal: true, alias: "params", required: true }] }] } });
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Table Card Component
|
|
24
|
+
*
|
|
25
|
+
* Displays data in a table format with entity-info rendering.
|
|
26
|
+
* Matches old app-table-card + app-table behavior.
|
|
27
|
+
*
|
|
28
|
+
* Features:
|
|
29
|
+
* - Grouped and non-grouped modes
|
|
30
|
+
* - Entity-info rendering for each cell viewType
|
|
31
|
+
* - Column sorting
|
|
32
|
+
* - Row click actions
|
|
33
|
+
* - Style configuration
|
|
34
|
+
* - Status labels
|
|
35
|
+
*/
|
|
36
|
+
/**
|
|
37
|
+
* Helper: switch all keys to lowercase
|
|
38
|
+
*/
|
|
39
|
+
function switchAllKeysSmall(obj) {
|
|
40
|
+
if (!obj || typeof obj !== 'object')
|
|
41
|
+
return obj;
|
|
42
|
+
const result = {};
|
|
43
|
+
Object.keys(obj).forEach((key) => {
|
|
44
|
+
result[key.toLowerCase()] = obj[key];
|
|
45
|
+
});
|
|
46
|
+
return result;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Helper: get object with keys in lowercase
|
|
50
|
+
*/
|
|
51
|
+
function getObjectKeysInLowerCase(obj) {
|
|
52
|
+
if (!obj || typeof obj !== 'object')
|
|
53
|
+
return obj;
|
|
54
|
+
const result = {};
|
|
55
|
+
Object.keys(obj).forEach((key) => {
|
|
56
|
+
result[key.toLowerCase()] = obj[key];
|
|
57
|
+
});
|
|
58
|
+
return result;
|
|
59
|
+
}
|
|
60
|
+
function unwrapEntityValue(value) {
|
|
61
|
+
if (value === null || value === undefined)
|
|
62
|
+
return value;
|
|
63
|
+
if (typeof value !== 'object')
|
|
64
|
+
return value;
|
|
65
|
+
const wrapped = value.value;
|
|
66
|
+
if (wrapped !== undefined && wrapped !== null) {
|
|
67
|
+
if (typeof wrapped !== 'object')
|
|
68
|
+
return wrapped;
|
|
69
|
+
return (wrapped.value ??
|
|
70
|
+
wrapped.key ??
|
|
71
|
+
wrapped.id ??
|
|
72
|
+
wrapped.actualValue ??
|
|
73
|
+
wrapped.displayValue ??
|
|
74
|
+
wrapped.name ??
|
|
75
|
+
wrapped.displayName ??
|
|
76
|
+
wrapped.display ??
|
|
77
|
+
wrapped);
|
|
78
|
+
}
|
|
79
|
+
return (value.rawValue ??
|
|
80
|
+
value.actualValue ??
|
|
81
|
+
value.key ??
|
|
82
|
+
value.id ??
|
|
83
|
+
value.displayValue ??
|
|
84
|
+
value.displayName ??
|
|
85
|
+
value.name ??
|
|
86
|
+
value.display ??
|
|
87
|
+
value);
|
|
88
|
+
}
|
|
89
|
+
function displayEntityValue(value) {
|
|
90
|
+
if (value === null || value === undefined)
|
|
91
|
+
return '';
|
|
92
|
+
if (typeof value !== 'object')
|
|
93
|
+
return String(value);
|
|
94
|
+
const wrapped = value.value;
|
|
95
|
+
if (wrapped && typeof wrapped === 'object') {
|
|
96
|
+
const display = wrapped.display;
|
|
97
|
+
return String(wrapped.displayName ??
|
|
98
|
+
wrapped.name ??
|
|
99
|
+
(typeof display === 'object'
|
|
100
|
+
? display?.name || display?.displayName || display?.label
|
|
101
|
+
: display) ??
|
|
102
|
+
wrapped.value ??
|
|
103
|
+
wrapped.key ??
|
|
104
|
+
'');
|
|
105
|
+
}
|
|
106
|
+
return String(value.displayName ??
|
|
107
|
+
value.name ??
|
|
108
|
+
value.display ??
|
|
109
|
+
value.label ??
|
|
110
|
+
unwrapEntityValue(value) ??
|
|
111
|
+
'');
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* One entry per property key across ALL rows, in first-seen order. Rows from
|
|
115
|
+
* different sources of a multi-source table carry different keys (milestone_*
|
|
116
|
+
* on some, deliverable_* on others); building columns from a single "widest"
|
|
117
|
+
* row dropped every other source's columns and showed their values as empty.
|
|
118
|
+
*/
|
|
119
|
+
function columnSample(values) {
|
|
120
|
+
const sample = {};
|
|
121
|
+
values.forEach((item) => {
|
|
122
|
+
const itemLower = getObjectKeysInLowerCase(item || {});
|
|
123
|
+
Object.keys(itemLower).forEach((key) => {
|
|
124
|
+
if (!(key in sample))
|
|
125
|
+
sample[key] = itemLower[key];
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
return sample;
|
|
129
|
+
}
|
|
130
|
+
function normalizeIdentity(value) {
|
|
131
|
+
return String(value ?? '')
|
|
132
|
+
.trim()
|
|
133
|
+
.toLowerCase()
|
|
134
|
+
.replace(/[\s_-]+/g, '');
|
|
135
|
+
}
|
|
136
|
+
function fieldIdentity(prop, fallbackKey) {
|
|
137
|
+
return [prop?.normalizedKey, prop?.key, fallbackKey, prop?.label, prop?.name]
|
|
138
|
+
.map(normalizeIdentity)
|
|
139
|
+
.filter(Boolean)
|
|
140
|
+
.join('|');
|
|
141
|
+
}
|
|
142
|
+
function isIdentityField(prop, fallbackKey) {
|
|
143
|
+
const identities = [
|
|
144
|
+
normalizeIdentity(fallbackKey),
|
|
145
|
+
normalizeIdentity(prop?.normalizedKey),
|
|
146
|
+
normalizeIdentity(prop?.key),
|
|
147
|
+
normalizeIdentity(prop?.label),
|
|
148
|
+
].filter(Boolean);
|
|
149
|
+
return identities.some((identity) => identity === 'id' ||
|
|
150
|
+
identity.endsWith('id') ||
|
|
151
|
+
identity === 'identifier' ||
|
|
152
|
+
identity.includes('leveldataid') ||
|
|
153
|
+
identity.includes('moduledataid') ||
|
|
154
|
+
identity.includes('entityid'));
|
|
155
|
+
}
|
|
156
|
+
function toBooleanValue(value) {
|
|
157
|
+
const primitive = unwrapEntityValue(value);
|
|
158
|
+
if (typeof primitive === 'boolean')
|
|
159
|
+
return primitive;
|
|
160
|
+
if (typeof primitive === 'number')
|
|
161
|
+
return primitive === 1;
|
|
162
|
+
const text = String(primitive ?? '')
|
|
163
|
+
.trim()
|
|
164
|
+
.toLowerCase();
|
|
165
|
+
return text === 'true' || text === '1' || text === 'yes';
|
|
166
|
+
}
|
|
167
|
+
function toNumberValue(value) {
|
|
168
|
+
const primitive = unwrapEntityValue(value);
|
|
169
|
+
if (primitive === null ||
|
|
170
|
+
primitive === undefined ||
|
|
171
|
+
(typeof primitive === 'string' && !primitive.trim())) {
|
|
172
|
+
return null;
|
|
173
|
+
}
|
|
174
|
+
const num = Number(primitive);
|
|
175
|
+
return Number.isFinite(num) ? num : null;
|
|
176
|
+
}
|
|
177
|
+
function getEntityColor(value) {
|
|
178
|
+
const wrapped = value?.value;
|
|
179
|
+
return (wrapped?.details?.color ||
|
|
180
|
+
wrapped?.display?.color ||
|
|
181
|
+
wrapped?.color ||
|
|
182
|
+
value?.details?.color ||
|
|
183
|
+
value?.display?.color ||
|
|
184
|
+
value?.color ||
|
|
185
|
+
'');
|
|
186
|
+
}
|
|
187
|
+
class TableCardComponent {
|
|
188
|
+
storeService = inject(DashboardItemStoreService);
|
|
189
|
+
transloco = inject(TranslocoService);
|
|
190
|
+
subscription = new Subscription();
|
|
191
|
+
/** Dashboard ID */
|
|
192
|
+
dashboardId = input.required(...(ngDevMode ? [{ debugName: "dashboardId" }] : /* istanbul ignore next */ []));
|
|
193
|
+
/** Whether card is in a group */
|
|
194
|
+
inGroup = input(false, ...(ngDevMode ? [{ debugName: "inGroup" }] : /* istanbul ignore next */ []));
|
|
195
|
+
/** Hide the card header (e.g. inside a dialog where the dialog header suffices). */
|
|
196
|
+
hideHeader = input(false, ...(ngDevMode ? [{ debugName: "hideHeader" }] : /* istanbul ignore next */ []));
|
|
197
|
+
/** Action event output */
|
|
198
|
+
onAction = output();
|
|
199
|
+
/** Configuration item */
|
|
200
|
+
configurationItem = signal(null, ...(ngDevMode ? [{ debugName: "configurationItem" }] : /* istanbul ignore next */ []));
|
|
201
|
+
/** Raw data from handler */
|
|
202
|
+
rawData = signal(null, ...(ngDevMode ? [{ debugName: "rawData" }] : /* istanbul ignore next */ []));
|
|
203
|
+
/** Loading state */
|
|
204
|
+
loading = signal(false, ...(ngDevMode ? [{ debugName: "loading" }] : /* istanbul ignore next */ []));
|
|
205
|
+
/** Columns */
|
|
206
|
+
columns = signal([], ...(ngDevMode ? [{ debugName: "columns" }] : /* istanbul ignore next */ []));
|
|
207
|
+
/** Labels for status display */
|
|
208
|
+
labels = signal([], ...(ngDevMode ? [{ debugName: "labels" }] : /* istanbul ignore next */ []));
|
|
209
|
+
/** Table legends are visible by default for backward compatibility. */
|
|
210
|
+
showLegend = computed(() => this.configurationItem()?.clientConfig?.configAsType?.['legend']?.['show'] !== false, ...(ngDevMode ? [{ debugName: "showLegend" }] : /* istanbul ignore next */ []));
|
|
211
|
+
/**
|
|
212
|
+
* Whether there is a legend to render at all. Shared by both hosts (the card
|
|
213
|
+
* header's top-end slot and, when the header is hidden, the card body) so the
|
|
214
|
+
* two never disagree about visibility.
|
|
215
|
+
*/
|
|
216
|
+
hasLegend = computed(() => this.showLegend() && this.labels().length > 0, ...(ngDevMode ? [{ debugName: "hasLegend" }] : /* istanbul ignore next */ []));
|
|
217
|
+
legendPosition = computed(() => {
|
|
218
|
+
const position = this.configurationItem()?.clientConfig?.configAsType?.['legend']?.['position'];
|
|
219
|
+
return position === 'right' ||
|
|
220
|
+
position === 'bottom' ||
|
|
221
|
+
position === 'left'
|
|
222
|
+
? position
|
|
223
|
+
: 'top';
|
|
224
|
+
}, ...(ngDevMode ? [{ debugName: "legendPosition" }] : /* istanbul ignore next */ []));
|
|
225
|
+
legendIconType = computed(() => {
|
|
226
|
+
const iconType = this.configurationItem()?.clientConfig?.configAsType?.['legend']?.['iconType'];
|
|
227
|
+
return typeof iconType === 'string' && iconType ? iconType : 'circle';
|
|
228
|
+
}, ...(ngDevMode ? [{ debugName: "legendIconType" }] : /* istanbul ignore next */ []));
|
|
229
|
+
isSideLegend = computed(() => this.legendPosition() === 'left' || this.legendPosition() === 'right', ...(ngDevMode ? [{ debugName: "isSideLegend" }] : /* istanbul ignore next */ []));
|
|
230
|
+
/** Processed table rows */
|
|
231
|
+
tableRows = signal([], ...(ngDevMode ? [{ debugName: "tableRows" }] : /* istanbul ignore next */ []));
|
|
232
|
+
/** Grouped data */
|
|
233
|
+
groupedData = signal([], ...(ngDevMode ? [{ debugName: "groupedData" }] : /* istanbul ignore next */ []));
|
|
234
|
+
/** Totals the backend calculated for a flat table's aggregations. */
|
|
235
|
+
tableAggregates = signal([], ...(ngDevMode ? [{ debugName: "tableAggregates" }] : /* istanbul ignore next */ []));
|
|
236
|
+
static AGGREGATE_LABEL_KEYS = {
|
|
237
|
+
sum: 'sum',
|
|
238
|
+
avg: 'average',
|
|
239
|
+
average: 'average',
|
|
240
|
+
count: 'count',
|
|
241
|
+
min: 'min',
|
|
242
|
+
max: 'max',
|
|
243
|
+
formula: 'formula',
|
|
244
|
+
};
|
|
245
|
+
/**
|
|
246
|
+
* "Sum · Actual Progress: 138.55" per aggregation (`{ propertyKey,
|
|
247
|
+
* aggregateFunction, alias, value }`); an alias replaces the generated name.
|
|
248
|
+
*/
|
|
249
|
+
aggregateSummary(aggregates) {
|
|
250
|
+
if (!Array.isArray(aggregates) || !aggregates.length)
|
|
251
|
+
return '';
|
|
252
|
+
const lang = this.transloco.getActiveLang();
|
|
253
|
+
return aggregates
|
|
254
|
+
.map((aggregate) => {
|
|
255
|
+
const alias = String(aggregate?.alias ?? '').trim();
|
|
256
|
+
const key = String(aggregate?.propertyKey ?? '').toLowerCase();
|
|
257
|
+
const column = this.columns().find((col) => (col.keyPure ?? col.key)?.toLowerCase() === key);
|
|
258
|
+
const fnKey = TableCardComponent.AGGREGATE_LABEL_KEYS[String(aggregate?.aggregateFunction ?? '').toLowerCase()];
|
|
259
|
+
const name = alias ||
|
|
260
|
+
[
|
|
261
|
+
fnKey
|
|
262
|
+
? this.transloco.translate(`dashboardBuilder.${fnKey}`)
|
|
263
|
+
: aggregate?.aggregateFunction,
|
|
264
|
+
column?.label ?? aggregate?.propertyKey,
|
|
265
|
+
]
|
|
266
|
+
.filter(Boolean)
|
|
267
|
+
.join(' · ');
|
|
268
|
+
const value = aggregate?.value === null || aggregate?.value === undefined
|
|
269
|
+
? '-'
|
|
270
|
+
: formatValue(aggregate.value, undefined, lang);
|
|
271
|
+
return `${name}: ${value}`;
|
|
272
|
+
})
|
|
273
|
+
.join(' ');
|
|
274
|
+
}
|
|
275
|
+
/** Title */
|
|
276
|
+
title = computed(() => {
|
|
277
|
+
const config = this.configurationItem();
|
|
278
|
+
const lang = this.transloco.getActiveLang();
|
|
279
|
+
return config?.clientConfig?.title?.[lang] || '';
|
|
280
|
+
}, ...(ngDevMode ? [{ debugName: "title" }] : /* istanbul ignore next */ []));
|
|
281
|
+
/** Table style config */
|
|
282
|
+
tableStyleConfig = computed(() => {
|
|
283
|
+
const config = this.configurationItem();
|
|
284
|
+
return config?.clientConfig?.['tableFormat'] || null;
|
|
285
|
+
}, ...(ngDevMode ? [{ debugName: "tableStyleConfig" }] : /* istanbul ignore next */ []));
|
|
286
|
+
/**
|
|
287
|
+
* The configured default sort (tableFormat.sortConfig) as a grid sort model. The
|
|
288
|
+
* configured column is a selected-property key; normalize like the hidden-columns
|
|
289
|
+
* match (strip separators + the trailing index suffix on `key`) so it resolves to a
|
|
290
|
+
* built column whether it was stored as the key, normalizedKey or label. The old
|
|
291
|
+
* card sorted flat tables only. Equal models compare equal, so unrelated config
|
|
292
|
+
* edits never undo a header sort.
|
|
293
|
+
*/
|
|
294
|
+
defaultSort = computed(() => {
|
|
295
|
+
const sortConfig = this.tableStyleConfig()?.sortConfig;
|
|
296
|
+
if (!sortConfig?.column || this.isGrouped())
|
|
297
|
+
return null;
|
|
298
|
+
const norm = (s) => String(s ?? '')
|
|
299
|
+
.toLowerCase()
|
|
300
|
+
.replace(/[\s_-]+/g, '')
|
|
301
|
+
.replace(/\d+$/, '');
|
|
302
|
+
const target = norm(sortConfig.column);
|
|
303
|
+
const match = this.visibleColumns().find((c) => norm(c.keyPure) === target ||
|
|
304
|
+
norm(c.key) === target ||
|
|
305
|
+
norm(c.label) === target);
|
|
306
|
+
return match
|
|
307
|
+
? {
|
|
308
|
+
colId: match.key,
|
|
309
|
+
sort: sortConfig.direction === 'desc' ? 'desc' : 'asc',
|
|
310
|
+
}
|
|
311
|
+
: null;
|
|
312
|
+
}, { ...(ngDevMode ? { debugName: "defaultSort" } : /* istanbul ignore next */ {}), equal: (a, b) => a?.colId === b?.colId && a?.sort === b?.sort });
|
|
313
|
+
/**
|
|
314
|
+
* Whether to skip currency formatting on cells.
|
|
315
|
+
* Reads `clientConfig.tableFormat.disableCurrencyFormat`. Gated: only true
|
|
316
|
+
* when the flag is explicitly set.
|
|
317
|
+
*/
|
|
318
|
+
disableCurrencyFormat = computed(() => this.tableStyleConfig()?.disableCurrencyFormat === true, ...(ngDevMode ? [{ debugName: "disableCurrencyFormat" }] : /* istanbul ignore next */ []));
|
|
319
|
+
/** "% status color" toggle — color percentage cells by the row's status. */
|
|
320
|
+
showPercentageStatus = computed(() => this.tableStyleConfig()?.showPercentageStatus === true, ...(ngDevMode ? [{ debugName: "showPercentageStatus" }] : /* istanbul ignore next */ []));
|
|
321
|
+
/**
|
|
322
|
+
* Resolve the row's status colour from the column whose viewType is 'status'
|
|
323
|
+
* (e.g. Delayed -> red, Completed -> green). Used to tint percentage cells.
|
|
324
|
+
*/
|
|
325
|
+
getRowStatusColor(row) {
|
|
326
|
+
for (const col of this.columns()) {
|
|
327
|
+
if (String(col.viewType || '').toLowerCase() !== 'status')
|
|
328
|
+
continue;
|
|
329
|
+
const cell = row?.[col.key] ?? row?.[col.keyPure || ''];
|
|
330
|
+
const value = cell && typeof cell === 'object' ? cell.value : cell;
|
|
331
|
+
const color = value?.details?.color || value?.color || cell?.color;
|
|
332
|
+
if (color)
|
|
333
|
+
return String(color);
|
|
334
|
+
}
|
|
335
|
+
return '';
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* Extra-columns-from-lookup config persisted at `clientConfig.tableCoulmns`
|
|
339
|
+
* (misspelling preserved on purpose). Shape: { extraCoulmnFromLookup,
|
|
340
|
+
* lookupId, groupedBy, propKey }. Read here so the renderer can react to it;
|
|
341
|
+
* the data-join itself is performed in buildTable when present.
|
|
342
|
+
*/
|
|
343
|
+
extraColumnsConfig = computed(() => {
|
|
344
|
+
const config = this.configurationItem();
|
|
345
|
+
return config?.clientConfig?.['tableCoulmns'] || null;
|
|
346
|
+
}, ...(ngDevMode ? [{ debugName: "extraColumnsConfig" }] : /* istanbul ignore next */ []));
|
|
347
|
+
/** Whether to show index column */
|
|
348
|
+
showIndex = computed(() => {
|
|
349
|
+
const config = this.configurationItem();
|
|
350
|
+
return config?.clientConfig?.configAsType?.['hideIndex'] !== true;
|
|
351
|
+
}, ...(ngDevMode ? [{ debugName: "showIndex" }] : /* istanbul ignore next */ []));
|
|
352
|
+
/** Whether table is grouped */
|
|
353
|
+
isGrouped = computed(() => {
|
|
354
|
+
const config = this.configurationItem();
|
|
355
|
+
return !!(config?.serviceConfig?.['groupBy'] ||
|
|
356
|
+
config?.serviceConfig?.['groupByMultiple']?.length);
|
|
357
|
+
}, ...(ngDevMode ? [{ debugName: "isGrouped" }] : /* istanbul ignore next */ []));
|
|
358
|
+
/** Has data */
|
|
359
|
+
hasData = computed(() => {
|
|
360
|
+
if (this.isGrouped()) {
|
|
361
|
+
return this.groupedData()?.some((g) => g.data?.length > 0);
|
|
362
|
+
}
|
|
363
|
+
return this.tableRows()?.length > 0;
|
|
364
|
+
}, ...(ngDevMode ? [{ debugName: "hasData" }] : /* istanbul ignore next */ []));
|
|
365
|
+
/** Visible columns (not hidden) */
|
|
366
|
+
visibleColumns = computed(() => {
|
|
367
|
+
const cols = this.columns();
|
|
368
|
+
const hiddenCols = this.tableStyleConfig()?.hiddenColumns?.map((c) => c.toLowerCase()) || [];
|
|
369
|
+
return cols.filter((col) => !col.hideColumn &&
|
|
370
|
+
!hiddenCols.includes(col.key?.toLowerCase()) &&
|
|
371
|
+
!hiddenCols.includes(col.keyPure?.toLowerCase() || ''));
|
|
372
|
+
}, ...(ngDevMode ? [{ debugName: "visibleColumns" }] : /* istanbul ignore next */ []));
|
|
373
|
+
/** Row clickable */
|
|
374
|
+
isRowClickable = computed(() => {
|
|
375
|
+
const config = this.configurationItem();
|
|
376
|
+
return (config?.clientConfig?.actions?.some((a) => a.type === 'click' || a.type === 'dblclick' || a.type === 'rowClick') ?? false);
|
|
377
|
+
}, ...(ngDevMode ? [{ debugName: "isRowClickable" }] : /* istanbul ignore next */ []));
|
|
378
|
+
// ── The standard grid ────────────────────────────────────────────────
|
|
379
|
+
/** Rows for the standard grid: the source row, its group and the group's aggregates. */
|
|
380
|
+
gridRows = computed(() => {
|
|
381
|
+
if (this.isGrouped())
|
|
382
|
+
return this.groupedData().flatMap((group, groupIndex) => (group.data ?? []).map((row, index) => ({
|
|
383
|
+
__row: row,
|
|
384
|
+
__id: `${groupIndex}:${this.resolveRowTrackId(row, index)}`,
|
|
385
|
+
__mtgroup: group.prop ?? null,
|
|
386
|
+
__mtgroupIndex: groupIndex,
|
|
387
|
+
__mtaggregates: this.aggregateSummary(group.aggregates),
|
|
388
|
+
})));
|
|
389
|
+
return this.tableRows().map((row, index) => ({
|
|
390
|
+
__row: row,
|
|
391
|
+
__id: this.resolveRowTrackId(row, index),
|
|
392
|
+
}));
|
|
393
|
+
}, ...(ngDevMode ? [{ debugName: "gridRows" }] : /* istanbul ignore next */ []));
|
|
394
|
+
gridRowId = (row) => row.__id;
|
|
395
|
+
gridCells = viewChildren('gridCell', ...(ngDevMode ? [{ debugName: "gridCells" }] : /* istanbul ignore next */ []));
|
|
396
|
+
/**
|
|
397
|
+
* Each data row's displayed position (after sorting and filtering), counted from 1 in
|
|
398
|
+
* every group like the old card's index. The grid api reads the grid's displayed-rows
|
|
399
|
+
* signal, so this follows every sort, filter, grouping and data change.
|
|
400
|
+
*/
|
|
401
|
+
rowPositions = computed(() => {
|
|
402
|
+
const positions = new Map();
|
|
403
|
+
let position = 0;
|
|
404
|
+
this.gridApi()?.forEachNodeAfterFilterAndSort((node) => {
|
|
405
|
+
if (node.group || node.footer)
|
|
406
|
+
position = 0;
|
|
407
|
+
else if (!node.detail)
|
|
408
|
+
positions.set(node.id, ++position);
|
|
409
|
+
});
|
|
410
|
+
return positions;
|
|
411
|
+
}, ...(ngDevMode ? [{ debugName: "rowPositions" }] : /* istanbul ignore next */ []));
|
|
412
|
+
/** The index cell: the row's displayed position, never a number stored with the row. */
|
|
413
|
+
indexCell = ({ node, }) => String(this.rowPositions().get(node.id) ?? '');
|
|
414
|
+
/** Authored cell text colour, weight and size, on every cell like the old card's td. */
|
|
415
|
+
cellStyle = computed(() => {
|
|
416
|
+
const format = this.tableStyleConfig();
|
|
417
|
+
const style = {};
|
|
418
|
+
if (format?.tdTextColor)
|
|
419
|
+
style['color'] = format.tdTextColor;
|
|
420
|
+
if (format?.tdFontBold)
|
|
421
|
+
style['font-weight'] = 'bold';
|
|
422
|
+
if (format?.tdFontSize)
|
|
423
|
+
style['font-size'] = `${format.tdFontSize}px`;
|
|
424
|
+
return Object.keys(style).length ? style : undefined;
|
|
425
|
+
}, ...(ngDevMode ? [{ debugName: "cellStyle" }] : /* istanbul ignore next */ []));
|
|
426
|
+
/** Authored header and group colours, read by the card's scoped grid rules. */
|
|
427
|
+
gridStyle = computed(() => {
|
|
428
|
+
const format = this.tableStyleConfig();
|
|
429
|
+
return {
|
|
430
|
+
'--table-card-th-color': format?.thTextColor || null,
|
|
431
|
+
'--table-card-th-background': format?.thBackgroundColor || null,
|
|
432
|
+
'--table-card-th-font-size': format?.thFontSize
|
|
433
|
+
? `${format.thFontSize}px`
|
|
434
|
+
: null,
|
|
435
|
+
'--table-card-group-color': format?.groupTextColor || null,
|
|
436
|
+
'--table-card-group-background': format?.groupBackgroundColor || '#e4d1ac',
|
|
437
|
+
};
|
|
438
|
+
}, ...(ngDevMode ? [{ debugName: "gridStyle" }] : /* istanbul ignore next */ []));
|
|
439
|
+
/** Group rows take the group colours; stripes alternate within a group, as before. */
|
|
440
|
+
gridRowClass = ({ node, }) => node.group
|
|
441
|
+
? 'table-card-group-row'
|
|
442
|
+
: this.tableStyleConfig()?.striped &&
|
|
443
|
+
(this.rowPositions().get(node.id) ?? 1) % 2 === 0
|
|
444
|
+
? 'table-card-row-striped'
|
|
445
|
+
: '';
|
|
446
|
+
gridColumns = computed(() => {
|
|
447
|
+
const cells = this.gridCells();
|
|
448
|
+
const cellStyle = this.cellStyle();
|
|
449
|
+
const group = this.isGrouped()
|
|
450
|
+
? [
|
|
451
|
+
mtEntityColumn({
|
|
452
|
+
key: '__mtgroup',
|
|
453
|
+
label: '',
|
|
454
|
+
viewType: (this.groupedData()[0]?.prop?.viewType ??
|
|
455
|
+
'Text'),
|
|
456
|
+
entity: (row) => row.__mtgroup ?? null,
|
|
457
|
+
// Keyed by server group, so groups sharing a key (groupByMultiple) stay
|
|
458
|
+
// apart, each with its own aggregates; the label is still the entity's.
|
|
459
|
+
valueGetter: ({ data }) => data.__mtgroupIndex,
|
|
460
|
+
valueFormatter: ({ data }) => data?.__mtgroup ? mtEntityCellValues(data.__mtgroup).display : '',
|
|
461
|
+
hidden: true,
|
|
462
|
+
enableRowGroup: true,
|
|
463
|
+
groupValueRenderer: TableCardGroupValue,
|
|
464
|
+
}),
|
|
465
|
+
]
|
|
466
|
+
: [];
|
|
467
|
+
const index = !this.tableStyleConfig()?.hideIndex && this.showIndex()
|
|
468
|
+
? [
|
|
469
|
+
{
|
|
470
|
+
colId: '__index',
|
|
471
|
+
headerName: '#',
|
|
472
|
+
initialWidth: 72,
|
|
473
|
+
type: 'rightAligned',
|
|
474
|
+
cellRenderer: this.indexCell,
|
|
475
|
+
cellStyle,
|
|
476
|
+
},
|
|
477
|
+
]
|
|
478
|
+
: [];
|
|
479
|
+
return [
|
|
480
|
+
...group,
|
|
481
|
+
...index,
|
|
482
|
+
...this.visibleColumns().map((column, position) => {
|
|
483
|
+
const phaseGate = this.isPhaseGateColumn(column);
|
|
484
|
+
return {
|
|
485
|
+
colId: column.key,
|
|
486
|
+
headerName: column.label,
|
|
487
|
+
// A phase-gate matrix cell has no order to sort by; it keeps the old 10rem.
|
|
488
|
+
...(phaseGate ? { sortable: false } : {}),
|
|
489
|
+
minWidth: phaseGate ? 160 : 120,
|
|
490
|
+
filter: 'text',
|
|
491
|
+
enableRowGroup: true,
|
|
492
|
+
// A phase-gate cell's value is its status text, for export and filter.
|
|
493
|
+
valueGetter: ({ data }) => {
|
|
494
|
+
if (!phaseGate)
|
|
495
|
+
return this.getSortValue(data.__row, column);
|
|
496
|
+
const cell = this.getPhaseGateCell(data.__row, column);
|
|
497
|
+
return cell ? this.getPhaseGateCellText(cell) : null;
|
|
498
|
+
},
|
|
499
|
+
cellStyle,
|
|
500
|
+
cellRenderer: MtTemplateCell,
|
|
501
|
+
cellRendererParams: { template: cells[position] },
|
|
502
|
+
};
|
|
503
|
+
}),
|
|
504
|
+
];
|
|
505
|
+
}, ...(ngDevMode ? [{ debugName: "gridColumns" }] : /* istanbul ignore next */ []));
|
|
506
|
+
gridApi = signal(null, ...(ngDevMode ? [{ debugName: "gridApi" }] : /* istanbul ignore next */ []));
|
|
507
|
+
gridHost = viewChild('gridHost', ...(ngDevMode ? [{ debugName: "gridHost" }] : /* istanbul ignore next */ []));
|
|
508
|
+
/** The grid fills the card body; measured, because the dashboard layout sizes the card. */
|
|
509
|
+
gridHeight = signal(400, ...(ngDevMode ? [{ debugName: "gridHeight" }] : /* istanbul ignore next */ []));
|
|
510
|
+
gridEffects = [
|
|
511
|
+
effect(() => {
|
|
512
|
+
const api = this.gridApi(), grouped = this.isGrouped();
|
|
513
|
+
if (!api)
|
|
514
|
+
return;
|
|
515
|
+
untracked(() => api.setRowGroupColumns(grouped ? ['__mtgroup'] : []));
|
|
516
|
+
}),
|
|
517
|
+
// The default sort goes through the grid, so its header shows the arrow. After
|
|
518
|
+
// render, so the grid already holds the column: setSortModel rejects an unknown one.
|
|
519
|
+
afterRenderEffect(() => {
|
|
520
|
+
const api = this.gridApi(), sort = this.defaultSort();
|
|
521
|
+
if (!api)
|
|
522
|
+
return;
|
|
523
|
+
untracked(() => {
|
|
524
|
+
if (!sort)
|
|
525
|
+
api.setSortModel([]);
|
|
526
|
+
else if (api.getColumnState().some((c) => c.colId === sort.colId))
|
|
527
|
+
api.setSortModel([sort]);
|
|
528
|
+
});
|
|
529
|
+
}),
|
|
530
|
+
effect((onCleanup) => {
|
|
531
|
+
const host = this.gridHost()?.nativeElement;
|
|
532
|
+
if (!host || typeof ResizeObserver === 'undefined')
|
|
533
|
+
return;
|
|
534
|
+
const observer = new ResizeObserver(([entry]) => this.gridHeight.set(Math.max(240, Math.floor(entry?.contentRect.height ?? 400))));
|
|
535
|
+
observer.observe(host);
|
|
536
|
+
onCleanup(() => observer.disconnect());
|
|
537
|
+
}),
|
|
538
|
+
];
|
|
539
|
+
/** Double-click on a data row runs the item's double-click action. */
|
|
540
|
+
onGridDoubleClick(event) {
|
|
541
|
+
const target = event.target;
|
|
542
|
+
if (target?.closest('button,a,input,textarea,select,[role="button"]'))
|
|
543
|
+
return;
|
|
544
|
+
const id = target?.closest('[data-row-id]')?.getAttribute('data-row-id');
|
|
545
|
+
const row = this.gridRows().find((candidate) => candidate.__id === id);
|
|
546
|
+
if (row)
|
|
547
|
+
this.onRowDblClick(row.__row);
|
|
548
|
+
}
|
|
549
|
+
ngOnInit() {
|
|
550
|
+
const id = this.dashboardId();
|
|
551
|
+
// Subscribe to configuration
|
|
552
|
+
this.subscription.add(this.storeService
|
|
553
|
+
.selectItemProperty$(id, 'ConfigurationItem')
|
|
554
|
+
.subscribe((config) => {
|
|
555
|
+
if (config) {
|
|
556
|
+
this.configurationItem.set(config);
|
|
557
|
+
}
|
|
558
|
+
}));
|
|
559
|
+
// Subscribe to data
|
|
560
|
+
this.subscription.add(this.storeService
|
|
561
|
+
.selectItemProperty$(id, 'DataHandled')
|
|
562
|
+
.subscribe((data) => {
|
|
563
|
+
this.rawData.set(data);
|
|
564
|
+
this.buildTable(data);
|
|
565
|
+
}));
|
|
566
|
+
}
|
|
567
|
+
ngOnDestroy() {
|
|
568
|
+
this.clicks.cancel();
|
|
569
|
+
this.subscription.unsubscribe();
|
|
570
|
+
}
|
|
571
|
+
resolveRowTrackId(row, index) {
|
|
572
|
+
const rawId = row?.Id?.value ??
|
|
573
|
+
row?.Id ??
|
|
574
|
+
row?.id?.value ??
|
|
575
|
+
row?.id ??
|
|
576
|
+
row?._index ??
|
|
577
|
+
index;
|
|
578
|
+
return String(rawId);
|
|
579
|
+
}
|
|
580
|
+
/**
|
|
581
|
+
* Build table columns and rows from raw data
|
|
582
|
+
* Matches old buildTable logic in table-card.component.ts
|
|
583
|
+
*/
|
|
584
|
+
buildTable(data) {
|
|
585
|
+
if (!data) {
|
|
586
|
+
this.columns.set([]);
|
|
587
|
+
this.tableRows.set([]);
|
|
588
|
+
this.groupedData.set([]);
|
|
589
|
+
this.labels.set([]);
|
|
590
|
+
return;
|
|
591
|
+
}
|
|
592
|
+
const config = this.configurationItem();
|
|
593
|
+
const languageCode = this.transloco.getActiveLang() || 'en';
|
|
594
|
+
// Apply color overrides from percentage properties
|
|
595
|
+
const colorConfig = config?.clientConfig?.configAsType?.['overrideSelectedPropertiesColors'];
|
|
596
|
+
if (colorConfig && data.values) {
|
|
597
|
+
data.values = fillColorForPercentageProperty(data.values, colorConfig);
|
|
598
|
+
}
|
|
599
|
+
// Get localization config
|
|
600
|
+
const configLocalization = this.storeService.getLocalization?.() || {};
|
|
601
|
+
const localization = switchAllKeysSmall(configLocalization);
|
|
602
|
+
// Get label overrides
|
|
603
|
+
const overrideLabels = switchAllKeysSmall(config?.clientConfig?.configAsType?.['overrideSelectedPropertiesLabels'] || {});
|
|
604
|
+
if (this.isPhaseGateTable(config)) {
|
|
605
|
+
this.buildPhaseGateTable(data, languageCode, localization, overrideLabels, config);
|
|
606
|
+
return;
|
|
607
|
+
}
|
|
608
|
+
// Totals of the Aggregation Properties: the response root carries them
|
|
609
|
+
// for a flat table, each group's data for a grouped one (#1850).
|
|
610
|
+
this.tableAggregates.set(!this.isGrouped() && Array.isArray(data?.aggregates)
|
|
611
|
+
? data.aggregates
|
|
612
|
+
: []);
|
|
613
|
+
if (this.isGrouped()) {
|
|
614
|
+
// Grouped mode
|
|
615
|
+
this.buildGroupedTable(data, languageCode, localization, overrideLabels);
|
|
616
|
+
}
|
|
617
|
+
else {
|
|
618
|
+
// Non-grouped mode
|
|
619
|
+
this.buildFlatTable(data, languageCode, localization, overrideLabels);
|
|
620
|
+
}
|
|
621
|
+
// Set labels. Grouped table responses are arrays, so labels may live on
|
|
622
|
+
// the first group data block rather than at the response root.
|
|
623
|
+
const dataLabels = this.extractLabels(data);
|
|
624
|
+
this.labels.set(this.applyLegendOrder(dataLabels.map((l) => ({
|
|
625
|
+
...l,
|
|
626
|
+
shape: 'circle',
|
|
627
|
+
}))));
|
|
628
|
+
}
|
|
629
|
+
/**
|
|
630
|
+
* Build flat (non-grouped) table
|
|
631
|
+
*/
|
|
632
|
+
buildFlatTable(data, languageCode, localization, overrideLabels) {
|
|
633
|
+
let values = data?.values || [];
|
|
634
|
+
if (!values.length) {
|
|
635
|
+
this.columns.set([]);
|
|
636
|
+
this.tableRows.set([]);
|
|
637
|
+
return;
|
|
638
|
+
}
|
|
639
|
+
// Apply lookupProperty ordering if configured
|
|
640
|
+
const config = this.configurationItem();
|
|
641
|
+
const lookupProperty = config?.serviceConfig?.query?.['lookupProperty'] ||
|
|
642
|
+
config?.serviceConfig?.['lookupProperty'];
|
|
643
|
+
const orderConfig = config?.clientConfig?.['orderConfig'];
|
|
644
|
+
if (lookupProperty && orderConfig) {
|
|
645
|
+
values = dynamicReorder({
|
|
646
|
+
array: values,
|
|
647
|
+
orderConfig: orderConfig,
|
|
648
|
+
path: lookupProperty + '.value.key',
|
|
649
|
+
});
|
|
650
|
+
}
|
|
651
|
+
const sampleItem = columnSample(values);
|
|
652
|
+
// Build columns
|
|
653
|
+
const cols = Object.keys(sampleItem).map((key, index) => {
|
|
654
|
+
const prop = sampleItem[key];
|
|
655
|
+
const overrideLabel = overrideLabels?.[key.toLowerCase()]?.[languageCode];
|
|
656
|
+
return {
|
|
657
|
+
key: prop?.normalizedKey !== 'Id'
|
|
658
|
+
? (prop?.normalizedKey || key) + index
|
|
659
|
+
: prop?.normalizedKey,
|
|
660
|
+
keyPure: key,
|
|
661
|
+
label: overrideLabel ||
|
|
662
|
+
localization?.[key.toLowerCase()]?.[languageCode] ||
|
|
663
|
+
prop?.label ||
|
|
664
|
+
key,
|
|
665
|
+
viewType: prop?.viewType,
|
|
666
|
+
columnType: 'entity',
|
|
667
|
+
hideColumn: isIdentityField(prop, key),
|
|
668
|
+
};
|
|
669
|
+
});
|
|
670
|
+
this.columns.set(cols);
|
|
671
|
+
// Build rows - store full entity data for each cell
|
|
672
|
+
const rows = values.map((item, rowIndex) => {
|
|
673
|
+
const itemLower = getObjectKeysInLowerCase(item);
|
|
674
|
+
const rowData = { _index: rowIndex, _original: item };
|
|
675
|
+
cols.forEach((col) => {
|
|
676
|
+
// Find matching key in item by keyPure
|
|
677
|
+
if (col.keyPure && itemLower[col.keyPure]) {
|
|
678
|
+
rowData[col.key] = itemLower[col.keyPure];
|
|
679
|
+
}
|
|
680
|
+
});
|
|
681
|
+
// Add Id for row click
|
|
682
|
+
const idKey = Object.keys(item).find((k) => isIdentityField(item[k], k));
|
|
683
|
+
if (idKey) {
|
|
684
|
+
rowData['Id'] = item[idKey];
|
|
685
|
+
}
|
|
686
|
+
return rowData;
|
|
687
|
+
});
|
|
688
|
+
this.tableRows.set(rows);
|
|
689
|
+
}
|
|
690
|
+
/**
|
|
691
|
+
* Build grouped table
|
|
692
|
+
*/
|
|
693
|
+
buildGroupedTable(data, languageCode, localization, overrideLabels) {
|
|
694
|
+
if (!Array.isArray(data)) {
|
|
695
|
+
this.columns.set([]);
|
|
696
|
+
this.groupedData.set([]);
|
|
697
|
+
return;
|
|
698
|
+
}
|
|
699
|
+
// Find first group with data to build columns
|
|
700
|
+
let sampleItem = null;
|
|
701
|
+
let sampleLabels = null;
|
|
702
|
+
for (const groupItem of data) {
|
|
703
|
+
if (groupItem.data?.values?.length > 0) {
|
|
704
|
+
sampleItem = columnSample(groupItem.data.values);
|
|
705
|
+
sampleLabels = groupItem.data.labels;
|
|
706
|
+
break;
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
if (!sampleItem) {
|
|
710
|
+
this.columns.set([]);
|
|
711
|
+
this.groupedData.set([]);
|
|
712
|
+
return;
|
|
713
|
+
}
|
|
714
|
+
// Build columns
|
|
715
|
+
const cols = Object.keys(sampleItem).map((key) => {
|
|
716
|
+
const prop = sampleItem[key];
|
|
717
|
+
const overrideLabel = overrideLabels?.[key.toLowerCase()]?.[languageCode];
|
|
718
|
+
return {
|
|
719
|
+
key: key,
|
|
720
|
+
keyPure: key,
|
|
721
|
+
label: overrideLabel ||
|
|
722
|
+
localization?.[key.toLowerCase()]?.[languageCode] ||
|
|
723
|
+
prop?.label ||
|
|
724
|
+
key,
|
|
725
|
+
viewType: prop?.viewType,
|
|
726
|
+
columnType: 'entity',
|
|
727
|
+
hideColumn: isIdentityField(prop, key),
|
|
728
|
+
};
|
|
729
|
+
});
|
|
730
|
+
this.columns.set(cols);
|
|
731
|
+
// Get lookupProperty ordering config
|
|
732
|
+
const config = this.configurationItem();
|
|
733
|
+
const lookupProperty = config?.serviceConfig?.query?.['lookupProperty'] ||
|
|
734
|
+
config?.serviceConfig?.['lookupProperty'];
|
|
735
|
+
const orderConfig = config?.clientConfig?.['orderConfig'];
|
|
736
|
+
// Build grouped data
|
|
737
|
+
const groups = data.map((groupItem) => {
|
|
738
|
+
let groupValues = groupItem.data?.values || [];
|
|
739
|
+
// Apply lookupProperty ordering to each group
|
|
740
|
+
if (lookupProperty && orderConfig && groupValues.length) {
|
|
741
|
+
groupValues = dynamicReorder({
|
|
742
|
+
array: groupValues,
|
|
743
|
+
orderConfig: orderConfig,
|
|
744
|
+
path: lookupProperty + '.key',
|
|
745
|
+
});
|
|
746
|
+
}
|
|
747
|
+
const processedData = groupValues.map((item) => {
|
|
748
|
+
const itemLower = getObjectKeysInLowerCase(item);
|
|
749
|
+
const rowData = { _original: item };
|
|
750
|
+
Object.keys(itemLower).forEach((key) => {
|
|
751
|
+
rowData[key] = itemLower[key];
|
|
752
|
+
});
|
|
753
|
+
return rowData;
|
|
754
|
+
});
|
|
755
|
+
return {
|
|
756
|
+
prop: groupItem.groupByKey,
|
|
757
|
+
data: processedData,
|
|
758
|
+
aggregates: Array.isArray(groupItem.data?.aggregates)
|
|
759
|
+
? groupItem.data.aggregates
|
|
760
|
+
: [],
|
|
761
|
+
};
|
|
762
|
+
});
|
|
763
|
+
this.groupedData.set(groups);
|
|
764
|
+
this.labels.set(this.extractLabels(data, sampleLabels));
|
|
765
|
+
}
|
|
766
|
+
isPhaseGateTable(config) {
|
|
767
|
+
return (config?.clientConfig?.componentName === 'phaseGateTable' ||
|
|
768
|
+
config?.serviceConfig?.['componentName'] === 'phaseGateTable' ||
|
|
769
|
+
config?.serviceConfig?.['serviceType'] === 'phaseGate');
|
|
770
|
+
}
|
|
771
|
+
buildPhaseGateTable(data, languageCode, localization, overrideLabels, config) {
|
|
772
|
+
const values = this.extractPhaseGateValues(data);
|
|
773
|
+
if (!values.length) {
|
|
774
|
+
this.columns.set([]);
|
|
775
|
+
this.tableRows.set([]);
|
|
776
|
+
this.groupedData.set([]);
|
|
777
|
+
this.labels.set([]);
|
|
778
|
+
return;
|
|
779
|
+
}
|
|
780
|
+
const query = (config?.serviceConfig?.query ??
|
|
781
|
+
{});
|
|
782
|
+
const isCanonicalQuery = this.isCanonicalPhaseGateQuery(query);
|
|
783
|
+
const sampleItem = this.findLargestRow(values);
|
|
784
|
+
const fieldKeys = Object.keys(sampleItem);
|
|
785
|
+
const phaseFields = this.resolvePhaseGateFields(values, query, isCanonicalQuery);
|
|
786
|
+
const configuredBaseKeys = this.resolveConfiguredTableKeys(values, query, isCanonicalQuery);
|
|
787
|
+
const baseKeys = (configuredBaseKeys ?? fieldKeys).filter((key) => {
|
|
788
|
+
const prop = this.findFirstFieldValue(values, key);
|
|
789
|
+
if (this.isConfiguredPhaseMetadataField(prop, key, phaseFields)) {
|
|
790
|
+
return false;
|
|
791
|
+
}
|
|
792
|
+
if (!isCanonicalQuery && this.isLegacyPhaseGateMetaField(prop, key)) {
|
|
793
|
+
return false;
|
|
794
|
+
}
|
|
795
|
+
return true;
|
|
796
|
+
});
|
|
797
|
+
const baseColumns = baseKeys.map((key, index) => {
|
|
798
|
+
const prop = this.findFirstFieldValue(values, key);
|
|
799
|
+
const overrideLabel = overrideLabels?.[key.toLowerCase()]?.[languageCode];
|
|
800
|
+
return {
|
|
801
|
+
key: !isIdentityField(prop, key) && prop?.normalizedKey
|
|
802
|
+
? `${prop.normalizedKey}${index}`
|
|
803
|
+
: key,
|
|
804
|
+
keyPure: key,
|
|
805
|
+
label: overrideLabel ||
|
|
806
|
+
localization?.[key.toLowerCase()]?.[languageCode] ||
|
|
807
|
+
prop?.label ||
|
|
808
|
+
key,
|
|
809
|
+
viewType: prop?.viewType,
|
|
810
|
+
columnType: 'entity',
|
|
811
|
+
hideColumn: isIdentityField(prop, key),
|
|
812
|
+
};
|
|
813
|
+
});
|
|
814
|
+
const phaseOrder = new Map();
|
|
815
|
+
values.forEach((item, encounterOrder) => {
|
|
816
|
+
const row = getObjectKeysInLowerCase(item);
|
|
817
|
+
const phaseValue = this.getPhaseGateFieldValue(row, phaseFields.phaseName);
|
|
818
|
+
const phaseIdValue = this.getPhaseGateFieldValue(row, phaseFields.phaseId);
|
|
819
|
+
const phaseLabel = this.getPhaseGateIdentityText(phaseValue) ||
|
|
820
|
+
displayEntityValue(phaseIdValue) ||
|
|
821
|
+
'Phase';
|
|
822
|
+
const phaseIdentity = phaseFields.phaseId ? phaseIdValue : phaseValue;
|
|
823
|
+
const phaseKey = this.toPhaseColumnKey(phaseIdentity, phaseLabel);
|
|
824
|
+
if (!phaseOrder.has(phaseKey)) {
|
|
825
|
+
phaseOrder.set(phaseKey, {
|
|
826
|
+
label: phaseLabel,
|
|
827
|
+
orderValue: this.getPhaseGateFieldValue(row, phaseFields.phaseOrder),
|
|
828
|
+
encounterOrder,
|
|
829
|
+
});
|
|
830
|
+
}
|
|
831
|
+
});
|
|
832
|
+
const phaseColumns = Array.from(phaseOrder.entries())
|
|
833
|
+
.sort((a, b) => this.comparePhaseGateOrder(a, b, phaseFields.phaseOrder !== null))
|
|
834
|
+
.map(([key, value]) => ({
|
|
835
|
+
key,
|
|
836
|
+
label: value.label,
|
|
837
|
+
columnType: 'phaseGate',
|
|
838
|
+
width: '10rem',
|
|
839
|
+
}));
|
|
840
|
+
const rowMap = new Map();
|
|
841
|
+
const statusLabels = new Map();
|
|
842
|
+
values.forEach((item) => {
|
|
843
|
+
const row = getObjectKeysInLowerCase(item);
|
|
844
|
+
const groupKey = isCanonicalQuery
|
|
845
|
+
? this.getCanonicalPhaseGateGroupKey(row, phaseFields.rowIdentity)
|
|
846
|
+
: this.getLegacyPhaseGateGroupKey(row, baseColumns);
|
|
847
|
+
let rowData = rowMap.get(groupKey);
|
|
848
|
+
if (!rowData) {
|
|
849
|
+
rowData = { _index: rowMap.size, _original: item };
|
|
850
|
+
baseColumns.forEach((col) => {
|
|
851
|
+
if (col.keyPure &&
|
|
852
|
+
Object.prototype.hasOwnProperty.call(row, col.keyPure)) {
|
|
853
|
+
rowData[col.key] = row[col.keyPure];
|
|
854
|
+
}
|
|
855
|
+
});
|
|
856
|
+
if (isCanonicalQuery) {
|
|
857
|
+
const identityValue = this.getPhaseGateFieldValue(row, phaseFields.rowIdentity);
|
|
858
|
+
if (identityValue !== null && identityValue !== undefined) {
|
|
859
|
+
rowData['Id'] = identityValue;
|
|
860
|
+
}
|
|
861
|
+
}
|
|
862
|
+
else {
|
|
863
|
+
const idKey = Object.keys(row).find((key) => isIdentityField(row[key], key));
|
|
864
|
+
if (idKey) {
|
|
865
|
+
rowData['Id'] = row[idKey];
|
|
866
|
+
}
|
|
867
|
+
}
|
|
868
|
+
rowMap.set(groupKey, rowData);
|
|
869
|
+
}
|
|
870
|
+
const phaseValue = this.getPhaseGateFieldValue(row, phaseFields.phaseName);
|
|
871
|
+
const phaseIdValue = this.getPhaseGateFieldValue(row, phaseFields.phaseId);
|
|
872
|
+
const phaseLabel = this.getPhaseGateIdentityText(phaseValue) ||
|
|
873
|
+
displayEntityValue(phaseIdValue) ||
|
|
874
|
+
'Phase';
|
|
875
|
+
const phaseIdentity = phaseFields.phaseId ? phaseIdValue : phaseValue;
|
|
876
|
+
const phaseColumnKey = this.toPhaseColumnKey(phaseIdentity, phaseLabel);
|
|
877
|
+
const cell = this.buildPhaseGateCell(row, phaseFields, item, phaseLabel);
|
|
878
|
+
if (cell.statusLabel) {
|
|
879
|
+
statusLabels.set(cell.statusLabel.toLowerCase(), {
|
|
880
|
+
key: cell.statusLabel,
|
|
881
|
+
label: cell.statusLabel,
|
|
882
|
+
color: cell.statusColor || this.getPhaseGateCellColor(cell),
|
|
883
|
+
});
|
|
884
|
+
}
|
|
885
|
+
rowData[phaseColumnKey] = cell;
|
|
886
|
+
});
|
|
887
|
+
this.columns.set([...baseColumns, ...phaseColumns]);
|
|
888
|
+
this.tableRows.set(Array.from(rowMap.values()));
|
|
889
|
+
this.groupedData.set([]);
|
|
890
|
+
this.labels.set(this.applyLegendOrder(Array.from(statusLabels.values()).map((label) => ({
|
|
891
|
+
...label,
|
|
892
|
+
shape: 'circle',
|
|
893
|
+
}))));
|
|
894
|
+
}
|
|
895
|
+
extractPhaseGateValues(data) {
|
|
896
|
+
if (Array.isArray(data)) {
|
|
897
|
+
return data.flatMap((group) => group?.data?.values || group?.values || []);
|
|
898
|
+
}
|
|
899
|
+
return Array.isArray(data?.values) ? data.values : [];
|
|
900
|
+
}
|
|
901
|
+
resolveConfiguredTableKeys(values, query, isCanonicalQuery) {
|
|
902
|
+
const hasConfiguredList = isCanonicalQuery
|
|
903
|
+
? Object.prototype.hasOwnProperty.call(query, 'baseProperties')
|
|
904
|
+
: Object.prototype.hasOwnProperty.call(query, 'selectedProperties') ||
|
|
905
|
+
Object.prototype.hasOwnProperty.call(query, 'properties');
|
|
906
|
+
const configured = isCanonicalQuery
|
|
907
|
+
? this.toStringArray(query['baseProperties'])
|
|
908
|
+
: [
|
|
909
|
+
...this.toStringArray(query['properties']),
|
|
910
|
+
...this.toStringArray(query['selectedProperties']),
|
|
911
|
+
];
|
|
912
|
+
if (!configured.length)
|
|
913
|
+
return hasConfiguredList ? [] : null;
|
|
914
|
+
const seen = new Set();
|
|
915
|
+
const resolved = [];
|
|
916
|
+
configured.forEach((configuredKey) => {
|
|
917
|
+
const responseKey = this.resolvePhaseGateFieldKey(values, configuredKey);
|
|
918
|
+
if (!responseKey)
|
|
919
|
+
return;
|
|
920
|
+
const normalized = normalizePhaseGatePropertyIdentity(responseKey);
|
|
921
|
+
if (seen.has(normalized))
|
|
922
|
+
return;
|
|
923
|
+
seen.add(normalized);
|
|
924
|
+
resolved.push(responseKey.toLowerCase());
|
|
925
|
+
});
|
|
926
|
+
return resolved;
|
|
927
|
+
}
|
|
928
|
+
toStringArray(value) {
|
|
929
|
+
if (!Array.isArray(value))
|
|
930
|
+
return [];
|
|
931
|
+
return value.filter((item) => typeof item === 'string');
|
|
932
|
+
}
|
|
933
|
+
findLargestRow(values) {
|
|
934
|
+
let sample = getObjectKeysInLowerCase(values[0] || {});
|
|
935
|
+
values.forEach((item) => {
|
|
936
|
+
const itemLower = getObjectKeysInLowerCase(item);
|
|
937
|
+
if (Object.keys(itemLower).length > Object.keys(sample).length) {
|
|
938
|
+
sample = itemLower;
|
|
939
|
+
}
|
|
940
|
+
});
|
|
941
|
+
return sample;
|
|
942
|
+
}
|
|
943
|
+
isCanonicalPhaseGateQuery(query) {
|
|
944
|
+
return [
|
|
945
|
+
query.rowIdentityProperty,
|
|
946
|
+
query.phaseNameProperty,
|
|
947
|
+
query.phaseStatusProperty,
|
|
948
|
+
].every((value) => typeof value === 'string' && value.trim().length > 0);
|
|
949
|
+
}
|
|
950
|
+
resolvePhaseGateFields(values, query, isCanonicalQuery) {
|
|
951
|
+
const configuredFields = {
|
|
952
|
+
rowIdentity: this.readPhaseGateProperty(query.rowIdentityProperty),
|
|
953
|
+
phaseName: this.readPhaseGateProperty(query.phaseNameProperty),
|
|
954
|
+
phaseId: this.readPhaseGateProperty(query.phaseIdProperty),
|
|
955
|
+
phaseOrder: this.readPhaseGateProperty(query.phaseOrderProperty),
|
|
956
|
+
isCurrent: this.readPhaseGateProperty(query.phaseIsCurrentProperty),
|
|
957
|
+
isCompleted: this.readPhaseGateProperty(query.phaseIsCompletedProperty),
|
|
958
|
+
allItemsCompleted: this.readPhaseGateProperty(query.phaseAllItemsCompletedProperty),
|
|
959
|
+
status: this.readPhaseGateProperty(query.phaseStatusProperty),
|
|
960
|
+
percentage: this.readPhaseGateProperty(query.phaseProgressProperty),
|
|
961
|
+
};
|
|
962
|
+
if (isCanonicalQuery)
|
|
963
|
+
return configuredFields;
|
|
964
|
+
// A partially migrated dashboard remains on the legacy path, but any
|
|
965
|
+
// explicit semantic role still wins and is resolved exactly.
|
|
966
|
+
const lookupProperty = this.readPhaseGateProperty(query['lookupProperty']);
|
|
967
|
+
const fields = {
|
|
968
|
+
...configuredFields,
|
|
969
|
+
status: configuredFields.status || lookupProperty,
|
|
970
|
+
};
|
|
971
|
+
fields.phaseName ??= this.resolveLegacyPhaseGateAlias(values, [
|
|
972
|
+
'phase_name',
|
|
973
|
+
'phasegate_name',
|
|
974
|
+
]);
|
|
975
|
+
fields.phaseId ??= this.resolveLegacyPhaseGateAlias(values, [
|
|
976
|
+
'phase_schemagateid',
|
|
977
|
+
'phasegate_id',
|
|
978
|
+
'phasegateid',
|
|
979
|
+
]);
|
|
980
|
+
fields.phaseOrder ??= this.resolveLegacyPhaseGateAlias(values, [
|
|
981
|
+
'phase_order',
|
|
982
|
+
'phasegate_order',
|
|
983
|
+
'phase_sequence',
|
|
984
|
+
]);
|
|
985
|
+
fields.isCurrent ??= this.resolveLegacyPhaseGateAlias(values, [
|
|
986
|
+
'phase_iscurrent',
|
|
987
|
+
'phasegate_iscurrent',
|
|
988
|
+
'iscurrentphase',
|
|
989
|
+
]);
|
|
990
|
+
fields.isCompleted ??= this.resolveLegacyPhaseGateAlias(values, [
|
|
991
|
+
'phase_iscompleted',
|
|
992
|
+
'phasegate_iscompleted',
|
|
993
|
+
'iscompletedphase',
|
|
994
|
+
]);
|
|
995
|
+
fields.allItemsCompleted ??= this.resolveLegacyPhaseGateAlias(values, [
|
|
996
|
+
'phase_all_items_completed',
|
|
997
|
+
'phasegate_all_items_completed',
|
|
998
|
+
'allitemscompleted',
|
|
999
|
+
]);
|
|
1000
|
+
fields.status ??= this.resolveLegacyPhaseGateAlias(values, [
|
|
1001
|
+
'phase_status',
|
|
1002
|
+
'phasegate_status',
|
|
1003
|
+
'phase_request_status',
|
|
1004
|
+
'phasegate_request_status',
|
|
1005
|
+
]);
|
|
1006
|
+
fields.percentage ??= this.resolveLegacyPhaseGateAlias(values, [
|
|
1007
|
+
'phase_percentage',
|
|
1008
|
+
'phasegate_percentage',
|
|
1009
|
+
'phase_progress',
|
|
1010
|
+
'phasegate_progress',
|
|
1011
|
+
]);
|
|
1012
|
+
fields.status ??= this.resolveLegacyFieldByViewType(values, [
|
|
1013
|
+
'status',
|
|
1014
|
+
'requeststatus',
|
|
1015
|
+
]);
|
|
1016
|
+
fields.percentage ??= this.resolveLegacyFieldByViewType(values, [
|
|
1017
|
+
'percentage',
|
|
1018
|
+
'slider',
|
|
1019
|
+
]);
|
|
1020
|
+
return fields;
|
|
1021
|
+
}
|
|
1022
|
+
findFirstFieldValue(values, key) {
|
|
1023
|
+
const normalizedKey = key.toLowerCase();
|
|
1024
|
+
for (const item of values) {
|
|
1025
|
+
const row = getObjectKeysInLowerCase(item);
|
|
1026
|
+
if (Object.prototype.hasOwnProperty.call(row, normalizedKey)) {
|
|
1027
|
+
return row[normalizedKey];
|
|
1028
|
+
}
|
|
1029
|
+
}
|
|
1030
|
+
return null;
|
|
1031
|
+
}
|
|
1032
|
+
readPhaseGateProperty(value) {
|
|
1033
|
+
return typeof value === 'string' && value.trim() ? value.trim() : null;
|
|
1034
|
+
}
|
|
1035
|
+
resolvePhaseGateFieldKey(values, configuredKey) {
|
|
1036
|
+
if (!configuredKey)
|
|
1037
|
+
return null;
|
|
1038
|
+
for (const item of values) {
|
|
1039
|
+
const row = getObjectKeysInLowerCase(item);
|
|
1040
|
+
const key = resolvePhaseGateResponseKey(row, configuredKey);
|
|
1041
|
+
if (key)
|
|
1042
|
+
return key;
|
|
1043
|
+
}
|
|
1044
|
+
return null;
|
|
1045
|
+
}
|
|
1046
|
+
resolveLegacyPhaseGateAlias(values, aliases) {
|
|
1047
|
+
for (const alias of aliases) {
|
|
1048
|
+
const key = this.resolvePhaseGateFieldKey(values, alias);
|
|
1049
|
+
if (key)
|
|
1050
|
+
return key;
|
|
1051
|
+
}
|
|
1052
|
+
return null;
|
|
1053
|
+
}
|
|
1054
|
+
resolveLegacyFieldByViewType(values, viewTypes) {
|
|
1055
|
+
const allowedTypes = new Set(viewTypes.map(normalizeIdentity));
|
|
1056
|
+
const candidateKeys = Array.from(new Set(values.flatMap((item) => Object.keys(getObjectKeysInLowerCase(item))))).sort((left, right) => {
|
|
1057
|
+
const leftProp = this.findFirstFieldValue(values, left);
|
|
1058
|
+
const rightProp = this.findFirstFieldValue(values, right);
|
|
1059
|
+
const leftIdentity = fieldIdentity(leftProp, left);
|
|
1060
|
+
const rightIdentity = fieldIdentity(rightProp, right);
|
|
1061
|
+
const leftPhaseRank = leftIdentity.includes('phasegate')
|
|
1062
|
+
? 0
|
|
1063
|
+
: leftIdentity.includes('phase')
|
|
1064
|
+
? 1
|
|
1065
|
+
: 2;
|
|
1066
|
+
const rightPhaseRank = rightIdentity.includes('phasegate')
|
|
1067
|
+
? 0
|
|
1068
|
+
: rightIdentity.includes('phase')
|
|
1069
|
+
? 1
|
|
1070
|
+
: 2;
|
|
1071
|
+
if (leftPhaseRank !== rightPhaseRank) {
|
|
1072
|
+
return leftPhaseRank - rightPhaseRank;
|
|
1073
|
+
}
|
|
1074
|
+
return leftIdentity.localeCompare(rightIdentity, undefined, {
|
|
1075
|
+
numeric: true,
|
|
1076
|
+
sensitivity: 'base',
|
|
1077
|
+
});
|
|
1078
|
+
});
|
|
1079
|
+
return (candidateKeys.find((key) => {
|
|
1080
|
+
const prop = this.findFirstFieldValue(values, key);
|
|
1081
|
+
return allowedTypes.has(normalizeIdentity(prop?.viewType));
|
|
1082
|
+
}) ?? null);
|
|
1083
|
+
}
|
|
1084
|
+
getPhaseGateFieldValue(row, property) {
|
|
1085
|
+
if (!property)
|
|
1086
|
+
return null;
|
|
1087
|
+
const responseKey = resolvePhaseGateResponseKey(row, property);
|
|
1088
|
+
return responseKey ? row[responseKey] : null;
|
|
1089
|
+
}
|
|
1090
|
+
getPhaseGateIdentityText(value) {
|
|
1091
|
+
const runtimeValue = unwrapEntityValue(value);
|
|
1092
|
+
if (runtimeValue !== null &&
|
|
1093
|
+
runtimeValue !== undefined &&
|
|
1094
|
+
typeof runtimeValue !== 'object') {
|
|
1095
|
+
return String(runtimeValue);
|
|
1096
|
+
}
|
|
1097
|
+
return displayEntityValue(value);
|
|
1098
|
+
}
|
|
1099
|
+
isConfiguredPhaseMetadataField(prop, key, fields) {
|
|
1100
|
+
const phaseMetadataRoles = [
|
|
1101
|
+
fields.phaseName,
|
|
1102
|
+
fields.phaseId,
|
|
1103
|
+
fields.phaseOrder,
|
|
1104
|
+
fields.status,
|
|
1105
|
+
fields.percentage,
|
|
1106
|
+
fields.isCurrent,
|
|
1107
|
+
fields.isCompleted,
|
|
1108
|
+
fields.allItemsCompleted,
|
|
1109
|
+
];
|
|
1110
|
+
const row = { [key]: prop };
|
|
1111
|
+
return phaseMetadataRoles.some((role) => !!role && resolvePhaseGateResponseKey(row, role) === key);
|
|
1112
|
+
}
|
|
1113
|
+
isLegacyPhaseGateMetaField(prop, key) {
|
|
1114
|
+
const aliases = [
|
|
1115
|
+
'phase_name',
|
|
1116
|
+
'phasegate_name',
|
|
1117
|
+
'phase_schemagateid',
|
|
1118
|
+
'phasegate_id',
|
|
1119
|
+
'phase_order',
|
|
1120
|
+
'phasegate_order',
|
|
1121
|
+
'phase_iscurrent',
|
|
1122
|
+
'phasegate_iscurrent',
|
|
1123
|
+
'phase_iscompleted',
|
|
1124
|
+
'phasegate_iscompleted',
|
|
1125
|
+
'phase_all_items_completed',
|
|
1126
|
+
'phasegate_all_items_completed',
|
|
1127
|
+
'phase_status',
|
|
1128
|
+
'phasegate_status',
|
|
1129
|
+
'phase_request_status',
|
|
1130
|
+
'phasegate_request_status',
|
|
1131
|
+
'phase_percentage',
|
|
1132
|
+
'phasegate_percentage',
|
|
1133
|
+
'phase_progress',
|
|
1134
|
+
'phasegate_progress',
|
|
1135
|
+
];
|
|
1136
|
+
const row = { [key]: prop };
|
|
1137
|
+
return aliases.some((alias) => resolvePhaseGateResponseKey(row, alias) === key);
|
|
1138
|
+
}
|
|
1139
|
+
toPhaseColumnKey(identityValue, fallbackLabel) {
|
|
1140
|
+
const primitiveIdentity = unwrapEntityValue(identityValue);
|
|
1141
|
+
const identity = normalizePhaseGatePropertyIdentity(primitiveIdentity || fallbackLabel || 'unknown');
|
|
1142
|
+
return `_phase_${identity || 'unknown'}`;
|
|
1143
|
+
}
|
|
1144
|
+
comparePhaseGateOrder(left, right, hasConfiguredOrder) {
|
|
1145
|
+
if (!hasConfiguredOrder) {
|
|
1146
|
+
return left[1].encounterOrder - right[1].encounterOrder;
|
|
1147
|
+
}
|
|
1148
|
+
// The order is the cell's own value. displayEntityValue would prefer the
|
|
1149
|
+
// wrapper's `label` — the property name ("Order") — making every phase
|
|
1150
|
+
// tie and the columns fall back to alphabetical order.
|
|
1151
|
+
const orderText = (value) => {
|
|
1152
|
+
const raw = unwrapEntityValue(value);
|
|
1153
|
+
return raw === null || raw === undefined || typeof raw === 'object'
|
|
1154
|
+
? ''
|
|
1155
|
+
: String(raw).trim();
|
|
1156
|
+
};
|
|
1157
|
+
const leftOrder = orderText(left[1].orderValue);
|
|
1158
|
+
const rightOrder = orderText(right[1].orderValue);
|
|
1159
|
+
if (leftOrder && rightOrder) {
|
|
1160
|
+
const leftNumber = Number(leftOrder);
|
|
1161
|
+
const rightNumber = Number(rightOrder);
|
|
1162
|
+
if (Number.isFinite(leftNumber) && Number.isFinite(rightNumber)) {
|
|
1163
|
+
const numericComparison = leftNumber - rightNumber;
|
|
1164
|
+
if (numericComparison !== 0)
|
|
1165
|
+
return numericComparison;
|
|
1166
|
+
}
|
|
1167
|
+
else {
|
|
1168
|
+
const textComparison = leftOrder.localeCompare(rightOrder, undefined, {
|
|
1169
|
+
numeric: true,
|
|
1170
|
+
sensitivity: 'base',
|
|
1171
|
+
});
|
|
1172
|
+
if (textComparison !== 0)
|
|
1173
|
+
return textComparison;
|
|
1174
|
+
}
|
|
1175
|
+
}
|
|
1176
|
+
else if (leftOrder || rightOrder) {
|
|
1177
|
+
return leftOrder ? -1 : 1;
|
|
1178
|
+
}
|
|
1179
|
+
const labelComparison = left[1].label.localeCompare(right[1].label, undefined, { numeric: true, sensitivity: 'base' });
|
|
1180
|
+
return labelComparison || left[0].localeCompare(right[0]);
|
|
1181
|
+
}
|
|
1182
|
+
getCanonicalPhaseGateGroupKey(row, rowIdentityProperty) {
|
|
1183
|
+
const identityValue = this.getPhaseGateFieldValue(row, rowIdentityProperty);
|
|
1184
|
+
return `id:${this.toStablePhaseGateValue(identityValue)}`;
|
|
1185
|
+
}
|
|
1186
|
+
getLegacyPhaseGateGroupKey(row, baseColumns) {
|
|
1187
|
+
const identityColumn = baseColumns.find((col) => col.keyPure && isIdentityField(row[col.keyPure], col.keyPure));
|
|
1188
|
+
if (identityColumn?.keyPure) {
|
|
1189
|
+
return `id:${this.toStablePhaseGateValue(row[identityColumn.keyPure])}`;
|
|
1190
|
+
}
|
|
1191
|
+
const parts = baseColumns
|
|
1192
|
+
.filter((col) => col.keyPure)
|
|
1193
|
+
.map((col) => this.toStablePhaseGateValue(row[col.keyPure]));
|
|
1194
|
+
return parts.some(Boolean)
|
|
1195
|
+
? `values:${JSON.stringify(parts)}`
|
|
1196
|
+
: 'values:unidentified';
|
|
1197
|
+
}
|
|
1198
|
+
toStablePhaseGateValue(value) {
|
|
1199
|
+
const primitive = unwrapEntityValue(value);
|
|
1200
|
+
if (primitive === null || primitive === undefined)
|
|
1201
|
+
return '';
|
|
1202
|
+
if (typeof primitive !== 'object')
|
|
1203
|
+
return String(primitive);
|
|
1204
|
+
return displayEntityValue(primitive);
|
|
1205
|
+
}
|
|
1206
|
+
buildPhaseGateCell(row, fields, original, phaseName) {
|
|
1207
|
+
const statusValue = this.getPhaseGateFieldValue(row, fields.status);
|
|
1208
|
+
const percentageValue = this.getPhaseGateFieldValue(row, fields.percentage);
|
|
1209
|
+
return {
|
|
1210
|
+
phaseName,
|
|
1211
|
+
statusLabel: displayEntityValue(statusValue),
|
|
1212
|
+
statusColor: getEntityColor(statusValue),
|
|
1213
|
+
percentage: toNumberValue(percentageValue),
|
|
1214
|
+
isCurrent: fields.isCurrent
|
|
1215
|
+
? toBooleanValue(this.getPhaseGateFieldValue(row, fields.isCurrent))
|
|
1216
|
+
: false,
|
|
1217
|
+
isCompleted: fields.isCompleted
|
|
1218
|
+
? toBooleanValue(this.getPhaseGateFieldValue(row, fields.isCompleted))
|
|
1219
|
+
: false,
|
|
1220
|
+
allItemsCompleted: fields.allItemsCompleted
|
|
1221
|
+
? toBooleanValue(this.getPhaseGateFieldValue(row, fields.allItemsCompleted))
|
|
1222
|
+
: false,
|
|
1223
|
+
raw: original,
|
|
1224
|
+
};
|
|
1225
|
+
}
|
|
1226
|
+
getLegendColor(label) {
|
|
1227
|
+
const override = resolveLegendColorOverride(this.configurationItem()?.clientConfig?.configAsType?.['legend']?.['colorOverrides'], this.getLegendText(label));
|
|
1228
|
+
return (override ||
|
|
1229
|
+
label?.details?.color ||
|
|
1230
|
+
label?.value?.details?.color ||
|
|
1231
|
+
label?.color ||
|
|
1232
|
+
label?.backgroundColor ||
|
|
1233
|
+
'#999');
|
|
1234
|
+
}
|
|
1235
|
+
getLegendText(label) {
|
|
1236
|
+
const languageCode = this.transloco.getActiveLang() || 'en';
|
|
1237
|
+
const localizedLabel = label?.label && typeof label.label === 'object'
|
|
1238
|
+
? label.label?.[languageCode] || label.label?.en || label.label?.ar
|
|
1239
|
+
: label?.label;
|
|
1240
|
+
const value = label?.value;
|
|
1241
|
+
return (localizedLabel ||
|
|
1242
|
+
label?.name ||
|
|
1243
|
+
label?.display ||
|
|
1244
|
+
label?.title ||
|
|
1245
|
+
value?.name ||
|
|
1246
|
+
value?.display ||
|
|
1247
|
+
value?.label ||
|
|
1248
|
+
value?.key ||
|
|
1249
|
+
label?.key ||
|
|
1250
|
+
'');
|
|
1251
|
+
}
|
|
1252
|
+
applyLegendOrder(labels) {
|
|
1253
|
+
return orderLegendItems(labels, getLegendOverrideOrder(this.configurationItem()), (label) => this.getLegendText(label));
|
|
1254
|
+
}
|
|
1255
|
+
extractLabels(data, fallback = null) {
|
|
1256
|
+
if (Array.isArray(fallback) && fallback.length) {
|
|
1257
|
+
return fallback;
|
|
1258
|
+
}
|
|
1259
|
+
if (Array.isArray(data)) {
|
|
1260
|
+
for (const groupItem of data) {
|
|
1261
|
+
const labels = groupItem?.data?.labels;
|
|
1262
|
+
if (Array.isArray(labels) && labels.length) {
|
|
1263
|
+
return labels;
|
|
1264
|
+
}
|
|
1265
|
+
}
|
|
1266
|
+
return [];
|
|
1267
|
+
}
|
|
1268
|
+
return Array.isArray(data?.labels) ? data.labels : [];
|
|
1269
|
+
}
|
|
1270
|
+
/**
|
|
1271
|
+
* Get cell data for entity-info component
|
|
1272
|
+
* Returns the full entity data object { viewType, value, label }
|
|
1273
|
+
*/
|
|
1274
|
+
getCellData(row, column) {
|
|
1275
|
+
const cellData = row[column.key] || row[column.keyPure || ''];
|
|
1276
|
+
if (!cellData) {
|
|
1277
|
+
return { viewType: column.viewType || 'text', value: null };
|
|
1278
|
+
}
|
|
1279
|
+
// If it's already an entity object with viewType
|
|
1280
|
+
if (typeof cellData === 'object' && cellData !== null) {
|
|
1281
|
+
const viewType = cellData.viewType || column.viewType || 'text';
|
|
1282
|
+
// disableCurrencyFormat: render currency cells as a plain number so no
|
|
1283
|
+
// currency formatting / symbol is applied. Gated — only when the flag is
|
|
1284
|
+
// set AND the cell is currency, otherwise behavior is unchanged.
|
|
1285
|
+
if (this.disableCurrencyFormat() &&
|
|
1286
|
+
String(viewType).toLowerCase() === 'currency') {
|
|
1287
|
+
return {
|
|
1288
|
+
viewType: 'number',
|
|
1289
|
+
value: unwrapEntityValue(cellData),
|
|
1290
|
+
label: cellData.label,
|
|
1291
|
+
};
|
|
1292
|
+
}
|
|
1293
|
+
const base = {
|
|
1294
|
+
viewType,
|
|
1295
|
+
value: cellData.value,
|
|
1296
|
+
label: cellData.label,
|
|
1297
|
+
};
|
|
1298
|
+
// "% status color": tint the percentage progress bar / dot by the ROW's
|
|
1299
|
+
// status property color (the column whose viewType is 'status'), instead
|
|
1300
|
+
// of the percentage cell's own (usually empty) color. Gated on the toggle.
|
|
1301
|
+
if (this.showPercentageStatus() &&
|
|
1302
|
+
String(viewType).toLowerCase() === 'percentage') {
|
|
1303
|
+
return { ...base, statusColor: this.getRowStatusColor(row) };
|
|
1304
|
+
}
|
|
1305
|
+
return base;
|
|
1306
|
+
}
|
|
1307
|
+
// Primitive value
|
|
1308
|
+
const primitiveViewType = column.viewType || 'text';
|
|
1309
|
+
if (this.disableCurrencyFormat() &&
|
|
1310
|
+
String(primitiveViewType).toLowerCase() === 'currency') {
|
|
1311
|
+
return { viewType: 'number', value: cellData };
|
|
1312
|
+
}
|
|
1313
|
+
return {
|
|
1314
|
+
viewType: primitiveViewType,
|
|
1315
|
+
value: cellData,
|
|
1316
|
+
};
|
|
1317
|
+
}
|
|
1318
|
+
isPhaseGateColumn(column) {
|
|
1319
|
+
return column.columnType === 'phaseGate';
|
|
1320
|
+
}
|
|
1321
|
+
getPhaseGateCell(row, column) {
|
|
1322
|
+
return row?.[column.key] || null;
|
|
1323
|
+
}
|
|
1324
|
+
getPhaseGateCellColor(cell) {
|
|
1325
|
+
if (!cell)
|
|
1326
|
+
return '#9ca3af';
|
|
1327
|
+
if (cell.statusColor)
|
|
1328
|
+
return cell.statusColor;
|
|
1329
|
+
if (cell.isCompleted && cell.allItemsCompleted)
|
|
1330
|
+
return '#16a34a';
|
|
1331
|
+
if (cell.isCompleted)
|
|
1332
|
+
return '#22c55e';
|
|
1333
|
+
if (cell.isCurrent)
|
|
1334
|
+
return 'var(--primary-color, #3b82f6)';
|
|
1335
|
+
return '#9ca3af';
|
|
1336
|
+
}
|
|
1337
|
+
getPhaseGateCellText(cell) {
|
|
1338
|
+
if (!cell)
|
|
1339
|
+
return '__';
|
|
1340
|
+
if (cell.statusLabel)
|
|
1341
|
+
return cell.statusLabel;
|
|
1342
|
+
if (cell.isCompleted)
|
|
1343
|
+
return 'Completed';
|
|
1344
|
+
if (cell.isCurrent)
|
|
1345
|
+
return 'Current';
|
|
1346
|
+
return 'Pending';
|
|
1347
|
+
}
|
|
1348
|
+
getPhaseGatePercentage(cell) {
|
|
1349
|
+
if (cell?.percentage === null || cell?.percentage === undefined) {
|
|
1350
|
+
return null;
|
|
1351
|
+
}
|
|
1352
|
+
return Math.max(0, Math.min(100, cell.percentage));
|
|
1353
|
+
}
|
|
1354
|
+
getPhaseGateCellTooltip(cell) {
|
|
1355
|
+
if (!cell)
|
|
1356
|
+
return '';
|
|
1357
|
+
const parts = [cell.phaseName, this.getPhaseGateCellText(cell)].filter(Boolean);
|
|
1358
|
+
const percentage = this.getPhaseGatePercentage(cell);
|
|
1359
|
+
if (percentage !== null) {
|
|
1360
|
+
parts.push(`${percentage}%`);
|
|
1361
|
+
}
|
|
1362
|
+
return parts.join(' - ');
|
|
1363
|
+
}
|
|
1364
|
+
/**
|
|
1365
|
+
* Get sortable value from row
|
|
1366
|
+
*/
|
|
1367
|
+
getSortValue(row, column) {
|
|
1368
|
+
const cellData = row[column.key] || row[column.keyPure || ''];
|
|
1369
|
+
if (!cellData)
|
|
1370
|
+
return null;
|
|
1371
|
+
if (typeof cellData === 'object') {
|
|
1372
|
+
// For entity values, get the actual value
|
|
1373
|
+
const val = cellData.value;
|
|
1374
|
+
if (typeof val === 'object') {
|
|
1375
|
+
return val.name || val.displayName || val.display || '';
|
|
1376
|
+
}
|
|
1377
|
+
return val;
|
|
1378
|
+
}
|
|
1379
|
+
return cellData;
|
|
1380
|
+
}
|
|
1381
|
+
/** Delays a click only while a Double Click action is configured (#1905). */
|
|
1382
|
+
clicks = new ClickDispatcher();
|
|
1383
|
+
/**
|
|
1384
|
+
* Handle row click
|
|
1385
|
+
*/
|
|
1386
|
+
onRowClick(row) {
|
|
1387
|
+
this.clicks.click(hasDoubleClickAction(this.configurationItem()), () => this.emitRowAction('click', row));
|
|
1388
|
+
}
|
|
1389
|
+
/** Handle row double click — the Actions drawer offers it for tables too. */
|
|
1390
|
+
onRowDblClick(row) {
|
|
1391
|
+
this.clicks.doubleClick(() => this.emitRowAction('dblclick', row));
|
|
1392
|
+
}
|
|
1393
|
+
emitRowAction(type, row) {
|
|
1394
|
+
if (!this.isRowClickable())
|
|
1395
|
+
return;
|
|
1396
|
+
const config = this.configurationItem();
|
|
1397
|
+
if (!config)
|
|
1398
|
+
return;
|
|
1399
|
+
// Build body with key from Id
|
|
1400
|
+
const body = {
|
|
1401
|
+
...row,
|
|
1402
|
+
key: row.Id?.value,
|
|
1403
|
+
};
|
|
1404
|
+
// Emit action — routed through dashboard-item.doActions -> ActionService.
|
|
1405
|
+
this.onAction.emit({ type, data: body });
|
|
1406
|
+
}
|
|
1407
|
+
/**
|
|
1408
|
+
* Handle header click
|
|
1409
|
+
*/
|
|
1410
|
+
onHeaderClick() {
|
|
1411
|
+
const config = this.configurationItem();
|
|
1412
|
+
if (!config)
|
|
1413
|
+
return;
|
|
1414
|
+
this.onAction.emit({ type: 'clickOnHeader', data: {} });
|
|
1415
|
+
}
|
|
1416
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: TableCardComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1417
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.8", type: TableCardComponent, isStandalone: true, selector: "mt-table-card", inputs: { dashboardId: { classPropertyName: "dashboardId", publicName: "dashboardId", isSignal: true, isRequired: true, transformFunction: null }, inGroup: { classPropertyName: "inGroup", publicName: "inGroup", isSignal: true, isRequired: false, transformFunction: null }, hideHeader: { classPropertyName: "hideHeader", publicName: "hideHeader", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { onAction: "onAction" }, viewQueries: [{ propertyName: "gridCells", predicate: ["gridCell"], descendants: true, isSignal: true }, { propertyName: "gridHost", first: true, predicate: ["gridHost"], descendants: true, isSignal: true }], ngImport: i0, template: "<!-- One legend definition; the body grid places it on any configured edge. -->\r\n<ng-template #legendList>\r\n <div\r\n class=\"flex flex-wrap items-center gap-2\"\r\n [class.flex-col]=\"isSideLegend()\"\r\n [class.items-start]=\"isSideLegend()\"\r\n >\r\n @for (label of labels(); track label.key || $index) {\r\n <div class=\"flex items-center gap-1 text-xs\">\r\n <span\r\n class=\"table-legend-marker\"\r\n [class.shape-rect]=\"legendIconType() === 'rect'\"\r\n [class.shape-roundRect]=\"legendIconType() === 'roundRect'\"\r\n [class.shape-diamond]=\"legendIconType() === 'diamond'\"\r\n [class.shape-triangle]=\"legendIconType() === 'triangle'\"\r\n [style.backgroundColor]=\"\r\n legendIconType() === 'triangle' ? null : getLegendColor(label)\r\n \"\r\n [style.border-bottom-color]=\"\r\n legendIconType() === 'triangle' ? getLegendColor(label) : null\r\n \"\r\n ></span>\r\n <span>{{ getLegendText(label) }}</span>\r\n </div>\r\n }\r\n </div>\r\n</ng-template>\r\n\r\n<mt-card-content\r\n [inGroup]=\"inGroup()\"\r\n [showHeader]=\"!hideHeader()\"\r\n [title]=\"title()\"\r\n [styleConfig]=\"\r\n configurationItem()?.clientConfig?.displayConfig?.['StyleConfig']\r\n \"\r\n [cardStyleConfig]=\"\r\n configurationItem()?.clientConfig?.configAsType?.['cardStyleConfig']\r\n \"\r\n [headerConfig]=\"\r\n configurationItem()?.clientConfig?.configAsType?.['headerCardConfig']\r\n \"\r\n [padding]=\"configurationItem()?.clientConfig?.configAsType?.['padding']\"\r\n (headerClick)=\"onHeaderClick()\"\r\n>\r\n <ng-container body>\r\n <div\r\n class=\"table-wrapper h-full\"\r\n [attr.data-legend-position]=\"legendPosition()\"\r\n *transloco=\"let t; prefix: 'dashboardBuilder'\"\r\n >\r\n @if (hasLegend()) {\r\n <div class=\"table-legend-host\">\r\n <ng-container [ngTemplateOutlet]=\"legendList\" />\r\n </div>\r\n }\r\n\r\n <div class=\"table-content\">\r\n @if (loading()) {\r\n <div class=\"flex items-center justify-center h-32\">\r\n <i class=\"pi pi-spin pi-spinner text-2xl\"></i>\r\n </div>\r\n } @else if (hasData()) {\r\n <!-- One cell template per visible column: phase-gate cells and entity values. -->\r\n @for (column of visibleColumns(); track column.key) {\r\n <ng-template #gridCell let-row>\r\n @if (isPhaseGateColumn(column)) {\r\n @let phaseCell = getPhaseGateCell(row.__row, column);\r\n <div\r\n class=\"min-w-36\"\r\n [title]=\"getPhaseGateCellTooltip(phaseCell)\"\r\n >\r\n <div class=\"flex items-center gap-2\">\r\n <span\r\n class=\"w-2.5 h-2.5 rounded-full flex-shrink-0\"\r\n [style.backgroundColor]=\"getPhaseGateCellColor(phaseCell)\"\r\n ></span>\r\n <span class=\"font-medium truncate\">{{\r\n getPhaseGateCellText(phaseCell)\r\n }}</span>\r\n </div>\r\n @if (getPhaseGatePercentage(phaseCell) !== null) {\r\n <div\r\n class=\"mt-1 h-1.5 overflow-hidden rounded-full bg-surface-200\"\r\n >\r\n <div\r\n class=\"h-full rounded-full\"\r\n [style.width.%]=\"getPhaseGatePercentage(phaseCell)\"\r\n [style.backgroundColor]=\"\r\n getPhaseGateCellColor(phaseCell)\r\n \"\r\n ></div>\r\n </div>\r\n }\r\n </div>\r\n } @else {\r\n <mt-entity-info\r\n [data]=\"getCellData(row.__row, column)\"\r\n [displayType]=\"'inTable'\"\r\n [extraInfoData]=\"tableStyleConfig()\"\r\n ></mt-entity-info>\r\n }\r\n </ng-template>\r\n }\r\n <div class=\"flex h-full min-h-0 flex-col gap-2\">\r\n <div\r\n #gridHost\r\n class=\"min-h-0 flex-1\"\r\n [class.table-card-th-color]=\"!!tableStyleConfig()?.thTextColor\"\r\n [class.table-card-th-background]=\"\r\n !!tableStyleConfig()?.thBackgroundColor\r\n \"\r\n [class.table-card-th-bold]=\"!!tableStyleConfig()?.thFontBold\"\r\n [class.table-card-th-size]=\"!!tableStyleConfig()?.thFontSize\"\r\n [style]=\"gridStyle()\"\r\n (dblclick)=\"onGridDoubleClick($event)\"\r\n >\r\n <!-- Every row scrolls inside the card, as before: no pager. -->\r\n <mt-standard-grid\r\n [rows]=\"gridRows()\"\r\n [columns]=\"gridColumns()\"\r\n [rowId]=\"gridRowId\"\r\n [label]=\"title()\"\r\n [height]=\"gridHeight()\"\r\n [exportName]=\"title()\"\r\n [paged]=\"false\"\r\n [clickableRows]=\"isRowClickable()\"\r\n [rowClass]=\"gridRowClass\"\r\n (gridReady)=\"gridApi.set($event.api)\"\r\n (rowClicked)=\"onRowClick($event.__row)\"\r\n />\r\n </div>\r\n @if (aggregateSummary(tableAggregates()); as totals) {\r\n <div\r\n class=\"rounded-md border border-surface-200 bg-surface-50 px-3 py-2 text-sm font-semibold whitespace-pre-wrap\"\r\n >\r\n {{ totals }}\r\n </div>\r\n }\r\n </div>\r\n } @else {\r\n <!-- No Data -->\r\n <div\r\n class=\"flex flex-col items-center justify-center h-32 text-muted-color gap-2\"\r\n >\r\n <i class=\"pi pi-info-circle text-2xl\"></i>\r\n <span>{{ t(\"noData\") }}</span>\r\n </div>\r\n }\r\n </div>\r\n </div>\r\n </ng-container>\r\n</mt-card-content>\r\n", styles: [":host{display:block;height:100%}.table-wrapper{display:grid;grid-template-areas:\"legend\" \"content\";grid-template-rows:auto minmax(0,1fr);min-height:0}.table-wrapper[data-legend-position=bottom]{grid-template-areas:\"content\" \"legend\";grid-template-rows:minmax(0,1fr) auto}.table-wrapper[data-legend-position=left]{grid-template-areas:\"legend content\";grid-template-columns:auto minmax(0,1fr);grid-template-rows:minmax(0,1fr)}.table-wrapper[data-legend-position=right]{grid-template-areas:\"content legend\";grid-template-columns:minmax(0,1fr) auto;grid-template-rows:minmax(0,1fr)}.table-content{grid-area:content;min-height:0;min-width:0;display:flex;flex-direction:column}.table-legend-host{grid-area:legend;min-width:0;padding:.25rem .5rem}.table-wrapper[data-legend-position=left] .table-legend-host,.table-wrapper[data-legend-position=right] .table-legend-host{max-width:12rem;overflow:auto}.table-legend-marker{display:inline-block;width:.625rem;height:.625rem;flex:0 0 auto;border-radius:999px}.table-legend-marker.shape-rect{border-radius:0}.table-legend-marker.shape-roundRect{border-radius:.2rem}.table-legend-marker.shape-diamond{border-radius:.0625rem;transform:rotate(45deg)}.table-legend-marker.shape-triangle{width:0;height:0;background:transparent!important;border-radius:0;border-left:.34rem solid transparent;border-right:.34rem solid transparent;border-bottom-width:.6rem;border-bottom-style:solid}.table-scroll-container{flex:1;min-height:0}table{border-collapse:collapse}.dashboard-table-row{height:48px}.dashboard-table-spacer td{border:0;padding:0}th,td{text-align:start}:host ::ng-deep .table-card-th-background mt-data-grid{--mt-grid-header-background: var(--table-card-th-background)}:host ::ng-deep .table-card-th-color mt-data-grid{--mt-grid-header-foreground: var(--table-card-th-color)}:host ::ng-deep .table-card-th-bold .mt-grid-header{font-weight:700}:host ::ng-deep .table-card-th-size .mt-grid-header{font-size:var(--table-card-th-font-size)}:host ::ng-deep .mt-grid-row.table-card-group-row,:host ::ng-deep .mt-grid-sticky-rows>.mt-grid-sticky-row{background:var(--table-card-group-background);color:var(--table-card-group-color)}:host ::ng-deep .mt-grid-row.table-card-row-striped:not(:hover){background:var(--p-surface-100)}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: TranslocoDirective, selector: "[transloco]", inputs: ["transloco", "translocoParams", "translocoScope", "translocoRead", "translocoPrefix", "translocoLang", "translocoLoadingTpl"] }, { kind: "component", type: CardContentComponent, selector: "mt-card-content", inputs: ["title", "inGroup", "groupHeader", "headerConfig", "styleConfig", "cardStyleConfig", "density", "padding", "showHeader", "headerClickable", "isNoTopEnd", "isChart", "titleEditable"], outputs: ["headerClick", "titleChange"] }, { kind: "component", type: EntityInfoComponent, selector: "mt-entity-info", inputs: ["data", "displayType", "extraInfoData", "limitWords", "customClass"] }, { kind: "component", type: MtStandardGridComponent, selector: "mt-standard-grid", inputs: ["rows", "columns", "rowId", "label", "loading", "height", "rowHeight", "selection", "exportable", "exportButtons", "exportName", "exportFormats", "exporter", "rowMenuItems", "server", "paged", "pageSize", "clickableRows", "cellClickFilter", "rowClass", "detail", "chartContext", "search", "emptyTitle", "emptyDescription", "view"], outputs: ["gridReady", "rowClicked", "selectionChanged", "sortChanged", "filterChanged", "paginationChanged", "rowGroupOpened", "viewChanged", "chartsChanged"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
1418
|
+
}
|
|
1419
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: TableCardComponent, decorators: [{
|
|
1420
|
+
type: Component,
|
|
1421
|
+
args: [{ selector: 'mt-table-card', standalone: true, imports: [
|
|
1422
|
+
CommonModule,
|
|
1423
|
+
TranslocoDirective,
|
|
1424
|
+
CardContentComponent,
|
|
1425
|
+
EntityInfoComponent,
|
|
1426
|
+
MtStandardGridComponent,
|
|
1427
|
+
], changeDetection: ChangeDetectionStrategy.OnPush, template: "<!-- One legend definition; the body grid places it on any configured edge. -->\r\n<ng-template #legendList>\r\n <div\r\n class=\"flex flex-wrap items-center gap-2\"\r\n [class.flex-col]=\"isSideLegend()\"\r\n [class.items-start]=\"isSideLegend()\"\r\n >\r\n @for (label of labels(); track label.key || $index) {\r\n <div class=\"flex items-center gap-1 text-xs\">\r\n <span\r\n class=\"table-legend-marker\"\r\n [class.shape-rect]=\"legendIconType() === 'rect'\"\r\n [class.shape-roundRect]=\"legendIconType() === 'roundRect'\"\r\n [class.shape-diamond]=\"legendIconType() === 'diamond'\"\r\n [class.shape-triangle]=\"legendIconType() === 'triangle'\"\r\n [style.backgroundColor]=\"\r\n legendIconType() === 'triangle' ? null : getLegendColor(label)\r\n \"\r\n [style.border-bottom-color]=\"\r\n legendIconType() === 'triangle' ? getLegendColor(label) : null\r\n \"\r\n ></span>\r\n <span>{{ getLegendText(label) }}</span>\r\n </div>\r\n }\r\n </div>\r\n</ng-template>\r\n\r\n<mt-card-content\r\n [inGroup]=\"inGroup()\"\r\n [showHeader]=\"!hideHeader()\"\r\n [title]=\"title()\"\r\n [styleConfig]=\"\r\n configurationItem()?.clientConfig?.displayConfig?.['StyleConfig']\r\n \"\r\n [cardStyleConfig]=\"\r\n configurationItem()?.clientConfig?.configAsType?.['cardStyleConfig']\r\n \"\r\n [headerConfig]=\"\r\n configurationItem()?.clientConfig?.configAsType?.['headerCardConfig']\r\n \"\r\n [padding]=\"configurationItem()?.clientConfig?.configAsType?.['padding']\"\r\n (headerClick)=\"onHeaderClick()\"\r\n>\r\n <ng-container body>\r\n <div\r\n class=\"table-wrapper h-full\"\r\n [attr.data-legend-position]=\"legendPosition()\"\r\n *transloco=\"let t; prefix: 'dashboardBuilder'\"\r\n >\r\n @if (hasLegend()) {\r\n <div class=\"table-legend-host\">\r\n <ng-container [ngTemplateOutlet]=\"legendList\" />\r\n </div>\r\n }\r\n\r\n <div class=\"table-content\">\r\n @if (loading()) {\r\n <div class=\"flex items-center justify-center h-32\">\r\n <i class=\"pi pi-spin pi-spinner text-2xl\"></i>\r\n </div>\r\n } @else if (hasData()) {\r\n <!-- One cell template per visible column: phase-gate cells and entity values. -->\r\n @for (column of visibleColumns(); track column.key) {\r\n <ng-template #gridCell let-row>\r\n @if (isPhaseGateColumn(column)) {\r\n @let phaseCell = getPhaseGateCell(row.__row, column);\r\n <div\r\n class=\"min-w-36\"\r\n [title]=\"getPhaseGateCellTooltip(phaseCell)\"\r\n >\r\n <div class=\"flex items-center gap-2\">\r\n <span\r\n class=\"w-2.5 h-2.5 rounded-full flex-shrink-0\"\r\n [style.backgroundColor]=\"getPhaseGateCellColor(phaseCell)\"\r\n ></span>\r\n <span class=\"font-medium truncate\">{{\r\n getPhaseGateCellText(phaseCell)\r\n }}</span>\r\n </div>\r\n @if (getPhaseGatePercentage(phaseCell) !== null) {\r\n <div\r\n class=\"mt-1 h-1.5 overflow-hidden rounded-full bg-surface-200\"\r\n >\r\n <div\r\n class=\"h-full rounded-full\"\r\n [style.width.%]=\"getPhaseGatePercentage(phaseCell)\"\r\n [style.backgroundColor]=\"\r\n getPhaseGateCellColor(phaseCell)\r\n \"\r\n ></div>\r\n </div>\r\n }\r\n </div>\r\n } @else {\r\n <mt-entity-info\r\n [data]=\"getCellData(row.__row, column)\"\r\n [displayType]=\"'inTable'\"\r\n [extraInfoData]=\"tableStyleConfig()\"\r\n ></mt-entity-info>\r\n }\r\n </ng-template>\r\n }\r\n <div class=\"flex h-full min-h-0 flex-col gap-2\">\r\n <div\r\n #gridHost\r\n class=\"min-h-0 flex-1\"\r\n [class.table-card-th-color]=\"!!tableStyleConfig()?.thTextColor\"\r\n [class.table-card-th-background]=\"\r\n !!tableStyleConfig()?.thBackgroundColor\r\n \"\r\n [class.table-card-th-bold]=\"!!tableStyleConfig()?.thFontBold\"\r\n [class.table-card-th-size]=\"!!tableStyleConfig()?.thFontSize\"\r\n [style]=\"gridStyle()\"\r\n (dblclick)=\"onGridDoubleClick($event)\"\r\n >\r\n <!-- Every row scrolls inside the card, as before: no pager. -->\r\n <mt-standard-grid\r\n [rows]=\"gridRows()\"\r\n [columns]=\"gridColumns()\"\r\n [rowId]=\"gridRowId\"\r\n [label]=\"title()\"\r\n [height]=\"gridHeight()\"\r\n [exportName]=\"title()\"\r\n [paged]=\"false\"\r\n [clickableRows]=\"isRowClickable()\"\r\n [rowClass]=\"gridRowClass\"\r\n (gridReady)=\"gridApi.set($event.api)\"\r\n (rowClicked)=\"onRowClick($event.__row)\"\r\n />\r\n </div>\r\n @if (aggregateSummary(tableAggregates()); as totals) {\r\n <div\r\n class=\"rounded-md border border-surface-200 bg-surface-50 px-3 py-2 text-sm font-semibold whitespace-pre-wrap\"\r\n >\r\n {{ totals }}\r\n </div>\r\n }\r\n </div>\r\n } @else {\r\n <!-- No Data -->\r\n <div\r\n class=\"flex flex-col items-center justify-center h-32 text-muted-color gap-2\"\r\n >\r\n <i class=\"pi pi-info-circle text-2xl\"></i>\r\n <span>{{ t(\"noData\") }}</span>\r\n </div>\r\n }\r\n </div>\r\n </div>\r\n </ng-container>\r\n</mt-card-content>\r\n", styles: [":host{display:block;height:100%}.table-wrapper{display:grid;grid-template-areas:\"legend\" \"content\";grid-template-rows:auto minmax(0,1fr);min-height:0}.table-wrapper[data-legend-position=bottom]{grid-template-areas:\"content\" \"legend\";grid-template-rows:minmax(0,1fr) auto}.table-wrapper[data-legend-position=left]{grid-template-areas:\"legend content\";grid-template-columns:auto minmax(0,1fr);grid-template-rows:minmax(0,1fr)}.table-wrapper[data-legend-position=right]{grid-template-areas:\"content legend\";grid-template-columns:minmax(0,1fr) auto;grid-template-rows:minmax(0,1fr)}.table-content{grid-area:content;min-height:0;min-width:0;display:flex;flex-direction:column}.table-legend-host{grid-area:legend;min-width:0;padding:.25rem .5rem}.table-wrapper[data-legend-position=left] .table-legend-host,.table-wrapper[data-legend-position=right] .table-legend-host{max-width:12rem;overflow:auto}.table-legend-marker{display:inline-block;width:.625rem;height:.625rem;flex:0 0 auto;border-radius:999px}.table-legend-marker.shape-rect{border-radius:0}.table-legend-marker.shape-roundRect{border-radius:.2rem}.table-legend-marker.shape-diamond{border-radius:.0625rem;transform:rotate(45deg)}.table-legend-marker.shape-triangle{width:0;height:0;background:transparent!important;border-radius:0;border-left:.34rem solid transparent;border-right:.34rem solid transparent;border-bottom-width:.6rem;border-bottom-style:solid}.table-scroll-container{flex:1;min-height:0}table{border-collapse:collapse}.dashboard-table-row{height:48px}.dashboard-table-spacer td{border:0;padding:0}th,td{text-align:start}:host ::ng-deep .table-card-th-background mt-data-grid{--mt-grid-header-background: var(--table-card-th-background)}:host ::ng-deep .table-card-th-color mt-data-grid{--mt-grid-header-foreground: var(--table-card-th-color)}:host ::ng-deep .table-card-th-bold .mt-grid-header{font-weight:700}:host ::ng-deep .table-card-th-size .mt-grid-header{font-size:var(--table-card-th-font-size)}:host ::ng-deep .mt-grid-row.table-card-group-row,:host ::ng-deep .mt-grid-sticky-rows>.mt-grid-sticky-row{background:var(--table-card-group-background);color:var(--table-card-group-color)}:host ::ng-deep .mt-grid-row.table-card-row-striped:not(:hover){background:var(--p-surface-100)}\n"] }]
|
|
1428
|
+
}], propDecorators: { dashboardId: [{ type: i0.Input, args: [{ isSignal: true, alias: "dashboardId", required: true }] }], inGroup: [{ type: i0.Input, args: [{ isSignal: true, alias: "inGroup", required: false }] }], hideHeader: [{ type: i0.Input, args: [{ isSignal: true, alias: "hideHeader", required: false }] }], onAction: [{ type: i0.Output, args: ["onAction"] }], gridCells: [{ type: i0.ViewChildren, args: ['gridCell', { isSignal: true }] }], gridHost: [{ type: i0.ViewChild, args: ['gridHost', { isSignal: true }] }] } });
|
|
1429
|
+
|
|
1430
|
+
export { TableCardComponent };
|
|
1431
|
+
//# sourceMappingURL=masterteam-dashboard-builder-table-card.component-CKAm_KXn.mjs.map
|