@masterteam/components 0.0.347 → 0.0.349

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.
@@ -8,7 +8,7 @@ import { Popover } from 'primeng/popover';
8
8
  import { MTDateFormatPipe, REQUEST_CONTEXT, coerceCheckboxValue, readableTextOn, getLightColor } from '@masterteam/components';
9
9
  import { ModalService } from '@masterteam/components/modal';
10
10
  import { HttpHeaders, HttpClient, HttpContext } from '@angular/common/http';
11
- import { of, forkJoin, map, catchError, switchMap, finalize, take, EMPTY } from 'rxjs';
11
+ import { map, of, forkJoin, catchError, switchMap, finalize, take, EMPTY } from 'rxjs';
12
12
  import { toSignal } from '@angular/core/rxjs-interop';
13
13
  import { Avatar } from '@masterteam/components/avatar';
14
14
  import { SecureImagePipe, UploadField } from '@masterteam/components/upload-field';
@@ -354,6 +354,20 @@ const ENTITY_LIST_TABLE_COMPONENT = new InjectionToken('ENTITY_LIST_TABLE_COMPON
354
354
  const SINGLE_READS = 25;
355
355
  /** A missing name only costs a label: never a toast. */
356
356
  const SILENT = new HttpHeaders({ noMessage: 'true' });
357
+ const MT_CALCULATION_EXPLANATION_RESPONSE_MAPPER = new InjectionToken('MT_CALCULATION_EXPLANATION_RESPONSE_MAPPER', {
358
+ providedIn: 'root',
359
+ factory: () => (body) => body,
360
+ });
361
+ /**
362
+ * Opts a host into reading the explanation from a wrapped payload, for example
363
+ * `provideCalculationExplanationResponseMapper((body) => body.data)`.
364
+ */
365
+ function provideCalculationExplanationResponseMapper(mapper) {
366
+ return {
367
+ provide: MT_CALCULATION_EXPLANATION_RESPONSE_MAPPER,
368
+ useValue: mapper,
369
+ };
370
+ }
357
371
  /**
358
372
  * Reads the latest saved calculation of a value. The request never
359
373
  * recalculates anything; the response is marked `no-store`, so every open
@@ -361,14 +375,17 @@ const SILENT = new HttpHeaders({ noMessage: 'true' });
361
375
  */
362
376
  class CalculationExplanationApi {
363
377
  http = inject(HttpClient);
378
+ mapResponse = inject(MT_CALCULATION_EXPLANATION_RESPONSE_MAPPER);
364
379
  read(source, propertyKey) {
365
- return this.http.get('properties/calculation-explanation', {
380
+ return this.http
381
+ .get('properties/calculation-explanation', {
366
382
  params: {
367
383
  contextKey: toCalculationContextKey(source.contextKey) ?? '',
368
384
  recordId: source.recordId,
369
385
  propertyKey,
370
386
  },
371
- });
387
+ })
388
+ .pipe(map((body) => this.mapResponse(body)));
372
389
  }
373
390
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: CalculationExplanationApi, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
374
391
  static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: CalculationExplanationApi, providedIn: 'root' });
@@ -547,10 +564,12 @@ const CALCULATION_EXPLANATION_KEYS = 'components.entitiesPreview.calculationExpl
547
564
  const K = CALCULATION_EXPLANATION_KEYS;
548
565
  /**
549
566
  * Every key of the backend's text-key catalog
550
- * (`Pplus5.BE/Docs/Calculation-Explanation-Text-Keys.json`) this version
567
+ * (`Pplus5.BE/Docs/Calculation-Explanation-Text-Keys.json`, and the Splus
568
+ * backend's own `kpi.*`, `measures.*` and `codeBuilder.*` keys) this version
551
569
  * translates. A key outside it reads as a generic heading.
552
570
  */
