@masterteam/components 0.0.293 → 0.0.295

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.
@@ -6,7 +6,7 @@ import * as i1 from '@angular/forms';
6
6
  import { ControlContainer, NgControl, FormsModule, Validators } from '@angular/forms';
7
7
  import * as i2 from '@jsverse/transloco';
8
8
  import { TranslocoService, TranslocoModule, TranslocoPipe } from '@jsverse/transloco';
9
- import { startWith, finalize, catchError, of, take, map, throwError, expand, EMPTY, reduce } from 'rxjs';
9
+ import { startWith, finalize, catchError, of, take, expand, EMPTY, reduce, map } from 'rxjs';
10
10
  import { Tooltip } from '@masterteam/components/tooltip';
11
11
  import { Icon } from '@masterteam/icons';
12
12
  import { SelectField } from '@masterteam/components/select-field';
@@ -755,6 +755,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImpor
755
755
  */
756
756
  const ENTITY_LIST_ADD_DIALOG_COMPONENT = new InjectionToken('ENTITY_LIST_ADD_DIALOG_COMPONENT');
757
757
 
758
+ function resolveMetadataFailure(status) {
759
+ if (status === 403)
760
+ return 'forbidden';
761
+ return status === 400 || status === 404 ? 'unavailable' : 'failed';
762
+ }
758
763
  const UNSORTABLE_ENTITY_VIEW_TYPES = new Set([
759
764
  'Attachment',
760
765
  'Checkbox',
@@ -788,27 +793,25 @@ const ROW_PREFILL_KEY = '__prefill';
788
793
  * object and would otherwise display a bare id.
789
794
  */
790
795
  const OBJECT_VALUED_VIEW_TYPES = new Set(['User', 'MultiUser']);
791
- /**
792
- * Stable sort by the payload's `order`, falling back to array position when it
793
- * is absent. Used to flatten a process form into reading order: `order` on a
794
- * form field is *section-relative*, so every section restarts at 0 and the
795
- * numbers only mean anything within their own section.
796
- */
797
- function sortByOrder(items) {
798
- return items
799
- .map((item, index) => ({ item, index }))
800
- .sort((a, b) => (a.item.order ?? a.index) - (b.item.order ?? b.index) ||
801
- a.index - b.index)
802
- .map(({ item }) => item);
803
- }
804
796
  class EntityListField {
805
797
  // Inputs
806
798
  label = input('', ...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
807
799
  readonly = input(false, ...(ngDevMode ? [{ debugName: "readonly" }] : /* istanbul ignore next */ []));
808
800
  required = input(false, ...(ngDevMode ? [{ debugName: "required" }] : /* istanbul ignore next */ []));
809
- /** EntityList property id (kept for back-compat; unused by fetch/query). */
801
+ /**
802
+ * EntityList property id. **Required** — with the owning level it addresses
803
+ * the table-metadata endpoint, which is the only source of this field's
804
+ * effective configuration.
805
+ */
810
806
  propertyId = input(null, ...(ngDevMode ? [{ debugName: "propertyId" }] : /* istanbul ignore next */ []));
811
- /** Property configuration (sourceType, moduleId, access, readFields, etc). */
807
+ /**
808
+ * Stored property configuration (sourceType, moduleId, access, readFields …).
809
+ *
810
+ * Kept for hosts that still bind it, but **not read**: the stored value is
811
+ * the un-overridden one, and the backend resolves the level-module override
812
+ * before answering the metadata request. Everything this field gates on comes
813
+ * from that response.
814
+ */
812
815
  configuration = input(null, ...(ngDevMode ? [{ debugName: "configuration" }] : /* istanbul ignore next */ []));
813
816
  /** Runtime ids needed to call the read endpoint. */
814
817
  runtimeContext = input(null, ...(ngDevMode ? [{ debugName: "runtimeContext" }] : /* istanbul ignore next */ []));
@@ -830,6 +833,9 @@ class EntityListField {
830
833
  context = input(undefined, ...(ngDevMode ? [{ debugName: "context" }] : /* istanbul ignore next */ []));
831
834
  // CVA state — pass-through value (EntityList stored JSON shape).
832
835
  storedValue = signal(null, ...(ngDevMode ? [{ debugName: "storedValue" }] : /* istanbul ignore next */ []));
836
+ /** Runtime-scoped metadata; null until the endpoint answers. */
837
+ metadata = signal(null, ...(ngDevMode ? [{ debugName: "metadata" }] : /* istanbul ignore next */ []));
838
+ metadataFailure = signal(null, ...(ngDevMode ? [{ debugName: "metadataFailure" }] : /* istanbul ignore next */ []));
833
839
  // Loaded table state.
834
840
  columns = signal([], ...(ngDevMode ? [{ debugName: "columns" }] : /* istanbul ignore next */ []));
835
841
  /** Rows loaded from the backend (existing target records). */
@@ -847,25 +853,49 @@ class EntityListField {
847
853
  const raw = this.runtimeContext()?.levelDataId ?? null;
848
854
  return raw == null || raw === '' ? null : raw;
849
855
  }, ...(ngDevMode ? [{ debugName: "levelDataId" }] : /* istanbul ignore next */ []));
850
- moduleId = computed(() => {
851
- const raw = this.configuration()
852
- ?.moduleId;
853
- return raw == null || raw === '' ? null : raw;
854
- }, ...(ngDevMode ? [{ debugName: "moduleId" }] : /* istanbul ignore next */ []));
855
- readFields = computed(() => {
856
- const raw = this.configuration()
857
- ?.readFields;
858
- if (!Array.isArray(raw))
859
- return [];
860
- return raw.filter((f) => typeof f === 'string' && f.length > 0);
861
- }, ...(ngDevMode ? [{ debugName: "readFields" }] : /* istanbul ignore next */ []));
862
- /** Normalized `access` from the property configuration. */
856
+ /** EntityList property id as a number; `0` when the host bound none. */
857
+ propertyKeyId = computed(() => Number(this.propertyId() ?? 0), ...(ngDevMode ? [{ debugName: "propertyKeyId" }] : /* istanbul ignore next */ []));
858
+ /** Target module id, as resolved for this level. */
859
+ moduleId = computed(() => this.metadata()?.moduleId ?? null, ...(ngDevMode ? [{ debugName: "moduleId" }] : /* istanbul ignore next */ []));
860
+ /** Canonical readable target keys — the columns this field renders. */
861
+ readFields = computed(() => this.metadata()?.readFields ?? [], ...(ngDevMode ? [{ debugName: "readFields" }] : /* istanbul ignore next */ []));
862
+ /**
863
+ * Keys the row projection asks for: readable **and** writable.
864
+ *
865
+ * A writable key that is not readable has no column, but the edit dialog
866
+ * still renders it — and several are `isRequired` on the target module (the
867
+ * schedule module's `task_planned_finish` is). Projecting only `readFields`
868
+ * left those controls empty, so the form was invalid until the user retyped a
869
+ * value that already existed, and a different value silently overwrote the
870
+ * stored one. Read order first, so the request body stays stable.
871
+ */
872
+ projectedKeys = computed(() => [
873
+ ...new Set([...this.readFields(), ...this.writeFields()]),
874
+ ], ...(ngDevMode ? [{ debugName: "projectedKeys" }] : /* istanbul ignore next */ []));
875
+ /** Effective `access` for this level, as resolved by the backend. */
863
876
  accessMode = computed(() => {
864
- const raw = this.configuration()?.access;
877
+ const raw = this.metadata()?.access;
865
878
  if (raw == null || raw === '')
866
- return 'Auto';
867
- return ACCESS_ALIASES[String(raw).trim().toLowerCase()] ?? 'Auto';
879
+ return 'None';
880
+ return ACCESS_ALIASES[String(raw).trim().toLowerCase()] ?? 'None';
868
881
  }, ...(ngDevMode ? [{ debugName: "accessMode" }] : /* istanbul ignore next */ []));
882
+ /**
883
+ * The table is backed by target module records. Inline lists resolve their
884
+ * rows from the stored value and have no module form to write through, so
885
+ * this field does not render them.
886
+ */
887
+ moduleBacked = computed(() => {
888
+ const metadata = this.metadata();
889
+ return metadata?.sourceType === 'Module' && Number(metadata.moduleId) > 0;
890
+ }, ...(ngDevMode ? [{ debugName: "moduleBacked" }] : /* istanbul ignore next */ []));
891
+ /**
892
+ * Rows live in this property's own value rather than in target records: the
893
+ * module supplies the columns and the editors, nothing else. The whole row
894
+ * array is submitted on every save and no target record is ever written.
895
+ */
896
+ embedded = computed(() => this.moduleBacked() && this.metadata()?.storageMode === 'Embedded', ...(ngDevMode ? [{ debugName: "embedded" }] : /* istanbul ignore next */ []));
897
+ /** The module record that owns an embedded value — the rows `instanceId`. */
898
+ ownerRecordId = computed(() => Number(this.runtimeContext()?.moduleDataId ?? 0), ...(ngDevMode ? [{ debugName: "ownerRecordId" }] : /* istanbul ignore next */ []));
869
899
  canRead = computed(() => {
870
900
  const access = this.accessMode();
871
901
  return access === 'Auto' || access === 'Read' || access === 'ReadWrite';
@@ -882,14 +912,14 @@ class EntityListField {
882
912
  return access === 'Auto' || access === 'Write' || access === 'ReadWrite';
883
913
  }, ...(ngDevMode ? [{ debugName: "writeAllowed" }] : /* istanbul ignore next */ []));
884
914
  /** Write UI is rendered only when access allows it and the field is editable. */
885
- canWrite = computed(() => this.writeAllowed() && !this.readonly(), ...(ngDevMode ? [{ debugName: "canWrite" }] : /* istanbul ignore next */ []));
886
- writeFields = computed(() => {
887
- const raw = this.configuration()
888
- ?.writeFields;
889
- if (!Array.isArray(raw))
890
- return [];
891
- return raw.filter((f) => typeof f === 'string' && f.length > 0);
892
- }, ...(ngDevMode ? [{ debugName: "writeFields" }] : /* istanbul ignore next */ []));
915
+ canWrite = computed(() => this.writeAllowed() && this.moduleBacked() && !this.readonly(), ...(ngDevMode ? [{ debugName: "canWrite" }] : /* istanbul ignore next */ []));
916
+ /**
917
+ * Canonical writable target keys. They are what the add/edit dialog renders
918
+ * and what a submitted row is restricted to — canonical, so a configuration
919
+ * that listed `normalizedKey` aliases still matches the target module's form
920
+ * value keys.
921
+ */
922
+ writeFields = computed(() => this.metadata()?.writeFields ?? [], ...(ngDevMode ? [{ debugName: "writeFields" }] : /* istanbul ignore next */ []));
893
923
  /**
894
924
  * Pending create/update rows, in the exact shape persisted by the backend
895
925
  * (`rows[]` of the stored EntityList JSON). Rows with `entityId > 0` are
@@ -914,6 +944,11 @@ class EntityListField {
914
944
  }, ...(ngDevMode ? [{ debugName: "deletedIds" }] : /* istanbul ignore next */ []));
915
945
  /** rowId → original form values / option labels (view state only). */
916
946
  rowDrafts = signal({}, ...(ngDevMode ? [{ debugName: "rowDrafts" }] : /* istanbul ignore next */ []));
947
+ /**
948
+ * rowId → the backend's rendered cells for a saved embedded row, from the
949
+ * rows endpoint. View state only: the submitted values stay `pendingRows`.
950
+ */
951
+ renderedRows = signal({}, ...(ngDevMode ? [{ debugName: "renderedRows" }] : /* istanbul ignore next */ []));
917
952
  localRowSeq = 0;
918
953
  /** Serialized copy of the last value we emitted, to ignore CVA echoes. */
919
954
  lastEmittedJson = null;
@@ -927,14 +962,23 @@ class EntityListField {
927
962
  }
928
963
  return map;
929
964
  }, ...(ngDevMode ? [{ debugName: "rowsByEntityId" }] : /* istanbul ignore next */ []));
930
- /** Locally created rows (not yet persisted). */
965
+ /**
966
+ * Rows with no target record: locally created ones in a linked list, and
967
+ * *every* row of an embedded list.
968
+ *
969
+ * Three sources, in order: what the user last entered (`rowDrafts`), what the
970
+ * rows endpoint rendered for a saved embedded row, and the stored value's own
971
+ * cells. The middle one is what turns a saved `rawValue` of `"3fa85f64…"`
972
+ * back into an assignee's name after a reload.
973
+ */
931
974
  createdRows = computed(() => {
932
975
  const drafts = this.rowDrafts();
976
+ const rendered = this.renderedRows();
933
977
  return this.pendingRows()
934
978
  .filter((row) => !(row.entityId > 0))
935
979
  .map((row) => {
936
- const draft = drafts[row.rowId];
937
- return this.buildRow(row.rowId, row.rowId, 0, draft?.values ?? this.toValueMap(row.values), draft?.display ?? this.toDisplayMap(row.values));
980
+ const source = drafts[row.rowId] ?? rendered[row.rowId];
981
+ return this.buildRow(row.rowId, row.rowId, 0, source?.values ?? this.toValueMap(row.values), source?.display ?? this.toDisplayMap(row.values), source?.prefill);
938
982
  });
939
983
  }, ...(ngDevMode ? [{ debugName: "createdRows" }] : /* istanbul ignore next */ []));
940
984
  /** Pending edits of existing rows, keyed by entity id. */
@@ -988,7 +1032,10 @@ class EntityListField {
988
1032
  */
989
1033
  showsPendingOperations = computed(() => this.canWrite() ||
990
1034
  this.accessMode() === 'Write' ||
991
- this.pendingSubmission(), ...(ngDevMode ? [{ debugName: "showsPendingOperations" }] : /* istanbul ignore next */ []));
1035
+ this.pendingSubmission() ||
1036
+ // An embedded list has nothing else to show: its rows *are* the value,
1037
+ // so they render even when the field is read-only.
1038
+ this.embedded(), ...(ngDevMode ? [{ debugName: "showsPendingOperations" }] : /* istanbul ignore next */ []));
992
1039
  /**
993
1040
  * Rows rendered in the table: existing rows merged with pending edits,
994
1041
  * removed rows hidden, and created rows appended.
@@ -1004,12 +1051,38 @@ class EntityListField {
1004
1051
  return [...existing, ...this.createdRows()];
1005
1052
  }, ...(ngDevMode ? [{ debugName: "displayRows" }] : /* istanbul ignore next */ []));
