@masterteam/components 0.0.343 → 0.0.344
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/assets/common.css +1 -1
- package/assets/i18n/ar.json +92 -4
- package/assets/i18n/en.json +92 -4
- package/fesm2022/masterteam-components-entities.mjs +2182 -232
- package/fesm2022/masterteam-components-entities.mjs.map +1 -1
- package/package.json +1 -1
- package/types/masterteam-components-entities.d.ts +365 -29
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { signal, Injectable, InjectionToken, inject, input, computed,
|
|
2
|
+
import { signal, Injectable, InjectionToken, inject, input, computed, ChangeDetectionStrategy, Component, DestroyRef, viewChild, ElementRef, afterNextRender, Directive, effect, untracked, ViewEncapsulation, output, NgZone, model } from '@angular/core';
|
|
3
3
|
import { Tooltip, TruncateTooltip } from '@masterteam/components/tooltip';
|
|
4
4
|
import { Icon } from '@masterteam/icons';
|
|
5
5
|
import { NgTemplateOutlet, NgComponentOutlet, DOCUMENT } from '@angular/common';
|
|
6
6
|
import { TranslocoPipe, TranslocoService } from '@jsverse/transloco';
|
|
7
7
|
import { Popover } from 'primeng/popover';
|
|
8
8
|
import { MTDateFormatPipe, REQUEST_CONTEXT, coerceCheckboxValue, readableTextOn, getLightColor } from '@masterteam/components';
|
|
9
|
-
import { HttpClient, HttpContext } from '@angular/common/http';
|
|
10
9
|
import { toSignal } from '@angular/core/rxjs-interop';
|
|
10
|
+
import { HttpClient, HttpContext } from '@angular/common/http';
|
|
11
11
|
import { Avatar } from '@masterteam/components/avatar';
|
|
12
12
|
import { SecureImagePipe, UploadField } from '@masterteam/components/upload-field';
|
|
13
13
|
import { Progress } from '@masterteam/components/progress';
|
|
@@ -346,6 +346,34 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImpor
|
|
|
346
346
|
*/
|
|
347
347
|
const ENTITY_LIST_TABLE_COMPONENT = new InjectionToken('ENTITY_LIST_TABLE_COMPONENT');
|
|
348
348
|
|
|
349
|
+
/**
|
|
350
|
+
* One shared active-language signal per `TranslocoService`.
|
|
351
|
+
*
|
|
352
|
+
* `mt-entity-preview` renders once per property per record — a client-list card
|
|
353
|
+
* grid mounts thousands of them — so a `toSignal(langChanges$)` inside each
|
|
354
|
+
* instance would open thousands of subscriptions to the same Subject just to
|
|
355
|
+
* read one global value. The language is global, so the signal is too: created
|
|
356
|
+
* once, cached against the service, and shared by every entity that needs it.
|
|
357
|
+
*
|
|
358
|
+
* `manualCleanup` is deliberate. The cached signal outlives any single
|
|
359
|
+
* component by design, and the service it hangs off is the root injector's —
|
|
360
|
+
* tying its subscription to whichever entity happened to ask first would tear
|
|
361
|
+
* it down the moment that entity scrolled out of view.
|
|
362
|
+
*/
|
|
363
|
+
const langSignals = new WeakMap();
|
|
364
|
+
function sharedActiveLang(transloco) {
|
|
365
|
+
const cached = langSignals.get(transloco);
|
|
366
|
+
if (cached) {
|
|
367
|
+
return cached;
|
|
368
|
+
}
|
|
369
|
+
const lang = toSignal(transloco.langChanges$, {
|
|
370
|
+
initialValue: transloco.getActiveLang(),
|
|
371
|
+
manualCleanup: true,
|
|
372
|
+
});
|
|
373
|
+
langSignals.set(transloco, lang);
|
|
374
|
+
return lang;
|
|
375
|
+
}
|
|
376
|
+
|
|
349
377
|
/**
|
|
350
378
|
* Reads the latest saved calculation of a value. The request never
|
|
351
379
|
* recalculates anything; the response is marked `no-store`, so every open
|
|
@@ -387,17 +415,15 @@ function toCalculationContextKey(contextKey) {
|
|
|
387
415
|
return moduleOnly ? `Module:${moduleOnly[1]}` : null;
|
|
388
416
|
}
|
|
389
417
|
/**
|
|
390
|
-
* What a value's calculated-value mark explains on click:
|
|
391
|
-
*
|
|
392
|
-
*
|
|
393
|
-
* keeps the plain mark.
|
|
418
|
+
* What a value's calculated-value mark explains on click: any calculated value
|
|
419
|
+
* (a formula, a status, a generated code, a date or an amount) whose host
|
|
420
|
+
* named the record it was read from.
|
|
394
421
|
*/
|
|
395
422
|
function toCalculationExplanationTarget(entity, label) {
|
|
396
423
|
const source = entity?.calculationSource;
|
|
397
424
|
if (!entity?.calculated ||
|
|
398
425
|
!source ||
|
|
399
426
|
!entity.key ||
|
|
400
|
-
entity.viewType === 'Status' ||
|
|
401
427
|
!(source.recordId > 0) ||
|
|
402
428
|
!toCalculationContextKey(source.contextKey)) {
|
|
403
429
|
return null;
|
|
@@ -407,8 +433,20 @@ function toCalculationExplanationTarget(entity, label) {
|
|
|
407
433
|
propertyKey: entity.key,
|
|
408
434
|
label: label || entity.name || entity.key,
|
|
409
435
|
displayedValue: entity.rawValue,
|
|
436
|
+
viewType: entity.viewType,
|
|
437
|
+
statusNames: statusNamesOf(entity.value),
|
|
410
438
|
};
|
|
411
439
|
}
|
|
440
|
+
/** The name of the status on screen, keyed by its status key. */
|
|
441
|
+
function statusNamesOf(value) {
|
|
442
|
+
if (!value || typeof value !== 'object') {
|
|
443
|
+
return undefined;
|
|
444
|
+
}
|
|
445
|
+
const { key, display } = value;
|
|
446
|
+
return typeof key === 'string' && typeof display === 'string' && display
|
|
447
|
+
? { [key]: display }
|
|
448
|
+
: undefined;
|
|
449
|
+
}
|
|
412
450
|
/**
|
|
413
451
|
* Lets an explanation ask the host that rendered a value to read it again,
|
|
414
452
|
* when the saved value no longer matches the one on screen. Provided by
|
|
@@ -417,7 +455,1729 @@ function toCalculationExplanationTarget(entity, label) {
|
|
|
417
455
|
class EntityCalculationRefresher {
|
|
418
456
|
}
|
|
419
457
|
|
|
420
|
-
|
|
458
|
+
/**
|
|
459
|
+
* The application's currency unit (`SAR`), shown after captured amounts. The
|
|
460
|
+
* explanation never guesses a currency: without this token, or with an empty
|
|
461
|
+
* unit, amounts are shown as plain numbers.
|
|
462
|
+
*/
|
|
463
|
+
const MT_CALCULATION_CURRENCY = new InjectionToken('MT_CALCULATION_CURRENCY', { providedIn: 'root', factory: () => signal('').asReadonly() });
|
|
464
|
+
const CALCULATION_EXPLANATION_KEYS = 'components.entitiesPreview.calculationExplanation';
|
|
465
|
+
const K = CALCULATION_EXPLANATION_KEYS;
|
|
466
|
+
const NUMERIC_VIEW_TYPES$1 = new Set(['Number', 'Currency', 'Percentage']);
|
|
467
|
+
const DATE_VIEW_TYPES = {
|
|
468
|
+
Date: 'date',
|
|
469
|
+
DateTime: 'dateTime',
|
|
470
|
+
Time: 'time',
|
|
471
|
+
};
|
|
472
|
+
const EQUATION_KINDS = new Set([
|
|
473
|
+
'literal',
|
|
474
|
+
'input',
|
|
475
|
+
'semantic',
|
|
476
|
+
'table',
|
|
477
|
+
'binary',
|
|
478
|
+
'unary',
|
|
479
|
+
'function',
|
|
480
|
+
'conditional',
|
|
481
|
+
'array',
|
|
482
|
+
]);
|
|
483
|
+
const OPERATORS = {
|
|
484
|
+
'+': '+',
|
|
485
|
+
'-': '−',
|
|
486
|
+
'*': '×',
|
|
487
|
+
'/': '÷',
|
|
488
|
+
'%': 'mod',
|
|
489
|
+
'==': '=',
|
|
490
|
+
'!=': '≠',
|
|
491
|
+
'<': '<',
|
|
492
|
+
'<=': '≤',
|
|
493
|
+
'>': '>',
|
|
494
|
+
'>=': '≥',
|
|
495
|
+
'&&': 'AND',
|
|
496
|
+
'||': 'OR',
|
|
497
|
+
};
|
|
498
|
+
const SEMANTIC_KEYS = new Set([
|
|
499
|
+
'actual_progress',
|
|
500
|
+
'planned_progress',
|
|
501
|
+
'baseline_progress',
|
|
502
|
+
]);
|
|
503
|
+
const CODE_BLOCK_TYPES = new Set([
|
|
504
|
+
'Source',
|
|
505
|
+
'StaticText',
|
|
506
|
+
'Counter',
|
|
507
|
+
'CurrentDatePart',
|
|
508
|
+
]);
|
|
509
|
+
const SCHEDULE_NOTES = new Set([
|
|
510
|
+
'noEligibleScheduleItems',
|
|
511
|
+
'allWeightsZeroUsingArithmeticMean',
|
|
512
|
+
'zeroWeightItemsExcluded',
|
|
513
|
+
'missingInputsTreatedAsZero',
|
|
514
|
+
'noBaselineProgressInputs',
|
|
515
|
+
]);
|
|
516
|
+
const PLANNED_RULES = new Set([
|
|
517
|
+
'missingDates',
|
|
518
|
+
'invalidDateRange',
|
|
519
|
+
'beforeStart',
|
|
520
|
+
'afterFinish',
|
|
521
|
+
'milestoneDueDate',
|
|
522
|
+
'noWorkingTime',
|
|
523
|
+
'elapsedWorkingMinutes',
|
|
524
|
+
]);
|
|
525
|
+
/** Vector inputs list their values inline up to this many. */
|
|
526
|
+
const INLINE_VALUES = 3;
|
|
527
|
+
/** Source record ids listed before "+n". */
|
|
528
|
+
const LISTED_IDS = 20;
|
|
529
|
+
/** Nested captured data rendered as fields up to this depth, then as JSON. */
|
|
530
|
+
const DATA_DEPTH = 3;
|
|
531
|
+
/** A number as captured: grouped, never rounded, with a real minus sign. */
|
|
532
|
+
function formatExplanationNumber(value) {
|
|
533
|
+
if (!Number.isFinite(value)) {
|
|
534
|
+
return String(value);
|
|
535
|
+
}
|
|
536
|
+
return new Intl.NumberFormat('en-US', { maximumFractionDigits: 20 })
|
|
537
|
+
.format(value)
|
|
538
|
+
.replace(/^-/, '−');
|
|
539
|
+
}
|
|
540
|
+
/** A captured value as plain text. Never formatted or rounded here. */
|
|
541
|
+
function formatExplanationValue(value) {
|
|
542
|
+
if (value === null || value === undefined) {
|
|
543
|
+
return '—';
|
|
544
|
+
}
|
|
545
|
+
return typeof value === 'object' ? JSON.stringify(value) : String(value);
|
|
546
|
+
}
|
|
547
|
+
/**
|
|
548
|
+
* A captured value the way its property shows values: grouped numbers, the
|
|
549
|
+
* application currency, `%`, the configured date format.
|
|
550
|
+
*/
|
|
551
|
+
function formatTypedValue(value, viewType, ctx) {
|
|
552
|
+
if (value === null || value === undefined || value === '') {
|
|
553
|
+
return '—';
|
|
554
|
+
}
|
|
555
|
+
if (Array.isArray(value)) {
|
|
556
|
+
return value
|
|
557
|
+
.map((item) => formatTypedValue(item, viewType, ctx))
|
|
558
|
+
.join(', ');
|
|
559
|
+
}
|
|
560
|
+
if (typeof value === 'object') {
|
|
561
|
+
return JSON.stringify(value);
|
|
562
|
+
}
|
|
563
|
+
if (typeof value === 'boolean') {
|
|
564
|
+
return ctx.translate(`${K}.${value ? 'yes' : 'no'}`);
|
|
565
|
+
}
|
|
566
|
+
const type = viewType ?? '';
|
|
567
|
+
if (typeof value === 'number') {
|
|
568
|
+
return formatTypedNumber(value, type, ctx);
|
|
569
|
+
}
|
|
570
|
+
if (NUMERIC_VIEW_TYPES$1.has(type) && isNumericText(value)) {
|
|
571
|
+
return formatTypedNumber(Number(value), type, ctx);
|
|
572
|
+
}
|
|
573
|
+
const dateType = DATE_VIEW_TYPES[type];
|
|
574
|
+
if (dateType) {
|
|
575
|
+
return ctx.formatDate(value, dateType) || value;
|
|
576
|
+
}
|
|
577
|
+
if (type === 'Checkbox' && (value === 'true' || value === 'false')) {
|
|
578
|
+
return ctx.translate(`${K}.${value === 'true' ? 'yes' : 'no'}`);
|
|
579
|
+
}
|
|
580
|
+
return value;
|
|
581
|
+
}
|
|
582
|
+
function formatTypedNumber(value, viewType, ctx) {
|
|
583
|
+
const text = formatExplanationNumber(value);
|
|
584
|
+
if (viewType === 'Currency') {
|
|
585
|
+
return ctx.currency ? `${text} ${ctx.currency}` : text;
|
|
586
|
+
}
|
|
587
|
+
return viewType === 'Percentage' ? `${text}%` : text;
|
|
588
|
+
}
|
|
589
|
+
function isNumericText(value) {
|
|
590
|
+
return value.trim() !== '' && Number.isFinite(Number(value));
|
|
591
|
+
}
|
|
592
|
+
/** A property's current name in the active language. */
|
|
593
|
+
function displayName(display, lang) {
|
|
594
|
+
if (!display) {
|
|
595
|
+
return null;
|
|
596
|
+
}
|
|
597
|
+
const preferred = lang.startsWith('ar')
|
|
598
|
+
? [display.nameAr, display.name, display.nameEn]
|
|
599
|
+
: [display.nameEn, display.name, display.nameAr];
|
|
600
|
+
return preferred.find((name) => !!name?.trim()) ?? null;
|
|
601
|
+
}
|
|
602
|
+
/** `Current::project_budget` → `project_budget`, for an unnamed input. */
|
|
603
|
+
function referenceColumn(reference) {
|
|
604
|
+
if (!reference) {
|
|
605
|
+
return null;
|
|
606
|
+
}
|
|
607
|
+
const at = reference.lastIndexOf('::');
|
|
608
|
+
return at >= 0 ? reference.slice(at + 2) : reference;
|
|
609
|
+
}
|
|
610
|
+
/** `Modules.LevelDataFinancial` → `LevelDataFinancial`. */
|
|
611
|
+
function tableLabel(tablePath) {
|
|
612
|
+
return (tablePath ?? '').replace(/^Modules\./, '') || '—';
|
|
613
|
+
}
|
|
614
|
+
/** `totalLevelWeight` / `is_cancelled` → `Total level weight` / `Is cancelled`. */
|
|
615
|
+
function humanizeKey$1(key) {
|
|
616
|
+
const words = key
|
|
617
|
+
.replace(/([a-z0-9])([A-Z])/g, '$1 $2')
|
|
618
|
+
.replace(/[_.-]+/g, ' ')
|
|
619
|
+
.trim()
|
|
620
|
+
.toLowerCase();
|
|
621
|
+
return words ? words[0].toUpperCase() + words.slice(1) : key;
|
|
622
|
+
}
|
|
623
|
+
function semanticLabel(reference, ctx) {
|
|
624
|
+
const column = referenceColumn(reference);
|
|
625
|
+
return column && SEMANTIC_KEYS.has(column)
|
|
626
|
+
? ctx.translate(`${K}.semantic.${column}`)
|
|
627
|
+
: null;
|
|
628
|
+
}
|
|
629
|
+
function nodeLabel(node, ctx) {
|
|
630
|
+
return (displayName(node.display, ctx.lang) ??
|
|
631
|
+
(node.kind === 'semantic' ? semanticLabel(node.reference, ctx) : null) ??
|
|
632
|
+
referenceColumn(node.reference) ??
|
|
633
|
+
(node.expression || node.kind));
|
|
634
|
+
}
|
|
635
|
+
function nodeValueText(node, ctx) {
|
|
636
|
+
if (node.state === 'notEvaluated') {
|
|
637
|
+
return ctx.translate(`${K}.notEvaluated`);
|
|
638
|
+
}
|
|
639
|
+
const value = node.value;
|
|
640
|
+
const viewType = node.display?.viewType;
|
|
641
|
+
if (Array.isArray(value)) {
|
|
642
|
+
return value.length <= INLINE_VALUES
|
|
643
|
+
? value.map((item) => formatTypedValue(item, viewType, ctx)).join(', ')
|
|
644
|
+
: ctx.translate(`${K}.valueCount`, { count: value.length });
|
|
645
|
+
}
|
|
646
|
+
return formatTypedValue(value, viewType, ctx);
|
|
647
|
+
}
|
|
648
|
+
function scheduleDetailOf(document, reference) {
|
|
649
|
+
return ((reference &&
|
|
650
|
+
document.schedule?.find((detail) => detail.reference === reference)) ||
|
|
651
|
+
null);
|
|
652
|
+
}
|
|
653
|
+
/** `Weighted average of 4 items`. */
|
|
654
|
+
function describeRollup(detail, ctx) {
|
|
655
|
+
if (!['weightedAverage', 'arithmeticMean'].includes(detail.aggregation)) {
|
|
656
|
+
return ctx.translate(`${K}.schedule.aggregation.empty`);
|
|
657
|
+
}
|
|
658
|
+
return ctx.translate(`${K}.schedule.rollup`, {
|
|
659
|
+
aggregation: ctx.translate(`${K}.schedule.aggregation.${detail.aggregation}`),
|
|
660
|
+
count: (detail.contributors ?? []).filter((row) => row.includedInAggregation).length,
|
|
661
|
+
});
|
|
662
|
+
}
|
|
663
|
+
/** `__central_planned_start` → `Planned start`. */
|
|
664
|
+
function columnLabel(reference) {
|
|
665
|
+
const column = referenceColumn(reference) ?? '';
|
|
666
|
+
return humanizeKey$1(column.replace(/^_+/, '').replace(/^central_/, ''));
|
|
667
|
+
}
|
|
668
|
+
/** Whether the document's root reads as an equation. */
|
|
669
|
+
function isEquationDocument(document) {
|
|
670
|
+
const root = document.nodes?.find((node) => node.id === document.rootNodeId);
|
|
671
|
+
return !!root && EQUATION_KINDS.has(root.kind);
|
|
672
|
+
}
|
|
673
|
+
/**
|
|
674
|
+
* The calculation as a readable equation: every input by its property name
|
|
675
|
+
* with the value it had, operators as symbols, nested function results shown
|
|
676
|
+
* after the call. `null` when the document is not an equation (a native
|
|
677
|
+
* method, a status selection, a generated code).
|
|
678
|
+
*/
|
|
679
|
+
function buildExplanationSegments(document, ctx) {
|
|
680
|
+
if (!isEquationDocument(document)) {
|
|
681
|
+
return null;
|
|
682
|
+
}
|
|
683
|
+
const byId = new Map(document.nodes.map((node) => [node.id, node]));
|
|
684
|
+
const out = [];
|
|
685
|
+
const visited = new Set();
|
|
686
|
+
const render = (id, nested) => {
|
|
687
|
+
const node = byId.get(id);
|
|
688
|
+
if (!node || visited.has(id)) {
|
|
689
|
+
out.push({ kind: 'muted', text: '…' });
|
|
690
|
+
return;
|
|
691
|
+
}
|
|
692
|
+
visited.add(id);
|
|
693
|
+
const notEvaluated = node.state === 'notEvaluated';
|
|
694
|
+
switch (node.kind) {
|
|
695
|
+
case 'literal':
|
|
696
|
+
// Written the way the formula wrote it: `"Paid"`, `true`, `1,000`.
|
|
697
|
+
out.push({
|
|
698
|
+
kind: 'value',
|
|
699
|
+
text: typeof node.value === 'string'
|
|
700
|
+
? `"${node.value}"`
|
|
701
|
+
: typeof node.value === 'number'
|
|
702
|
+
? formatExplanationNumber(node.value)
|
|
703
|
+
: node.expression || formatExplanationValue(node.value),
|
|
704
|
+
});
|
|
705
|
+
return;
|
|
706
|
+
case 'input':
|
|
707
|
+
out.push({
|
|
708
|
+
kind: 'term',
|
|
709
|
+
label: nodeLabel(node, ctx),
|
|
710
|
+
value: nodeValueText(node, ctx),
|
|
711
|
+
});
|
|
712
|
+
return;
|
|
713
|
+
case 'semantic': {
|
|
714
|
+
// A schedule rollup reads as how it was aggregated; its numbers are in
|
|
715
|
+
// the details, and its value follows when it is part of a larger
|
|
716
|
+
// formula.
|
|
717
|
+
const rollup = scheduleDetailOf(document, node.reference);
|
|
718
|
+
out.push({
|
|
719
|
+
kind: 'term',
|
|
720
|
+
label: nodeLabel(node, ctx),
|
|
721
|
+
value: rollup
|
|
722
|
+
? describeRollup(rollup, ctx)
|
|
723
|
+
: nodeValueText(node, ctx),
|
|
724
|
+
});
|
|
725
|
+
if (rollup && nested && node.value !== undefined) {
|
|
726
|
+
out.push({
|
|
727
|
+
kind: 'result',
|
|
728
|
+
text: formatTypedValue(node.value, null, ctx),
|
|
729
|
+
});
|
|
730
|
+
}
|
|
731
|
+
return;
|
|
732
|
+
}
|
|
733
|
+
case 'table': {
|
|
734
|
+
const rows = Math.max(0, ...node.children.map((child) => byId.get(child)?.recordIds?.length ?? 0));
|
|
735
|
+
out.push({
|
|
736
|
+
kind: 'term',
|
|
737
|
+
label: tableLabel(node.reference),
|
|
738
|
+
value: ctx.translate(`${K}.recordCount`, { count: rows }),
|
|
739
|
+
});
|
|
740
|
+
return;
|
|
741
|
+
}
|
|
742
|
+
case 'binary': {
|
|
743
|
+
if (notEvaluated) {
|
|
744
|
+
out.push({ kind: 'muted', text: ctx.translate(`${K}.notEvaluated`) });
|
|
745
|
+
return;
|
|
746
|
+
}
|
|
747
|
+
if (nested)
|
|
748
|
+
out.push({ kind: 'text', text: '(' });
|
|
749
|
+
render(node.children[0], true);
|
|
750
|
+
out.push({
|
|
751
|
+
kind: 'text',
|
|
752
|
+
text: OPERATORS[node.operation ?? ''] ?? node.operation ?? '?',
|
|
753
|
+
});
|
|
754
|
+
render(node.children[1], true);
|
|
755
|
+
if (nested)
|
|
756
|
+
out.push({ kind: 'text', text: ')' });
|
|
757
|
+
return;
|
|
758
|
+
}
|
|
759
|
+
case 'unary':
|
|
760
|
+
out.push({
|
|
761
|
+
kind: 'text',
|
|
762
|
+
text: node.operation === 'Negate'
|
|
763
|
+
? '−'
|
|
764
|
+
: node.operation === 'Not'
|
|
765
|
+
? 'NOT'
|
|
766
|
+
: '+',
|
|
767
|
+
});
|
|
768
|
+
render(node.children[0], true);
|
|
769
|
+
return;
|
|
770
|
+
case 'function':
|
|
771
|
+
case 'conditional':
|
|
772
|
+
case 'array': {
|
|
773
|
+
if (notEvaluated) {
|
|
774
|
+
out.push({ kind: 'muted', text: ctx.translate(`${K}.notEvaluated`) });
|
|
775
|
+
return;
|
|
776
|
+
}
|
|
777
|
+
const array = node.kind === 'array';
|
|
778
|
+
out.push({
|
|
779
|
+
kind: 'text',
|
|
780
|
+
text: array ? '[' : `${node.operation ?? node.kind}(`,
|
|
781
|
+
});
|
|
782
|
+
node.children.forEach((child, index) => {
|
|
783
|
+
if (index > 0)
|
|
784
|
+
out.push({ kind: 'text', text: ',' });
|
|
785
|
+
const name = node.argumentNames?.[index];
|
|
786
|
+
if (name)
|
|
787
|
+
out.push({ kind: 'text', text: `${name}:` });
|
|
788
|
+
render(child, false);
|
|
789
|
+
});
|
|
790
|
+
out.push({ kind: 'text', text: array ? ']' : ')' });
|
|
791
|
+
if (nested && !array && node.value !== undefined) {
|
|
792
|
+
out.push({
|
|
793
|
+
kind: 'result',
|
|
794
|
+
text: formatTypedValue(node.value, null, ctx),
|
|
795
|
+
});
|
|
796
|
+
}
|
|
797
|
+
return;
|
|
798
|
+
}
|
|
799
|
+
default:
|
|
800
|
+
// A kind this version does not know: shown as labelled data.
|
|
801
|
+
out.push({
|
|
802
|
+
kind: 'term',
|
|
803
|
+
label: node.expression || node.kind,
|
|
804
|
+
value: formatTypedValue(node.value, null, ctx),
|
|
805
|
+
});
|
|
806
|
+
}
|
|
807
|
+
};
|
|
808
|
+
render(document.rootNodeId, false);
|
|
809
|
+
return out;
|
|
810
|
+
}
|
|
811
|
+
/** Captured JSON (native method facts) as labelled fields, lists or tables. */
|
|
812
|
+
function toExplanationData(value, ctx, depth = 0) {
|
|
813
|
+
if (value === null || value === undefined || typeof value !== 'object') {
|
|
814
|
+
return { kind: 'text', text: formatTypedValue(value, null, ctx) };
|
|
815
|
+
}
|
|
816
|
+
if (depth >= DATA_DEPTH) {
|
|
817
|
+
return { kind: 'text', text: JSON.stringify(value) };
|
|
818
|
+
}
|
|
819
|
+
if (Array.isArray(value)) {
|
|
820
|
+
if (value.length === 0) {
|
|
821
|
+
return { kind: 'text', text: '—' };
|
|
822
|
+
}
|
|
823
|
+
if (value.every((item) => item === null || typeof item !== 'object')) {
|
|
824
|
+
return {
|
|
825
|
+
kind: 'list',
|
|
826
|
+
items: value.map((item) => formatTypedValue(item, null, ctx)),
|
|
827
|
+
};
|
|
828
|
+
}
|
|
829
|
+
if (value.every((item) => isPlainObject(item))) {
|
|
830
|
+
const records = value;
|
|
831
|
+
const columns = [...new Set(records.flatMap((row) => Object.keys(row)))];
|
|
832
|
+
return {
|
|
833
|
+
kind: 'table',
|
|
834
|
+
columns: columns.map(humanizeKey$1),
|
|
835
|
+
rows: records.map((row) => columns.map((column) => formatTypedValue(row[column], null, ctx))),
|
|
836
|
+
};
|
|
837
|
+
}
|
|
838
|
+
return {
|
|
839
|
+
kind: 'list',
|
|
840
|
+
items: value.map((item) => formatTypedValue(item, null, ctx)),
|
|
841
|
+
};
|
|
842
|
+
}
|
|
843
|
+
return {
|
|
844
|
+
kind: 'fields',
|
|
845
|
+
fields: Object.entries(value).map(([key, item]) => ({
|
|
846
|
+
label: humanizeKey$1(key),
|
|
847
|
+
data: toExplanationData(item, ctx, depth + 1),
|
|
848
|
+
})),
|
|
849
|
+
};
|
|
850
|
+
}
|
|
851
|
+
function isPlainObject(value) {
|
|
852
|
+
return !!value && typeof value === 'object' && !Array.isArray(value);
|
|
853
|
+
}
|
|
854
|
+
/** Everything the expandable details show, read from the document as is. */
|
|
855
|
+
function buildExplanationDetails(document, ctx, statusNames = {}) {
|
|
856
|
+
const equation = isEquationDocument(document);
|
|
857
|
+
const nodes = document.nodes ?? [];
|
|
858
|
+
const byId = new Map(nodes.map((node) => [node.id, node]));
|
|
859
|
+
const inputs = [];
|
|
860
|
+
const functions = [];
|
|
861
|
+
const facts = [];
|
|
862
|
+
const codeBlocks = [];
|
|
863
|
+
const seenInputs = new Set();
|
|
864
|
+
// A schedule rollup's own columns (`__central_progress`, …) are internal:
|
|
865
|
+
// the schedule section shows them as contributors, or else one table does.
|
|
866
|
+
const rollupColumns = new Set();
|
|
867
|
+
for (const node of nodes) {
|
|
868
|
+
if (node.kind !== 'semantic' || !node.children.length)
|
|
869
|
+
continue;
|
|
870
|
+
node.children.forEach((child) => rollupColumns.add(child));
|
|
871
|
+
if (!scheduleDetailOf(document, node.reference)) {
|
|
872
|
+
facts.push({
|
|
873
|
+
label: nodeLabel(node, ctx),
|
|
874
|
+
data: rollupTable(node, byId, ctx),
|
|
875
|
+
});
|
|
876
|
+
}
|
|
877
|
+
}
|
|
878
|
+
for (const node of nodes) {
|
|
879
|
+
if ((node.id === document.rootNodeId && !equation) ||
|
|
880
|
+
rollupColumns.has(node.id)) {
|
|
881
|
+
continue;
|
|
882
|
+
}
|
|
883
|
+
switch (node.kind) {
|
|
884
|
+
case 'input':
|
|
885
|
+
case 'semantic': {
|
|
886
|
+
if (!equation) {
|
|
887
|
+
// A native method's observed facts: a label and any JSON.
|
|
888
|
+
facts.push({
|
|
889
|
+
label: node.expression || node.kind,
|
|
890
|
+
data: toExplanationData(node.value, ctx),
|
|
891
|
+
});
|
|
892
|
+
break;
|
|
893
|
+
}
|
|
894
|
+
// A rollup the schedule section explains is not repeated here.
|
|
895
|
+
if (node.kind === 'semantic' &&
|
|
896
|
+
scheduleDetailOf(document, node.reference)) {
|
|
897
|
+
break;
|
|
898
|
+
}
|
|
899
|
+
const id = `${node.reference}|${(node.recordIds ?? []).join(',')}`;
|
|
900
|
+
if (seenInputs.has(id))
|
|
901
|
+
break;
|
|
902
|
+
seenInputs.add(id);
|
|
903
|
+
inputs.push(toInputView(node, ctx));
|
|
904
|
+
break;
|
|
905
|
+
}
|
|
906
|
+
case 'function':
|
|
907
|
+
case 'conditional':
|
|
908
|
+
if (document.provider === 'codeBuilder')
|
|
909
|
+
break;
|
|
910
|
+
functions.push({
|
|
911
|
+
name: node.operation ?? node.kind,
|
|
912
|
+
result: node.state === 'notEvaluated'
|
|
913
|
+
? ctx.translate(`${K}.notEvaluated`)
|
|
914
|
+
: formatTypedValue(node.value, null, ctx),
|
|
915
|
+
notEvaluated: node.state === 'notEvaluated',
|
|
916
|
+
});
|
|
917
|
+
break;
|
|
918
|
+
case 'codeBlock': {
|
|
919
|
+
const raw = byId.get(node.children[0]);
|
|
920
|
+
const value = formatTypedValue(node.value, null, ctx);
|
|
921
|
+
const rawText = raw && raw.value !== undefined
|
|
922
|
+
? formatTypedValue(raw.value, null, ctx)
|
|
923
|
+
: null;
|
|
924
|
+
codeBlocks.push({
|
|
925
|
+
type: CODE_BLOCK_TYPES.has(node.operation ?? '')
|
|
926
|
+
? ctx.translate(`${K}.codeBlock.${node.operation}`)
|
|
927
|
+
: (node.operation ?? node.kind),
|
|
928
|
+
value,
|
|
929
|
+
raw: rawText !== null && rawText !== value ? rawText : null,
|
|
930
|
+
settings: parseSettings(node.expression, ctx),
|
|
931
|
+
});
|
|
932
|
+
break;
|
|
933
|
+
}
|
|
934
|
+
case 'literal':
|
|
935
|
+
case 'binary':
|
|
936
|
+
case 'unary':
|
|
937
|
+
case 'array':
|
|
938
|
+
case 'table':
|
|
939
|
+
case 'selection':
|
|
940
|
+
case 'method':
|
|
941
|
+
break;
|
|
942
|
+
default:
|
|
943
|
+
facts.push({
|
|
944
|
+
label: node.expression || node.kind,
|
|
945
|
+
data: toExplanationData(node.value, ctx),
|
|
946
|
+
});
|
|
947
|
+
}
|
|
948
|
+
}
|
|
949
|
+
// A status, a generated code and a native method carry a description or
|
|
950
|
+
// their configuration in `formula`; only a formula is shown as one.
|
|
951
|
+
const showFormula = equation && document.provider === 'formula';
|
|
952
|
+
return {
|
|
953
|
+
formula: showFormula ? document.formula?.trim() || null : null,
|
|
954
|
+
// A formula that is only a schedule rollup has its substitution there.
|
|
955
|
+
formulaWithValues: showFormula &&
|
|
956
|
+
!(document.schedule ?? []).some((detail) => detail.formulaWithValues === document.formulaWithValues)
|
|
957
|
+
? document.formulaWithValues
|
|
958
|
+
: null,
|
|
959
|
+
inputs,
|
|
960
|
+
functions,
|
|
961
|
+
facts,
|
|
962
|
+
codeBlocks,
|
|
963
|
+
statusRules: (document.statusRules ?? [])
|
|
964
|
+
.slice()
|
|
965
|
+
.sort((a, b) => a.order - b.order)
|
|
966
|
+
.map((rule) => toStatusRuleView(rule, ctx, statusNames)),
|
|
967
|
+
schedule: (document.schedule ?? []).map((detail) => toScheduleView(detail, ctx)),
|
|
968
|
+
sources: mergeSources(document),
|
|
969
|
+
};
|
|
970
|
+
}
|
|
971
|
+
/** Records per source table; one table read in several contexts is one row. */
|
|
972
|
+
function mergeSources(document) {
|
|
973
|
+
const byLabel = new Map();
|
|
974
|
+
for (const source of document.sources ?? []) {
|
|
975
|
+
if (!source.recordIds?.length)
|
|
976
|
+
continue;
|
|
977
|
+
const label = tableLabel(source.tablePath);
|
|
978
|
+
const ids = byLabel.get(label) ?? [];
|
|
979
|
+
for (const id of source.recordIds)
|
|
980
|
+
if (!ids.includes(id))
|
|
981
|
+
ids.push(id);
|
|
982
|
+
byLabel.set(label, ids);
|
|
983
|
+
}
|
|
984
|
+
return [...byLabel].map(([label, ids]) => ({
|
|
985
|
+
label,
|
|
986
|
+
count: ids.length,
|
|
987
|
+
ids: listIds(ids),
|
|
988
|
+
}));
|
|
989
|
+
}
|
|
990
|
+
/** A rollup's columns side by side, one row per record. */
|
|
991
|
+
function rollupTable(node, byId, ctx) {
|
|
992
|
+
const columns = node.children
|
|
993
|
+
.map((id) => byId.get(id))
|
|
994
|
+
.filter((column) => !!column);
|
|
995
|
+
const recordIds = columns.find((column) => column.recordIds?.length)?.recordIds;
|
|
996
|
+
if (!recordIds?.length) {
|
|
997
|
+
return { kind: 'text', text: nodeValueText(node, ctx) };
|
|
998
|
+
}
|
|
999
|
+
return {
|
|
1000
|
+
kind: 'table',
|
|
1001
|
+
columns: ['#', ...columns.map((column) => columnLabel(column.reference))],
|
|
1002
|
+
rows: recordIds.map((recordId, index) => [
|
|
1003
|
+
String(recordId),
|
|
1004
|
+
...columns.map((column) => formatTypedValue(Array.isArray(column.value) ? column.value[index] : null, null, ctx)),
|
|
1005
|
+
]),
|
|
1006
|
+
};
|
|
1007
|
+
}
|
|
1008
|
+
/** Whether the details have anything to expand. */
|
|
1009
|
+
function hasExplanationDetails(view) {
|
|
1010
|
+
return (!!view.formula ||
|
|
1011
|
+
view.inputs.length > 0 ||
|
|
1012
|
+
view.functions.length > 0 ||
|
|
1013
|
+
view.facts.length > 0 ||
|
|
1014
|
+
view.codeBlocks.length > 0 ||
|
|
1015
|
+
view.statusRules.length > 0 ||
|
|
1016
|
+
view.schedule.length > 0 ||
|
|
1017
|
+
view.sources.length > 0);
|
|
1018
|
+
}
|
|
1019
|
+
/** A generated code as its parts: `PRJ + - + 2026 + - + 0042`. */
|
|
1020
|
+
function buildCodeSegments(document, ctx) {
|
|
1021
|
+
const blocks = (document.nodes ?? []).filter((node) => node.kind === 'codeBlock');
|
|
1022
|
+
return blocks.flatMap((node, index) => [
|
|
1023
|
+
...(index > 0 ? [{ kind: 'text', text: '+' }] : []),
|
|
1024
|
+
{
|
|
1025
|
+
kind: 'value',
|
|
1026
|
+
text: JSON.stringify(formatTypedValue(node.value, null, ctx)),
|
|
1027
|
+
},
|
|
1028
|
+
]);
|
|
1029
|
+
}
|
|
1030
|
+
function toInputView(node, ctx) {
|
|
1031
|
+
const viewType = node.display?.viewType;
|
|
1032
|
+
const values = Array.isArray(node.value) ? node.value : null;
|
|
1033
|
+
return {
|
|
1034
|
+
label: nodeLabel(node, ctx),
|
|
1035
|
+
value: values
|
|
1036
|
+
? ctx.translate(`${K}.valueCount`, { count: values.length })
|
|
1037
|
+
: nodeValueText(node, ctx),
|
|
1038
|
+
rows: values
|
|
1039
|
+
? values.map((value, index) => ({
|
|
1040
|
+
recordId: node.recordIds?.[index] ?? null,
|
|
1041
|
+
value: formatTypedValue(value, viewType, ctx),
|
|
1042
|
+
}))
|
|
1043
|
+
: [],
|
|
1044
|
+
};
|
|
1045
|
+
}
|
|
1046
|
+
function parseSettings(expression, ctx) {
|
|
1047
|
+
try {
|
|
1048
|
+
const parsed = JSON.parse(expression);
|
|
1049
|
+
if (!isPlainObject(parsed)) {
|
|
1050
|
+
return null;
|
|
1051
|
+
}
|
|
1052
|
+
// The block type is already the part's title.
|
|
1053
|
+
const settings = Object.fromEntries(Object.entries(parsed).filter(([key]) => key.toLowerCase() !== 'blocktype'));
|
|
1054
|
+
return Object.keys(settings).length
|
|
1055
|
+
? toExplanationData(settings, ctx)
|
|
1056
|
+
: null;
|
|
1057
|
+
}
|
|
1058
|
+
catch {
|
|
1059
|
+
return null;
|
|
1060
|
+
}
|
|
1061
|
+
}
|
|
1062
|
+
/** The status a rule selects, by the name the host knows or its key. */
|
|
1063
|
+
function statusName(key, statusNames) {
|
|
1064
|
+
return statusNames[key] || key;
|
|
1065
|
+
}
|
|
1066
|
+
function toStatusRuleView(rule, ctx, statusNames) {
|
|
1067
|
+
const result = rule.condition?.result;
|
|
1068
|
+
const verdict = rule.selected
|
|
1069
|
+
? 'selected'
|
|
1070
|
+
: rule.state === 'failed'
|
|
1071
|
+
? 'failed'
|
|
1072
|
+
: rule.state === 'notEvaluated'
|
|
1073
|
+
? 'notEvaluated'
|
|
1074
|
+
: result === true
|
|
1075
|
+
? 'matched'
|
|
1076
|
+
: result === false
|
|
1077
|
+
? 'notMatched'
|
|
1078
|
+
: 'checked';
|
|
1079
|
+
return {
|
|
1080
|
+
key: rule.key,
|
|
1081
|
+
name: statusName(rule.key, statusNames),
|
|
1082
|
+
order: rule.order,
|
|
1083
|
+
verdict,
|
|
1084
|
+
segments: rule.condition
|
|
1085
|
+
? buildExplanationSegments(rule.condition, ctx)
|
|
1086
|
+
: null,
|
|
1087
|
+
};
|
|
1088
|
+
}
|
|
1089
|
+
/** The rule that chose the status, if one did. */
|
|
1090
|
+
function selectedStatusRule(document) {
|
|
1091
|
+
return document.statusRules?.find((rule) => rule.selected) ?? null;
|
|
1092
|
+
}
|
|
1093
|
+
function toScheduleView(detail, ctx) {
|
|
1094
|
+
const t = (key, params) => ctx.translate(`${K}.schedule.${key}`, params);
|
|
1095
|
+
const known = (set, prefix, code) => set.has(code) ? t(`${prefix}.${code}`) : code;
|
|
1096
|
+
const percent = (value) => `${formatExplanationNumber(value)}%`;
|
|
1097
|
+
const facts = [
|
|
1098
|
+
t('asOf', { time: ctx.formatDate(detail.asOfUtc, 'dateTime') }),
|
|
1099
|
+
detail.weightMode === 'workingDays' ||
|
|
1100
|
+
detail.weightMode === 'explicitWeight'
|
|
1101
|
+
? t(`weightMode.${detail.weightMode}`)
|
|
1102
|
+
: detail.weightMode,
|
|
1103
|
+
['weightedAverage', 'arithmeticMean', 'empty'].includes(detail.aggregation)
|
|
1104
|
+
? t(`aggregation.${detail.aggregation}`)
|
|
1105
|
+
: detail.aggregation,
|
|
1106
|
+
t('rounding', { digits: detail.roundingDigits }),
|
|
1107
|
+
t(detail.includeMilestones ? 'milestonesIncluded' : 'milestonesExcluded'),
|
|
1108
|
+
...(detail.excludeSameDayMilestones
|
|
1109
|
+
? [t('sameDayMilestonesExcluded')]
|
|
1110
|
+
: []),
|
|
1111
|
+
...(detail.leafOnly ? [t('leafOnly')] : []),
|
|
1112
|
+
...(detail.excludedRowCount > 0
|
|
1113
|
+
? [t('excludedRows', { count: detail.excludedRowCount })]
|
|
1114
|
+
: []),
|
|
1115
|
+
].filter((fact) => !!fact);
|
|
1116
|
+
const contributors = detail.contributors ?? [];
|
|
1117
|
+
const planned = contributors
|
|
1118
|
+
.filter((row) => !!row.plannedCalculation)
|
|
1119
|
+
.map((row) => {
|
|
1120
|
+
const plan = row.plannedCalculation;
|
|
1121
|
+
const start = plan.plannedStart ?? row.plannedStart;
|
|
1122
|
+
const finish = plan.plannedFinish ?? row.plannedFinish;
|
|
1123
|
+
return {
|
|
1124
|
+
recordId: row.recordId,
|
|
1125
|
+
rule: known(PLANNED_RULES, 'plannedRule', plan.rule),
|
|
1126
|
+
minutes: plan.elapsedWorkingMinutes !== null &&
|
|
1127
|
+
plan.totalWorkingMinutes !== null
|
|
1128
|
+
? t('workingMinutes', {
|
|
1129
|
+
elapsed: formatExplanationNumber(plan.elapsedWorkingMinutes),
|
|
1130
|
+
total: formatExplanationNumber(plan.totalWorkingMinutes),
|
|
1131
|
+
})
|
|
1132
|
+
: null,
|
|
1133
|
+
dates: start || finish
|
|
1134
|
+
? `${start ? ctx.formatDate(start, 'date') : '—'} → ${finish ? ctx.formatDate(finish, 'date') : '—'}`
|
|
1135
|
+
: null,
|
|
1136
|
+
};
|
|
1137
|
+
});
|
|
1138
|
+
const calendarSource = contributors.find((row) => !!row.plannedCalculation)?.plannedCalculation;
|
|
1139
|
+
return {
|
|
1140
|
+
title: semanticLabel(detail.reference, ctx) ??
|
|
1141
|
+
referenceColumn(detail.reference) ??
|
|
1142
|
+
detail.reference,
|
|
1143
|
+
result: percent(detail.result),
|
|
1144
|
+
formulaWithValues: detail.formulaWithValues,
|
|
1145
|
+
facts,
|
|
1146
|
+
notes: (detail.notes ?? []).map((note) => known(SCHEDULE_NOTES, 'note', note)),
|
|
1147
|
+
contributors: contributors.map((row) => ({
|
|
1148
|
+
recordId: row.recordId,
|
|
1149
|
+
progress: percent(row.progress),
|
|
1150
|
+
weight: formatExplanationNumber(row.weight),
|
|
1151
|
+
included: row.includedInAggregation,
|
|
1152
|
+
inputMissing: row.inputMissing,
|
|
1153
|
+
})),
|
|
1154
|
+
planned,
|
|
1155
|
+
calendar: calendarSource
|
|
1156
|
+
? {
|
|
1157
|
+
timeZone: calendarSource.timeZoneId,
|
|
1158
|
+
source: calendarSource.calendarSource,
|
|
1159
|
+
workingHours: `${clock(calendarSource.workDayStartMinute)}–${clock(calendarSource.workDayEndMinute)}`,
|
|
1160
|
+
workingDays: (calendarSource.workingDays ?? [])
|
|
1161
|
+
.map((day) => weekdayName(day, ctx.lang))
|
|
1162
|
+
.join(', '),
|
|
1163
|
+
holidays: (calendarSource.holidays ?? [])
|
|
1164
|
+
.map((day) => ctx.formatDate(day, 'date') || day)
|
|
1165
|
+
.join(', '),
|
|
1166
|
+
}
|
|
1167
|
+
: null,
|
|
1168
|
+
};
|
|
1169
|
+
}
|
|
1170
|
+
/** Minutes after midnight as `08:30`. */
|
|
1171
|
+
function clock(minutes) {
|
|
1172
|
+
const h = Math.floor(minutes / 60);
|
|
1173
|
+
const m = minutes % 60;
|
|
1174
|
+
return `${String(h).padStart(2, '0')}:${String(m).padStart(2, '0')}`;
|
|
1175
|
+
}
|
|
1176
|
+
/** Sunday = 0, named in the active language. */
|
|
1177
|
+
function weekdayName(day, lang) {
|
|
1178
|
+
// 2023-01-01 was a Sunday.
|
|
1179
|
+
const date = new Date(Date.UTC(2023, 0, 1 + day));
|
|
1180
|
+
try {
|
|
1181
|
+
return new Intl.DateTimeFormat(lang, {
|
|
1182
|
+
weekday: 'short',
|
|
1183
|
+
timeZone: 'UTC',
|
|
1184
|
+
}).format(date);
|
|
1185
|
+
}
|
|
1186
|
+
catch {
|
|
1187
|
+
return String(day);
|
|
1188
|
+
}
|
|
1189
|
+
}
|
|
1190
|
+
function listIds(ids) {
|
|
1191
|
+
const shown = ids.slice(0, LISTED_IDS).map((id) => `#${id}`);
|
|
1192
|
+
return ids.length > LISTED_IDS
|
|
1193
|
+
? `${shown.join(', ')} +${ids.length - LISTED_IDS}`
|
|
1194
|
+
: shown.join(', ');
|
|
1195
|
+
}
|
|
1196
|
+
|
|
1197
|
+
/** Pieces that hug their neighbour: `(a`, `a)`, `a,`, `f(a`. */
|
|
1198
|
+
const OPENERS = /[([]$/;
|
|
1199
|
+
const CLOSERS = /^[)\],]$/;
|
|
1200
|
+
/**
|
|
1201
|
+
* A readable equation: `Budget (12,000 SAR) − Spent (15,000 SAR) = −3,000 SAR`.
|
|
1202
|
+
* A left-to-right block in every language, like a formula in a spreadsheet:
|
|
1203
|
+
* inside a right-to-left page an inline left-to-right run breaks across lines
|
|
1204
|
+
* in the wrong order. Each term is isolated and kept whole, so an Arabic name
|
|
1205
|
+
* reads with its own value. Every piece is interpolated as text.
|
|
1206
|
+
*/
|
|
1207
|
+
class CalculationExplanationEquation {
|
|
1208
|
+
segments = input.required(...(ngDevMode ? [{ debugName: "segments" }] : /* istanbul ignore next */ []));
|
|
1209
|
+
/** Shown after the equation, behind `resultOperator`. */
|
|
1210
|
+
result = input(null, ...(ngDevMode ? [{ debugName: "result" }] : /* istanbul ignore next */ []));
|
|
1211
|
+
resultOperator = input('=', ...(ngDevMode ? [{ debugName: "resultOperator" }] : /* istanbul ignore next */ []));
|
|
1212
|
+
pieces = computed(() => {
|
|
1213
|
+
const segments = this.segments();
|
|
1214
|
+
return segments.map((segment, index) => {
|
|
1215
|
+
const next = segments[index + 1];
|
|
1216
|
+
const text = segment.kind === 'text' ? segment.text : '';
|
|
1217
|
+
const nextText = next?.kind === 'text' ? next.text : '';
|
|
1218
|
+
return {
|
|
1219
|
+
segment,
|
|
1220
|
+
space: !!next && !OPENERS.test(text) && !CLOSERS.test(nextText),
|
|
1221
|
+
};
|
|
1222
|
+
});
|
|
1223
|
+
}, ...(ngDevMode ? [{ debugName: "pieces" }] : /* istanbul ignore next */ []));
|
|
1224
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: CalculationExplanationEquation, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1225
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.8", type: CalculationExplanationEquation, isStandalone: true, selector: "mt-calculation-explanation-equation", inputs: { segments: { classPropertyName: "segments", publicName: "segments", isSignal: true, isRequired: true, transformFunction: null }, result: { classPropertyName: "result", publicName: "result", isSignal: true, isRequired: false, transformFunction: null }, resultOperator: { classPropertyName: "resultOperator", publicName: "resultOperator", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: `
|
|
1226
|
+
<div dir="ltr" class="text-left break-words">
|
|
1227
|
+
@for (piece of pieces(); track $index) {
|
|
1228
|
+
@switch (piece.segment.kind) {
|
|
1229
|
+
@case ('term') {
|
|
1230
|
+
<bdi class="inline-block max-w-full"
|
|
1231
|
+
><span class="font-medium text-surface-900 dark:text-surface-0">{{
|
|
1232
|
+
piece.segment.label
|
|
1233
|
+
}}</span>
|
|
1234
|
+
@if (piece.segment.value !== null) {
|
|
1235
|
+
<!-- The leading space lives inside the text node: Angular
|
|
1236
|
+
drops whitespace-only nodes between elements. -->
|
|
1237
|
+
<span class="text-surface-500 dark:text-surface-400">
|
|
1238
|
+
({{ piece.segment.value }})</span
|
|
1239
|
+
>
|
|
1240
|
+
}
|
|
1241
|
+
</bdi>
|
|
1242
|
+
}
|
|
1243
|
+
@case ('value') {
|
|
1244
|
+
<bdi class="font-mono text-surface-800 dark:text-surface-100">{{
|
|
1245
|
+
piece.segment.text
|
|
1246
|
+
}}</bdi>
|
|
1247
|
+
}
|
|
1248
|
+
@case ('result') {
|
|
1249
|
+
<bdi class="text-surface-500 dark:text-surface-400"
|
|
1250
|
+
>→ {{ piece.segment.text }}</bdi
|
|
1251
|
+
>
|
|
1252
|
+
}
|
|
1253
|
+
@case ('muted') {
|
|
1254
|
+
<span class="text-surface-400 italic">{{
|
|
1255
|
+
piece.segment.text
|
|
1256
|
+
}}</span>
|
|
1257
|
+
}
|
|
1258
|
+
@default {
|
|
1259
|
+
<span class="text-surface-500 dark:text-surface-400">{{
|
|
1260
|
+
piece.segment.text
|
|
1261
|
+
}}</span>
|
|
1262
|
+
}
|
|
1263
|
+
}
|
|
1264
|
+
@if (piece.space) {
|
|
1265
|
+
{{ ' ' }}
|
|
1266
|
+
}
|
|
1267
|
+
}
|
|
1268
|
+
@if (result(); as value) {
|
|
1269
|
+
<span class="text-surface-400"> {{ resultOperator() }} </span>
|
|
1270
|
+
<bdi class="font-semibold text-surface-900 dark:text-surface-0">{{
|
|
1271
|
+
value
|
|
1272
|
+
}}</bdi>
|
|
1273
|
+
}
|
|
1274
|
+
</div>
|
|
1275
|
+
`, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
1276
|
+
}
|
|
1277
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: CalculationExplanationEquation, decorators: [{
|
|
1278
|
+
type: Component,
|
|
1279
|
+
args: [{
|
|
1280
|
+
selector: 'mt-calculation-explanation-equation',
|
|
1281
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
1282
|
+
template: `
|
|
1283
|
+
<div dir="ltr" class="text-left break-words">
|
|
1284
|
+
@for (piece of pieces(); track $index) {
|
|
1285
|
+
@switch (piece.segment.kind) {
|
|
1286
|
+
@case ('term') {
|
|
1287
|
+
<bdi class="inline-block max-w-full"
|
|
1288
|
+
><span class="font-medium text-surface-900 dark:text-surface-0">{{
|
|
1289
|
+
piece.segment.label
|
|
1290
|
+
}}</span>
|
|
1291
|
+
@if (piece.segment.value !== null) {
|
|
1292
|
+
<!-- The leading space lives inside the text node: Angular
|
|
1293
|
+
drops whitespace-only nodes between elements. -->
|
|
1294
|
+
<span class="text-surface-500 dark:text-surface-400">
|
|
1295
|
+
({{ piece.segment.value }})</span
|
|
1296
|
+
>
|
|
1297
|
+
}
|
|
1298
|
+
</bdi>
|
|
1299
|
+
}
|
|
1300
|
+
@case ('value') {
|
|
1301
|
+
<bdi class="font-mono text-surface-800 dark:text-surface-100">{{
|
|
1302
|
+
piece.segment.text
|
|
1303
|
+
}}</bdi>
|
|
1304
|
+
}
|
|
1305
|
+
@case ('result') {
|
|
1306
|
+
<bdi class="text-surface-500 dark:text-surface-400"
|
|
1307
|
+
>→ {{ piece.segment.text }}</bdi
|
|
1308
|
+
>
|
|
1309
|
+
}
|
|
1310
|
+
@case ('muted') {
|
|
1311
|
+
<span class="text-surface-400 italic">{{
|
|
1312
|
+
piece.segment.text
|
|
1313
|
+
}}</span>
|
|
1314
|
+
}
|
|
1315
|
+
@default {
|
|
1316
|
+
<span class="text-surface-500 dark:text-surface-400">{{
|
|
1317
|
+
piece.segment.text
|
|
1318
|
+
}}</span>
|
|
1319
|
+
}
|
|
1320
|
+
}
|
|
1321
|
+
@if (piece.space) {
|
|
1322
|
+
{{ ' ' }}
|
|
1323
|
+
}
|
|
1324
|
+
}
|
|
1325
|
+
@if (result(); as value) {
|
|
1326
|
+
<span class="text-surface-400"> {{ resultOperator() }} </span>
|
|
1327
|
+
<bdi class="font-semibold text-surface-900 dark:text-surface-0">{{
|
|
1328
|
+
value
|
|
1329
|
+
}}</bdi>
|
|
1330
|
+
}
|
|
1331
|
+
</div>
|
|
1332
|
+
`,
|
|
1333
|
+
}]
|
|
1334
|
+
}], propDecorators: { segments: [{ type: i0.Input, args: [{ isSignal: true, alias: "segments", required: true }] }], result: [{ type: i0.Input, args: [{ isSignal: true, alias: "result", required: false }] }], resultOperator: [{ type: i0.Input, args: [{ isSignal: true, alias: "resultOperator", required: false }] }] } });
|
|
1335
|
+
|
|
1336
|
+
/**
|
|
1337
|
+
* The expandable part of an explanation: the inputs with the rows they came
|
|
1338
|
+
* from, function results, status rules, schedule rollups, generated-code
|
|
1339
|
+
* parts and contributing records. Everything is the backend's captured data,
|
|
1340
|
+
* shown as text; nothing is recalculated here.
|
|
1341
|
+
*/
|
|
1342
|
+
class CalculationExplanationDetails {
|
|
1343
|
+
details = input.required(...(ngDevMode ? [{ debugName: "details" }] : /* istanbul ignore next */ []));
|
|
1344
|
+
prefix = CALCULATION_EXPLANATION_KEYS;
|
|
1345
|
+
scheduleKeys = `${CALCULATION_EXPLANATION_KEYS}.schedule`;
|
|
1346
|
+
verdictClass = {
|
|
1347
|
+
selected: 'bg-primary-100 text-primary-700',
|
|
1348
|
+
matched: 'bg-green-50 text-green-700',
|
|
1349
|
+
notMatched: 'bg-surface-100 text-surface-600',
|
|
1350
|
+
checked: 'bg-surface-100 text-surface-600',
|
|
1351
|
+
failed: 'bg-red-50 text-red-700',
|
|
1352
|
+
notEvaluated: 'bg-surface-100 text-surface-400',
|
|
1353
|
+
};
|
|
1354
|
+
hasMissingInput(rows) {
|
|
1355
|
+
return rows.some((row) => row.inputMissing);
|
|
1356
|
+
}
|
|
1357
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: CalculationExplanationDetails, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1358
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.8", type: CalculationExplanationDetails, isStandalone: true, selector: "mt-calculation-explanation-details", inputs: { details: { classPropertyName: "details", publicName: "details", isSignal: true, isRequired: true, transformFunction: null } }, ngImport: i0, template: `
|
|
1359
|
+
<ng-template #section let-title>
|
|
1360
|
+
<div class="text-xs font-semibold text-surface-500 dark:text-surface-400">
|
|
1361
|
+
{{ prefix + '.' + title | transloco }}
|
|
1362
|
+
</div>
|
|
1363
|
+
</ng-template>
|
|
1364
|
+
|
|
1365
|
+
<ng-template #dataTpl let-data>
|
|
1366
|
+
@switch (data.kind) {
|
|
1367
|
+
@case ('text') {
|
|
1368
|
+
<span class="break-words">{{ data.text }}</span>
|
|
1369
|
+
}
|
|
1370
|
+
@case ('list') {
|
|
1371
|
+
<span class="break-words">{{ data.items.join(', ') }}</span>
|
|
1372
|
+
}
|
|
1373
|
+
@case ('table') {
|
|
1374
|
+
<div class="overflow-x-auto">
|
|
1375
|
+
<table class="w-full text-xs">
|
|
1376
|
+
<thead>
|
|
1377
|
+
<tr class="text-surface-500 dark:text-surface-400">
|
|
1378
|
+
@for (column of data.columns; track $index) {
|
|
1379
|
+
<th class="px-1 py-0.5 text-start font-medium">
|
|
1380
|
+
{{ column }}
|
|
1381
|
+
</th>
|
|
1382
|
+
}
|
|
1383
|
+
</tr>
|
|
1384
|
+
</thead>
|
|
1385
|
+
<tbody>
|
|
1386
|
+
@for (row of data.rows; track $index) {
|
|
1387
|
+
<tr
|
|
1388
|
+
class="border-t border-surface-100 dark:border-surface-700"
|
|
1389
|
+
>
|
|
1390
|
+
@for (cell of row; track $index) {
|
|
1391
|
+
<td class="px-1 py-0.5 align-top break-words">
|
|
1392
|
+
{{ cell }}
|
|
1393
|
+
</td>
|
|
1394
|
+
}
|
|
1395
|
+
</tr>
|
|
1396
|
+
}
|
|
1397
|
+
</tbody>
|
|
1398
|
+
</table>
|
|
1399
|
+
</div>
|
|
1400
|
+
}
|
|
1401
|
+
@case ('fields') {
|
|
1402
|
+
<dl class="flex flex-col gap-1">
|
|
1403
|
+
@for (field of data.fields; track $index) {
|
|
1404
|
+
<div class="flex flex-col">
|
|
1405
|
+
<dt class="text-xs text-surface-500 dark:text-surface-400">
|
|
1406
|
+
{{ field.label }}
|
|
1407
|
+
</dt>
|
|
1408
|
+
<dd class="ms-0">
|
|
1409
|
+
<ng-container
|
|
1410
|
+
[ngTemplateOutlet]="dataTpl"
|
|
1411
|
+
[ngTemplateOutletContext]="{ $implicit: field.data }"
|
|
1412
|
+
/>
|
|
1413
|
+
</dd>
|
|
1414
|
+
</div>
|
|
1415
|
+
}
|
|
1416
|
+
</dl>
|
|
1417
|
+
}
|
|
1418
|
+
}
|
|
1419
|
+
</ng-template>
|
|
1420
|
+
|
|
1421
|
+
@let view = details();
|
|
1422
|
+
<div
|
|
1423
|
+
class="flex flex-col gap-3 text-xs text-surface-700 dark:text-surface-200"
|
|
1424
|
+
>
|
|
1425
|
+
@if (view.formula) {
|
|
1426
|
+
<div class="flex flex-col gap-1">
|
|
1427
|
+
<ng-container
|
|
1428
|
+
[ngTemplateOutlet]="section"
|
|
1429
|
+
[ngTemplateOutletContext]="{ $implicit: 'formula' }"
|
|
1430
|
+
/>
|
|
1431
|
+
<code
|
|
1432
|
+
dir="ltr"
|
|
1433
|
+
class="rounded-md border border-surface-200 bg-surface-50 px-2 py-1 font-mono break-all dark:border-surface-700 dark:bg-surface-800"
|
|
1434
|
+
>{{ view.formula }}</code
|
|
1435
|
+
>
|
|
1436
|
+
@if (view.formulaWithValues) {
|
|
1437
|
+
<span class="text-surface-500 dark:text-surface-400">
|
|
1438
|
+
{{ prefix + '.withValues' | transloco }}
|
|
1439
|
+
</span>
|
|
1440
|
+
<code
|
|
1441
|
+
dir="ltr"
|
|
1442
|
+
class="rounded-md border border-surface-200 bg-surface-50 px-2 py-1 font-mono break-all dark:border-surface-700 dark:bg-surface-800"
|
|
1443
|
+
>{{ view.formulaWithValues }}</code
|
|
1444
|
+
>
|
|
1445
|
+
}
|
|
1446
|
+
</div>
|
|
1447
|
+
}
|
|
1448
|
+
|
|
1449
|
+
@if (view.inputs.length) {
|
|
1450
|
+
<div class="flex flex-col gap-1">
|
|
1451
|
+
<ng-container
|
|
1452
|
+
[ngTemplateOutlet]="section"
|
|
1453
|
+
[ngTemplateOutletContext]="{ $implicit: 'inputs' }"
|
|
1454
|
+
/>
|
|
1455
|
+
<ul class="flex flex-col gap-1">
|
|
1456
|
+
@for (item of view.inputs; track $index) {
|
|
1457
|
+
<li class="flex flex-col gap-0.5">
|
|
1458
|
+
<div class="flex items-baseline justify-between gap-2">
|
|
1459
|
+
<bdi class="min-w-0 break-words">{{ item.label }}</bdi>
|
|
1460
|
+
<bdi class="shrink-0 font-medium tabular-nums">{{
|
|
1461
|
+
item.value
|
|
1462
|
+
}}</bdi>
|
|
1463
|
+
</div>
|
|
1464
|
+
@if (item.rows.length) {
|
|
1465
|
+
<ul
|
|
1466
|
+
class="flex flex-col gap-0.5 rounded-md border border-surface-200 px-2 py-1 dark:border-surface-700"
|
|
1467
|
+
>
|
|
1468
|
+
@for (row of item.rows; track $index) {
|
|
1469
|
+
<li class="flex justify-between gap-2 tabular-nums">
|
|
1470
|
+
@if (row.recordId !== null) {
|
|
1471
|
+
<span class="text-surface-500 dark:text-surface-400"
|
|
1472
|
+
>#{{ row.recordId }}</span
|
|
1473
|
+
>
|
|
1474
|
+
}
|
|
1475
|
+
<bdi>{{ row.value }}</bdi>
|
|
1476
|
+
</li>
|
|
1477
|
+
}
|
|
1478
|
+
</ul>
|
|
1479
|
+
}
|
|
1480
|
+
</li>
|
|
1481
|
+
}
|
|
1482
|
+
</ul>
|
|
1483
|
+
</div>
|
|
1484
|
+
}
|
|
1485
|
+
|
|
1486
|
+
@if (view.functions.length) {
|
|
1487
|
+
<div class="flex flex-col gap-1">
|
|
1488
|
+
<ng-container
|
|
1489
|
+
[ngTemplateOutlet]="section"
|
|
1490
|
+
[ngTemplateOutletContext]="{ $implicit: 'functions' }"
|
|
1491
|
+
/>
|
|
1492
|
+
<ul class="flex flex-col gap-0.5">
|
|
1493
|
+
@for (fn of view.functions; track $index) {
|
|
1494
|
+
<li class="flex items-baseline justify-between gap-2">
|
|
1495
|
+
<span dir="ltr" class="font-mono">{{ fn.name }}</span>
|
|
1496
|
+
<bdi
|
|
1497
|
+
class="shrink-0 tabular-nums"
|
|
1498
|
+
[class.italic]="fn.notEvaluated"
|
|
1499
|
+
[class.text-surface-400]="fn.notEvaluated"
|
|
1500
|
+
>{{ fn.result }}</bdi
|
|
1501
|
+
>
|
|
1502
|
+
</li>
|
|
1503
|
+
}
|
|
1504
|
+
</ul>
|
|
1505
|
+
</div>
|
|
1506
|
+
}
|
|
1507
|
+
|
|
1508
|
+
@if (view.statusRules.length) {
|
|
1509
|
+
<div class="flex flex-col gap-1">
|
|
1510
|
+
<ng-container
|
|
1511
|
+
[ngTemplateOutlet]="section"
|
|
1512
|
+
[ngTemplateOutletContext]="{ $implicit: 'statusRules' }"
|
|
1513
|
+
/>
|
|
1514
|
+
<p class="text-surface-500 dark:text-surface-400">
|
|
1515
|
+
{{ prefix + '.firstMatchWins' | transloco }}
|
|
1516
|
+
</p>
|
|
1517
|
+
<ol class="flex flex-col gap-1.5">
|
|
1518
|
+
@for (rule of view.statusRules; track rule.key) {
|
|
1519
|
+
<li
|
|
1520
|
+
class="flex flex-col gap-1 rounded-md border px-2 py-1.5"
|
|
1521
|
+
[class]="
|
|
1522
|
+
rule.verdict === 'selected'
|
|
1523
|
+
? 'border-primary-200 bg-primary-50 dark:border-primary-800 dark:bg-primary-950'
|
|
1524
|
+
: 'border-surface-200 dark:border-surface-700'
|
|
1525
|
+
"
|
|
1526
|
+
>
|
|
1527
|
+
<div class="flex items-center justify-between gap-2">
|
|
1528
|
+
<bdi class="font-medium">{{ rule.name }}</bdi>
|
|
1529
|
+
<span
|
|
1530
|
+
class="shrink-0 rounded-md px-1.5 py-0.5 text-[11px]"
|
|
1531
|
+
[class]="verdictClass[rule.verdict]"
|
|
1532
|
+
>
|
|
1533
|
+
{{ prefix + '.verdict.' + rule.verdict | transloco }}
|
|
1534
|
+
</span>
|
|
1535
|
+
</div>
|
|
1536
|
+
@if (rule.segments; as segments) {
|
|
1537
|
+
<mt-calculation-explanation-equation [segments]="segments" />
|
|
1538
|
+
}
|
|
1539
|
+
</li>
|
|
1540
|
+
}
|
|
1541
|
+
</ol>
|
|
1542
|
+
</div>
|
|
1543
|
+
}
|
|
1544
|
+
|
|
1545
|
+
@for (detail of view.schedule; track $index) {
|
|
1546
|
+
<div class="flex flex-col gap-1.5">
|
|
1547
|
+
<div class="flex items-baseline justify-between gap-2">
|
|
1548
|
+
<span
|
|
1549
|
+
class="text-xs font-semibold text-surface-500 dark:text-surface-400"
|
|
1550
|
+
>{{ detail.title }}</span
|
|
1551
|
+
>
|
|
1552
|
+
<span class="font-semibold tabular-nums">{{ detail.result }}</span>
|
|
1553
|
+
</div>
|
|
1554
|
+
<code
|
|
1555
|
+
dir="ltr"
|
|
1556
|
+
class="rounded-md border border-surface-200 bg-surface-50 px-2 py-1 font-mono break-all dark:border-surface-700 dark:bg-surface-800"
|
|
1557
|
+
>{{ detail.formulaWithValues }}</code
|
|
1558
|
+
>
|
|
1559
|
+
<div class="flex flex-wrap gap-1">
|
|
1560
|
+
@for (fact of detail.facts; track $index) {
|
|
1561
|
+
<span
|
|
1562
|
+
class="rounded-md bg-surface-100 px-1.5 py-0.5 dark:bg-surface-800"
|
|
1563
|
+
>{{ fact }}</span
|
|
1564
|
+
>
|
|
1565
|
+
}
|
|
1566
|
+
</div>
|
|
1567
|
+
@for (note of detail.notes; track $index) {
|
|
1568
|
+
<div
|
|
1569
|
+
class="rounded-md border border-amber-200 bg-amber-50 px-2 py-1 text-amber-700"
|
|
1570
|
+
>
|
|
1571
|
+
{{ note }}
|
|
1572
|
+
</div>
|
|
1573
|
+
}
|
|
1574
|
+
@if (detail.contributors.length) {
|
|
1575
|
+
<div class="overflow-x-auto">
|
|
1576
|
+
<table class="w-full tabular-nums">
|
|
1577
|
+
<thead>
|
|
1578
|
+
<tr class="text-surface-500 dark:text-surface-400">
|
|
1579
|
+
<th class="px-1 py-0.5 text-start font-medium">
|
|
1580
|
+
{{ scheduleKeys + '.item' | transloco }}
|
|
1581
|
+
</th>
|
|
1582
|
+
<th class="px-1 py-0.5 text-end font-medium">
|
|
1583
|
+
{{ scheduleKeys + '.progress' | transloco }}
|
|
1584
|
+
</th>
|
|
1585
|
+
<th class="px-1 py-0.5 text-end font-medium">
|
|
1586
|
+
{{ scheduleKeys + '.weight' | transloco }}
|
|
1587
|
+
</th>
|
|
1588
|
+
<th class="px-1 py-0.5 text-end font-medium">
|
|
1589
|
+
{{ scheduleKeys + '.included' | transloco }}
|
|
1590
|
+
</th>
|
|
1591
|
+
</tr>
|
|
1592
|
+
</thead>
|
|
1593
|
+
<tbody>
|
|
1594
|
+
@for (row of detail.contributors; track row.recordId) {
|
|
1595
|
+
<tr
|
|
1596
|
+
class="border-t border-surface-100 dark:border-surface-700"
|
|
1597
|
+
[class.text-surface-400]="!row.included"
|
|
1598
|
+
>
|
|
1599
|
+
<td class="px-1 py-0.5">#{{ row.recordId }}</td>
|
|
1600
|
+
<td
|
|
1601
|
+
class="px-1 py-0.5 text-end"
|
|
1602
|
+
[class.italic]="row.inputMissing"
|
|
1603
|
+
[attr.title]="
|
|
1604
|
+
row.inputMissing
|
|
1605
|
+
? (scheduleKeys + '.inputMissing' | transloco)
|
|
1606
|
+
: null
|
|
1607
|
+
"
|
|
1608
|
+
>
|
|
1609
|
+
{{ row.progress }}{{ row.inputMissing ? ' *' : '' }}
|
|
1610
|
+
</td>
|
|
1611
|
+
<td class="px-1 py-0.5 text-end">{{ row.weight }}</td>
|
|
1612
|
+
<td class="px-1 py-0.5 text-end">
|
|
1613
|
+
{{
|
|
1614
|
+
prefix + (row.included ? '.yes' : '.no') | transloco
|
|
1615
|
+
}}
|
|
1616
|
+
</td>
|
|
1617
|
+
</tr>
|
|
1618
|
+
}
|
|
1619
|
+
</tbody>
|
|
1620
|
+
</table>
|
|
1621
|
+
@if (hasMissingInput(detail.contributors)) {
|
|
1622
|
+
<p class="mt-1 text-surface-500 dark:text-surface-400">
|
|
1623
|
+
* {{ scheduleKeys + '.inputMissing' | transloco }}
|
|
1624
|
+
</p>
|
|
1625
|
+
}
|
|
1626
|
+
</div>
|
|
1627
|
+
}
|
|
1628
|
+
@if (detail.planned.length) {
|
|
1629
|
+
<div class="flex flex-col gap-1">
|
|
1630
|
+
<span class="text-surface-500 dark:text-surface-400">{{
|
|
1631
|
+
scheduleKeys + '.planned' | transloco
|
|
1632
|
+
}}</span>
|
|
1633
|
+
<ul class="flex flex-col gap-0.5">
|
|
1634
|
+
@for (item of detail.planned; track item.recordId) {
|
|
1635
|
+
<li class="flex flex-col">
|
|
1636
|
+
<div class="flex justify-between gap-2">
|
|
1637
|
+
<span class="tabular-nums">#{{ item.recordId }}</span>
|
|
1638
|
+
<span class="text-end">{{ item.rule }}</span>
|
|
1639
|
+
</div>
|
|
1640
|
+
@if (item.dates || item.minutes) {
|
|
1641
|
+
<div
|
|
1642
|
+
class="flex justify-between gap-2 text-surface-500 tabular-nums dark:text-surface-400"
|
|
1643
|
+
>
|
|
1644
|
+
<bdi>{{ item.dates }}</bdi>
|
|
1645
|
+
<bdi>{{ item.minutes }}</bdi>
|
|
1646
|
+
</div>
|
|
1647
|
+
}
|
|
1648
|
+
</li>
|
|
1649
|
+
}
|
|
1650
|
+
</ul>
|
|
1651
|
+
</div>
|
|
1652
|
+
}
|
|
1653
|
+
@if (detail.calendar; as calendar) {
|
|
1654
|
+
<dl
|
|
1655
|
+
class="grid grid-cols-[auto_minmax(0,1fr)] gap-x-2 gap-y-0.5 rounded-md border border-surface-200 px-2 py-1 dark:border-surface-700"
|
|
1656
|
+
>
|
|
1657
|
+
<dt class="text-surface-500 dark:text-surface-400">
|
|
1658
|
+
{{ scheduleKeys + '.timeZone' | transloco }}
|
|
1659
|
+
</dt>
|
|
1660
|
+
<dd class="ms-0 break-words">{{ calendar.timeZone }}</dd>
|
|
1661
|
+
<dt class="text-surface-500 dark:text-surface-400">
|
|
1662
|
+
{{ scheduleKeys + '.calendarSource' | transloco }}
|
|
1663
|
+
</dt>
|
|
1664
|
+
<dd class="ms-0 break-words">{{ calendar.source }}</dd>
|
|
1665
|
+
<dt class="text-surface-500 dark:text-surface-400">
|
|
1666
|
+
{{ scheduleKeys + '.workingHours' | transloco }}
|
|
1667
|
+
</dt>
|
|
1668
|
+
<dd class="ms-0 tabular-nums" dir="ltr">
|
|
1669
|
+
{{ calendar.workingHours }}
|
|
1670
|
+
</dd>
|
|
1671
|
+
<dt class="text-surface-500 dark:text-surface-400">
|
|
1672
|
+
{{ scheduleKeys + '.workingDays' | transloco }}
|
|
1673
|
+
</dt>
|
|
1674
|
+
<dd class="ms-0">{{ calendar.workingDays || '—' }}</dd>
|
|
1675
|
+
<dt class="text-surface-500 dark:text-surface-400">
|
|
1676
|
+
{{ scheduleKeys + '.holidays' | transloco }}
|
|
1677
|
+
</dt>
|
|
1678
|
+
<dd class="ms-0 break-words">{{ calendar.holidays || '—' }}</dd>
|
|
1679
|
+
</dl>
|
|
1680
|
+
}
|
|
1681
|
+
</div>
|
|
1682
|
+
}
|
|
1683
|
+
|
|
1684
|
+
@if (view.codeBlocks.length) {
|
|
1685
|
+
<div class="flex flex-col gap-1">
|
|
1686
|
+
<ng-container
|
|
1687
|
+
[ngTemplateOutlet]="section"
|
|
1688
|
+
[ngTemplateOutletContext]="{ $implicit: 'codeBlocks' }"
|
|
1689
|
+
/>
|
|
1690
|
+
<ol class="flex flex-col gap-1.5">
|
|
1691
|
+
@for (block of view.codeBlocks; track $index) {
|
|
1692
|
+
<li
|
|
1693
|
+
class="flex flex-col gap-1 rounded-md border border-surface-200 px-2 py-1.5 dark:border-surface-700"
|
|
1694
|
+
>
|
|
1695
|
+
<div class="flex items-baseline justify-between gap-2">
|
|
1696
|
+
<span class="text-surface-500 dark:text-surface-400">{{
|
|
1697
|
+
block.type
|
|
1698
|
+
}}</span>
|
|
1699
|
+
<bdi class="font-mono font-medium">{{ block.value }}</bdi>
|
|
1700
|
+
</div>
|
|
1701
|
+
@if (block.raw !== null) {
|
|
1702
|
+
<span class="text-surface-500 dark:text-surface-400">
|
|
1703
|
+
{{
|
|
1704
|
+
prefix + '.codeBlockBefore'
|
|
1705
|
+
| transloco: { value: block.raw }
|
|
1706
|
+
}}
|
|
1707
|
+
</span>
|
|
1708
|
+
}
|
|
1709
|
+
@if (block.settings; as settings) {
|
|
1710
|
+
<ng-container
|
|
1711
|
+
[ngTemplateOutlet]="dataTpl"
|
|
1712
|
+
[ngTemplateOutletContext]="{ $implicit: settings }"
|
|
1713
|
+
/>
|
|
1714
|
+
}
|
|
1715
|
+
</li>
|
|
1716
|
+
}
|
|
1717
|
+
</ol>
|
|
1718
|
+
</div>
|
|
1719
|
+
}
|
|
1720
|
+
|
|
1721
|
+
@if (view.facts.length) {
|
|
1722
|
+
<div class="flex flex-col gap-1.5">
|
|
1723
|
+
<ng-container
|
|
1724
|
+
[ngTemplateOutlet]="section"
|
|
1725
|
+
[ngTemplateOutletContext]="{ $implicit: 'facts' }"
|
|
1726
|
+
/>
|
|
1727
|
+
@for (fact of view.facts; track $index) {
|
|
1728
|
+
<div class="flex flex-col gap-0.5">
|
|
1729
|
+
<bdi class="font-medium">{{ fact.label }}</bdi>
|
|
1730
|
+
<ng-container
|
|
1731
|
+
[ngTemplateOutlet]="dataTpl"
|
|
1732
|
+
[ngTemplateOutletContext]="{ $implicit: fact.data }"
|
|
1733
|
+
/>
|
|
1734
|
+
</div>
|
|
1735
|
+
}
|
|
1736
|
+
</div>
|
|
1737
|
+
}
|
|
1738
|
+
|
|
1739
|
+
@if (view.sources.length) {
|
|
1740
|
+
<div class="flex flex-col gap-1">
|
|
1741
|
+
<ng-container
|
|
1742
|
+
[ngTemplateOutlet]="section"
|
|
1743
|
+
[ngTemplateOutletContext]="{ $implicit: 'sources' }"
|
|
1744
|
+
/>
|
|
1745
|
+
<ul class="flex flex-col gap-1">
|
|
1746
|
+
@for (source of view.sources; track $index) {
|
|
1747
|
+
<li class="flex flex-col">
|
|
1748
|
+
<span>{{
|
|
1749
|
+
prefix + '.sourceRecords'
|
|
1750
|
+
| transloco: { count: source.count, source: source.label }
|
|
1751
|
+
}}</span>
|
|
1752
|
+
<span
|
|
1753
|
+
class="break-words text-surface-500 tabular-nums dark:text-surface-400"
|
|
1754
|
+
dir="ltr"
|
|
1755
|
+
>{{ source.ids }}</span
|
|
1756
|
+
>
|
|
1757
|
+
</li>
|
|
1758
|
+
}
|
|
1759
|
+
</ul>
|
|
1760
|
+
</div>
|
|
1761
|
+
}
|
|
1762
|
+
</div>
|
|
1763
|
+
`, isInline: true, dependencies: [{ kind: "component", type: CalculationExplanationEquation, selector: "mt-calculation-explanation-equation", inputs: ["segments", "result", "resultOperator"] }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "pipe", type: TranslocoPipe, name: "transloco" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
1764
|
+
}
|
|
1765
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: CalculationExplanationDetails, decorators: [{
|
|
1766
|
+
type: Component,
|
|
1767
|
+
args: [{
|
|
1768
|
+
selector: 'mt-calculation-explanation-details',
|
|
1769
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
1770
|
+
imports: [CalculationExplanationEquation, NgTemplateOutlet, TranslocoPipe],
|
|
1771
|
+
template: `
|
|
1772
|
+
<ng-template #section let-title>
|
|
1773
|
+
<div class="text-xs font-semibold text-surface-500 dark:text-surface-400">
|
|
1774
|
+
{{ prefix + '.' + title | transloco }}
|
|
1775
|
+
</div>
|
|
1776
|
+
</ng-template>
|
|
1777
|
+
|
|
1778
|
+
<ng-template #dataTpl let-data>
|
|
1779
|
+
@switch (data.kind) {
|
|
1780
|
+
@case ('text') {
|
|
1781
|
+
<span class="break-words">{{ data.text }}</span>
|
|
1782
|
+
}
|
|
1783
|
+
@case ('list') {
|
|
1784
|
+
<span class="break-words">{{ data.items.join(', ') }}</span>
|
|
1785
|
+
}
|
|
1786
|
+
@case ('table') {
|
|
1787
|
+
<div class="overflow-x-auto">
|
|
1788
|
+
<table class="w-full text-xs">
|
|
1789
|
+
<thead>
|
|
1790
|
+
<tr class="text-surface-500 dark:text-surface-400">
|
|
1791
|
+
@for (column of data.columns; track $index) {
|
|
1792
|
+
<th class="px-1 py-0.5 text-start font-medium">
|
|
1793
|
+
{{ column }}
|
|
1794
|
+
</th>
|
|
1795
|
+
}
|
|
1796
|
+
</tr>
|
|
1797
|
+
</thead>
|
|
1798
|
+
<tbody>
|
|
1799
|
+
@for (row of data.rows; track $index) {
|
|
1800
|
+
<tr
|
|
1801
|
+
class="border-t border-surface-100 dark:border-surface-700"
|
|
1802
|
+
>
|
|
1803
|
+
@for (cell of row; track $index) {
|
|
1804
|
+
<td class="px-1 py-0.5 align-top break-words">
|
|
1805
|
+
{{ cell }}
|
|
1806
|
+
</td>
|
|
1807
|
+
}
|
|
1808
|
+
</tr>
|
|
1809
|
+
}
|
|
1810
|
+
</tbody>
|
|
1811
|
+
</table>
|
|
1812
|
+
</div>
|
|
1813
|
+
}
|
|
1814
|
+
@case ('fields') {
|
|
1815
|
+
<dl class="flex flex-col gap-1">
|
|
1816
|
+
@for (field of data.fields; track $index) {
|
|
1817
|
+
<div class="flex flex-col">
|
|
1818
|
+
<dt class="text-xs text-surface-500 dark:text-surface-400">
|
|
1819
|
+
{{ field.label }}
|
|
1820
|
+
</dt>
|
|
1821
|
+
<dd class="ms-0">
|
|
1822
|
+
<ng-container
|
|
1823
|
+
[ngTemplateOutlet]="dataTpl"
|
|
1824
|
+
[ngTemplateOutletContext]="{ $implicit: field.data }"
|
|
1825
|
+
/>
|
|
1826
|
+
</dd>
|
|
1827
|
+
</div>
|
|
1828
|
+
}
|
|
1829
|
+
</dl>
|
|
1830
|
+
}
|
|
1831
|
+
}
|
|
1832
|
+
</ng-template>
|
|
1833
|
+
|
|
1834
|
+
@let view = details();
|
|
1835
|
+
<div
|
|
1836
|
+
class="flex flex-col gap-3 text-xs text-surface-700 dark:text-surface-200"
|
|
1837
|
+
>
|
|
1838
|
+
@if (view.formula) {
|
|
1839
|
+
<div class="flex flex-col gap-1">
|
|
1840
|
+
<ng-container
|
|
1841
|
+
[ngTemplateOutlet]="section"
|
|
1842
|
+
[ngTemplateOutletContext]="{ $implicit: 'formula' }"
|
|
1843
|
+
/>
|
|
1844
|
+
<code
|
|
1845
|
+
dir="ltr"
|
|
1846
|
+
class="rounded-md border border-surface-200 bg-surface-50 px-2 py-1 font-mono break-all dark:border-surface-700 dark:bg-surface-800"
|
|
1847
|
+
>{{ view.formula }}</code
|
|
1848
|
+
>
|
|
1849
|
+
@if (view.formulaWithValues) {
|
|
1850
|
+
<span class="text-surface-500 dark:text-surface-400">
|
|
1851
|
+
{{ prefix + '.withValues' | transloco }}
|
|
1852
|
+
</span>
|
|
1853
|
+
<code
|
|
1854
|
+
dir="ltr"
|
|
1855
|
+
class="rounded-md border border-surface-200 bg-surface-50 px-2 py-1 font-mono break-all dark:border-surface-700 dark:bg-surface-800"
|
|
1856
|
+
>{{ view.formulaWithValues }}</code
|
|
1857
|
+
>
|
|
1858
|
+
}
|
|
1859
|
+
</div>
|
|
1860
|
+
}
|
|
1861
|
+
|
|
1862
|
+
@if (view.inputs.length) {
|
|
1863
|
+
<div class="flex flex-col gap-1">
|
|
1864
|
+
<ng-container
|
|
1865
|
+
[ngTemplateOutlet]="section"
|
|
1866
|
+
[ngTemplateOutletContext]="{ $implicit: 'inputs' }"
|
|
1867
|
+
/>
|
|
1868
|
+
<ul class="flex flex-col gap-1">
|
|
1869
|
+
@for (item of view.inputs; track $index) {
|
|
1870
|
+
<li class="flex flex-col gap-0.5">
|
|
1871
|
+
<div class="flex items-baseline justify-between gap-2">
|
|
1872
|
+
<bdi class="min-w-0 break-words">{{ item.label }}</bdi>
|
|
1873
|
+
<bdi class="shrink-0 font-medium tabular-nums">{{
|
|
1874
|
+
item.value
|
|
1875
|
+
}}</bdi>
|
|
1876
|
+
</div>
|
|
1877
|
+
@if (item.rows.length) {
|
|
1878
|
+
<ul
|
|
1879
|
+
class="flex flex-col gap-0.5 rounded-md border border-surface-200 px-2 py-1 dark:border-surface-700"
|
|
1880
|
+
>
|
|
1881
|
+
@for (row of item.rows; track $index) {
|
|
1882
|
+
<li class="flex justify-between gap-2 tabular-nums">
|
|
1883
|
+
@if (row.recordId !== null) {
|
|
1884
|
+
<span class="text-surface-500 dark:text-surface-400"
|
|
1885
|
+
>#{{ row.recordId }}</span
|
|
1886
|
+
>
|
|
1887
|
+
}
|
|
1888
|
+
<bdi>{{ row.value }}</bdi>
|
|
1889
|
+
</li>
|
|
1890
|
+
}
|
|
1891
|
+
</ul>
|
|
1892
|
+
}
|
|
1893
|
+
</li>
|
|
1894
|
+
}
|
|
1895
|
+
</ul>
|
|
1896
|
+
</div>
|
|
1897
|
+
}
|
|
1898
|
+
|
|
1899
|
+
@if (view.functions.length) {
|
|
1900
|
+
<div class="flex flex-col gap-1">
|
|
1901
|
+
<ng-container
|
|
1902
|
+
[ngTemplateOutlet]="section"
|
|
1903
|
+
[ngTemplateOutletContext]="{ $implicit: 'functions' }"
|
|
1904
|
+
/>
|
|
1905
|
+
<ul class="flex flex-col gap-0.5">
|
|
1906
|
+
@for (fn of view.functions; track $index) {
|
|
1907
|
+
<li class="flex items-baseline justify-between gap-2">
|
|
1908
|
+
<span dir="ltr" class="font-mono">{{ fn.name }}</span>
|
|
1909
|
+
<bdi
|
|
1910
|
+
class="shrink-0 tabular-nums"
|
|
1911
|
+
[class.italic]="fn.notEvaluated"
|
|
1912
|
+
[class.text-surface-400]="fn.notEvaluated"
|
|
1913
|
+
>{{ fn.result }}</bdi
|
|
1914
|
+
>
|
|
1915
|
+
</li>
|
|
1916
|
+
}
|
|
1917
|
+
</ul>
|
|
1918
|
+
</div>
|
|
1919
|
+
}
|
|
1920
|
+
|
|
1921
|
+
@if (view.statusRules.length) {
|
|
1922
|
+
<div class="flex flex-col gap-1">
|
|
1923
|
+
<ng-container
|
|
1924
|
+
[ngTemplateOutlet]="section"
|
|
1925
|
+
[ngTemplateOutletContext]="{ $implicit: 'statusRules' }"
|
|
1926
|
+
/>
|
|
1927
|
+
<p class="text-surface-500 dark:text-surface-400">
|
|
1928
|
+
{{ prefix + '.firstMatchWins' | transloco }}
|
|
1929
|
+
</p>
|
|
1930
|
+
<ol class="flex flex-col gap-1.5">
|
|
1931
|
+
@for (rule of view.statusRules; track rule.key) {
|
|
1932
|
+
<li
|
|
1933
|
+
class="flex flex-col gap-1 rounded-md border px-2 py-1.5"
|
|
1934
|
+
[class]="
|
|
1935
|
+
rule.verdict === 'selected'
|
|
1936
|
+
? 'border-primary-200 bg-primary-50 dark:border-primary-800 dark:bg-primary-950'
|
|
1937
|
+
: 'border-surface-200 dark:border-surface-700'
|
|
1938
|
+
"
|
|
1939
|
+
>
|
|
1940
|
+
<div class="flex items-center justify-between gap-2">
|
|
1941
|
+
<bdi class="font-medium">{{ rule.name }}</bdi>
|
|
1942
|
+
<span
|
|
1943
|
+
class="shrink-0 rounded-md px-1.5 py-0.5 text-[11px]"
|
|
1944
|
+
[class]="verdictClass[rule.verdict]"
|
|
1945
|
+
>
|
|
1946
|
+
{{ prefix + '.verdict.' + rule.verdict | transloco }}
|
|
1947
|
+
</span>
|
|
1948
|
+
</div>
|
|
1949
|
+
@if (rule.segments; as segments) {
|
|
1950
|
+
<mt-calculation-explanation-equation [segments]="segments" />
|
|
1951
|
+
}
|
|
1952
|
+
</li>
|
|
1953
|
+
}
|
|
1954
|
+
</ol>
|
|
1955
|
+
</div>
|
|
1956
|
+
}
|
|
1957
|
+
|
|
1958
|
+
@for (detail of view.schedule; track $index) {
|
|
1959
|
+
<div class="flex flex-col gap-1.5">
|
|
1960
|
+
<div class="flex items-baseline justify-between gap-2">
|
|
1961
|
+
<span
|
|
1962
|
+
class="text-xs font-semibold text-surface-500 dark:text-surface-400"
|
|
1963
|
+
>{{ detail.title }}</span
|
|
1964
|
+
>
|
|
1965
|
+
<span class="font-semibold tabular-nums">{{ detail.result }}</span>
|
|
1966
|
+
</div>
|
|
1967
|
+
<code
|
|
1968
|
+
dir="ltr"
|
|
1969
|
+
class="rounded-md border border-surface-200 bg-surface-50 px-2 py-1 font-mono break-all dark:border-surface-700 dark:bg-surface-800"
|
|
1970
|
+
>{{ detail.formulaWithValues }}</code
|
|
1971
|
+
>
|
|
1972
|
+
<div class="flex flex-wrap gap-1">
|
|
1973
|
+
@for (fact of detail.facts; track $index) {
|
|
1974
|
+
<span
|
|
1975
|
+
class="rounded-md bg-surface-100 px-1.5 py-0.5 dark:bg-surface-800"
|
|
1976
|
+
>{{ fact }}</span
|
|
1977
|
+
>
|
|
1978
|
+
}
|
|
1979
|
+
</div>
|
|
1980
|
+
@for (note of detail.notes; track $index) {
|
|
1981
|
+
<div
|
|
1982
|
+
class="rounded-md border border-amber-200 bg-amber-50 px-2 py-1 text-amber-700"
|
|
1983
|
+
>
|
|
1984
|
+
{{ note }}
|
|
1985
|
+
</div>
|
|
1986
|
+
}
|
|
1987
|
+
@if (detail.contributors.length) {
|
|
1988
|
+
<div class="overflow-x-auto">
|
|
1989
|
+
<table class="w-full tabular-nums">
|
|
1990
|
+
<thead>
|
|
1991
|
+
<tr class="text-surface-500 dark:text-surface-400">
|
|
1992
|
+
<th class="px-1 py-0.5 text-start font-medium">
|
|
1993
|
+
{{ scheduleKeys + '.item' | transloco }}
|
|
1994
|
+
</th>
|
|
1995
|
+
<th class="px-1 py-0.5 text-end font-medium">
|
|
1996
|
+
{{ scheduleKeys + '.progress' | transloco }}
|
|
1997
|
+
</th>
|
|
1998
|
+
<th class="px-1 py-0.5 text-end font-medium">
|
|
1999
|
+
{{ scheduleKeys + '.weight' | transloco }}
|
|
2000
|
+
</th>
|
|
2001
|
+
<th class="px-1 py-0.5 text-end font-medium">
|
|
2002
|
+
{{ scheduleKeys + '.included' | transloco }}
|
|
2003
|
+
</th>
|
|
2004
|
+
</tr>
|
|
2005
|
+
</thead>
|
|
2006
|
+
<tbody>
|
|
2007
|
+
@for (row of detail.contributors; track row.recordId) {
|
|
2008
|
+
<tr
|
|
2009
|
+
class="border-t border-surface-100 dark:border-surface-700"
|
|
2010
|
+
[class.text-surface-400]="!row.included"
|
|
2011
|
+
>
|
|
2012
|
+
<td class="px-1 py-0.5">#{{ row.recordId }}</td>
|
|
2013
|
+
<td
|
|
2014
|
+
class="px-1 py-0.5 text-end"
|
|
2015
|
+
[class.italic]="row.inputMissing"
|
|
2016
|
+
[attr.title]="
|
|
2017
|
+
row.inputMissing
|
|
2018
|
+
? (scheduleKeys + '.inputMissing' | transloco)
|
|
2019
|
+
: null
|
|
2020
|
+
"
|
|
2021
|
+
>
|
|
2022
|
+
{{ row.progress }}{{ row.inputMissing ? ' *' : '' }}
|
|
2023
|
+
</td>
|
|
2024
|
+
<td class="px-1 py-0.5 text-end">{{ row.weight }}</td>
|
|
2025
|
+
<td class="px-1 py-0.5 text-end">
|
|
2026
|
+
{{
|
|
2027
|
+
prefix + (row.included ? '.yes' : '.no') | transloco
|
|
2028
|
+
}}
|
|
2029
|
+
</td>
|
|
2030
|
+
</tr>
|
|
2031
|
+
}
|
|
2032
|
+
</tbody>
|
|
2033
|
+
</table>
|
|
2034
|
+
@if (hasMissingInput(detail.contributors)) {
|
|
2035
|
+
<p class="mt-1 text-surface-500 dark:text-surface-400">
|
|
2036
|
+
* {{ scheduleKeys + '.inputMissing' | transloco }}
|
|
2037
|
+
</p>
|
|
2038
|
+
}
|
|
2039
|
+
</div>
|
|
2040
|
+
}
|
|
2041
|
+
@if (detail.planned.length) {
|
|
2042
|
+
<div class="flex flex-col gap-1">
|
|
2043
|
+
<span class="text-surface-500 dark:text-surface-400">{{
|
|
2044
|
+
scheduleKeys + '.planned' | transloco
|
|
2045
|
+
}}</span>
|
|
2046
|
+
<ul class="flex flex-col gap-0.5">
|
|
2047
|
+
@for (item of detail.planned; track item.recordId) {
|
|
2048
|
+
<li class="flex flex-col">
|
|
2049
|
+
<div class="flex justify-between gap-2">
|
|
2050
|
+
<span class="tabular-nums">#{{ item.recordId }}</span>
|
|
2051
|
+
<span class="text-end">{{ item.rule }}</span>
|
|
2052
|
+
</div>
|
|
2053
|
+
@if (item.dates || item.minutes) {
|
|
2054
|
+
<div
|
|
2055
|
+
class="flex justify-between gap-2 text-surface-500 tabular-nums dark:text-surface-400"
|
|
2056
|
+
>
|
|
2057
|
+
<bdi>{{ item.dates }}</bdi>
|
|
2058
|
+
<bdi>{{ item.minutes }}</bdi>
|
|
2059
|
+
</div>
|
|
2060
|
+
}
|
|
2061
|
+
</li>
|
|
2062
|
+
}
|
|
2063
|
+
</ul>
|
|
2064
|
+
</div>
|
|
2065
|
+
}
|
|
2066
|
+
@if (detail.calendar; as calendar) {
|
|
2067
|
+
<dl
|
|
2068
|
+
class="grid grid-cols-[auto_minmax(0,1fr)] gap-x-2 gap-y-0.5 rounded-md border border-surface-200 px-2 py-1 dark:border-surface-700"
|
|
2069
|
+
>
|
|
2070
|
+
<dt class="text-surface-500 dark:text-surface-400">
|
|
2071
|
+
{{ scheduleKeys + '.timeZone' | transloco }}
|
|
2072
|
+
</dt>
|
|
2073
|
+
<dd class="ms-0 break-words">{{ calendar.timeZone }}</dd>
|
|
2074
|
+
<dt class="text-surface-500 dark:text-surface-400">
|
|
2075
|
+
{{ scheduleKeys + '.calendarSource' | transloco }}
|
|
2076
|
+
</dt>
|
|
2077
|
+
<dd class="ms-0 break-words">{{ calendar.source }}</dd>
|
|
2078
|
+
<dt class="text-surface-500 dark:text-surface-400">
|
|
2079
|
+
{{ scheduleKeys + '.workingHours' | transloco }}
|
|
2080
|
+
</dt>
|
|
2081
|
+
<dd class="ms-0 tabular-nums" dir="ltr">
|
|
2082
|
+
{{ calendar.workingHours }}
|
|
2083
|
+
</dd>
|
|
2084
|
+
<dt class="text-surface-500 dark:text-surface-400">
|
|
2085
|
+
{{ scheduleKeys + '.workingDays' | transloco }}
|
|
2086
|
+
</dt>
|
|
2087
|
+
<dd class="ms-0">{{ calendar.workingDays || '—' }}</dd>
|
|
2088
|
+
<dt class="text-surface-500 dark:text-surface-400">
|
|
2089
|
+
{{ scheduleKeys + '.holidays' | transloco }}
|
|
2090
|
+
</dt>
|
|
2091
|
+
<dd class="ms-0 break-words">{{ calendar.holidays || '—' }}</dd>
|
|
2092
|
+
</dl>
|
|
2093
|
+
}
|
|
2094
|
+
</div>
|
|
2095
|
+
}
|
|
2096
|
+
|
|
2097
|
+
@if (view.codeBlocks.length) {
|
|
2098
|
+
<div class="flex flex-col gap-1">
|
|
2099
|
+
<ng-container
|
|
2100
|
+
[ngTemplateOutlet]="section"
|
|
2101
|
+
[ngTemplateOutletContext]="{ $implicit: 'codeBlocks' }"
|
|
2102
|
+
/>
|
|
2103
|
+
<ol class="flex flex-col gap-1.5">
|
|
2104
|
+
@for (block of view.codeBlocks; track $index) {
|
|
2105
|
+
<li
|
|
2106
|
+
class="flex flex-col gap-1 rounded-md border border-surface-200 px-2 py-1.5 dark:border-surface-700"
|
|
2107
|
+
>
|
|
2108
|
+
<div class="flex items-baseline justify-between gap-2">
|
|
2109
|
+
<span class="text-surface-500 dark:text-surface-400">{{
|
|
2110
|
+
block.type
|
|
2111
|
+
}}</span>
|
|
2112
|
+
<bdi class="font-mono font-medium">{{ block.value }}</bdi>
|
|
2113
|
+
</div>
|
|
2114
|
+
@if (block.raw !== null) {
|
|
2115
|
+
<span class="text-surface-500 dark:text-surface-400">
|
|
2116
|
+
{{
|
|
2117
|
+
prefix + '.codeBlockBefore'
|
|
2118
|
+
| transloco: { value: block.raw }
|
|
2119
|
+
}}
|
|
2120
|
+
</span>
|
|
2121
|
+
}
|
|
2122
|
+
@if (block.settings; as settings) {
|
|
2123
|
+
<ng-container
|
|
2124
|
+
[ngTemplateOutlet]="dataTpl"
|
|
2125
|
+
[ngTemplateOutletContext]="{ $implicit: settings }"
|
|
2126
|
+
/>
|
|
2127
|
+
}
|
|
2128
|
+
</li>
|
|
2129
|
+
}
|
|
2130
|
+
</ol>
|
|
2131
|
+
</div>
|
|
2132
|
+
}
|
|
2133
|
+
|
|
2134
|
+
@if (view.facts.length) {
|
|
2135
|
+
<div class="flex flex-col gap-1.5">
|
|
2136
|
+
<ng-container
|
|
2137
|
+
[ngTemplateOutlet]="section"
|
|
2138
|
+
[ngTemplateOutletContext]="{ $implicit: 'facts' }"
|
|
2139
|
+
/>
|
|
2140
|
+
@for (fact of view.facts; track $index) {
|
|
2141
|
+
<div class="flex flex-col gap-0.5">
|
|
2142
|
+
<bdi class="font-medium">{{ fact.label }}</bdi>
|
|
2143
|
+
<ng-container
|
|
2144
|
+
[ngTemplateOutlet]="dataTpl"
|
|
2145
|
+
[ngTemplateOutletContext]="{ $implicit: fact.data }"
|
|
2146
|
+
/>
|
|
2147
|
+
</div>
|
|
2148
|
+
}
|
|
2149
|
+
</div>
|
|
2150
|
+
}
|
|
2151
|
+
|
|
2152
|
+
@if (view.sources.length) {
|
|
2153
|
+
<div class="flex flex-col gap-1">
|
|
2154
|
+
<ng-container
|
|
2155
|
+
[ngTemplateOutlet]="section"
|
|
2156
|
+
[ngTemplateOutletContext]="{ $implicit: 'sources' }"
|
|
2157
|
+
/>
|
|
2158
|
+
<ul class="flex flex-col gap-1">
|
|
2159
|
+
@for (source of view.sources; track $index) {
|
|
2160
|
+
<li class="flex flex-col">
|
|
2161
|
+
<span>{{
|
|
2162
|
+
prefix + '.sourceRecords'
|
|
2163
|
+
| transloco: { count: source.count, source: source.label }
|
|
2164
|
+
}}</span>
|
|
2165
|
+
<span
|
|
2166
|
+
class="break-words text-surface-500 tabular-nums dark:text-surface-400"
|
|
2167
|
+
dir="ltr"
|
|
2168
|
+
>{{ source.ids }}</span
|
|
2169
|
+
>
|
|
2170
|
+
</li>
|
|
2171
|
+
}
|
|
2172
|
+
</ul>
|
|
2173
|
+
</div>
|
|
2174
|
+
}
|
|
2175
|
+
</div>
|
|
2176
|
+
`,
|
|
2177
|
+
}]
|
|
2178
|
+
}], propDecorators: { details: [{ type: i0.Input, args: [{ isSignal: true, alias: "details", required: true }] }] } });
|
|
2179
|
+
|
|
2180
|
+
const KEY_PREFIX = CALCULATION_EXPLANATION_KEYS;
|
|
421
2181
|
/** Unavailable outcomes with their own message; anything else is generic. */
|
|
422
2182
|
const UNAVAILABLE_KEYS = {
|
|
423
2183
|
notCaptured: `${KEY_PREFIX}.notCaptured`,
|
|
@@ -427,19 +2187,33 @@ const UNAVAILABLE_KEYS = {
|
|
|
427
2187
|
valueChanged: `${KEY_PREFIX}.valueChanged`,
|
|
428
2188
|
notCalculated: `${KEY_PREFIX}.notCalculated`,
|
|
429
2189
|
};
|
|
2190
|
+
const PROVIDERS = new Set([
|
|
2191
|
+
'formula',
|
|
2192
|
+
'status',
|
|
2193
|
+
'nativeMethod',
|
|
2194
|
+
'codeBuilder',
|
|
2195
|
+
'schedule',
|
|
2196
|
+
]);
|
|
2197
|
+
const BASES = new Set(['savedCalculation', 'currentCalculation']);
|
|
430
2198
|
/**
|
|
431
|
-
* How a calculated value was calculated:
|
|
432
|
-
*
|
|
433
|
-
*
|
|
2199
|
+
* How a calculated value was calculated: a readable equation with each input
|
|
2200
|
+
* by name and the value it had, the result and when, with the captured
|
|
2201
|
+
* details behind a toggle. Fetched each time it opens; reading it never
|
|
2202
|
+
* recalculates anything, and nothing here is recalculated either.
|
|
434
2203
|
*/
|
|
435
2204
|
class EntityCalculationExplanation {
|
|
436
2205
|
api = inject(CalculationExplanationApi);
|
|
437
2206
|
refresher = inject(EntityCalculationRefresher, {
|
|
438
2207
|
optional: true,
|
|
439
2208
|
});
|
|
2209
|
+
transloco = inject(TranslocoService);
|
|
2210
|
+
lang = sharedActiveLang(this.transloco);
|
|
2211
|
+
currency = inject(MT_CALCULATION_CURRENCY);
|
|
2212
|
+
datePipe = inject(MTDateFormatPipe);
|
|
440
2213
|
target = input.required(...(ngDevMode ? [{ debugName: "target" }] : /* istanbul ignore next */ []));
|
|
441
2214
|
prefix = KEY_PREFIX;
|
|
442
2215
|
state = signal({ kind: 'loading' }, ...(ngDevMode ? [{ debugName: "state" }] : /* istanbul ignore next */ []));
|
|
2216
|
+
expanded = signal(false, ...(ngDevMode ? [{ debugName: "expanded" }] : /* istanbul ignore next */ []));
|
|
443
2217
|
available = computed(() => {
|
|
444
2218
|
const state = this.state();
|
|
445
2219
|
return state.kind === 'available' ? state : null;
|
|
@@ -448,6 +2222,54 @@ class EntityCalculationExplanation {
|
|
|
448
2222
|
const state = this.state();
|
|
449
2223
|
return state.kind === 'unavailable' ? state.messageKey : null;
|
|
450
2224
|
}, ...(ngDevMode ? [{ debugName: "unavailableKey" }] : /* istanbul ignore next */ []));
|
|
2225
|
+
formatContext = computed(() => ({
|
|
2226
|
+
lang: this.lang(),
|
|
2227
|
+
currency: this.currency(),
|
|
2228
|
+
formatDate: (value, type) => this.datePipe.transform(value, type),
|
|
2229
|
+
translate: (key, params) => this.transloco.translate(key, params),
|
|
2230
|
+
}), ...(ngDevMode ? [{ debugName: "formatContext" }] : /* istanbul ignore next */ []));
|
|
2231
|
+
view = computed(() => {
|
|
2232
|
+
const state = this.available();
|
|
2233
|
+
if (!state) {
|
|
2234
|
+
return null;
|
|
2235
|
+
}
|
|
2236
|
+
const ctx = this.formatContext();
|
|
2237
|
+
const target = this.target();
|
|
2238
|
+
const { document, basis } = state;
|
|
2239
|
+
const names = target.statusNames ?? {};
|
|
2240
|
+
const status = document.provider === 'status';
|
|
2241
|
+
const result = status
|
|
2242
|
+
? statusName(String(document.result ?? ''), names)
|
|
2243
|
+
: formatTypedValue(document.result, state.viewType, ctx);
|
|
2244
|
+
const summary = this.summarize(document, result, ctx, names);
|
|
2245
|
+
const details = buildExplanationDetails(document, ctx, names);
|
|
2246
|
+
return {
|
|
2247
|
+
basis,
|
|
2248
|
+
calculatedAt: document.calculatedAt,
|
|
2249
|
+
definitionChanged: state.definitionChanged,
|
|
2250
|
+
refreshed: state.refreshed,
|
|
2251
|
+
result,
|
|
2252
|
+
summary,
|
|
2253
|
+
equation: summary.kind === 'equation' ? summary.segments : [],
|
|
2254
|
+
operator: summary.kind === 'equation' ? summary.operator : '=',
|
|
2255
|
+
description: summary.kind === 'description' || summary.kind === 'message'
|
|
2256
|
+
? summary.text
|
|
2257
|
+
: '',
|
|
2258
|
+
descriptionIsCode: summary.kind === 'description' ? summary.code : false,
|
|
2259
|
+
// A current calculation is shown beside the value on the page, never in
|
|
2260
|
+
// place of it: the page keeps what it read.
|
|
2261
|
+
differs: basis === 'currentCalculation' &&
|
|
2262
|
+
!status &&
|
|
2263
|
+
!isSameSavedValue(primitiveText(document.result), target.displayedValue)
|
|
2264
|
+
? {
|
|
2265
|
+
page: formatTypedValue(target.displayedValue ?? null, state.viewType, ctx),
|
|
2266
|
+
current: result,
|
|
2267
|
+
}
|
|
2268
|
+
: null,
|
|
2269
|
+
details,
|
|
2270
|
+
hasDetails: hasExplanationDetails(details),
|
|
2271
|
+
};
|
|
2272
|
+
}, ...(ngDevMode ? [{ debugName: "view" }] : /* istanbul ignore next */ []));
|
|
451
2273
|
request;
|
|
452
2274
|
constructor() {
|
|
453
2275
|
inject(DestroyRef).onDestroy(() => this.request?.unsubscribe());
|
|
@@ -467,39 +2289,84 @@ class EntityCalculationExplanation {
|
|
|
467
2289
|
}
|
|
468
2290
|
apply(response, retried) {
|
|
469
2291
|
// The value was saved again while the explanation was read: show the new
|
|
470
|
-
// value, then explain that one.
|
|
2292
|
+
// value (a read, never a recalculation), then explain that one.
|
|
471
2293
|
if (response.status === 'valueChanged' && !retried) {
|
|
472
2294
|
this.refresher?.refreshStaleCalculatedValue();
|
|
473
2295
|
this.load(true);
|
|
474
2296
|
return;
|
|
475
2297
|
}
|
|
476
2298
|
const explanation = response.explanation;
|
|
2299
|
+
const basis = response.basis ?? 'savedCalculation';
|
|
477
2300
|
if (response.status !== 'available' ||
|
|
478
2301
|
!explanation ||
|
|
479
2302
|
explanation.schemaVersion !== 1 ||
|
|
480
|
-
explanation.provider
|
|
2303
|
+
!PROVIDERS.has(explanation.provider) ||
|
|
2304
|
+
!BASES.has(basis)) {
|
|
481
2305
|
this.state.set({
|
|
482
2306
|
kind: 'unavailable',
|
|
483
2307
|
messageKey: UNAVAILABLE_KEYS[response.status] ?? `${KEY_PREFIX}.unavailable`,
|
|
484
2308
|
});
|
|
485
2309
|
return;
|
|
486
2310
|
}
|
|
487
|
-
|
|
2311
|
+
// Only a saved calculation names the persisted value; a newer one than
|
|
2312
|
+
// the value on screen means the screen is behind.
|
|
2313
|
+
const stale = basis === 'savedCalculation' &&
|
|
2314
|
+
!isSameSavedValue(response.savedValue, this.target().displayedValue);
|
|
488
2315
|
if (stale) {
|
|
489
2316
|
this.refresher?.refreshStaleCalculatedValue();
|
|
490
2317
|
}
|
|
491
2318
|
this.state.set({
|
|
492
2319
|
kind: 'available',
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
calculatedAt: explanation.calculatedAt,
|
|
2320
|
+
basis: basis,
|
|
2321
|
+
document: explanation,
|
|
496
2322
|
definitionChanged: response.definitionChanged,
|
|
497
2323
|
refreshed: stale && !!this.refresher,
|
|
2324
|
+
viewType: response.display?.viewType ?? this.target().viewType,
|
|
498
2325
|
});
|
|
499
2326
|
}
|
|
2327
|
+
summarize(document, result, ctx, names) {
|
|
2328
|
+
if (document.provider === 'status') {
|
|
2329
|
+
const rule = selectedStatusRule(document);
|
|
2330
|
+
const condition = rule?.condition
|
|
2331
|
+
? buildExplanationSegments(rule.condition, ctx)
|
|
2332
|
+
: null;
|
|
2333
|
+
if (condition) {
|
|
2334
|
+
return { kind: 'equation', segments: condition, operator: '⇒' };
|
|
2335
|
+
}
|
|
2336
|
+
if (!rule && (document.statusRules?.length ?? 0) > 0) {
|
|
2337
|
+
return {
|
|
2338
|
+
kind: 'message',
|
|
2339
|
+
text: ctx.translate(`${KEY_PREFIX}.noRuleMatched`, {
|
|
2340
|
+
status: statusName(String(document.result ?? ''), names),
|
|
2341
|
+
}),
|
|
2342
|
+
};
|
|
2343
|
+
}
|
|
2344
|
+
}
|
|
2345
|
+
if (document.provider === 'codeBuilder') {
|
|
2346
|
+
const parts = buildCodeSegments(document, ctx);
|
|
2347
|
+
if (parts.length) {
|
|
2348
|
+
return { kind: 'equation', segments: parts, operator: '=' };
|
|
2349
|
+
}
|
|
2350
|
+
}
|
|
2351
|
+
if (isEquationDocument(document)) {
|
|
2352
|
+
const segments = buildExplanationSegments(document, ctx);
|
|
2353
|
+
if (segments?.length) {
|
|
2354
|
+
return { kind: 'equation', segments, operator: '=' };
|
|
2355
|
+
}
|
|
2356
|
+
}
|
|
2357
|
+
// A native method, a schedule field or a manual status: the backend's
|
|
2358
|
+
// description of the calculation, then its result.
|
|
2359
|
+
return {
|
|
2360
|
+
kind: 'description',
|
|
2361
|
+
text: document.formula || document.formulaWithValues || '—',
|
|
2362
|
+
code: document.provider === 'formula',
|
|
2363
|
+
};
|
|
2364
|
+
}
|
|
500
2365
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: EntityCalculationExplanation, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
501
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.8", type: EntityCalculationExplanation, isStandalone: true, selector: "mt-entity-calculation-explanation", inputs: { target: { classPropertyName: "target", publicName: "target", isSignal: true, isRequired: true, transformFunction: null } }, ngImport: i0, template: `
|
|
502
|
-
<div
|
|
2366
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.8", type: EntityCalculationExplanation, isStandalone: true, selector: "mt-entity-calculation-explanation", inputs: { target: { classPropertyName: "target", publicName: "target", isSignal: true, isRequired: true, transformFunction: null } }, providers: [MTDateFormatPipe], ngImport: i0, template: `
|
|
2367
|
+
<div
|
|
2368
|
+
class="flex max-h-[70vh] w-96 max-w-[calc(100vw-2rem)] flex-col gap-3 overflow-y-auto text-sm"
|
|
2369
|
+
>
|
|
503
2370
|
<div class="flex min-w-0 flex-col gap-0.5">
|
|
504
2371
|
<span
|
|
505
2372
|
class="truncate font-semibold text-surface-900 dark:text-surface-0"
|
|
@@ -507,7 +2374,12 @@ class EntityCalculationExplanation {
|
|
|
507
2374
|
{{ target().label }}
|
|
508
2375
|
</span>
|
|
509
2376
|
<span class="text-xs text-surface-500 dark:text-surface-400">
|
|
510
|
-
{{
|
|
2377
|
+
{{
|
|
2378
|
+
prefix +
|
|
2379
|
+
(available()?.basis === 'currentCalculation'
|
|
2380
|
+
? '.currentTitle'
|
|
2381
|
+
: '.title') | transloco
|
|
2382
|
+
}}
|
|
511
2383
|
</span>
|
|
512
2384
|
</div>
|
|
513
2385
|
|
|
@@ -523,37 +2395,85 @@ class EntityCalculationExplanation {
|
|
|
523
2395
|
</div>
|
|
524
2396
|
}
|
|
525
2397
|
@case ('available') {
|
|
526
|
-
@if (
|
|
2398
|
+
@if (view(); as v) {
|
|
527
2399
|
<div
|
|
528
|
-
class="rounded-md border border-surface-200 bg-surface-50 px-3 py-2
|
|
529
|
-
dir="ltr"
|
|
2400
|
+
class="rounded-md border border-surface-200 bg-surface-50 px-3 py-2 text-sm text-surface-800 dark:border-surface-700 dark:bg-surface-800 dark:text-surface-100"
|
|
530
2401
|
>
|
|
531
|
-
@
|
|
532
|
-
|
|
533
|
-
|
|
2402
|
+
@switch (v.summary.kind) {
|
|
2403
|
+
@case ('equation') {
|
|
2404
|
+
<mt-calculation-explanation-equation
|
|
2405
|
+
[segments]="v.equation"
|
|
2406
|
+
[result]="v.result"
|
|
2407
|
+
[resultOperator]="v.operator"
|
|
2408
|
+
/>
|
|
2409
|
+
}
|
|
2410
|
+
@case ('description') {
|
|
2411
|
+
<div class="flex flex-col gap-1">
|
|
2412
|
+
<span
|
|
2413
|
+
class="break-words"
|
|
2414
|
+
[class.font-mono]="v.descriptionIsCode"
|
|
2415
|
+
[attr.dir]="v.descriptionIsCode ? 'ltr' : null"
|
|
2416
|
+
>{{ v.description }}</span
|
|
2417
|
+
>
|
|
2418
|
+
<span>
|
|
2419
|
+
=
|
|
2420
|
+
<bdi class="font-semibold">{{ v.result }}</bdi>
|
|
2421
|
+
</span>
|
|
2422
|
+
</div>
|
|
2423
|
+
}
|
|
2424
|
+
@case ('message') {
|
|
2425
|
+
<span>{{ v.description }}</span>
|
|
2426
|
+
}
|
|
534
2427
|
}
|
|
535
|
-
<span class="font-semibold">{{ explanation.result }}</span>
|
|
536
2428
|
</div>
|
|
537
2429
|
<div class="text-xs text-surface-500 dark:text-surface-400">
|
|
538
|
-
{{
|
|
2430
|
+
{{
|
|
2431
|
+
prefix +
|
|
2432
|
+
(v.basis === 'currentCalculation'
|
|
2433
|
+
? '.currentCalculatedAt'
|
|
2434
|
+
: '.calculatedAt') | transloco
|
|
2435
|
+
}}
|
|
539
2436
|
<span dir="ltr" class="tabular-nums">{{
|
|
540
|
-
|
|
2437
|
+
v.calculatedAt | mtDateFormat: 'dateTime'
|
|
541
2438
|
}}</span>
|
|
542
2439
|
</div>
|
|
543
|
-
@if (
|
|
2440
|
+
@if (v.differs; as differs) {
|
|
2441
|
+
<div
|
|
2442
|
+
class="rounded-md border border-primary-200 bg-primary-50 px-3 py-2 text-xs text-primary-700"
|
|
2443
|
+
>
|
|
2444
|
+
{{ prefix + '.differsFromPage' | transloco: differs }}
|
|
2445
|
+
</div>
|
|
2446
|
+
}
|
|
2447
|
+
@if (v.definitionChanged) {
|
|
544
2448
|
<div
|
|
545
2449
|
class="rounded-md border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-700"
|
|
546
2450
|
>
|
|
547
2451
|
{{ prefix + '.definitionChanged' | transloco }}
|
|
548
2452
|
</div>
|
|
549
2453
|
}
|
|
550
|
-
@if (
|
|
2454
|
+
@if (v.refreshed) {
|
|
551
2455
|
<div
|
|
552
2456
|
class="rounded-md border border-primary-200 bg-primary-50 px-3 py-2 text-xs text-primary-700"
|
|
553
2457
|
>
|
|
554
2458
|
{{ prefix + '.valueRefreshed' | transloco }}
|
|
555
2459
|
</div>
|
|
556
2460
|
}
|
|
2461
|
+
@if (v.hasDetails) {
|
|
2462
|
+
<button
|
|
2463
|
+
type="button"
|
|
2464
|
+
class="self-start rounded-md text-xs font-medium text-primary-700 hover:underline focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-primary-500 dark:text-primary-300"
|
|
2465
|
+
[attr.aria-expanded]="expanded()"
|
|
2466
|
+
(click)="expanded.set(!expanded())"
|
|
2467
|
+
>
|
|
2468
|
+
{{
|
|
2469
|
+
prefix + (expanded() ? '.hideDetails' : '.showDetails')
|
|
2470
|
+
| transloco
|
|
2471
|
+
}}
|
|
2472
|
+
</button>
|
|
2473
|
+
@if (expanded()) {
|
|
2474
|
+
<mt-calculation-explanation-details [details]="v.details" />
|
|
2475
|
+
}
|
|
2476
|
+
}
|
|
557
2477
|
}
|
|
558
2478
|
}
|
|
559
2479
|
@case ('unavailable') {
|
|
@@ -574,16 +2494,24 @@ class EntityCalculationExplanation {
|
|
|
574
2494
|
}
|
|
575
2495
|
}
|
|
576
2496
|
</div>
|
|
577
|
-
`, isInline: true, dependencies: [{ kind: "pipe", type: TranslocoPipe, name: "transloco" }, { kind: "pipe", type: MTDateFormatPipe, name: "mtDateFormat" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
2497
|
+
`, isInline: true, dependencies: [{ kind: "component", type: CalculationExplanationEquation, selector: "mt-calculation-explanation-equation", inputs: ["segments", "result", "resultOperator"] }, { kind: "component", type: CalculationExplanationDetails, selector: "mt-calculation-explanation-details", inputs: ["details"] }, { kind: "pipe", type: TranslocoPipe, name: "transloco" }, { kind: "pipe", type: MTDateFormatPipe, name: "mtDateFormat" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
578
2498
|
}
|
|
579
2499
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: EntityCalculationExplanation, decorators: [{
|
|
580
2500
|
type: Component,
|
|
581
2501
|
args: [{
|
|
582
2502
|
selector: 'mt-entity-calculation-explanation',
|
|
583
2503
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
584
|
-
imports: [
|
|
2504
|
+
imports: [
|
|
2505
|
+
TranslocoPipe,
|
|
2506
|
+
MTDateFormatPipe,
|
|
2507
|
+
CalculationExplanationEquation,
|
|
2508
|
+
CalculationExplanationDetails,
|
|
2509
|
+
],
|
|
2510
|
+
providers: [MTDateFormatPipe],
|
|
585
2511
|
template: `
|
|
586
|
-
<div
|
|
2512
|
+
<div
|
|
2513
|
+
class="flex max-h-[70vh] w-96 max-w-[calc(100vw-2rem)] flex-col gap-3 overflow-y-auto text-sm"
|
|
2514
|
+
>
|
|
587
2515
|
<div class="flex min-w-0 flex-col gap-0.5">
|
|
588
2516
|
<span
|
|
589
2517
|
class="truncate font-semibold text-surface-900 dark:text-surface-0"
|
|
@@ -591,7 +2519,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImpor
|
|
|
591
2519
|
{{ target().label }}
|
|
592
2520
|
</span>
|
|
593
2521
|
<span class="text-xs text-surface-500 dark:text-surface-400">
|
|
594
|
-
{{
|
|
2522
|
+
{{
|
|
2523
|
+
prefix +
|
|
2524
|
+
(available()?.basis === 'currentCalculation'
|
|
2525
|
+
? '.currentTitle'
|
|
2526
|
+
: '.title') | transloco
|
|
2527
|
+
}}
|
|
595
2528
|
</span>
|
|
596
2529
|
</div>
|
|
597
2530
|
|
|
@@ -607,37 +2540,85 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImpor
|
|
|
607
2540
|
</div>
|
|
608
2541
|
}
|
|
609
2542
|
@case ('available') {
|
|
610
|
-
@if (
|
|
2543
|
+
@if (view(); as v) {
|
|
611
2544
|
<div
|
|
612
|
-
class="rounded-md border border-surface-200 bg-surface-50 px-3 py-2
|
|
613
|
-
dir="ltr"
|
|
2545
|
+
class="rounded-md border border-surface-200 bg-surface-50 px-3 py-2 text-sm text-surface-800 dark:border-surface-700 dark:bg-surface-800 dark:text-surface-100"
|
|
614
2546
|
>
|
|
615
|
-
@
|
|
616
|
-
|
|
617
|
-
|
|
2547
|
+
@switch (v.summary.kind) {
|
|
2548
|
+
@case ('equation') {
|
|
2549
|
+
<mt-calculation-explanation-equation
|
|
2550
|
+
[segments]="v.equation"
|
|
2551
|
+
[result]="v.result"
|
|
2552
|
+
[resultOperator]="v.operator"
|
|
2553
|
+
/>
|
|
2554
|
+
}
|
|
2555
|
+
@case ('description') {
|
|
2556
|
+
<div class="flex flex-col gap-1">
|
|
2557
|
+
<span
|
|
2558
|
+
class="break-words"
|
|
2559
|
+
[class.font-mono]="v.descriptionIsCode"
|
|
2560
|
+
[attr.dir]="v.descriptionIsCode ? 'ltr' : null"
|
|
2561
|
+
>{{ v.description }}</span
|
|
2562
|
+
>
|
|
2563
|
+
<span>
|
|
2564
|
+
=
|
|
2565
|
+
<bdi class="font-semibold">{{ v.result }}</bdi>
|
|
2566
|
+
</span>
|
|
2567
|
+
</div>
|
|
2568
|
+
}
|
|
2569
|
+
@case ('message') {
|
|
2570
|
+
<span>{{ v.description }}</span>
|
|
2571
|
+
}
|
|
618
2572
|
}
|
|
619
|
-
<span class="font-semibold">{{ explanation.result }}</span>
|
|
620
2573
|
</div>
|
|
621
2574
|
<div class="text-xs text-surface-500 dark:text-surface-400">
|
|
622
|
-
{{
|
|
2575
|
+
{{
|
|
2576
|
+
prefix +
|
|
2577
|
+
(v.basis === 'currentCalculation'
|
|
2578
|
+
? '.currentCalculatedAt'
|
|
2579
|
+
: '.calculatedAt') | transloco
|
|
2580
|
+
}}
|
|
623
2581
|
<span dir="ltr" class="tabular-nums">{{
|
|
624
|
-
|
|
2582
|
+
v.calculatedAt | mtDateFormat: 'dateTime'
|
|
625
2583
|
}}</span>
|
|
626
2584
|
</div>
|
|
627
|
-
@if (
|
|
2585
|
+
@if (v.differs; as differs) {
|
|
2586
|
+
<div
|
|
2587
|
+
class="rounded-md border border-primary-200 bg-primary-50 px-3 py-2 text-xs text-primary-700"
|
|
2588
|
+
>
|
|
2589
|
+
{{ prefix + '.differsFromPage' | transloco: differs }}
|
|
2590
|
+
</div>
|
|
2591
|
+
}
|
|
2592
|
+
@if (v.definitionChanged) {
|
|
628
2593
|
<div
|
|
629
2594
|
class="rounded-md border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-700"
|
|
630
2595
|
>
|
|
631
2596
|
{{ prefix + '.definitionChanged' | transloco }}
|
|
632
2597
|
</div>
|
|
633
2598
|
}
|
|
634
|
-
@if (
|
|
2599
|
+
@if (v.refreshed) {
|
|
635
2600
|
<div
|
|
636
2601
|
class="rounded-md border border-primary-200 bg-primary-50 px-3 py-2 text-xs text-primary-700"
|
|
637
2602
|
>
|
|
638
2603
|
{{ prefix + '.valueRefreshed' | transloco }}
|
|
639
2604
|
</div>
|
|
640
2605
|
}
|
|
2606
|
+
@if (v.hasDetails) {
|
|
2607
|
+
<button
|
|
2608
|
+
type="button"
|
|
2609
|
+
class="self-start rounded-md text-xs font-medium text-primary-700 hover:underline focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-primary-500 dark:text-primary-300"
|
|
2610
|
+
[attr.aria-expanded]="expanded()"
|
|
2611
|
+
(click)="expanded.set(!expanded())"
|
|
2612
|
+
>
|
|
2613
|
+
{{
|
|
2614
|
+
prefix + (expanded() ? '.hideDetails' : '.showDetails')
|
|
2615
|
+
| transloco
|
|
2616
|
+
}}
|
|
2617
|
+
</button>
|
|
2618
|
+
@if (expanded()) {
|
|
2619
|
+
<mt-calculation-explanation-details [details]="v.details" />
|
|
2620
|
+
}
|
|
2621
|
+
}
|
|
641
2622
|
}
|
|
642
2623
|
}
|
|
643
2624
|
@case ('unavailable') {
|
|
@@ -661,6 +2642,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImpor
|
|
|
661
2642
|
`,
|
|
662
2643
|
}]
|
|
663
2644
|
}], ctorParameters: () => [], propDecorators: { target: [{ type: i0.Input, args: [{ isSignal: true, alias: "target", required: true }] }] } });
|
|
2645
|
+
function primitiveText(value) {
|
|
2646
|
+
return value === null || value === undefined || typeof value === 'object'
|
|
2647
|
+
? null
|
|
2648
|
+
: String(value);
|
|
2649
|
+
}
|
|
664
2650
|
/**
|
|
665
2651
|
* Whether the saved value is the one on screen. Both are the persisted string,
|
|
666
2652
|
* but a number may be written either way (`40` and `40.0`), so numbers compare
|
|
@@ -679,13 +2665,6 @@ function isSameSavedValue(saved, displayed) {
|
|
|
679
2665
|
const y = Number(b);
|
|
680
2666
|
return Number.isFinite(x) && Number.isFinite(y) && x === y;
|
|
681
2667
|
}
|
|
682
|
-
/** A captured value as plain text. Never formatted or rounded here. */
|
|
683
|
-
function formatExplanationValue(value) {
|
|
684
|
-
if (value === null || value === undefined) {
|
|
685
|
-
return '—';
|
|
686
|
-
}
|
|
687
|
-
return typeof value === 'object' ? JSON.stringify(value) : String(value);
|
|
688
|
-
}
|
|
689
2668
|
|
|
690
2669
|
const TOOLTIP_KEYS = {
|
|
691
2670
|
idle: 'components.entitiesPreview.calculatedValue',
|
|
@@ -698,23 +2677,23 @@ const EXPLAIN_TOOLTIP_KEY = 'components.entitiesPreview.explainCalculation';
|
|
|
698
2677
|
/** The calculated-value mark. Drawn, so it sits centred at any size. */
|
|
699
2678
|
class EntityCalculatedGlyph {
|
|
700
2679
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: EntityCalculatedGlyph, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
701
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "21.2.8", type: EntityCalculatedGlyph, isStandalone: true, selector: "mt-entity-calculated-glyph", host: { classAttribute: "block size-full" }, ngImport: i0, template: `
|
|
702
|
-
<svg
|
|
703
|
-
viewBox="0 0 16 16"
|
|
704
|
-
width="100%"
|
|
705
|
-
height="100%"
|
|
706
|
-
fill="none"
|
|
707
|
-
stroke="currentColor"
|
|
708
|
-
stroke-width="1.5"
|
|
709
|
-
stroke-linecap="round"
|
|
710
|
-
stroke-linejoin="round"
|
|
711
|
-
aria-hidden="true"
|
|
712
|
-
>
|
|
713
|
-
<path
|
|
714
|
-
d="M10.1 4.7c-.35-.42-.85-.62-1.38-.56-.87.1-1.4.76-1.57 1.66L6.1 11.3"
|
|
715
|
-
/>
|
|
716
|
-
<path d="M5.5 7.5h3.9" />
|
|
717
|
-
</svg>
|
|
2680
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "21.2.8", type: EntityCalculatedGlyph, isStandalone: true, selector: "mt-entity-calculated-glyph", host: { classAttribute: "block size-full" }, ngImport: i0, template: `
|
|
2681
|
+
<svg
|
|
2682
|
+
viewBox="0 0 16 16"
|
|
2683
|
+
width="100%"
|
|
2684
|
+
height="100%"
|
|
2685
|
+
fill="none"
|
|
2686
|
+
stroke="currentColor"
|
|
2687
|
+
stroke-width="1.5"
|
|
2688
|
+
stroke-linecap="round"
|
|
2689
|
+
stroke-linejoin="round"
|
|
2690
|
+
aria-hidden="true"
|
|
2691
|
+
>
|
|
2692
|
+
<path
|
|
2693
|
+
d="M10.1 4.7c-.35-.42-.85-.62-1.38-.56-.87.1-1.4.76-1.57 1.66L6.1 11.3"
|
|
2694
|
+
/>
|
|
2695
|
+
<path d="M5.5 7.5h3.9" />
|
|
2696
|
+
</svg>
|
|
718
2697
|
`, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
719
2698
|
}
|
|
720
2699
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: EntityCalculatedGlyph, decorators: [{
|
|
@@ -722,23 +2701,23 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImpor
|
|
|
722
2701
|
args: [{
|
|
723
2702
|
selector: 'mt-entity-calculated-glyph',
|
|
724
2703
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
725
|
-
template: `
|
|
726
|
-
<svg
|
|
727
|
-
viewBox="0 0 16 16"
|
|
728
|
-
width="100%"
|
|
729
|
-
height="100%"
|
|
730
|
-
fill="none"
|
|
731
|
-
stroke="currentColor"
|
|
732
|
-
stroke-width="1.5"
|
|
733
|
-
stroke-linecap="round"
|
|
734
|
-
stroke-linejoin="round"
|
|
735
|
-
aria-hidden="true"
|
|
736
|
-
>
|
|
737
|
-
<path
|
|
738
|
-
d="M10.1 4.7c-.35-.42-.85-.62-1.38-.56-.87.1-1.4.76-1.57 1.66L6.1 11.3"
|
|
739
|
-
/>
|
|
740
|
-
<path d="M5.5 7.5h3.9" />
|
|
741
|
-
</svg>
|
|
2704
|
+
template: `
|
|
2705
|
+
<svg
|
|
2706
|
+
viewBox="0 0 16 16"
|
|
2707
|
+
width="100%"
|
|
2708
|
+
height="100%"
|
|
2709
|
+
fill="none"
|
|
2710
|
+
stroke="currentColor"
|
|
2711
|
+
stroke-width="1.5"
|
|
2712
|
+
stroke-linecap="round"
|
|
2713
|
+
stroke-linejoin="round"
|
|
2714
|
+
aria-hidden="true"
|
|
2715
|
+
>
|
|
2716
|
+
<path
|
|
2717
|
+
d="M10.1 4.7c-.35-.42-.85-.62-1.38-.56-.87.1-1.4.76-1.57 1.66L6.1 11.3"
|
|
2718
|
+
/>
|
|
2719
|
+
<path d="M5.5 7.5h3.9" />
|
|
2720
|
+
</svg>
|
|
742
2721
|
`,
|
|
743
2722
|
host: {
|
|
744
2723
|
class: 'block size-full',
|
|
@@ -785,62 +2764,62 @@ class EntityCalculatedIndicator {
|
|
|
785
2764
|
this.popover()?.toggle(event);
|
|
786
2765
|
}
|
|
787
2766
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: EntityCalculatedIndicator, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
788
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.8", type: EntityCalculatedIndicator, isStandalone: true, selector: "mt-entity-calculated-indicator", inputs: { status: { classPropertyName: "status", publicName: "status", isSignal: true, isRequired: false, transformFunction: null }, change: { classPropertyName: "change", publicName: "change", isSignal: true, isRequired: false, transformFunction: null }, explanation: { classPropertyName: "explanation", publicName: "explanation", isSignal: true, isRequired: false, transformFunction: null } }, host: { classAttribute: "inline-flex shrink-0" }, viewQueries: [{ propertyName: "popover", first: true, predicate: Popover, descendants: true, isSignal: true }], ngImport: i0, template: `
|
|
789
|
-
<ng-template #mark>
|
|
790
|
-
@if (pulsing()) {
|
|
791
|
-
<span
|
|
792
|
-
class="absolute inset-0 animate-ping rounded-full bg-primary-700 opacity-60 motion-reduce:animate-none"
|
|
793
|
-
aria-hidden="true"
|
|
794
|
-
></span>
|
|
795
|
-
}
|
|
796
|
-
<mt-entity-calculated-glyph class="relative" />
|
|
797
|
-
</ng-template>
|
|
798
|
-
|
|
799
|
-
@if (explanation(); as target) {
|
|
800
|
-
<button
|
|
801
|
-
type="button"
|
|
802
|
-
class="relative inline-flex size-4 cursor-pointer items-center justify-center rounded-full select-none focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-primary-500"
|
|
803
|
-
[class]="
|
|
804
|
-
status()
|
|
805
|
-
? 'bg-primary-700 text-white'
|
|
806
|
-
: 'bg-surface-100 text-surface-500 hover:bg-primary-100 hover:text-primary-700 dark:bg-surface-800 dark:text-surface-300'
|
|
807
|
-
"
|
|
808
|
-
[attr.aria-label]="tooltipKey() | transloco: tooltipParams()"
|
|
809
|
-
aria-haspopup="dialog"
|
|
810
|
-
[mtTooltip]="tooltipKey() | transloco: tooltipParams()"
|
|
811
|
-
tooltipPosition="top"
|
|
812
|
-
(click)="toggle($event)"
|
|
813
|
-
>
|
|
814
|
-
<ng-container [ngTemplateOutlet]="mark" />
|
|
815
|
-
</button>
|
|
816
|
-
<!-- Projected content is created with this view even while the popover
|
|
817
|
-
is closed, so the explanation is gated on the open state: it reads
|
|
818
|
-
its value when opened, not when the page loads. -->
|
|
819
|
-
<p-popover
|
|
820
|
-
appendTo="body"
|
|
821
|
-
(onShow)="opened.set(true)"
|
|
822
|
-
(onHide)="opened.set(false)"
|
|
823
|
-
>
|
|
824
|
-
@if (opened()) {
|
|
825
|
-
<mt-entity-calculation-explanation [target]="target" />
|
|
826
|
-
}
|
|
827
|
-
</p-popover>
|
|
828
|
-
} @else {
|
|
829
|
-
<span
|
|
830
|
-
class="relative inline-flex size-4 cursor-help items-center justify-center rounded-full select-none"
|
|
831
|
-
[class]="
|
|
832
|
-
status()
|
|
833
|
-
? 'bg-primary-700 text-white'
|
|
834
|
-
: 'bg-surface-100 text-surface-500 dark:bg-surface-800 dark:text-surface-300'
|
|
835
|
-
"
|
|
836
|
-
role="img"
|
|
837
|
-
[attr.aria-label]="tooltipKey() | transloco: tooltipParams()"
|
|
838
|
-
[mtTooltip]="tooltipKey() | transloco: tooltipParams()"
|
|
839
|
-
tooltipPosition="top"
|
|
840
|
-
>
|
|
841
|
-
<ng-container [ngTemplateOutlet]="mark" />
|
|
842
|
-
</span>
|
|
843
|
-
}
|
|
2767
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.8", type: EntityCalculatedIndicator, isStandalone: true, selector: "mt-entity-calculated-indicator", inputs: { status: { classPropertyName: "status", publicName: "status", isSignal: true, isRequired: false, transformFunction: null }, change: { classPropertyName: "change", publicName: "change", isSignal: true, isRequired: false, transformFunction: null }, explanation: { classPropertyName: "explanation", publicName: "explanation", isSignal: true, isRequired: false, transformFunction: null } }, host: { classAttribute: "inline-flex shrink-0" }, viewQueries: [{ propertyName: "popover", first: true, predicate: Popover, descendants: true, isSignal: true }], ngImport: i0, template: `
|
|
2768
|
+
<ng-template #mark>
|
|
2769
|
+
@if (pulsing()) {
|
|
2770
|
+
<span
|
|
2771
|
+
class="absolute inset-0 animate-ping rounded-full bg-primary-700 opacity-60 motion-reduce:animate-none"
|
|
2772
|
+
aria-hidden="true"
|
|
2773
|
+
></span>
|
|
2774
|
+
}
|
|
2775
|
+
<mt-entity-calculated-glyph class="relative" />
|
|
2776
|
+
</ng-template>
|
|
2777
|
+
|
|
2778
|
+
@if (explanation(); as target) {
|
|
2779
|
+
<button
|
|
2780
|
+
type="button"
|
|
2781
|
+
class="relative inline-flex size-4 cursor-pointer items-center justify-center rounded-full select-none focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-primary-500"
|
|
2782
|
+
[class]="
|
|
2783
|
+
status()
|
|
2784
|
+
? 'bg-primary-700 text-white'
|
|
2785
|
+
: 'bg-surface-100 text-surface-500 hover:bg-primary-100 hover:text-primary-700 dark:bg-surface-800 dark:text-surface-300'
|
|
2786
|
+
"
|
|
2787
|
+
[attr.aria-label]="tooltipKey() | transloco: tooltipParams()"
|
|
2788
|
+
aria-haspopup="dialog"
|
|
2789
|
+
[mtTooltip]="tooltipKey() | transloco: tooltipParams()"
|
|
2790
|
+
tooltipPosition="top"
|
|
2791
|
+
(click)="toggle($event)"
|
|
2792
|
+
>
|
|
2793
|
+
<ng-container [ngTemplateOutlet]="mark" />
|
|
2794
|
+
</button>
|
|
2795
|
+
<!-- Projected content is created with this view even while the popover
|
|
2796
|
+
is closed, so the explanation is gated on the open state: it reads
|
|
2797
|
+
its value when opened, not when the page loads. -->
|
|
2798
|
+
<p-popover
|
|
2799
|
+
appendTo="body"
|
|
2800
|
+
(onShow)="opened.set(true)"
|
|
2801
|
+
(onHide)="opened.set(false)"
|
|
2802
|
+
>
|
|
2803
|
+
@if (opened()) {
|
|
2804
|
+
<mt-entity-calculation-explanation [target]="target" />
|
|
2805
|
+
}
|
|
2806
|
+
</p-popover>
|
|
2807
|
+
} @else {
|
|
2808
|
+
<span
|
|
2809
|
+
class="relative inline-flex size-4 cursor-help items-center justify-center rounded-full select-none"
|
|
2810
|
+
[class]="
|
|
2811
|
+
status()
|
|
2812
|
+
? 'bg-primary-700 text-white'
|
|
2813
|
+
: 'bg-surface-100 text-surface-500 dark:bg-surface-800 dark:text-surface-300'
|
|
2814
|
+
"
|
|
2815
|
+
role="img"
|
|
2816
|
+
[attr.aria-label]="tooltipKey() | transloco: tooltipParams()"
|
|
2817
|
+
[mtTooltip]="tooltipKey() | transloco: tooltipParams()"
|
|
2818
|
+
tooltipPosition="top"
|
|
2819
|
+
>
|
|
2820
|
+
<ng-container [ngTemplateOutlet]="mark" />
|
|
2821
|
+
</span>
|
|
2822
|
+
}
|
|
844
2823
|
`, isInline: true, dependencies: [{ kind: "component", type: EntityCalculatedGlyph, selector: "mt-entity-calculated-glyph" }, { kind: "component", type: EntityCalculationExplanation, selector: "mt-entity-calculation-explanation", inputs: ["target"] }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "component", type: Popover, selector: "p-popover", inputs: ["ariaLabel", "ariaLabelledBy", "dismissable", "style", "styleClass", "appendTo", "autoZIndex", "ariaCloseLabel", "baseZIndex", "focusOnShow", "showTransitionOptions", "hideTransitionOptions", "motionOptions"], outputs: ["onShow", "onHide"] }, { kind: "directive", type: Tooltip, selector: "[mtTooltip]" }, { kind: "pipe", type: TranslocoPipe, name: "transloco" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
845
2824
|
}
|
|
846
2825
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: EntityCalculatedIndicator, decorators: [{
|
|
@@ -856,62 +2835,62 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImpor
|
|
|
856
2835
|
Tooltip,
|
|
857
2836
|
TranslocoPipe,
|
|
858
2837
|
],
|
|
859
|
-
template: `
|
|
860
|
-
<ng-template #mark>
|
|
861
|
-
@if (pulsing()) {
|
|
862
|
-
<span
|
|
863
|
-
class="absolute inset-0 animate-ping rounded-full bg-primary-700 opacity-60 motion-reduce:animate-none"
|
|
864
|
-
aria-hidden="true"
|
|
865
|
-
></span>
|
|
866
|
-
}
|
|
867
|
-
<mt-entity-calculated-glyph class="relative" />
|
|
868
|
-
</ng-template>
|
|
869
|
-
|
|
870
|
-
@if (explanation(); as target) {
|
|
871
|
-
<button
|
|
872
|
-
type="button"
|
|
873
|
-
class="relative inline-flex size-4 cursor-pointer items-center justify-center rounded-full select-none focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-primary-500"
|
|
874
|
-
[class]="
|
|
875
|
-
status()
|
|
876
|
-
? 'bg-primary-700 text-white'
|
|
877
|
-
: 'bg-surface-100 text-surface-500 hover:bg-primary-100 hover:text-primary-700 dark:bg-surface-800 dark:text-surface-300'
|
|
878
|
-
"
|
|
879
|
-
[attr.aria-label]="tooltipKey() | transloco: tooltipParams()"
|
|
880
|
-
aria-haspopup="dialog"
|
|
881
|
-
[mtTooltip]="tooltipKey() | transloco: tooltipParams()"
|
|
882
|
-
tooltipPosition="top"
|
|
883
|
-
(click)="toggle($event)"
|
|
884
|
-
>
|
|
885
|
-
<ng-container [ngTemplateOutlet]="mark" />
|
|
886
|
-
</button>
|
|
887
|
-
<!-- Projected content is created with this view even while the popover
|
|
888
|
-
is closed, so the explanation is gated on the open state: it reads
|
|
889
|
-
its value when opened, not when the page loads. -->
|
|
890
|
-
<p-popover
|
|
891
|
-
appendTo="body"
|
|
892
|
-
(onShow)="opened.set(true)"
|
|
893
|
-
(onHide)="opened.set(false)"
|
|
894
|
-
>
|
|
895
|
-
@if (opened()) {
|
|
896
|
-
<mt-entity-calculation-explanation [target]="target" />
|
|
897
|
-
}
|
|
898
|
-
</p-popover>
|
|
899
|
-
} @else {
|
|
900
|
-
<span
|
|
901
|
-
class="relative inline-flex size-4 cursor-help items-center justify-center rounded-full select-none"
|
|
902
|
-
[class]="
|
|
903
|
-
status()
|
|
904
|
-
? 'bg-primary-700 text-white'
|
|
905
|
-
: 'bg-surface-100 text-surface-500 dark:bg-surface-800 dark:text-surface-300'
|
|
906
|
-
"
|
|
907
|
-
role="img"
|
|
908
|
-
[attr.aria-label]="tooltipKey() | transloco: tooltipParams()"
|
|
909
|
-
[mtTooltip]="tooltipKey() | transloco: tooltipParams()"
|
|
910
|
-
tooltipPosition="top"
|
|
911
|
-
>
|
|
912
|
-
<ng-container [ngTemplateOutlet]="mark" />
|
|
913
|
-
</span>
|
|
914
|
-
}
|
|
2838
|
+
template: `
|
|
2839
|
+
<ng-template #mark>
|
|
2840
|
+
@if (pulsing()) {
|
|
2841
|
+
<span
|
|
2842
|
+
class="absolute inset-0 animate-ping rounded-full bg-primary-700 opacity-60 motion-reduce:animate-none"
|
|
2843
|
+
aria-hidden="true"
|
|
2844
|
+
></span>
|
|
2845
|
+
}
|
|
2846
|
+
<mt-entity-calculated-glyph class="relative" />
|
|
2847
|
+
</ng-template>
|
|
2848
|
+
|
|
2849
|
+
@if (explanation(); as target) {
|
|
2850
|
+
<button
|
|
2851
|
+
type="button"
|
|
2852
|
+
class="relative inline-flex size-4 cursor-pointer items-center justify-center rounded-full select-none focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-primary-500"
|
|
2853
|
+
[class]="
|
|
2854
|
+
status()
|
|
2855
|
+
? 'bg-primary-700 text-white'
|
|
2856
|
+
: 'bg-surface-100 text-surface-500 hover:bg-primary-100 hover:text-primary-700 dark:bg-surface-800 dark:text-surface-300'
|
|
2857
|
+
"
|
|
2858
|
+
[attr.aria-label]="tooltipKey() | transloco: tooltipParams()"
|
|
2859
|
+
aria-haspopup="dialog"
|
|
2860
|
+
[mtTooltip]="tooltipKey() | transloco: tooltipParams()"
|
|
2861
|
+
tooltipPosition="top"
|
|
2862
|
+
(click)="toggle($event)"
|
|
2863
|
+
>
|
|
2864
|
+
<ng-container [ngTemplateOutlet]="mark" />
|
|
2865
|
+
</button>
|
|
2866
|
+
<!-- Projected content is created with this view even while the popover
|
|
2867
|
+
is closed, so the explanation is gated on the open state: it reads
|
|
2868
|
+
its value when opened, not when the page loads. -->
|
|
2869
|
+
<p-popover
|
|
2870
|
+
appendTo="body"
|
|
2871
|
+
(onShow)="opened.set(true)"
|
|
2872
|
+
(onHide)="opened.set(false)"
|
|
2873
|
+
>
|
|
2874
|
+
@if (opened()) {
|
|
2875
|
+
<mt-entity-calculation-explanation [target]="target" />
|
|
2876
|
+
}
|
|
2877
|
+
</p-popover>
|
|
2878
|
+
} @else {
|
|
2879
|
+
<span
|
|
2880
|
+
class="relative inline-flex size-4 cursor-help items-center justify-center rounded-full select-none"
|
|
2881
|
+
[class]="
|
|
2882
|
+
status()
|
|
2883
|
+
? 'bg-primary-700 text-white'
|
|
2884
|
+
: 'bg-surface-100 text-surface-500 dark:bg-surface-800 dark:text-surface-300'
|
|
2885
|
+
"
|
|
2886
|
+
role="img"
|
|
2887
|
+
[attr.aria-label]="tooltipKey() | transloco: tooltipParams()"
|
|
2888
|
+
[mtTooltip]="tooltipKey() | transloco: tooltipParams()"
|
|
2889
|
+
tooltipPosition="top"
|
|
2890
|
+
>
|
|
2891
|
+
<ng-container [ngTemplateOutlet]="mark" />
|
|
2892
|
+
</span>
|
|
2893
|
+
}
|
|
915
2894
|
`,
|
|
916
2895
|
host: {
|
|
917
2896
|
class: 'inline-flex shrink-0',
|
|
@@ -919,34 +2898,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImpor
|
|
|
919
2898
|
}]
|
|
920
2899
|
}], propDecorators: { status: [{ type: i0.Input, args: [{ isSignal: true, alias: "status", required: false }] }], change: [{ type: i0.Input, args: [{ isSignal: true, alias: "change", required: false }] }], explanation: [{ type: i0.Input, args: [{ isSignal: true, alias: "explanation", required: false }] }], popover: [{ type: i0.ViewChild, args: [i0.forwardRef(() => Popover), { isSignal: true }] }] } });
|
|
921
2900
|
|
|
922
|
-
/**
|
|
923
|
-
* One shared active-language signal per `TranslocoService`.
|
|
924
|
-
*
|
|
925
|
-
* `mt-entity-preview` renders once per property per record — a client-list card
|
|
926
|
-
* grid mounts thousands of them — so a `toSignal(langChanges$)` inside each
|
|
927
|
-
* instance would open thousands of subscriptions to the same Subject just to
|
|
928
|
-
* read one global value. The language is global, so the signal is too: created
|
|
929
|
-
* once, cached against the service, and shared by every entity that needs it.
|
|
930
|
-
*
|
|
931
|
-
* `manualCleanup` is deliberate. The cached signal outlives any single
|
|
932
|
-
* component by design, and the service it hangs off is the root injector's —
|
|
933
|
-
* tying its subscription to whichever entity happened to ask first would tear
|
|
934
|
-
* it down the moment that entity scrolled out of view.
|
|
935
|
-
*/
|
|
936
|
-
const langSignals = new WeakMap();
|
|
937
|
-
function sharedActiveLang(transloco) {
|
|
938
|
-
const cached = langSignals.get(transloco);
|
|
939
|
-
if (cached) {
|
|
940
|
-
return cached;
|
|
941
|
-
}
|
|
942
|
-
const lang = toSignal(transloco.langChanges$, {
|
|
943
|
-
initialValue: transloco.getActiveLang(),
|
|
944
|
-
manualCleanup: true,
|
|
945
|
-
});
|
|
946
|
-
langSignals.set(transloco, lang);
|
|
947
|
-
return lang;
|
|
948
|
-
}
|
|
949
|
-
|
|
950
2901
|
/**
|
|
951
2902
|
* The largest amount still rendered in full.
|
|
952
2903
|
*
|
|
@@ -4400,7 +6351,8 @@ const CALCULATION_CHANGE_CHIP_MS = 30_000;
|
|
|
4400
6351
|
* Whether a surface marks this property as calculated. `isCalculated` alone is
|
|
4401
6352
|
* too broad: the backend also sets it, with no calculation method, on system
|
|
4402
6353
|
* columns such as `created_at`, `id` and `team_members`. A status has no method
|
|
4403
|
-
* but is recalculated
|
|
6354
|
+
* but is recalculated. An auto code is generated rather than recalculated, but
|
|
6355
|
+
* the backend explains it like any calculated value, so it is marked too.
|
|
4404
6356
|
*/
|
|
4405
6357
|
function isCalculatedProperty(meta) {
|
|
4406
6358
|
if (!meta) {
|
|
@@ -4409,9 +6361,7 @@ function isCalculatedProperty(meta) {
|
|
|
4409
6361
|
if (meta.viewType === 'Status') {
|
|
4410
6362
|
return true;
|
|
4411
6363
|
}
|
|
4412
|
-
return
|
|
4413
|
-
!!meta.calculationMethod &&
|
|
4414
|
-
meta.calculationMethod !== 'CodeBuilder');
|
|
6364
|
+
return meta.isCalculated === true && !!meta.calculationMethod;
|
|
4415
6365
|
}
|
|
4416
6366
|
const EMPTY_CHANGES = new Map();
|
|
4417
6367
|
const historyKey = (scope, recordId, propertyKey) => `${scope}|${recordId}|${propertyKey}`;
|
|
@@ -5065,5 +7015,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImpor
|
|
|
5065
7015
|
* Generated bundle index. Do not edit.
|
|
5066
7016
|
*/
|
|
5067
7017
|
|
|
5068
|
-
export { CALCULATION_CHANGE_CHIP_MS, CONNECTION_KEY_SEPARATOR, CURRENCY_COMPACT_THRESHOLD, CalculatedValueHistory, CalculationExplanationApi, 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, PERFORMANCE_SCORE_CHART_SIZES, SECTION_KEY_PREFIX, buildConnectionKey, buildDisplayEntities, buildEntityListRows, buildSectionKey, canEntityBeHeader, compactCurrencyDisplay, currencyUnitOf, describeCalculationChange, displayOrPlaceholder, expandConnectionEntity, expandLeafDetailsEntity, extractDisplayText, formatCalculationDelta, formatExplanationValue, getEntitySectionTitle, getPerformanceScoreBands, groupEntitiesIntoSections, humanizeEntityListKey, isCalculatedProperty, isConnectionSyntheticKey, isEntityAlignEnd, isEntityHeader, isEntityLabelHidden, isEntityListLocalDocument, isEntityListSelectionDocument, isEntitySection, isLeafDetailsCatalogConfiguration, isLeafDetailsCollectionValue, isLeafDetailsRuntimeValue, isLeafDetailsSyntheticKey, isLeafDetailsValue, isLeafPhasesSyntheticKey, isLeafSyntheticKey, isSameSavedValue, isSectionKey, isValueMissing, localCellsByFieldId, matchesPercentageColorRule, mergeStakeholderNameColumns, mergeStakeholderNameEntities, mergeStakeholderNameRows, normalizeConnectionSourceLevels, normalizeNumerals, parseCurrencyAmount, parsePerformanceScore, pinEntityHeaderFirst, readEntityHeaderDefaults, readEntityValueColor, resolveConnectionLevelName, resolveEntityGridRow, resolveEntityHeader, resolveEntityInfo, resolveEntityLabelPosition, resolveLocalFieldConfiguration, resolveLocalFieldLabel, resolveLocalFieldViewType, resolveLocalizedLabel, resolvePercentageColor, resolvePerformanceScoreStatus, serializeEntityRawValue, sharedActiveLang, sortLocalRows, splitConnectionKey, splitLeafKey, summarizeEntityListRows, toCalculationContextKey, toCalculationExplanationTarget, visibleLocalSchemaFields };
|
|
7018
|
+
export { CALCULATION_CHANGE_CHIP_MS, CALCULATION_EXPLANATION_KEYS, CONNECTION_KEY_SEPARATOR, CURRENCY_COMPACT_THRESHOLD, CalculatedValueHistory, CalculationExplanationApi, CalculationExplanationDetails, CalculationExplanationEquation, 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, PERFORMANCE_SCORE_CHART_SIZES, SECTION_KEY_PREFIX, buildCodeSegments, buildConnectionKey, buildDisplayEntities, buildEntityListRows, buildExplanationDetails, buildExplanationSegments, buildSectionKey, canEntityBeHeader, compactCurrencyDisplay, currencyUnitOf, describeCalculationChange, 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, isSameSavedValue, isSectionKey, isValueMissing, localCellsByFieldId, matchesPercentageColorRule, mergeStakeholderNameColumns, mergeStakeholderNameEntities, mergeStakeholderNameRows, normalizeConnectionSourceLevels, normalizeNumerals, parseCurrencyAmount, parsePerformanceScore, pinEntityHeaderFirst, readEntityHeaderDefaults, readEntityValueColor, resolveConnectionLevelName, resolveEntityGridRow, resolveEntityHeader, resolveEntityInfo, resolveEntityLabelPosition, resolveLocalFieldConfiguration, resolveLocalFieldLabel, resolveLocalFieldViewType, resolveLocalizedLabel, resolvePercentageColor, resolvePerformanceScoreStatus, selectedStatusRule, serializeEntityRawValue, sharedActiveLang, sortLocalRows, splitConnectionKey, splitLeafKey, statusName, summarizeEntityListRows, tableLabel, toCalculationContextKey, toCalculationExplanationTarget, toExplanationData, visibleLocalSchemaFields };
|
|
5069
7019
|
//# sourceMappingURL=masterteam-components-entities.mjs.map
|