@masterteam/components 0.0.300 → 0.0.301
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/fesm2022/masterteam-components-business-fields.mjs +138 -51
- package/fesm2022/masterteam-components-business-fields.mjs.map +1 -1
- package/fesm2022/masterteam-components-checkbox-field.mjs +2 -2
- package/fesm2022/masterteam-components-checkbox-field.mjs.map +1 -1
- package/fesm2022/masterteam-components-entities.mjs +208 -291
- package/fesm2022/masterteam-components-entities.mjs.map +1 -1
- package/fesm2022/masterteam-components-radio-button-field.mjs +2 -2
- package/fesm2022/masterteam-components-radio-button-field.mjs.map +1 -1
- package/fesm2022/masterteam-components-select-field.mjs +23 -2
- package/fesm2022/masterteam-components-select-field.mjs.map +1 -1
- package/fesm2022/masterteam-components-table.mjs +1 -1
- package/fesm2022/masterteam-components-table.mjs.map +1 -1
- package/fesm2022/masterteam-components-toggle-field.mjs +2 -2
- package/fesm2022/masterteam-components-toggle-field.mjs.map +1 -1
- package/fesm2022/masterteam-components.mjs +43 -2
- package/fesm2022/masterteam-components.mjs.map +1 -1
- package/package.json +1 -1
- package/types/masterteam-components-business-fields.d.ts +80 -27
- package/types/masterteam-components-entities.d.ts +132 -114
- package/types/masterteam-components-select-field.d.ts +14 -0
- package/types/masterteam-components.d.ts +27 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CommonModule, NgComponentOutlet } from '@angular/common';
|
|
2
2
|
import * as i0 from '@angular/core';
|
|
3
|
-
import { input, inject, DestroyRef, signal, computed, ChangeDetectionStrategy, Component, effect, untracked, viewChild, linkedSignal, InjectionToken } from '@angular/core';
|
|
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
6
|
import { ControlContainer, NgControl, FormsModule, Validators } from '@angular/forms';
|
|
@@ -16,11 +16,11 @@ import { HttpClient, HttpParams } from '@angular/common/http';
|
|
|
16
16
|
import { Button } from '@masterteam/components/button';
|
|
17
17
|
import { NumberField } from '@masterteam/components/number-field';
|
|
18
18
|
import { Table } from '@masterteam/components/table';
|
|
19
|
-
import { newFieldId } from '@masterteam/components';
|
|
19
|
+
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 { readEntityValueColor, serializeEntityRawValue, ENTITY_LIST_TABLE_COMPONENT } from '@masterteam/components/entities';
|
|
23
|
+
import { readEntityValueColor, serializeEntityRawValue, EntityRuntimeContextStore, ENTITY_LIST_TABLE_COMPONENT } from '@masterteam/components/entities';
|
|
24
24
|
import * as i2$1 from 'primeng/inputtext';
|
|
25
25
|
import { InputTextModule } from 'primeng/inputtext';
|
|
26
26
|
|
|
@@ -191,6 +191,11 @@ class SchemaConnectionField {
|
|
|
191
191
|
label = input('', ...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
|
|
192
192
|
placeholder = input('', ...(ngDevMode ? [{ debugName: "placeholder" }] : /* istanbul ignore next */ []));
|
|
193
193
|
readonly = input(false, ...(ngDevMode ? [{ debugName: "readonly" }] : /* istanbul ignore next */ []));
|
|
194
|
+
/**
|
|
195
|
+
* Kept for direct-host API compatibility. Dynamic/client forms do not bind
|
|
196
|
+
* it; runtime requiredness is defined per source by
|
|
197
|
+
* `configuration.sourceLevels[].isOptional`.
|
|
198
|
+
*/
|
|
194
199
|
required = input(false, ...(ngDevMode ? [{ debugName: "required" }] : /* istanbul ignore next */ []));
|
|
195
200
|
filter = input(true, ...(ngDevMode ? [{ debugName: "filter" }] : /* istanbul ignore next */ []));
|
|
196
201
|
/**
|
|
@@ -223,21 +228,26 @@ class SchemaConnectionField {
|
|
|
223
228
|
onTouched = () => { };
|
|
224
229
|
onModelChange = () => { };
|
|
225
230
|
/**
|
|
226
|
-
*
|
|
227
|
-
*
|
|
228
|
-
*
|
|
229
|
-
* stock `Validators.required` accepts — so a plain required check would let an
|
|
230
|
-
* empty connection pass and the form submit. Mirrors {@link syncValue}, which
|
|
231
|
-
* collapses a source-less selection to `null`.
|
|
231
|
+
* Every source whose `isOptional` is false must have at least one selected
|
|
232
|
+
* record. The field-level `isRequired` flag is intentionally ignored because
|
|
233
|
+
* one Connection property can mix optional and required source levels.
|
|
232
234
|
*/
|
|
233
|
-
|
|
235
|
+
requiredSourcesValidator = (control) => {
|
|
234
236
|
const value = parseConnectionPayload(control.value);
|
|
235
|
-
const
|
|
236
|
-
|
|
237
|
+
const selectedSources = Array.isArray(value?.sources) ? value.sources : [];
|
|
238
|
+
const allRequiredSourcesSelected = this.sourceLevels()
|
|
239
|
+
.filter((source) => source.isOptional !== true)
|
|
240
|
+
.every((source) => {
|
|
241
|
+
const sourceId = this.getSourceId(source);
|
|
242
|
+
return selectedSources.some((selected) => (selected.sourceLevelId ?? selected.sourceModuleId) === sourceId &&
|
|
243
|
+
(selected.sourceLevelDataId ?? selected.sourceModuleDataId) != null);
|
|
244
|
+
});
|
|
245
|
+
return allRequiredSourcesSelected ? null : { required: true };
|
|
237
246
|
};
|
|
238
247
|
ngControl = null;
|
|
239
248
|
http = inject(HttpClient);
|
|
240
249
|
destroyRef = inject(DestroyRef);
|
|
250
|
+
cdr = inject(ChangeDetectorRef);
|
|
241
251
|
transloco = inject(TranslocoService);
|
|
242
252
|
/** Active UI language, kept reactive so source labels re-resolve on switch. */
|
|
243
253
|
activeLang = toSignal(this.transloco.langChanges$, {
|
|
@@ -300,13 +310,13 @@ class SchemaConnectionField {
|
|
|
300
310
|
const control = this.ngControl?.control;
|
|
301
311
|
if (!control)
|
|
302
312
|
return;
|
|
303
|
-
const
|
|
313
|
+
const hasRequiredSources = this.sourceLevels().some((source) => source.isOptional !== true);
|
|
304
314
|
untracked(() => {
|
|
305
|
-
if (
|
|
306
|
-
control.addValidators(this.
|
|
315
|
+
if (hasRequiredSources) {
|
|
316
|
+
control.addValidators(this.requiredSourcesValidator);
|
|
307
317
|
}
|
|
308
318
|
else {
|
|
309
|
-
control.removeValidators(this.
|
|
319
|
+
control.removeValidators(this.requiredSourcesValidator);
|
|
310
320
|
}
|
|
311
321
|
control.updateValueAndValidity({ emitEvent: false });
|
|
312
322
|
});
|
|
@@ -340,6 +350,23 @@ class SchemaConnectionField {
|
|
|
340
350
|
});
|
|
341
351
|
});
|
|
342
352
|
}
|
|
353
|
+
/**
|
|
354
|
+
* Repaint when the control's own state changes.
|
|
355
|
+
*
|
|
356
|
+
* `touched` and validity are plain `AbstractControl` state, not signals, and
|
|
357
|
+
* this component is `OnPush` — so a host that calls `markAllAsTouched()` on a
|
|
358
|
+
* failed submit marked the connection invalid and nothing re-rendered. The
|
|
359
|
+
* required message only appeared once the user happened to touch a dropdown,
|
|
360
|
+
* which is the one moment they no longer need telling.
|
|
361
|
+
*
|
|
362
|
+
* `ngOnInit` rather than the constructor: `formControl` / `formControlName`
|
|
363
|
+
* only expose `.control` after their first `ngOnChanges`.
|
|
364
|
+
*/
|
|
365
|
+
ngOnInit() {
|
|
366
|
+
this.ngControl?.control?.events
|
|
367
|
+
.pipe(takeUntilDestroyed(this.destroyRef))
|
|
368
|
+
.subscribe(() => this.cdr.markForCheck());
|
|
369
|
+
}
|
|
343
370
|
// ============================================================================
|
|
344
371
|
// Source Level Helpers
|
|
345
372
|
// ============================================================================
|
|
@@ -351,6 +378,49 @@ class SchemaConnectionField {
|
|
|
351
378
|
getSourceId(source) {
|
|
352
379
|
return (source.levelId ?? source.moduleId);
|
|
353
380
|
}
|
|
381
|
+
/**
|
|
382
|
+
* A source that must be selected and is not. Mirrors
|
|
383
|
+
* {@link requiredSourcesValidator}, which decides the same thing from the
|
|
384
|
+
* control value.
|
|
385
|
+
*
|
|
386
|
+
* A method, not a computed: `selections` is a plain object that `ngModel`
|
|
387
|
+
* mutates in place and carries no signal, so only re-reading it every change
|
|
388
|
+
* detection cycle stays truthful.
|
|
389
|
+
*/
|
|
390
|
+
isSourceMissing(source) {
|
|
391
|
+
if (source.isOptional === true)
|
|
392
|
+
return false;
|
|
393
|
+
const selected = this.selections[this.getSourceId(source)];
|
|
394
|
+
return Array.isArray(selected) ? selected.length === 0 : selected == null;
|
|
395
|
+
}
|
|
396
|
+
/**
|
|
397
|
+
* The control, but only for the source the message belongs under — every
|
|
398
|
+
* other source gets `null` and renders nothing. `mt-field-validation` still
|
|
399
|
+
* decides whether to paint: it waits for `touched`.
|
|
400
|
+
*
|
|
401
|
+
* Field height stays stable because the reserved line moves rather than
|
|
402
|
+
* appears. A null control reserves nothing, so exactly one slot is live at a
|
|
403
|
+
* time — the missing source's, or {@link unattributedErrorControl}'s below
|
|
404
|
+
* the row.
|
|
405
|
+
*/
|
|
406
|
+
sourceErrorControl(source) {
|
|
407
|
+
return this.isSourceMissing(source)
|
|
408
|
+
? (this.ngControl?.control ?? null)
|
|
409
|
+
: null;
|
|
410
|
+
}
|
|
411
|
+
/**
|
|
412
|
+
* The control, but only while no source owns the failure — a server error on
|
|
413
|
+
* a fully selected connection has nowhere else to render. Null as soon as a
|
|
414
|
+
* source is missing, so one failure never prints twice.
|
|
415
|
+
*/
|
|
416
|
+
unattributedErrorControl() {
|
|
417
|
+
const control = this.ngControl?.control ?? null;
|
|
418
|
+
if (!control)
|
|
419
|
+
return null;
|
|
420
|
+
return this.sourceLevels().some((source) => this.isSourceMissing(source))
|
|
421
|
+
? null
|
|
422
|
+
: control;
|
|
423
|
+
}
|
|
354
424
|
/**
|
|
355
425
|
* Builds the `contextKey` for the `fetch/query` request based on source type.
|
|
356
426
|
*/
|
|
@@ -473,7 +543,7 @@ class SchemaConnectionField {
|
|
|
473
543
|
this.disabled.set(disabled);
|
|
474
544
|
}
|
|
475
545
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: SchemaConnectionField, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
476
|
-
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\">\
|
|
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 });
|
|
477
547
|
}
|
|
478
548
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: SchemaConnectionField, decorators: [{
|
|
479
549
|
type: Component,
|
|
@@ -486,7 +556,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImpor
|
|
|
486
556
|
Icon,
|
|
487
557
|
], changeDetection: ChangeDetectionStrategy.OnPush, host: {
|
|
488
558
|
class: 'grid gap-1',
|
|
489
|
-
}, template: "<div class=\"flex gap-4 w-full\">\
|
|
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" }]
|
|
490
560
|
}], 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 }] }] } });
|
|
491
561
|
|
|
492
562
|
const PREDECESSOR_TYPE_BY_TOKEN = {
|
|
@@ -846,14 +916,17 @@ class EntityListField {
|
|
|
846
916
|
/** Optional HttpContext (kept for back-compat). */
|
|
847
917
|
context = input(undefined, ...(ngDevMode ? [{ debugName: "context" }] : /* istanbul ignore next */ []));
|
|
848
918
|
/**
|
|
849
|
-
*
|
|
850
|
-
*
|
|
851
|
-
* `
|
|
919
|
+
* The stored value, for hosts that render this field **outside a form** —
|
|
920
|
+
* the read-only `mt-entity-list-preview` creates it through
|
|
921
|
+
* `NgComponentOutlet`, which can set inputs but cannot drive a
|
|
922
|
+
* `ControlValueAccessor`.
|
|
852
923
|
*
|
|
853
|
-
* Ignored
|
|
854
|
-
*
|
|
924
|
+
* Ignored once a form control is attached, so it can never race
|
|
925
|
+
* `writeValue`. It matters for a `Write`-access list: that field may not read
|
|
926
|
+
* the target module, so its stored `rows[]` are the only thing it has to
|
|
927
|
+
* show.
|
|
855
928
|
*/
|
|
856
|
-
|
|
929
|
+
initialValue = input(null, ...(ngDevMode ? [{ debugName: "initialValue" }] : /* istanbul ignore next */ []));
|
|
857
930
|
// CVA state — pass-through value (EntityList stored JSON shape).
|
|
858
931
|
storedValue = signal(null, ...(ngDevMode ? [{ debugName: "storedValue" }] : /* istanbul ignore next */ []));
|
|
859
932
|
/** Runtime-scoped metadata; null until the endpoint answers. */
|
|
@@ -1236,15 +1309,15 @@ class EntityListField {
|
|
|
1236
1309
|
const levelDataId = this.levelDataId();
|
|
1237
1310
|
untracked(() => this.loadTable(propertyId, levelId, levelDataId));
|
|
1238
1311
|
});
|
|
1239
|
-
//
|
|
1240
|
-
// the
|
|
1241
|
-
// is
|
|
1312
|
+
// Form-less hosts hand the value over as an input instead. `writeValue` is
|
|
1313
|
+
// the one entry point that resets the pending rows and deletions with it,
|
|
1314
|
+
// so it is reused rather than re-implemented.
|
|
1242
1315
|
//
|
|
1243
|
-
//
|
|
1244
|
-
//
|
|
1245
|
-
// `writeValue`
|
|
1316
|
+
// Purely additive: an absent input never clears a value, so a host that
|
|
1317
|
+
// does not bind it — or binds it late — cannot wipe what a form or a direct
|
|
1318
|
+
// `writeValue` already put there.
|
|
1246
1319
|
effect(() => {
|
|
1247
|
-
const value = this.
|
|
1320
|
+
const value = this.initialValue();
|
|
1248
1321
|
if (this.ngControl || value == null)
|
|
1249
1322
|
return;
|
|
1250
1323
|
untracked(() => this.writeValue(value));
|
|
@@ -1949,14 +2022,24 @@ class EntityListField {
|
|
|
1949
2022
|
}
|
|
1950
2023
|
for (const key of valueKeys) {
|
|
1951
2024
|
const cell = record.values?.[key];
|
|
2025
|
+
const viewType = viewTypeByKey.get(key) ?? properties.get(key)?.viewType ?? '';
|
|
1952
2026
|
// Keep the machine-readable value as the baseline a partial update is
|
|
1953
2027
|
// diffed against — it is the shape the row submits.
|
|
1954
2028
|
values[key] = cell?.raw ?? cell?.value ?? null;
|
|
1955
2029
|
// What the edit dialog patches into its form, which is not always the
|
|
1956
2030
|
// same thing: see OBJECT_VALUED_VIEW_TYPES.
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
2031
|
+
if (OBJECT_VALUED_VIEW_TYPES.has(viewType)) {
|
|
2032
|
+
prefill[key] = cell?.value ?? cell?.raw ?? null;
|
|
2033
|
+
}
|
|
2034
|
+
else if (viewType === 'Checkbox') {
|
|
2035
|
+
// Stored as text (`'True'`/`'False'`), while `mt-toggle-field`
|
|
2036
|
+
// only shows a switch on as a strict `true` — see
|
|
2037
|
+
// `coerceCheckboxValue`.
|
|
2038
|
+
prefill[key] = coerceCheckboxValue(values[key]);
|
|
2039
|
+
}
|
|
2040
|
+
else {
|
|
2041
|
+
prefill[key] = values[key];
|
|
2042
|
+
}
|
|
1960
2043
|
}
|
|
1961
2044
|
row[ROW_VALUES_KEY] = values;
|
|
1962
2045
|
row[ROW_PREFILL_KEY] = prefill;
|
|
@@ -1982,7 +2065,7 @@ class EntityListField {
|
|
|
1982
2065
|
};
|
|
1983
2066
|
}
|
|
1984
2067
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: EntityListField, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1985
|
-
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 },
|
|
2068
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.8", type: EntityListField, isStandalone: true, selector: "mt-entity-list-field", inputs: { label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, readonly: { classPropertyName: "readonly", publicName: "readonly", isSignal: true, isRequired: false, transformFunction: null }, required: { classPropertyName: "required", publicName: "required", isSignal: true, isRequired: false, transformFunction: null }, propertyId: { classPropertyName: "propertyId", publicName: "propertyId", isSignal: true, isRequired: false, transformFunction: null }, configuration: { classPropertyName: "configuration", publicName: "configuration", isSignal: true, isRequired: false, transformFunction: null }, runtimeContext: { classPropertyName: "runtimeContext", publicName: "runtimeContext", isSignal: true, isRequired: false, transformFunction: null }, pendingSubmission: { classPropertyName: "pendingSubmission", publicName: "pendingSubmission", isSignal: true, isRequired: false, transformFunction: null }, lookups: { classPropertyName: "lookups", publicName: "lookups", isSignal: true, isRequired: false, transformFunction: null }, context: { classPropertyName: "context", publicName: "context", isSignal: true, isRequired: false, transformFunction: null }, initialValue: { classPropertyName: "initialValue", publicName: "initialValue", isSignal: true, isRequired: false, transformFunction: null } }, host: { classAttribute: "grid gap-1" }, providers: [EntityRuntimeContextStore], ngImport: i0, template: "<div class=\"flex flex-col gap-2\">\r\n @if (label()) {\r\n <label class=\"font-medium text-color\">\r\n {{ label() }}\r\n @if (required()) {\r\n <span class=\"text-red-500\">*</span>\r\n }\r\n </label>\r\n }\r\n\r\n @if (errorMessage(); as err) {\r\n <p-message severity=\"error\" [text]=\"err\" styleClass=\"w-full\" />\r\n } @else if (noticeKey(); as notice) {\r\n <div\r\n class=\"rounded-md border border-dashed border-surface-300 bg-surface-50 p-3 text-sm text-muted-color\"\r\n >\r\n {{ notice | transloco }}\r\n </div>\r\n } @else if (canWrite()) {\r\n <div class=\"flex justify-end\">\r\n <mt-button\r\n [label]=\"'components.entityListField.add' | transloco\"\r\n icon=\"general.plus\"\r\n size=\"small\"\r\n [disabled]=\"disabled()\"\r\n (onClick)=\"openAddDialog()\"\r\n />\r\n </div>\r\n <mt-table\r\n [noCard]=\"true\"\r\n [data]=\"displayRows()\"\r\n [columns]=\"tableColumns()\"\r\n [rowActions]=\"writeRowActions()\"\r\n dataKey=\"Id\"\r\n [loading]=\"loading()\"\r\n />\r\n } @else if (loading() && !hasRows()) {\r\n <div class=\"flex flex-col gap-2\">\r\n <p-skeleton width=\"100%\" height=\"3rem\" borderRadius=\"0.375rem\" />\r\n <p-skeleton width=\"100%\" height=\"3rem\" borderRadius=\"0.375rem\" />\r\n </div>\r\n } @else if (!hasRows()) {\r\n <div\r\n class=\"rounded-md border border-dashed border-surface-300 bg-surface-50 p-3 text-sm text-muted-color\"\r\n >\r\n {{ \"components.entityListField.noRelatedItems\" | transloco }}\r\n </div>\r\n } @else {\r\n <mt-table\r\n [noCard]=\"true\"\r\n [data]=\"displayRows()\"\r\n [columns]=\"tableColumns()\"\r\n dataKey=\"Id\"\r\n [loading]=\"loading()\"\r\n />\r\n }\r\n\r\n @if (ngControl?.control) {\r\n <mt-field-validation\r\n [control]=\"ngControl?.control!\"\r\n [touched]=\"ngControl?.touched ?? false\"\r\n />\r\n }\r\n</div>\r\n", styles: [":host{display:block}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "component", type: FieldValidation, selector: "mt-field-validation", inputs: ["control", "touched", "messageId"] }, { kind: "component", type: Skeleton, selector: "p-skeleton", inputs: ["styleClass", "shape", "animation", "borderRadius", "size", "width", "height"] }, { kind: "component", type: Message, selector: "p-message", inputs: ["severity", "text", "escape", "style", "styleClass", "closable", "icon", "closeIcon", "life", "showTransitionOptions", "hideTransitionOptions", "size", "variant", "motionOptions"], outputs: ["onClose"] }, { kind: "component", type: Table, selector: "mt-table", inputs: ["filters", "data", "columns", "rowActions", "size", "showGridlines", "stripedRows", "selectableRows", "clickableRows", "generalSearch", "lazyLocalSearch", "showFilters", "filterMode", "loading", "updating", "lazy", "lazyLocalSort", "lazyTotalRecords", "reorderableColumns", "reorderableRows", "dataKey", "storageKey", "storageMode", "persistStateExclude", "exportable", "printable", "groupable", "groupCountMap", "cellClickFilter", "freezeActions", "virtualScroll", "virtualScrollItemSize", "scrollHeight", "printTitle", "exportFilename", "actionShape", "rowActionsLoadingFn", "tableLayout", "noCard", "tabs", "tabsOptionLabel", "tabsOptionValue", "activeTab", "actions", "captionStartTemplate", "captionEndTemplate", "emptyTitle", "emptyDescription", "emptyActionLabel", "emptyActionIcon", "paginatorPosition", "alwaysShowPaginator", "rowsPerPageOptions", "pageSize", "currentPage", "first", "filterTerm", "groupBy", "sortField", "sortDirection"], outputs: ["selectionChange", "cellChange", "lazyLoad", "columnReorder", "rowReorder", "rowClick", "emptyAction", "rowActionsRequested", "filtersChange", "activeTabChange", "onTabChange", "pageSizeChange", "currentPageChange", "firstChange", "filterTermChange", "groupByChange", "sortFieldChange", "sortDirectionChange"] }, { kind: "component", type: Button, selector: "mt-button", inputs: ["icon", "label", "tooltip", "class", "type", "styleClass", "severity", "badge", "variant", "badgeSeverity", "size", "iconPos", "autofocus", "fluid", "raised", "rounded", "text", "plain", "outlined", "link", "disabled", "loading", "pInputs", "ariaLabel"], outputs: ["onClick", "onFocus", "onBlur"] }, { kind: "pipe", type: TranslocoPipe, name: "transloco" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
1986
2069
|
}
|
|
1987
2070
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: EntityListField, decorators: [{
|
|
1988
2071
|
type: Component,
|
|
@@ -1994,26 +2077,30 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImpor
|
|
|
1994
2077
|
Table,
|
|
1995
2078
|
Button,
|
|
1996
2079
|
TranslocoPipe,
|
|
1997
|
-
], 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]=\"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"] }]
|
|
1998
|
-
}], 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 }] }],
|
|
2080
|
+
], changeDetection: ChangeDetectionStrategy.OnPush, host: { class: 'grid gap-1' }, providers: [EntityRuntimeContextStore], template: "<div class=\"flex flex-col gap-2\">\r\n @if (label()) {\r\n <label class=\"font-medium text-color\">\r\n {{ label() }}\r\n @if (required()) {\r\n <span class=\"text-red-500\">*</span>\r\n }\r\n </label>\r\n }\r\n\r\n @if (errorMessage(); as err) {\r\n <p-message severity=\"error\" [text]=\"err\" styleClass=\"w-full\" />\r\n } @else if (noticeKey(); as notice) {\r\n <div\r\n class=\"rounded-md border border-dashed border-surface-300 bg-surface-50 p-3 text-sm text-muted-color\"\r\n >\r\n {{ notice | transloco }}\r\n </div>\r\n } @else if (canWrite()) {\r\n <div class=\"flex justify-end\">\r\n <mt-button\r\n [label]=\"'components.entityListField.add' | transloco\"\r\n icon=\"general.plus\"\r\n size=\"small\"\r\n [disabled]=\"disabled()\"\r\n (onClick)=\"openAddDialog()\"\r\n />\r\n </div>\r\n <mt-table\r\n [noCard]=\"true\"\r\n [data]=\"displayRows()\"\r\n [columns]=\"tableColumns()\"\r\n [rowActions]=\"writeRowActions()\"\r\n dataKey=\"Id\"\r\n [loading]=\"loading()\"\r\n />\r\n } @else if (loading() && !hasRows()) {\r\n <div class=\"flex flex-col gap-2\">\r\n <p-skeleton width=\"100%\" height=\"3rem\" borderRadius=\"0.375rem\" />\r\n <p-skeleton width=\"100%\" height=\"3rem\" borderRadius=\"0.375rem\" />\r\n </div>\r\n } @else if (!hasRows()) {\r\n <div\r\n class=\"rounded-md border border-dashed border-surface-300 bg-surface-50 p-3 text-sm text-muted-color\"\r\n >\r\n {{ \"components.entityListField.noRelatedItems\" | transloco }}\r\n </div>\r\n } @else {\r\n <mt-table\r\n [noCard]=\"true\"\r\n [data]=\"displayRows()\"\r\n [columns]=\"tableColumns()\"\r\n dataKey=\"Id\"\r\n [loading]=\"loading()\"\r\n />\r\n }\r\n\r\n @if (ngControl?.control) {\r\n <mt-field-validation\r\n [control]=\"ngControl?.control!\"\r\n [touched]=\"ngControl?.touched ?? false\"\r\n />\r\n }\r\n</div>\r\n", styles: [":host{display:block}\n"] }]
|
|
2081
|
+
}], 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 }] }] } });
|
|
1999
2082
|
|
|
2000
2083
|
/**
|
|
2001
|
-
* Lets
|
|
2002
|
-
*
|
|
2084
|
+
* Lets `mt-entity-list-preview` render a module-backed `EntityList` as the
|
|
2085
|
+
* real, fetched table instead of its count-and-drawer trigger.
|
|
2003
2086
|
*
|
|
2004
|
-
*
|
|
2005
|
-
*
|
|
2006
|
-
*
|
|
2007
|
-
*
|
|
2087
|
+
* Pair it with an `EntityRuntimeContextStore` carrying the owning level and
|
|
2088
|
+
* level-data ids — the preview needs both, and without the context this
|
|
2089
|
+
* provider changes nothing. `mt-client-instance-preview` sets both up, so a
|
|
2090
|
+
* host rendering preview cards through it needs neither.
|
|
2008
2091
|
*
|
|
2009
|
-
* The
|
|
2010
|
-
*
|
|
2092
|
+
* The indirection exists because `entities` cannot import `table`: `table`
|
|
2093
|
+
* already imports `entities`, and they are separate entry points of
|
|
2094
|
+
* `@masterteam/components`. See `ENTITY_LIST_TABLE_COMPONENT`.
|
|
2095
|
+
*
|
|
2096
|
+
* ```ts
|
|
2097
|
+
* @Component({
|
|
2098
|
+
* providers: [EntityRuntimeContextStore, provideEntityListTablePreview()],
|
|
2099
|
+
* })
|
|
2100
|
+
* ```
|
|
2011
2101
|
*/
|
|
2012
|
-
function
|
|
2013
|
-
return {
|
|
2014
|
-
provide: ENTITY_LIST_TABLE_COMPONENT,
|
|
2015
|
-
useValue: EntityListField,
|
|
2016
|
-
};
|
|
2102
|
+
function provideEntityListTablePreview() {
|
|
2103
|
+
return { provide: ENTITY_LIST_TABLE_COMPONENT, useValue: EntityListField };
|
|
2017
2104
|
}
|
|
2018
2105
|
|
|
2019
2106
|
/** Page size when loading the full deliverable list, and a hard safety cap. */
|
|
@@ -2443,5 +2530,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImpor
|
|
|
2443
2530
|
* Generated bundle index. Do not edit.
|
|
2444
2531
|
*/
|
|
2445
2532
|
|
|
2446
|
-
export { ENTITY_LIST_ADD_DIALOG_COMPONENT, EntityListField, LOOKUP_CHECK_LIST_FORM_COMPONENT, LookupMatrixField, LookupModuleCheckListField, ScheduleItemSelectorField, SchedulePredecessorField, SchemaConnectionField,
|
|
2533
|
+
export { ENTITY_LIST_ADD_DIALOG_COMPONENT, EntityListField, LOOKUP_CHECK_LIST_FORM_COMPONENT, LookupMatrixField, LookupModuleCheckListField, ScheduleItemSelectorField, SchedulePredecessorField, SchemaConnectionField, provideEntityListTablePreview };
|
|
2447
2534
|
//# sourceMappingURL=masterteam-components-business-fields.mjs.map
|