553
571
  const SERVER_TEXT_KEYS = new Set([
572
+ 'calculation.codeBuilder.concatenate',
554
573
  'calculation.fact.effectiveScheduleResults',
555
574
  'calculation.fact.latestBaseline',
556
575
  'calculation.fact.linkedScheduleLeaves',
@@ -563,6 +582,28 @@ const SERVER_TEXT_KEYS = new Set([
563
582
  'calculation.fact.selectedWorkingDays',
564
583
  'calculation.fact.selectionPolicyAndTime',
565
584
  'calculation.fact.unfilteredDescendants',
585
+ 'calculation.kpi.maxPerformance',
586
+ 'calculation.kpi.minPerformance',
587
+ 'calculation.kpi.notAvailable.divisionByZero',
588
+ 'calculation.kpi.notAvailable.invertedZero',
589
+ 'calculation.kpi.notAvailable.missingInput',
590
+ 'calculation.kpi.notAvailable.notFinite',
591
+ 'calculation.kpi.performanceSettings',
592
+ 'calculation.kpi.polarityFactor',
593
+ 'calculation.kpi.scale',
594
+ 'calculation.measures.accumulativeAverage',
595
+ 'calculation.measures.accumulativeLastValue',
596
+ 'calculation.measures.accumulativeSum',
597
+ 'calculation.measures.allMeasures',
598
+ 'calculation.measures.completedCount',
599
+ 'calculation.measures.currentPeriod',
600
+ 'calculation.measures.currentPeriodNotCompleted',
601
+ 'calculation.measures.lastUpdated',
602
+ 'calculation.measures.latestCompleted',
603
+ 'calculation.measures.nextUpcomingTarget',
604
+ 'calculation.measures.noCompletedMeasures',
605
+ 'calculation.measures.noMeasure',
606
+ 'calculation.measures.settings',
566
607
  'calculation.method.completedActualFinish',
567
608
  'calculation.method.descendantCount',
568
609
  'calculation.method.earliestStart',
@@ -697,6 +738,43 @@ const SEMANTIC_KEYS = new Set([
697
738
  'baseline_progress',
698
739
  'baseline_count',
699
740
  ]);
741
+ /**
742
+ * The columns of the KPI measures table a `semantic` node can read
743
+ * (`Measures::latest_actual`). Keyed by table as well as column, so they never
744
+ * collide with the schedule columns above.
745
+ */
746
+ const MEASURES_TABLE = 'Measures';
747
+ const MEASURE_COLUMNS = new Set([
748
+ 'latest_actual',
749
+ 'latest_target',
750
+ 'current_actual',
751
+ 'current_target',
752
+ 'accumulative_value',
753
+ 'accumulative_target',
754
+ 'accumulative_performance',
755
+ 'last_update',
756
+ 'completed_measures_count',
757
+ 'measures_count',
758
+ // A KPI setting read directly by a formula (rule `settings`).
759
+ 'pi_polarity_factor',
760
+ 'pi_scale',
761
+ 'pi_min_performance',
762
+ 'pi_max_performance',
763
+ ]);
764
+ /**
765
+ * How a measure column is shown where it is certain, whatever the catalog says
766
+ * (the catalog types every one `Number`). The other columns are figures in the
767
+ * KPI's own unit and show as plain numbers here.
768
+ */
769
+ const MEASURE_VIEW_TYPES = {
770
+ last_update: 'DateTime',
771
+ completed_measures_count: 'Number',
772
+ measures_count: 'Number',
773
+ pi_polarity_factor: 'Number',
774
+ pi_scale: 'Number',
775
+ pi_min_performance: 'Number',
776
+ pi_max_performance: 'Number',
777
+ };
700
778
  const PROGRESS_KEYS = new Set([
701
779
  'actual_progress',
702
780
  'planned_progress',
@@ -913,6 +991,15 @@ function semanticKey(reference) {
913
991
  const column = referenceColumn(reference);
914
992
  return column && SEMANTIC_KEYS.has(column) ? column : null;
915
993
  }
994
+ /** The column of a `Measures::<column>` reference, null for any other. */
995
+ function measureColumn(reference) {
996
+ const column = referenceColumn(reference);
997
+ return referenceTable(reference) === MEASURES_TABLE &&
998
+ column &&
999
+ MEASURE_COLUMNS.has(column)
1000
+ ? column
1001
+ : null;
1002
+ }
916
1003
  /**
917
1004
  * A node's business label: the property's authorized name, a known schedule
918
1005
  * value, or a generic label. Never a reference, key or formula text.
@@ -931,6 +1018,17 @@ function nodeLabel(node, ctx) {
931
1018
  if (semantic) {
932
1019
  return ctx.translate(`${K}.semantic.${semantic}`);
933
1020
  }
1021
+ // A KPI measures column carries no display name: the shared package names it.
1022
+ const measure = measureColumn(node.reference);
1023
+ if (measure) {
1024
+ return ctx.translate(`${K}.semantic.measures.${measure}`);
1025
+ }
1026
+ // A KPI measures column this version does not know is just a value: it is
1027
+ // never a schedule value.
1028
+ if (node.kind === 'semantic' &&
1029
+ referenceTable(node.reference) === MEASURES_TABLE) {
1030
+ return ctx.translate(`${K}.generic.value`);
1031
+ }
934
1032
  if (node.kind === 'semantic') {
935
1033
  return ctx.translate(`${K}.generic.scheduleValue`);
936
1034
  }
@@ -945,7 +1043,11 @@ function nodeViewType(node) {
945
1043
  return node.display.viewType;
946
1044
  }
947
1045
  const column = referenceColumn(node.reference);
948
- return column && PROGRESS_KEYS.has(column) ? 'Percentage' : null;
1046
+ if (column && PROGRESS_KEYS.has(column)) {
1047
+ return 'Percentage';
1048
+ }
1049
+ const measure = measureColumn(node.reference);
1050
+ return (measure && MEASURE_VIEW_TYPES[measure]) || null;
949
1051
  }
950
1052
  function nodeValueText(node, ctx) {
951
1053
  if (node.state === 'notEvaluated') {
@@ -976,6 +1078,19 @@ function describeRollup(detail, ctx) {
976
1078
  : 'empty';
977
1079
  return ctx.translate(`${K}.schedule.aggregation.${aggregation}`);
978
1080
  }
1081
+ const NOT_AVAILABLE = 'NOT_AVAILABLE';
1082
+ const KPI_SETTINGS = 'KPI_SETTINGS';
1083
+ /** `KPI_SETTINGS(formula, polarity, scale, min, max)`: five children. */
1084
+ function isKpiSettings(node) {
1085
+ return (node?.kind === 'function' &&
1086
+ functionName(node) === KPI_SETTINGS &&
1087
+ node.children.length >= 5);
1088
+ }
1089
+ /** A node that only wraps the business formula: its failure is not the cause. */
1090
+ function isKpiWrapper(node) {
1091
+ return (node.kind === 'function' &&
1092
+ (functionName(node) === NOT_AVAILABLE || isKpiSettings(node)));
1093
+ }
979
1094
  function functionName(node) {
980
1095
  const name = (node.operation ?? '').trim().toUpperCase();
981
1096
  return name || (node.kind === 'conditional' ? 'IF' : node.kind);
@@ -1038,13 +1153,22 @@ function buildExplanationSegments(document, ctx, mode = 'inline', startId = docu
1038
1153
  });
1039
1154
  }
1040
1155
  const wrap = segments.length > 1 && (shown || precedenceOf(node) < context);
1041
- return wrap
1156
+ const out = wrap
1042
1157
  ? [
1043
1158
  { kind: 'text', text: '(' },
1044
1159
  ...segments,
1045
1160
  { kind: 'text', text: ')' },
1046
1161
  ]
1047
1162
  : segments;
1163
+ // The deepest failed node is where the value was lost; the ones above
1164
+ // it read as having no value because of it.
1165
+ if (node.state === 'failed' &&
1166
+ mode !== 'inline' &&
1167
+ !isKpiWrapper(node) &&
1168
+ !node.children.some((child) => byId.get(child)?.state === 'failed')) {
1169
+ out.push({ kind: 'failed', text: ctx.translate(`${K}.kpi.noValue`) });
1170
+ }
1171
+ return out;
1048
1172
  }
1049
1173
  finally {
1050
1174
  path.delete(id);
@@ -1207,6 +1331,34 @@ function buildExplanationSegments(document, ctx, mode = 'inline', startId = docu
1207
1331
  }
1208
1332
  const name = functionName(node);
1209
1333
  const value = formatTypedValue(node.value, null, ctx);
1334
+ // The KPI wrappers are not part of the business formula: an N/A wrapper
1335
+ // reads as what it wraps, the settings as the formula, inverted when lower
1336
+ // is better, times the scale. Nothing is recalculated here.
1337
+ if (name === NOT_AVAILABLE && node.children.length > 0) {
1338
+ return render(node.children[0], LOOSEST);
1339
+ }
1340
+ if (isKpiSettings(node)) {
1341
+ const [, polarity, scale] = node.children.map((id) => byId.get(id));
1342
+ const inverted = polarity?.value === -1;
1343
+ const out = inverted
1344
+ ? [
1345
+ { kind: 'text', text: '1 ÷ (' },
1346
+ ...render(node.children[0], LOOSEST),
1347
+ { kind: 'text', text: ')' },
1348
+ ]
1349
+ : render(node.children[0], PRECEDENCE['*']);
1350
+ if (typeof scale?.value === 'number' && scale.value !== 1) {
1351
+ out.push({ kind: 'text', text: '×' });
1352
+ out.push(mode === 'labels'
1353
+ ? {
1354
+ kind: 'term',
1355
+ label: ctx.translate(`${K}.kpi.scale`),
1356
+ value: null,
1357
+ }
1358
+ : { kind: 'value', text: formatExplanationNumber(scale.value) });
1359
+ }
1360
+ return out;
1361
+ }
1210
1362
  if (name === 'TODAY' && node.children.length === 0) {
1211
1363
  const label = ctx.translate(`${K}.fn.TODAY`);
1212
1364
  return mode === 'values'
@@ -1620,6 +1772,8 @@ function buildExplanationDetails(document, ctx, statusNames = {}) {
1620
1772
  }
1621
1773
  }
1622
1774
  return {
1775
+ kpi: kpiView(document, byId, ctx),
1776
+ measures: (document.measures ?? []).map((item) => measureView(item, ctx)),
1623
1777
  // A status's rules section says how rules are chosen.
1624
1778
  description: equation || document.statusRules?.length
1625
1779
  ? null
@@ -1678,9 +1832,181 @@ function recordTables(document, rollupColumns, ctx) {
1678
1832
  }),
1679
1833
  }));
1680
1834
  }
1835
+ function limitText(node, ctx) {
1836
+ return typeof node?.value === 'number'
1837
+ ? formatExplanationNumber(node.value)
1838
+ : ctx.translate(`${K}.kpi.noLimit`);
1839
+ }
1840
+ /** The KPI settings of a performance formula, null for any other root. */
1841
+ function kpiView(document, byId, ctx) {
1842
+ const root = byId.get(document.rootNodeId);
1843
+ if (!root || !isKpiSettings(root)) {
1844
+ return null;
1845
+ }
1846
+ const [formula, polarity, scale, min, max] = root.children.map((id) => byId.get(id));
1847
+ const inverted = polarity?.value === -1;
1848
+ const failed = root.state === 'failed';
1849
+ const noValue = ctx.translate(`${K}.kpi.noValue`);
1850
+ const formulaValue = formatTypedValue(formula?.value, null, ctx);
1851
+ const resultText = failed
1852
+ ? noValue
1853
+ : formatTypedValue(document.result, null, ctx);
1854
+ const scaleText = typeof scale?.value === 'number'
1855
+ ? formatExplanationNumber(scale.value)
1856
+ : '—';
1857
+ const limited = root.appliedLimit === 'max' || root.appliedLimit === 'min';
1858
+ const hasLimit = typeof min?.value === 'number' || typeof max?.value === 'number';
1859
+ return {
1860
+ rows: [
1861
+ {
1862
+ label: ctx.translate(`${K}.kpi.polarity`),
1863
+ value: ctx.translate(`${K}.kpi.${inverted ? 'polarityLower' : 'polarityHigher'}`),
1864
+ },
1865
+ { label: ctx.translate(`${K}.kpi.scale`), value: scaleText },
1866
+ {
1867
+ label: ctx.translate(`${K}.kpi.minLimit`),
1868
+ value: limitText(min, ctx),
1869
+ },
1870
+ {
1871
+ label: ctx.translate(`${K}.kpi.maxLimit`),
1872
+ value: limitText(max, ctx),
1873
+ },
1874
+ ],
1875
+ steps: inverted
1876
+ ? [
1877
+ {
1878
+ label: ctx.translate(`${K}.kpi.formulaResult`),
1879
+ value: formulaValue,
1880
+ },
1881
+ {
1882
+ label: ctx.translate(`${K}.kpi.inverted`),
1883
+ value: failed ? noValue : null,
1884
+ },
1885
+ ...(failed
1886
+ ? []
1887
+ : [
1888
+ {
1889
+ label: ctx.translate(`${K}.kpi.scaled`),
1890
+ value: resultText,
1891
+ },
1892
+ ]),
1893
+ ]
1894
+ : null,
1895
+ limit: limited && typeof root.valueBeforeLimits === 'number'
1896
+ ? ctx.translate(`${K}.kpi.${root.appliedLimit === 'max' ? 'limitedMax' : 'limitedMin'}`, {
1897
+ before: formatExplanationNumber(root.valueBeforeLimits),
1898
+ limit: limitText(root.appliedLimit === 'max' ? max : min, ctx),
1899
+ })
1900
+ : null,
1901
+ limitUnknown: hasLimit && !failed && root.valueBeforeLimits === undefined && !limited,
1902
+ };
1903
+ }
1904
+ const MEASURE_PERIOD_FREQUENCIES = new Set([
1905
+ 'Annual',
1906
+ 'SemiAnnual',
1907
+ 'Quarterly',
1908
+ 'Monthly',
1909
+ 'BiWeekly',
1910
+ ]);
1911
+ const MEASURE_STATUSES = new Set([
1912
+ 'NotStarted',
1913
+ 'RequireUpdate',
1914
+ 'Completed',
1915
+ 'Locked',
1916
+ 'Unlocked',
1917
+ ]);
1918
+ /**
1919
+ * The label of a period from the calendar day written in its `date`: month and
1920
+ * year for a monthly (or longer) frequency, the day for `Custom`, a missing or
1921
+ * an unknown one. No time zone is applied and the calendar is Gregorian, so
1922
+ * the label never moves with the reader's clock.
1923
+ */
1924
+ function measurePeriodLabel(date, frequency, lang) {
1925
+ const match = /^(\d{4})-(\d{2})-(\d{2})/.exec(date);
1926
+ if (!match) {
1927
+ return date;
1928
+ }
1929
+ const day = new Date(Date.UTC(Number(match[1]), Number(match[2]) - 1, Number(match[3])));
1930
+ const byMonth = !!frequency && MEASURE_PERIOD_FREQUENCIES.has(frequency);
1931
+ return new Intl.DateTimeFormat(lang.startsWith('ar') ? 'ar-u-nu-latn-ca-gregory' : 'en-GB-u-ca-gregory', {
1932
+ timeZone: 'UTC',
1933
+ year: 'numeric',
1934
+ month: 'short',
1935
+ ...(byMonth ? {} : { day: 'numeric' }),
1936
+ }).format(day);
1937
+ }
1938
+ function measureView(item, ctx) {
1939
+ const column = measureColumn(item.reference);
1940
+ const plain = (value) => typeof value === 'number' ? formatExplanationNumber(value) : '—';
1941
+ const total = item.contributors.length
1942
+ ? item.contributors.length
1943
+ : (item.contributorCount ?? 0);
1944
+ return {
1945
+ title: column
1946
+ ? ctx.translate(`${K}.semantic.measures.${column}`)
1947
+ : ctx.translate(`${K}.generic.value`),
1948
+ rule: serverText(`calculation.measures.${item.rule}`, ctx),
1949
+ asOf: ctx.formatDate(item.asOfUtc, 'dateTime'),
1950
+ result: formatTypedValue(item.value, column ? (MEASURE_VIEW_TYPES[column] ?? null) : null, ctx),
1951
+ count: item.rule === 'settings'
1952
+ ? null
1953
+ : total
1954
+ ? ctx.translate(`${K}.measuresUsed.count`, { count: total })
1955
+ : ctx.translate(`${K}.measuresUsed.none`),
1956
+ rows: item.contributors.map((row) => ({
1957
+ period: measurePeriodLabel(row.date, item.frequency, ctx.lang),
1958
+ reporting: row.reportingDate
1959
+ ? ctx.formatDate(row.reportingDate, 'date')
1960
+ : null,
1961
+ value: plain(row.value),
1962
+ target: plain(row.target),
1963
+ status: ctx.translate(`${K}.measureStatus.${MEASURE_STATUSES.has(row.status) ? row.status : 'unknown'}`),
1964
+ ignored: row.isIgnore,
1965
+ cascaded: row.isCascading,
1966
+ })),
1967
+ };
1968
+ }
1969
+ const ARITHMETIC_OPERATORS = new Set(['+', '-', '*', '/', '%']);
1970
+ /**
1971
+ * Why a formula has no result, when its own structure says so: a KPI's
1972
+ * N/A wrapper (or failed settings) by the reason the server gave, an
1973
+ * arithmetic formula by the operand that has no value. Null otherwise.
1974
+ */
1975
+ function explanationReason(document, ctx) {
1976
+ const byId = new Map((document.nodes ?? []).map((node) => [node.id, node]));
1977
+ const root = byId.get(document.rootNodeId);
1978
+ if (!root) {
1979
+ return null;
1980
+ }
1981
+ if (root.kind === 'function' &&
1982
+ (functionName(root) === NOT_AVAILABLE ||
1983
+ (isKpiSettings(root) && root.state === 'failed'))) {
1984
+ return serverText(root.labelKey ?? document.descriptionKey, ctx);
1985
+ }
1986
+ if ((document.result === null || document.result === undefined) &&
1987
+ root.kind === 'binary' &&
1988
+ ARITHMETIC_OPERATORS.has(root.operation ?? '')) {
1989
+ const names = root.children
1990
+ .map((id) => byId.get(id))
1991
+ .filter((node) => node?.kind === 'input' &&
1992
+ node.state === 'evaluated' &&
1993
+ !Array.isArray(node.value) &&
1994
+ (node.value === null || node.value === undefined))
1995
+ .map((node) => nodeLabel(node, ctx));
1996
+ if (names.length) {
1997
+ return ctx.translate(`${K}.emptyInput`, {
1998
+ names: names.join(ctx.lang.startsWith('ar') ? '، ' : ', '),
1999
+ count: names.length,
2000
+ });
2001
+ }
2002
+ }
2003
+ return null;
2004
+ }
1681
2005
  /** Whether the details have anything beyond the summary. */
1682
2006
  function hasExplanationDetails(view) {
1683
- return (view.values.length > 0 ||
2007
+ return (view.kpi !== null ||
2008
+ view.measures.length > 0 ||
2009
+ view.values.length > 0 ||
1684
2010
  view.records.length > 0 ||
1685
2011
  view.steps.length > 0 ||
1686
2012
  view.statusRules.length > 0 ||
@@ -1963,6 +2289,7 @@ function summarize(document, target, ctx) {
1963
2289
  status: null,
1964
2290
  noRuleMatched: false,
1965
2291
  recordCount: null,
2292
+ reason: null,
1966
2293
  };
1967
2294
  if (document.provider === 'status' && document.statusRules?.length) {
1968
2295
  const rules = orderedStatusRules(document);
@@ -2003,6 +2330,7 @@ function summarize(document, target, ctx) {
2003
2330
  ],
2004
2331
  values: values?.length ? capitalizeSegments(values) : null,
2005
2332
  recordCount: values ? null : listedRecordCount(document),
2333
+ reason: explanationReason(document, ctx),
2006
2334
  };
2007
2335
  }
2008
2336
  }
@@ -2177,6 +2505,11 @@ class CalculationExplanationEquation {
2177
2505
  >→ {{ piece.segment.text }}</bdi
2178
2506
  >
2179
2507
  }
2508
+ @case ('failed') {
2509
+ <span class="text-red-600 dark:text-red-400"
2510
+ >({{ piece.segment.text }})</span
2511
+ >
2512
+ }
2180
2513
  @case ('muted') {
2181
2514
  <span class="text-surface-400 italic">{{
2182
2515
  piece.segment.text
@@ -2237,6 +2570,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImpor
2237
2570
  >→ {{ piece.segment.text }}</bdi
2238
2571
  >
2239
2572
  }
2573
+ @case ('failed') {
2574
+ <span class="text-red-600 dark:text-red-400"
2575
+ >({{ piece.segment.text }})</span
2576
+ >
2577
+ }
2240
2578
  @case ('muted') {
2241
2579
  <span class="text-surface-400 italic">{{
2242
2580
  piece.segment.text
@@ -2434,6 +2772,13 @@ class CalculationExplanationSummary {
2434
2772
  [result]="v.result"
2435
2773
  />
2436
2774
  }
2775
+ @if (v.summary.reason; as reason) {
2776
+ <p
2777
+ class="text-xs break-words text-surface-600 dark:text-surface-300"
2778
+ >
2779
+ {{ reason }}
2780
+ </p>
2781
+ }
2437
2782
  @if (v.summary.recordCount; as count) {
2438
2783
  <span class="text-xs text-surface-500 dark:text-surface-400">{{
2439
2784
  prefix + '.recordsUsed' | transloco: { count }
@@ -2544,6 +2889,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImpor
2544
2889
  [result]="v.result"
2545
2890
  />
2546
2891
  }
2892
+ @if (v.summary.reason; as reason) {
2893
+ <p
2894
+ class="text-xs break-words text-surface-600 dark:text-surface-300"
2895
+ >
2896
+ {{ reason }}
2897
+ </p>
2898
+ }
2547
2899
  @if (v.summary.recordCount; as count) {
2548
2900
  <span class="text-xs text-surface-500 dark:text-surface-400">{{
2549
2901
  prefix + '.recordsUsed' | transloco: { count }
@@ -2802,6 +3154,139 @@ class CalculationExplanationDetails {
2802
3154
  <p>{{ view.description }}</p>
2803
3155
  }
2804
3156
 
3157
+ @if (view.kpi; as kpi) {
3158
+ <mt-calculation-explanation-section
3159
+ [title]="prefix + '.kpi.title' | transloco"
3160
+ [open]="true"
3161
+ >
3162
+ @if (kpi.steps; as steps) {
3163
+ <ol class="flex flex-col gap-1">
3164
+ @for (step of steps; track $index) {
3165
+ <li class="flex items-baseline justify-between gap-3">
3166
+ <span>{{ step.label }}</span>
3167
+ @if (step.value !== null) {
3168
+ <bdi class="font-medium tabular-nums">{{ step.value }}</bdi>
3169
+ }
3170
+ </li>
3171
+ }
3172
+ </ol>
3173
+ }
3174
+ <dl
3175
+ class="grid grid-cols-[minmax(0,auto)_minmax(0,1fr)] gap-x-3 gap-y-1"
3176
+ >
3177
+ @for (row of kpi.rows; track $index) {
3178
+ <dt class="text-surface-500 dark:text-surface-400">
3179
+ {{ row.label }}
3180
+ </dt>
3181
+ <dd class="ms-0 min-w-0">
3182
+ <bdi class="tabular-nums">{{ row.value }}</bdi>
3183
+ </dd>
3184
+ }
3185
+ </dl>
3186
+ @if (kpi.limit; as limit) {
3187
+ <div
3188
+ class="rounded-md border border-amber-200 bg-amber-50 px-3 py-2 text-amber-700"
3189
+ >
3190
+ {{ limit }}
3191
+ </div>
3192
+ }
3193
+ @if (kpi.limitUnknown) {
3194
+ <p class="text-xs text-surface-500 dark:text-surface-400">
3195
+ {{ prefix + '.kpi.limitUnknown' | transloco }}
3196
+ </p>
3197
+ }
3198
+ </mt-calculation-explanation-section>
3199
+ }
3200
+
3201
+ @for (measure of view.measures; track $index) {
3202
+ <mt-calculation-explanation-section
3203
+ [title]="prefix + '.measuresUsed.title' | transloco"
3204
+ [aside]="measure.count"
3205
+ [open]="true"
3206
+ >
3207
+ <div class="flex items-baseline justify-between gap-3">
3208
+ <h3 class="font-semibold text-surface-900 dark:text-surface-0">
3209
+ {{ measure.title }}
3210
+ </h3>
3211
+ <bdi class="font-semibold tabular-nums">{{ measure.result }}</bdi>
3212
+ </div>
3213
+ @if (measure.rule) {
3214
+ <p>{{ measure.rule }}</p>
3215
+ }
3216
+ <p class="text-xs text-surface-500 dark:text-surface-400">
3217
+ {{
3218
+ prefix + '.measuresUsed.asOf' | transloco: { date: measure.asOf }
3219
+ }}
3220
+ </p>
3221
+ @if (measure.rows.length) {
3222
+ <div class="overflow-x-auto">
3223
+ <table class="w-full text-xs tabular-nums">
3224
+ <thead>
3225
+ <tr class="text-surface-500 dark:text-surface-400">
3226
+ <th class="py-1 pe-3 text-start font-medium">
3227
+ {{ prefix + '.measuresUsed.period' | transloco }}
3228
+ </th>
3229
+ <th class="px-3 py-1 text-end font-medium">
3230
+ {{ prefix + '.measuresUsed.value' | transloco }}
3231
+ </th>
3232
+ <th class="px-3 py-1 text-end font-medium">
3233
+ {{ prefix + '.measuresUsed.target' | transloco }}
3234
+ </th>
3235
+ <th class="py-1 ps-3 text-start font-medium">
3236
+ {{ prefix + '.measuresUsed.status' | transloco }}
3237
+ </th>
3238
+ </tr>
3239
+ </thead>
3240
+ <tbody>
3241
+ @for (row of measure.rows; track $index) {
3242
+ <tr
3243
+ class="border-t border-surface-200 dark:border-surface-700"
3244
+ >
3245
+ <td class="py-1 pe-3 align-top">
3246
+ <bdi>{{ row.period }}</bdi>
3247
+ @if (row.reporting; as reporting) {
3248
+ <div class="text-surface-500 dark:text-surface-400">
3249
+ {{
3250
+ prefix + '.measuresUsed.reported'
3251
+ | transloco: { date: reporting }
3252
+ }}
3253
+ </div>
3254
+ }
3255
+ </td>
3256
+ <td class="px-3 py-1 text-end align-top">
3257
+ <bdi>{{ row.value }}</bdi>
3258
+ </td>
3259
+ <td class="px-3 py-1 text-end align-top">
3260
+ <bdi>{{ row.target }}</bdi>
3261
+ </td>
3262
+ <td class="py-1 ps-3 align-top">
3263
+ {{ row.status }}
3264
+ @if (row.ignored) {
3265
+ <span
3266
+ class="ms-1 rounded-md bg-surface-100 px-1.5 py-0.5 dark:bg-surface-800"
3267
+ >{{
3268
+ prefix + '.measuresUsed.ignored' | transloco
3269
+ }}</span
3270
+ >
3271
+ }
3272
+ @if (row.cascaded) {
3273
+ <span
3274
+ class="ms-1 rounded-md bg-surface-100 px-1.5 py-0.5 dark:bg-surface-800"
3275
+ >{{
3276
+ prefix + '.measuresUsed.cascaded' | transloco
3277
+ }}</span
3278
+ >
3279
+ }
3280
+ </td>
3281
+ </tr>
3282
+ }
3283
+ </tbody>
3284
+ </table>
3285
+ </div>
3286
+ }
3287
+ </mt-calculation-explanation-section>
3288
+ }
3289
+
2805
3290
  @if (view.values.length) {
2806
3291
  <mt-calculation-explanation-section
2807
3292
  [title]="prefix + '.valuesUsed' | transloco"
@@ -3292,6 +3777,139 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImpor
3292
3777
  <p>{{ view.description }}</p>
3293
3778
  }
3294
3779
 
3780
+ @if (view.kpi; as kpi) {
3781
+ <mt-calculation-explanation-section
3782
+ [title]="prefix + '.kpi.title' | transloco"
3783
+ [open]="true"
3784
+ >
3785
+ @if (kpi.steps; as steps) {
3786
+ <ol class="flex flex-col gap-1">
3787
+ @for (step of steps; track $index) {
3788
+ <li class="flex items-baseline justify-between gap-3">
3789
+ <span>{{ step.label }}</span>
3790
+ @if (step.value !== null) {
3791
+ <bdi class="font-medium tabular-nums">{{ step.value }}</bdi>
3792
+ }
3793
+ </li>
3794
+ }
3795
+ </ol>
3796
+ }
3797
+ <dl
3798
+ class="grid grid-cols-[minmax(0,auto)_minmax(0,1fr)] gap-x-3 gap-y-1"
3799
+ >
3800
+ @for (row of kpi.rows; track $index) {
3801
+ <dt class="text-surface-500 dark:text-surface-400">
3802
+ {{ row.label }}
3803
+ </dt>
3804
+ <dd class="ms-0 min-w-0">
3805
+ <bdi class="tabular-nums">{{ row.value }}</bdi>
3806
+ </dd>
3807
+ }
3808
+ </dl>
3809
+ @if (kpi.limit; as limit) {
3810
+ <div
3811
+ class="rounded-md border border-amber-200 bg-amber-50 px-3 py-2 text-amber-700"
3812
+ >
3813
+ {{ limit }}
3814
+ </div>
3815
+ }
3816
+ @if (kpi.limitUnknown) {
3817
+ <p class="text-xs text-surface-500 dark:text-surface-400">
3818
+ {{ prefix + '.kpi.limitUnknown' | transloco }}
3819
+ </p>
3820
+ }
3821
+ </mt-calculation-explanation-section>
3822
+ }
3823
+
3824
+ @for (measure of view.measures; track $index) {
3825
+ <mt-calculation-explanation-section
3826
+ [title]="prefix + '.measuresUsed.title' | transloco"
3827
+ [aside]="measure.count"
3828
+ [open]="true"
3829
+ >
3830
+ <div class="flex items-baseline justify-between gap-3">
3831
+ <h3 class="font-semibold text-surface-900 dark:text-surface-0">
3832
+ {{ measure.title }}
3833
+ </h3>
3834
+ <bdi class="font-semibold tabular-nums">{{ measure.result }}</bdi>
3835
+ </div>
3836
+ @if (measure.rule) {
3837
+ <p>{{ measure.rule }}</p>
3838
+ }
3839
+ <p class="text-xs text-surface-500 dark:text-surface-400">
3840
+ {{
3841
+ prefix + '.measuresUsed.asOf' | transloco: { date: measure.asOf }
3842
+ }}
3843
+ </p>
3844
+ @if (measure.rows.length) {
3845
+ <div class="overflow-x-auto">
3846
+ <table class="w-full text-xs tabular-nums">
3847
+ <thead>
3848
+ <tr class="text-surface-500 dark:text-surface-400">
3849
+ <th class="py-1 pe-3 text-start font-medium">
3850
+ {{ prefix + '.measuresUsed.period' | transloco }}
3851
+ </th>
3852
+ <th class="px-3 py-1 text-end font-medium">
3853
+ {{ prefix + '.measuresUsed.value' | transloco }}
3854
+ </th>
3855
+ <th class="px-3 py-1 text-end font-medium">
3856
+ {{ prefix + '.measuresUsed.target' | transloco }}
3857
+ </th>
3858
+ <th class="py-1 ps-3 text-start font-medium">
3859
+ {{ prefix + '.measuresUsed.status' | transloco }}
3860
+ </th>
3861
+ </tr>
3862
+ </thead>
3863
+ <tbody>
3864
+ @for (row of measure.rows; track $index) {
3865
+ <tr
3866
+ class="border-t border-surface-200 dark:border-surface-700"
3867
+ >
3868
+ <td class="py-1 pe-3 align-top">
3869
+ <bdi>{{ row.period }}</bdi>
3870
+ @if (row.reporting; as reporting) {
3871
+ <div class="text-surface-500 dark:text-surface-400">
3872
+ {{
3873
+ prefix + '.measuresUsed.reported'
3874
+ | transloco: { date: reporting }
3875
+ }}
3876
+ </div>
3877
+ }
3878
+ </td>
3879
+ <td class="px-3 py-1 text-end align-top">
3880
+ <bdi>{{ row.value }}</bdi>
3881
+ </td>
3882
+ <td class="px-3 py-1 text-end align-top">
3883
+ <bdi>{{ row.target }}</bdi>
3884
+ </td>
3885
+ <td class="py-1 ps-3 align-top">
3886
+ {{ row.status }}
3887
+ @if (row.ignored) {
3888
+ <span
3889
+ class="ms-1 rounded-md bg-surface-100 px-1.5 py-0.5 dark:bg-surface-800"
3890
+ >{{
3891
+ prefix + '.measuresUsed.ignored' | transloco
3892
+ }}</span
3893
+ >
3894
+ }
3895
+ @if (row.cascaded) {
3896
+ <span
3897
+ class="ms-1 rounded-md bg-surface-100 px-1.5 py-0.5 dark:bg-surface-800"
3898
+ >{{
3899
+ prefix + '.measuresUsed.cascaded' | transloco
3900
+ }}</span
3901
+ >
3902
+ }
3903
+ </td>
3904
+ </tr>
3905
+ }
3906
+ </tbody>
3907
+ </table>
3908
+ </div>
3909
+ }
3910
+ </mt-calculation-explanation-section>
3911
+ }
3912
+
3295
3913
  @if (view.values.length) {
3296
3914
  <mt-calculation-explanation-section
3297
3915
  [title]="prefix + '.valuesUsed' | transloco"
@@ -8479,5 +9097,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImpor
8479
9097
  * Generated bundle index. Do not edit.
8480
9098
  */
8481
9099
 
8482
- export { CALCULATION_CHANGE_CHIP_MS, CALCULATION_EXPLANATION_KEYS, CONNECTION_KEY_SEPARATOR, CURRENCY_COMPACT_THRESHOLD, CalculatedValueHistory, CalculationExplanationApi, CalculationExplanationChecks, CalculationExplanationDetails, CalculationExplanationEquation, CalculationExplanationPanel, CalculationExplanationSummary, CalculationRecordNames, ComparisonEntityList, ComparisonValue, DEFAULT_PERFORMANCE_SCORE_CHART_SIZE, DEFAULT_PHASE_GATE_COLOR, ENTITY_EMPTY_VALUE_PLACEHOLDER, ENTITY_HEADER_VIEW_TYPES, ENTITY_LIST_TABLE_COMPONENT, ENTITY_ROW_SPANS, EntitiesManage, EntitiesPreview, EntitiesResizeBase, EntityAttachment, EntityCalculatedGlyph, EntityCalculatedIndicator, EntityCalculationChangeChip, EntityCalculationExplanation, EntityCalculationRefresher, EntityCheckbox, EntityColor, EntityConnection, EntityCurrency, EntityDate, EntityField, EntityHeader, EntityIcon, EntityLeafDetails, EntityListDrawer, EntityListPreview, EntityLocation, EntityLongText, EntityLookup, EntityLookupModuleCheckList, EntityPercentage, EntityPerformanceScore, EntityPhaseGate, EntityPreview, EntityPreviewBody, EntityRuntimeContextStore, EntityScheduleItem, EntityStatus, EntityText, EntityUser, FitText, LEAF_DETAILS_KEY_SEPARATOR, LEAF_PHASES_KEY_SEPARATOR, MT_CALCULATION_CURRENCY, MT_CALCULATION_STATUS_NAMES, PERFORMANCE_SCORE_CHART_SIZES, SECTION_KEY_PREFIX, buildCalculationExplanationView, buildCodeSegments, buildConditionChecks, buildConnectionKey, buildDisplayEntities, buildEntityListRows, buildExplanationDetails, buildExplanationSegments, buildSectionKey, calculationRecordKey, canEntityBeHeader, capitalizeSegments, compactCurrencyDisplay, currencyUnitOf, describeCalculationChange, describeDocument, detailRecordRefs, displayName, displayOrPlaceholder, expandConnectionEntity, expandLeafDetailsEntity, extractDisplayText, formatCalculationDelta, formatExplanationNumber, formatExplanationValue, formatTypedValue, getEntitySectionTitle, getPerformanceScoreBands, groupEntitiesIntoSections, hasExplanationDetails, humanizeEntityListKey, humanizeKey$1 as humanizeKey, isCalculatedProperty, isConnectionSyntheticKey, isEntityAlignEnd, isEntityHeader, isEntityLabelHidden, isEntityListLocalDocument, isEntityListSelectionDocument, isEntitySection, isEquationDocument, isLeafDetailsCatalogConfiguration, isLeafDetailsCollectionValue, isLeafDetailsRuntimeValue, isLeafDetailsSyntheticKey, isLeafDetailsValue, isLeafPhasesSyntheticKey, isLeafSyntheticKey, isMissingBaseline, isSameSavedValue, isSectionKey, isValueMissing, localCellsByFieldId, matchesPercentageColorRule, mergeStakeholderNameColumns, mergeStakeholderNameEntities, mergeStakeholderNameRows, normalizeConnectionSourceLevels, normalizeNumerals, orderedStatusRules, parseCurrencyAmount, parsePerformanceScore, pinEntityHeaderFirst, readEntityHeaderDefaults, readEntityValueColor, resolveConnectionLevelName, resolveEntityGridRow, resolveEntityHeader, resolveEntityInfo, resolveEntityLabelPosition, resolveLocalFieldConfiguration, resolveLocalFieldLabel, resolveLocalFieldViewType, resolveLocalizedLabel, resolvePercentageColor, resolvePerformanceScoreStatus, selectedStatusRule, serializeEntityRawValue, serverText, sharedActiveLang, sortLocalRows, splitConnectionKey, splitLeafKey, statusName, summarizeEntityListRows, toCalculationContextKey, toCalculationExplanationTarget, toExplanationData, toFetchContextKey, visibleLocalSchemaFields };
9100
+ export { CALCULATION_CHANGE_CHIP_MS, CALCULATION_EXPLANATION_KEYS, CONNECTION_KEY_SEPARATOR, CURRENCY_COMPACT_THRESHOLD, CalculatedValueHistory, CalculationExplanationApi, CalculationExplanationChecks, CalculationExplanationDetails, CalculationExplanationEquation, CalculationExplanationPanel, CalculationExplanationSummary, CalculationRecordNames, ComparisonEntityList, ComparisonValue, DEFAULT_PERFORMANCE_SCORE_CHART_SIZE, DEFAULT_PHASE_GATE_COLOR, ENTITY_EMPTY_VALUE_PLACEHOLDER, ENTITY_HEADER_VIEW_TYPES, ENTITY_LIST_TABLE_COMPONENT, ENTITY_ROW_SPANS, EntitiesManage, EntitiesPreview, EntitiesResizeBase, EntityAttachment, EntityCalculatedGlyph, EntityCalculatedIndicator, EntityCalculationChangeChip, EntityCalculationExplanation, EntityCalculationRefresher, EntityCheckbox, EntityColor, EntityConnection, EntityCurrency, EntityDate, EntityField, EntityHeader, EntityIcon, EntityLeafDetails, EntityListDrawer, EntityListPreview, EntityLocation, EntityLongText, EntityLookup, EntityLookupModuleCheckList, EntityPercentage, EntityPerformanceScore, EntityPhaseGate, EntityPreview, EntityPreviewBody, EntityRuntimeContextStore, EntityScheduleItem, EntityStatus, EntityText, EntityUser, FitText, LEAF_DETAILS_KEY_SEPARATOR, LEAF_PHASES_KEY_SEPARATOR, MT_CALCULATION_CURRENCY, MT_CALCULATION_EXPLANATION_RESPONSE_MAPPER, MT_CALCULATION_STATUS_NAMES, PERFORMANCE_SCORE_CHART_SIZES, SECTION_KEY_PREFIX, buildCalculationExplanationView, buildCodeSegments, buildConditionChecks, buildConnectionKey, buildDisplayEntities, buildEntityListRows, buildExplanationDetails, buildExplanationSegments, buildSectionKey, calculationRecordKey, canEntityBeHeader, capitalizeSegments, compactCurrencyDisplay, currencyUnitOf, describeCalculationChange, describeDocument, detailRecordRefs, displayName, displayOrPlaceholder, expandConnectionEntity, expandLeafDetailsEntity, explanationReason, extractDisplayText, formatCalculationDelta, formatExplanationNumber, formatExplanationValue, formatTypedValue, getEntitySectionTitle, getPerformanceScoreBands, groupEntitiesIntoSections, hasExplanationDetails, humanizeEntityListKey, humanizeKey$1 as humanizeKey, isCalculatedProperty, isConnectionSyntheticKey, isEntityAlignEnd, isEntityHeader, isEntityLabelHidden, isEntityListLocalDocument, isEntityListSelectionDocument, isEntitySection, isEquationDocument, isLeafDetailsCatalogConfiguration, isLeafDetailsCollectionValue, isLeafDetailsRuntimeValue, isLeafDetailsSyntheticKey, isLeafDetailsValue, isLeafPhasesSyntheticKey, isLeafSyntheticKey, isMissingBaseline, isSameSavedValue, isSectionKey, isValueMissing, localCellsByFieldId, matchesPercentageColorRule, measurePeriodLabel, mergeStakeholderNameColumns, mergeStakeholderNameEntities, mergeStakeholderNameRows, normalizeConnectionSourceLevels, normalizeNumerals, orderedStatusRules, parseCurrencyAmount, parsePerformanceScore, pinEntityHeaderFirst, provideCalculationExplanationResponseMapper, readEntityHeaderDefaults, readEntityValueColor, resolveConnectionLevelName, resolveEntityGridRow, resolveEntityHeader, resolveEntityInfo, resolveEntityLabelPosition, resolveLocalFieldConfiguration, resolveLocalFieldLabel, resolveLocalFieldViewType, resolveLocalizedLabel, resolvePercentageColor, resolvePerformanceScoreStatus, selectedStatusRule, serializeEntityRawValue, serverText, sharedActiveLang, sortLocalRows, splitConnectionKey, splitLeafKey, statusName, summarizeEntityListRows, toCalculationContextKey, toCalculationExplanationTarget, toExplanationData, toFetchContextKey, visibleLocalSchemaFields };
8483
9101
  //# sourceMappingURL=masterteam-components-entities.mjs.map