@masterteam/components 0.0.305 → 0.0.306
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 +11 -1
- package/assets/i18n/en.json +11 -1
- package/fesm2022/masterteam-components-business-fields.mjs +212 -36
- package/fesm2022/masterteam-components-business-fields.mjs.map +1 -1
- package/package.json +1 -1
- package/types/masterteam-components-business-fields.d.ts +90 -5
package/assets/i18n/ar.json
CHANGED
|
@@ -147,7 +147,17 @@
|
|
|
147
147
|
"preservedAt": "التُقطت في {{date}}",
|
|
148
148
|
"noPreservedSnapshot": "لا توجد لقطة محفوظة بعد.",
|
|
149
149
|
"preservedEmpty": "القائمة المحفوظة فارغة.",
|
|
150
|
-
"unavailableRecords": "{{count}} من السجلات المحفوظة لم تعد متاحة."
|
|
150
|
+
"unavailableRecords": "{{count}} من السجلات المحفوظة لم تعد متاحة.",
|
|
151
|
+
"revisions": "مراجعات القائمة المحفوظة",
|
|
152
|
+
"revisionsHint": "كل حفظ ناجح لهذه القائمة. لا تظهر هنا التغييرات التي تتم مباشرة على سجلات المصدر.",
|
|
153
|
+
"revisionLabel": "المراجعة {{version}}",
|
|
154
|
+
"noRevisions": "لا توجد مراجعات محفوظة بعد.",
|
|
155
|
+
"viewingRevision": "عرض المراجعة {{version}}",
|
|
156
|
+
"backToLatest": "العودة إلى الأحدث",
|
|
157
|
+
"revisionsLoadFailed": "تعذر تحميل المراجعات المحفوظة.",
|
|
158
|
+
"revisionSourceChanged": "حُفظت هذه المراجعة بمصدر مختلف، لذا لا يمكن مقارنتها بالقيم الحالية.",
|
|
159
|
+
"revisionNotFound": "هذه المراجعة لم تعد متاحة.",
|
|
160
|
+
"unknownUser": "مستخدم غير معروف"
|
|
151
161
|
},
|
|
152
162
|
"entityListPreview": {
|
|
153
163
|
"view": "عرض القائمة",
|
package/assets/i18n/en.json
CHANGED
|
@@ -147,7 +147,17 @@
|
|
|
147
147
|
"preservedAt": "Captured {{date}}",
|
|
148
148
|
"noPreservedSnapshot": "No preserved snapshot yet.",
|
|
149
149
|
"preservedEmpty": "The preserved list is empty.",
|
|
150
|
-
"unavailableRecords": "{{count}} saved record(s) are no longer available."
|
|
150
|
+
"unavailableRecords": "{{count}} saved record(s) are no longer available.",
|
|
151
|
+
"revisions": "Saved list revisions",
|
|
152
|
+
"revisionsHint": "Each successful save of this list. Changes made directly to the source records are not listed.",
|
|
153
|
+
"revisionLabel": "Revision {{version}}",
|
|
154
|
+
"noRevisions": "No saved revisions yet.",
|
|
155
|
+
"viewingRevision": "Viewing revision {{version}}",
|
|
156
|
+
"backToLatest": "Back to latest",
|
|
157
|
+
"revisionsLoadFailed": "Could not load the saved revisions.",
|
|
158
|
+
"revisionSourceChanged": "This revision was saved with a different source, so it cannot be compared with today's values.",
|
|
159
|
+
"revisionNotFound": "This revision is no longer available.",
|
|
160
|
+
"unknownUser": "Unknown user"
|
|
151
161
|
},
|
|
152
162
|
"entityListPreview": {
|
|
153
163
|
"view": "View list",
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as i1$1 from '@angular/common';
|
|
1
2
|
import { CommonModule, NgComponentOutlet } from '@angular/common';
|
|
2
3
|
import * as i0 from '@angular/core';
|
|
3
4
|
import { input, inject, DestroyRef, signal, computed, ChangeDetectionStrategy, Component, ChangeDetectorRef, effect, untracked, viewChild, linkedSignal, InjectionToken } from '@angular/core';
|
|
@@ -1244,6 +1245,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImpor
|
|
|
1244
1245
|
], changeDetection: ChangeDetectionStrategy.OnPush, template: "<div [class]=\"modal.contentClass + ' flex max-h-[70vh] flex-col gap-3 p-4'\">\r\n <mt-text-field\r\n [formControl]=\"searchControl\"\r\n icon=\"general.search-md\"\r\n [placeholder]=\"'components.entityListField.searchRecords' | transloco\"\r\n />\r\n\r\n @if (multiple()) {\r\n <p\r\n class=\"text-xs\"\r\n [class.text-muted-color]=\"!atLimit()\"\r\n [class.text-amber-700]=\"atLimit()\"\r\n >\r\n {{\r\n (atLimit()\r\n ? \"components.entityListField.selectionLimit\"\r\n : \"components.entityListField.selectedCount\"\r\n ) | transloco: { count: pickedCount(), max: maxSelections }\r\n }}\r\n </p>\r\n }\r\n\r\n @if (failureKey(); as failure) {\r\n <div\r\n class=\"rounded-md border border-red-200 bg-red-50 p-3 text-sm text-red-700\"\r\n >\r\n {{ failure | transloco }}\r\n </div>\r\n } @else {\r\n <div\r\n class=\"flex min-h-40 flex-col gap-1 overflow-y-auto\"\r\n role=\"listbox\"\r\n [attr.aria-multiselectable]=\"multiple()\"\r\n >\r\n @for (item of items(); track item.id) {\r\n @let chosen = isPicked(item.id);\r\n <button\r\n type=\"button\"\r\n role=\"option\"\r\n [attr.aria-selected]=\"chosen\"\r\n [disabled]=\"!chosen && atLimit()\"\r\n class=\"flex w-full items-center gap-3 rounded-md border px-3 py-2 text-start text-sm transition-colors hover:border-primary disabled:cursor-not-allowed disabled:opacity-50\"\r\n [class.border-primary]=\"chosen\"\r\n [class.bg-primary-50]=\"chosen\"\r\n [class.border-surface]=\"!chosen\"\r\n (click)=\"toggle(item)\"\r\n >\r\n <span\r\n class=\"flex size-4 shrink-0 items-center justify-center border\"\r\n [class.rounded-sm]=\"multiple()\"\r\n [class.rounded-full]=\"!multiple()\"\r\n [class.border-primary]=\"chosen\"\r\n [class.bg-primary]=\"chosen\"\r\n [class.text-primary-contrast]=\"chosen\"\r\n [class.border-surface-400]=\"!chosen\"\r\n >\r\n @if (chosen) {\r\n <mt-icon icon=\"general.check\" class=\"text-[0.625rem]\" />\r\n }\r\n </span>\r\n <span class=\"min-w-0 flex-1 truncate text-color\">{{\r\n item.name\r\n }}</span>\r\n </button>\r\n }\r\n\r\n @if (loading()) {\r\n <p-skeleton width=\"100%\" height=\"2.5rem\" borderRadius=\"0.375rem\" />\r\n <p-skeleton width=\"100%\" height=\"2.5rem\" borderRadius=\"0.375rem\" />\r\n <p-skeleton width=\"100%\" height=\"2.5rem\" borderRadius=\"0.375rem\" />\r\n } @else if (!items().length) {\r\n <div\r\n class=\"rounded-md border border-dashed border-surface-300 bg-surface-50 p-3 text-sm text-muted-color\"\r\n >\r\n {{ \"components.entityListField.noCandidates\" | transloco }}\r\n </div>\r\n }\r\n </div>\r\n\r\n @if (hasMore() && !loading()) {\r\n <div class=\"flex justify-center\">\r\n <mt-button\r\n [label]=\"'components.entityListField.loadMore' | transloco\"\r\n variant=\"text\"\r\n size=\"small\"\r\n (onClick)=\"loadMore()\"\r\n />\r\n </div>\r\n }\r\n }\r\n</div>\r\n\r\n<div [class]=\"modal.footerClass\">\r\n <mt-button\r\n [label]=\"'components.entityListField.cancel' | transloco\"\r\n severity=\"secondary\"\r\n variant=\"outlined\"\r\n (onClick)=\"onCancel()\"\r\n />\r\n <mt-button\r\n [label]=\"'components.entityListField.apply' | transloco\"\r\n severity=\"primary\"\r\n [disabled]=\"!!failureKey()\"\r\n (onClick)=\"onApply()\"\r\n />\r\n</div>\r\n" }]
|
|
1245
1246
|
}], propDecorators: { propertyKey: [{ type: i0.Input, args: [{ isSignal: true, alias: "propertyKey", required: false }] }], contextKey: [{ type: i0.Input, args: [{ isSignal: true, alias: "contextKey", required: false }] }], levelDataId: [{ type: i0.Input, args: [{ isSignal: true, alias: "levelDataId", required: false }] }], multiple: [{ type: i0.Input, args: [{ isSignal: true, alias: "multiple", required: false }] }], selectedIds: [{ type: i0.Input, args: [{ isSignal: true, alias: "selectedIds", required: false }] }], context: [{ type: i0.Input, args: [{ isSignal: true, alias: "context", required: false }] }] } });
|
|
1246
1247
|
|
|
1248
|
+
/** Revisions fetched per page of the history list (the backend allows 1–100). */
|
|
1249
|
+
const REVISIONS_PAGE_SIZE = 25;
|
|
1247
1250
|
function resolveMetadataFailure(status) {
|
|
1248
1251
|
if (status === 403)
|
|
1249
1252
|
return 'forbidden';
|
|
@@ -1757,10 +1760,17 @@ class EntityListField {
|
|
|
1757
1760
|
* id cells are keyed by. Sorting is off while rows can be dragged: a sorted
|
|
1758
1761
|
* table would show an order that is not the one being saved.
|
|
1759
1762
|
*/
|
|
1760
|
-
localColumns = computed(() => {
|
|
1763
|
+
localColumns = computed(() => this.buildLocalColumns(this.localFields(), !this.localCanEdit()), ...(ngDevMode ? [{ debugName: "localColumns" }] : /* istanbul ignore next */ []));
|
|
1764
|
+
/**
|
|
1765
|
+
* Rows as rendered: loaded rows with this session's edits over them, then
|
|
1766
|
+
* new rows, in the order they would be saved. A loaded cell renders from the
|
|
1767
|
+
* backend's resolved `value`; a cell the user set renders from the dialog's
|
|
1768
|
+
* control value and option label, like a locally added linked row.
|
|
1769
|
+
*/
|
|
1770
|
+
localTableRows = computed(() => this.buildLocalRows(this.localState(), this.localFields(), this.localColumns()), ...(ngDevMode ? [{ debugName: "localTableRows" }] : /* istanbul ignore next */ []));
|
|
1771
|
+
buildLocalColumns(fields, sortable) {
|
|
1761
1772
|
const lang = this.lang();
|
|
1762
|
-
|
|
1763
|
-
return this.localFields().map((field, index) => {
|
|
1773
|
+
return fields.map((field, index) => {
|
|
1764
1774
|
const viewType = resolveLocalFieldViewType(field);
|
|
1765
1775
|
return {
|
|
1766
1776
|
key: field.id,
|
|
@@ -1774,17 +1784,9 @@ class EntityListField {
|
|
|
1774
1784
|
configuration: null,
|
|
1775
1785
|
};
|
|
1776
1786
|
});
|
|
1777
|
-
}
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
* new rows, in the order they would be saved. A loaded cell renders from the
|
|
1781
|
-
* backend's resolved `value`; a cell the user set renders from the dialog's
|
|
1782
|
-
* control value and option label, like a locally added linked row.
|
|
1783
|
-
*/
|
|
1784
|
-
localTableRows = computed(() => {
|
|
1785
|
-
const state = this.localState();
|
|
1786
|
-
const fields = this.localFields();
|
|
1787
|
-
const columns = new Map(this.localColumns().map((column) => [column.key, column]));
|
|
1787
|
+
}
|
|
1788
|
+
buildLocalRows(state, fields, localColumns) {
|
|
1789
|
+
const columns = new Map(localColumns.map((column) => [column.key, column]));
|
|
1788
1790
|
return orderLocalRows(state).map((entry) => {
|
|
1789
1791
|
const cells = entry.existing
|
|
1790
1792
|
? localCellsByFieldId(entry.existing)
|
|
@@ -1808,7 +1810,7 @@ class EntityListField {
|
|
|
1808
1810
|
}
|
|
1809
1811
|
return row;
|
|
1810
1812
|
});
|
|
1811
|
-
}
|
|
1813
|
+
}
|
|
1812
1814
|
/**
|
|
1813
1815
|
* Edit and delete per row. A row added in this session is still part of the
|
|
1814
1816
|
* create — changing or dropping it undoes nothing stored — so it follows
|
|
@@ -1999,19 +2001,26 @@ class EntityListField {
|
|
|
1999
2001
|
preservedAvailable = computed(() => this.comparison()?.preservedAvailable === true, ...(ngDevMode ? [{ debugName: "preservedAvailable" }] : /* istanbul ignore next */ []));
|
|
2000
2002
|
preservedAt = computed(() => this.comparison()?.preservedAt ?? null, ...(ngDevMode ? [{ debugName: "preservedAt" }] : /* istanbul ignore next */ []));
|
|
2001
2003
|
unavailableCount = computed(() => this.comparison()?.unavailableIds?.length ?? 0, ...(ngDevMode ? [{ debugName: "unavailableCount" }] : /* istanbul ignore next */ []));
|
|
2002
|
-
|
|
2004
|
+
/** Query of the two read-only review endpoints for this list's owner. */
|
|
2005
|
+
reviewParams(propertyId) {
|
|
2003
2006
|
const owner = this.comparisonOwner();
|
|
2004
2007
|
if (!owner)
|
|
2008
|
+
return null;
|
|
2009
|
+
return {
|
|
2010
|
+
ownerKind: owner.ownerKind,
|
|
2011
|
+
ownerId: String(owner.ownerId),
|
|
2012
|
+
propertyId: String(propertyId),
|
|
2013
|
+
};
|
|
2014
|
+
}
|
|
2015
|
+
fetchComparison(propertyId) {
|
|
2016
|
+
const params = this.reviewParams(propertyId);
|
|
2017
|
+
if (!params)
|
|
2005
2018
|
return;
|
|
2006
2019
|
this.loading.set(true);
|
|
2007
2020
|
const ctx = this.context();
|
|
2008
2021
|
this.fetchSubscription = this.http
|
|
2009
2022
|
.get('entity-lists/comparison', {
|
|
2010
|
-
params
|
|
2011
|
-
ownerKind: owner.ownerKind,
|
|
2012
|
-
ownerId: String(owner.ownerId),
|
|
2013
|
-
propertyId: String(propertyId),
|
|
2014
|
-
},
|
|
2023
|
+
params,
|
|
2015
2024
|
// `403` / `404` are rendered as notices, not toasts.
|
|
2016
2025
|
headers: { noMessage: 'true' },
|
|
2017
2026
|
...(ctx ? { context: ctx } : {}),
|
|
@@ -2028,6 +2037,159 @@ class EntityListField {
|
|
|
2028
2037
|
},
|
|
2029
2038
|
});
|
|
2030
2039
|
}
|
|
2040
|
+
// ============================================================================
|
|
2041
|
+
// Saved list revisions (`entity-lists/revisions`) — read-only history
|
|
2042
|
+
// ============================================================================
|
|
2043
|
+
/**
|
|
2044
|
+
* A list viewed from outside its form, with its owning record named (a
|
|
2045
|
+
* table cell's drawer), has saved revisions to browse — Related, Local and
|
|
2046
|
+
* Selected alike. Nowhere else: an editable list, a record preview and a
|
|
2047
|
+
* form know no owner, and history is read-only anyway.
|
|
2048
|
+
*/
|
|
2049
|
+
historyAvailable = computed(() => !!this.comparisonOwner() &&
|
|
2050
|
+
(this.comparisonMode() || this.localReady() || this.selectionReady()), ...(ngDevMode ? [{ debugName: "historyAvailable" }] : /* istanbul ignore next */ []));
|
|
2051
|
+
/**
|
|
2052
|
+
* A Local or Selected list shows its value until a revision is picked;
|
|
2053
|
+
* then that revision, until *Back to latest*. A Related list always shows
|
|
2054
|
+
* a comparison, the latest one when no revision is picked.
|
|
2055
|
+
*/
|
|
2056
|
+
showingRevision = computed(() => this.viewedRevision() != null && !!this.comparison(), ...(ngDevMode ? [{ debugName: "showingRevision" }] : /* istanbul ignore next */ []));
|
|
2057
|
+
/** The Local rows of the revision being viewed, with that revision's schema. */
|
|
2058
|
+
revisionLocalDocument = computed(() => this.localMode() ? (this.comparison()?.localDocument ?? null) : null, ...(ngDevMode ? [{ debugName: "revisionLocalDocument" }] : /* istanbul ignore next */ []));
|
|
2059
|
+
revisionLocalFields = computed(() => visibleLocalSchemaFields(this.revisionLocalDocument()?.schema), ...(ngDevMode ? [{ debugName: "revisionLocalFields" }] : /* istanbul ignore next */ []));
|
|
2060
|
+
revisionLocalColumns = computed(() => this.buildLocalColumns(this.revisionLocalFields(), true), ...(ngDevMode ? [{ debugName: "revisionLocalColumns" }] : /* istanbul ignore next */ []));
|
|
2061
|
+
revisionLocalRows = computed(() => {
|
|
2062
|
+
const document = this.revisionLocalDocument();
|
|
2063
|
+
if (!document)
|
|
2064
|
+
return [];
|
|
2065
|
+
return this.buildLocalRows(createLocalEditorState(document), this.revisionLocalFields(), this.revisionLocalColumns());
|
|
2066
|
+
}, ...(ngDevMode ? [{ debugName: "revisionLocalRows" }] : /* istanbul ignore next */ []));
|
|
2067
|
+
/** The history list is open. */
|
|
2068
|
+
revisionsOpen = signal(false, ...(ngDevMode ? [{ debugName: "revisionsOpen" }] : /* istanbul ignore next */ []));
|
|
2069
|
+
/** Revisions loaded so far, newest first. */
|
|
2070
|
+
revisions = signal([], ...(ngDevMode ? [{ debugName: "revisions" }] : /* istanbul ignore next */ []));
|
|
2071
|
+
/**
|
|
2072
|
+
* The revisions as listed, each with the author to print: the name the
|
|
2073
|
+
* backend resolved for the page, or "Unknown user" when it resolved none.
|
|
2074
|
+
* Plain text — the template interpolates it, never binds it as HTML.
|
|
2075
|
+
*/
|
|
2076
|
+
revisionItems = computed(() => {
|
|
2077
|
+
const unknown = this.transloco.translate('components.entityListField.unknownUser', {}, this.lang());
|
|
2078
|
+
return this.revisions().map((revision) => ({
|
|
2079
|
+
version: revision.version,
|
|
2080
|
+
createdAt: revision.createdAt,
|
|
2081
|
+
author: revision.createdByName?.trim() || unknown,
|
|
2082
|
+
}));
|
|
2083
|
+
}, ...(ngDevMode ? [{ debugName: "revisionItems" }] : /* istanbul ignore next */ []));
|
|
2084
|
+
revisionsTotal = signal(0, ...(ngDevMode ? [{ debugName: "revisionsTotal" }] : /* istanbul ignore next */ []));
|
|
2085
|
+
revisionsPage = 0;
|
|
2086
|
+
revisionsLoading = signal(false, ...(ngDevMode ? [{ debugName: "revisionsLoading" }] : /* istanbul ignore next */ []));
|
|
2087
|
+
revisionsError = signal(null, ...(ngDevMode ? [{ debugName: "revisionsError" }] : /* istanbul ignore next */ []));
|
|
2088
|
+
hasMoreRevisions = computed(() => this.revisions().length < this.revisionsTotal(), ...(ngDevMode ? [{ debugName: "hasMoreRevisions" }] : /* istanbul ignore next */ []));
|
|
2089
|
+
/** The revision the comparison shows; null is the list as saved last. */
|
|
2090
|
+
viewedRevision = signal(null, ...(ngDevMode ? [{ debugName: "viewedRevision" }] : /* istanbul ignore next */ []));
|
|
2091
|
+
/** A revision is being read; the tables stay until it arrives. */
|
|
2092
|
+
revisionLoading = signal(false, ...(ngDevMode ? [{ debugName: "revisionLoading" }] : /* istanbul ignore next */ []));
|
|
2093
|
+
/** Why the chosen revision could not be read. The last comparison stays. */
|
|
2094
|
+
revisionError = signal(null, ...(ngDevMode ? [{ debugName: "revisionError" }] : /* istanbul ignore next */ []));
|
|
2095
|
+
revisionSubscription;
|
|
2096
|
+
revisionsSubscription;
|
|
2097
|
+
toggleRevisions() {
|
|
2098
|
+
const open = !this.revisionsOpen();
|
|
2099
|
+
this.revisionsOpen.set(open);
|
|
2100
|
+
if (open && this.revisionsPage === 0 && !this.revisionsLoading()) {
|
|
2101
|
+
this.loadRevisions();
|
|
2102
|
+
}
|
|
2103
|
+
}
|
|
2104
|
+
/** The next page of the revision index. */
|
|
2105
|
+
loadRevisions() {
|
|
2106
|
+
const propertyId = this.metadata()?.propertyId ?? 0;
|
|
2107
|
+
const params = this.reviewParams(propertyId);
|
|
2108
|
+
if (!params)
|
|
2109
|
+
return;
|
|
2110
|
+
const page = this.revisionsPage + 1;
|
|
2111
|
+
const ctx = this.context();
|
|
2112
|
+
this.revisionsLoading.set(true);
|
|
2113
|
+
this.revisionsError.set(null);
|
|
2114
|
+
this.revisionsSubscription = this.http
|
|
2115
|
+
.get('entity-lists/revisions', {
|
|
2116
|
+
params: { ...params, page, pageSize: REVISIONS_PAGE_SIZE },
|
|
2117
|
+
headers: { noMessage: 'true' },
|
|
2118
|
+
...(ctx ? { context: ctx } : {}),
|
|
2119
|
+
})
|
|
2120
|
+
.pipe(takeUntilDestroyed(this.destroyRef), finalize(() => this.revisionsLoading.set(false)))
|
|
2121
|
+
.subscribe({
|
|
2122
|
+
next: (response) => {
|
|
2123
|
+
this.revisionsPage = page;
|
|
2124
|
+
this.revisions.set([...this.revisions(), ...(response.items ?? [])]);
|
|
2125
|
+
this.revisionsTotal.set(Number(response.totalCount) || 0);
|
|
2126
|
+
},
|
|
2127
|
+
error: () => this.revisionsError.set(this.transloco.translate('components.entityListField.revisionsLoadFailed')),
|
|
2128
|
+
});
|
|
2129
|
+
}
|
|
2130
|
+
/**
|
|
2131
|
+
* Compare a saved revision with today — its preserved rows beside today's
|
|
2132
|
+
* values of the records it held; for Local, its rows as saved — or, with
|
|
2133
|
+
* `null`, go back to the latest: a Related list re-reads its comparison, a
|
|
2134
|
+
* Local or Selected one shows its value again. Read-only: nothing here is
|
|
2135
|
+
* ever submitted.
|
|
2136
|
+
*/
|
|
2137
|
+
showRevision(version) {
|
|
2138
|
+
const propertyId = this.metadata()?.propertyId ?? 0;
|
|
2139
|
+
const params = this.reviewParams(propertyId);
|
|
2140
|
+
if (!params || version === this.viewedRevision())
|
|
2141
|
+
return;
|
|
2142
|
+
this.revisionSubscription?.unsubscribe();
|
|
2143
|
+
this.revisionError.set(null);
|
|
2144
|
+
if (version == null && !this.comparisonMode()) {
|
|
2145
|
+
this.revisionLoading.set(false);
|
|
2146
|
+
this.viewedRevision.set(null);
|
|
2147
|
+
this.comparison.set(null);
|
|
2148
|
+
return;
|
|
2149
|
+
}
|
|
2150
|
+
const ctx = this.context();
|
|
2151
|
+
this.revisionLoading.set(true);
|
|
2152
|
+
this.revisionSubscription = this.http
|
|
2153
|
+
.get('entity-lists/comparison', {
|
|
2154
|
+
params: version == null ? params : { ...params, revision: version },
|
|
2155
|
+
headers: { noMessage: 'true' },
|
|
2156
|
+
...(ctx ? { context: ctx } : {}),
|
|
2157
|
+
})
|
|
2158
|
+
.pipe(takeUntilDestroyed(this.destroyRef), finalize(() => this.revisionLoading.set(false)))
|
|
2159
|
+
.subscribe({
|
|
2160
|
+
next: (response) => {
|
|
2161
|
+
this.comparison.set(response);
|
|
2162
|
+
this.viewedRevision.set(version);
|
|
2163
|
+
},
|
|
2164
|
+
error: (error) => this.revisionError.set(this.revisionFailureMessage(error)),
|
|
2165
|
+
});
|
|
2166
|
+
}
|
|
2167
|
+
/**
|
|
2168
|
+
* `entity_list.history_source_changed` (`400`): the revision was saved with
|
|
2169
|
+
* another source configuration. `404`: it no longer exists.
|
|
2170
|
+
*/
|
|
2171
|
+
revisionFailureMessage(error) {
|
|
2172
|
+
const code = error.error?.code;
|
|
2173
|
+
const key = code === 'entity_list.history_source_changed'
|
|
2174
|
+
? 'revisionSourceChanged'
|
|
2175
|
+
: error.status === 404
|
|
2176
|
+
? 'revisionNotFound'
|
|
2177
|
+
: 'loadFailed';
|
|
2178
|
+
return this.transloco.translate(`components.entityListField.${key}`);
|
|
2179
|
+
}
|
|
2180
|
+
resetRevisions() {
|
|
2181
|
+
this.revisionSubscription?.unsubscribe();
|
|
2182
|
+
this.revisionsSubscription?.unsubscribe();
|
|
2183
|
+
this.revisionsOpen.set(false);
|
|
2184
|
+
this.revisions.set([]);
|
|
2185
|
+
this.revisionsTotal.set(0);
|
|
2186
|
+
this.revisionsPage = 0;
|
|
2187
|
+
this.revisionsLoading.set(false);
|
|
2188
|
+
this.revisionsError.set(null);
|
|
2189
|
+
this.viewedRevision.set(null);
|
|
2190
|
+
this.revisionLoading.set(false);
|
|
2191
|
+
this.revisionError.set(null);
|
|
2192
|
+
}
|
|
2031
2193
|
selectionRowActions = computed(() => {
|
|
2032
2194
|
this.lang();
|
|
2033
2195
|
if (!this.selectionWritable())
|
|
@@ -2243,6 +2405,7 @@ class EntityListField {
|
|
|
2243
2405
|
return;
|
|
2244
2406
|
this.lastEmittedJson = null;
|
|
2245
2407
|
this.linkedMutation = null;
|
|
2408
|
+
this.loadedMutationId = incoming?.mutationId;
|
|
2246
2409
|
this.storedValue.set(incoming);
|
|
2247
2410
|
// Restore rows the backend left unprocessed. Whether the loaded
|
|
2248
2411
|
// `deletedIds` are historical markers or pending intent depends on the
|
|
@@ -2298,17 +2461,28 @@ class EntityListField {
|
|
|
2298
2461
|
return true;
|
|
2299
2462
|
}
|
|
2300
2463
|
/**
|
|
2301
|
-
* True when the written value still carries exactly the
|
|
2302
|
-
*
|
|
2303
|
-
*
|
|
2464
|
+
* True when the written value still carries exactly the change we last
|
|
2465
|
+
* emitted — i.e. the form is echoing our own value back rather than loading
|
|
2466
|
+
* a new one.
|
|
2467
|
+
*
|
|
2468
|
+
* The list version, change id and tokens are part of it: a reload after a
|
|
2469
|
+
* save can carry the same (empty) rows and deletions as the last emission,
|
|
2470
|
+
* and taking it for an echo kept the old version, so the next save was
|
|
2471
|
+
* refused as a version conflict.
|
|
2304
2472
|
*/
|
|
2305
2473
|
isEchoOfLastEmit(incoming) {
|
|
2306
2474
|
if (this.lastEmittedJson === null)
|
|
2307
2475
|
return false;
|
|
2308
|
-
return (
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2476
|
+
return this.echoKey(incoming) === this.lastEmittedJson;
|
|
2477
|
+
}
|
|
2478
|
+
echoKey(value) {
|
|
2479
|
+
return JSON.stringify({
|
|
2480
|
+
rows: value?.rows ?? [],
|
|
2481
|
+
deletedIds: value?.deletedIds ?? [],
|
|
2482
|
+
version: value?.version ?? null,
|
|
2483
|
+
mutationId: value?.mutationId ?? null,
|
|
2484
|
+
expectedVersions: value?.expectedVersions ?? null,
|
|
2485
|
+
});
|
|
2312
2486
|
}
|
|
2313
2487
|
/**
|
|
2314
2488
|
* The stored value is persisted as JSON, so a host may write either the
|
|
@@ -2906,10 +3080,7 @@ class EntityListField {
|
|
|
2906
3080
|
...this.linkedMutationId(current, rows, deletedIds),
|
|
2907
3081
|
};
|
|
2908
3082
|
this.storedValue.set(next);
|
|
2909
|
-
this.lastEmittedJson =
|
|
2910
|
-
rows: next.rows,
|
|
2911
|
-
deletedIds: next.deletedIds,
|
|
2912
|
-
});
|
|
3083
|
+
this.lastEmittedJson = this.echoKey(next);
|
|
2913
3084
|
this.onModelChange(next);
|
|
2914
3085
|
this.onTouched();
|
|
2915
3086
|
}
|
|
@@ -2923,9 +3094,13 @@ class EntityListField {
|
|
|
2923
3094
|
* what it loaded with; the backend skips it.
|
|
2924
3095
|
*/
|
|
2925
3096
|
linkedMutation = null;
|
|
3097
|
+
/** The loaded value's `mutationId`, restored once nothing is left to apply. */
|
|
3098
|
+
loadedMutationId;
|
|
2926
3099
|
linkedMutationId(current, rows, deletedIds) {
|
|
2927
|
-
|
|
2928
|
-
|
|
3100
|
+
// `current` is the last emission, which may carry this session's id.
|
|
3101
|
+
if (rows.length === 0 && deletedIds.length === 0) {
|
|
3102
|
+
return { mutationId: this.loadedMutationId };
|
|
3103
|
+
}
|
|
2929
3104
|
const version = Number(current.version ?? 0) || 0;
|
|
2930
3105
|
const key = JSON.stringify({ version, rows, deletedIds });
|
|
2931
3106
|
if (this.linkedMutation?.key !== key) {
|
|
@@ -3059,6 +3234,7 @@ class EntityListField {
|
|
|
3059
3234
|
this.columns.set([]);
|
|
3060
3235
|
this.rows.set([]);
|
|
3061
3236
|
this.comparison.set(null);
|
|
3237
|
+
this.resetRevisions();
|
|
3062
3238
|
this.errorMessage.set(null);
|
|
3063
3239
|
this.loading.set(false);
|
|
3064
3240
|
if (!(propertyId > 0) || levelId == null || !(Number(levelId) > 0))
|
|
@@ -3287,7 +3463,7 @@ class EntityListField {
|
|
|
3287
3463
|
};
|
|
3288
3464
|
}
|
|
3289
3465
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: EntityListField, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
3290
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.8", type: EntityListField, isStandalone: true, selector: "mt-entity-list-field", inputs: { label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, readonly: { classPropertyName: "readonly", publicName: "readonly", isSignal: true, isRequired: false, transformFunction: null }, required: { classPropertyName: "required", publicName: "required", isSignal: true, isRequired: false, transformFunction: null }, propertyId: { classPropertyName: "propertyId", publicName: "propertyId", isSignal: true, isRequired: false, transformFunction: null }, propertyKey: { classPropertyName: "propertyKey", publicName: "propertyKey", isSignal: true, isRequired: false, transformFunction: null }, configuration: { classPropertyName: "configuration", publicName: "configuration", isSignal: true, isRequired: false, transformFunction: null }, runtimeContext: { classPropertyName: "runtimeContext", publicName: "runtimeContext", isSignal: true, isRequired: false, transformFunction: null }, pendingSubmission: { classPropertyName: "pendingSubmission", publicName: "pendingSubmission", isSignal: true, isRequired: false, transformFunction: null }, lookups: { classPropertyName: "lookups", publicName: "lookups", isSignal: true, isRequired: false, transformFunction: null }, context: { classPropertyName: "context", publicName: "context", isSignal: true, isRequired: false, transformFunction: null }, initialValue: { classPropertyName: "initialValue", publicName: "initialValue", isSignal: true, isRequired: false, transformFunction: null } }, host: { classAttribute: "grid gap-1" }, providers: [EntityRuntimeContextStore], ngImport: i0, template: "<div class=\"flex flex-col gap-2\">\n @if (label()) {\n <label class=\"font-medium text-color\">\n {{ label() }}\n @if (required()) {\n <span class=\"text-red-500\">*</span>\n }\n </label>\n }\n\n @if (errorMessage(); as err) {\n <p-message severity=\"error\" [text]=\"err\" styleClass=\"w-full\" />\n } @else if (noticeKey(); as notice) {\n <div\n class=\"rounded-md border border-dashed border-surface-300 bg-surface-50 p-3 text-sm text-muted-color\"\n >\n {{ notice | transloco }}\n </div>\n } @else if (localReady()) {\n <!--\n A Local list: rows owned by this record, staged into its own submission.\n Add / edit / delete / drag follow the Local operation switches.\n -->\n @if (localCanCreate()) {\n <div class=\"flex justify-end\">\n <mt-button\n [label]=\"'components.entityListField.add' | transloco\"\n icon=\"general.plus\"\n size=\"small\"\n [disabled]=\"disabled()\"\n (onClick)=\"openLocalRowDialog()\"\n />\n </div>\n }\n @if (localTableRows().length || localCanCreate()) {\n <mt-table\n [noCard]=\"true\"\n [data]=\"localTableRows()\"\n [columns]=\"localColumns()\"\n [rowActions]=\"localRowActions()\"\n [reorderableRows]=\"localCanReorder()\"\n (rowReorder)=\"onLocalReorder($event)\"\n dataKey=\"Id\"\n />\n } @else {\n <div\n class=\"rounded-md border border-dashed border-surface-300 bg-surface-50 p-3 text-sm text-muted-color\"\n >\n {{ \"components.entityListField.noLocalRows\" | transloco }}\n </div>\n }\n } @else if (selectionReady()) {\n <!--\n A Selected list: the source records picked for this record, and nothing\n else. Picking and removing change only which records it holds.\n -->\n @if (selectionWritable()) {\n <div class=\"flex justify-end\">\n <mt-button\n [label]=\"'components.entityListField.selectRecords' | transloco\"\n icon=\"general.plus\"\n size=\"small\"\n [disabled]=\"disabled()\"\n (onClick)=\"openSelectionDialog()\"\n />\n </div>\n }\n @if (selectionRows().length) {\n <mt-table\n [noCard]=\"true\"\n [data]=\"selectionRows()\"\n [columns]=\"columns()\"\n [rowActions]=\"selectionRowActions()\"\n dataKey=\"Id\"\n />\n } @else {\n <div\n class=\"rounded-md border border-dashed border-surface-300 bg-surface-50 p-3 text-sm text-muted-color\"\n >\n {{ \"components.entityListField.noSelectedRecords\" | transloco }}\n </div>\n }\n } @else if (comparisonMode()) {\n <!--\n A saved Related list opened from outside its form: its sources' current\n values, and the values preserved when it was saved. A missing baseline is\n said as such \u2014 it is not an empty list.\n -->\n @if (!comparisonReady()) {\n <div class=\"flex flex-col gap-2\">\n <p-skeleton width=\"100%\" height=\"3rem\" borderRadius=\"0.375rem\" />\n <p-skeleton width=\"100%\" height=\"3rem\" borderRadius=\"0.375rem\" />\n </div>\n } @else {\n <section class=\"flex flex-col gap-2\">\n <h4 class=\"text-sm font-semibold text-color\">\n {{ \"components.entityListField.currentValues\" | transloco }}\n </h4>\n @if (liveRows().length) {\n <mt-table\n [noCard]=\"true\"\n [data]=\"liveRows()\"\n [columns]=\"columns()\"\n dataKey=\"Id\"\n />\n } @else {\n <div\n class=\"rounded-md border border-dashed border-surface-300 bg-surface-50 p-3 text-sm text-muted-color\"\n >\n {{ \"components.entityListField.noRelatedItems\" | transloco }}\n </div>\n }\n </section>\n\n <section class=\"flex flex-col gap-2\">\n <h4\n class=\"flex flex-wrap items-baseline gap-2 text-sm font-semibold text-color\"\n >\n {{ \"components.entityListField.preservedValues\" | transloco }}\n @if (preservedAt(); as capturedAt) {\n <span class=\"text-xs font-normal text-muted-color\">\n {{\n \"components.entityListField.preservedAt\"\n | transloco: { date: (capturedAt | mtDateFormat: \"dateTime\") }\n }}\n </span>\n }\n </h4>\n @if (!preservedAvailable()) {\n <div\n class=\"rounded-md border border-dashed border-surface-300 bg-surface-50 p-3 text-sm text-muted-color\"\n >\n {{ \"components.entityListField.noPreservedSnapshot\" | transloco }}\n </div>\n } @else if (preservedRows().length) {\n <mt-table\n [noCard]=\"true\"\n [data]=\"preservedRows()\"\n [columns]=\"columns()\"\n dataKey=\"Id\"\n />\n } @else {\n <div\n class=\"rounded-md border border-dashed border-surface-300 bg-surface-50 p-3 text-sm text-muted-color\"\n >\n {{ \"components.entityListField.preservedEmpty\" | transloco }}\n </div>\n }\n </section>\n\n @if (unavailableCount()) {\n <p class=\"text-xs text-muted-color\">\n {{\n \"components.entityListField.unavailableRecords\"\n | transloco: { count: unavailableCount() }\n }}\n </p>\n }\n }\n } @else if (canWrite()) {\n <div class=\"flex justify-end\">\n <mt-button\n [label]=\"'components.entityListField.add' | transloco\"\n icon=\"general.plus\"\n size=\"small\"\n [disabled]=\"disabled()\"\n (onClick)=\"openAddDialog()\"\n />\n </div>\n <mt-table\n [noCard]=\"true\"\n [data]=\"displayRows()\"\n [columns]=\"tableColumns()\"\n [rowActions]=\"writeRowActions()\"\n dataKey=\"Id\"\n [loading]=\"loading()\"\n />\n } @else if (loading() && !hasRows()) {\n <div class=\"flex flex-col gap-2\">\n <p-skeleton width=\"100%\" height=\"3rem\" borderRadius=\"0.375rem\" />\n <p-skeleton width=\"100%\" height=\"3rem\" borderRadius=\"0.375rem\" />\n </div>\n } @else if (!hasRows()) {\n <div\n class=\"rounded-md border border-dashed border-surface-300 bg-surface-50 p-3 text-sm text-muted-color\"\n >\n {{ \"components.entityListField.noRelatedItems\" | transloco }}\n </div>\n } @else {\n <mt-table\n [noCard]=\"true\"\n [data]=\"displayRows()\"\n [columns]=\"tableColumns()\"\n dataKey=\"Id\"\n [loading]=\"loading()\"\n />\n }\n\n @if (ngControl?.control) {\n <mt-field-validation\n [control]=\"ngControl?.control!\"\n [touched]=\"ngControl?.touched ?? false\"\n />\n }\n</div>\n", styles: [":host{display:block}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "component", type: FieldValidation, selector: "mt-field-validation", inputs: ["control", "touched", "messageId"] }, { kind: "component", type: Skeleton, selector: "p-skeleton", inputs: ["styleClass", "shape", "animation", "borderRadius", "size", "width", "height"] }, { kind: "component", type: Message, selector: "p-message", inputs: ["severity", "text", "escape", "style", "styleClass", "closable", "icon", "closeIcon", "life", "showTransitionOptions", "hideTransitionOptions", "size", "variant", "motionOptions"], outputs: ["onClose"] }, { kind: "component", type: Table, selector: "mt-table", inputs: ["filters", "data", "columns", "rowActions", "size", "showGridlines", "stripedRows", "selectableRows", "clickableRows", "generalSearch", "lazyLocalSearch", "showFilters", "filterMode", "loading", "updating", "lazy", "lazyLocalSort", "lazyTotalRecords", "reorderableColumns", "reorderableRows", "dataKey", "storageKey", "storageMode", "persistStateExclude", "exportable", "printable", "groupable", "groupCountMap", "cellClickFilter", "freezeActions", "virtualScroll", "virtualScrollItemSize", "scrollHeight", "printTitle", "exportFilename", "actionShape", "rowActionsLoadingFn", "tableLayout", "noCard", "tabs", "tabsOptionLabel", "tabsOptionValue", "activeTab", "actions", "captionStartTemplate", "captionEndTemplate", "emptyTitle", "emptyDescription", "emptyActionLabel", "emptyActionIcon", "paginatorPosition", "alwaysShowPaginator", "rowsPerPageOptions", "pageSize", "currentPage", "first", "filterTerm", "groupBy", "sortField", "sortDirection"], outputs: ["selectionChange", "cellChange", "lazyLoad", "columnReorder", "rowReorder", "rowClick", "emptyAction", "rowActionsRequested", "filtersChange", "activeTabChange", "onTabChange", "pageSizeChange", "currentPageChange", "firstChange", "filterTermChange", "groupByChange", "sortFieldChange", "sortDirectionChange"] }, { kind: "component", type: Button, selector: "mt-button", inputs: ["icon", "label", "tooltip", "class", "type", "styleClass", "severity", "badge", "variant", "badgeSeverity", "size", "iconPos", "autofocus", "fluid", "raised", "rounded", "text", "plain", "outlined", "link", "disabled", "loading", "pInputs", "ariaLabel"], outputs: ["onClick", "onFocus", "onBlur"] }, { kind: "pipe", type: TranslocoPipe, name: "transloco" }, { kind: "pipe", type: MTDateFormatPipe, name: "mtDateFormat" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
3466
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.8", type: EntityListField, isStandalone: true, selector: "mt-entity-list-field", inputs: { label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, readonly: { classPropertyName: "readonly", publicName: "readonly", isSignal: true, isRequired: false, transformFunction: null }, required: { classPropertyName: "required", publicName: "required", isSignal: true, isRequired: false, transformFunction: null }, propertyId: { classPropertyName: "propertyId", publicName: "propertyId", isSignal: true, isRequired: false, transformFunction: null }, propertyKey: { classPropertyName: "propertyKey", publicName: "propertyKey", isSignal: true, isRequired: false, transformFunction: null }, configuration: { classPropertyName: "configuration", publicName: "configuration", isSignal: true, isRequired: false, transformFunction: null }, runtimeContext: { classPropertyName: "runtimeContext", publicName: "runtimeContext", isSignal: true, isRequired: false, transformFunction: null }, pendingSubmission: { classPropertyName: "pendingSubmission", publicName: "pendingSubmission", isSignal: true, isRequired: false, transformFunction: null }, lookups: { classPropertyName: "lookups", publicName: "lookups", isSignal: true, isRequired: false, transformFunction: null }, context: { classPropertyName: "context", publicName: "context", isSignal: true, isRequired: false, transformFunction: null }, initialValue: { classPropertyName: "initialValue", publicName: "initialValue", isSignal: true, isRequired: false, transformFunction: null } }, host: { classAttribute: "grid gap-1" }, providers: [EntityRuntimeContextStore], ngImport: i0, template: "<div class=\"flex flex-col gap-2\">\n @if (label()) {\n <label class=\"font-medium text-color\">\n {{ label() }}\n @if (required()) {\n <span class=\"text-red-500\">*</span>\n }\n </label>\n }\n\n @if (errorMessage(); as err) {\n <p-message severity=\"error\" [text]=\"err\" styleClass=\"w-full\" />\n } @else if (noticeKey(); as notice) {\n <div\n class=\"rounded-md border border-dashed border-surface-300 bg-surface-50 p-3 text-sm text-muted-color\"\n >\n {{ notice | transloco }}\n </div>\n } @else if (localReady()) {\n <!--\n A Local list: rows owned by this record, staged into its own submission.\n Add / edit / delete / drag follow the Local operation switches. Opened\n from a table cell, it can also show a saved revision's rows instead.\n -->\n @if (historyAvailable()) {\n <ng-container [ngTemplateOutlet]=\"history\" />\n }\n @if (showingRevision()) {\n <section\n class=\"flex flex-col gap-2 transition-opacity\"\n [class.opacity-60]=\"revisionLoading()\"\n >\n <ng-container [ngTemplateOutlet]=\"preservedHeading\" />\n @if (revisionLocalRows().length) {\n <mt-table\n [noCard]=\"true\"\n [data]=\"revisionLocalRows()\"\n [columns]=\"revisionLocalColumns()\"\n dataKey=\"Id\"\n />\n } @else {\n <div\n class=\"rounded-md border border-dashed border-surface-300 bg-surface-50 p-3 text-sm text-muted-color\"\n >\n {{ \"components.entityListField.preservedEmpty\" | transloco }}\n </div>\n }\n </section>\n } @else {\n @if (localCanCreate()) {\n <div class=\"flex justify-end\">\n <mt-button\n [label]=\"'components.entityListField.add' | transloco\"\n icon=\"general.plus\"\n size=\"small\"\n [disabled]=\"disabled()\"\n (onClick)=\"openLocalRowDialog()\"\n />\n </div>\n }\n @if (localTableRows().length || localCanCreate()) {\n <mt-table\n [noCard]=\"true\"\n [data]=\"localTableRows()\"\n [columns]=\"localColumns()\"\n [rowActions]=\"localRowActions()\"\n [reorderableRows]=\"localCanReorder()\"\n (rowReorder)=\"onLocalReorder($event)\"\n dataKey=\"Id\"\n />\n } @else {\n <div\n class=\"rounded-md border border-dashed border-surface-300 bg-surface-50 p-3 text-sm text-muted-color\"\n >\n {{ \"components.entityListField.noLocalRows\" | transloco }}\n </div>\n }\n }\n } @else if (selectionReady()) {\n <!--\n A Selected list: the source records picked for this record, and nothing\n else. Picking and removing change only which records it holds. Opened\n from a table cell, a saved revision compares the records it held then\n with their values today.\n -->\n @if (historyAvailable()) {\n <ng-container [ngTemplateOutlet]=\"history\" />\n }\n @if (showingRevision()) {\n <ng-container [ngTemplateOutlet]=\"comparisonSections\" />\n } @else {\n @if (selectionWritable()) {\n <div class=\"flex justify-end\">\n <mt-button\n [label]=\"'components.entityListField.selectRecords' | transloco\"\n icon=\"general.plus\"\n size=\"small\"\n [disabled]=\"disabled()\"\n (onClick)=\"openSelectionDialog()\"\n />\n </div>\n }\n @if (selectionRows().length) {\n <mt-table\n [noCard]=\"true\"\n [data]=\"selectionRows()\"\n [columns]=\"columns()\"\n [rowActions]=\"selectionRowActions()\"\n dataKey=\"Id\"\n />\n } @else {\n <div\n class=\"rounded-md border border-dashed border-surface-300 bg-surface-50 p-3 text-sm text-muted-color\"\n >\n {{ \"components.entityListField.noSelectedRecords\" | transloco }}\n </div>\n }\n }\n } @else if (comparisonMode()) {\n <!--\n A saved Related list opened from outside its form: its sources' current\n values, and the values preserved when it was saved. A missing baseline is\n said as such \u2014 it is not an empty list.\n -->\n @if (!comparisonReady()) {\n <div class=\"flex flex-col gap-2\">\n <p-skeleton width=\"100%\" height=\"3rem\" borderRadius=\"0.375rem\" />\n <p-skeleton width=\"100%\" height=\"3rem\" borderRadius=\"0.375rem\" />\n </div>\n } @else {\n <ng-container [ngTemplateOutlet]=\"history\" />\n <ng-container [ngTemplateOutlet]=\"comparisonSections\" />\n }\n } @else if (canWrite()) {\n <div class=\"flex justify-end\">\n <mt-button\n [label]=\"'components.entityListField.add' | transloco\"\n icon=\"general.plus\"\n size=\"small\"\n [disabled]=\"disabled()\"\n (onClick)=\"openAddDialog()\"\n />\n </div>\n <mt-table\n [noCard]=\"true\"\n [data]=\"displayRows()\"\n [columns]=\"tableColumns()\"\n [rowActions]=\"writeRowActions()\"\n dataKey=\"Id\"\n [loading]=\"loading()\"\n />\n } @else if (loading() && !hasRows()) {\n <div class=\"flex flex-col gap-2\">\n <p-skeleton width=\"100%\" height=\"3rem\" borderRadius=\"0.375rem\" />\n <p-skeleton width=\"100%\" height=\"3rem\" borderRadius=\"0.375rem\" />\n </div>\n } @else if (!hasRows()) {\n <div\n class=\"rounded-md border border-dashed border-surface-300 bg-surface-50 p-3 text-sm text-muted-color\"\n >\n {{ \"components.entityListField.noRelatedItems\" | transloco }}\n </div>\n } @else {\n <mt-table\n [noCard]=\"true\"\n [data]=\"displayRows()\"\n [columns]=\"tableColumns()\"\n dataKey=\"Id\"\n [loading]=\"loading()\"\n />\n }\n\n @if (ngControl?.control) {\n <mt-field-validation\n [control]=\"ngControl?.control!\"\n [touched]=\"ngControl?.touched ?? false\"\n />\n }\n</div>\n\n<!--\n Saved list revisions: each successful save of this list, newest first.\n Picking one shows what it preserved \u2014 beside today's values of the records\n it held, for a linked list. Read-only: history is never submitted.\n-->\n<ng-template #history>\n <div class=\"flex flex-wrap items-center justify-between gap-2\">\n <div class=\"flex flex-wrap items-center gap-2\">\n @if (viewedRevision(); as version) {\n <span\n class=\"rounded-md border border-primary-200 bg-primary-50 px-2 py-0.5 text-xs font-medium text-primary-700\"\n >\n {{\n \"components.entityListField.viewingRevision\"\n | transloco: { version: version }\n }}\n </span>\n <mt-button\n [label]=\"'components.entityListField.backToLatest' | transloco\"\n size=\"small\"\n variant=\"text\"\n [disabled]=\"revisionLoading()\"\n (onClick)=\"showRevision(null)\"\n />\n }\n </div>\n <mt-button\n [label]=\"'components.entityListField.revisions' | transloco\"\n icon=\"time.clock-rewind\"\n size=\"small\"\n severity=\"secondary\"\n variant=\"outlined\"\n (onClick)=\"toggleRevisions()\"\n />\n </div>\n\n @if (revisionsOpen()) {\n <div\n class=\"flex flex-col gap-2 rounded-md border border-surface bg-surface-50 p-3\"\n >\n <p class=\"text-xs text-muted-color\">\n {{ \"components.entityListField.revisionsHint\" | transloco }}\n </p>\n @if (revisionsError(); as message) {\n <p class=\"text-sm text-red-600\">{{ message }}</p>\n }\n @for (revision of revisionItems(); track revision.version) {\n <button\n type=\"button\"\n class=\"flex items-center justify-between gap-3 rounded-md border px-3 py-2 text-start text-sm transition-colors\"\n [class.border-primary-200]=\"viewedRevision() === revision.version\"\n [class.bg-primary-50]=\"viewedRevision() === revision.version\"\n [class.border-surface]=\"viewedRevision() !== revision.version\"\n [class.bg-content]=\"viewedRevision() !== revision.version\"\n [disabled]=\"revisionLoading()\"\n (click)=\"showRevision(revision.version)\"\n >\n <span class=\"font-medium text-color\">\n {{\n \"components.entityListField.revisionLabel\"\n | transloco: { version: revision.version }\n }}\n </span>\n <span\n class=\"flex min-w-0 flex-wrap items-center justify-end gap-x-2 text-xs text-muted-color\"\n >\n <span class=\"truncate\">{{ revision.author }}</span>\n <span>{{ revision.createdAt | mtDateFormat: \"dateTime\" }}</span>\n </span>\n </button>\n } @empty {\n @if (!revisionsLoading() && !revisionsError()) {\n <p class=\"text-sm text-muted-color\">\n {{ \"components.entityListField.noRevisions\" | transloco }}\n </p>\n }\n }\n @if (revisionsLoading()) {\n <p-skeleton width=\"100%\" height=\"2.25rem\" borderRadius=\"0.375rem\" />\n } @else if (hasMoreRevisions()) {\n <div class=\"flex justify-center\">\n <mt-button\n [label]=\"'components.entityListField.loadMore' | transloco\"\n size=\"small\"\n variant=\"text\"\n (onClick)=\"loadRevisions()\"\n />\n </div>\n }\n </div>\n }\n\n @if (revisionError(); as message) {\n <div\n class=\"rounded-md border border-red-200 bg-red-50 p-3 text-sm text-red-700\"\n >\n {{ message }}\n </div>\n }\n</ng-template>\n\n<!-- \"Preserved values\", with when they were captured. -->\n<ng-template #preservedHeading>\n <h4\n class=\"flex flex-wrap items-baseline gap-2 text-sm font-semibold text-color\"\n >\n {{ \"components.entityListField.preservedValues\" | transloco }}\n @if (preservedAt(); as capturedAt) {\n <span class=\"text-xs font-normal text-muted-color\">\n {{\n \"components.entityListField.preservedAt\"\n | transloco: { date: (capturedAt | mtDateFormat: \"dateTime\") }\n }}\n </span>\n }\n </h4>\n</ng-template>\n\n<!--\n A linked list's comparison: its source records' current values, and the\n values preserved when it was saved (or at the chosen revision).\n-->\n<ng-template #comparisonSections>\n <section\n class=\"flex flex-col gap-2 transition-opacity\"\n [class.opacity-60]=\"revisionLoading()\"\n >\n <h4 class=\"text-sm font-semibold text-color\">\n {{ \"components.entityListField.currentValues\" | transloco }}\n </h4>\n @if (liveRows().length) {\n <mt-table\n [noCard]=\"true\"\n [data]=\"liveRows()\"\n [columns]=\"columns()\"\n dataKey=\"Id\"\n />\n } @else {\n <div\n class=\"rounded-md border border-dashed border-surface-300 bg-surface-50 p-3 text-sm text-muted-color\"\n >\n {{ \"components.entityListField.noRelatedItems\" | transloco }}\n </div>\n }\n </section>\n\n <section\n class=\"flex flex-col gap-2 transition-opacity\"\n [class.opacity-60]=\"revisionLoading()\"\n >\n <ng-container [ngTemplateOutlet]=\"preservedHeading\" />\n @if (!preservedAvailable()) {\n <div\n class=\"rounded-md border border-dashed border-surface-300 bg-surface-50 p-3 text-sm text-muted-color\"\n >\n {{ \"components.entityListField.noPreservedSnapshot\" | transloco }}\n </div>\n } @else if (preservedRows().length) {\n <mt-table\n [noCard]=\"true\"\n [data]=\"preservedRows()\"\n [columns]=\"columns()\"\n dataKey=\"Id\"\n />\n } @else {\n <div\n class=\"rounded-md border border-dashed border-surface-300 bg-surface-50 p-3 text-sm text-muted-color\"\n >\n {{ \"components.entityListField.preservedEmpty\" | transloco }}\n </div>\n }\n </section>\n\n @if (unavailableCount()) {\n <p class=\"text-xs text-muted-color\">\n {{\n \"components.entityListField.unavailableRecords\"\n | transloco: { count: unavailableCount() }\n }}\n </p>\n }\n</ng-template>\n", styles: [":host{display:block}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1$1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "component", type: FieldValidation, selector: "mt-field-validation", inputs: ["control", "touched", "messageId"] }, { kind: "component", type: Skeleton, selector: "p-skeleton", inputs: ["styleClass", "shape", "animation", "borderRadius", "size", "width", "height"] }, { kind: "component", type: Message, selector: "p-message", inputs: ["severity", "text", "escape", "style", "styleClass", "closable", "icon", "closeIcon", "life", "showTransitionOptions", "hideTransitionOptions", "size", "variant", "motionOptions"], outputs: ["onClose"] }, { kind: "component", type: Table, selector: "mt-table", inputs: ["filters", "data", "columns", "rowActions", "size", "showGridlines", "stripedRows", "selectableRows", "clickableRows", "generalSearch", "lazyLocalSearch", "showFilters", "filterMode", "loading", "updating", "lazy", "lazyLocalSort", "lazyTotalRecords", "reorderableColumns", "reorderableRows", "dataKey", "storageKey", "storageMode", "persistStateExclude", "exportable", "printable", "groupable", "groupCountMap", "cellClickFilter", "freezeActions", "virtualScroll", "virtualScrollItemSize", "scrollHeight", "printTitle", "exportFilename", "actionShape", "rowActionsLoadingFn", "tableLayout", "noCard", "tabs", "tabsOptionLabel", "tabsOptionValue", "activeTab", "actions", "captionStartTemplate", "captionEndTemplate", "emptyTitle", "emptyDescription", "emptyActionLabel", "emptyActionIcon", "paginatorPosition", "alwaysShowPaginator", "rowsPerPageOptions", "pageSize", "currentPage", "first", "filterTerm", "groupBy", "sortField", "sortDirection"], outputs: ["selectionChange", "cellChange", "lazyLoad", "columnReorder", "rowReorder", "rowClick", "emptyAction", "rowActionsRequested", "filtersChange", "activeTabChange", "onTabChange", "pageSizeChange", "currentPageChange", "firstChange", "filterTermChange", "groupByChange", "sortFieldChange", "sortDirectionChange"] }, { kind: "component", type: Button, selector: "mt-button", inputs: ["icon", "label", "tooltip", "class", "type", "styleClass", "severity", "badge", "variant", "badgeSeverity", "size", "iconPos", "autofocus", "fluid", "raised", "rounded", "text", "plain", "outlined", "link", "disabled", "loading", "pInputs", "ariaLabel"], outputs: ["onClick", "onFocus", "onBlur"] }, { kind: "pipe", type: TranslocoPipe, name: "transloco" }, { kind: "pipe", type: MTDateFormatPipe, name: "mtDateFormat" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
3291
3467
|
}
|
|
3292
3468
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: EntityListField, decorators: [{
|
|
3293
3469
|
type: Component,
|
|
@@ -3300,7 +3476,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImpor
|
|
|
3300
3476
|
Button,
|
|
3301
3477
|
TranslocoPipe,
|
|
3302
3478
|
MTDateFormatPipe,
|
|
3303
|
-
], changeDetection: ChangeDetectionStrategy.OnPush, host: { class: 'grid gap-1' }, providers: [EntityRuntimeContextStore], template: "<div class=\"flex flex-col gap-2\">\n @if (label()) {\n <label class=\"font-medium text-color\">\n {{ label() }}\n @if (required()) {\n <span class=\"text-red-500\">*</span>\n }\n </label>\n }\n\n @if (errorMessage(); as err) {\n <p-message severity=\"error\" [text]=\"err\" styleClass=\"w-full\" />\n } @else if (noticeKey(); as notice) {\n <div\n class=\"rounded-md border border-dashed border-surface-300 bg-surface-50 p-3 text-sm text-muted-color\"\n >\n {{ notice | transloco }}\n </div>\n } @else if (localReady()) {\n <!--\n A Local list: rows owned by this record, staged into its own submission.\n Add / edit / delete / drag follow the Local operation switches.\n -->\n @if (localCanCreate()) {\n <div class=\"flex justify-end\">\n <mt-button\n [label]=\"'components.entityListField.add' | transloco\"\n icon=\"general.plus\"\n size=\"small\"\n [disabled]=\"disabled()\"\n (onClick)=\"openLocalRowDialog()\"\n />\n </div>\n }\n @if (localTableRows().length || localCanCreate()) {\n <mt-table\n [noCard]=\"true\"\n [data]=\"localTableRows()\"\n [columns]=\"localColumns()\"\n [rowActions]=\"localRowActions()\"\n [reorderableRows]=\"localCanReorder()\"\n (rowReorder)=\"onLocalReorder($event)\"\n dataKey=\"Id\"\n />\n } @else {\n <div\n class=\"rounded-md border border-dashed border-surface-300 bg-surface-50 p-3 text-sm text-muted-color\"\n >\n {{ \"components.entityListField.noLocalRows\" | transloco }}\n </div>\n }\n } @else if (selectionReady()) {\n <!--\n A Selected list: the source records picked for this record, and nothing\n else. Picking and removing change only which records it holds.\n -->\n @if (selectionWritable()) {\n <div class=\"flex justify-end\">\n <mt-button\n [label]=\"'components.entityListField.selectRecords' | transloco\"\n icon=\"general.plus\"\n size=\"small\"\n [disabled]=\"disabled()\"\n (onClick)=\"openSelectionDialog()\"\n />\n </div>\n }\n @if (selectionRows().length) {\n <mt-table\n [noCard]=\"true\"\n [data]=\"selectionRows()\"\n [columns]=\"columns()\"\n [rowActions]=\"selectionRowActions()\"\n dataKey=\"Id\"\n />\n } @else {\n <div\n class=\"rounded-md border border-dashed border-surface-300 bg-surface-50 p-3 text-sm text-muted-color\"\n >\n {{ \"components.entityListField.noSelectedRecords\" | transloco }}\n </div>\n }\n } @else if (comparisonMode()) {\n <!--\n A saved Related list opened from outside its form: its sources' current\n values, and the values preserved when it was saved. A missing baseline is\n said as such \u2014 it is not an empty list.\n -->\n @if (!comparisonReady()) {\n <div class=\"flex flex-col gap-2\">\n <p-skeleton width=\"100%\" height=\"3rem\" borderRadius=\"0.375rem\" />\n <p-skeleton width=\"100%\" height=\"3rem\" borderRadius=\"0.375rem\" />\n </div>\n } @else {\n <section class=\"flex flex-col gap-2\">\n <h4 class=\"text-sm font-semibold text-color\">\n {{ \"components.entityListField.currentValues\" | transloco }}\n </h4>\n @if (liveRows().length) {\n <mt-table\n [noCard]=\"true\"\n [data]=\"liveRows()\"\n [columns]=\"columns()\"\n dataKey=\"Id\"\n />\n } @else {\n <div\n class=\"rounded-md border border-dashed border-surface-300 bg-surface-50 p-3 text-sm text-muted-color\"\n >\n {{ \"components.entityListField.noRelatedItems\" | transloco }}\n </div>\n }\n </section>\n\n <section class=\"flex flex-col gap-2\">\n <h4\n class=\"flex flex-wrap items-baseline gap-2 text-sm font-semibold text-color\"\n >\n {{ \"components.entityListField.preservedValues\" | transloco }}\n @if (preservedAt(); as capturedAt) {\n <span class=\"text-xs font-normal text-muted-color\">\n {{\n \"components.entityListField.preservedAt\"\n | transloco: { date: (capturedAt | mtDateFormat: \"dateTime\") }\n }}\n </span>\n }\n </h4>\n @if (!preservedAvailable()) {\n <div\n class=\"rounded-md border border-dashed border-surface-300 bg-surface-50 p-3 text-sm text-muted-color\"\n >\n {{ \"components.entityListField.noPreservedSnapshot\" | transloco }}\n </div>\n } @else if (preservedRows().length) {\n <mt-table\n [noCard]=\"true\"\n [data]=\"preservedRows()\"\n [columns]=\"columns()\"\n dataKey=\"Id\"\n />\n } @else {\n <div\n class=\"rounded-md border border-dashed border-surface-300 bg-surface-50 p-3 text-sm text-muted-color\"\n >\n {{ \"components.entityListField.preservedEmpty\" | transloco }}\n </div>\n }\n </section>\n\n @if (unavailableCount()) {\n <p class=\"text-xs text-muted-color\">\n {{\n \"components.entityListField.unavailableRecords\"\n | transloco: { count: unavailableCount() }\n }}\n </p>\n }\n }\n } @else if (canWrite()) {\n <div class=\"flex justify-end\">\n <mt-button\n [label]=\"'components.entityListField.add' | transloco\"\n icon=\"general.plus\"\n size=\"small\"\n [disabled]=\"disabled()\"\n (onClick)=\"openAddDialog()\"\n />\n </div>\n <mt-table\n [noCard]=\"true\"\n [data]=\"displayRows()\"\n [columns]=\"tableColumns()\"\n [rowActions]=\"writeRowActions()\"\n dataKey=\"Id\"\n [loading]=\"loading()\"\n />\n } @else if (loading() && !hasRows()) {\n <div class=\"flex flex-col gap-2\">\n <p-skeleton width=\"100%\" height=\"3rem\" borderRadius=\"0.375rem\" />\n <p-skeleton width=\"100%\" height=\"3rem\" borderRadius=\"0.375rem\" />\n </div>\n } @else if (!hasRows()) {\n <div\n class=\"rounded-md border border-dashed border-surface-300 bg-surface-50 p-3 text-sm text-muted-color\"\n >\n {{ \"components.entityListField.noRelatedItems\" | transloco }}\n </div>\n } @else {\n <mt-table\n [noCard]=\"true\"\n [data]=\"displayRows()\"\n [columns]=\"tableColumns()\"\n dataKey=\"Id\"\n [loading]=\"loading()\"\n />\n }\n\n @if (ngControl?.control) {\n <mt-field-validation\n [control]=\"ngControl?.control!\"\n [touched]=\"ngControl?.touched ?? false\"\n />\n }\n</div>\n", styles: [":host{display:block}\n"] }]
|
|
3479
|
+
], changeDetection: ChangeDetectionStrategy.OnPush, host: { class: 'grid gap-1' }, providers: [EntityRuntimeContextStore], template: "<div class=\"flex flex-col gap-2\">\n @if (label()) {\n <label class=\"font-medium text-color\">\n {{ label() }}\n @if (required()) {\n <span class=\"text-red-500\">*</span>\n }\n </label>\n }\n\n @if (errorMessage(); as err) {\n <p-message severity=\"error\" [text]=\"err\" styleClass=\"w-full\" />\n } @else if (noticeKey(); as notice) {\n <div\n class=\"rounded-md border border-dashed border-surface-300 bg-surface-50 p-3 text-sm text-muted-color\"\n >\n {{ notice | transloco }}\n </div>\n } @else if (localReady()) {\n <!--\n A Local list: rows owned by this record, staged into its own submission.\n Add / edit / delete / drag follow the Local operation switches. Opened\n from a table cell, it can also show a saved revision's rows instead.\n -->\n @if (historyAvailable()) {\n <ng-container [ngTemplateOutlet]=\"history\" />\n }\n @if (showingRevision()) {\n <section\n class=\"flex flex-col gap-2 transition-opacity\"\n [class.opacity-60]=\"revisionLoading()\"\n >\n <ng-container [ngTemplateOutlet]=\"preservedHeading\" />\n @if (revisionLocalRows().length) {\n <mt-table\n [noCard]=\"true\"\n [data]=\"revisionLocalRows()\"\n [columns]=\"revisionLocalColumns()\"\n dataKey=\"Id\"\n />\n } @else {\n <div\n class=\"rounded-md border border-dashed border-surface-300 bg-surface-50 p-3 text-sm text-muted-color\"\n >\n {{ \"components.entityListField.preservedEmpty\" | transloco }}\n </div>\n }\n </section>\n } @else {\n @if (localCanCreate()) {\n <div class=\"flex justify-end\">\n <mt-button\n [label]=\"'components.entityListField.add' | transloco\"\n icon=\"general.plus\"\n size=\"small\"\n [disabled]=\"disabled()\"\n (onClick)=\"openLocalRowDialog()\"\n />\n </div>\n }\n @if (localTableRows().length || localCanCreate()) {\n <mt-table\n [noCard]=\"true\"\n [data]=\"localTableRows()\"\n [columns]=\"localColumns()\"\n [rowActions]=\"localRowActions()\"\n [reorderableRows]=\"localCanReorder()\"\n (rowReorder)=\"onLocalReorder($event)\"\n dataKey=\"Id\"\n />\n } @else {\n <div\n class=\"rounded-md border border-dashed border-surface-300 bg-surface-50 p-3 text-sm text-muted-color\"\n >\n {{ \"components.entityListField.noLocalRows\" | transloco }}\n </div>\n }\n }\n } @else if (selectionReady()) {\n <!--\n A Selected list: the source records picked for this record, and nothing\n else. Picking and removing change only which records it holds. Opened\n from a table cell, a saved revision compares the records it held then\n with their values today.\n -->\n @if (historyAvailable()) {\n <ng-container [ngTemplateOutlet]=\"history\" />\n }\n @if (showingRevision()) {\n <ng-container [ngTemplateOutlet]=\"comparisonSections\" />\n } @else {\n @if (selectionWritable()) {\n <div class=\"flex justify-end\">\n <mt-button\n [label]=\"'components.entityListField.selectRecords' | transloco\"\n icon=\"general.plus\"\n size=\"small\"\n [disabled]=\"disabled()\"\n (onClick)=\"openSelectionDialog()\"\n />\n </div>\n }\n @if (selectionRows().length) {\n <mt-table\n [noCard]=\"true\"\n [data]=\"selectionRows()\"\n [columns]=\"columns()\"\n [rowActions]=\"selectionRowActions()\"\n dataKey=\"Id\"\n />\n } @else {\n <div\n class=\"rounded-md border border-dashed border-surface-300 bg-surface-50 p-3 text-sm text-muted-color\"\n >\n {{ \"components.entityListField.noSelectedRecords\" | transloco }}\n </div>\n }\n }\n } @else if (comparisonMode()) {\n <!--\n A saved Related list opened from outside its form: its sources' current\n values, and the values preserved when it was saved. A missing baseline is\n said as such \u2014 it is not an empty list.\n -->\n @if (!comparisonReady()) {\n <div class=\"flex flex-col gap-2\">\n <p-skeleton width=\"100%\" height=\"3rem\" borderRadius=\"0.375rem\" />\n <p-skeleton width=\"100%\" height=\"3rem\" borderRadius=\"0.375rem\" />\n </div>\n } @else {\n <ng-container [ngTemplateOutlet]=\"history\" />\n <ng-container [ngTemplateOutlet]=\"comparisonSections\" />\n }\n } @else if (canWrite()) {\n <div class=\"flex justify-end\">\n <mt-button\n [label]=\"'components.entityListField.add' | transloco\"\n icon=\"general.plus\"\n size=\"small\"\n [disabled]=\"disabled()\"\n (onClick)=\"openAddDialog()\"\n />\n </div>\n <mt-table\n [noCard]=\"true\"\n [data]=\"displayRows()\"\n [columns]=\"tableColumns()\"\n [rowActions]=\"writeRowActions()\"\n dataKey=\"Id\"\n [loading]=\"loading()\"\n />\n } @else if (loading() && !hasRows()) {\n <div class=\"flex flex-col gap-2\">\n <p-skeleton width=\"100%\" height=\"3rem\" borderRadius=\"0.375rem\" />\n <p-skeleton width=\"100%\" height=\"3rem\" borderRadius=\"0.375rem\" />\n </div>\n } @else if (!hasRows()) {\n <div\n class=\"rounded-md border border-dashed border-surface-300 bg-surface-50 p-3 text-sm text-muted-color\"\n >\n {{ \"components.entityListField.noRelatedItems\" | transloco }}\n </div>\n } @else {\n <mt-table\n [noCard]=\"true\"\n [data]=\"displayRows()\"\n [columns]=\"tableColumns()\"\n dataKey=\"Id\"\n [loading]=\"loading()\"\n />\n }\n\n @if (ngControl?.control) {\n <mt-field-validation\n [control]=\"ngControl?.control!\"\n [touched]=\"ngControl?.touched ?? false\"\n />\n }\n</div>\n\n<!--\n Saved list revisions: each successful save of this list, newest first.\n Picking one shows what it preserved \u2014 beside today's values of the records\n it held, for a linked list. Read-only: history is never submitted.\n-->\n<ng-template #history>\n <div class=\"flex flex-wrap items-center justify-between gap-2\">\n <div class=\"flex flex-wrap items-center gap-2\">\n @if (viewedRevision(); as version) {\n <span\n class=\"rounded-md border border-primary-200 bg-primary-50 px-2 py-0.5 text-xs font-medium text-primary-700\"\n >\n {{\n \"components.entityListField.viewingRevision\"\n | transloco: { version: version }\n }}\n </span>\n <mt-button\n [label]=\"'components.entityListField.backToLatest' | transloco\"\n size=\"small\"\n variant=\"text\"\n [disabled]=\"revisionLoading()\"\n (onClick)=\"showRevision(null)\"\n />\n }\n </div>\n <mt-button\n [label]=\"'components.entityListField.revisions' | transloco\"\n icon=\"time.clock-rewind\"\n size=\"small\"\n severity=\"secondary\"\n variant=\"outlined\"\n (onClick)=\"toggleRevisions()\"\n />\n </div>\n\n @if (revisionsOpen()) {\n <div\n class=\"flex flex-col gap-2 rounded-md border border-surface bg-surface-50 p-3\"\n >\n <p class=\"text-xs text-muted-color\">\n {{ \"components.entityListField.revisionsHint\" | transloco }}\n </p>\n @if (revisionsError(); as message) {\n <p class=\"text-sm text-red-600\">{{ message }}</p>\n }\n @for (revision of revisionItems(); track revision.version) {\n <button\n type=\"button\"\n class=\"flex items-center justify-between gap-3 rounded-md border px-3 py-2 text-start text-sm transition-colors\"\n [class.border-primary-200]=\"viewedRevision() === revision.version\"\n [class.bg-primary-50]=\"viewedRevision() === revision.version\"\n [class.border-surface]=\"viewedRevision() !== revision.version\"\n [class.bg-content]=\"viewedRevision() !== revision.version\"\n [disabled]=\"revisionLoading()\"\n (click)=\"showRevision(revision.version)\"\n >\n <span class=\"font-medium text-color\">\n {{\n \"components.entityListField.revisionLabel\"\n | transloco: { version: revision.version }\n }}\n </span>\n <span\n class=\"flex min-w-0 flex-wrap items-center justify-end gap-x-2 text-xs text-muted-color\"\n >\n <span class=\"truncate\">{{ revision.author }}</span>\n <span>{{ revision.createdAt | mtDateFormat: \"dateTime\" }}</span>\n </span>\n </button>\n } @empty {\n @if (!revisionsLoading() && !revisionsError()) {\n <p class=\"text-sm text-muted-color\">\n {{ \"components.entityListField.noRevisions\" | transloco }}\n </p>\n }\n }\n @if (revisionsLoading()) {\n <p-skeleton width=\"100%\" height=\"2.25rem\" borderRadius=\"0.375rem\" />\n } @else if (hasMoreRevisions()) {\n <div class=\"flex justify-center\">\n <mt-button\n [label]=\"'components.entityListField.loadMore' | transloco\"\n size=\"small\"\n variant=\"text\"\n (onClick)=\"loadRevisions()\"\n />\n </div>\n }\n </div>\n }\n\n @if (revisionError(); as message) {\n <div\n class=\"rounded-md border border-red-200 bg-red-50 p-3 text-sm text-red-700\"\n >\n {{ message }}\n </div>\n }\n</ng-template>\n\n<!-- \"Preserved values\", with when they were captured. -->\n<ng-template #preservedHeading>\n <h4\n class=\"flex flex-wrap items-baseline gap-2 text-sm font-semibold text-color\"\n >\n {{ \"components.entityListField.preservedValues\" | transloco }}\n @if (preservedAt(); as capturedAt) {\n <span class=\"text-xs font-normal text-muted-color\">\n {{\n \"components.entityListField.preservedAt\"\n | transloco: { date: (capturedAt | mtDateFormat: \"dateTime\") }\n }}\n </span>\n }\n </h4>\n</ng-template>\n\n<!--\n A linked list's comparison: its source records' current values, and the\n values preserved when it was saved (or at the chosen revision).\n-->\n<ng-template #comparisonSections>\n <section\n class=\"flex flex-col gap-2 transition-opacity\"\n [class.opacity-60]=\"revisionLoading()\"\n >\n <h4 class=\"text-sm font-semibold text-color\">\n {{ \"components.entityListField.currentValues\" | transloco }}\n </h4>\n @if (liveRows().length) {\n <mt-table\n [noCard]=\"true\"\n [data]=\"liveRows()\"\n [columns]=\"columns()\"\n dataKey=\"Id\"\n />\n } @else {\n <div\n class=\"rounded-md border border-dashed border-surface-300 bg-surface-50 p-3 text-sm text-muted-color\"\n >\n {{ \"components.entityListField.noRelatedItems\" | transloco }}\n </div>\n }\n </section>\n\n <section\n class=\"flex flex-col gap-2 transition-opacity\"\n [class.opacity-60]=\"revisionLoading()\"\n >\n <ng-container [ngTemplateOutlet]=\"preservedHeading\" />\n @if (!preservedAvailable()) {\n <div\n class=\"rounded-md border border-dashed border-surface-300 bg-surface-50 p-3 text-sm text-muted-color\"\n >\n {{ \"components.entityListField.noPreservedSnapshot\" | transloco }}\n </div>\n } @else if (preservedRows().length) {\n <mt-table\n [noCard]=\"true\"\n [data]=\"preservedRows()\"\n [columns]=\"columns()\"\n dataKey=\"Id\"\n />\n } @else {\n <div\n class=\"rounded-md border border-dashed border-surface-300 bg-surface-50 p-3 text-sm text-muted-color\"\n >\n {{ \"components.entityListField.preservedEmpty\" | transloco }}\n </div>\n }\n </section>\n\n @if (unavailableCount()) {\n <p class=\"text-xs text-muted-color\">\n {{\n \"components.entityListField.unavailableRecords\"\n | transloco: { count: unavailableCount() }\n }}\n </p>\n }\n</ng-template>\n", styles: [":host{display:block}\n"] }]
|
|
3304
3480
|
}], ctorParameters: () => [], propDecorators: { label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], readonly: [{ type: i0.Input, args: [{ isSignal: true, alias: "readonly", required: false }] }], required: [{ type: i0.Input, args: [{ isSignal: true, alias: "required", required: false }] }], propertyId: [{ type: i0.Input, args: [{ isSignal: true, alias: "propertyId", required: false }] }], propertyKey: [{ type: i0.Input, args: [{ isSignal: true, alias: "propertyKey", required: false }] }], configuration: [{ type: i0.Input, args: [{ isSignal: true, alias: "configuration", required: false }] }], runtimeContext: [{ type: i0.Input, args: [{ isSignal: true, alias: "runtimeContext", required: false }] }], pendingSubmission: [{ type: i0.Input, args: [{ isSignal: true, alias: "pendingSubmission", required: false }] }], lookups: [{ type: i0.Input, args: [{ isSignal: true, alias: "lookups", required: false }] }], context: [{ type: i0.Input, args: [{ isSignal: true, alias: "context", required: false }] }], initialValue: [{ type: i0.Input, args: [{ isSignal: true, alias: "initialValue", required: false }] }] } });
|
|
3305
3481
|
|
|
3306
3482
|
/**
|