1006
1053
  hasRows = computed(() => this.displayRows().length > 0, ...(ngDevMode ? [{ debugName: "hasRows" }] : /* istanbul ignore next */ []));
1007
- hasRequiredContext = computed(() => Number(this.levelId()) > 0 &&
1008
- Number(this.moduleId()) > 0 &&
1009
- this.readFields().length > 0, ...(ngDevMode ? [{ debugName: "hasRequiredContext" }] : /* istanbul ignore next */ []));
1054
+ /** Enough context to ask the backend what this field should render. */
1055
+ hasRequiredContext = computed(() => this.propertyKeyId() > 0 && Number(this.levelId()) > 0, ...(ngDevMode ? [{ debugName: "hasRequiredContext" }] : /* istanbul ignore next */ []));
1056
+ /**
1057
+ * The non-error state the field renders instead of a table, as a translation
1058
+ * key. Null while the metadata request is still in flight, so the template
1059
+ * falls through to the skeleton.
1060
+ */
1061
+ noticeKey = computed(() => {
1062
+ if (!this.hasRequiredContext()) {
1063
+ return 'components.entityListField.missingConfiguration';
1064
+ }
1065
+ switch (this.metadataFailure()) {
1066
+ case 'forbidden':
1067
+ return 'components.entityListField.accessDenied';
1068
+ case 'unavailable':
1069
+ return 'components.entityListField.missingConfiguration';
1070
+ case 'failed':
1071
+ return null;
1072
+ }
1073
+ if (!this.metadata())
1074
+ return null;
1075
+ if (!this.moduleBacked()) {
1076
+ return 'components.entityListField.missingConfiguration';
1077
+ }
1078
+ return this.canDisplayRows()
1079
+ ? null
1080
+ : 'components.entityListField.readingNotAllowed';
1081
+ }, ...(ngDevMode ? [{ debugName: "noticeKey" }] : /* istanbul ignore next */ []));
1010
1082
  onTouched = () => { };
