@masterteam/components 0.0.302 → 0.0.303
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/common.css +1 -1
- package/assets/i18n/ar.json +405 -392
- package/assets/i18n/en.json +405 -392
- package/fesm2022/masterteam-components-business-fields.mjs +500 -14
- package/fesm2022/masterteam-components-business-fields.mjs.map +1 -1
- package/fesm2022/masterteam-components-entities.mjs +101 -5
- package/fesm2022/masterteam-components-entities.mjs.map +1 -1
- package/fesm2022/masterteam-components.mjs +6 -0
- package/fesm2022/masterteam-components.mjs.map +1 -1
- package/package.json +1 -1
- package/types/masterteam-components-business-fields.d.ts +80 -7
- package/types/masterteam-components-entities.d.ts +38 -2
- package/types/masterteam-components.d.ts +12 -0
|
@@ -3,10 +3,10 @@ import * as i0 from '@angular/core';
|
|
|
3
3
|
import { input, inject, DestroyRef, signal, computed, ChangeDetectionStrategy, Component, ChangeDetectorRef, effect, untracked, viewChild, linkedSignal, InjectionToken } from '@angular/core';
|
|
4
4
|
import { takeUntilDestroyed, toSignal } from '@angular/core/rxjs-interop';
|
|
5
5
|
import * as i1 from '@angular/forms';
|
|
6
|
-
import { ControlContainer, NgControl, FormsModule, Validators } from '@angular/forms';
|
|
6
|
+
import { ControlContainer, NgControl, FormsModule, Validators, FormControl, ReactiveFormsModule } 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, expand, EMPTY, reduce
|
|
9
|
+
import { startWith, finalize, catchError, of, debounceTime, map, distinctUntilChanged, take, expand, EMPTY, reduce } 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';
|
|
@@ -20,7 +20,9 @@ import { newFieldId, coerceCheckboxValue } from '@masterteam/components';
|
|
|
20
20
|
import { Skeleton } from 'primeng/skeleton';
|
|
21
21
|
import { Message } from 'primeng/message';
|
|
22
22
|
import { ModalService } from '@masterteam/components/modal';
|
|
23
|
-
import { sortLocalRows, visibleLocalSchemaFields, resolveLocalFieldViewType, resolveLocalFieldLabel, localCellsByFieldId, resolveLocalFieldConfiguration, isEntityListLocalDocument, serializeEntityRawValue, readEntityValueColor, EntityRuntimeContextStore, ENTITY_LIST_TABLE_COMPONENT } from '@masterteam/components/entities';
|
|
23
|
+
import { sortLocalRows, visibleLocalSchemaFields, resolveLocalFieldViewType, resolveLocalFieldLabel, localCellsByFieldId, resolveLocalFieldConfiguration, isEntityListSelectionDocument, isEntityListLocalDocument, serializeEntityRawValue, readEntityValueColor, EntityRuntimeContextStore, ENTITY_LIST_TABLE_COMPONENT } from '@masterteam/components/entities';
|
|
24
|
+
import { ModalRef } from '@masterteam/components/dialog';
|
|
25
|
+
import { TextField } from '@masterteam/components/text-field';
|
|
24
26
|
import * as i2$1 from 'primeng/inputtext';
|
|
25
27
|
import { InputTextModule } from 'primeng/inputtext';
|
|
26
28
|
|
|
@@ -543,7 +545,7 @@ class SchemaConnectionField {
|
|
|
543
545
|
this.disabled.set(disabled);
|
|
544
546
|
}
|
|
545
547
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: SchemaConnectionField, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
546
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.8", type: SchemaConnectionField, isStandalone: true, selector: "mt-schema-connection-field", inputs: { label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", 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 }, filter: { classPropertyName: "filter", publicName: "filter", isSignal: true, isRequired: false, transformFunction: null }, configuration: { classPropertyName: "configuration", publicName: "configuration", isSignal: true, isRequired: true, transformFunction: null }, runtimeContext: { classPropertyName: "runtimeContext", publicName: "runtimeContext", 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 gap-4 w-full\">\n @for (state of sourceLevelStates(); track getSourceId(state.source)) {\n <!--\n `grid gap-1 grid-cols-[minmax(0,1fr)]` matches the label\u2192control spacing\n every other mt-* field gets from its host class; the explicit column\n keeps the implicit max-content track from letting long values overflow.\n -->\n <div\n [style.width]=\"dropdownWidth()\"\n class=\"grid gap-1 grid-cols-[minmax(0,1fr)] min-w-0\"\n >\n <div class=\"flex items-center gap-1\">\n <label\n class=\"truncate\"\n [class.required]=\"state.source.isOptional !== true\"\n >\n {{ resolveSourceName(state.source) }}\n </label>\n <span\n class=\"inline-flex shrink-0 text-surface-400\"\n [mtTooltip]=\"connectionHint()\"\n tooltipPosition=\"top\"\n >\n <mt-icon icon=\"general.link-01\" />\n </span>\n </div>\n\n @if (state.source.allowManyToMany) {\n <mt-multi-select-field\n [field]=\"false\"\n [(ngModel)]=\"selections[getSourceId(state.source)]\"\n (ngModelChange)=\"syncValue()\"\n [options]=\"state.options\"\n optionLabel=\"name\"\n optionValue=\"id\"\n [placeholder]=\"sourcePlaceholder(state.source)\"\n [readonly]=\"disabled() || readonly()\"\n [filter]=\"filter()\"\n [showClear]=\"state.source.isOptional === true\"\n display=\"chip\"\n />\n } @else {\n <mt-select-field\n [field]=\"false\"\n [(ngModel)]=\"selections[getSourceId(state.source)]\"\n (ngModelChange)=\"syncValue()\"\n [options]=\"state.options\"\n optionLabel=\"name\"\n optionValue=\"id\"\n [placeholder]=\"sourcePlaceholder(state.source)\"\n [readonly]=\"disabled() || readonly()\"\n [filter]=\"filter()\"\n [loading]=\"state.loading\"\n [showClear]=\"state.source.isOptional === true\"\n />\n }\n\n <!--\n The error belongs to the dropdown that is empty, not to the field. One\n message below the whole row always rendered under the first source, so\n a missing `Program` read as an error on `Portfolio`.\n -->\n <mt-field-validation\n [control]=\"sourceErrorControl(state.source)\"\n ></mt-field-validation>\n </div>\n }\n</div>\n\n<!--\n Whatever the control reports that no single source owns \u2014 a server error, say.\n Null while a source is missing, so the message is never shown twice.\n-->\n<mt-field-validation\n [control]=\"unattributedErrorControl()\"\n></mt-field-validation>\n", styles: [""], dependencies: [{ kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "component", type: SelectField, selector: "mt-select-field", inputs: ["field", "hint", "label", "placeholder", "hasPlaceholderPrefix", "class", "readonly", "pInputs", "options", "optionValue", "optionLabel", "filter", "filterBy", "dataKey", "showClear", "clearAfterSelect", "required", "group", "size", "optionGroupLabel", "optionGroupChildren", "loading", "optionIcon", "optionIconColor", "optionIconShape", "optionAvatarShape", "optionGroupIcon", "optionGroupIconColor", "optionGroupIconShape", "optionGroupAvatarShape", "markCurrentUser"], outputs: ["onChange"] }, { kind: "component", type: MultiSelectField, selector: "mt-multi-select-field", inputs: ["field", "label", "placeholder", "class", "readonly", "pInputs", "options", "optionValue", "optionLabel", "filter", "filterBy", "dataKey", "showClear", "display", "required", "maxSelectedLabels", "group", "virtualScroll", "virtualScrollItemSize", "optionGroupLabel", "optionGroupChildren", "optionIcon", "optionIconColor", "optionIconShape", "optionAvatarShape", "optionGroupIcon", "optionGroupIconColor", "optionGroupIconShape", "optionGroupAvatarShape"], outputs: ["onChange"] }, { kind: "component", type: FieldValidation, selector: "mt-field-validation", inputs: ["control", "touched", "messageId"] }, { kind: "directive", type: Tooltip, selector: "[mtTooltip]" }, { kind: "component", type: Icon, selector: "mt-icon", inputs: ["icon"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
548
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.8", type: SchemaConnectionField, isStandalone: true, selector: "mt-schema-connection-field", inputs: { label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", 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 }, filter: { classPropertyName: "filter", publicName: "filter", isSignal: true, isRequired: false, transformFunction: null }, configuration: { classPropertyName: "configuration", publicName: "configuration", isSignal: true, isRequired: true, transformFunction: null }, runtimeContext: { classPropertyName: "runtimeContext", publicName: "runtimeContext", 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 gap-4 w-full\">\r\n @for (state of sourceLevelStates(); track getSourceId(state.source)) {\r\n <!--\r\n `grid gap-1 grid-cols-[minmax(0,1fr)]` matches the label\u2192control spacing\r\n every other mt-* field gets from its host class; the explicit column\r\n keeps the implicit max-content track from letting long values overflow.\r\n -->\r\n <div\r\n [style.width]=\"dropdownWidth()\"\r\n class=\"grid gap-1 grid-cols-[minmax(0,1fr)] min-w-0\"\r\n >\r\n <div class=\"flex items-center gap-1\">\r\n <label\r\n class=\"truncate\"\r\n [class.required]=\"state.source.isOptional !== true\"\r\n >\r\n {{ resolveSourceName(state.source) }}\r\n </label>\r\n <span\r\n class=\"inline-flex shrink-0 text-surface-400\"\r\n [mtTooltip]=\"connectionHint()\"\r\n tooltipPosition=\"top\"\r\n >\r\n <mt-icon icon=\"general.link-01\" />\r\n </span>\r\n </div>\r\n\r\n @if (state.source.allowManyToMany) {\r\n <mt-multi-select-field\r\n [field]=\"false\"\r\n [(ngModel)]=\"selections[getSourceId(state.source)]\"\r\n (ngModelChange)=\"syncValue()\"\r\n [options]=\"state.options\"\r\n optionLabel=\"name\"\r\n optionValue=\"id\"\r\n [placeholder]=\"sourcePlaceholder(state.source)\"\r\n [readonly]=\"disabled() || readonly()\"\r\n [filter]=\"filter()\"\r\n [showClear]=\"state.source.isOptional === true\"\r\n display=\"chip\"\r\n />\r\n } @else {\r\n <mt-select-field\r\n [field]=\"false\"\r\n [(ngModel)]=\"selections[getSourceId(state.source)]\"\r\n (ngModelChange)=\"syncValue()\"\r\n [options]=\"state.options\"\r\n optionLabel=\"name\"\r\n optionValue=\"id\"\r\n [placeholder]=\"sourcePlaceholder(state.source)\"\r\n [readonly]=\"disabled() || readonly()\"\r\n [filter]=\"filter()\"\r\n [loading]=\"state.loading\"\r\n [showClear]=\"state.source.isOptional === true\"\r\n />\r\n }\r\n\r\n <!--\r\n The error belongs to the dropdown that is empty, not to the field. One\r\n message below the whole row always rendered under the first source, so\r\n a missing `Program` read as an error on `Portfolio`.\r\n -->\r\n <mt-field-validation\r\n [control]=\"sourceErrorControl(state.source)\"\r\n ></mt-field-validation>\r\n </div>\r\n }\r\n</div>\r\n\r\n<!--\r\n Whatever the control reports that no single source owns \u2014 a server error, say.\r\n Null while a source is missing, so the message is never shown twice.\r\n-->\r\n<mt-field-validation\r\n [control]=\"unattributedErrorControl()\"\r\n></mt-field-validation>\r\n", styles: [""], dependencies: [{ kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "component", type: SelectField, selector: "mt-select-field", inputs: ["field", "hint", "label", "placeholder", "hasPlaceholderPrefix", "class", "readonly", "pInputs", "options", "optionValue", "optionLabel", "filter", "filterBy", "dataKey", "showClear", "clearAfterSelect", "required", "group", "size", "optionGroupLabel", "optionGroupChildren", "loading", "optionIcon", "optionIconColor", "optionIconShape", "optionAvatarShape", "optionGroupIcon", "optionGroupIconColor", "optionGroupIconShape", "optionGroupAvatarShape", "markCurrentUser"], outputs: ["onChange"] }, { kind: "component", type: MultiSelectField, selector: "mt-multi-select-field", inputs: ["field", "label", "placeholder", "class", "readonly", "pInputs", "options", "optionValue", "optionLabel", "filter", "filterBy", "dataKey", "showClear", "display", "required", "maxSelectedLabels", "group", "virtualScroll", "virtualScrollItemSize", "optionGroupLabel", "optionGroupChildren", "optionIcon", "optionIconColor", "optionIconShape", "optionAvatarShape", "optionGroupIcon", "optionGroupIconColor", "optionGroupIconShape", "optionGroupAvatarShape"], outputs: ["onChange"] }, { kind: "component", type: FieldValidation, selector: "mt-field-validation", inputs: ["control", "touched", "messageId"] }, { kind: "directive", type: Tooltip, selector: "[mtTooltip]" }, { kind: "component", type: Icon, selector: "mt-icon", inputs: ["icon"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
547
549
|
}
|
|
548
550
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: SchemaConnectionField, decorators: [{
|
|
549
551
|
type: Component,
|
|
@@ -556,7 +558,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImpor
|
|
|
556
558
|
Icon,
|
|
557
559
|
], changeDetection: ChangeDetectionStrategy.OnPush, host: {
|
|
558
560
|
class: 'grid gap-1',
|
|
559
|
-
}, template: "<div class=\"flex gap-4 w-full\">\n @for (state of sourceLevelStates(); track getSourceId(state.source)) {\n <!--\n `grid gap-1 grid-cols-[minmax(0,1fr)]` matches the label\u2192control spacing\n every other mt-* field gets from its host class; the explicit column\n keeps the implicit max-content track from letting long values overflow.\n -->\n <div\n [style.width]=\"dropdownWidth()\"\n class=\"grid gap-1 grid-cols-[minmax(0,1fr)] min-w-0\"\n >\n <div class=\"flex items-center gap-1\">\n <label\n class=\"truncate\"\n [class.required]=\"state.source.isOptional !== true\"\n >\n {{ resolveSourceName(state.source) }}\n </label>\n <span\n class=\"inline-flex shrink-0 text-surface-400\"\n [mtTooltip]=\"connectionHint()\"\n tooltipPosition=\"top\"\n >\n <mt-icon icon=\"general.link-01\" />\n </span>\n </div>\n\n @if (state.source.allowManyToMany) {\n <mt-multi-select-field\n [field]=\"false\"\n [(ngModel)]=\"selections[getSourceId(state.source)]\"\n (ngModelChange)=\"syncValue()\"\n [options]=\"state.options\"\n optionLabel=\"name\"\n optionValue=\"id\"\n [placeholder]=\"sourcePlaceholder(state.source)\"\n [readonly]=\"disabled() || readonly()\"\n [filter]=\"filter()\"\n [showClear]=\"state.source.isOptional === true\"\n display=\"chip\"\n />\n } @else {\n <mt-select-field\n [field]=\"false\"\n [(ngModel)]=\"selections[getSourceId(state.source)]\"\n (ngModelChange)=\"syncValue()\"\n [options]=\"state.options\"\n optionLabel=\"name\"\n optionValue=\"id\"\n [placeholder]=\"sourcePlaceholder(state.source)\"\n [readonly]=\"disabled() || readonly()\"\n [filter]=\"filter()\"\n [loading]=\"state.loading\"\n [showClear]=\"state.source.isOptional === true\"\n />\n }\n\n <!--\n The error belongs to the dropdown that is empty, not to the field. One\n message below the whole row always rendered under the first source, so\n a missing `Program` read as an error on `Portfolio`.\n -->\n <mt-field-validation\n [control]=\"sourceErrorControl(state.source)\"\n ></mt-field-validation>\n </div>\n }\n</div>\n\n<!--\n Whatever the control reports that no single source owns \u2014 a server error, say.\n Null while a source is missing, so the message is never shown twice.\n-->\n<mt-field-validation\n [control]=\"unattributedErrorControl()\"\n></mt-field-validation>\n" }]
|
|
561
|
+
}, template: "<div class=\"flex gap-4 w-full\">\r\n @for (state of sourceLevelStates(); track getSourceId(state.source)) {\r\n <!--\r\n `grid gap-1 grid-cols-[minmax(0,1fr)]` matches the label\u2192control spacing\r\n every other mt-* field gets from its host class; the explicit column\r\n keeps the implicit max-content track from letting long values overflow.\r\n -->\r\n <div\r\n [style.width]=\"dropdownWidth()\"\r\n class=\"grid gap-1 grid-cols-[minmax(0,1fr)] min-w-0\"\r\n >\r\n <div class=\"flex items-center gap-1\">\r\n <label\r\n class=\"truncate\"\r\n [class.required]=\"state.source.isOptional !== true\"\r\n >\r\n {{ resolveSourceName(state.source) }}\r\n </label>\r\n <span\r\n class=\"inline-flex shrink-0 text-surface-400\"\r\n [mtTooltip]=\"connectionHint()\"\r\n tooltipPosition=\"top\"\r\n >\r\n <mt-icon icon=\"general.link-01\" />\r\n </span>\r\n </div>\r\n\r\n @if (state.source.allowManyToMany) {\r\n <mt-multi-select-field\r\n [field]=\"false\"\r\n [(ngModel)]=\"selections[getSourceId(state.source)]\"\r\n (ngModelChange)=\"syncValue()\"\r\n [options]=\"state.options\"\r\n optionLabel=\"name\"\r\n optionValue=\"id\"\r\n [placeholder]=\"sourcePlaceholder(state.source)\"\r\n [readonly]=\"disabled() || readonly()\"\r\n [filter]=\"filter()\"\r\n [showClear]=\"state.source.isOptional === true\"\r\n display=\"chip\"\r\n />\r\n } @else {\r\n <mt-select-field\r\n [field]=\"false\"\r\n [(ngModel)]=\"selections[getSourceId(state.source)]\"\r\n (ngModelChange)=\"syncValue()\"\r\n [options]=\"state.options\"\r\n optionLabel=\"name\"\r\n optionValue=\"id\"\r\n [placeholder]=\"sourcePlaceholder(state.source)\"\r\n [readonly]=\"disabled() || readonly()\"\r\n [filter]=\"filter()\"\r\n [loading]=\"state.loading\"\r\n [showClear]=\"state.source.isOptional === true\"\r\n />\r\n }\r\n\r\n <!--\r\n The error belongs to the dropdown that is empty, not to the field. One\r\n message below the whole row always rendered under the first source, so\r\n a missing `Program` read as an error on `Portfolio`.\r\n -->\r\n <mt-field-validation\r\n [control]=\"sourceErrorControl(state.source)\"\r\n ></mt-field-validation>\r\n </div>\r\n }\r\n</div>\r\n\r\n<!--\r\n Whatever the control reports that no single source owns \u2014 a server error, say.\r\n Null while a source is missing, so the message is never shown twice.\r\n-->\r\n<mt-field-validation\r\n [control]=\"unattributedErrorControl()\"\r\n></mt-field-validation>\r\n" }]
|
|
560
562
|
}], ctorParameters: () => [], propDecorators: { label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], placeholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "placeholder", required: false }] }], readonly: [{ type: i0.Input, args: [{ isSignal: true, alias: "readonly", required: false }] }], required: [{ type: i0.Input, args: [{ isSignal: true, alias: "required", required: false }] }], filter: [{ type: i0.Input, args: [{ isSignal: true, alias: "filter", required: false }] }], configuration: [{ type: i0.Input, args: [{ isSignal: true, alias: "configuration", required: true }] }], runtimeContext: [{ type: i0.Input, args: [{ isSignal: true, alias: "runtimeContext", required: false }] }], context: [{ type: i0.Input, args: [{ isSignal: true, alias: "context", required: false }] }] } });
|
|
561
563
|
|
|
562
564
|
const PREDECESSOR_TYPE_BY_TOKEN = {
|
|
@@ -949,6 +951,269 @@ function newLocalUuid() {
|
|
|
949
951
|
].join('-');
|
|
950
952
|
}
|
|
951
953
|
|
|
954
|
+
function createSelectionEditorState(base) {
|
|
955
|
+
return {
|
|
956
|
+
base,
|
|
957
|
+
ids: positiveIds(base?.entityIds),
|
|
958
|
+
names: {},
|
|
959
|
+
mutationId: null,
|
|
960
|
+
mutationKey: null,
|
|
961
|
+
};
|
|
962
|
+
}
|
|
963
|
+
function positiveIds(ids) {
|
|
964
|
+
const out = [];
|
|
965
|
+
for (const entry of ids ?? []) {
|
|
966
|
+
const id = Number(entry);
|
|
967
|
+
if (Number.isInteger(id) && id > 0 && !out.includes(id))
|
|
968
|
+
out.push(id);
|
|
969
|
+
}
|
|
970
|
+
return out;
|
|
971
|
+
}
|
|
972
|
+
/** Same records regardless of order — the backend stores them sorted. */
|
|
973
|
+
function sameSelection(a, b) {
|
|
974
|
+
if (a.length !== b.length)
|
|
975
|
+
return false;
|
|
976
|
+
const set = new Set(a);
|
|
977
|
+
return b.every((id) => set.has(id));
|
|
978
|
+
}
|
|
979
|
+
/**
|
|
980
|
+
* Replace the selection with the picker's result. Records already selected
|
|
981
|
+
* keep their place; new ones are appended in the order they were picked. In
|
|
982
|
+
* single mode only the last pick survives.
|
|
983
|
+
*/
|
|
984
|
+
function applySelectionPicks(state, picks, multiple) {
|
|
985
|
+
const wanted = positiveIds(picks.map((pick) => pick.id));
|
|
986
|
+
const chosen = multiple ? wanted : wanted.slice(-1);
|
|
987
|
+
const kept = state.ids.filter((id) => chosen.includes(id));
|
|
988
|
+
const added = chosen.filter((id) => !kept.includes(id));
|
|
989
|
+
const names = { ...state.names };
|
|
990
|
+
for (const pick of picks) {
|
|
991
|
+
if (added.includes(pick.id) && pick.name)
|
|
992
|
+
names[pick.id] = pick.name;
|
|
993
|
+
}
|
|
994
|
+
return { ...state, ids: [...kept, ...added], names };
|
|
995
|
+
}
|
|
996
|
+
function removeSelectedRecord(state, id) {
|
|
997
|
+
return { ...state, ids: state.ids.filter((entry) => entry !== id) };
|
|
998
|
+
}
|
|
999
|
+
/**
|
|
1000
|
+
* The control's value for a state.
|
|
1001
|
+
*
|
|
1002
|
+
* A changed selection is a mutation: the full replacement `entityIds`, the
|
|
1003
|
+
* version it was loaded at, and a `mutationId` that stays the same while the
|
|
1004
|
+
* content does (a retry of the same save) and changes with it. Nothing else is
|
|
1005
|
+
* sent — the backend discards rendered records and snapshots, and rejects any
|
|
1006
|
+
* other member.
|
|
1007
|
+
*
|
|
1008
|
+
* An unchanged selection is the value it arrived as, which the submission
|
|
1009
|
+
* leaves out: an omitted Selected list keeps its membership.
|
|
1010
|
+
*/
|
|
1011
|
+
function buildSelectionValue(next, newUuid) {
|
|
1012
|
+
const loaded = next.base?.entityIds ?? [];
|
|
1013
|
+
if (sameSelection(next.ids, positiveIds(loaded))) {
|
|
1014
|
+
return {
|
|
1015
|
+
state: { ...next, mutationId: null, mutationKey: null },
|
|
1016
|
+
value: next.base,
|
|
1017
|
+
};
|
|
1018
|
+
}
|
|
1019
|
+
const version = Number(next.base?.version ?? 0) || 0;
|
|
1020
|
+
const entityIds = [...next.ids];
|
|
1021
|
+
const mutationKey = JSON.stringify({
|
|
1022
|
+
version,
|
|
1023
|
+
entityIds: [...entityIds].sort((a, b) => a - b),
|
|
1024
|
+
});
|
|
1025
|
+
const mutationId = next.mutationKey === mutationKey && next.mutationId
|
|
1026
|
+
? next.mutationId
|
|
1027
|
+
: newUuid();
|
|
1028
|
+
return {
|
|
1029
|
+
state: { ...next, mutationId, mutationKey },
|
|
1030
|
+
value: { recordMode: 'Selected', version, mutationId, entityIds },
|
|
1031
|
+
};
|
|
1032
|
+
}
|
|
1033
|
+
|
|
1034
|
+
/**
|
|
1035
|
+
* Candidates per request. The backend takes 1–100 and requires `skip` to be a
|
|
1036
|
+
* multiple of `take`, so paging only ever adds whole pages.
|
|
1037
|
+
*/
|
|
1038
|
+
const PAGE_SIZE$1 = 25;
|
|
1039
|
+
/** The backend's limit on one list's selection. */
|
|
1040
|
+
const ENTITY_LIST_MAX_SELECTIONS = 100;
|
|
1041
|
+
/**
|
|
1042
|
+
* Picker of a Selected `EntityList` (`recordMode: "Selected"`), opened by
|
|
1043
|
+
* `mt-entity-list-field`.
|
|
1044
|
+
*
|
|
1045
|
+
* Candidates come from `GET forms/options/{propertyKey}` with the **parent's**
|
|
1046
|
+
* context: the backend resolves the source module and its eligibility filter
|
|
1047
|
+
* from the property's trusted configuration, so the caller never names the
|
|
1048
|
+
* source. Each candidate is only a key and a name — its field values are
|
|
1049
|
+
* rendered once the parent is saved.
|
|
1050
|
+
*
|
|
1051
|
+
* Closes with the chosen records as `SelectionPick[]`, or `null` on Cancel.
|
|
1052
|
+
*/
|
|
1053
|
+
class EntityListSelectionDialog {
|
|
1054
|
+
ref = inject(ModalRef);
|
|
1055
|
+
/** Exposes the shared modal content/footer classes to the template. */
|
|
1056
|
+
modal = inject(ModalService);
|
|
1057
|
+
http = inject(HttpClient);
|
|
1058
|
+
destroyRef = inject(DestroyRef);
|
|
1059
|
+
/** The EntityList property's key — the options route. */
|
|
1060
|
+
propertyKey = input('', ...(ngDevMode ? [{ debugName: "propertyKey" }] : /* istanbul ignore next */ []));
|
|
1061
|
+
/** The parent form's context, e.g. `Level:3/Module:22`. */
|
|
1062
|
+
contextKey = input('', ...(ngDevMode ? [{ debugName: "contextKey" }] : /* istanbul ignore next */ []));
|
|
1063
|
+
levelDataId = input(null, ...(ngDevMode ? [{ debugName: "levelDataId" }] : /* istanbul ignore next */ []));
|
|
1064
|
+
multiple = input(true, ...(ngDevMode ? [{ debugName: "multiple" }] : /* istanbul ignore next */ []));
|
|
1065
|
+
/** The records the field holds now. */
|
|
1066
|
+
selectedIds = input([], ...(ngDevMode ? [{ debugName: "selectedIds" }] : /* istanbul ignore next */ []));
|
|
1067
|
+
context = input(undefined, ...(ngDevMode ? [{ debugName: "context" }] : /* istanbul ignore next */ []));
|
|
1068
|
+
searchControl = new FormControl('', {
|
|
1069
|
+
nonNullable: true,
|
|
1070
|
+
});
|
|
1071
|
+
items = signal([], ...(ngDevMode ? [{ debugName: "items" }] : /* istanbul ignore next */ []));
|
|
1072
|
+
loading = signal(false, ...(ngDevMode ? [{ debugName: "loading" }] : /* istanbul ignore next */ []));
|
|
1073
|
+
hasMore = signal(false, ...(ngDevMode ? [{ debugName: "hasMore" }] : /* istanbul ignore next */ []));
|
|
1074
|
+
/** Translation key of the failure to show instead of the list, if any. */
|
|
1075
|
+
failureKey = signal(null, ...(ngDevMode ? [{ debugName: "failureKey" }] : /* istanbul ignore next */ []));
|
|
1076
|
+
/** Chosen records, in the order they were picked; id → name. */
|
|
1077
|
+
picked = signal(new Map(), ...(ngDevMode ? [{ debugName: "picked" }] : /* istanbul ignore next */ []));
|
|
1078
|
+
pickedCount = computed(() => this.picked().size, ...(ngDevMode ? [{ debugName: "pickedCount" }] : /* istanbul ignore next */ []));
|
|
1079
|
+
atLimit = computed(() => this.multiple() && this.pickedCount() >= ENTITY_LIST_MAX_SELECTIONS, ...(ngDevMode ? [{ debugName: "atLimit" }] : /* istanbul ignore next */ []));
|
|
1080
|
+
maxSelections = ENTITY_LIST_MAX_SELECTIONS;
|
|
1081
|
+
nextSkip = 0;
|
|
1082
|
+
request;
|
|
1083
|
+
ngOnInit() {
|
|
1084
|
+
this.picked.set(new Map(this.selectedIds().map((id) => [id, ''])));
|
|
1085
|
+
this.searchControl.valueChanges
|
|
1086
|
+
.pipe(debounceTime(300), map((value) => value.trim()), distinctUntilChanged(), takeUntilDestroyed(this.destroyRef))
|
|
1087
|
+
.subscribe(() => this.load(true));
|
|
1088
|
+
this.load(true);
|
|
1089
|
+
}
|
|
1090
|
+
isPicked(id) {
|
|
1091
|
+
return this.picked().has(id);
|
|
1092
|
+
}
|
|
1093
|
+
/**
|
|
1094
|
+
* Multiple mode toggles the record. Single mode replaces the choice, and
|
|
1095
|
+
* picking the chosen record again clears it.
|
|
1096
|
+
*/
|
|
1097
|
+
toggle(item) {
|
|
1098
|
+
const current = this.picked();
|
|
1099
|
+
if (current.has(item.id)) {
|
|
1100
|
+
const next = new Map(current);
|
|
1101
|
+
next.delete(item.id);
|
|
1102
|
+
this.picked.set(next);
|
|
1103
|
+
return;
|
|
1104
|
+
}
|
|
1105
|
+
if (!this.multiple()) {
|
|
1106
|
+
this.picked.set(new Map([[item.id, item.name]]));
|
|
1107
|
+
return;
|
|
1108
|
+
}
|
|
1109
|
+
if (this.atLimit())
|
|
1110
|
+
return;
|
|
1111
|
+
this.picked.set(new Map(current).set(item.id, item.name));
|
|
1112
|
+
}
|
|
1113
|
+
loadMore() {
|
|
1114
|
+
this.load(false);
|
|
1115
|
+
}
|
|
1116
|
+
onCancel() {
|
|
1117
|
+
this.ref.close(null);
|
|
1118
|
+
}
|
|
1119
|
+
onApply() {
|
|
1120
|
+
const names = new Map(this.items().map((item) => [item.id, item.name]));
|
|
1121
|
+
const picks = [...this.picked()].map(([id, name]) => ({
|
|
1122
|
+
id,
|
|
1123
|
+
name: name || names.get(id) || '',
|
|
1124
|
+
}));
|
|
1125
|
+
this.ref.close(picks);
|
|
1126
|
+
}
|
|
1127
|
+
/**
|
|
1128
|
+
* Load a page of candidates; `reset` starts over from the first page of the
|
|
1129
|
+
* current search.
|
|
1130
|
+
*
|
|
1131
|
+
* The first page of an unfiltered list also asks for the records already
|
|
1132
|
+
* selected (`includeSelected`), so they show as chosen even when they sit on
|
|
1133
|
+
* a later page. They are added beside the page, not counted in it.
|
|
1134
|
+
*/
|
|
1135
|
+
load(reset) {
|
|
1136
|
+
this.request?.unsubscribe();
|
|
1137
|
+
if (reset) {
|
|
1138
|
+
this.nextSkip = 0;
|
|
1139
|
+
this.items.set([]);
|
|
1140
|
+
this.hasMore.set(false);
|
|
1141
|
+
}
|
|
1142
|
+
this.failureKey.set(null);
|
|
1143
|
+
const propertyKey = this.propertyKey();
|
|
1144
|
+
const contextKey = this.contextKey();
|
|
1145
|
+
if (!propertyKey || !contextKey) {
|
|
1146
|
+
this.failureKey.set('components.entityListField.selectionUnavailable');
|
|
1147
|
+
return;
|
|
1148
|
+
}
|
|
1149
|
+
const search = this.searchControl.value.trim();
|
|
1150
|
+
const skip = this.nextSkip;
|
|
1151
|
+
let params = new HttpParams()
|
|
1152
|
+
.set('contextKey', contextKey)
|
|
1153
|
+
.set('skip', String(skip))
|
|
1154
|
+
.set('take', String(PAGE_SIZE$1));
|
|
1155
|
+
const levelDataId = this.levelDataId();
|
|
1156
|
+
if (levelDataId != null && levelDataId !== '') {
|
|
1157
|
+
params = params.set('levelDataId', String(levelDataId));
|
|
1158
|
+
}
|
|
1159
|
+
if (search) {
|
|
1160
|
+
params = params.set('search', search);
|
|
1161
|
+
}
|
|
1162
|
+
const selected = this.selectedIds();
|
|
1163
|
+
if (skip === 0 && !search && selected.length) {
|
|
1164
|
+
params = params.set('includeSelected', 'true');
|
|
1165
|
+
for (const id of selected) {
|
|
1166
|
+
params = params.append('selectedIds', String(id));
|
|
1167
|
+
}
|
|
1168
|
+
}
|
|
1169
|
+
this.loading.set(true);
|
|
1170
|
+
const context = this.context();
|
|
1171
|
+
this.request = this.http
|
|
1172
|
+
.get(`forms/options/${encodeURIComponent(propertyKey)}`, {
|
|
1173
|
+
params,
|
|
1174
|
+
// Failures are shown inside the dialog, not as a host toast.
|
|
1175
|
+
headers: { noMessage: 'true' },
|
|
1176
|
+
...(context ? { context } : {}),
|
|
1177
|
+
})
|
|
1178
|
+
.pipe(finalize(() => this.loading.set(false)), takeUntilDestroyed(this.destroyRef))
|
|
1179
|
+
.subscribe({
|
|
1180
|
+
next: (response) => this.applyPage(response, skip),
|
|
1181
|
+
error: (error) => this.failureKey.set(error?.error?.errors?.code === 'entity_list.target_read_denied'
|
|
1182
|
+
? 'components.entityListField.accessDenied'
|
|
1183
|
+
: 'components.entityListField.selectionLoadFailed'),
|
|
1184
|
+
});
|
|
1185
|
+
}
|
|
1186
|
+
applyPage(response, skip) {
|
|
1187
|
+
const page = [];
|
|
1188
|
+
for (const item of response?.data?.items ?? []) {
|
|
1189
|
+
const id = Number(item?.key);
|
|
1190
|
+
if (!Number.isInteger(id) || id <= 0)
|
|
1191
|
+
continue;
|
|
1192
|
+
page.push({ id, name: item.name?.trim() || `#${id}` });
|
|
1193
|
+
}
|
|
1194
|
+
const seen = new Set(this.items().map((item) => item.id));
|
|
1195
|
+
this.items.set([
|
|
1196
|
+
...this.items(),
|
|
1197
|
+
...page.filter((item) => !seen.has(item.id)),
|
|
1198
|
+
]);
|
|
1199
|
+
this.hasMore.set(!!response?.data?.hasMore);
|
|
1200
|
+
this.nextSkip = skip + PAGE_SIZE$1;
|
|
1201
|
+
}
|
|
1202
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: EntityListSelectionDialog, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1203
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.8", type: EntityListSelectionDialog, isStandalone: true, selector: "mt-entity-list-selection-dialog", inputs: { propertyKey: { classPropertyName: "propertyKey", publicName: "propertyKey", isSignal: true, isRequired: false, transformFunction: null }, contextKey: { classPropertyName: "contextKey", publicName: "contextKey", isSignal: true, isRequired: false, transformFunction: null }, levelDataId: { classPropertyName: "levelDataId", publicName: "levelDataId", isSignal: true, isRequired: false, transformFunction: null }, multiple: { classPropertyName: "multiple", publicName: "multiple", isSignal: true, isRequired: false, transformFunction: null }, selectedIds: { classPropertyName: "selectedIds", publicName: "selectedIds", isSignal: true, isRequired: false, transformFunction: null }, context: { classPropertyName: "context", publicName: "context", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: "<div [class]=\"modal.contentClass + ' flex max-h-[70vh] flex-col gap-3 p-4'\">\n <mt-text-field\n [formControl]=\"searchControl\"\n icon=\"general.search-md\"\n [placeholder]=\"'components.entityListField.searchRecords' | transloco\"\n />\n\n @if (multiple()) {\n <p\n class=\"text-xs\"\n [class.text-muted-color]=\"!atLimit()\"\n [class.text-amber-700]=\"atLimit()\"\n >\n {{\n (atLimit()\n ? \"components.entityListField.selectionLimit\"\n : \"components.entityListField.selectedCount\"\n ) | transloco: { count: pickedCount(), max: maxSelections }\n }}\n </p>\n }\n\n @if (failureKey(); as failure) {\n <div\n class=\"rounded-md border border-red-200 bg-red-50 p-3 text-sm text-red-700\"\n >\n {{ failure | transloco }}\n </div>\n } @else {\n <div\n class=\"flex min-h-40 flex-col gap-1 overflow-y-auto\"\n role=\"listbox\"\n [attr.aria-multiselectable]=\"multiple()\"\n >\n @for (item of items(); track item.id) {\n @let chosen = isPicked(item.id);\n <button\n type=\"button\"\n role=\"option\"\n [attr.aria-selected]=\"chosen\"\n [disabled]=\"!chosen && atLimit()\"\n class=\"flex w-full items-center gap-3 rounded-md border px-3 py-2 text-start text-sm transition-colors hover:border-primary disabled:cursor-not-allowed disabled:opacity-50\"\n [class.border-primary]=\"chosen\"\n [class.bg-primary-50]=\"chosen\"\n [class.border-surface]=\"!chosen\"\n (click)=\"toggle(item)\"\n >\n <span\n class=\"flex size-4 shrink-0 items-center justify-center border\"\n [class.rounded-sm]=\"multiple()\"\n [class.rounded-full]=\"!multiple()\"\n [class.border-primary]=\"chosen\"\n [class.bg-primary]=\"chosen\"\n [class.text-primary-contrast]=\"chosen\"\n [class.border-surface-400]=\"!chosen\"\n >\n @if (chosen) {\n <mt-icon icon=\"general.check\" class=\"text-[0.625rem]\" />\n }\n </span>\n <span class=\"min-w-0 flex-1 truncate text-color\">{{\n item.name\n }}</span>\n </button>\n }\n\n @if (loading()) {\n <p-skeleton width=\"100%\" height=\"2.5rem\" borderRadius=\"0.375rem\" />\n <p-skeleton width=\"100%\" height=\"2.5rem\" borderRadius=\"0.375rem\" />\n <p-skeleton width=\"100%\" height=\"2.5rem\" borderRadius=\"0.375rem\" />\n } @else if (!items().length) {\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.noCandidates\" | transloco }}\n </div>\n }\n </div>\n\n @if (hasMore() && !loading()) {\n <div class=\"flex justify-center\">\n <mt-button\n [label]=\"'components.entityListField.loadMore' | transloco\"\n variant=\"text\"\n size=\"small\"\n (onClick)=\"loadMore()\"\n />\n </div>\n }\n }\n</div>\n\n<div [class]=\"modal.footerClass\">\n <mt-button\n [label]=\"'components.entityListField.cancel' | transloco\"\n severity=\"secondary\"\n variant=\"outlined\"\n (onClick)=\"onCancel()\"\n />\n <mt-button\n [label]=\"'components.entityListField.apply' | transloco\"\n severity=\"primary\"\n [disabled]=\"!!failureKey()\"\n (onClick)=\"onApply()\"\n />\n</div>\n", dependencies: [{ kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "component", type: Skeleton, selector: "p-skeleton", inputs: ["styleClass", "shape", "animation", "borderRadius", "size", "width", "height"] }, { kind: "component", type: Icon, selector: "mt-icon", inputs: ["icon"] }, { 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: "component", type: TextField, selector: "mt-text-field", inputs: ["field", "hint", "label", "placeholder", "class", "type", "readonly", "pInputs", "required", "maxLength", "icon", "iconPosition"] }, { kind: "pipe", type: TranslocoPipe, name: "transloco" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
1204
|
+
}
|
|
1205
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: EntityListSelectionDialog, decorators: [{
|
|
1206
|
+
type: Component,
|
|
1207
|
+
args: [{ selector: 'mt-entity-list-selection-dialog', standalone: true, imports: [
|
|
1208
|
+
ReactiveFormsModule,
|
|
1209
|
+
TranslocoPipe,
|
|
1210
|
+
Skeleton,
|
|
1211
|
+
Icon,
|
|
1212
|
+
Button,
|
|
1213
|
+
TextField,
|
|
1214
|
+
], changeDetection: ChangeDetectionStrategy.OnPush, template: "<div [class]=\"modal.contentClass + ' flex max-h-[70vh] flex-col gap-3 p-4'\">\n <mt-text-field\n [formControl]=\"searchControl\"\n icon=\"general.search-md\"\n [placeholder]=\"'components.entityListField.searchRecords' | transloco\"\n />\n\n @if (multiple()) {\n <p\n class=\"text-xs\"\n [class.text-muted-color]=\"!atLimit()\"\n [class.text-amber-700]=\"atLimit()\"\n >\n {{\n (atLimit()\n ? \"components.entityListField.selectionLimit\"\n : \"components.entityListField.selectedCount\"\n ) | transloco: { count: pickedCount(), max: maxSelections }\n }}\n </p>\n }\n\n @if (failureKey(); as failure) {\n <div\n class=\"rounded-md border border-red-200 bg-red-50 p-3 text-sm text-red-700\"\n >\n {{ failure | transloco }}\n </div>\n } @else {\n <div\n class=\"flex min-h-40 flex-col gap-1 overflow-y-auto\"\n role=\"listbox\"\n [attr.aria-multiselectable]=\"multiple()\"\n >\n @for (item of items(); track item.id) {\n @let chosen = isPicked(item.id);\n <button\n type=\"button\"\n role=\"option\"\n [attr.aria-selected]=\"chosen\"\n [disabled]=\"!chosen && atLimit()\"\n class=\"flex w-full items-center gap-3 rounded-md border px-3 py-2 text-start text-sm transition-colors hover:border-primary disabled:cursor-not-allowed disabled:opacity-50\"\n [class.border-primary]=\"chosen\"\n [class.bg-primary-50]=\"chosen\"\n [class.border-surface]=\"!chosen\"\n (click)=\"toggle(item)\"\n >\n <span\n class=\"flex size-4 shrink-0 items-center justify-center border\"\n [class.rounded-sm]=\"multiple()\"\n [class.rounded-full]=\"!multiple()\"\n [class.border-primary]=\"chosen\"\n [class.bg-primary]=\"chosen\"\n [class.text-primary-contrast]=\"chosen\"\n [class.border-surface-400]=\"!chosen\"\n >\n @if (chosen) {\n <mt-icon icon=\"general.check\" class=\"text-[0.625rem]\" />\n }\n </span>\n <span class=\"min-w-0 flex-1 truncate text-color\">{{\n item.name\n }}</span>\n </button>\n }\n\n @if (loading()) {\n <p-skeleton width=\"100%\" height=\"2.5rem\" borderRadius=\"0.375rem\" />\n <p-skeleton width=\"100%\" height=\"2.5rem\" borderRadius=\"0.375rem\" />\n <p-skeleton width=\"100%\" height=\"2.5rem\" borderRadius=\"0.375rem\" />\n } @else if (!items().length) {\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.noCandidates\" | transloco }}\n </div>\n }\n </div>\n\n @if (hasMore() && !loading()) {\n <div class=\"flex justify-center\">\n <mt-button\n [label]=\"'components.entityListField.loadMore' | transloco\"\n variant=\"text\"\n size=\"small\"\n (onClick)=\"loadMore()\"\n />\n </div>\n }\n }\n</div>\n\n<div [class]=\"modal.footerClass\">\n <mt-button\n [label]=\"'components.entityListField.cancel' | transloco\"\n severity=\"secondary\"\n variant=\"outlined\"\n (onClick)=\"onCancel()\"\n />\n <mt-button\n [label]=\"'components.entityListField.apply' | transloco\"\n severity=\"primary\"\n [disabled]=\"!!failureKey()\"\n (onClick)=\"onApply()\"\n />\n</div>\n" }]
|
|
1215
|
+
}], propDecorators: { propertyKey: [{ type: i0.Input, args: [{ isSignal: true, alias: "propertyKey", required: false }] }], contextKey: [{ type: i0.Input, args: [{ isSignal: true, alias: "contextKey", required: false }] }], levelDataId: [{ type: i0.Input, args: [{ isSignal: true, alias: "levelDataId", required: false }] }], multiple: [{ type: i0.Input, args: [{ isSignal: true, alias: "multiple", required: false }] }], selectedIds: [{ type: i0.Input, args: [{ isSignal: true, alias: "selectedIds", required: false }] }], context: [{ type: i0.Input, args: [{ isSignal: true, alias: "context", required: false }] }] } });
|
|
1216
|
+
|
|
952
1217
|
function resolveMetadataFailure(status) {
|
|
953
1218
|
if (status === 403)
|
|
954
1219
|
return 'forbidden';
|
|
@@ -1005,6 +1270,12 @@ const ROW_LOCAL_CREATED_KEY = '__localCreated';
|
|
|
1005
1270
|
* and a `WeakMap` lets it go with the value.
|
|
1006
1271
|
*/
|
|
1007
1272
|
const LOCAL_EDITOR_STATES = new WeakMap();
|
|
1273
|
+
/**
|
|
1274
|
+
* The editing state behind each Selected value this field emitted, for the
|
|
1275
|
+
* same reason as `LOCAL_EDITOR_STATES`: a mutation is only ids, and the names
|
|
1276
|
+
* of records picked in this session live nowhere else.
|
|
1277
|
+
*/
|
|
1278
|
+
const SELECTION_EDITOR_STATES = new WeakMap();
|
|
1008
1279
|
/**
|
|
1009
1280
|
* Badge colour per staged operation, as a hex: `mt-entity-status` derives its
|
|
1010
1281
|
* own 12%-alpha background by slicing the value's `color`, so a Tailwind class
|
|
@@ -1026,6 +1297,11 @@ class EntityListField {
|
|
|
1026
1297
|
* effective configuration.
|
|
1027
1298
|
*/
|
|
1028
1299
|
propertyId = input(null, ...(ngDevMode ? [{ debugName: "propertyId" }] : /* istanbul ignore next */ []));
|
|
1300
|
+
/**
|
|
1301
|
+
* EntityList property key. A Selected list's picker loads its candidates
|
|
1302
|
+
* from `forms/options/{propertyKey}`; no other mode reads it.
|
|
1303
|
+
*/
|
|
1304
|
+
propertyKey = input('', ...(ngDevMode ? [{ debugName: "propertyKey" }] : /* istanbul ignore next */ []));
|
|
1029
1305
|
/**
|
|
1030
1306
|
* Stored property configuration (sourceType, moduleId, access, readFields …).
|
|
1031
1307
|
*
|
|
@@ -1525,6 +1801,189 @@ class EntityListField {
|
|
|
1525
1801
|
}
|
|
1526
1802
|
return actions;
|
|
1527
1803
|
}, ...(ngDevMode ? [{ debugName: "localRowActions" }] : /* istanbul ignore next */ []));
|
|
1804
|
+
// ============================================================================
|
|
1805
|
+
// Selected records (`recordMode: "Selected"`) — source records the user picked
|
|
1806
|
+
// ============================================================================
|
|
1807
|
+
/** Loaded selection plus this session's picks; see `SelectionEditorState`. */
|
|
1808
|
+
selectionState = signal(createSelectionEditorState(null), ...(ngDevMode ? [{ debugName: "selectionState" }] : /* istanbul ignore next */ []));
|
|
1809
|
+
/** The bound value was a Selected document, whatever the metadata says yet. */
|
|
1810
|
+
selectionValueSeen = signal(false, ...(ngDevMode ? [{ debugName: "selectionValueSeen" }] : /* istanbul ignore next */ []));
|
|
1811
|
+
/** The last Selected value emitted, so its echo does not reset the picks. */
|
|
1812
|
+
lastSelectionEmit = null;
|
|
1813
|
+
/**
|
|
1814
|
+
* The list holds only the records the user picked. It never falls back to
|
|
1815
|
+
* every related record: an empty selection is empty. Known from the
|
|
1816
|
+
* metadata, or earlier from the value itself.
|
|
1817
|
+
*/
|
|
1818
|
+
selectionMode = computed(() => this.metadata()?.recordMode === 'Selected' || this.selectionValueSeen(), ...(ngDevMode ? [{ debugName: "selectionMode" }] : /* istanbul ignore next */ []));
|
|
1819
|
+
/** Render once the metadata answered: it is the access boundary. */
|
|
1820
|
+
selectionReady = computed(() => this.selectionMode() && !!this.metadata(), ...(ngDevMode ? [{ debugName: "selectionReady" }] : /* istanbul ignore next */ []));
|
|
1821
|
+
selectionMultiple = computed(() => this.metadata()?.selectionMode !== 'Single', ...(ngDevMode ? [{ debugName: "selectionMultiple" }] : /* istanbul ignore next */ []));
|
|
1822
|
+
/**
|
|
1823
|
+
* The picker's `contextKey`: the context of the form that owns the property
|
|
1824
|
+
* — never the source module, which the backend resolves from the property's
|
|
1825
|
+
* own configuration.
|
|
1826
|
+
*/
|
|
1827
|
+
selectionContextKey = computed(() => {
|
|
1828
|
+
const levelId = this.levelId();
|
|
1829
|
+
if (levelId == null)
|
|
1830
|
+
return null;
|
|
1831
|
+
const moduleId = this.runtimeContext()?.moduleId;
|
|
1832
|
+
return moduleId == null || moduleId === ''
|
|
1833
|
+
? `Level:${levelId}`
|
|
1834
|
+
: `Level:${levelId}/Module:${moduleId}`;
|
|
1835
|
+
}, ...(ngDevMode ? [{ debugName: "selectionContextKey" }] : /* istanbul ignore next */ []));
|
|
1836
|
+
/**
|
|
1837
|
+
* Whether the user may change which records are selected. That is the
|
|
1838
|
+
* form's call — `readonly`, from the field's `isWrite` — and not the
|
|
1839
|
+
* metadata's `access` or its `allow*` switches: those describe the source
|
|
1840
|
+
* records, which selecting never writes.
|
|
1841
|
+
*/
|
|
1842
|
+
selectionWritable = computed(() => this.selectionReady() &&
|
|
1843
|
+
!this.readonly() &&
|
|
1844
|
+
!this.disabled() &&
|
|
1845
|
+
!!this.propertyKey() &&
|
|
1846
|
+
!!this.selectionContextKey(), ...(ngDevMode ? [{ debugName: "selectionWritable" }] : /* istanbul ignore next */ []));
|
|
1847
|
+
/**
|
|
1848
|
+
* The selected records as table rows, in selection order.
|
|
1849
|
+
*
|
|
1850
|
+
* A saved record renders from the backend's `records`, cell by cell against
|
|
1851
|
+
* the metadata columns — the same cells a related list shows. A record
|
|
1852
|
+
* picked in this session has no rendered values until the parent is saved,
|
|
1853
|
+
* so it shows its name in the first column. A record in `unavailableIds` was
|
|
1854
|
+
* deleted or is no longer visible: the backend keeps it selected but
|
|
1855
|
+
* withholds its values, and the row says so, so the user can remove it.
|
|
1856
|
+
*/
|
|
1857
|
+
selectionRows = computed(() => {
|
|
1858
|
+
const state = this.selectionState();
|
|
1859
|
+
const columns = this.columns();
|
|
1860
|
+
const properties = this.propertyByKey();
|
|
1861
|
+
const records = new Map((state.base?.records ?? []).map((record) => [record.entityId, record]));
|
|
1862
|
+
const unavailable = new Set(state.base?.unavailableIds ?? []);
|
|
1863
|
+
return state.ids.map((id) => {
|
|
1864
|
+
const row = {
|
|
1865
|
+
Id: id,
|
|
1866
|
+
[ROW_ID_KEY]: `entity-${id}`,
|
|
1867
|
+
[ROW_ENTITY_ID_KEY]: id,
|
|
1868
|
+
};
|
|
1869
|
+
const record = records.get(id);
|
|
1870
|
+
if (record) {
|
|
1871
|
+
const values = new Map((record.values ?? []).map((item) => [item.propertyKey, item]));
|
|
1872
|
+
for (const column of columns) {
|
|
1873
|
+
const propertyKey = column.propertyKey ?? column.key;
|
|
1874
|
+
const item = values.get(propertyKey) ?? values.get(column.key);
|
|
1875
|
+
row[column.key] = this.toEntityData(column, item ? { raw: item.rawValue, value: item.value } : undefined, properties.get(propertyKey), id);
|
|
1876
|
+
}
|
|
1877
|
+
return row;
|
|
1878
|
+
}
|
|
1879
|
+
const label = unavailable.has(id)
|
|
1880
|
+
? this.transloco.translate('components.entityListField.unavailableRecord', { id }, this.lang())
|
|
1881
|
+
: state.names[id] || `#${id}`;
|
|
1882
|
+
columns.forEach((column, index) => {
|
|
1883
|
+
row[column.key] = {
|
|
1884
|
+
key: column.key,
|
|
1885
|
+
name: column.label,
|
|
1886
|
+
viewType: 'Text',
|
|
1887
|
+
value: index === 0 ? label : '',
|
|
1888
|
+
};
|
|
1889
|
+
});
|
|
1890
|
+
return row;
|
|
1891
|
+
});
|
|
1892
|
+
}, ...(ngDevMode ? [{ debugName: "selectionRows" }] : /* istanbul ignore next */ []));
|
|
1893
|
+
selectionRowActions = computed(() => {
|
|
1894
|
+
this.lang();
|
|
1895
|
+
if (!this.selectionWritable())
|
|
1896
|
+
return [];
|
|
1897
|
+
return [
|
|
1898
|
+
{
|
|
1899
|
+
icon: 'general.x-close',
|
|
1900
|
+
tooltip: this.transloco.translate('components.entityListField.unselect'),
|
|
1901
|
+
color: 'danger',
|
|
1902
|
+
action: (row) => this.emitSelection(removeSelectedRecord(this.selectionState(), Number(row[ROW_ENTITY_ID_KEY]))),
|
|
1903
|
+
},
|
|
1904
|
+
];
|
|
1905
|
+
}, ...(ngDevMode ? [{ debugName: "selectionRowActions" }] : /* istanbul ignore next */ []));
|
|
1906
|
+
/**
|
|
1907
|
+
* A required Selected list needs a record. An emptied selection is an
|
|
1908
|
+
* object — a mutation with no ids — so `Validators.required` passes it and
|
|
1909
|
+
* only the backend would object (`entity_list.selection_required`).
|
|
1910
|
+
*/
|
|
1911
|
+
selectionRequiredValidator = (control) => {
|
|
1912
|
+
if (!this.required())
|
|
1913
|
+
return null;
|
|
1914
|
+
const value = control.value;
|
|
1915
|
+
if (isEntityListSelectionDocument(value)) {
|
|
1916
|
+
return value.entityIds?.length ? null : { required: true };
|
|
1917
|
+
}
|
|
1918
|
+
return value == null && this.selectionMode() ? { required: true } : null;
|
|
1919
|
+
};
|
|
1920
|
+
openSelectionDialog() {
|
|
1921
|
+
if (!this.selectionWritable())
|
|
1922
|
+
return;
|
|
1923
|
+
const ref = this.modal.openModal(EntityListSelectionDialog, 'dialog', {
|
|
1924
|
+
header: this.transloco.translate('components.entityListField.selectRecords'),
|
|
1925
|
+
styleClass: '!w-[36rem] max-w-[96vw]',
|
|
1926
|
+
dismissableMask: true,
|
|
1927
|
+
inputValues: {
|
|
1928
|
+
propertyKey: this.propertyKey(),
|
|
1929
|
+
contextKey: this.selectionContextKey(),
|
|
1930
|
+
levelDataId: this.levelDataId(),
|
|
1931
|
+
multiple: this.selectionMultiple(),
|
|
1932
|
+
selectedIds: this.selectionState().ids,
|
|
1933
|
+
context: this.context(),
|
|
1934
|
+
},
|
|
1935
|
+
});
|
|
1936
|
+
ref.onClose.pipe(take(1)).subscribe((result) => {
|
|
1937
|
+
if (!Array.isArray(result))
|
|
1938
|
+
return;
|
|
1939
|
+
this.emitSelection(applySelectionPicks(this.selectionState(), result, this.selectionMultiple()));
|
|
1940
|
+
});
|
|
1941
|
+
}
|
|
1942
|
+
/**
|
|
1943
|
+
* Publish the selection as the control's value: a mutation when it differs
|
|
1944
|
+
* from what was loaded, else the loaded value, which the submission leaves
|
|
1945
|
+
* out. See `buildSelectionValue`.
|
|
1946
|
+
*/
|
|
1947
|
+
emitSelection(next) {
|
|
1948
|
+
const { state, value } = buildSelectionValue(next, newLocalUuid);
|
|
1949
|
+
this.selectionState.set(state);
|
|
1950
|
+
if (value)
|
|
1951
|
+
SELECTION_EDITOR_STATES.set(value, state);
|
|
1952
|
+
this.lastSelectionEmit = value;
|
|
1953
|
+
this.onModelChange(value);
|
|
1954
|
+
this.onTouched();
|
|
1955
|
+
}
|
|
1956
|
+
/**
|
|
1957
|
+
* Take a Selected document, and say whether it was one.
|
|
1958
|
+
*
|
|
1959
|
+
* Our own emission echoed back keeps the session; a value some instance of
|
|
1960
|
+
* this field emitted restores that instance's state (see
|
|
1961
|
+
* `SELECTION_EDITOR_STATES`); anything else starts a session on it. That is
|
|
1962
|
+
* the projection `process-form-load` returns, the stored document a preview
|
|
1963
|
+
* gets from the fetch endpoints, or a mutation the form already held — which
|
|
1964
|
+
* stays the control's value until the user changes the selection.
|
|
1965
|
+
*
|
|
1966
|
+
* An empty value resets the session too and still falls through, since
|
|
1967
|
+
* which mode the list uses may not be known yet.
|
|
1968
|
+
*/
|
|
1969
|
+
writeSelectionValue(value) {
|
|
1970
|
+
const incoming = this.coerceStoredValue(value);
|
|
1971
|
+
if (!isEntityListSelectionDocument(incoming)) {
|
|
1972
|
+
if (incoming == null) {
|
|
1973
|
+
this.lastSelectionEmit = null;
|
|
1974
|
+
this.selectionState.set(createSelectionEditorState(null));
|
|
1975
|
+
}
|
|
1976
|
+
return false;
|
|
1977
|
+
}
|
|
1978
|
+
this.selectionValueSeen.set(true);
|
|
1979
|
+
if (incoming === this.lastSelectionEmit)
|
|
1980
|
+
return true;
|
|
1981
|
+
this.lastSelectionEmit = null;
|
|
1982
|
+
const restored = SELECTION_EDITOR_STATES.get(incoming);
|
|
1983
|
+
this.selectionState.set(restored ??
|
|
1984
|
+
createSelectionEditorState(incoming));
|
|
1985
|
+
return true;
|
|
1986
|
+
}
|
|
1528
1987
|
/** Enough context to ask the backend what this field should render. */
|
|
1529
1988
|
hasRequiredContext = computed(() => this.propertyKeyId() > 0 && Number(this.levelId()) > 0, ...(ngDevMode ? [{ debugName: "hasRequiredContext" }] : /* istanbul ignore next */ []));
|
|
1530
1989
|
/**
|
|
@@ -1600,6 +2059,23 @@ class EntityListField {
|
|
|
1600
2059
|
const levelDataId = this.levelDataId();
|
|
1601
2060
|
untracked(() => this.loadTable(propertyId, levelId, levelDataId));
|
|
1602
2061
|
});
|
|
2062
|
+
// The control exists once the form directive has resolved it, which is
|
|
2063
|
+
// after construction. The validator reads `required` and the mode itself,
|
|
2064
|
+
// so it is added once; the control is re-validated when either changes —
|
|
2065
|
+
// the mode is only known once the metadata or the value arrives.
|
|
2066
|
+
effect(() => {
|
|
2067
|
+
this.selectionMode();
|
|
2068
|
+
this.required();
|
|
2069
|
+
const control = this.ngControl?.control;
|
|
2070
|
+
if (!control)
|
|
2071
|
+
return;
|
|
2072
|
+
untracked(() => {
|
|
2073
|
+
if (!control.hasValidator(this.selectionRequiredValidator)) {
|
|
2074
|
+
control.addValidators(this.selectionRequiredValidator);
|
|
2075
|
+
}
|
|
2076
|
+
control.updateValueAndValidity({ emitEvent: false });
|
|
2077
|
+
});
|
|
2078
|
+
});
|
|
1603
2079
|
// Form-less hosts hand the value over as an input instead. `writeValue` is
|
|
1604
2080
|
// the one entry point that resets the pending rows and deletions with it,
|
|
1605
2081
|
// so it is reused rather than re-implemented.
|
|
@@ -1620,6 +2096,8 @@ class EntityListField {
|
|
|
1620
2096
|
writeValue(value) {
|
|
1621
2097
|
if (this.writeLocalValue(value))
|
|
1622
2098
|
return;
|
|
2099
|
+
if (this.writeSelectionValue(value))
|
|
2100
|
+
return;
|
|
1623
2101
|
const incoming = this.coerceStoredValue(value);
|
|
1624
2102
|
// Ignore the echo of our own emission (DynamicForm re-writes the model on
|
|
1625
2103
|
// every value change) so pending edits/deletions are not reset.
|
|
@@ -1647,9 +2125,10 @@ class EntityListField {
|
|
|
1647
2125
|
* - A value some instance of this field emitted restores that instance's
|
|
1648
2126
|
* state — see `LOCAL_EDITOR_STATES`.
|
|
1649
2127
|
* - A document the backend sent starts a fresh session on it: the projection
|
|
1650
|
-
* `process-form-load`
|
|
1651
|
-
*
|
|
1652
|
-
* null`, cells unrendered) — the schema then
|
|
2128
|
+
* `process-form-load` and the fetch endpoints return (its `schema` set,
|
|
2129
|
+
* cells rendered), or the stored document an older backend's fetch
|
|
2130
|
+
* endpoints returned (`schema: null`, cells unrendered) — the schema then
|
|
2131
|
+
* comes from the metadata.
|
|
1653
2132
|
* Every backend document carries the `schema` member, null or not; a
|
|
1654
2133
|
* mutation never does. So a mutation nobody here emitted has no rows to
|
|
1655
2134
|
* rebuild the table from and is left as the control's value, untouched
|
|
@@ -2086,9 +2565,9 @@ class EntityListField {
|
|
|
2086
2565
|
}
|
|
2087
2566
|
/**
|
|
2088
2567
|
* A loaded cell: the backend's rendered `value` beside its `rawValue`. A
|
|
2089
|
-
* stored document
|
|
2090
|
-
* raw one is shaped the way a locally set cell would
|
|
2091
|
-
* renders as a user, though only as its id
|
|
2568
|
+
* stored document (what an older backend's fetch endpoints returned) has no
|
|
2569
|
+
* rendered values, so the raw one is shaped the way a locally set cell would
|
|
2570
|
+
* be — a user id still renders as a user, though only as its id.
|
|
2092
2571
|
*/
|
|
2093
2572
|
buildLocalLoadedCell(column, cell, configuration) {
|
|
2094
2573
|
const value = cell?.value != null
|
|
@@ -2452,6 +2931,13 @@ class EntityListField {
|
|
|
2452
2931
|
return;
|
|
2453
2932
|
}
|
|
2454
2933
|
this.columns.set(this.buildColumns(metadata));
|
|
2934
|
+
// A Selected list's rows are the records in its value. Fetching the source
|
|
2935
|
+
// module would list every related record, which is exactly what this mode
|
|
2936
|
+
// is not.
|
|
2937
|
+
if (this.selectionMode()) {
|
|
2938
|
+
this.loading.set(false);
|
|
2939
|
+
return;
|
|
2940
|
+
}
|
|
2455
2941
|
if (!this.moduleBacked() ||
|
|
2456
2942
|
!this.canRead() ||
|
|
2457
2943
|
levelDataId == null ||
|
|
@@ -2623,7 +3109,7 @@ class EntityListField {
|
|
|
2623
3109
|
};
|
|
2624
3110
|
}
|
|
2625
3111
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: EntityListField, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2626
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.8", type: EntityListField, isStandalone: true, selector: "mt-entity-list-field", inputs: { label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, readonly: { classPropertyName: "readonly", publicName: "readonly", isSignal: true, isRequired: false, transformFunction: null }, required: { classPropertyName: "required", publicName: "required", isSignal: true, isRequired: false, transformFunction: null }, propertyId: { classPropertyName: "propertyId", publicName: "propertyId", isSignal: true, isRequired: false, transformFunction: null }, configuration: { classPropertyName: "configuration", publicName: "configuration", isSignal: true, isRequired: false, transformFunction: null }, runtimeContext: { classPropertyName: "runtimeContext", publicName: "runtimeContext", isSignal: true, isRequired: false, transformFunction: null }, pendingSubmission: { classPropertyName: "pendingSubmission", publicName: "pendingSubmission", isSignal: true, isRequired: false, transformFunction: null }, lookups: { classPropertyName: "lookups", publicName: "lookups", isSignal: true, isRequired: false, transformFunction: null }, context: { classPropertyName: "context", publicName: "context", isSignal: true, isRequired: false, transformFunction: null }, initialValue: { classPropertyName: "initialValue", publicName: "initialValue", isSignal: true, isRequired: false, transformFunction: null } }, host: { classAttribute: "grid gap-1" }, providers: [EntityRuntimeContextStore], ngImport: i0, template: "<div class=\"flex flex-col gap-2\">\n @if (label()) {\n <label class=\"font-medium text-color\">\n {{ label() }}\n @if (required()) {\n <span class=\"text-red-500\">*</span>\n }\n </label>\n }\n\n @if (errorMessage(); as err) {\n <p-message severity=\"error\" [text]=\"err\" styleClass=\"w-full\" />\n } @else if (noticeKey(); as notice) {\n <div\n class=\"rounded-md border border-dashed border-surface-300 bg-surface-50 p-3 text-sm text-muted-color\"\n >\n {{ notice | transloco }}\n </div>\n } @else if (localReady()) {\n <!--\n A Local list: rows owned by this record, staged into its own submission.\n Add / edit / delete / drag follow the Local operation switches.\n -->\n @if (localCanCreate()) {\n <div class=\"flex justify-end\">\n <mt-button\n [label]=\"'components.entityListField.add' | transloco\"\n icon=\"general.plus\"\n size=\"small\"\n [disabled]=\"disabled()\"\n (onClick)=\"openLocalRowDialog()\"\n />\n </div>\n }\n @if (localTableRows().length || localCanCreate()) {\n <mt-table\n [noCard]=\"true\"\n [data]=\"localTableRows()\"\n [columns]=\"localColumns()\"\n [rowActions]=\"localRowActions()\"\n [reorderableRows]=\"localCanReorder()\"\n (rowReorder)=\"onLocalReorder($event)\"\n dataKey=\"Id\"\n />\n } @else {\n <div\n class=\"rounded-md border border-dashed border-surface-300 bg-surface-50 p-3 text-sm text-muted-color\"\n >\n {{ \"components.entityListField.noLocalRows\" | transloco }}\n </div>\n }\n } @else if (canWrite()) {\n <div class=\"flex justify-end\">\n <mt-button\n [label]=\"'components.entityListField.add' | transloco\"\n icon=\"general.plus\"\n size=\"small\"\n [disabled]=\"disabled()\"\n (onClick)=\"openAddDialog()\"\n />\n </div>\n <mt-table\n [noCard]=\"true\"\n [data]=\"displayRows()\"\n [columns]=\"tableColumns()\"\n [rowActions]=\"writeRowActions()\"\n dataKey=\"Id\"\n [loading]=\"loading()\"\n />\n } @else if (loading() && !hasRows()) {\n <div class=\"flex flex-col gap-2\">\n <p-skeleton width=\"100%\" height=\"3rem\" borderRadius=\"0.375rem\" />\n <p-skeleton width=\"100%\" height=\"3rem\" borderRadius=\"0.375rem\" />\n </div>\n } @else if (!hasRows()) {\n <div\n class=\"rounded-md border border-dashed border-surface-300 bg-surface-50 p-3 text-sm text-muted-color\"\n >\n {{ \"components.entityListField.noRelatedItems\" | transloco }}\n </div>\n } @else {\n <mt-table\n [noCard]=\"true\"\n [data]=\"displayRows()\"\n [columns]=\"tableColumns()\"\n dataKey=\"Id\"\n [loading]=\"loading()\"\n />\n }\n\n @if (ngControl?.control) {\n <mt-field-validation\n [control]=\"ngControl?.control!\"\n [touched]=\"ngControl?.touched ?? false\"\n />\n }\n</div>\n", styles: [":host{display:block}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "component", type: FieldValidation, selector: "mt-field-validation", inputs: ["control", "touched", "messageId"] }, { kind: "component", type: Skeleton, selector: "p-skeleton", inputs: ["styleClass", "shape", "animation", "borderRadius", "size", "width", "height"] }, { kind: "component", type: Message, selector: "p-message", inputs: ["severity", "text", "escape", "style", "styleClass", "closable", "icon", "closeIcon", "life", "showTransitionOptions", "hideTransitionOptions", "size", "variant", "motionOptions"], outputs: ["onClose"] }, { kind: "component", type: Table, selector: "mt-table", inputs: ["filters", "data", "columns", "rowActions", "size", "showGridlines", "stripedRows", "selectableRows", "clickableRows", "generalSearch", "lazyLocalSearch", "showFilters", "filterMode", "loading", "updating", "lazy", "lazyLocalSort", "lazyTotalRecords", "reorderableColumns", "reorderableRows", "dataKey", "storageKey", "storageMode", "persistStateExclude", "exportable", "printable", "groupable", "groupCountMap", "cellClickFilter", "freezeActions", "virtualScroll", "virtualScrollItemSize", "scrollHeight", "printTitle", "exportFilename", "actionShape", "rowActionsLoadingFn", "tableLayout", "noCard", "tabs", "tabsOptionLabel", "tabsOptionValue", "activeTab", "actions", "captionStartTemplate", "captionEndTemplate", "emptyTitle", "emptyDescription", "emptyActionLabel", "emptyActionIcon", "paginatorPosition", "alwaysShowPaginator", "rowsPerPageOptions", "pageSize", "currentPage", "first", "filterTerm", "groupBy", "sortField", "sortDirection"], outputs: ["selectionChange", "cellChange", "lazyLoad", "columnReorder", "rowReorder", "rowClick", "emptyAction", "rowActionsRequested", "filtersChange", "activeTabChange", "onTabChange", "pageSizeChange", "currentPageChange", "firstChange", "filterTermChange", "groupByChange", "sortFieldChange", "sortDirectionChange"] }, { kind: "component", type: Button, selector: "mt-button", inputs: ["icon", "label", "tooltip", "class", "type", "styleClass", "severity", "badge", "variant", "badgeSeverity", "size", "iconPos", "autofocus", "fluid", "raised", "rounded", "text", "plain", "outlined", "link", "disabled", "loading", "pInputs", "ariaLabel"], outputs: ["onClick", "onFocus", "onBlur"] }, { kind: "pipe", type: TranslocoPipe, name: "transloco" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
3112
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.8", type: EntityListField, isStandalone: true, selector: "mt-entity-list-field", inputs: { label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, readonly: { classPropertyName: "readonly", publicName: "readonly", isSignal: true, isRequired: false, transformFunction: null }, required: { classPropertyName: "required", publicName: "required", isSignal: true, isRequired: false, transformFunction: null }, propertyId: { classPropertyName: "propertyId", publicName: "propertyId", isSignal: true, isRequired: false, transformFunction: null }, propertyKey: { classPropertyName: "propertyKey", publicName: "propertyKey", isSignal: true, isRequired: false, transformFunction: null }, configuration: { classPropertyName: "configuration", publicName: "configuration", isSignal: true, isRequired: false, transformFunction: null }, runtimeContext: { classPropertyName: "runtimeContext", publicName: "runtimeContext", isSignal: true, isRequired: false, transformFunction: null }, pendingSubmission: { classPropertyName: "pendingSubmission", publicName: "pendingSubmission", isSignal: true, isRequired: false, transformFunction: null }, lookups: { classPropertyName: "lookups", publicName: "lookups", isSignal: true, isRequired: false, transformFunction: null }, context: { classPropertyName: "context", publicName: "context", isSignal: true, isRequired: false, transformFunction: null }, initialValue: { classPropertyName: "initialValue", publicName: "initialValue", isSignal: true, isRequired: false, transformFunction: null } }, host: { classAttribute: "grid gap-1" }, providers: [EntityRuntimeContextStore], ngImport: i0, template: "<div class=\"flex flex-col gap-2\">\n @if (label()) {\n <label class=\"font-medium text-color\">\n {{ label() }}\n @if (required()) {\n <span class=\"text-red-500\">*</span>\n }\n </label>\n }\n\n @if (errorMessage(); as err) {\n <p-message severity=\"error\" [text]=\"err\" styleClass=\"w-full\" />\n } @else if (noticeKey(); as notice) {\n <div\n class=\"rounded-md border border-dashed border-surface-300 bg-surface-50 p-3 text-sm text-muted-color\"\n >\n {{ notice | transloco }}\n </div>\n } @else if (localReady()) {\n <!--\n A Local list: rows owned by this record, staged into its own submission.\n Add / edit / delete / drag follow the Local operation switches.\n -->\n @if (localCanCreate()) {\n <div class=\"flex justify-end\">\n <mt-button\n [label]=\"'components.entityListField.add' | transloco\"\n icon=\"general.plus\"\n size=\"small\"\n [disabled]=\"disabled()\"\n (onClick)=\"openLocalRowDialog()\"\n />\n </div>\n }\n @if (localTableRows().length || localCanCreate()) {\n <mt-table\n [noCard]=\"true\"\n [data]=\"localTableRows()\"\n [columns]=\"localColumns()\"\n [rowActions]=\"localRowActions()\"\n [reorderableRows]=\"localCanReorder()\"\n (rowReorder)=\"onLocalReorder($event)\"\n dataKey=\"Id\"\n />\n } @else {\n <div\n class=\"rounded-md border border-dashed border-surface-300 bg-surface-50 p-3 text-sm text-muted-color\"\n >\n {{ \"components.entityListField.noLocalRows\" | transloco }}\n </div>\n }\n } @else if (selectionReady()) {\n <!--\n A Selected list: the source records picked for this record, and nothing\n else. Picking and removing change only which records it holds.\n -->\n @if (selectionWritable()) {\n <div class=\"flex justify-end\">\n <mt-button\n [label]=\"'components.entityListField.selectRecords' | transloco\"\n icon=\"general.plus\"\n size=\"small\"\n [disabled]=\"disabled()\"\n (onClick)=\"openSelectionDialog()\"\n />\n </div>\n }\n @if (selectionRows().length) {\n <mt-table\n [noCard]=\"true\"\n [data]=\"selectionRows()\"\n [columns]=\"columns()\"\n [rowActions]=\"selectionRowActions()\"\n dataKey=\"Id\"\n />\n } @else {\n <div\n class=\"rounded-md border border-dashed border-surface-300 bg-surface-50 p-3 text-sm text-muted-color\"\n >\n {{ \"components.entityListField.noSelectedRecords\" | transloco }}\n </div>\n }\n } @else if (canWrite()) {\n <div class=\"flex justify-end\">\n <mt-button\n [label]=\"'components.entityListField.add' | transloco\"\n icon=\"general.plus\"\n size=\"small\"\n [disabled]=\"disabled()\"\n (onClick)=\"openAddDialog()\"\n />\n </div>\n <mt-table\n [noCard]=\"true\"\n [data]=\"displayRows()\"\n [columns]=\"tableColumns()\"\n [rowActions]=\"writeRowActions()\"\n dataKey=\"Id\"\n [loading]=\"loading()\"\n />\n } @else if (loading() && !hasRows()) {\n <div class=\"flex flex-col gap-2\">\n <p-skeleton width=\"100%\" height=\"3rem\" borderRadius=\"0.375rem\" />\n <p-skeleton width=\"100%\" height=\"3rem\" borderRadius=\"0.375rem\" />\n </div>\n } @else if (!hasRows()) {\n <div\n class=\"rounded-md border border-dashed border-surface-300 bg-surface-50 p-3 text-sm text-muted-color\"\n >\n {{ \"components.entityListField.noRelatedItems\" | transloco }}\n </div>\n } @else {\n <mt-table\n [noCard]=\"true\"\n [data]=\"displayRows()\"\n [columns]=\"tableColumns()\"\n dataKey=\"Id\"\n [loading]=\"loading()\"\n />\n }\n\n @if (ngControl?.control) {\n <mt-field-validation\n [control]=\"ngControl?.control!\"\n [touched]=\"ngControl?.touched ?? false\"\n />\n }\n</div>\n", styles: [":host{display:block}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "component", type: FieldValidation, selector: "mt-field-validation", inputs: ["control", "touched", "messageId"] }, { kind: "component", type: Skeleton, selector: "p-skeleton", inputs: ["styleClass", "shape", "animation", "borderRadius", "size", "width", "height"] }, { kind: "component", type: Message, selector: "p-message", inputs: ["severity", "text", "escape", "style", "styleClass", "closable", "icon", "closeIcon", "life", "showTransitionOptions", "hideTransitionOptions", "size", "variant", "motionOptions"], outputs: ["onClose"] }, { kind: "component", type: Table, selector: "mt-table", inputs: ["filters", "data", "columns", "rowActions", "size", "showGridlines", "stripedRows", "selectableRows", "clickableRows", "generalSearch", "lazyLocalSearch", "showFilters", "filterMode", "loading", "updating", "lazy", "lazyLocalSort", "lazyTotalRecords", "reorderableColumns", "reorderableRows", "dataKey", "storageKey", "storageMode", "persistStateExclude", "exportable", "printable", "groupable", "groupCountMap", "cellClickFilter", "freezeActions", "virtualScroll", "virtualScrollItemSize", "scrollHeight", "printTitle", "exportFilename", "actionShape", "rowActionsLoadingFn", "tableLayout", "noCard", "tabs", "tabsOptionLabel", "tabsOptionValue", "activeTab", "actions", "captionStartTemplate", "captionEndTemplate", "emptyTitle", "emptyDescription", "emptyActionLabel", "emptyActionIcon", "paginatorPosition", "alwaysShowPaginator", "rowsPerPageOptions", "pageSize", "currentPage", "first", "filterTerm", "groupBy", "sortField", "sortDirection"], outputs: ["selectionChange", "cellChange", "lazyLoad", "columnReorder", "rowReorder", "rowClick", "emptyAction", "rowActionsRequested", "filtersChange", "activeTabChange", "onTabChange", "pageSizeChange", "currentPageChange", "firstChange", "filterTermChange", "groupByChange", "sortFieldChange", "sortDirectionChange"] }, { kind: "component", type: Button, selector: "mt-button", inputs: ["icon", "label", "tooltip", "class", "type", "styleClass", "severity", "badge", "variant", "badgeSeverity", "size", "iconPos", "autofocus", "fluid", "raised", "rounded", "text", "plain", "outlined", "link", "disabled", "loading", "pInputs", "ariaLabel"], outputs: ["onClick", "onFocus", "onBlur"] }, { kind: "pipe", type: TranslocoPipe, name: "transloco" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
2627
3113
|
}
|
|
2628
3114
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: EntityListField, decorators: [{
|
|
2629
3115
|
type: Component,
|
|
@@ -2635,8 +3121,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImpor
|
|
|
2635
3121
|
Table,
|
|
2636
3122
|
Button,
|
|
2637
3123
|
TranslocoPipe,
|
|
2638
|
-
], changeDetection: ChangeDetectionStrategy.OnPush, host: { class: 'grid gap-1' }, providers: [EntityRuntimeContextStore], template: "<div class=\"flex flex-col gap-2\">\n @if (label()) {\n <label class=\"font-medium text-color\">\n {{ label() }}\n @if (required()) {\n <span class=\"text-red-500\">*</span>\n }\n </label>\n }\n\n @if (errorMessage(); as err) {\n <p-message severity=\"error\" [text]=\"err\" styleClass=\"w-full\" />\n } @else if (noticeKey(); as notice) {\n <div\n class=\"rounded-md border border-dashed border-surface-300 bg-surface-50 p-3 text-sm text-muted-color\"\n >\n {{ notice | transloco }}\n </div>\n } @else if (localReady()) {\n <!--\n A Local list: rows owned by this record, staged into its own submission.\n Add / edit / delete / drag follow the Local operation switches.\n -->\n @if (localCanCreate()) {\n <div class=\"flex justify-end\">\n <mt-button\n [label]=\"'components.entityListField.add' | transloco\"\n icon=\"general.plus\"\n size=\"small\"\n [disabled]=\"disabled()\"\n (onClick)=\"openLocalRowDialog()\"\n />\n </div>\n }\n @if (localTableRows().length || localCanCreate()) {\n <mt-table\n [noCard]=\"true\"\n [data]=\"localTableRows()\"\n [columns]=\"localColumns()\"\n [rowActions]=\"localRowActions()\"\n [reorderableRows]=\"localCanReorder()\"\n (rowReorder)=\"onLocalReorder($event)\"\n dataKey=\"Id\"\n />\n } @else {\n <div\n class=\"rounded-md border border-dashed border-surface-300 bg-surface-50 p-3 text-sm text-muted-color\"\n >\n {{ \"components.entityListField.noLocalRows\" | transloco }}\n </div>\n }\n } @else if (canWrite()) {\n <div class=\"flex justify-end\">\n <mt-button\n [label]=\"'components.entityListField.add' | transloco\"\n icon=\"general.plus\"\n size=\"small\"\n [disabled]=\"disabled()\"\n (onClick)=\"openAddDialog()\"\n />\n </div>\n <mt-table\n [noCard]=\"true\"\n [data]=\"displayRows()\"\n [columns]=\"tableColumns()\"\n [rowActions]=\"writeRowActions()\"\n dataKey=\"Id\"\n [loading]=\"loading()\"\n />\n } @else if (loading() && !hasRows()) {\n <div class=\"flex flex-col gap-2\">\n <p-skeleton width=\"100%\" height=\"3rem\" borderRadius=\"0.375rem\" />\n <p-skeleton width=\"100%\" height=\"3rem\" borderRadius=\"0.375rem\" />\n </div>\n } @else if (!hasRows()) {\n <div\n class=\"rounded-md border border-dashed border-surface-300 bg-surface-50 p-3 text-sm text-muted-color\"\n >\n {{ \"components.entityListField.noRelatedItems\" | transloco }}\n </div>\n } @else {\n <mt-table\n [noCard]=\"true\"\n [data]=\"displayRows()\"\n [columns]=\"tableColumns()\"\n dataKey=\"Id\"\n [loading]=\"loading()\"\n />\n }\n\n @if (ngControl?.control) {\n <mt-field-validation\n [control]=\"ngControl?.control!\"\n [touched]=\"ngControl?.touched ?? false\"\n />\n }\n</div>\n", styles: [":host{display:block}\n"] }]
|
|
2639
|
-
}], ctorParameters: () => [], propDecorators: { label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], readonly: [{ type: i0.Input, args: [{ isSignal: true, alias: "readonly", required: false }] }], required: [{ type: i0.Input, args: [{ isSignal: true, alias: "required", required: false }] }], propertyId: [{ type: i0.Input, args: [{ isSignal: true, alias: "propertyId", required: false }] }], configuration: [{ type: i0.Input, args: [{ isSignal: true, alias: "configuration", required: false }] }], runtimeContext: [{ type: i0.Input, args: [{ isSignal: true, alias: "runtimeContext", required: false }] }], pendingSubmission: [{ type: i0.Input, args: [{ isSignal: true, alias: "pendingSubmission", required: false }] }], lookups: [{ type: i0.Input, args: [{ isSignal: true, alias: "lookups", required: false }] }], context: [{ type: i0.Input, args: [{ isSignal: true, alias: "context", required: false }] }], initialValue: [{ type: i0.Input, args: [{ isSignal: true, alias: "initialValue", required: false }] }] } });
|
|
3124
|
+
], changeDetection: ChangeDetectionStrategy.OnPush, host: { class: 'grid gap-1' }, providers: [EntityRuntimeContextStore], template: "<div class=\"flex flex-col gap-2\">\n @if (label()) {\n <label class=\"font-medium text-color\">\n {{ label() }}\n @if (required()) {\n <span class=\"text-red-500\">*</span>\n }\n </label>\n }\n\n @if (errorMessage(); as err) {\n <p-message severity=\"error\" [text]=\"err\" styleClass=\"w-full\" />\n } @else if (noticeKey(); as notice) {\n <div\n class=\"rounded-md border border-dashed border-surface-300 bg-surface-50 p-3 text-sm text-muted-color\"\n >\n {{ notice | transloco }}\n </div>\n } @else if (localReady()) {\n <!--\n A Local list: rows owned by this record, staged into its own submission.\n Add / edit / delete / drag follow the Local operation switches.\n -->\n @if (localCanCreate()) {\n <div class=\"flex justify-end\">\n <mt-button\n [label]=\"'components.entityListField.add' | transloco\"\n icon=\"general.plus\"\n size=\"small\"\n [disabled]=\"disabled()\"\n (onClick)=\"openLocalRowDialog()\"\n />\n </div>\n }\n @if (localTableRows().length || localCanCreate()) {\n <mt-table\n [noCard]=\"true\"\n [data]=\"localTableRows()\"\n [columns]=\"localColumns()\"\n [rowActions]=\"localRowActions()\"\n [reorderableRows]=\"localCanReorder()\"\n (rowReorder)=\"onLocalReorder($event)\"\n dataKey=\"Id\"\n />\n } @else {\n <div\n class=\"rounded-md border border-dashed border-surface-300 bg-surface-50 p-3 text-sm text-muted-color\"\n >\n {{ \"components.entityListField.noLocalRows\" | transloco }}\n </div>\n }\n } @else if (selectionReady()) {\n <!--\n A Selected list: the source records picked for this record, and nothing\n else. Picking and removing change only which records it holds.\n -->\n @if (selectionWritable()) {\n <div class=\"flex justify-end\">\n <mt-button\n [label]=\"'components.entityListField.selectRecords' | transloco\"\n icon=\"general.plus\"\n size=\"small\"\n [disabled]=\"disabled()\"\n (onClick)=\"openSelectionDialog()\"\n />\n </div>\n }\n @if (selectionRows().length) {\n <mt-table\n [noCard]=\"true\"\n [data]=\"selectionRows()\"\n [columns]=\"columns()\"\n [rowActions]=\"selectionRowActions()\"\n dataKey=\"Id\"\n />\n } @else {\n <div\n class=\"rounded-md border border-dashed border-surface-300 bg-surface-50 p-3 text-sm text-muted-color\"\n >\n {{ \"components.entityListField.noSelectedRecords\" | transloco }}\n </div>\n }\n } @else if (canWrite()) {\n <div class=\"flex justify-end\">\n <mt-button\n [label]=\"'components.entityListField.add' | transloco\"\n icon=\"general.plus\"\n size=\"small\"\n [disabled]=\"disabled()\"\n (onClick)=\"openAddDialog()\"\n />\n </div>\n <mt-table\n [noCard]=\"true\"\n [data]=\"displayRows()\"\n [columns]=\"tableColumns()\"\n [rowActions]=\"writeRowActions()\"\n dataKey=\"Id\"\n [loading]=\"loading()\"\n />\n } @else if (loading() && !hasRows()) {\n <div class=\"flex flex-col gap-2\">\n <p-skeleton width=\"100%\" height=\"3rem\" borderRadius=\"0.375rem\" />\n <p-skeleton width=\"100%\" height=\"3rem\" borderRadius=\"0.375rem\" />\n </div>\n } @else if (!hasRows()) {\n <div\n class=\"rounded-md border border-dashed border-surface-300 bg-surface-50 p-3 text-sm text-muted-color\"\n >\n {{ \"components.entityListField.noRelatedItems\" | transloco }}\n </div>\n } @else {\n <mt-table\n [noCard]=\"true\"\n [data]=\"displayRows()\"\n [columns]=\"tableColumns()\"\n dataKey=\"Id\"\n [loading]=\"loading()\"\n />\n }\n\n @if (ngControl?.control) {\n <mt-field-validation\n [control]=\"ngControl?.control!\"\n [touched]=\"ngControl?.touched ?? false\"\n />\n }\n</div>\n", styles: [":host{display:block}\n"] }]
|
|
3125
|
+
}], ctorParameters: () => [], propDecorators: { label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], readonly: [{ type: i0.Input, args: [{ isSignal: true, alias: "readonly", required: false }] }], required: [{ type: i0.Input, args: [{ isSignal: true, alias: "required", required: false }] }], propertyId: [{ type: i0.Input, args: [{ isSignal: true, alias: "propertyId", required: false }] }], propertyKey: [{ type: i0.Input, args: [{ isSignal: true, alias: "propertyKey", required: false }] }], configuration: [{ type: i0.Input, args: [{ isSignal: true, alias: "configuration", required: false }] }], runtimeContext: [{ type: i0.Input, args: [{ isSignal: true, alias: "runtimeContext", required: false }] }], pendingSubmission: [{ type: i0.Input, args: [{ isSignal: true, alias: "pendingSubmission", required: false }] }], lookups: [{ type: i0.Input, args: [{ isSignal: true, alias: "lookups", required: false }] }], context: [{ type: i0.Input, args: [{ isSignal: true, alias: "context", required: false }] }], initialValue: [{ type: i0.Input, args: [{ isSignal: true, alias: "initialValue", required: false }] }] } });
|
|
2640
3126
|
|
|
2641
3127
|
/**
|
|
2642
3128
|
* Lets `mt-entity-list-preview` render a module-backed `EntityList` as the
|