@masterteam/components 0.0.301 → 0.0.302
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 +392 -391
- package/assets/i18n/en.json +392 -391
- package/fesm2022/masterteam-components-business-fields.mjs +562 -4
- package/fesm2022/masterteam-components-business-fields.mjs.map +1 -1
- package/fesm2022/masterteam-components-entities.mjs +158 -5
- package/fesm2022/masterteam-components-entities.mjs.map +1 -1
- package/package.json +1 -1
- package/types/masterteam-components-business-fields.d.ts +180 -3
- package/types/masterteam-components-entities.d.ts +126 -3
|
@@ -20,7 +20,7 @@ import { newFieldId, coerceCheckboxValue } from '@masterteam/components';
|
|
|
20
20
|
import { Skeleton } from 'primeng/skeleton';
|
|
21
21
|
import { Message } from 'primeng/message';
|
|
22
22
|
import { ModalService } from '@masterteam/components/modal';
|
|
23
|
-
import {
|
|
23
|
+
import { sortLocalRows, visibleLocalSchemaFields, resolveLocalFieldViewType, resolveLocalFieldLabel, localCellsByFieldId, resolveLocalFieldConfiguration, isEntityListLocalDocument, serializeEntityRawValue, readEntityValueColor, EntityRuntimeContextStore, ENTITY_LIST_TABLE_COMPONENT } from '@masterteam/components/entities';
|
|
24
24
|
import * as i2$1 from 'primeng/inputtext';
|
|
25
25
|
import { InputTextModule } from 'primeng/inputtext';
|
|
26
26
|
|
|
@@ -824,6 +824,130 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImpor
|
|
|
824
824
|
* token is not registered, the field falls back to a minimal text-only popup.
|
|
825
825
|
*/
|
|
826
826
|
const ENTITY_LIST_ADD_DIALOG_COMPONENT = new InjectionToken('ENTITY_LIST_ADD_DIALOG_COMPONENT');
|
|
827
|
+
/**
|
|
828
|
+
* Local counterpart of `ENTITY_LIST_ADD_DIALOG_COMPONENT`, registered by the
|
|
829
|
+
* same `provideEntityListAddForm()`. Without it a Local list is read-only.
|
|
830
|
+
*/
|
|
831
|
+
const ENTITY_LIST_LOCAL_ROW_DIALOG_COMPONENT = new InjectionToken('ENTITY_LIST_LOCAL_ROW_DIALOG_COMPONENT');
|
|
832
|
+
|
|
833
|
+
function createLocalEditorState(base) {
|
|
834
|
+
return {
|
|
835
|
+
base,
|
|
836
|
+
created: [],
|
|
837
|
+
edited: {},
|
|
838
|
+
deleted: [],
|
|
839
|
+
order: null,
|
|
840
|
+
mutationId: null,
|
|
841
|
+
mutationKey: null,
|
|
842
|
+
};
|
|
843
|
+
}
|
|
844
|
+
/**
|
|
845
|
+
* Rows in display order. Until the user reorders, loaded rows keep their
|
|
846
|
+
* stored `order` and new rows go after the last one. After a reorder every row
|
|
847
|
+
* takes its position — the backend requires a non-negative order and nothing
|
|
848
|
+
* more, so positions are the simplest valid numbering.
|
|
849
|
+
*/
|
|
850
|
+
function orderLocalRows(state) {
|
|
851
|
+
const deleted = new Set(state.deleted);
|
|
852
|
+
const loaded = sortLocalRows(state.base?.localRows).filter((row) => !deleted.has(row.rowId));
|
|
853
|
+
const maxOrder = loaded.reduce((max, row) => Math.max(max, row.order ?? 0), -1);
|
|
854
|
+
const rows = [
|
|
855
|
+
...loaded.map((row) => ({
|
|
856
|
+
rowId: row.rowId,
|
|
857
|
+
order: row.order ?? 0,
|
|
858
|
+
existing: row,
|
|
859
|
+
})),
|
|
860
|
+
...state.created.map((row, index) => ({
|
|
861
|
+
rowId: row.rowId,
|
|
862
|
+
order: maxOrder + 1 + index,
|
|
863
|
+
created: row,
|
|
864
|
+
})),
|
|
865
|
+
];
|
|
866
|
+
if (!state.order)
|
|
867
|
+
return rows;
|
|
868
|
+
const position = new Map(state.order.map((rowId, index) => [rowId, index]));
|
|
869
|
+
return rows
|
|
870
|
+
.map((row, index) => ({ row, index }))
|
|
871
|
+
.sort((a, b) => (position.get(a.row.rowId) ?? state.order.length + a.index) -
|
|
872
|
+
(position.get(b.row.rowId) ?? state.order.length + b.index))
|
|
873
|
+
.map(({ row }, index) => ({ ...row, order: index }));
|
|
874
|
+
}
|
|
875
|
+
/**
|
|
876
|
+
* What changed, or null when nothing did.
|
|
877
|
+
*
|
|
878
|
+
* - A loaded row is sent only when a cell or its order changed, with its
|
|
879
|
+
* loaded version and only those cells: omission retains a cell or a row, it
|
|
880
|
+
* never deletes one. A reorder alone sends no cells.
|
|
881
|
+
* - A new row is sent with version 0 and every cell the user filled in.
|
|
882
|
+
* - A removed row is listed in `deletedRowIds` and never also submitted.
|
|
883
|
+
*/
|
|
884
|
+
function buildLocalMutationContent(state) {
|
|
885
|
+
const localRows = [];
|
|
886
|
+
for (const row of orderLocalRows(state)) {
|
|
887
|
+
if (row.existing) {
|
|
888
|
+
const cells = toCells(state.edited[row.rowId]?.cells ?? {});
|
|
889
|
+
if (!cells.length && row.order === (row.existing.order ?? 0))
|
|
890
|
+
continue;
|
|
891
|
+
localRows.push({
|
|
892
|
+
rowId: row.rowId,
|
|
893
|
+
order: row.order,
|
|
894
|
+
version: row.existing.version ?? 0,
|
|
895
|
+
cells,
|
|
896
|
+
});
|
|
897
|
+
continue;
|
|
898
|
+
}
|
|
899
|
+
localRows.push({
|
|
900
|
+
rowId: row.rowId,
|
|
901
|
+
order: row.order,
|
|
902
|
+
version: 0,
|
|
903
|
+
cells: toCells(row.created?.draft.cells ?? {}).filter((cell) => cell.rawValue !== null),
|
|
904
|
+
});
|
|
905
|
+
}
|
|
906
|
+
if (!localRows.length && !state.deleted.length)
|
|
907
|
+
return null;
|
|
908
|
+
return { localRows, deletedRowIds: [...state.deleted] };
|
|
909
|
+
}
|
|
910
|
+
function toCells(cells) {
|
|
911
|
+
return Object.entries(cells).map(([fieldId, rawValue]) => ({
|
|
912
|
+
fieldId,
|
|
913
|
+
rawValue,
|
|
914
|
+
}));
|
|
915
|
+
}
|
|
916
|
+
/**
|
|
917
|
+
* The cells of an edited loaded row that differ from what was loaded.
|
|
918
|
+
* Setting a cell back to its loaded value drops it, so an edit that is undone
|
|
919
|
+
* by hand stops being an edit.
|
|
920
|
+
*/
|
|
921
|
+
function diffLocalCells(loaded, next) {
|
|
922
|
+
const before = new Map((loaded.cells ?? []).map((cell) => [cell.fieldId, cell.rawValue ?? null]));
|
|
923
|
+
const changed = {};
|
|
924
|
+
for (const [fieldId, rawValue] of Object.entries(next)) {
|
|
925
|
+
if ((before.get(fieldId) ?? null) === rawValue)
|
|
926
|
+
continue;
|
|
927
|
+
changed[fieldId] = rawValue;
|
|
928
|
+
}
|
|
929
|
+
return changed;
|
|
930
|
+
}
|
|
931
|
+
/**
|
|
932
|
+
* A v4 UUID. Row ids and mutation ids are parsed as GUIDs by the backend.
|
|
933
|
+
* `crypto.randomUUID` exists only in secure contexts, and these apps are also
|
|
934
|
+
* served over plain HTTP, where `getRandomValues` is still available.
|
|
935
|
+
*/
|
|
936
|
+
function newLocalUuid() {
|
|
937
|
+
if (typeof crypto.randomUUID === 'function')
|
|
938
|
+
return crypto.randomUUID();
|
|
939
|
+
const bytes = crypto.getRandomValues(new Uint8Array(16));
|
|
940
|
+
bytes[6] = (bytes[6] & 0x0f) | 0x40;
|
|
941
|
+
bytes[8] = (bytes[8] & 0x3f) | 0x80;
|
|
942
|
+
const hex = Array.from(bytes, (byte) => byte.toString(16).padStart(2, '0'));
|
|
943
|
+
return [
|
|
944
|
+
hex.slice(0, 4).join(''),
|
|
945
|
+
hex.slice(4, 6).join(''),
|
|
946
|
+
hex.slice(6, 8).join(''),
|
|
947
|
+
hex.slice(8, 10).join(''),
|
|
948
|
+
hex.slice(10, 16).join(''),
|
|
949
|
+
].join('-');
|
|
950
|
+
}
|
|
827
951
|
|
|
828
952
|
function resolveMetadataFailure(status) {
|
|
829
953
|
if (status === 403)
|
|
@@ -867,6 +991,20 @@ const OBJECT_VALUED_VIEW_TYPES = new Set(['User', 'MultiUser']);
|
|
|
867
991
|
const ROW_CHANGE_KEY = '__change';
|
|
868
992
|
/** Column key of the synthetic flag column — never a target property key. */
|
|
869
993
|
const ROW_CHANGE_COLUMN_KEY = '__changeState';
|
|
994
|
+
/** Internal row key marking a Local row added in this session. */
|
|
995
|
+
const ROW_LOCAL_CREATED_KEY = '__localCreated';
|
|
996
|
+
/**
|
|
997
|
+
* The editing state behind each Local value this field emitted, keyed by that
|
|
998
|
+
* value.
|
|
999
|
+
*
|
|
1000
|
+
* A mutation carries only what changed, so it cannot rebuild the table on its
|
|
1001
|
+
* own — and the field is not always the one that emitted it: `mt-dynamic-form`
|
|
1002
|
+
* destroys the sections outside the current wizard step, and the field that
|
|
1003
|
+
* comes back is a new instance handed the form's current value. Keeping the
|
|
1004
|
+
* state out of the payload leaves the submitted JSON exactly the contract,
|
|
1005
|
+
* and a `WeakMap` lets it go with the value.
|
|
1006
|
+
*/
|
|
1007
|
+
const LOCAL_EDITOR_STATES = new WeakMap();
|
|
870
1008
|
/**
|
|
871
1009
|
* Badge colour per staged operation, as a hex: `mt-entity-status` derives its
|
|
872
1010
|
* own 12%-alpha background by slicing the value's `color`, so a Tailwind class
|
|
@@ -1247,6 +1385,146 @@ class EntityListField {
|
|
|
1247
1385
|
},
|
|
1248
1386
|
];
|
|
1249
1387
|
}, ...(ngDevMode ? [{ debugName: "tableColumns" }] : /* istanbul ignore next */ []));
|
|
1388
|
+
// ============================================================================
|
|
1389
|
+
// Local storage (`storageMode: "Local"`) — rows owned by the parent record
|
|
1390
|
+
// ============================================================================
|
|
1391
|
+
/** Loaded document plus this session's edits; see `LocalEditorState`. */
|
|
1392
|
+
localState = signal(createLocalEditorState(null), ...(ngDevMode ? [{ debugName: "localState" }] : /* istanbul ignore next */ []));
|
|
1393
|
+
/** The bound value was a Local document, whatever the metadata says yet. */
|
|
1394
|
+
localValueSeen = signal(false, ...(ngDevMode ? [{ debugName: "localValueSeen" }] : /* istanbul ignore next */ []));
|
|
1395
|
+
/** The last Local value emitted, so its echo does not reset the edits. */
|
|
1396
|
+
lastLocalEmit = null;
|
|
1397
|
+
/**
|
|
1398
|
+
* Rows live inside the parent record: no target records, no `fetch/query`,
|
|
1399
|
+
* and the value is a document of its own rather than operation markers.
|
|
1400
|
+
* Known from the metadata, or earlier from the value itself.
|
|
1401
|
+
*/
|
|
1402
|
+
localMode = computed(() => this.metadata()?.storageMode === 'Local' || this.localValueSeen(), ...(ngDevMode ? [{ debugName: "localMode" }] : /* istanbul ignore next */ []));
|
|
1403
|
+
/**
|
|
1404
|
+
* The schema the table is built from. A loaded value's own schema wins: it
|
|
1405
|
+
* is the one its rows were projected against, and pending or approved
|
|
1406
|
+
* evidence stays pinned to the schema it was submitted with. The metadata's
|
|
1407
|
+
* active schema is the fallback for a list that has never been saved.
|
|
1408
|
+
*/
|
|
1409
|
+
localSchema = computed(() => this.localState().base?.schema ?? this.metadata()?.localSchema ?? null, ...(ngDevMode ? [{ debugName: "localSchema" }] : /* istanbul ignore next */ []));
|
|
1410
|
+
localFields = computed(() => visibleLocalSchemaFields(this.localSchema()), ...(ngDevMode ? [{ debugName: "localFields" }] : /* istanbul ignore next */ []));
|
|
1411
|
+
/**
|
|
1412
|
+
* Render the Local table once the metadata answered: it is the access
|
|
1413
|
+
* boundary, and it carries the operation switches the table obeys.
|
|
1414
|
+
*/
|
|
1415
|
+
localReady = computed(() => this.localMode() && !!this.metadata(), ...(ngDevMode ? [{ debugName: "localReady" }] : /* istanbul ignore next */ []));
|
|
1416
|
+
/**
|
|
1417
|
+
* Writes are staged into the parent's submission, never sent on their own.
|
|
1418
|
+
*
|
|
1419
|
+
* Whether the host lets this field be edited is the form's call —
|
|
1420
|
+
* `readonly` — as it is for a linked list; `pendingSubmission` is not one.
|
|
1421
|
+
* A loaded request is not always a review: a returned request is loaded to
|
|
1422
|
+
* be corrected and resubmitted, and the backend projects the active schema
|
|
1423
|
+
* for exactly that.
|
|
1424
|
+
*/
|
|
1425
|
+
localWritable = computed(() => !!this.localDialogComponent &&
|
|
1426
|
+
!!this.metadata() &&
|
|
1427
|
+
this.writeAllowed() &&
|
|
1428
|
+
!this.readonly() &&
|
|
1429
|
+
!this.disabled() &&
|
|
1430
|
+
this.localFields().length > 0, ...(ngDevMode ? [{ debugName: "localWritable" }] : /* istanbul ignore next */ []));
|
|
1431
|
+
localCanCreate = computed(() => this.localWritable() && this.metadata()?.allowCreate !== false, ...(ngDevMode ? [{ debugName: "localCanCreate" }] : /* istanbul ignore next */ []));
|
|
1432
|
+
localCanEdit = computed(() => this.localWritable() && this.metadata()?.allowEdit !== false, ...(ngDevMode ? [{ debugName: "localCanEdit" }] : /* istanbul ignore next */ []));
|
|
1433
|
+
localCanDelete = computed(() => this.localWritable() && this.metadata()?.allowDelete !== false, ...(ngDevMode ? [{ debugName: "localCanDelete" }] : /* istanbul ignore next */ []));
|
|
1434
|
+
/** Reordering rewrites loaded rows, so it is an edit. */
|
|
1435
|
+
localCanReorder = computed(() => this.localCanEdit() && this.localTableRows().length > 1, ...(ngDevMode ? [{ debugName: "localCanReorder" }] : /* istanbul ignore next */ []));
|
|
1436
|
+
/**
|
|
1437
|
+
* One column per visible schema field, keyed by the field's local id — the
|
|
1438
|
+
* id cells are keyed by. Sorting is off while rows can be dragged: a sorted
|
|
1439
|
+
* table would show an order that is not the one being saved.
|
|
1440
|
+
*/
|
|
1441
|
+
localColumns = computed(() => {
|
|
1442
|
+
const lang = this.lang();
|
|
1443
|
+
const sortable = !this.localCanEdit();
|
|
1444
|
+
return this.localFields().map((field, index) => {
|
|
1445
|
+
const viewType = resolveLocalFieldViewType(field);
|
|
1446
|
+
return {
|
|
1447
|
+
key: field.id,
|
|
1448
|
+
label: resolveLocalFieldLabel(field, lang),
|
|
1449
|
+
type: 'entity',
|
|
1450
|
+
sortable: sortable &&
|
|
1451
|
+
!UNSORTABLE_ENTITY_VIEW_TYPES.has(viewType),
|
|
1452
|
+
viewType,
|
|
1453
|
+
order: index,
|
|
1454
|
+
visible: true,
|
|
1455
|
+
configuration: null,
|
|
1456
|
+
};
|
|
1457
|
+
});
|
|
1458
|
+
}, ...(ngDevMode ? [{ debugName: "localColumns" }] : /* istanbul ignore next */ []));
|
|
1459
|
+
/**
|
|
1460
|
+
* Rows as rendered: loaded rows with this session's edits over them, then
|
|
1461
|
+
* new rows, in the order they would be saved. A loaded cell renders from the
|
|
1462
|
+
* backend's resolved `value`; a cell the user set renders from the dialog's
|
|
1463
|
+
* control value and option label, like a locally added linked row.
|
|
1464
|
+
*/
|
|
1465
|
+
localTableRows = computed(() => {
|
|
1466
|
+
const state = this.localState();
|
|
1467
|
+
const fields = this.localFields();
|
|
1468
|
+
const columns = new Map(this.localColumns().map((column) => [column.key, column]));
|
|
1469
|
+
return orderLocalRows(state).map((entry) => {
|
|
1470
|
+
const cells = entry.existing
|
|
1471
|
+
? localCellsByFieldId(entry.existing)
|
|
1472
|
+
: new Map();
|
|
1473
|
+
const draft = entry.created?.draft ?? state.edited[entry.rowId];
|
|
1474
|
+
const row = {
|
|
1475
|
+
Id: entry.rowId,
|
|
1476
|
+
[ROW_ID_KEY]: entry.rowId,
|
|
1477
|
+
[ROW_LOCAL_CREATED_KEY]: !!entry.created,
|
|
1478
|
+
};
|
|
1479
|
+
for (const field of fields) {
|
|
1480
|
+
const fieldId = field.id;
|
|
1481
|
+
const column = columns.get(fieldId);
|
|
1482
|
+
if (!column)
|
|
1483
|
+
continue;
|
|
1484
|
+
const configuration = resolveLocalFieldConfiguration(field);
|
|
1485
|
+
row[fieldId] =
|
|
1486
|
+
draft && (entry.created || fieldId in draft.cells)
|
|
1487
|
+
? this.buildLocalDraftCell(column, draft, configuration)
|
|
1488
|
+
: this.buildLocalLoadedCell(column, cells.get(fieldId), configuration);
|
|
1489
|
+
}
|
|
1490
|
+
return row;
|
|
1491
|
+
});
|
|
1492
|
+
}, ...(ngDevMode ? [{ debugName: "localTableRows" }] : /* istanbul ignore next */ []));
|
|
1493
|
+
/**
|
|
1494
|
+
* Edit and delete per row. A row added in this session is still part of the
|
|
1495
|
+
* create — changing or dropping it undoes nothing stored — so it follows
|
|
1496
|
+
* `allowCreate`; a loaded row follows `allowEdit` / `allowDelete`.
|
|
1497
|
+
*/
|
|
1498
|
+
localRowActions = computed(() => {
|
|
1499
|
+
this.lang();
|
|
1500
|
+
const canCreate = this.localCanCreate();
|
|
1501
|
+
const canEdit = this.localCanEdit();
|
|
1502
|
+
const canDelete = this.localCanDelete();
|
|
1503
|
+
const isCreated = (row) => row[ROW_LOCAL_CREATED_KEY] === true;
|
|
1504
|
+
const actions = [];
|
|
1505
|
+
if (canCreate || canEdit) {
|
|
1506
|
+
actions.push({
|
|
1507
|
+
icon: 'custom.pencil',
|
|
1508
|
+
tooltip: this.transloco.translate('components.entityListField.edit'),
|
|
1509
|
+
hidden: (row) => isCreated(row) ? !canCreate : !canEdit,
|
|
1510
|
+
action: (row) => this.openLocalRowDialog(row),
|
|
1511
|
+
});
|
|
1512
|
+
}
|
|
1513
|
+
if (canCreate || canDelete) {
|
|
1514
|
+
actions.push({
|
|
1515
|
+
icon: 'general.trash-01',
|
|
1516
|
+
tooltip: this.transloco.translate('components.entityListField.delete'),
|
|
1517
|
+
color: 'danger',
|
|
1518
|
+
confirmation: {
|
|
1519
|
+
type: 'popup',
|
|
1520
|
+
confirmationType: 'delete',
|
|
1521
|
+
},
|
|
1522
|
+
hidden: (row) => isCreated(row) ? !canCreate : !canDelete,
|
|
1523
|
+
action: (row) => this.deleteLocalRow(row),
|
|
1524
|
+
});
|
|
1525
|
+
}
|
|
1526
|
+
return actions;
|
|
1527
|
+
}, ...(ngDevMode ? [{ debugName: "localRowActions" }] : /* istanbul ignore next */ []));
|
|
1250
1528
|
/** Enough context to ask the backend what this field should render. */
|
|
1251
1529
|
hasRequiredContext = computed(() => this.propertyKeyId() > 0 && Number(this.levelId()) > 0, ...(ngDevMode ? [{ debugName: "hasRequiredContext" }] : /* istanbul ignore next */ []));
|
|
1252
1530
|
/**
|
|
@@ -1268,6 +1546,13 @@ class EntityListField {
|
|
|
1268
1546
|
}
|
|
1269
1547
|
if (!this.metadata())
|
|
1270
1548
|
return null;
|
|
1549
|
+
// A Local list reads nothing from the source module; it needs only a
|
|
1550
|
+
// schema to render its own rows with.
|
|
1551
|
+
if (this.localMode()) {
|
|
1552
|
+
return this.localFields().length
|
|
1553
|
+
? null
|
|
1554
|
+
: 'components.entityListField.missingConfiguration';
|
|
1555
|
+
}
|
|
1271
1556
|
if (!this.moduleBacked()) {
|
|
1272
1557
|
return 'components.entityListField.missingConfiguration';
|
|
1273
1558
|
}
|
|
@@ -1294,6 +1579,12 @@ class EntityListField {
|
|
|
1294
1579
|
* `writeFields`.
|
|
1295
1580
|
*/
|
|
1296
1581
|
addDialogComponent = inject(ENTITY_LIST_ADD_DIALOG_COMPONENT, { optional: true });
|
|
1582
|
+
/**
|
|
1583
|
+
* Row dialog of a Local list, built from the schema's captured definitions
|
|
1584
|
+
* (`provideEntityListAddForm()` registers it beside the linked one). Without
|
|
1585
|
+
* it a Local list renders read-only.
|
|
1586
|
+
*/
|
|
1587
|
+
localDialogComponent = inject(ENTITY_LIST_LOCAL_ROW_DIALOG_COMPONENT, { optional: true });
|
|
1297
1588
|
constructor() {
|
|
1298
1589
|
this.ngControl = inject(NgControl, { self: true, optional: true });
|
|
1299
1590
|
if (this.ngControl) {
|
|
@@ -1327,6 +1618,8 @@ class EntityListField {
|
|
|
1327
1618
|
// CVA
|
|
1328
1619
|
// ============================================================================
|
|
1329
1620
|
writeValue(value) {
|
|
1621
|
+
if (this.writeLocalValue(value))
|
|
1622
|
+
return;
|
|
1330
1623
|
const incoming = this.coerceStoredValue(value);
|
|
1331
1624
|
// Ignore the echo of our own emission (DynamicForm re-writes the model on
|
|
1332
1625
|
// every value change) so pending edits/deletions are not reset.
|
|
@@ -1346,6 +1639,46 @@ class EntityListField {
|
|
|
1346
1639
|
this.stagedDeletedIds.set([]);
|
|
1347
1640
|
this.rowDrafts.set({});
|
|
1348
1641
|
}
|
|
1642
|
+
/**
|
|
1643
|
+
* Take a Local document, and say whether it was one.
|
|
1644
|
+
*
|
|
1645
|
+
* - Our own emission echoed back (`mt-dynamic-form` re-writes the model on
|
|
1646
|
+
* every change) keeps the session's edits.
|
|
1647
|
+
* - A value some instance of this field emitted restores that instance's
|
|
1648
|
+
* state — see `LOCAL_EDITOR_STATES`.
|
|
1649
|
+
* - A document the backend sent starts a fresh session on it: the projection
|
|
1650
|
+
* `process-form-load` returns (its `schema` set, cells rendered), or the
|
|
1651
|
+
* stored document the fetch endpoints return for a preview (`schema:
|
|
1652
|
+
* null`, cells unrendered) — the schema then comes from the metadata.
|
|
1653
|
+
* Every backend document carries the `schema` member, null or not; a
|
|
1654
|
+
* mutation never does. So a mutation nobody here emitted has no rows to
|
|
1655
|
+
* rebuild the table from and is left as the control's value, untouched
|
|
1656
|
+
* until the user edits.
|
|
1657
|
+
*
|
|
1658
|
+
* An empty value resets the Local session too — a form reset — and still
|
|
1659
|
+
* falls through, since which storage the list uses may not be known yet.
|
|
1660
|
+
*/
|
|
1661
|
+
writeLocalValue(value) {
|
|
1662
|
+
const incoming = this.coerceStoredValue(value);
|
|
1663
|
+
if (!isEntityListLocalDocument(incoming)) {
|
|
1664
|
+
if (incoming == null) {
|
|
1665
|
+
this.lastLocalEmit = null;
|
|
1666
|
+
this.localState.set(createLocalEditorState(null));
|
|
1667
|
+
}
|
|
1668
|
+
return false;
|
|
1669
|
+
}
|
|
1670
|
+
this.localValueSeen.set(true);
|
|
1671
|
+
if (incoming === this.lastLocalEmit)
|
|
1672
|
+
return true;
|
|
1673
|
+
this.lastLocalEmit = null;
|
|
1674
|
+
const restored = LOCAL_EDITOR_STATES.get(incoming);
|
|
1675
|
+
if (restored) {
|
|
1676
|
+
this.localState.set(restored);
|
|
1677
|
+
return true;
|
|
1678
|
+
}
|
|
1679
|
+
this.localState.set(createLocalEditorState('schema' in incoming ? incoming : null));
|
|
1680
|
+
return true;
|
|
1681
|
+
}
|
|
1349
1682
|
/**
|
|
1350
1683
|
* True when the written value still carries exactly the rows and deletions
|
|
1351
1684
|
* we last emitted — i.e. the form is echoing our own value back rather than
|
|
@@ -1550,6 +1883,226 @@ class EntityListField {
|
|
|
1550
1883
|
this.clearRowDraft(rowId);
|
|
1551
1884
|
this.emitValue();
|
|
1552
1885
|
}
|
|
1886
|
+
// ============================================================================
|
|
1887
|
+
// Local write mode — staged into the parent's own submission
|
|
1888
|
+
// ============================================================================
|
|
1889
|
+
/**
|
|
1890
|
+
* Add a Local row (no `row`) or edit one. The dialog is built from the
|
|
1891
|
+
* schema; its `submit` map is serialized here into cell `rawValue`s.
|
|
1892
|
+
*
|
|
1893
|
+
* A loaded row keeps only the cells that differ from what was loaded, so an
|
|
1894
|
+
* untouched cell is omitted and retained. Emptying a cell that had a value
|
|
1895
|
+
* is a clear, sent as `null` — the dialog is filled from every schema field,
|
|
1896
|
+
* so an empty control here really was emptied.
|
|
1897
|
+
*/
|
|
1898
|
+
openLocalRowDialog(row) {
|
|
1899
|
+
const component = this.localDialogComponent;
|
|
1900
|
+
if (!component || this.disabled())
|
|
1901
|
+
return;
|
|
1902
|
+
const state = this.localState();
|
|
1903
|
+
const rowId = row ? String(row[ROW_ID_KEY] ?? '') : null;
|
|
1904
|
+
const created = rowId
|
|
1905
|
+
? state.created.find((entry) => entry.rowId === rowId)
|
|
1906
|
+
: undefined;
|
|
1907
|
+
const existing = rowId && !created
|
|
1908
|
+
? state.base?.localRows?.find((entry) => entry.rowId === rowId)
|
|
1909
|
+
: undefined;
|
|
1910
|
+
const ref = this.modal.openModal(component, 'dialog', {
|
|
1911
|
+
header: this.transloco.translate(row
|
|
1912
|
+
? 'components.entityListField.edit'
|
|
1913
|
+
: 'components.entityListField.add'),
|
|
1914
|
+
styleClass: '!w-[48rem] max-w-[96vw]',
|
|
1915
|
+
dismissableMask: true,
|
|
1916
|
+
inputValues: {
|
|
1917
|
+
fields: this.localFields(),
|
|
1918
|
+
lookups: this.lookups(),
|
|
1919
|
+
initialCells: existing
|
|
1920
|
+
? Object.fromEntries(localCellsByFieldId(existing))
|
|
1921
|
+
: undefined,
|
|
1922
|
+
initialValues: created?.draft.values ??
|
|
1923
|
+
(rowId ? state.edited[rowId]?.values : undefined),
|
|
1924
|
+
isEdit: !!row,
|
|
1925
|
+
},
|
|
1926
|
+
});
|
|
1927
|
+
ref.onClose.pipe(take(1)).subscribe((result) => {
|
|
1928
|
+
const parsed = this.parseDialogResult(result);
|
|
1929
|
+
if (!parsed)
|
|
1930
|
+
return;
|
|
1931
|
+
const draft = {
|
|
1932
|
+
cells: this.toLocalCells(parsed.values, parsed.submit),
|
|
1933
|
+
values: parsed.values,
|
|
1934
|
+
display: parsed.display,
|
|
1935
|
+
};
|
|
1936
|
+
const current = this.localState();
|
|
1937
|
+
if (!rowId) {
|
|
1938
|
+
this.emitLocal({
|
|
1939
|
+
...current,
|
|
1940
|
+
created: [...current.created, { rowId: newLocalUuid(), draft }],
|
|
1941
|
+
});
|
|
1942
|
+
return;
|
|
1943
|
+
}
|
|
1944
|
+
if (created) {
|
|
1945
|
+
this.emitLocal({
|
|
1946
|
+
...current,
|
|
1947
|
+
created: current.created.map((entry) => entry.rowId === rowId ? { ...entry, draft } : entry),
|
|
1948
|
+
});
|
|
1949
|
+
return;
|
|
1950
|
+
}
|
|
1951
|
+
if (!existing)
|
|
1952
|
+
return;
|
|
1953
|
+
const edited = { ...current.edited };
|
|
1954
|
+
const changed = diffLocalCells(existing, draft.cells);
|
|
1955
|
+
if (Object.keys(changed).length > 0) {
|
|
1956
|
+
edited[rowId] = { ...draft, cells: changed };
|
|
1957
|
+
}
|
|
1958
|
+
else {
|
|
1959
|
+
delete edited[rowId];
|
|
1960
|
+
}
|
|
1961
|
+
this.emitLocal({ ...current, edited });
|
|
1962
|
+
});
|
|
1963
|
+
}
|
|
1964
|
+
/**
|
|
1965
|
+
* Remove a Local row. A loaded row is listed in `deletedRowIds` and its
|
|
1966
|
+
* pending edit dropped — a row is never both deleted and submitted. A row
|
|
1967
|
+
* added in this session just disappears.
|
|
1968
|
+
*/
|
|
1969
|
+
deleteLocalRow(row) {
|
|
1970
|
+
if (this.disabled())
|
|
1971
|
+
return;
|
|
1972
|
+
const rowId = String(row[ROW_ID_KEY] ?? '');
|
|
1973
|
+
const current = this.localState();
|
|
1974
|
+
if (current.created.some((entry) => entry.rowId === rowId)) {
|
|
1975
|
+
this.emitLocal({
|
|
1976
|
+
...current,
|
|
1977
|
+
created: current.created.filter((entry) => entry.rowId !== rowId),
|
|
1978
|
+
});
|
|
1979
|
+
return;
|
|
1980
|
+
}
|
|
1981
|
+
const edited = { ...current.edited };
|
|
1982
|
+
delete edited[rowId];
|
|
1983
|
+
this.emitLocal({
|
|
1984
|
+
...current,
|
|
1985
|
+
edited,
|
|
1986
|
+
deleted: current.deleted.includes(rowId)
|
|
1987
|
+
? current.deleted
|
|
1988
|
+
: [...current.deleted, rowId],
|
|
1989
|
+
});
|
|
1990
|
+
}
|
|
1991
|
+
/**
|
|
1992
|
+
* Apply a drag within the table. Replays PrimeNG's own move on the rows as
|
|
1993
|
+
* rendered: `p-table` is bound to a derived array, so the event's `value`
|
|
1994
|
+
* is not reliably the reordered one.
|
|
1995
|
+
*/
|
|
1996
|
+
onLocalReorder(event) {
|
|
1997
|
+
const from = Number(event?.dragIndex);
|
|
1998
|
+
const to = Number(event?.dropIndex);
|
|
1999
|
+
const ids = this.localTableRows().map((row) => String(row[ROW_ID_KEY]));
|
|
2000
|
+
if (!Number.isInteger(from) ||
|
|
2001
|
+
!Number.isInteger(to) ||
|
|
2002
|
+
from === to ||
|
|
2003
|
+
from < 0 ||
|
|
2004
|
+
to < 0 ||
|
|
2005
|
+
from >= ids.length ||
|
|
2006
|
+
to >= ids.length) {
|
|
2007
|
+
return;
|
|
2008
|
+
}
|
|
2009
|
+
const [moved] = ids.splice(from, 1);
|
|
2010
|
+
ids.splice(to, 0, moved);
|
|
2011
|
+
this.emitLocal({ ...this.localState(), order: ids });
|
|
2012
|
+
}
|
|
2013
|
+
/**
|
|
2014
|
+
* Serialize one dialog result into cells, by field id, for every visible
|
|
2015
|
+
* field. `submit` is the dialog's reduction to stored scalars and wins over
|
|
2016
|
+
* the raw control value, as for linked rows.
|
|
2017
|
+
*/
|
|
2018
|
+
toLocalCells(values, submit) {
|
|
2019
|
+
const cells = {};
|
|
2020
|
+
for (const field of this.localFields()) {
|
|
2021
|
+
const fieldId = field.id;
|
|
2022
|
+
cells[fieldId] = this.toRawValue(fieldId in submit ? submit[fieldId] : values[fieldId]);
|
|
2023
|
+
}
|
|
2024
|
+
return cells;
|
|
2025
|
+
}
|
|
2026
|
+
/**
|
|
2027
|
+
* Publish the Local state as the control's value.
|
|
2028
|
+
*
|
|
2029
|
+
* With changes, the value is a mutation: the loaded list and schema
|
|
2030
|
+
* versions, only the changed rows and cells, explicit deletions, and a
|
|
2031
|
+
* `mutationId` that stays the same while the content does (a retry of the
|
|
2032
|
+
* same save) and changes with it (a new save). Without changes it is the
|
|
2033
|
+
* loaded document again, which `mapFormValueToSubmitFields` leaves out of the
|
|
2034
|
+
* submission — an unchanged Local list is omitted, never re-sent.
|
|
2035
|
+
*/
|
|
2036
|
+
emitLocal(next) {
|
|
2037
|
+
const content = buildLocalMutationContent(next);
|
|
2038
|
+
let state = next;
|
|
2039
|
+
let value = next.base;
|
|
2040
|
+
if (content) {
|
|
2041
|
+
const mutation = {
|
|
2042
|
+
storageMode: 'Local',
|
|
2043
|
+
formatVersion: 1,
|
|
2044
|
+
schemaVersion: next.base?.schemaVersion ??
|
|
2045
|
+
this.metadata()?.localSchema?.version ??
|
|
2046
|
+
'',
|
|
2047
|
+
version: next.base?.version ?? 0,
|
|
2048
|
+
...content,
|
|
2049
|
+
};
|
|
2050
|
+
const mutationKey = JSON.stringify(mutation);
|
|
2051
|
+
const mutationId = next.mutationKey === mutationKey && next.mutationId
|
|
2052
|
+
? next.mutationId
|
|
2053
|
+
: newLocalUuid();
|
|
2054
|
+
state = { ...next, mutationId, mutationKey };
|
|
2055
|
+
value = { ...mutation, mutationId };
|
|
2056
|
+
}
|
|
2057
|
+
else {
|
|
2058
|
+
state = { ...next, mutationId: null, mutationKey: null };
|
|
2059
|
+
}
|
|
2060
|
+
this.localState.set(state);
|
|
2061
|
+
if (value)
|
|
2062
|
+
LOCAL_EDITOR_STATES.set(value, state);
|
|
2063
|
+
this.lastLocalEmit = value;
|
|
2064
|
+
this.onModelChange(value);
|
|
2065
|
+
this.onTouched();
|
|
2066
|
+
}
|
|
2067
|
+
/** A cell the user set in this session, shaped like a backend one. */
|
|
2068
|
+
buildLocalDraftCell(column, draft, configuration) {
|
|
2069
|
+
const fieldId = column.key;
|
|
2070
|
+
const raw = draft.values[fieldId];
|
|
2071
|
+
const label = draft.display[fieldId];
|
|
2072
|
+
// A multi-select holds ids and resolves to labels; print the labels.
|
|
2073
|
+
const value = Array.isArray(raw) && Array.isArray(label)
|
|
2074
|
+
? label.join(', ')
|
|
2075
|
+
: this.toLocalEntityValue(column.viewType, raw, label);
|
|
2076
|
+
return {
|
|
2077
|
+
key: fieldId,
|
|
2078
|
+
name: column.label,
|
|
2079
|
+
viewType: (column.viewType ?? 'Text'),
|
|
2080
|
+
value: (value !== null && typeof value === 'object'
|
|
2081
|
+
? value
|
|
2082
|
+
: (this.toRawValue(value) ?? '')),
|
|
2083
|
+
rawValue: draft.cells[fieldId] ?? undefined,
|
|
2084
|
+
propertyConfiguration: configuration ?? undefined,
|
|
2085
|
+
};
|
|
2086
|
+
}
|
|
2087
|
+
/**
|
|
2088
|
+
* A loaded cell: the backend's rendered `value` beside its `rawValue`. A
|
|
2089
|
+
* stored document from the fetch endpoints has no rendered values, so the
|
|
2090
|
+
* raw one is shaped the way a locally set cell would be — a user id still
|
|
2091
|
+
* renders as a user, though only as its id until the backend renders it.
|
|
2092
|
+
*/
|
|
2093
|
+
buildLocalLoadedCell(column, cell, configuration) {
|
|
2094
|
+
const value = cell?.value != null
|
|
2095
|
+
? cell.value
|
|
2096
|
+
: this.toLocalEntityValue(column.viewType, cell?.rawValue, undefined);
|
|
2097
|
+
return {
|
|
2098
|
+
key: column.key,
|
|
2099
|
+
name: column.label,
|
|
2100
|
+
viewType: (column.viewType ?? 'Text'),
|
|
2101
|
+
value: (value ?? ''),
|
|
2102
|
+
rawValue: serializeEntityRawValue(cell?.rawValue),
|
|
2103
|
+
propertyConfiguration: configuration ?? undefined,
|
|
2104
|
+
};
|
|
2105
|
+
}
|
|
1553
2106
|
/**
|
|
1554
2107
|
* Normalize the add/edit dialog close payload. The rich dialog returns
|
|
1555
2108
|
* `{ values, display }`; a custom add-dialog may still return the raw values
|
|
@@ -1893,6 +2446,11 @@ class EntityListField {
|
|
|
1893
2446
|
*/
|
|
1894
2447
|
applyMetadata(metadata, levelDataId) {
|
|
1895
2448
|
this.metadata.set(metadata);
|
|
2449
|
+
// A Local list's rows are the value; the source module is not read.
|
|
2450
|
+
if (this.localMode()) {
|
|
2451
|
+
this.loading.set(false);
|
|
2452
|
+
return;
|
|
2453
|
+
}
|
|
1896
2454
|
this.columns.set(this.buildColumns(metadata));
|
|
1897
2455
|
if (!this.moduleBacked() ||
|
|
1898
2456
|
!this.canRead() ||
|
|
@@ -2065,7 +2623,7 @@ class EntityListField {
|
|
|
2065
2623
|
};
|
|
2066
2624
|
}
|
|
2067
2625
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: EntityListField, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2068
|
-
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 }, 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\">\
|
|
2626
|
+
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 }, 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 (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" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
2069
2627
|
}
|
|
2070
2628
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: EntityListField, decorators: [{
|
|
2071
2629
|
type: Component,
|
|
@@ -2077,7 +2635,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImpor
|
|
|
2077
2635
|
Table,
|
|
2078
2636
|
Button,
|
|
2079
2637
|
TranslocoPipe,
|
|
2080
|
-
], changeDetection: ChangeDetectionStrategy.OnPush, host: { class: 'grid gap-1' }, providers: [EntityRuntimeContextStore], template: "<div class=\"flex flex-col gap-2\">\
|
|
2638
|
+
], 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 (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"] }]
|
|
2081
2639
|
}], 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 }] }], 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 }] }] } });
|
|
2082
2640
|
|
|
2083
2641
|
/**
|
|
@@ -2530,5 +3088,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImpor
|
|
|
2530
3088
|
* Generated bundle index. Do not edit.
|
|
2531
3089
|
*/
|
|
2532
3090
|
|
|
2533
|
-
export { ENTITY_LIST_ADD_DIALOG_COMPONENT, EntityListField, LOOKUP_CHECK_LIST_FORM_COMPONENT, LookupMatrixField, LookupModuleCheckListField, ScheduleItemSelectorField, SchedulePredecessorField, SchemaConnectionField, provideEntityListTablePreview };
|
|
3091
|
+
export { ENTITY_LIST_ADD_DIALOG_COMPONENT, ENTITY_LIST_LOCAL_ROW_DIALOG_COMPONENT, EntityListField, LOOKUP_CHECK_LIST_FORM_COMPONENT, LookupMatrixField, LookupModuleCheckListField, ScheduleItemSelectorField, SchedulePredecessorField, SchemaConnectionField, provideEntityListTablePreview };
|
|
2534
3092
|
//# sourceMappingURL=masterteam-components-business-fields.mjs.map
|