1011
1083
  onModelChange = () => { };
1012
1084
  http = inject(HttpClient);
1085
+ metadataSubscription;
1013
1086
  fetchSubscription;
1014
1087
  destroyRef = inject(DestroyRef);
1015
1088
  modal = inject(ModalService);
@@ -1026,34 +1099,15 @@ class EntityListField {
1026
1099
  if (this.ngControl) {
1027
1100
  this.ngControl.valueAccessor = this;
1028
1101
  }
1029
- // Draft parents load column metadata only. Persisted parents load the
1030
- // Table projection, scoped to their record ID.
1102
+ // The property and its level address the metadata endpoint; the answer
1103
+ // decides everything else, including whether rows are fetched at all.
1104
+ // Only these scalars retrigger a load — a host that rebuilds its field
1105
+ // config object (language, readonly) must not cost a round trip.
1031
1106
  effect(() => {
1032
- const allowedRead = this.canRead();
1033
- const allowedWrite = this.writeAllowed();
1034
- const ready = this.hasRequiredContext();
1107
+ const propertyId = this.propertyKeyId();
1035
1108
  const levelId = this.levelId();
1036
1109
  const levelDataId = this.levelDataId();
1037
- const moduleId = this.moduleId();
1038
- const readFields = this.readFields();
1039
- untracked(() => {
1040
- this.fetchSubscription?.unsubscribe();
1041
- this.columns.set([]);
1042
- this.rows.set([]);
1043
- this.errorMessage.set(null);
1044
- if ((!allowedRead && !allowedWrite) ||
1045
- !ready ||
1046
- levelId == null ||
1047
- moduleId == null) {
1048
- return;
1049
- }
1050
- if (levelDataId == null || Number(levelDataId) <= 0 || !allowedRead) {
1051
- this.fetchDraftColumns(levelId, moduleId, readFields);
1052
- }
1053
- else {
1054
- this.fetchRows(levelId, levelDataId, moduleId, readFields);
1055
- }
1056
- });
1110
+ untracked(() => this.loadTable(propertyId, levelId, levelDataId));
1057
1111
  });
1058
1112
  }
1059
1113
  // ============================================================================
@@ -1161,6 +1215,7 @@ class EntityListField {
1161
1215
  levelDataId: this.levelDataId(),
1162
1216
  writeFields: this.writeFields(),
1163
1217
  lookups: this.lookups(),
1218
+ useRootModuleSchema: this.embedded(),
1164
1219
  },
1165
1220
  });
