@masterteam/components 0.0.292 → 0.0.294
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/i18n/ar.json +387 -386
- package/assets/i18n/en.json +387 -386
- package/fesm2022/masterteam-components-business-fields.mjs +356 -209
- package/fesm2022/masterteam-components-business-fields.mjs.map +1 -1
- package/fesm2022/masterteam-components-entities.mjs.map +1 -1
- package/fesm2022/masterteam-components.mjs +8 -0
- package/fesm2022/masterteam-components.mjs.map +1 -1
- package/package.json +1 -1
- package/types/masterteam-components-business-fields.d.ts +164 -17
- package/types/masterteam-components-entities.d.ts +1 -1
- package/types/masterteam-components.d.ts +8 -0
|
@@ -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,
|
|
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,30 +793,36 @@ 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
|
-
/**
|
|
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
|
-
/**
|
|
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 */ []));
|
|
818
|
+
/**
|
|
819
|
+
* The bound value is an unapplied process submission — an Approval step's
|
|
820
|
+
* frozen create/update/delete operations — rather than a persisted record
|
|
821
|
+
* value. Its `rows[]` and `deletedIds` are pending intent the approver has
|
|
822
|
+
* to see staged over the loaded records, not markers of writes the backend
|
|
823
|
+
* already applied. See `.github/instructions/properties/EntityList.md`.
|
|
824
|
+
*/
|
|
825
|
+
pendingSubmission = input(false, ...(ngDevMode ? [{ debugName: "pendingSubmission" }] : /* istanbul ignore next */ []));
|
|
815
826
|
/**
|
|
816
827
|
* Full lookup catalog of the host form, forwarded to the add/edit dialog's
|
|
817
828
|
* nested form. `process-form-load` returns only the lookup *id* per field,
|
|
@@ -822,6 +833,9 @@ class EntityListField {
|
|
|
822
833
|
context = input(undefined, ...(ngDevMode ? [{ debugName: "context" }] : /* istanbul ignore next */ []));
|
|
823
834
|
// CVA state — pass-through value (EntityList stored JSON shape).
|
|
824
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 */ []));
|
|
825
839
|
// Loaded table state.
|
|
826
840
|
columns = signal([], ...(ngDevMode ? [{ debugName: "columns" }] : /* istanbul ignore next */ []));
|
|
827
841
|
/** Rows loaded from the backend (existing target records). */
|
|
@@ -839,25 +853,41 @@ class EntityListField {
|
|
|
839
853
|
const raw = this.runtimeContext()?.levelDataId ?? null;
|
|
840
854
|
return raw == null || raw === '' ? null : raw;
|
|
841
855
|
}, ...(ngDevMode ? [{ debugName: "levelDataId" }] : /* istanbul ignore next */ []));
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
readFields = computed(() => {
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
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. */
|
|
855
876
|
accessMode = computed(() => {
|
|
856
|
-
const raw = this.
|
|
877
|
+
const raw = this.metadata()?.access;
|
|
857
878
|
if (raw == null || raw === '')
|
|
858
|
-
return '
|
|
859
|
-
return ACCESS_ALIASES[String(raw).trim().toLowerCase()] ?? '
|
|
879
|
+
return 'None';
|
|
880
|
+
return ACCESS_ALIASES[String(raw).trim().toLowerCase()] ?? 'None';
|
|
860
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 */ []));
|
|
861
891
|
canRead = computed(() => {
|
|
862
892
|
const access = this.accessMode();
|
|
863
893
|
return access === 'Auto' || access === 'Read' || access === 'ReadWrite';
|
|
@@ -874,22 +904,36 @@ class EntityListField {
|
|
|
874
904
|
return access === 'Auto' || access === 'Write' || access === 'ReadWrite';
|
|
875
905
|
}, ...(ngDevMode ? [{ debugName: "writeAllowed" }] : /* istanbul ignore next */ []));
|
|
876
906
|
/** Write UI is rendered only when access allows it and the field is editable. */
|
|
877
|
-
canWrite = computed(() => this.writeAllowed() && !this.readonly(), ...(ngDevMode ? [{ debugName: "canWrite" }] : /* istanbul ignore next */ []));
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
907
|
+
canWrite = computed(() => this.writeAllowed() && this.moduleBacked() && !this.readonly(), ...(ngDevMode ? [{ debugName: "canWrite" }] : /* istanbul ignore next */ []));
|
|
908
|
+
/**
|
|
909
|
+
* Canonical writable target keys. They are what the add/edit dialog renders
|
|
910
|
+
* and what a submitted row is restricted to — canonical, so a configuration
|
|
911
|
+
* that listed `normalizedKey` aliases still matches the target module's form
|
|
912
|
+
* value keys.
|
|
913
|
+
*/
|
|
914
|
+
writeFields = computed(() => this.metadata()?.writeFields ?? [], ...(ngDevMode ? [{ debugName: "writeFields" }] : /* istanbul ignore next */ []));
|
|
885
915
|
/**
|
|
886
916
|
* Pending create/update rows, in the exact shape persisted by the backend
|
|
887
917
|
* (`rows[]` of the stored EntityList JSON). Rows with `entityId > 0` are
|
|
888
918
|
* partial updates of existing records; `entityId = 0` rows are creates.
|
|
889
919
|
*/
|
|
890
920
|
pendingRows = signal([], ...(ngDevMode ? [{ debugName: "pendingRows" }] : /* istanbul ignore next */ []));
|
|
891
|
-
/** Existing entity ids the user removed
|
|
892
|
-
|
|
921
|
+
/** Existing entity ids the user removed in this session. */
|
|
922
|
+
stagedDeletedIds = signal([], ...(ngDevMode ? [{ debugName: "stagedDeletedIds" }] : /* istanbul ignore next */ []));
|
|
923
|
+
/** `deletedIds` carried by the loaded value, before they mean anything. */
|
|
924
|
+
loadedDeletedIds = signal([], ...(ngDevMode ? [{ debugName: "loadedDeletedIds" }] : /* istanbul ignore next */ []));
|
|
925
|
+
/**
|
|
926
|
+
* Delete intents that apply to the table right now. On a persisted value the
|
|
927
|
+
* loaded `deletedIds` are historical operation markers — the records are
|
|
928
|
+
* already gone — so only this session's removals count. On an unapplied
|
|
929
|
+
* submission they are deletes awaiting approval and must be staged too.
|
|
930
|
+
*/
|
|
931
|
+
deletedIds = computed(() => {
|
|
932
|
+
const staged = this.stagedDeletedIds();
|
|
933
|
+
if (!this.pendingSubmission())
|
|
934
|
+
return staged;
|
|
935
|
+
return [...new Set([...this.loadedDeletedIds(), ...staged])];
|
|
936
|
+
}, ...(ngDevMode ? [{ debugName: "deletedIds" }] : /* istanbul ignore next */ []));
|
|
893
937
|
/** rowId → original form values / option labels (view state only). */
|
|
894
938
|
rowDrafts = signal({}, ...(ngDevMode ? [{ debugName: "rowDrafts" }] : /* istanbul ignore next */ []));
|
|
895
939
|
localRowSeq = 0;
|
|
@@ -912,7 +956,7 @@ class EntityListField {
|
|
|
912
956
|
.filter((row) => !(row.entityId > 0))
|
|
913
957
|
.map((row) => {
|
|
914
958
|
const draft = drafts[row.rowId];
|
|
915
|
-
return this.buildRow(row.rowId, row.rowId, 0, draft?.values ?? this.toValueMap(row.values), draft?.display ??
|
|
959
|
+
return this.buildRow(row.rowId, row.rowId, 0, draft?.values ?? this.toValueMap(row.values), draft?.display ?? this.toDisplayMap(row.values));
|
|
916
960
|
});
|
|
917
961
|
}, ...(ngDevMode ? [{ debugName: "createdRows" }] : /* istanbul ignore next */ []));
|
|
918
962
|
/** Pending edits of existing rows, keyed by entity id. */
|
|
@@ -927,7 +971,7 @@ class EntityListField {
|
|
|
927
971
|
const draft = drafts[row.rowId];
|
|
928
972
|
// A pending update only carries the keys the user changed.
|
|
929
973
|
const changed = draft?.values ?? this.toValueMap(row.values);
|
|
930
|
-
const display = draft?.display ??
|
|
974
|
+
const display = draft?.display ?? this.toDisplayMap(row.values);
|
|
931
975
|
if (!base) {
|
|
932
976
|
map.set(row.entityId, this.buildRow(row.entityId, row.rowId, row.entityId, changed, display));
|
|
933
977
|
continue;
|
|
@@ -956,12 +1000,23 @@ class EntityListField {
|
|
|
956
1000
|
return map;
|
|
957
1001
|
}, ...(ngDevMode ? [{ debugName: "editedRowsByEntityId" }] : /* istanbul ignore next */ []));
|
|
958
1002
|
/**
|
|
959
|
-
*
|
|
960
|
-
*
|
|
961
|
-
*
|
|
1003
|
+
* Whether the table stages pending operations over the loaded records.
|
|
1004
|
+
*
|
|
1005
|
+
* Editable write modes stage the user's own edits, and a read-only
|
|
1006
|
+
* Write-only field has nothing but its stored rows to show. A pending
|
|
1007
|
+
* submission stages them too even though it is read-only and `ReadWrite`:
|
|
1008
|
+
* an approver reviewing a request has to see what it *will* do to the target
|
|
1009
|
+
* module, not the records as they stand.
|
|
1010
|
+
*/
|
|
1011
|
+
showsPendingOperations = computed(() => this.canWrite() ||
|
|
1012
|
+
this.accessMode() === 'Write' ||
|
|
1013
|
+
this.pendingSubmission(), ...(ngDevMode ? [{ debugName: "showsPendingOperations" }] : /* istanbul ignore next */ []));
|
|
1014
|
+
/**
|
|
1015
|
+
* Rows rendered in the table: existing rows merged with pending edits,
|
|
1016
|
+
* removed rows hidden, and created rows appended.
|
|
962
1017
|
*/
|
|
963
1018
|
displayRows = computed(() => {
|
|
964
|
-
if (!this.
|
|
1019
|
+
if (!this.showsPendingOperations())
|
|
965
1020
|
return this.rows();
|
|
966
1021
|
const deleted = new Set(this.deletedIds());
|
|
967
1022
|
const edited = this.editedRowsByEntityId();
|
|
@@ -971,12 +1026,38 @@ class EntityListField {
|
|
|
971
1026
|
return [...existing, ...this.createdRows()];
|
|
972
1027
|
}, ...(ngDevMode ? [{ debugName: "displayRows" }] : /* istanbul ignore next */ []));
|
|
973
1028
|
hasRows = computed(() => this.displayRows().length > 0, ...(ngDevMode ? [{ debugName: "hasRows" }] : /* istanbul ignore next */ []));
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
1029
|
+
/** Enough context to ask the backend what this field should render. */
|
|
1030
|
+
hasRequiredContext = computed(() => this.propertyKeyId() > 0 && Number(this.levelId()) > 0, ...(ngDevMode ? [{ debugName: "hasRequiredContext" }] : /* istanbul ignore next */ []));
|
|
1031
|
+
/**
|
|
1032
|
+
* The non-error state the field renders instead of a table, as a translation
|
|
1033
|
+
* key. Null while the metadata request is still in flight, so the template
|
|
1034
|
+
* falls through to the skeleton.
|
|
1035
|
+
*/
|
|
1036
|
+
noticeKey = computed(() => {
|
|
1037
|
+
if (!this.hasRequiredContext()) {
|
|
1038
|
+
return 'components.entityListField.missingConfiguration';
|
|
1039
|
+
}
|
|
1040
|
+
switch (this.metadataFailure()) {
|
|
1041
|
+
case 'forbidden':
|
|
1042
|
+
return 'components.entityListField.accessDenied';
|
|
1043
|
+
case 'unavailable':
|
|
1044
|
+
return 'components.entityListField.missingConfiguration';
|
|
1045
|
+
case 'failed':
|
|
1046
|
+
return null;
|
|
1047
|
+
}
|
|
1048
|
+
if (!this.metadata())
|
|
1049
|
+
return null;
|
|
1050
|
+
if (!this.moduleBacked()) {
|
|
1051
|
+
return 'components.entityListField.missingConfiguration';
|
|
1052
|
+
}
|
|
1053
|
+
return this.canDisplayRows()
|
|
1054
|
+
? null
|
|
1055
|
+
: 'components.entityListField.readingNotAllowed';
|
|
1056
|
+
}, ...(ngDevMode ? [{ debugName: "noticeKey" }] : /* istanbul ignore next */ []));
|
|
977
1057
|
onTouched = () => { };
|
|
978
1058
|
onModelChange = () => { };
|
|
979
1059
|
http = inject(HttpClient);
|
|
1060
|
+
metadataSubscription;
|
|
980
1061
|
fetchSubscription;
|
|
981
1062
|
destroyRef = inject(DestroyRef);
|
|
982
1063
|
modal = inject(ModalService);
|
|
@@ -993,34 +1074,15 @@ class EntityListField {
|
|
|
993
1074
|
if (this.ngControl) {
|
|
994
1075
|
this.ngControl.valueAccessor = this;
|
|
995
1076
|
}
|
|
996
|
-
//
|
|
997
|
-
//
|
|
1077
|
+
// The property and its level address the metadata endpoint; the answer
|
|
1078
|
+
// decides everything else, including whether rows are fetched at all.
|
|
1079
|
+
// Only these scalars retrigger a load — a host that rebuilds its field
|
|
1080
|
+
// config object (language, readonly) must not cost a round trip.
|
|
998
1081
|
effect(() => {
|
|
999
|
-
const
|
|
1000
|
-
const allowedWrite = this.writeAllowed();
|
|
1001
|
-
const ready = this.hasRequiredContext();
|
|
1082
|
+
const propertyId = this.propertyKeyId();
|
|
1002
1083
|
const levelId = this.levelId();
|
|
1003
1084
|
const levelDataId = this.levelDataId();
|
|
1004
|
-
|
|
1005
|
-
const readFields = this.readFields();
|
|
1006
|
-
untracked(() => {
|
|
1007
|
-
this.fetchSubscription?.unsubscribe();
|
|
1008
|
-
this.columns.set([]);
|
|
1009
|
-
this.rows.set([]);
|
|
1010
|
-
this.errorMessage.set(null);
|
|
1011
|
-
if ((!allowedRead && !allowedWrite) ||
|
|
1012
|
-
!ready ||
|
|
1013
|
-
levelId == null ||
|
|
1014
|
-
moduleId == null) {
|
|
1015
|
-
return;
|
|
1016
|
-
}
|
|
1017
|
-
if (levelDataId == null || Number(levelDataId) <= 0 || !allowedRead) {
|
|
1018
|
-
this.fetchDraftColumns(levelId, moduleId, readFields);
|
|
1019
|
-
}
|
|
1020
|
-
else {
|
|
1021
|
-
this.fetchRows(levelId, levelDataId, moduleId, readFields);
|
|
1022
|
-
}
|
|
1023
|
-
});
|
|
1085
|
+
untracked(() => this.loadTable(propertyId, levelId, levelDataId));
|
|
1024
1086
|
});
|
|
1025
1087
|
}
|
|
1026
1088
|
// ============================================================================
|
|
@@ -1034,11 +1096,16 @@ class EntityListField {
|
|
|
1034
1096
|
return;
|
|
1035
1097
|
this.lastEmittedJson = null;
|
|
1036
1098
|
this.storedValue.set(incoming);
|
|
1037
|
-
// Restore rows the backend left unprocessed.
|
|
1038
|
-
//
|
|
1099
|
+
// Restore rows the backend left unprocessed. Whether the loaded
|
|
1100
|
+
// `deletedIds` are historical markers or pending intent depends on the
|
|
1101
|
+
// value's provenance, which `deletedIds` resolves from `pendingSubmission`
|
|
1102
|
+
// — an input, so it cannot be read reliably this early.
|
|
1039
1103
|
const rows = Array.isArray(incoming?.rows) ? incoming.rows : [];
|
|
1040
1104
|
this.pendingRows.set(rows.filter((row) => !!row && typeof row === 'object'));
|
|
1041
|
-
this.
|
|
1105
|
+
this.loadedDeletedIds.set((Array.isArray(incoming?.deletedIds) ? incoming.deletedIds : [])
|
|
1106
|
+
.map((id) => Number(id))
|
|
1107
|
+
.filter((id) => Number.isFinite(id) && id > 0));
|
|
1108
|
+
this.stagedDeletedIds.set([]);
|
|
1042
1109
|
this.rowDrafts.set({});
|
|
1043
1110
|
}
|
|
1044
1111
|
/**
|
|
@@ -1234,7 +1301,7 @@ class EntityListField {
|
|
|
1234
1301
|
const rowId = String(row[ROW_ID_KEY] ?? '');
|
|
1235
1302
|
if (entityId > 0) {
|
|
1236
1303
|
if (!this.deletedIds().includes(entityId)) {
|
|
1237
|
-
this.
|
|
1304
|
+
this.stagedDeletedIds.set([...this.stagedDeletedIds(), entityId]);
|
|
1238
1305
|
}
|
|
1239
1306
|
// A queued update for a deleted record is pointless — drop it.
|
|
1240
1307
|
this.pendingRows.set(this.pendingRows().filter((pending) => pending.entityId !== entityId));
|
|
@@ -1302,14 +1369,36 @@ class EntityListField {
|
|
|
1302
1369
|
}
|
|
1303
1370
|
return row;
|
|
1304
1371
|
}
|
|
1305
|
-
/**
|
|
1372
|
+
/**
|
|
1373
|
+
* Render one table cell from a raw form value and its resolved label.
|
|
1374
|
+
*
|
|
1375
|
+
* The cell has to arrive in the shape the backend would have sent, because
|
|
1376
|
+
* that is what the entity renderers bind. Two things a control value is not:
|
|
1377
|
+
*
|
|
1378
|
+
* - **A scalar `value` is a string.** `mt-entity-percentage` reads `d.value`
|
|
1379
|
+
* only when `typeof` it is `'string'` and prints its placeholder otherwise,
|
|
1380
|
+
* so a numeric control value rendered as a filled bar with no number beside
|
|
1381
|
+
* it. Objects and arrays are the resolved shapes the rich renderers want,
|
|
1382
|
+
* and pass through untouched.
|
|
1383
|
+
* - **The column configuration has to travel with it.** Colour rules live
|
|
1384
|
+
* there, and `mt-entity-percentage` falls back to evaluating them itself
|
|
1385
|
+
* exactly when no per-value colour was resolved — which is every locally
|
|
1386
|
+
* added row. Without it a new 45% row rendered in the default colour while
|
|
1387
|
+
* the same value loaded from the backend rendered in its band colour.
|
|
1388
|
+
*/
|
|
1306
1389
|
buildCell(column, raw, label) {
|
|
1390
|
+
const value = this.toLocalEntityValue(column.viewType, raw, label);
|
|
1391
|
+
const propertyKey = column.propertyKey ?? column.key;
|
|
1307
1392
|
return {
|
|
1308
1393
|
name: column.label ?? column.key,
|
|
1309
1394
|
key: column.key,
|
|
1310
1395
|
viewType: column.viewType ?? 'Text',
|
|
1311
|
-
value:
|
|
1312
|
-
|
|
1396
|
+
value: value !== null && typeof value === 'object'
|
|
1397
|
+
? value
|
|
1398
|
+
: (this.toRawValue(value) ?? ''),
|
|
1399
|
+
rawValue: this.toRawValue(raw) ?? undefined,
|
|
1400
|
+
configuration: column.configuration,
|
|
1401
|
+
propertyConfiguration: this.propertyByKey().get(propertyKey)?.configuration,
|
|
1313
1402
|
};
|
|
1314
1403
|
}
|
|
1315
1404
|
/**
|
|
@@ -1320,6 +1409,14 @@ class EntityListField {
|
|
|
1320
1409
|
* `label` is the resolved option display (present for select-based fields).
|
|
1321
1410
|
*/
|
|
1322
1411
|
toLocalEntityValue(viewType, raw, label) {
|
|
1412
|
+
// A row loaded from a staged submission carries the backend's resolved
|
|
1413
|
+
// value as its label, and for the rich view types that object *is* what
|
|
1414
|
+
// the renderer binds — the same shape the raw branches below assemble by
|
|
1415
|
+
// hand. A select's resolved option is a plain string and still falls
|
|
1416
|
+
// through to them.
|
|
1417
|
+
const resolved = label != null && typeof label === 'object' && !Array.isArray(label)
|
|
1418
|
+
? label
|
|
1419
|
+
: null;
|
|
1323
1420
|
if (viewType === 'User') {
|
|
1324
1421
|
if (Array.isArray(raw)) {
|
|
1325
1422
|
const names = raw
|
|
@@ -1329,6 +1426,13 @@ class EntityListField {
|
|
|
1329
1426
|
.filter((name) => name != null && name !== '');
|
|
1330
1427
|
return names.length ? { displayName: names.join(', ') } : '';
|
|
1331
1428
|
}
|
|
1429
|
+
if (resolved) {
|
|
1430
|
+
return {
|
|
1431
|
+
...resolved,
|
|
1432
|
+
displayName: resolved['displayName'] ?? '',
|
|
1433
|
+
photoUrl: resolved['photoUrl'] ?? resolved['photo'] ?? '',
|
|
1434
|
+
};
|
|
1435
|
+
}
|
|
1332
1436
|
if (raw && typeof raw === 'object') {
|
|
1333
1437
|
const user = raw;
|
|
1334
1438
|
return {
|
|
@@ -1344,6 +1448,8 @@ class EntityListField {
|
|
|
1344
1448
|
return '';
|
|
1345
1449
|
}
|
|
1346
1450
|
if (viewType === 'Status' || viewType === 'Lookup') {
|
|
1451
|
+
if (resolved)
|
|
1452
|
+
return resolved;
|
|
1347
1453
|
if (raw && typeof raw === 'object')
|
|
1348
1454
|
return raw;
|
|
1349
1455
|
if (raw != null && raw !== '' && label != null) {
|
|
@@ -1351,6 +1457,8 @@ class EntityListField {
|
|
|
1351
1457
|
}
|
|
1352
1458
|
return raw ?? '';
|
|
1353
1459
|
}
|
|
1460
|
+
if (resolved)
|
|
1461
|
+
return resolved;
|
|
1354
1462
|
// Plain / scalar view types: prefer a resolved option label when present,
|
|
1355
1463
|
// else the raw value (unchanged for text / number / date / percentage).
|
|
1356
1464
|
if (label != null && (raw == null || typeof raw !== 'object')) {
|
|
@@ -1368,7 +1476,16 @@ class EntityListField {
|
|
|
1368
1476
|
// and delete intents.
|
|
1369
1477
|
const next = {
|
|
1370
1478
|
...(current ?? {}),
|
|
1371
|
-
|
|
1479
|
+
// `values[].value` is the backend's rendered label, carried only so the
|
|
1480
|
+
// table can print it. Submitting it back would echo a user object where
|
|
1481
|
+
// the stored scalar belongs.
|
|
1482
|
+
rows: this.pendingRows().map((row) => ({
|
|
1483
|
+
...row,
|
|
1484
|
+
values: (row.values ?? []).map(({ propertyKey, rawValue }) => ({
|
|
1485
|
+
propertyKey,
|
|
1486
|
+
rawValue,
|
|
1487
|
+
})),
|
|
1488
|
+
})),
|
|
1372
1489
|
deletedIds: this.deletedIds(),
|
|
1373
1490
|
};
|
|
1374
1491
|
this.storedValue.set(next);
|
|
@@ -1418,6 +1535,23 @@ class EntityListField {
|
|
|
1418
1535
|
}
|
|
1419
1536
|
return map;
|
|
1420
1537
|
}
|
|
1538
|
+
/**
|
|
1539
|
+
* Backend-resolved display values of a loaded row, keyed like `toValueMap`.
|
|
1540
|
+
*
|
|
1541
|
+
* A row the user just added carries its labels in a `rowDrafts` entry, but a
|
|
1542
|
+
* row that arrived on a loaded value has none — only what the backend
|
|
1543
|
+
* rendered beside each `rawValue`. Without this the approver's table prints
|
|
1544
|
+
* the stored scalar: a bare GUID where the assignee belongs.
|
|
1545
|
+
*/
|
|
1546
|
+
toDisplayMap(values) {
|
|
1547
|
+
const map = {};
|
|
1548
|
+
for (const value of values ?? []) {
|
|
1549
|
+
if (!value?.propertyKey || value.value === undefined)
|
|
1550
|
+
continue;
|
|
1551
|
+
map[value.propertyKey] = value.value;
|
|
1552
|
+
}
|
|
1553
|
+
return map;
|
|
1554
|
+
}
|
|
1421
1555
|
dropEmptyValues(values) {
|
|
1422
1556
|
const next = {};
|
|
1423
1557
|
for (const [key, value] of Object.entries(values)) {
|
|
@@ -1466,97 +1600,123 @@ class EntityListField {
|
|
|
1466
1600
|
return this.toRawValue(a) === this.toRawValue(b);
|
|
1467
1601
|
}
|
|
1468
1602
|
// ============================================================================
|
|
1469
|
-
// Read
|
|
1603
|
+
// Read endpoints — GET Properties/{id}/entitylist/table-metadata (columns,
|
|
1604
|
+
// effective access, canonical keys) + POST fetch/query (rows)
|
|
1470
1605
|
// ============================================================================
|
|
1471
|
-
|
|
1606
|
+
/**
|
|
1607
|
+
* Load the runtime-scoped table description, then its rows.
|
|
1608
|
+
*
|
|
1609
|
+
* The metadata endpoint is the authorization boundary for this field: it
|
|
1610
|
+
* answers `403` when the user may not read the target module in this level,
|
|
1611
|
+
* so the columns are never built from a source that skipped that check.
|
|
1612
|
+
*/
|
|
1613
|
+
loadTable(propertyId, levelId, levelDataId) {
|
|
1614
|
+
this.metadataSubscription?.unsubscribe();
|
|
1615
|
+
this.fetchSubscription?.unsubscribe();
|
|
1616
|
+
this.metadata.set(null);
|
|
1617
|
+
this.metadataFailure.set(null);
|
|
1618
|
+
this.columns.set([]);
|
|
1619
|
+
this.rows.set([]);
|
|
1620
|
+
this.errorMessage.set(null);
|
|
1621
|
+
this.loading.set(false);
|
|
1622
|
+
if (!(propertyId > 0) || levelId == null || !(Number(levelId) > 0))
|
|
1623
|
+
return;
|
|
1472
1624
|
this.loading.set(true);
|
|
1473
1625
|
const ctx = this.context();
|
|
1474
|
-
|
|
1475
|
-
.get(
|
|
1476
|
-
params: {
|
|
1477
|
-
//
|
|
1478
|
-
//
|
|
1479
|
-
//
|
|
1480
|
-
// only honours `noMessage`, and `fetch/catalog` is not a silent
|
|
1481
|
-
// endpoint the way `fetch/query` is.
|
|
1626
|
+
this.metadataSubscription = this.http
|
|
1627
|
+
.get(`Properties/${propertyId}/entitylist/table-metadata`, {
|
|
1628
|
+
params: { levelId: String(levelId) },
|
|
1629
|
+
// `403` (no module read access) and `404` (not configured for this
|
|
1630
|
+
// level) are states this field renders inline, not failures worth a
|
|
1631
|
+
// toast from the host's message interceptor.
|
|
1482
1632
|
headers: { noMessage: 'true' },
|
|
1483
1633
|
...(ctx ? { context: ctx } : {}),
|
|
1484
1634
|
})
|
|
1485
|
-
.pipe(
|
|
1486
|
-
if (this.accessMode() !== 'Write' || error.status !== 404) {
|
|
1487
|
-
return throwError(() => error);
|
|
1488
|
-
}
|
|
1489
|
-
// Write-only EntityLists may intentionally use a target module that
|
|
1490
|
-
// is not mapped to the owning level. Fetch catalog represents a
|
|
1491
|
-
// browsable level/module context and rejects that pair; the runtime
|
|
1492
|
-
// Create form remains the authorized source for its field metadata.
|
|
1493
|
-
return this.http
|
|
1494
|
-
.post('process-form-load', {
|
|
1495
|
-
moduleKey: 'ModuleData',
|
|
1496
|
-
operationKey: 'Create',
|
|
1497
|
-
moduleId,
|
|
1498
|
-
levelId,
|
|
1499
|
-
}, {
|
|
1500
|
-
headers: { noMessage: 'true' },
|
|
1501
|
-
...(ctx ? { context: ctx } : {}),
|
|
1502
|
-
})
|
|
1503
|
-
.pipe(map((response) => this.mapProcessFormProperties(response)));
|
|
1504
|
-
}));
|
|
1505
|
-
this.fetchSubscription = properties$
|
|
1506
|
-
.pipe(takeUntilDestroyed(this.destroyRef), finalize(() => this.loading.set(false)))
|
|
1635
|
+
.pipe(takeUntilDestroyed(this.destroyRef))
|
|
1507
1636
|
.subscribe({
|
|
1508
|
-
next: (
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
viewType: property.viewType,
|
|
1519
|
-
order: property.order,
|
|
1520
|
-
visible: true,
|
|
1521
|
-
configuration: property.configuration ?? null,
|
|
1522
|
-
})),
|
|
1523
|
-
},
|
|
1524
|
-
});
|
|
1637
|
+
next: (response) => this.applyMetadata(response.data, levelDataId),
|
|
1638
|
+
error: (error) => {
|
|
1639
|
+
this.loading.set(false);
|
|
1640
|
+
const failure = resolveMetadataFailure(error.status);
|
|
1641
|
+
this.metadataFailure.set(failure);
|
|
1642
|
+
// `forbidden` and `unavailable` are rendered as their own notice; only
|
|
1643
|
+
// a real request failure is an error.
|
|
1644
|
+
if (failure === 'failed') {
|
|
1645
|
+
this.errorMessage.set(this.transloco.translate('components.entityListField.loadFailed'));
|
|
1646
|
+
}
|
|
1525
1647
|
},
|
|
1526
|
-
error: () => this.errorMessage.set(this.transloco.translate('components.entityListField.loadFailed')),
|
|
1527
1648
|
});
|
|
1528
1649
|
}
|
|
1529
1650
|
/**
|
|
1530
|
-
*
|
|
1531
|
-
*
|
|
1532
|
-
*
|
|
1533
|
-
*
|
|
1651
|
+
* Apply the metadata, then fetch rows when there is a persisted parent to
|
|
1652
|
+
* scope them to. A draft parent (no `levelDataId`) and a write-only field
|
|
1653
|
+
* both stop at the columns — the first has no records yet, the second may
|
|
1654
|
+
* not read them.
|
|
1534
1655
|
*/
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
.
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1656
|
+
applyMetadata(metadata, levelDataId) {
|
|
1657
|
+
this.metadata.set(metadata);
|
|
1658
|
+
this.columns.set(this.buildColumns(metadata));
|
|
1659
|
+
if (!this.moduleBacked() ||
|
|
1660
|
+
!this.canRead() ||
|
|
1661
|
+
levelDataId == null ||
|
|
1662
|
+
Number(levelDataId) <= 0) {
|
|
1663
|
+
this.loading.set(false);
|
|
1664
|
+
return;
|
|
1665
|
+
}
|
|
1666
|
+
this.fetchRows(metadata.levelId, levelDataId, metadata.moduleId, this.projectedKeys());
|
|
1667
|
+
}
|
|
1668
|
+
/**
|
|
1669
|
+
* Table columns, in the order the backend returned them.
|
|
1670
|
+
*
|
|
1671
|
+
* `projectionMeta.columns[].key` is the catalog property key here — the same
|
|
1672
|
+
* key `fetch/query` keys its record values by — so a column maps onto a row
|
|
1673
|
+
* value directly. The lookup still falls back to `normalizedKey` so a column
|
|
1674
|
+
* fed from any other projection keeps resolving.
|
|
1675
|
+
*
|
|
1676
|
+
* The columns are the *union* of readable and writable fields, so a
|
|
1677
|
+
* write-only key arrives as a column too — a `Planned Finish` the user may
|
|
1678
|
+
* set in the dialog but may not read. It is not projected into the rows and
|
|
1679
|
+
* would render as an empty column, so only readable keys become columns.
|
|
1680
|
+
* Write-only access is the exception: its readable set is empty by
|
|
1681
|
+
* definition, and its stored rows have nothing else to render through.
|
|
1682
|
+
*/
|
|
1683
|
+
buildColumns(metadata) {
|
|
1684
|
+
const propertyByKey = new Map();
|
|
1685
|
+
const propertyByNormalizedKey = new Map();
|
|
1686
|
+
for (const property of metadata.catalog?.properties ?? []) {
|
|
1687
|
+
propertyByKey.set(property.key, property);
|
|
1688
|
+
propertyByNormalizedKey.set(property.normalizedKey, property);
|
|
1689
|
+
}
|
|
1690
|
+
const readable = new Set(metadata.readFields);
|
|
1691
|
+
return (metadata.projectionMeta?.columns ?? [])
|
|
1692
|
+
.filter((column) => column.visible)
|
|
1693
|
+
.filter((column) => readable.size === 0 || readable.has(column.key))
|
|
1694
|
+
.sort((a, b) => a.order - b.order)
|
|
1695
|
+
.map((column) => ({
|
|
1696
|
+
key: column.key,
|
|
1697
|
+
label: column.label,
|
|
1698
|
+
type: 'entity',
|
|
1699
|
+
sortable: !UNSORTABLE_ENTITY_VIEW_TYPES.has(column.viewType),
|
|
1700
|
+
viewType: column.viewType,
|
|
1701
|
+
order: column.order,
|
|
1702
|
+
visible: column.visible,
|
|
1703
|
+
configuration: column.configuration ?? null,
|
|
1704
|
+
propertyKey: (propertyByKey.has(column.key)
|
|
1705
|
+
? column.key
|
|
1706
|
+
: propertyByNormalizedKey.get(column.key)?.key) ?? column.key,
|
|
1707
|
+
}));
|
|
1559
1708
|
}
|
|
1709
|
+
/** Catalog properties of the loaded metadata, keyed by property key. */
|
|
1710
|
+
propertyByKey = computed(() => {
|
|
1711
|
+
const map = new Map();
|
|
1712
|
+
for (const property of this.metadata()?.catalog?.properties ?? []) {
|
|
1713
|
+
map.set(property.key, property);
|
|
1714
|
+
if (!map.has(property.normalizedKey)) {
|
|
1715
|
+
map.set(property.normalizedKey, property);
|
|
1716
|
+
}
|
|
1717
|
+
}
|
|
1718
|
+
return map;
|
|
1719
|
+
}, ...(ngDevMode ? [{ debugName: "propertyByKey" }] : /* istanbul ignore next */ []));
|
|
1560
1720
|
fetchRows(levelId, levelDataId, moduleId, propertyKeys) {
|
|
1561
1721
|
this.loading.set(true);
|
|
1562
1722
|
this.errorMessage.set(null);
|
|
@@ -1587,42 +1747,30 @@ class EntityListField {
|
|
|
1587
1747
|
const payload = response && typeof response === 'object' && 'data' in response
|
|
1588
1748
|
? (response.data ?? response)
|
|
1589
1749
|
: response;
|
|
1590
|
-
this.
|
|
1750
|
+
this.applyRecords(payload.records ?? []);
|
|
1591
1751
|
});
|
|
1592
1752
|
}
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
const columns =
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
// Store the catalog property key so buildRow can look up form values
|
|
1615
|
-
// keyed by property key (e.g. "task_name") rather than the
|
|
1616
|
-
// normalizedKey used as the column display key (e.g. "Name").
|
|
1617
|
-
propertyKey: propertyByNormalizedKey.get(column.key)?.key ?? column.key,
|
|
1618
|
-
}));
|
|
1619
|
-
this.columns.set(columns);
|
|
1620
|
-
// Reading blocked (access = Write / None): keep the columns, drop records.
|
|
1621
|
-
if (!this.canRead()) {
|
|
1622
|
-
this.rows.set([]);
|
|
1623
|
-
return;
|
|
1624
|
-
}
|
|
1625
|
-
const rows = (response.records ?? []).map((record) => {
|
|
1753
|
+
/**
|
|
1754
|
+
* Project fetched records onto the metadata columns.
|
|
1755
|
+
*
|
|
1756
|
+
* Cells are built per rendered column, but the row's value maps cover every
|
|
1757
|
+
* **projected** key — a writable key without a column has no cell to render
|
|
1758
|
+
* and still has to reach the edit dialog and the update diff.
|
|
1759
|
+
*/
|
|
1760
|
+
applyRecords(records) {
|
|
1761
|
+
const properties = this.propertyByKey();
|
|
1762
|
+
const columns = this.columns();
|
|
1763
|
+
const valueKeys = [
|
|
1764
|
+
...new Set([
|
|
1765
|
+
...this.projectedKeys(),
|
|
1766
|
+
...columns.map((column) => column.propertyKey ?? column.key),
|
|
1767
|
+
]),
|
|
1768
|
+
];
|
|
1769
|
+
const viewTypeByKey = new Map(columns.map((column) => [
|
|
1770
|
+
column.propertyKey ?? column.key,
|
|
1771
|
+
column.viewType,
|
|
1772
|
+
]));
|
|
1773
|
+
this.rows.set(records.map((record) => {
|
|
1626
1774
|
const values = {};
|
|
1627
1775
|
const prefill = {};
|
|
1628
1776
|
const row = {
|
|
@@ -1631,25 +1779,24 @@ class EntityListField {
|
|
|
1631
1779
|
[ROW_ENTITY_ID_KEY]: record.id,
|
|
1632
1780
|
};
|
|
1633
1781
|
for (const column of columns) {
|
|
1634
|
-
const
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1782
|
+
const propertyKey = column.propertyKey ?? column.key;
|
|
1783
|
+
row[column.key] = this.toEntityData(column, record.values?.[propertyKey], properties.get(propertyKey), record.id);
|
|
1784
|
+
}
|
|
1785
|
+
for (const key of valueKeys) {
|
|
1786
|
+
const cell = record.values?.[key];
|
|
1639
1787
|
// Keep the machine-readable value as the baseline a partial update is
|
|
1640
1788
|
// diffed against — it is the shape the row submits.
|
|
1641
|
-
values[
|
|
1789
|
+
values[key] = cell?.raw ?? cell?.value ?? null;
|
|
1642
1790
|
// What the edit dialog patches into its form, which is not always the
|
|
1643
1791
|
// same thing: see OBJECT_VALUED_VIEW_TYPES.
|
|
1644
|
-
prefill[
|
|
1792
|
+
prefill[key] = OBJECT_VALUED_VIEW_TYPES.has(viewTypeByKey.get(key) ?? properties.get(key)?.viewType ?? '')
|
|
1645
1793
|
? (cell?.value ?? cell?.raw ?? null)
|
|
1646
|
-
: values[
|
|
1794
|
+
: values[key];
|
|
1647
1795
|
}
|
|
1648
1796
|
row[ROW_VALUES_KEY] = values;
|
|
1649
1797
|
row[ROW_PREFILL_KEY] = prefill;
|
|
1650
1798
|
return row;
|
|
1651
|
-
});
|
|
1652
|
-
this.rows.set(rows);
|
|
1799
|
+
}));
|
|
1653
1800
|
}
|
|
1654
1801
|
toEntityData(column, cell, property, recordId) {
|
|
1655
1802
|
return {
|
|
@@ -1670,7 +1817,7 @@ class EntityListField {
|
|
|
1670
1817
|
};
|
|
1671
1818
|
}
|
|
1672
1819
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: EntityListField, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1673
|
-
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 }, 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\">\
|
|
1820
|
+
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 });
|
|
1674
1821
|
}
|
|
1675
1822
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: EntityListField, decorators: [{
|
|
1676
1823
|
type: Component,
|
|
@@ -1682,8 +1829,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImpor
|
|
|
1682
1829
|
Table,
|
|
1683
1830
|
Button,
|
|
1684
1831
|
TranslocoPipe,
|
|
1685
|
-
], changeDetection: ChangeDetectionStrategy.OnPush, host: { class: 'grid gap-1' }, template: "<div class=\"flex flex-col gap-2\">\
|
|
1686
|
-
}], 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 }] }], lookups: [{ type: i0.Input, args: [{ isSignal: true, alias: "lookups", required: false }] }], context: [{ type: i0.Input, args: [{ isSignal: true, alias: "context", required: false }] }] } });
|
|
1832
|
+
], 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"] }]
|
|
1833
|
+
}], 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 }] }] } });
|
|
1687
1834
|
|
|
1688
1835
|
/** Page size when loading the full deliverable list, and a hard safety cap. */
|
|
1689
1836
|
const PAGE_SIZE = 100;
|