@maro-tech/card 0.2.7 → 0.2.8
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.
|
@@ -9,7 +9,7 @@ import { DomSanitizer } from '@angular/platform-browser';
|
|
|
9
9
|
import Panzoom from '@panzoom/panzoom';
|
|
10
10
|
import { LucideDownload, LucideDynamicIcon, LucideEye, LucideFileText, LucidePlus, LucideSparkles, LucideTrash } from '@lucide/angular';
|
|
11
11
|
import { HttpClient, HttpParams, HttpHeaders } from '@angular/common/http';
|
|
12
|
-
import { map, shareReplay, forkJoin, switchMap, timer, of
|
|
12
|
+
import { map, shareReplay, forkJoin, switchMap, timer, of } from 'rxjs';
|
|
13
13
|
import { UiTableComponent, UiPaginatorComponent } from '@maro-tech/table';
|
|
14
14
|
import { ActivatedRoute, Router, RouterLink } from '@angular/router';
|
|
15
15
|
import { map as map$1, exhaustMap, catchError, takeWhile, takeUntil, finalize } from 'rxjs/operators';
|
|
@@ -1623,7 +1623,6 @@ class HistoryTabComponent {
|
|
|
1623
1623
|
destroyRef = inject(DestroyRef);
|
|
1624
1624
|
refreshSequence = signal(0, ...(ngDevMode ? [{ debugName: "refreshSequence" }] : /* istanbul ignore next */ []));
|
|
1625
1625
|
lastRequestKey = '';
|
|
1626
|
-
dictionaryCache = new Map();
|
|
1627
1626
|
constructor() {
|
|
1628
1627
|
this.eventBus.on(ENTITY_UPDATED)
|
|
1629
1628
|
.pipe(takeUntilDestroyed(this.destroyRef))
|
|
@@ -1749,8 +1748,8 @@ class HistoryTabComponent {
|
|
|
1749
1748
|
label: config.label || field,
|
|
1750
1749
|
type: config.type || 'text',
|
|
1751
1750
|
summary: values.summary,
|
|
1752
|
-
from: await this.toDisplayValue(values.from, config),
|
|
1753
|
-
to: await this.toDisplayValue(values.to, config),
|
|
1751
|
+
from: await this.toDisplayValue(values.from, config, values.from_data),
|
|
1752
|
+
to: await this.toDisplayValue(values.to, config, values.to_data),
|
|
1754
1753
|
};
|
|
1755
1754
|
}
|
|
1756
1755
|
return { ...change, changedFields };
|
|
@@ -1764,6 +1763,8 @@ class HistoryTabComponent {
|
|
|
1764
1763
|
return [key, {
|
|
1765
1764
|
from: from && typeof from === 'object' && 'value' in from ? from.value : from,
|
|
1766
1765
|
to: to && typeof to === 'object' && 'value' in to ? to.value : to,
|
|
1766
|
+
from_data: field?.from_data,
|
|
1767
|
+
to_data: field?.to_data,
|
|
1767
1768
|
summary: typeof field?.changeSummary === 'string' ? field.changeSummary : undefined,
|
|
1768
1769
|
}];
|
|
1769
1770
|
}));
|
|
@@ -1778,10 +1779,10 @@ class HistoryTabComponent {
|
|
|
1778
1779
|
}
|
|
1779
1780
|
return undefined;
|
|
1780
1781
|
}
|
|
1781
|
-
async toDisplayValue(value, config) {
|
|
1782
|
+
async toDisplayValue(value, config, data) {
|
|
1782
1783
|
const display = config.type === 'boolean' && value !== null && value !== undefined && value !== ''
|
|
1783
1784
|
? (value === true || value === 'true' || value === 1 ? 'Так' : 'Ні')
|
|
1784
|
-
: await this.resolveDisplay(value, config);
|
|
1785
|
+
: await this.resolveDisplay(value, config, data);
|
|
1785
1786
|
const structured = config.displayMode === 'structured' ? await this.toStructuredItems(value, config.itemFields) : undefined;
|
|
1786
1787
|
const result = {
|
|
1787
1788
|
value: value ?? null,
|
|
@@ -1794,23 +1795,24 @@ class HistoryTabComponent {
|
|
|
1794
1795
|
result.url = `/api/files/${encodeURIComponent(String(value))}`;
|
|
1795
1796
|
return result;
|
|
1796
1797
|
}
|
|
1797
|
-
async resolveDisplay(value, config) {
|
|
1798
|
+
async resolveDisplay(value, config, data) {
|
|
1798
1799
|
if (value === null || value === undefined || value === '')
|
|
1799
1800
|
return 'Не задано';
|
|
1801
|
+
const dataLabel = this.getDataLabel(data);
|
|
1802
|
+
if (dataLabel !== null)
|
|
1803
|
+
return dataLabel;
|
|
1800
1804
|
const values = Array.isArray(value) ? value : [value];
|
|
1801
|
-
return
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
const
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
this.dictionaryCache.set(cacheKey, request);
|
|
1813
|
-
return request;
|
|
1805
|
+
return values
|
|
1806
|
+
.filter((item) => item !== null && item !== undefined && item !== '')
|
|
1807
|
+
.map((item) => typeof item === 'object' ? JSON.stringify(item) : String(item))
|
|
1808
|
+
.filter(Boolean).join(', ') || 'Не задано';
|
|
1809
|
+
}
|
|
1810
|
+
getDataLabel(data) {
|
|
1811
|
+
const values = Array.isArray(data) ? data : [data];
|
|
1812
|
+
const labels = values
|
|
1813
|
+
.map((item) => item && typeof item === 'object' && 'label' in item ? String(item.label ?? '') : '')
|
|
1814
|
+
.filter(Boolean);
|
|
1815
|
+
return labels.length ? labels.join(', ') : null;
|
|
1814
1816
|
}
|
|
1815
1817
|
async toStructuredItems(value, itemFields) {
|
|
1816
1818
|
const values = Array.isArray(value) ? value : value && typeof value === 'object' ? [value] : [];
|
|
@@ -1831,7 +1833,8 @@ class HistoryTabComponent {
|
|
|
1831
1833
|
if (value === null || value === undefined || value === '' || seenLabels.has(label))
|
|
1832
1834
|
return null;
|
|
1833
1835
|
seenLabels.add(label);
|
|
1834
|
-
const display =
|
|
1836
|
+
const display = this.getDataLabel(record[`${key}_data`])
|
|
1837
|
+
|| (typeof value === 'object' ? JSON.stringify(value) : String(value));
|
|
1835
1838
|
return { key, label, value, display };
|
|
1836
1839
|
}))).filter((field) => field !== null),
|
|
1837
1840
|
};
|