1166
1221
  ref.onClose.pipe(take(1)).subscribe((result) => {
@@ -1206,6 +1261,7 @@ class EntityListField {
1206
1261
  levelDataId: this.levelDataId(),
1207
1262
  writeFields: this.writeFields(),
1208
1263
  lookups: this.lookups(),
1264
+ useRootModuleSchema: this.embedded(),
1209
1265
  initialValues: prefillValues,
1210
1266
  isEdit: true,
1211
1267
  },
@@ -1321,15 +1377,16 @@ class EntityListField {
1321
1377
  delete next[rowId];
1322
1378
  this.rowDrafts.set(next);
1323
1379
  }
1324
- buildRow(id, rowId, entityId, values, display = {}) {
1380
+ buildRow(id, rowId, entityId, values, display = {}, prefill) {
1325
1381
  const row = {
1326
1382
  Id: id,
1327
1383
  [ROW_ID_KEY]: rowId,
1328
1384
  [ROW_ENTITY_ID_KEY]: entityId,
1329
1385
  [ROW_VALUES_KEY]: values,
1330
1386
  // A drafted row is built from control values already, so there is
1331
- // nothing to resolve — the two maps are the same.
1332
- [ROW_PREFILL_KEY]: values,
1387
+ // nothing to resolve — the two maps are the same. A saved embedded row
1388
+ // is not: it holds stored scalars and carries its own prefill.
1389
+ [ROW_PREFILL_KEY]: prefill ?? values,
1333
1390
  };
1334
1391
  for (const column of this.columns()) {
1335
1392
  // Form values are keyed by catalog property key (e.g. "task_name"),
@@ -1340,14 +1397,36 @@ class EntityListField {
1340
1397
  }
1341
1398
  return row;
1342
1399
  }
1343
- /** Render one table cell from a raw form value and its resolved label. */
1400
+ /**
1401
+ * Render one table cell from a raw form value and its resolved label.
1402
+ *
1403
+ * The cell has to arrive in the shape the backend would have sent, because
1404
+ * that is what the entity renderers bind. Two things a control value is not:
1405
+ *
1406
+ * - **A scalar `value` is a string.** `mt-entity-percentage` reads `d.value`
1407
+ * only when `typeof` it is `'string'` and prints its placeholder otherwise,
1408
+ * so a numeric control value rendered as a filled bar with no number beside
1409
+ * it. Objects and arrays are the resolved shapes the rich renderers want,
1410
+ * and pass through untouched.
1411
+ * - **The column configuration has to travel with it.** Colour rules live
1412
+ * there, and `mt-entity-percentage` falls back to evaluating them itself
1413
+ * exactly when no per-value colour was resolved — which is every locally
1414
+ * added row. Without it a new 45% row rendered in the default colour while
1415
+ * the same value loaded from the backend rendered in its band colour.
1416
+ */
1344
1417
  buildCell(column, raw, label) {
1418
+ const value = this.toLocalEntityValue(column.viewType, raw, label);
1419
+ const propertyKey = column.propertyKey ?? column.key;
1345
1420
  return {
1346
1421
  name: column.label ?? column.key,
1347
1422
  key: column.key,
1348
1423
  viewType: column.viewType ?? 'Text',
1349
- value: this.toLocalEntityValue(column.viewType, raw, label),
1350
- rawValue: raw ?? null,
1424
+ value: value !== null && typeof value === 'object'
1425
+ ? value
1426
+ : (this.toRawValue(value) ?? ''),
1427
+ rawValue: this.toRawValue(raw) ?? undefined,
1428
+ configuration: column.configuration,
1429
+ propertyConfiguration: this.propertyByKey().get(propertyKey)?.configuration,
1351
1430
  };
1352
1431
  }
1353
1432
  /**
@@ -1420,27 +1499,31 @@ class EntityListField {
1420
1499
  // ============================================================================
1421
1500
  emitValue() {
1422
1501
  const current = this.storedValue();
1423
- // `entityIds` / `createdIds` / `updatedIds` / `snapshot` are backend-owned
1424
- // and passed through untouched; the frontend only contributes pending rows
1425
- // and delete intents.
1426
- const next = {
1427
- ...(current ?? {}),
1428
- // `values[].value` is the backend's rendered label, carried only so the
1429
- // table can print it. Submitting it back would echo a user object where
1430
- // the stored scalar belongs.
1431
- rows: this.pendingRows().map((row) => ({
1432
- ...row,
1433
- values: (row.values ?? []).map(({ propertyKey, rawValue }) => ({
1434
- propertyKey,
1435
- rawValue,
1436
- })),
1502
+ // `values[].value` is the backend's rendered label, carried only so the
1503
+ // table can print it. Submitting it back would echo a user object where
1504
+ // the stored scalar belongs.
1505
+ const rows = this.pendingRows().map((row) => ({
1506
+ ...row,
1507
+ values: (row.values ?? []).map(({ propertyKey, rawValue }) => ({
1508
+ propertyKey,
1509
+ rawValue,
1437
1510
  })),
1438
- deletedIds: this.deletedIds(),
1439
- };
1511
+ }));
1512
+ // An embedded value *is* its rows: the array is submitted whole, a removed
1513
+ // row is simply absent from it, and linked bookkeeping has no meaning —
1514
+ // the backend strips `entityIds` / `deletedIds` / `snapshot` for it anyway.
1515
+ // A linked value instead carries pending intent over backend-owned fields,
1516
+ // which are passed through untouched.
1517
+ const next = this.embedded()
1518
+ ? { rows }
1519
+ : { ...(current ?? {}), rows, deletedIds: this.deletedIds() };
1440
1520
  this.storedValue.set(next);
1521
+ // Normalized the same way `isEchoOfLastEmit` reads the incoming value —
1522
+ // an embedded payload has no `deletedIds`, and an absent key would make
1523
+ // every echo look like a new value and reset the user's edits.
1441
1524
  this.lastEmittedJson = JSON.stringify({
1442
- rows: next.rows,
1443
- deletedIds: next.deletedIds,
1525
+ rows: next.rows ?? [],
1526
+ deletedIds: next.deletedIds ?? [],
1444
1527
  });
1445
1528
  this.onModelChange(next);
1446
1529
  this.onTouched();
@@ -1549,97 +1632,216 @@ class EntityListField {
1549
1632
  return this.toRawValue(a) === this.toRawValue(b);
1550
1633
  }
1551
1634
  // ============================================================================
1552
- // Read endpoint — POST /api/fetch/query (Table projection)
1635
+ // Read endpoints — GET Properties/{id}/entitylist/table-metadata (columns,
1636
+ // effective access, canonical keys) + POST fetch/query (rows)
1553
1637
  // ============================================================================
1554
- fetchDraftColumns(levelId, moduleId, propertyKeys) {
1638
+ /**
1639
+ * Load the runtime-scoped table description, then its rows.
1640
+ *
1641
+ * The metadata endpoint is the authorization boundary for this field: it
1642
+ * answers `403` when the user may not read the target module in this level,
1643
+ * so the columns are never built from a source that skipped that check.
1644
+ */
1645
+ loadTable(propertyId, levelId, levelDataId) {
1646
+ this.metadataSubscription?.unsubscribe();
1647
+ this.fetchSubscription?.unsubscribe();
1648
+ this.metadata.set(null);
1649
+ this.metadataFailure.set(null);
1650
+ this.columns.set([]);
1651
+ this.rows.set([]);
1652
+ this.renderedRows.set({});
1653
+ this.errorMessage.set(null);
1654
+ this.loading.set(false);
1655
+ if (!(propertyId > 0) || levelId == null || !(Number(levelId) > 0))
1656
+ return;
1555
1657
  this.loading.set(true);
1556
1658
  const ctx = this.context();
1557
- const properties$ = this.http
1558
- .get('fetch/catalog', {
1559
- params: { contextKey: `level:${levelId}/module:${moduleId}` },
1560
- // A 404 here is the expected unmapped Write-only case handled below,
1561
- // and every other failure is already surfaced inline by `errorMessage`.
1562
- // Without this the host's message interceptor toasts the 404 too — it
1563
- // only honours `noMessage`, and `fetch/catalog` is not a silent
1564
- // endpoint the way `fetch/query` is.
1659
+ this.metadataSubscription = this.http
1660
+ .get(`Properties/${propertyId}/entitylist/table-metadata`, {
1661
+ params: { levelId: String(levelId) },
1662
+ // `403` (no module read access) and `404` (not configured for this
1663
+ // level) are states this field renders inline, not failures worth a
1664
+ // toast from the host's message interceptor.
1565
1665
  headers: { noMessage: 'true' },
1566
1666
  ...(ctx ? { context: ctx } : {}),
1567
1667
  })
1568
- .pipe(map((response) => response.data.properties), catchError((error) => {
1569
- if (this.accessMode() !== 'Write' || error.status !== 404) {
1570
- return throwError(() => error);
1571
- }
1572
- // Write-only EntityLists may intentionally use a target module that
1573
- // is not mapped to the owning level. Fetch catalog represents a
1574
- // browsable level/module context and rejects that pair; the runtime
1575
- // Create form remains the authorized source for its field metadata.
1576
- return this.http
1577
- .post('process-form-load', {
1578
- moduleKey: 'ModuleData',
1579
- operationKey: 'Create',
1580
- moduleId,
1581
- levelId,
1582
- }, {
1583
- headers: { noMessage: 'true' },
1584
- ...(ctx ? { context: ctx } : {}),
1585
- })
1586
- .pipe(map((response) => this.mapProcessFormProperties(response)));
1587
- }));
1588
- this.fetchSubscription = properties$
1589
- .pipe(takeUntilDestroyed(this.destroyRef), finalize(() => this.loading.set(false)))
1668
+ .pipe(takeUntilDestroyed(this.destroyRef))
1590
1669
  .subscribe({
1591
- next: (catalogProperties) => {
1592
- const properties = catalogProperties.filter((property) => propertyKeys.includes(property.key) ||
1593
- propertyKeys.includes(property.normalizedKey));
1594
- this.applyResponse({
1595
- catalog: { properties },
1596
- records: [],
1597
- projectionMeta: {
1598
- columns: properties.map((property) => ({
1599
- key: property.normalizedKey || property.key,
1600
- label: property.label,
1601
- viewType: property.viewType,
1602
- order: property.order,
1603
- visible: true,
1604
- configuration: property.configuration ?? null,
1605
- })),
1606
- },
1607
- });
1670
+ next: (response) => this.applyMetadata(response.data, levelDataId),
1671
+ error: (error) => {
1672
+ this.loading.set(false);
1673
+ const failure = resolveMetadataFailure(error.status);
1674
+ this.metadataFailure.set(failure);
1675
+ // `forbidden` and `unavailable` are rendered as their own notice; only
1676
+ // a real request failure is an error.
1677
+ if (failure === 'failed') {
1678
+ this.errorMessage.set(this.transloco.translate('components.entityListField.loadFailed'));
1679
+ }
1608
1680
  },
1609
- error: () => this.errorMessage.set(this.transloco.translate('components.entityListField.loadFailed')),
1610
1681
  });
1611
1682
  }
1612
1683
  /**
1613
- * Project a Create form into the catalog shape the column builder expects.
1614
- * Sections and their fields are flattened into reading order and renumbered
1615
- * from there — a field's own `order` is section-relative, so carrying it over
1616
- * as the column order interleaves the sections once `applyResponse` sorts.
1684
+ * Apply the metadata, then fetch rows when there is a persisted parent to
1685
+ * scope them to. A draft parent (no `levelDataId`) and a write-only field
1686
+ * both stop at the columns — the first has no records yet, the second may
1687
+ * not read them.
1617
1688
  */
1618
- mapProcessFormProperties(response) {
1619
- const sections = sortByOrder(response.data?.formConfiguration?.sections ?? []);
1620
- return sections
1621
- .flatMap((section) => sortByOrder(section.fields ?? []))
1622
- .map((field, index) => {
1623
- const metadata = field.propertyMetadata;
1624
- const key = metadata?.key || field.propertyKey;
1625
- if (!metadata?.viewType || !key)
1626
- return null;
1627
- const name = metadata.name;
1628
- const label = typeof name === 'string'
1629
- ? name
1630
- : name?.display || name?.en || name?.ar || key;
1631
- return {
1632
- id: metadata.propertyId ?? 0,
1633
- key,
1634
- normalizedKey: metadata.normalizedKey || key,
1635
- label,
1636
- viewType: metadata.viewType,
1637
- configuration: metadata.configuration ?? null,
1638
- order: index,
1639
- };
1689
+ applyMetadata(metadata, levelDataId) {
1690
+ this.metadata.set(metadata);
1691
+ this.columns.set(this.buildColumns(metadata));
1692
+ if (!this.moduleBacked() || !this.canRead()) {
1693
+ this.loading.set(false);
1694
+ return;
1695
+ }
1696
+ // An embedded list reads its own saved rows, keyed by the record that owns
1697
+ // them — never the schema module's records. Before that record exists the
1698
+ // rows are purely local, exactly like a draft parent's.
1699
+ if (this.embedded()) {
1700
+ const ownerRecordId = this.ownerRecordId();
1701
+ if (ownerRecordId > 0) {
1702
+ this.fetchEmbeddedRows(metadata.propertyId, ownerRecordId);
1703
+ }
1704
+ else {
1705
+ this.loading.set(false);
1706
+ }
1707
+ return;
1708
+ }
1709
+ if (levelDataId == null || Number(levelDataId) <= 0) {
1710
+ this.loading.set(false);
1711
+ return;
1712
+ }
1713
+ this.fetchRows(metadata.levelId, levelDataId, metadata.moduleId, this.projectedKeys());
1714
+ }
1715
+ /**
1716
+ * Saved rows of an embedded list, rendered by the backend.
1717
+ *
1718
+ * They are not merged into `rows` — that signal is target module records,
1719
+ * which an embedded list has none of. They land in `renderedRows`, which
1720
+ * `createdRows` consults to render the value's own rows with resolved labels
1721
+ * instead of stored scalars.
1722
+ *
1723
+ * The stored value stays authoritative for *which* rows exist, so a value
1724
+ * that already carries them is left alone; the response only seeds the array
1725
+ * when the control arrived without one.
1726
+ */
1727
+ fetchEmbeddedRows(propertyId, ownerRecordId) {
1728
+ this.loading.set(true);
1729
+ this.errorMessage.set(null);
1730
+ const ctx = this.context();
1731
+ this.fetchSubscription = this.http
1732
+ .get(`Properties/${propertyId}/entitylist/rows`, {
1733
+ params: { instanceId: String(ownerRecordId) },
1734
+ headers: { noMessage: 'true' },
1735
+ ...(ctx ? { context: ctx } : {}),
1640
1736
  })
1641
- .filter((property) => property !== null);
1737
+ .pipe(takeUntilDestroyed(this.destroyRef), finalize(() => this.loading.set(false)), catchError((error) => {
1738
+ // `404` is "no saved rows for this owner" as much as it is a
1739
+ // misconfiguration, and the value's own rows still render.
1740
+ if (error.status !== 404 && error.status !== 403) {
1741
+ this.errorMessage.set(this.transloco.translate('components.entityListField.loadFailed'));
1742
+ }
1743
+ return of({ data: [] });
1744
+ }))
1745
+ .subscribe((response) => this.applyEmbeddedRows(response.data ?? []));
1746
+ }
1747
+ applyEmbeddedRows(rows) {
1748
+ const rendered = {};
1749
+ const stored = [];
1750
+ const properties = this.propertyByKey();
1751
+ for (const row of rows) {
1752
+ const rowId = row.rowId?.trim();
1753
+ if (!rowId)
1754
+ continue;
1755
+ const values = {};
1756
+ const display = {};
1757
+ const prefill = {};
1758
+ const submitted = [];
1759
+ for (const cell of row.values ?? []) {
1760
+ if (!cell?.propertyKey)
1761
+ continue;
1762
+ values[cell.propertyKey] = cell.rawValue;
1763
+ if (cell.value !== undefined)
1764
+ display[cell.propertyKey] = cell.value;
1765
+ // A user picker binds the resolved object, not the stored id, so the
1766
+ // edit dialog is pre-filled from the rendered value for those view
1767
+ // types — the same exception the loaded linked rows make. The rendered
1768
+ // counterpart is only usable when the backend resolved one.
1769
+ const resolved = cell.value !== null &&
1770
+ typeof cell.value === 'object' &&
1771
+ OBJECT_VALUED_VIEW_TYPES.has(properties.get(cell.propertyKey)?.viewType ?? '');
1772
+ prefill[cell.propertyKey] = resolved ? cell.value : cell.rawValue;
1773
+ submitted.push({
1774
+ propertyKey: cell.propertyKey,
1775
+ rawValue: cell.rawValue,
1776
+ });
1777
+ }
1778
+ rendered[rowId] = { values, display, prefill };
1779
+ // `entityId` is always 0 here: an embedded row has no target record.
1780
+ stored.push({ rowId, entityId: 0, values: submitted });
1781
+ }
1782
+ this.renderedRows.set(rendered);
1783
+ if (this.pendingRows().length === 0 && stored.length > 0) {
1784
+ this.pendingRows.set(stored);
1785
+ }
1786
+ }
1787
+ /**
1788
+ * Table columns, in the order the backend returned them.
1789
+ *
1790
+ * `projectionMeta.columns[].key` is the catalog property key here — the same
1791
+ * key `fetch/query` keys its record values by — so a column maps onto a row
1792
+ * value directly. The lookup still falls back to `normalizedKey` so a column
1793
+ * fed from any other projection keeps resolving.
1794
+ *
1795
+ * The columns are the *union* of readable and writable fields, so in a
1796
+ * **linked** list a write-only key arrives as a column too — a `Planned
1797
+ * Finish` the user may set in the dialog but may not read. It is not
1798
+ * projected into the rows and would render as an empty column, so only
1799
+ * readable keys become columns there. Two exceptions keep the union:
1800
+ *
1801
+ * - **Write-only access**, whose readable set is empty by definition and
1802
+ * whose stored rows have nothing else to render through.
1803
+ * - **Embedded storage**, where the rows endpoint returns cells for the whole
1804
+ * union by design, "so saved editor values can be rendered after reload".
1805
+ */
1806
+ buildColumns(metadata) {
1807
+ const propertyByKey = new Map();
1808
+ const propertyByNormalizedKey = new Map();
1809
+ for (const property of metadata.catalog?.properties ?? []) {
1810
+ propertyByKey.set(property.key, property);
1811
+ propertyByNormalizedKey.set(property.normalizedKey, property);
1812
+ }
1813
+ const readable = metadata.storageMode === 'Embedded'
1814
+ ? new Set()
1815
+ : new Set(metadata.readFields);
1816
+ return (metadata.projectionMeta?.columns ?? [])
1817
+ .filter((column) => column.visible)
1818
+ .filter((column) => readable.size === 0 || readable.has(column.key))
1819
+ .sort((a, b) => a.order - b.order)
1820
+ .map((column) => ({
1821
+ key: column.key,
1822
+ label: column.label,
1823
+ type: 'entity',
1824
+ sortable: !UNSORTABLE_ENTITY_VIEW_TYPES.has(column.viewType),
1825
+ viewType: column.viewType,
1826
+ order: column.order,
1827
+ visible: column.visible,
1828
+ configuration: column.configuration ?? null,
1829
+ propertyKey: (propertyByKey.has(column.key)
1830
+ ? column.key
1831
+ : propertyByNormalizedKey.get(column.key)?.key) ?? column.key,
1832
+ }));
1642
1833
  }
1834
+ /** Catalog properties of the loaded metadata, keyed by property key. */
1835
+ propertyByKey = computed(() => {
1836
+ const map = new Map();
1837
+ for (const property of this.metadata()?.catalog?.properties ?? []) {
1838
+ map.set(property.key, property);
1839
+ if (!map.has(property.normalizedKey)) {
1840
+ map.set(property.normalizedKey, property);
1841
+ }
1842
+ }
1843
+ return map;
1844
+ }, ...(ngDevMode ? [{ debugName: "propertyByKey" }] : /* istanbul ignore next */ []));
1643
1845
  fetchRows(levelId, levelDataId, moduleId, propertyKeys) {
1644
1846
  this.loading.set(true);
1645
1847
  this.errorMessage.set(null);
@@ -1670,42 +1872,30 @@ class EntityListField {
1670
1872
  const payload = response && typeof response === 'object' && 'data' in response
1671
1873
  ? (response.data ?? response)
1672
1874
  : response;
1673
- this.applyResponse(payload);
1875
+ this.applyRecords(payload.records ?? []);
1674
1876
  });
1675
1877
  }
1676
- applyResponse(response) {
1677
- // Build property maps first so column defs can include the propertyKey
1678
- // mapping (normalizedKey → catalog key) needed for row value lookup.
1679
- const propertyByKey = new Map();
1680
- const propertyByNormalizedKey = new Map();
1681
- for (const property of response.catalog?.properties ?? []) {
1682
- propertyByKey.set(property.key, property);
1683
- propertyByNormalizedKey.set(property.normalizedKey, property);
1684
- }
1685
- const columns = (response.projectionMeta?.columns ?? [])
1686
- .filter((column) => column.visible)
1687
- .sort((a, b) => a.order - b.order)
1688
- .map((column) => ({
1689
- key: column.key,
1690
- label: column.label,
1691
- type: 'entity',
1692
- sortable: !UNSORTABLE_ENTITY_VIEW_TYPES.has(column.viewType),
1693
- viewType: column.viewType,
1694
- order: column.order,
1695
- visible: column.visible,
1696
- configuration: column.configuration ?? null,
1697
- // Store the catalog property key so buildRow can look up form values
1698
- // keyed by property key (e.g. "task_name") rather than the
1699
- // normalizedKey used as the column display key (e.g. "Name").
1700
- propertyKey: propertyByNormalizedKey.get(column.key)?.key ?? column.key,
1701
- }));
1702
- this.columns.set(columns);
1703
- // Reading blocked (access = Write / None): keep the columns, drop records.
1704
- if (!this.canRead()) {
1705
- this.rows.set([]);
1706
- return;
1707
- }
1708
- const rows = (response.records ?? []).map((record) => {
1878
+ /**
1879
+ * Project fetched records onto the metadata columns.
1880
+ *
1881
+ * Cells are built per rendered column, but the row's value maps cover every
1882
+ * **projected** key — a writable key without a column has no cell to render
1883
+ * and still has to reach the edit dialog and the update diff.
1884
+ */
1885
+ applyRecords(records) {
1886
+ const properties = this.propertyByKey();
1887
+ const columns = this.columns();
1888
+ const valueKeys = [
1889
+ ...new Set([
1890
+ ...this.projectedKeys(),
1891
+ ...columns.map((column) => column.propertyKey ?? column.key),
1892
+ ]),
1893
+ ];
1894
+ const viewTypeByKey = new Map(columns.map((column) => [
1895
+ column.propertyKey ?? column.key,
1896
+ column.viewType,
1897
+ ]));
1898
+ this.rows.set(records.map((record) => {
1709
1899
  const values = {};
1710
1900
  const prefill = {};
1711
1901
  const row = {
@@ -1714,25 +1904,24 @@ class EntityListField {
1714
1904
  [ROW_ENTITY_ID_KEY]: record.id,
1715
1905
  };
1716
1906
  for (const column of columns) {
1717
- const property = propertyByKey.get(column.key) ??
1718
- propertyByNormalizedKey.get(column.key);
1719
- const propertyKey = property?.key ?? column.key;
1720
- const cell = record.values?.[propertyKey];
1721
- row[column.key] = this.toEntityData(column, cell, property, record.id);
1907
+ const propertyKey = column.propertyKey ?? column.key;
1908
+ row[column.key] = this.toEntityData(column, record.values?.[propertyKey], properties.get(propertyKey), record.id);
1909
+ }
1910
+ for (const key of valueKeys) {
1911
+ const cell = record.values?.[key];
1722
1912
  // Keep the machine-readable value as the baseline a partial update is
1723
1913
  // diffed against — it is the shape the row submits.
1724
- values[propertyKey] = cell?.raw ?? cell?.value ?? null;
1914
+ values[key] = cell?.raw ?? cell?.value ?? null;
1725
1915
  // What the edit dialog patches into its form, which is not always the
1726
1916
  // same thing: see OBJECT_VALUED_VIEW_TYPES.
1727
- prefill[propertyKey] = OBJECT_VALUED_VIEW_TYPES.has(column.viewType ?? '')
1917
+ prefill[key] = OBJECT_VALUED_VIEW_TYPES.has(viewTypeByKey.get(key) ?? properties.get(key)?.viewType ?? '')
1728
1918
  ? (cell?.value ?? cell?.raw ?? null)
1729
- : values[propertyKey];
1919
+ : values[key];
1730
1920
  }
1731
1921
  row[ROW_VALUES_KEY] = values;
1732
1922
  row[ROW_PREFILL_KEY] = prefill;
1733
1923
  return row;
1734
- });
1735
- this.rows.set(rows);
1924
+ }));
1736
1925
  }
1737
1926
  toEntityData(column, cell, property, recordId) {
1738
1927
  return {
@@ -1753,7 +1942,7 @@ class EntityListField {
1753
1942
  };
1754
1943
  }
1755
1944
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: EntityListField, deps: [], target: i0.ɵɵFactoryTarget.Component });
1756
- 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 } }, host: { classAttribute: "grid gap-1" }, ngImport: i0, template: "<div class=\"flex flex-col gap-2\">\r\n @if (label()) {\r\n <label class=\"font-medium text-color\">\r\n {{ label() }}\r\n @if (required()) {\r\n <span class=\"text-red-500\">*</span>\r\n }\r\n </label>\r\n }\r\n\r\n @if (errorMessage(); as err) {\r\n <p-message severity=\"error\" [text]=\"err\" styleClass=\"w-full\" />\r\n } @else if (canWrite()) {\r\n <div class=\"flex justify-end\">\r\n <mt-button\r\n [label]=\"'components.entityListField.add' | transloco\"\r\n icon=\"general.plus\"\r\n size=\"small\"\r\n [disabled]=\"disabled()\"\r\n (onClick)=\"openAddDialog()\"\r\n />\r\n </div>\r\n <mt-table\r\n [noCard]=\"true\"\r\n [data]=\"displayRows()\"\r\n [columns]=\"columns()\"\r\n [rowActions]=\"writeRowActions()\"\r\n dataKey=\"Id\"\r\n [loading]=\"loading()\"\r\n />\r\n } @else if (!canDisplayRows()) {\r\n <div\r\n class=\"rounded border border-dashed border-surface-300 bg-surface-50 p-3 text-sm text-muted-color\"\r\n >\r\n {{ \"components.entityListField.readingNotAllowed\" | transloco }}\r\n </div>\r\n } @else if (!hasRequiredContext()) {\r\n <div\r\n class=\"rounded border border-dashed border-surface-300 bg-surface-50 p-3 text-sm text-muted-color\"\r\n >\r\n {{ \"components.entityListField.missingConfiguration\" | transloco }}\r\n </div>\r\n } @else if (loading() && !hasRows()) {\r\n <div class=\"flex flex-col gap-2\">\r\n <p-skeleton width=\"100%\" height=\"3rem\" />\r\n <p-skeleton width=\"100%\" height=\"3rem\" />\r\n </div>\r\n } @else if (!hasRows()) {\r\n <div\r\n class=\"rounded border border-dashed border-surface-300 bg-surface-50 p-3 text-sm text-muted-color\"\r\n >\r\n {{ \"components.entityListField.noRelatedItems\" | transloco }}\r\n </div>\r\n } @else {\r\n <mt-table\r\n [noCard]=\"true\"\r\n [data]=\"displayRows()\"\r\n [columns]=\"columns()\"\r\n dataKey=\"Id\"\r\n [loading]=\"loading()\"\r\n />\r\n }\r\n\r\n @if (ngControl?.control) {\r\n <mt-field-validation\r\n [control]=\"ngControl?.control!\"\r\n [touched]=\"ngControl?.touched ?? false\"\r\n />\r\n }\r\n</div>\r\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 });
1945
+ 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 } }, host: { classAttribute: "grid gap-1" }, 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 (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]=\"columns()\"\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]=\"columns()\"\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 });
1757
1946
  }
1758
1947
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: EntityListField, decorators: [{
1759
1948
  type: Component,
@@ -1765,7 +1954,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImpor
1765
1954
  Table,
1766
1955
  Button,
1767
1956
  TranslocoPipe,
1768
- ], changeDetection: ChangeDetectionStrategy.OnPush, host: { class: 'grid gap-1' }, template: "<div class=\"flex flex-col gap-2\">\r\n @if (label()) {\r\n <label class=\"font-medium text-color\">\r\n {{ label() }}\r\n @if (required()) {\r\n <span class=\"text-red-500\">*</span>\r\n }\r\n </label>\r\n }\r\n\r\n @if (errorMessage(); as err) {\r\n <p-message severity=\"error\" [text]=\"err\" styleClass=\"w-full\" />\r\n } @else if (canWrite()) {\r\n <div class=\"flex justify-end\">\r\n <mt-button\r\n [label]=\"'components.entityListField.add' | transloco\"\r\n icon=\"general.plus\"\r\n size=\"small\"\r\n [disabled]=\"disabled()\"\r\n (onClick)=\"openAddDialog()\"\r\n />\r\n </div>\r\n <mt-table\r\n [noCard]=\"true\"\r\n [data]=\"displayRows()\"\r\n [columns]=\"columns()\"\r\n [rowActions]=\"writeRowActions()\"\r\n dataKey=\"Id\"\r\n [loading]=\"loading()\"\r\n />\r\n } @else if (!canDisplayRows()) {\r\n <div\r\n class=\"rounded border border-dashed border-surface-300 bg-surface-50 p-3 text-sm text-muted-color\"\r\n >\r\n {{ \"components.entityListField.readingNotAllowed\" | transloco }}\r\n </div>\r\n } @else if (!hasRequiredContext()) {\r\n <div\r\n class=\"rounded border border-dashed border-surface-300 bg-surface-50 p-3 text-sm text-muted-color\"\r\n >\r\n {{ \"components.entityListField.missingConfiguration\" | transloco }}\r\n </div>\r\n } @else if (loading() && !hasRows()) {\r\n <div class=\"flex flex-col gap-2\">\r\n <p-skeleton width=\"100%\" height=\"3rem\" />\r\n <p-skeleton width=\"100%\" height=\"3rem\" />\r\n </div>\r\n } @else if (!hasRows()) {\r\n <div\r\n class=\"rounded border border-dashed border-surface-300 bg-surface-50 p-3 text-sm text-muted-color\"\r\n >\r\n {{ \"components.entityListField.noRelatedItems\" | transloco }}\r\n </div>\r\n } @else {\r\n <mt-table\r\n [noCard]=\"true\"\r\n [data]=\"displayRows()\"\r\n [columns]=\"columns()\"\r\n dataKey=\"Id\"\r\n [loading]=\"loading()\"\r\n />\r\n }\r\n\r\n @if (ngControl?.control) {\r\n <mt-field-validation\r\n [control]=\"ngControl?.control!\"\r\n [touched]=\"ngControl?.touched ?? false\"\r\n />\r\n }\r\n</div>\r\n", styles: [":host{display:block}\n"] }]
1957
+ ], changeDetection: ChangeDetectionStrategy.OnPush, host: { class: 'grid gap-1' }, 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 (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]=\"columns()\"\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]=\"columns()\"\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"] }]
1769
1958
  }], 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 }] }] } });
1770
1959
 
1771
1960
  /** Page size when loading the full deliverable list, and a hard safety cap. */