@masterteam/components 0.0.309 → 0.0.311

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.
@@ -1 +1 @@
1
- {"version":3,"file":"masterteam-components-business-fields.mjs","sources":["../../../../packages/masterteam/components/business-fields/lookup-matrix-field/lookup-matrix-field.ts","../../../../packages/masterteam/components/business-fields/lookup-matrix-field/lookup-matrix-field.html","../../../../packages/masterteam/components/business-fields/schema-connection-field/schema-connection-field.ts","../../../../packages/masterteam/components/business-fields/schema-connection-field/schema-connection-field.html","../../../../packages/masterteam/components/business-fields/schedule-predecessor-field/schedule-predecessor-field.ts","../../../../packages/masterteam/components/business-fields/schedule-predecessor-field/schedule-predecessor-field.html","../../../../packages/masterteam/components/business-fields/entity-list-field/entity-list-add-token.ts","../../../../packages/masterteam/components/business-fields/entity-list-field/entity-list-local-editor.ts","../../../../packages/masterteam/components/business-fields/entity-list-field/entity-list-selection-editor.ts","../../../../packages/masterteam/components/business-fields/entity-list-field/entity-list-selection-dialog.ts","../../../../packages/masterteam/components/business-fields/entity-list-field/entity-list-selection-dialog.html","../../../../packages/masterteam/components/business-fields/entity-list-field/entity-list-field.ts","../../../../packages/masterteam/components/business-fields/entity-list-field/entity-list-field.html","../../../../packages/masterteam/components/business-fields/entity-list-field/entity-list-table-token.ts","../../../../packages/masterteam/components/business-fields/schedule-item-selector-field/schedule-item-selector-field.ts","../../../../packages/masterteam/components/business-fields/schedule-item-selector-field/schedule-item-selector-field.html","../../../../packages/masterteam/components/business-fields/lookup-module-check-list-field/lookup-module-check-list-form-token.ts","../../../../packages/masterteam/components/business-fields/lookup-module-check-list-field/lookup-module-check-list-field.ts","../../../../packages/masterteam/components/business-fields/lookup-module-check-list-field/lookup-module-check-list-field.html","../../../../packages/masterteam/components/business-fields/masterteam-components-business-fields.ts"],"sourcesContent":["import { CommonModule } from '@angular/common';\r\nimport {\r\n AfterViewInit,\r\n ChangeDetectionStrategy,\r\n Component,\r\n computed,\r\n DestroyRef,\r\n inject,\r\n input,\r\n signal,\r\n} from '@angular/core';\r\nimport { takeUntilDestroyed } from '@angular/core/rxjs-interop';\r\nimport { AbstractControl, ControlContainer } from '@angular/forms';\r\nimport { TranslocoService } from '@jsverse/transloco';\r\nimport { startWith } from 'rxjs';\r\nimport type {\r\n LookupMatrixCellConfig,\r\n LookupMatrixFieldConfig,\r\n LookupOptionItemConfig,\r\n} from '@masterteam/components';\r\nimport { Tooltip } from '@masterteam/components/tooltip';\r\nimport { Icon } from '@masterteam/icons';\r\n\r\n@Component({\r\n selector: 'mt-lookup-matrix-field',\r\n standalone: true,\r\n imports: [CommonModule, Tooltip, Icon],\r\n templateUrl: './lookup-matrix-field.html',\r\n changeDetection: ChangeDetectionStrategy.OnPush,\r\n host: {\r\n class: 'grid gap-2',\r\n },\r\n})\r\nexport class LookupMatrixField implements AfterViewInit {\r\n readonly config = input.required<LookupMatrixFieldConfig>();\r\n\r\n private readonly controlContainer = inject(ControlContainer, {\r\n optional: true,\r\n });\r\n private readonly destroyRef = inject(DestroyRef);\r\n private readonly transloco = inject(TranslocoService);\r\n private readonly valueVersion = signal(0);\r\n private subscribedControl: AbstractControl | null = null;\r\n\r\n readonly hasYAxis = computed(() => !!this.config().yFieldKey);\r\n readonly xOptions = computed(() => this.config().xOptions ?? []);\r\n readonly yOptions = computed(() => this.config().yOptions ?? []);\r\n readonly hasMatrix = computed(() => this.config().cells.length > 0);\r\n readonly cellMap = computed(\r\n () =>\r\n new Map(\r\n this.config().cells.map((cell) => [\r\n this.cellKey(cell.xLookupItemId, cell.yLookupItemId),\r\n cell,\r\n ]),\r\n ),\r\n );\r\n readonly selectedXOption = computed(() => {\r\n this.valueVersion();\r\n return this.resolveSelectedOption(\r\n this.xOptions(),\r\n this.getControlValue(this.config().xFieldKey),\r\n );\r\n });\r\n readonly selectedYOption = computed(() => {\r\n this.valueVersion();\r\n const yFieldKey = this.config().yFieldKey;\r\n if (!yFieldKey) {\r\n return null;\r\n }\r\n\r\n return this.resolveSelectedOption(\r\n this.yOptions(),\r\n this.getControlValue(yFieldKey),\r\n );\r\n });\r\n readonly activeCell = computed(() => {\r\n const selectedX = this.selectedXOption();\r\n if (!selectedX) {\r\n return null;\r\n }\r\n\r\n if (!this.hasYAxis()) {\r\n return this.getCell(selectedX.id ?? selectedX.value);\r\n }\r\n\r\n const selectedY = this.selectedYOption();\r\n if (!selectedY) {\r\n return null;\r\n }\r\n\r\n return this.getCell(\r\n selectedX.id ?? selectedX.value,\r\n selectedY.id ?? selectedY.value,\r\n );\r\n });\r\n readonly selectionSummary = computed(() => {\r\n const parts: string[] = [];\r\n const xAxisLabel =\r\n this.config().xAxisLabel.trim() ||\r\n this.transloco.translate('components.lookupMatrixField.xAxisFallback');\r\n const selectedX = this.selectedXOption();\r\n\r\n if (selectedX) {\r\n parts.push(`${xAxisLabel}: ${selectedX.label}`);\r\n }\r\n\r\n const selectedY = this.selectedYOption();\r\n const yAxisLabel =\r\n this.config().yAxisLabel?.trim() ||\r\n this.transloco.translate('components.lookupMatrixField.yAxisFallback');\r\n if (selectedY && this.hasYAxis()) {\r\n parts.push(`${yAxisLabel}: ${selectedY.label}`);\r\n }\r\n\r\n return parts.join(' / ');\r\n });\r\n readonly pendingMessage = computed(() => {\r\n const xAxisLabel =\r\n this.config().xAxisLabel.trim() ||\r\n this.transloco.translate(\r\n 'components.lookupMatrixField.firstValueFallback',\r\n );\r\n\r\n if (!this.hasYAxis()) {\r\n return this.transloco.translate(\r\n 'components.lookupMatrixField.selectXAxisFirst',\r\n { xAxisLabel },\r\n );\r\n }\r\n\r\n const yAxisLabel =\r\n this.config().yAxisLabel?.trim() ||\r\n this.transloco.translate(\r\n 'components.lookupMatrixField.secondValueFallback',\r\n );\r\n\r\n return this.transloco.translate(\r\n 'components.lookupMatrixField.selectAxesFirst',\r\n { xAxisLabel, yAxisLabel },\r\n );\r\n });\r\n readonly missingResultMessage = computed(() => {\r\n if (!this.selectedXOption()) {\r\n return this.pendingMessage();\r\n }\r\n\r\n if (this.hasYAxis() && !this.selectedYOption()) {\r\n return this.pendingMessage();\r\n }\r\n\r\n return this.transloco.translate(\r\n 'components.lookupMatrixField.noMatchingValue',\r\n );\r\n });\r\n\r\n ngAfterViewInit(): void {\r\n this.ensureControlSubscription();\r\n }\r\n\r\n getCell(\r\n xLookupItemId: number | string,\r\n yLookupItemId?: number | string,\r\n ): LookupMatrixCellConfig | null {\r\n return (\r\n this.cellMap().get(this.cellKey(xLookupItemId, yLookupItemId)) ?? null\r\n );\r\n }\r\n\r\n getSwatchColor(color?: string | null): string | null {\r\n return this.resolveColor(color);\r\n }\r\n\r\n private getControlValue(path: string): unknown {\r\n if (!path) return null;\r\n return this.controlContainer?.control?.get(path)?.value ?? null;\r\n }\r\n\r\n private ensureControlSubscription(): void {\r\n const control = this.controlContainer?.control;\r\n if (!control || control === this.subscribedControl) {\r\n return;\r\n }\r\n\r\n this.subscribedControl = control;\r\n control.valueChanges\r\n .pipe(\r\n startWith(control.getRawValue()),\r\n takeUntilDestroyed(this.destroyRef),\r\n )\r\n .subscribe(() => {\r\n this.valueVersion.update((value) => value + 1);\r\n });\r\n }\r\n\r\n private resolveSelectedOption(\r\n options: LookupOptionItemConfig[],\r\n rawValue: unknown,\r\n ): LookupOptionItemConfig | null {\r\n if (rawValue == null || rawValue === '') return null;\r\n\r\n return (\r\n options.find((option) => this.optionMatchesValue(option, rawValue)) ??\r\n null\r\n );\r\n }\r\n\r\n private optionMatchesValue(\r\n option: LookupOptionItemConfig,\r\n rawValue: unknown,\r\n ): boolean {\r\n return [option.value, option.key, option.id].some(\r\n (candidate) =>\r\n candidate != null && String(candidate) === String(rawValue),\r\n );\r\n }\r\n\r\n private cellKey(\r\n xLookupItemId: number | string,\r\n yLookupItemId?: number | string,\r\n ): string {\r\n return `${String(xLookupItemId)}::${String(yLookupItemId ?? '')}`;\r\n }\r\n\r\n private resolveColor(color?: string | null): string | null {\r\n if (!color) return null;\r\n\r\n if (\r\n color.startsWith('#') ||\r\n color.startsWith('rgb') ||\r\n color.startsWith('hsl') ||\r\n color.startsWith('var(')\r\n ) {\r\n return color;\r\n }\r\n\r\n return `var(--p-${color}-500)`;\r\n }\r\n}\r\n","@if (config().label) {\r\n <label class=\"font-medium text-color\">\r\n {{ config().label }}\r\n </label>\r\n}\r\n\r\n<div\r\n class=\"rounded-lg border border-surface-200 bg-surface-50 px-3 flex items-center\"\r\n>\r\n @if (activeCell(); as cell) {\r\n <div class=\"flex flex-1 min-h-6 items-center gap-2 justify-between\">\r\n <span\r\n class=\"h-6 w-2 shrink-0 rounded-[2px] border border-surface-200\"\r\n [style.background-color]=\"getSwatchColor(cell.color)\"\r\n [style.border-color]=\"getSwatchColor(cell.color)\"\r\n ></span>\r\n\r\n <div class=\"min-w-0 flex-1 py-2 flex items-center justify-between\">\r\n <div class=\"truncate font-semibold text-gray-500\">\r\n {{ cell.label }}\r\n </div>\r\n\r\n @if (selectionSummary()) {\r\n <div class=\"font-bold text-gray-500\">\r\n <mt-icon\r\n [mtTooltip]=\"selectionSummary()\"\r\n icon=\"general.info-circle\"\r\n />\r\n </div>\r\n }\r\n </div>\r\n </div>\r\n } @else {\r\n <div class=\"flex min-h-6 items-center text-muted-color py-2\">\r\n {{ hasMatrix() ? missingResultMessage() : config().emptyMessage }}\r\n </div>\r\n }\r\n</div>\r\n","import {\r\n Component,\r\n signal,\r\n input,\r\n computed,\r\n inject,\r\n ChangeDetectionStrategy,\r\n ChangeDetectorRef,\r\n effect,\r\n untracked,\r\n DestroyRef,\r\n OnInit,\r\n} from '@angular/core';\r\nimport {\r\n AbstractControl,\r\n ControlValueAccessor,\r\n FormsModule,\r\n NgControl,\r\n ValidationErrors,\r\n ValidatorFn,\r\n} from '@angular/forms';\r\nimport { TranslocoService } from '@jsverse/transloco';\r\nimport { SelectField } from '@masterteam/components/select-field';\r\nimport { MultiSelectField } from '@masterteam/components/multi-select-field';\r\nimport { FieldValidation } from '@masterteam/components/field-validation';\r\nimport { Tooltip } from '@masterteam/components/tooltip';\r\nimport { Icon } from '@masterteam/icons';\r\nimport { HttpClient, HttpContext } from '@angular/common/http';\r\nimport { takeUntilDestroyed, toSignal } from '@angular/core/rxjs-interop';\r\nimport { finalize, catchError, of } from 'rxjs';\r\nimport type { SchemaConnectionFieldRuntimeContext } from '@masterteam/components';\r\n\r\n// ============================================================================\r\n// Types\r\n// ============================================================================\r\n\r\n/**\r\n * One source level inside connection configuration.\r\n * Comes from `field.propertyMetadata.configuration.sourceLevels[]`\r\n *\r\n * A source can be either a **level** (has `levelId`/`levelKey`) or a\r\n * **module** (has `moduleId`/`moduleKey`). Exactly one pair will be present.\r\n */\r\nexport interface ConnectionSourceLevel {\r\n /** Present for level-type sources */\r\n levelId?: number;\r\n /** Present for level-type sources */\r\n levelKey?: string;\r\n /** Present for module-type sources */\r\n moduleId?: number;\r\n /** Present for module-type sources */\r\n moduleKey?: string;\r\n name: { en?: string; ar?: string; [k: string]: string | undefined };\r\n connectionId: number;\r\n isOptional: boolean;\r\n allowManyToMany: boolean;\r\n supportWeights: boolean;\r\n optionsQuery: {\r\n path: string;\r\n method?: string;\r\n query?: Record<string, unknown>;\r\n };\r\n}\r\n\r\n/**\r\n * Full connection configuration from `field.propertyMetadata.configuration`.\r\n * This is passed as a single input to the component.\r\n */\r\nexport interface SchemaConnectionConfig {\r\n targetLevelId: number;\r\n sourceLevelId?: number;\r\n propertyKey?: string;\r\n valueMode?: string;\r\n sourceLevels: ConnectionSourceLevel[];\r\n payloadTemplate?: { levelId: number; sources: any[] };\r\n sourceItemShape?: Record<string, string>;\r\n}\r\n\r\n/** One selected source in the connection payload */\r\nexport interface ConnectionSource {\r\n sourceLevelId?: number;\r\n sourceLevelDataId?: number;\r\n sourceModuleId?: number;\r\n sourceModuleDataId?: number;\r\n}\r\n\r\n/** The value shape for a connection field */\r\nexport interface ConnectionPayload {\r\n levelId: number;\r\n sources: ConnectionSource[];\r\n}\r\n\r\n/**\r\n * Internal state tracked per source level dropdown.\r\n */\r\nexport interface SourceLevelState {\r\n source: ConnectionSourceLevel;\r\n options: any[];\r\n loading: boolean;\r\n}\r\n\r\n/**\r\n * Read a control value as a payload, accepting the serialized JSON string a\r\n * form load can patch in. {@link SchemaConnectionField.writeValue} and the\r\n * required validator must agree on this: while only `writeValue` parsed, a\r\n * string-valued connection rendered as filled but validated as empty.\r\n */\r\nfunction parseConnectionPayload(value: unknown): ConnectionPayload | null {\r\n if (typeof value === 'string') {\r\n const trimmed = value.trim();\r\n if (!trimmed) return null;\r\n try {\r\n const parsed = JSON.parse(trimmed);\r\n return parsed && typeof parsed === 'object'\r\n ? (parsed as ConnectionPayload)\r\n : null;\r\n } catch {\r\n return null;\r\n }\r\n }\r\n\r\n return (value as ConnectionPayload | null) ?? null;\r\n}\r\n\r\n@Component({\r\n selector: 'mt-schema-connection-field',\r\n standalone: true,\r\n imports: [\r\n FormsModule,\r\n SelectField,\r\n MultiSelectField,\r\n FieldValidation,\r\n Tooltip,\r\n Icon,\r\n ],\r\n templateUrl: './schema-connection-field.html',\r\n styleUrls: ['./schema-connection-field.scss'],\r\n changeDetection: ChangeDetectionStrategy.OnPush,\r\n host: {\r\n class: 'grid gap-1',\r\n },\r\n})\r\nexport class SchemaConnectionField implements ControlValueAccessor, OnInit {\r\n // ============================================================================\r\n // Inputs\r\n // ============================================================================\r\n\r\n readonly label = input<string>('');\r\n readonly placeholder = input<string>('');\r\n readonly readonly = input<boolean>(false);\r\n /**\r\n * Kept for direct-host API compatibility. Dynamic/client forms do not bind\r\n * it; runtime requiredness is defined per source by\r\n * `configuration.sourceLevels[].isOptional`.\r\n */\r\n readonly required = input<boolean>(false);\r\n readonly filter = input<boolean>(true);\r\n\r\n /**\r\n * Full connection configuration object from the API.\r\n * Includes `targetLevelId`, `sourceLevels[]`, `payloadTemplate`, etc.\r\n */\r\n readonly configuration = input.required<SchemaConnectionConfig>();\r\n\r\n /**\r\n * Runtime scope for this field's options queries. When `templateId` is\r\n * present, it is sent as a `templateId` structural filter on every source\r\n * level's `fetch/query` request, scoping the dropdown to the active plan\r\n * instance. Absent means options load unscoped, same as before this input\r\n * existed.\r\n */\r\n readonly runtimeContext = input<SchemaConnectionFieldRuntimeContext | null>(\r\n null,\r\n );\r\n\r\n /**\r\n * Optional HttpContext for API requests (e.g. to set base URL behavior).\r\n */\r\n readonly context = input<HttpContext | undefined>(undefined);\r\n\r\n // ============================================================================\r\n // Internal State\r\n // ============================================================================\r\n\r\n /** The full ConnectionPayload value */\r\n value = signal<ConnectionPayload | null>(null);\r\n disabled = signal<boolean>(false);\r\n\r\n /** Per-source-level state: options + loading */\r\n sourceLevelStates = signal<SourceLevelState[]>([]);\r\n\r\n /** Mutable selections per source level: sourceLevelId -> selected value */\r\n selections: Record<number, any> = {};\r\n\r\n onTouched: () => void = () => {};\r\n onModelChange: (value: ConnectionPayload | null) => void = () => {};\r\n\r\n /**\r\n * Every source whose `isOptional` is false must have at least one selected\r\n * record. The field-level `isRequired` flag is intentionally ignored because\r\n * one Connection property can mix optional and required source levels.\r\n */\r\n private readonly requiredSourcesValidator: ValidatorFn = (\r\n control: AbstractControl,\r\n ): ValidationErrors | null => {\r\n const value = parseConnectionPayload(control.value);\r\n const selectedSources = Array.isArray(value?.sources) ? value.sources : [];\r\n const allRequiredSourcesSelected = this.sourceLevels()\r\n .filter((source) => source.isOptional !== true)\r\n .every((source) => {\r\n const sourceId = this.getSourceId(source);\r\n return selectedSources.some(\r\n (selected) =>\r\n (selected.sourceLevelId ?? selected.sourceModuleId) === sourceId &&\r\n (selected.sourceLevelDataId ?? selected.sourceModuleDataId) != null,\r\n );\r\n });\r\n\r\n return allRequiredSourcesSelected ? null : { required: true };\r\n };\r\n\r\n public ngControl: NgControl | null = null;\r\n private http = inject(HttpClient);\r\n private destroyRef = inject(DestroyRef);\r\n private readonly cdr = inject(ChangeDetectorRef);\r\n private transloco = inject(TranslocoService);\r\n\r\n /** Active UI language, kept reactive so source labels re-resolve on switch. */\r\n private readonly activeLang = toSignal(this.transloco.langChanges$, {\r\n initialValue: this.transloco.getActiveLang(),\r\n });\r\n\r\n /**\r\n * Resolve a source level's display name in the active locale, falling back\r\n * to English, Arabic, then the level/module key.\r\n */\r\n protected resolveSourceName(source: ConnectionSourceLevel): string {\r\n const name = source.name;\r\n return (\r\n name?.[this.activeLang()] ||\r\n name?.en ||\r\n name?.ar ||\r\n source.levelKey ||\r\n source.moduleKey ||\r\n ''\r\n );\r\n }\r\n\r\n /**\r\n * Source levels from configuration.\r\n */\r\n readonly sourceLevels = computed<ConnectionSourceLevel[]>(() => {\r\n return this.configuration()?.sourceLevels ?? [];\r\n });\r\n\r\n /**\r\n * Tooltip for the marker rendered next to every source label — it is what\r\n * tells the user these dropdowns belong to a connection, now that the\r\n * connection's own label no longer occupies a row above them. Reads\r\n * {@link activeLang} so the text re-translates on language switch.\r\n */\r\n readonly connectionHint = computed<string>(() => {\r\n this.activeLang();\r\n return this.transloco.translate('components.schemaConnection.hint');\r\n });\r\n\r\n /**\r\n * Placeholder for a source dropdown: its own source name, matching the label\r\n * above it. Falls back to the field-level placeholder only when the source\r\n * has no resolvable name.\r\n */\r\n protected sourcePlaceholder(source: ConnectionSourceLevel): string {\r\n return (\r\n this.resolveSourceName(source) ||\r\n this.placeholder() ||\r\n this.transloco.translate('components.selectPlaceholder')\r\n );\r\n }\r\n\r\n /**\r\n * Percentage width for each dropdown, evenly divided.\r\n */\r\n readonly dropdownWidth = computed<string>(() => {\r\n const count = this.sourceLevels().length;\r\n if (count <= 0) return '100%';\r\n return `${100 / count}%`;\r\n });\r\n\r\n constructor() {\r\n this.ngControl = inject(NgControl, { self: true, optional: true });\r\n if (this.ngControl) {\r\n this.ngControl.valueAccessor = this;\r\n }\r\n\r\n effect(() => {\r\n const control = this.ngControl?.control;\r\n if (!control) return;\r\n const hasRequiredSources = this.sourceLevels().some(\r\n (source) => source.isOptional !== true,\r\n );\r\n untracked(() => {\r\n if (hasRequiredSources) {\r\n control.addValidators(this.requiredSourcesValidator);\r\n } else {\r\n control.removeValidators(this.requiredSourcesValidator);\r\n }\r\n control.updateValueAndValidity({ emitEvent: false });\r\n });\r\n });\r\n\r\n // Load options for each source level when configuration changes\r\n effect(() => {\r\n const levels = this.sourceLevels();\r\n if (!levels.length) return;\r\n\r\n // Everything below must NOT create signal dependencies,\r\n // only sourceLevels() (→ configuration) should trigger this effect.\r\n untracked(() => {\r\n // Initialize per-source states + selections\r\n this.sourceLevelStates.set(\r\n levels.map((source) => ({\r\n source,\r\n options: [],\r\n loading: false,\r\n })),\r\n );\r\n\r\n for (const source of levels) {\r\n const sourceId = this.getSourceId(source);\r\n if (!(sourceId in this.selections)) {\r\n this.selections[sourceId] = source.allowManyToMany ? [] : null;\r\n }\r\n }\r\n\r\n // Distribute existing value to selections\r\n this.distributeToSelections(this.value());\r\n\r\n // Load options for each source level\r\n for (const source of levels) {\r\n this.loadOptions(source);\r\n }\r\n });\r\n });\r\n }\r\n\r\n /**\r\n * Repaint when the control's own state changes.\r\n *\r\n * `touched` and validity are plain `AbstractControl` state, not signals, and\r\n * this component is `OnPush` — so a host that calls `markAllAsTouched()` on a\r\n * failed submit marked the connection invalid and nothing re-rendered. The\r\n * required message only appeared once the user happened to touch a dropdown,\r\n * which is the one moment they no longer need telling.\r\n *\r\n * `ngOnInit` rather than the constructor: `formControl` / `formControlName`\r\n * only expose `.control` after their first `ngOnChanges`.\r\n */\r\n ngOnInit(): void {\r\n this.ngControl?.control?.events\r\n .pipe(takeUntilDestroyed(this.destroyRef))\r\n .subscribe(() => this.cdr.markForCheck());\r\n }\r\n\r\n // ============================================================================\r\n // Source Level Helpers\r\n // ============================================================================\r\n\r\n /**\r\n * Returns a stable numeric ID for a source regardless of whether it is a\r\n * level (`levelId`) or a module (`moduleId`). Used as the key in `selections`\r\n * and `sourceLevelStates`.\r\n */\r\n protected getSourceId(source: ConnectionSourceLevel): number {\r\n return (source.levelId ?? source.moduleId)!;\r\n }\r\n\r\n /**\r\n * A source that must be selected and is not. Mirrors\r\n * {@link requiredSourcesValidator}, which decides the same thing from the\r\n * control value.\r\n *\r\n * A method, not a computed: `selections` is a plain object that `ngModel`\r\n * mutates in place and carries no signal, so only re-reading it every change\r\n * detection cycle stays truthful.\r\n */\r\n protected isSourceMissing(source: ConnectionSourceLevel): boolean {\r\n if (source.isOptional === true) return false;\r\n\r\n const selected = this.selections[this.getSourceId(source)];\r\n return Array.isArray(selected) ? selected.length === 0 : selected == null;\r\n }\r\n\r\n /**\r\n * The control, but only for the source the message belongs under — every\r\n * other source gets `null` and renders nothing. `mt-field-validation` still\r\n * decides whether to paint: it waits for `touched`.\r\n *\r\n * Field height stays stable because the reserved line moves rather than\r\n * appears. A null control reserves nothing, so exactly one slot is live at a\r\n * time — the missing source's, or {@link unattributedErrorControl}'s below\r\n * the row.\r\n */\r\n protected sourceErrorControl(\r\n source: ConnectionSourceLevel,\r\n ): AbstractControl | null {\r\n return this.isSourceMissing(source)\r\n ? (this.ngControl?.control ?? null)\r\n : null;\r\n }\r\n\r\n /**\r\n * The control, but only while no source owns the failure — a server error on\r\n * a fully selected connection has nowhere else to render. Null as soon as a\r\n * source is missing, so one failure never prints twice.\r\n */\r\n protected unattributedErrorControl(): AbstractControl | null {\r\n const control = this.ngControl?.control ?? null;\r\n if (!control) return null;\r\n\r\n return this.sourceLevels().some((source) => this.isSourceMissing(source))\r\n ? null\r\n : control;\r\n }\r\n\r\n /**\r\n * Builds the `contextKey` for the `fetch/query` request based on source type.\r\n */\r\n private getContextKey(source: ConnectionSourceLevel): string {\r\n return source.levelId != null\r\n ? `level:${source.levelId}`\r\n : `module:${source.moduleId}`;\r\n }\r\n\r\n // ============================================================================\r\n // Option Loading (per source level)\r\n // ============================================================================\r\n\r\n private loadOptions(source: ConnectionSourceLevel): void {\r\n this.updateSourceState(this.getSourceId(source), { loading: true });\r\n\r\n const ctx = this.context();\r\n const templateId = this.runtimeContext()?.templateId;\r\n const payload = {\r\n contextKey: this.getContextKey(source),\r\n projection: 'Flat',\r\n propertyKeys: ['name'],\r\n ...(templateId != null\r\n ? {\r\n filters: [\r\n {\r\n key: 'templateId',\r\n operator: 'Equals',\r\n value: String(templateId),\r\n },\r\n ],\r\n }\r\n : {}),\r\n };\r\n\r\n this.http\r\n .post<unknown>('fetch/query', payload, {\r\n ...(ctx ? { context: ctx } : {}),\r\n })\r\n .pipe(\r\n takeUntilDestroyed(this.destroyRef),\r\n finalize(() =>\r\n this.updateSourceState(this.getSourceId(source), { loading: false }),\r\n ),\r\n catchError((err) => {\r\n console.error(\r\n `Connection options load failed for ${source.levelKey ?? source.moduleKey}:`,\r\n err,\r\n );\r\n return of({ data: { records: [] } });\r\n }),\r\n )\r\n .subscribe((response: any) => {\r\n const options = (response?.data?.records ?? [])\r\n .filter((record: any) => record?.id != null)\r\n .map((record: any) => ({\r\n ...record,\r\n id: record.id,\r\n name: record.name,\r\n }));\r\n\r\n this.updateSourceState(this.getSourceId(source), {\r\n options,\r\n loading: false,\r\n });\r\n });\r\n }\r\n\r\n private updateSourceState(\r\n sourceId: number,\r\n patch: Partial<Pick<SourceLevelState, 'options' | 'loading'>>,\r\n ): void {\r\n this.sourceLevelStates.update((states) =>\r\n states.map((s) =>\r\n this.getSourceId(s.source) === sourceId ? { ...s, ...patch } : s,\r\n ),\r\n );\r\n }\r\n\r\n // ============================================================================\r\n // Value Handling\r\n // ============================================================================\r\n\r\n /**\r\n * Single handler — no params. Reads all selections, builds the combined payload.\r\n */\r\n syncValue(): void {\r\n const cfg = this.configuration();\r\n const states = this.sourceLevelStates();\r\n const sources: ConnectionSource[] = [];\r\n\r\n for (const state of states) {\r\n const val = this.selections[this.getSourceId(state.source)];\r\n if (val == null) continue;\r\n\r\n const effectiveId = this.getSourceId(state.source);\r\n if (state.source.allowManyToMany && Array.isArray(val)) {\r\n for (const id of val) {\r\n sources.push({\r\n sourceLevelId: effectiveId,\r\n sourceLevelDataId: id,\r\n });\r\n }\r\n } else if (typeof val === 'number') {\r\n sources.push({\r\n sourceLevelId: effectiveId,\r\n sourceLevelDataId: val,\r\n });\r\n }\r\n }\r\n\r\n const payload: ConnectionPayload | null =\r\n sources.length > 0 ? { levelId: cfg.targetLevelId, sources } : null;\r\n\r\n this.value.set(payload);\r\n this.onModelChange(payload);\r\n this.onTouched();\r\n }\r\n\r\n private distributeToSelections(payload: ConnectionPayload | null): void {\r\n const states = this.sourceLevelStates();\r\n for (const state of states) {\r\n const sourceId = this.getSourceId(state.source);\r\n const ids = (payload?.sources ?? [])\r\n .filter((s) => (s.sourceLevelId ?? s.sourceModuleId) === sourceId)\r\n .map((s) => s.sourceLevelDataId ?? s.sourceModuleDataId)\r\n .filter((id): id is number => id != null);\r\n\r\n this.selections[sourceId] = state.source.allowManyToMany\r\n ? ids\r\n : (ids[0] ?? null);\r\n }\r\n }\r\n\r\n // ============================================================================\r\n // ControlValueAccessor\r\n // ============================================================================\r\n\r\n writeValue(value: ConnectionPayload | string | null): void {\r\n const payload = parseConnectionPayload(value);\r\n this.value.set(payload);\r\n this.distributeToSelections(payload);\r\n }\r\n\r\n registerOnChange(fn: (value: ConnectionPayload | null) => void): void {\r\n this.onModelChange = fn;\r\n }\r\n\r\n registerOnTouched(fn: any): void {\r\n this.onTouched = fn;\r\n }\r\n\r\n setDisabledState(disabled: boolean): void {\r\n this.disabled.set(disabled);\r\n }\r\n}\r\n","<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→control 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 — 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","import { CommonModule } from '@angular/common';\r\nimport {\r\n ChangeDetectionStrategy,\r\n Component,\r\n computed,\r\n DestroyRef,\r\n effect,\r\n inject,\r\n input,\r\n linkedSignal,\r\n signal,\r\n TemplateRef,\r\n untracked,\r\n viewChild,\r\n} from '@angular/core';\r\nimport { takeUntilDestroyed, toSignal } from '@angular/core/rxjs-interop';\r\nimport {\r\n ControlValueAccessor,\r\n FormsModule,\r\n NgControl,\r\n Validators,\r\n} from '@angular/forms';\r\nimport { HttpClient } from '@angular/common/http';\r\nimport { catchError, finalize, of } from 'rxjs';\r\nimport { TranslocoModule, TranslocoService } from '@jsverse/transloco';\r\nimport { Button } from '@masterteam/components/button';\r\nimport { FieldValidation } from '@masterteam/components/field-validation';\r\nimport { NumberField } from '@masterteam/components/number-field';\r\nimport { SelectField } from '@masterteam/components/select-field';\r\nimport {\r\n Table,\r\n type ColumnDef,\r\n type TableAction,\r\n} from '@masterteam/components/table';\r\nimport type { SchedulePredecessorFieldRuntimeContext } from '@masterteam/components';\r\nimport { newFieldId } from '@masterteam/components';\r\n\r\ntype PredecessorType = 0 | 1 | 2 | 3;\r\ntype PredecessorTypeToken = 'FS' | 'SS' | 'FF' | 'SF';\r\n\r\ninterface ScheduleQueryRecord {\r\n id: number | string;\r\n name?: string | null;\r\n children?: ScheduleQueryRecord[] | null;\r\n}\r\n\r\ninterface ScheduleQueryData {\r\n records?: ScheduleQueryRecord[] | null;\r\n projectionMeta?: {\r\n rootIds?: Array<number | string> | null;\r\n } | null;\r\n}\r\n\r\ninterface ScheduleQueryResponse {\r\n data?: ScheduleQueryData | null;\r\n}\r\n\r\ninterface SchedulePredecessorValue {\r\n predecessorId: number | string;\r\n type: PredecessorType;\r\n lagDays: number;\r\n}\r\n\r\ninterface SchedulePredecessorRow extends SchedulePredecessorValue {\r\n key: string;\r\n}\r\n\r\ninterface SelectOption {\r\n label: string;\r\n value: number | string;\r\n}\r\n\r\nconst PREDECESSOR_TYPE_BY_TOKEN: Record<PredecessorTypeToken, PredecessorType> =\r\n {\r\n FS: 0,\r\n SS: 1,\r\n FF: 2,\r\n SF: 3,\r\n };\r\n\r\nconst PREDECESSOR_TOKEN_BY_TYPE: Record<PredecessorType, PredecessorTypeToken> =\r\n {\r\n 0: 'FS',\r\n 1: 'SS',\r\n 2: 'FF',\r\n 3: 'SF',\r\n };\r\n\r\n@Component({\r\n selector: 'mt-schedule-predecessor-field',\r\n standalone: true,\r\n imports: [\r\n CommonModule,\r\n FormsModule,\r\n Button,\r\n FieldValidation,\r\n NumberField,\r\n SelectField,\r\n Table,\r\n TranslocoModule,\r\n ],\r\n templateUrl: './schedule-predecessor-field.html',\r\n changeDetection: ChangeDetectionStrategy.OnPush,\r\n host: {\r\n class: 'grid gap-1',\r\n },\r\n})\r\nexport class SchedulePredecessorField implements ControlValueAccessor {\r\n private readonly predecessorCellTpl =\r\n viewChild.required<TemplateRef<any>>('predecessorCellTpl');\r\n private readonly typeCellTpl =\r\n viewChild.required<TemplateRef<any>>('typeCellTpl');\r\n private readonly lagCellTpl =\r\n viewChild.required<TemplateRef<any>>('lagCellTpl');\r\n\r\n readonly label = input<string>('');\r\n\r\n /** Unique; shared by the control and its <label for>. See src/lib/utils/field-id. */\r\n readonly fieldId = newFieldId('mt-schedule-predecessor-field');\r\n readonly placeholder = input<string>('');\r\n readonly readonly = input<boolean>(false);\r\n readonly required = input<boolean>(false);\r\n readonly configuration = input<unknown>(null);\r\n readonly runtimeContext =\r\n input<SchedulePredecessorFieldRuntimeContext | null>(null);\r\n\r\n readonly loading = signal(false);\r\n readonly taskOptions = signal<SelectOption[]>([]);\r\n readonly rows = signal<SchedulePredecessorRow[]>([]);\r\n readonly disabled = signal(false);\r\n\r\n readonly typeOptions = computed<SelectOption[]>(() => [\r\n { label: 'FS', value: 0 },\r\n { label: 'SS', value: 1 },\r\n { label: 'FF', value: 2 },\r\n { label: 'SF', value: 3 },\r\n ]);\r\n\r\n readonly availableTaskOptions = computed(() => {\r\n const currentTaskId = this.runtimeContext()?.moduleDataId;\r\n return this.taskOptions().filter(\r\n (item) => String(item.value) !== String(currentTaskId ?? ''),\r\n );\r\n });\r\n\r\n readonly canAddRow = computed(\r\n () =>\r\n !!this.runtimeContext()?.levelId &&\r\n !!this.runtimeContext()?.levelDataId &&\r\n this.availableTaskOptions().length > 0,\r\n );\r\n\r\n readonly addTooltip = computed(() =>\r\n this.canAddRow() ? undefined : this.texts().noAvailable,\r\n );\r\n readonly pageSize = computed(() =>\r\n this.rows().length > 0 ? this.rows().length : 1,\r\n );\r\n\r\n readonly columns = linkedSignal<ColumnDef[]>(() => [\r\n {\r\n key: 'predecessorId',\r\n label: this.texts().predecessor,\r\n type: 'custom',\r\n customCellTpl: this.predecessorCellTpl(),\r\n },\r\n {\r\n key: 'type',\r\n label: this.texts().type,\r\n type: 'custom',\r\n customCellTpl: this.typeCellTpl(),\r\n },\r\n {\r\n key: 'lagDays',\r\n label: this.texts().lagDays,\r\n type: 'custom',\r\n customCellTpl: this.lagCellTpl(),\r\n },\r\n ]);\r\n\r\n readonly rowActions = computed<TableAction[]>(() => [\r\n {\r\n icon: 'general.trash-01',\r\n color: 'danger',\r\n variant: 'text',\r\n tooltip: this.texts().delete,\r\n hidden: () => this.disabled() || this.readonly(),\r\n action: (row) => this.removeRow(row.key),\r\n },\r\n ]);\r\n\r\n requiredValidator = Validators.required;\r\n onTouched: () => void = () => {};\r\n onModelChange: (value: string | null) => void = () => {};\r\n\r\n public ngControl: NgControl | null = null;\r\n\r\n private readonly http = inject(HttpClient);\r\n private readonly transloco = inject(TranslocoService);\r\n private readonly destroyRef = inject(DestroyRef);\r\n private readonly activeLang = toSignal(this.transloco.langChanges$, {\r\n initialValue: this.transloco.getActiveLang(),\r\n });\r\n private rowKey = 0;\r\n\r\n readonly texts = computed(() => {\r\n this.activeLang();\r\n\r\n return {\r\n noAvailable: this.transloco.translate(\r\n 'components.schedulePredecessorField.noAvailable',\r\n ),\r\n predecessor: this.transloco.translate(\r\n 'components.schedulePredecessorField.predecessor',\r\n ),\r\n type: this.transloco.translate(\r\n 'components.schedulePredecessorField.type',\r\n ),\r\n lagDays: this.transloco.translate(\r\n 'components.schedulePredecessorField.lagDays',\r\n ),\r\n delete: this.transloco.translate(\r\n 'components.schedulePredecessorField.delete',\r\n ),\r\n };\r\n });\r\n\r\n constructor() {\r\n this.ngControl = inject(NgControl, { self: true, optional: true });\r\n if (this.ngControl) {\r\n this.ngControl.valueAccessor = this;\r\n }\r\n\r\n effect(() => {\r\n if (this.ngControl?.control && this.required()) {\r\n this.ngControl.control.addValidators(Validators.required);\r\n this.ngControl.control.updateValueAndValidity();\r\n }\r\n });\r\n\r\n effect(() => {\r\n const context = this.runtimeContext();\r\n const levelId = context?.levelId;\r\n const levelDataId = context?.levelDataId;\r\n\r\n if (levelId == null || levelDataId == null) {\r\n this.taskOptions.set([]);\r\n return;\r\n }\r\n\r\n untracked(() => this.loadTaskOptions(levelId, levelDataId));\r\n });\r\n }\r\n\r\n addRow(): void {\r\n if (this.disabled() || this.readonly() || !this.canAddRow()) {\r\n return;\r\n }\r\n\r\n this.syncRows([\r\n ...this.rows(),\r\n {\r\n key: this.nextRowKey(),\r\n predecessorId: '',\r\n type: 0,\r\n lagDays: 0,\r\n },\r\n ]);\r\n }\r\n\r\n removeRow(key: string): void {\r\n if (this.disabled() || this.readonly()) {\r\n return;\r\n }\r\n\r\n this.syncRows(this.rows().filter((row) => row.key !== key));\r\n }\r\n\r\n updateRow(key: string, patch: Partial<SchedulePredecessorRow>): void {\r\n if (this.disabled() || this.readonly()) {\r\n return;\r\n }\r\n\r\n this.syncRows(\r\n this.rows().map((row) => (row.key === key ? { ...row, ...patch } : row)),\r\n );\r\n }\r\n\r\n writeValue(value: unknown): void {\r\n const rows =\r\n typeof value === 'string'\r\n ? value\r\n .split(',')\r\n .map((item) => item.trim())\r\n .filter(Boolean)\r\n .map((item) => this.parseCompactValue(item))\r\n .filter((item): item is SchedulePredecessorValue => item != null)\r\n .map((item) => ({\r\n key: this.nextRowKey(),\r\n ...item,\r\n }))\r\n : [];\r\n\r\n this.rows.set(rows);\r\n }\r\n\r\n registerOnChange(fn: (value: string | null) => void): void {\r\n this.onModelChange = fn;\r\n }\r\n\r\n registerOnTouched(fn: () => void): void {\r\n this.onTouched = fn;\r\n }\r\n\r\n setDisabledState(disabled: boolean): void {\r\n this.disabled.set(disabled);\r\n }\r\n\r\n private syncRows(rows: SchedulePredecessorRow[]): void {\r\n this.rows.set(rows);\r\n const value = rows\r\n .filter(\r\n (row) =>\r\n row.predecessorId !== null &&\r\n row.predecessorId !== undefined &&\r\n String(row.predecessorId).trim() !== '',\r\n )\r\n .map((row) => this.formatCompactValue(row))\r\n .join(',');\r\n\r\n this.onModelChange(value || null);\r\n this.onTouched();\r\n }\r\n\r\n private loadTaskOptions(\r\n levelId: number | string,\r\n levelDataId: number | string,\r\n ): void {\r\n this.loading.set(true);\r\n\r\n this.http\r\n .post<ScheduleQueryResponse>(\r\n `levels/${levelId}/${levelDataId}/schedule/query`,\r\n {\r\n projection: 'Tree',\r\n propertyKeys: ['name'],\r\n },\r\n )\r\n .pipe(\r\n takeUntilDestroyed(this.destroyRef),\r\n finalize(() => this.loading.set(false)),\r\n catchError(() => of({ data: { records: [] } })),\r\n )\r\n .subscribe((response) => {\r\n this.taskOptions.set(this.mapTaskOptions(response.data));\r\n });\r\n }\r\n\r\n private mapTaskOptions(\r\n data: ScheduleQueryData | null | undefined,\r\n ): SelectOption[] {\r\n // Labels show the ROW NUMBER (1-based position in the same pre-order walk\r\n // the grid's ID column numbers), not the backend id — the two surfaces\r\n // must speak one coordinate. The option VALUE stays the real id: the\r\n // compact predecessor string this field produces is wire format.\r\n return this.flattenRecords(\r\n this.resolveRootRecords(\r\n data?.records ?? [],\r\n data?.projectionMeta?.rootIds ?? [],\r\n ),\r\n ).map((record, index) => ({\r\n label: `${index + 1} - ${record.name ?? record.id}`,\r\n value: String(record.id),\r\n }));\r\n }\r\n\r\n private resolveRootRecords(\r\n records: ScheduleQueryRecord[],\r\n rootIds: Array<number | string> | null | undefined,\r\n ): ScheduleQueryRecord[] {\r\n if (!rootIds?.length) {\r\n return records;\r\n }\r\n\r\n const recordsById = new Map(\r\n records.map((record) => [String(record.id), record]),\r\n );\r\n\r\n return rootIds\r\n .map((id) => recordsById.get(String(id)))\r\n .filter((record): record is ScheduleQueryRecord => record != null);\r\n }\r\n\r\n private flattenRecords(\r\n records: ScheduleQueryRecord[],\r\n ): ScheduleQueryRecord[] {\r\n const output: ScheduleQueryRecord[] = [];\r\n\r\n const walk = (items: ScheduleQueryRecord[]): void => {\r\n items.forEach((item) => {\r\n output.push(item);\r\n walk(item.children ?? []);\r\n });\r\n };\r\n\r\n walk(records);\r\n return output;\r\n }\r\n\r\n private nextRowKey(): string {\r\n this.rowKey += 1;\r\n return `predecessor-${this.rowKey}`;\r\n }\r\n\r\n private parseCompactValue(value: string): SchedulePredecessorValue | null {\r\n const match = value.match(/^(.+?)(FS|SS|FF|SF)([+-]\\d+)?$/);\r\n\r\n if (!match) {\r\n return null;\r\n }\r\n\r\n return {\r\n predecessorId: match[1],\r\n type: PREDECESSOR_TYPE_BY_TOKEN[match[2] as PredecessorTypeToken],\r\n lagDays: match[3] ? Number(match[3]) : 0,\r\n };\r\n }\r\n\r\n private formatCompactValue(row: SchedulePredecessorValue): string {\r\n const lag =\r\n row.lagDays > 0 ? `+${row.lagDays}` : row.lagDays < 0 ? row.lagDays : '';\r\n\r\n return `${row.predecessorId}${PREDECESSOR_TOKEN_BY_TYPE[row.type]}${lag}`;\r\n }\r\n}\r\n","<div class=\"gap-3 overflow-auto\">\r\n <div class=\"flex items-center justify-between mb-2\">\r\n <div>\r\n @if (label()) {\r\n <label\r\n [class.required]=\"ngControl?.control?.hasValidator(requiredValidator)\"\r\n [for]=\"fieldId\"\r\n >\r\n {{ label() }}\r\n </label>\r\n }\r\n </div>\r\n <mt-button\r\n icon=\"general.plus\"\r\n [label]=\"'components.schedulePredecessorField.add' | transloco\"\r\n severity=\"secondary\"\r\n variant=\"outlined\"\r\n size=\"small\"\r\n [disabled]=\"disabled() || readonly() || !canAddRow()\"\r\n [tooltip]=\"addTooltip()\"\r\n (onClick)=\"addRow()\"\r\n />\r\n </div>\r\n\r\n <ng-template #predecessorCellTpl let-row>\r\n <mt-select-field\r\n [field]=\"false\"\r\n [options]=\"availableTaskOptions()\"\r\n optionLabel=\"label\"\r\n optionValue=\"value\"\r\n [placeholder]=\"\r\n placeholder() ||\r\n ('components.schedulePredecessorField.selectPredecessor' | transloco)\r\n \"\r\n [filter]=\"true\"\r\n [showClear]=\"true\"\r\n [loading]=\"loading()\"\r\n [readonly]=\"disabled() || readonly()\"\r\n [ngModel]=\"row.predecessorId || undefined\"\r\n (onChange)=\"updateRow(row.key, { predecessorId: $event ?? '' })\"\r\n />\r\n </ng-template>\r\n\r\n <ng-template #typeCellTpl let-row>\r\n <mt-select-field\r\n [field]=\"false\"\r\n [options]=\"typeOptions()\"\r\n optionLabel=\"label\"\r\n optionValue=\"value\"\r\n [readonly]=\"disabled() || readonly()\"\r\n [ngModel]=\"row.type\"\r\n (onChange)=\"updateRow(row.key, { type: $event ?? 0 })\"\r\n />\r\n </ng-template>\r\n\r\n <ng-template #lagCellTpl let-row>\r\n <mt-number-field\r\n [field]=\"false\"\r\n [useGrouping]=\"false\"\r\n [placeholder]=\"'components.schedulePredecessorField.lagDays' | transloco\"\r\n [readonly]=\"disabled() || readonly()\"\r\n [ngModel]=\"row.lagDays\"\r\n (ngModelChange)=\"updateRow(row.key, { lagDays: $event ?? 0 })\"\r\n />\r\n </ng-template>\r\n\r\n <mt-table\r\n noCard\r\n [data]=\"rows()\"\r\n [columns]=\"columns()\"\r\n [rowActions]=\"rowActions()\"\r\n [pageSize]=\"pageSize()\"\r\n [generalSearch]=\"false\"\r\n [showFilters]=\"false\"\r\n [dataKey]=\"'key'\"\r\n storageKey=\"schedule-predecessor-field-table\"\r\n [loading]=\"loading()\"\r\n >\r\n <ng-template #empty>\r\n <div\r\n class=\"rounded-xl border border-dashed border-surface px-4 py-5 text-sm text-muted-color\"\r\n >\r\n {{ \"components.schedulePredecessorField.empty\" | transloco }}\r\n </div>\r\n </ng-template>\r\n </mt-table>\r\n</div>\r\n\r\n<mt-field-validation [control]=\"ngControl?.control\"></mt-field-validation>\r\n","import { InjectionToken, Type } from '@angular/core';\r\nimport type {\r\n EntityListLocalCell,\r\n EntityListLocalSchemaField,\r\n} from '@masterteam/components/entities';\r\n\r\n/** Inputs the EntityList add-row dialog will receive via ModalService inputValues. */\r\nexport interface EntityListAddDialogInputs {\r\n moduleId: number | string | null;\r\n levelId: number | string | null;\r\n levelDataId: number | string | null;\r\n /** Property keys that should be editable in the dialog. */\r\n writeFields: string[];\r\n /**\r\n * Host form's lookup catalog. The dialog's nested form needs it to resolve\r\n * options for the target module's `Lookup` / `LookupMultiSelect` fields.\r\n */\r\n lookups?: unknown[];\r\n /** Pre-populated form values (keyed by property key) for the Edit flow. */\r\n initialValues?: Record<string, unknown>;\r\n /** True when the dialog edits an existing row rather than adding one. */\r\n isEdit?: boolean;\r\n}\r\n\r\n/**\r\n * Token used by `mt-entity-list-field` (Write mode) to open the rich add-row\r\n * dialog backed by `@masterteam/forms`'s `mt-client-form`. Apps that want this\r\n * behavior should call `provideEntityListAddForm()` from\r\n * `@masterteam/forms/entity-list-add-form` in their app providers. When the\r\n * token is not registered, the field falls back to a minimal text-only popup.\r\n */\r\nexport const ENTITY_LIST_ADD_DIALOG_COMPONENT = new InjectionToken<\r\n Type<unknown>\r\n>('ENTITY_LIST_ADD_DIALOG_COMPONENT');\r\n\r\n/**\r\n * Inputs the Local row dialog receives via `ModalService` `inputValues`.\r\n *\r\n * A Local list (`storageMode: \"Local\"`) has no source form to load: its rows\r\n * belong to the parent record, and the source module only lent its field\r\n * definitions, which the published schema captured. So the dialog is built\r\n * from `fields` — never from `process-form-load` of the source module, which\r\n * may not even be mapped to this level.\r\n */\r\nexport interface EntityListLocalRowDialogInputs {\r\n /** Visible schema fields, in order, each with its captured definition. */\r\n fields: EntityListLocalSchemaField[];\r\n /** Host form's lookup catalog, for `Lookup` / `LookupMultiSelect` fields. */\r\n lookups?: unknown[];\r\n /**\r\n * The loaded cells of the row being edited, by field id. Each is mapped the\r\n * way a top-level form maps a loaded value (a `User` from its rendered\r\n * object, a `Checkbox` from its stored text …).\r\n */\r\n initialCells?: Record<string, EntityListLocalCell>;\r\n /** Control values from this session, by field id; win over `initialCells`. */\r\n initialValues?: Record<string, unknown>;\r\n isEdit?: boolean;\r\n}\r\n\r\n/**\r\n * Close payload of the Local row dialog, keyed by field id. Same three maps as\r\n * the linked dialog: `values` refills the form, `display` renders option\r\n * labels, and `submit` is each value reduced to the scalar the backend\r\n * stores — the field only serializes it.\r\n */\r\nexport interface EntityListLocalRowDialogResult {\r\n values: Record<string, unknown>;\r\n display: Record<string, unknown>;\r\n submit: Record<string, unknown>;\r\n}\r\n\r\n/**\r\n * Local counterpart of `ENTITY_LIST_ADD_DIALOG_COMPONENT`, registered by the\r\n * same `provideEntityListAddForm()`. Without it a Local list is read-only.\r\n */\r\nexport const ENTITY_LIST_LOCAL_ROW_DIALOG_COMPONENT = new InjectionToken<\r\n Type<unknown>\r\n>('ENTITY_LIST_LOCAL_ROW_DIALOG_COMPONENT');\r\n","import {\r\n sortLocalRows,\r\n type EntityListLocalDocument,\r\n type EntityListLocalRow,\r\n} from '@masterteam/components/entities';\r\n\r\n/**\r\n * Editing state of a Local `EntityList` (`storageMode: \"Local\"`) and the\r\n * mutation it produces. Pure functions over plain objects, so the rules the\r\n * backend enforces are tested without a TestBed. The contract is the \"Submit\r\n * rows through the parent process\" table of\r\n * `.github/instructions/properties/EntityList.md`.\r\n */\r\n\r\n/** What the user did to one row in this session. */\r\nexport interface LocalRowDraft {\r\n /**\r\n * Serialized cell values, by field id — the wire format. On an existing row\r\n * only the cells that differ from the loaded ones; `null` clears a cell.\r\n */\r\n cells: Record<string, string | null>;\r\n /** Control values, by field id, to refill the dialog on the next edit. */\r\n values: Record<string, unknown>;\r\n /** Resolved option labels, by field id, so the table can print the row. */\r\n display: Record<string, unknown>;\r\n}\r\n\r\n/** A row added in this session. Its id is final: rows are client-keyed. */\r\nexport interface LocalCreatedRow {\r\n rowId: string;\r\n draft: LocalRowDraft;\r\n}\r\n\r\nexport interface LocalEditorState {\r\n /**\r\n * The projected document the form loaded — current list and row versions,\r\n * rendered cells and the schema they were projected against. Null before\r\n * the parent's list was ever saved (a create form, or a record that has\r\n * never had rows).\r\n */\r\n base: EntityListLocalDocument | null;\r\n created: LocalCreatedRow[];\r\n /** Edits of loaded rows, by row id. */\r\n edited: Record<string, LocalRowDraft>;\r\n /** Loaded rows the user removed. */\r\n deleted: string[];\r\n /** Row ids in the order the user dragged them into; null until they do. */\r\n order: string[] | null;\r\n /**\r\n * The mutation id of the last emitted payload, and that payload's content.\r\n * A retry of an unchanged save must reuse the id — the backend treats the\r\n * same id with the same content as the same save — and any change of\r\n * content is a new logical save that needs a new one.\r\n */\r\n mutationId: string | null;\r\n mutationKey: string | null;\r\n}\r\n\r\nexport function createLocalEditorState(\r\n base: EntityListLocalDocument | null,\r\n): LocalEditorState {\r\n return {\r\n base,\r\n created: [],\r\n edited: {},\r\n deleted: [],\r\n order: null,\r\n mutationId: null,\r\n mutationKey: null,\r\n };\r\n}\r\n\r\n/** One rendered row, in display order, with the order it would be saved at. */\r\nexport interface LocalOrderedRow {\r\n rowId: string;\r\n order: number;\r\n existing?: EntityListLocalRow;\r\n created?: LocalCreatedRow;\r\n}\r\n\r\n/**\r\n * Rows in display order. Until the user reorders, loaded rows keep their\r\n * stored `order` and new rows go after the last one. After a reorder every row\r\n * takes its position — the backend requires a non-negative order and nothing\r\n * more, so positions are the simplest valid numbering.\r\n */\r\nexport function orderLocalRows(state: LocalEditorState): LocalOrderedRow[] {\r\n const deleted = new Set(state.deleted);\r\n const loaded = sortLocalRows(state.base?.localRows).filter(\r\n (row) => !deleted.has(row.rowId),\r\n );\r\n const maxOrder = loaded.reduce(\r\n (max, row) => Math.max(max, row.order ?? 0),\r\n -1,\r\n );\r\n\r\n const rows: LocalOrderedRow[] = [\r\n ...loaded.map((row) => ({\r\n rowId: row.rowId,\r\n order: row.order ?? 0,\r\n existing: row,\r\n })),\r\n ...state.created.map((row, index) => ({\r\n rowId: row.rowId,\r\n order: maxOrder + 1 + index,\r\n created: row,\r\n })),\r\n ];\r\n\r\n if (!state.order) return rows;\r\n\r\n const position = new Map(state.order.map((rowId, index) => [rowId, index]));\r\n return rows\r\n .map((row, index) => ({ row, index }))\r\n .sort(\r\n (a, b) =>\r\n (position.get(a.row.rowId) ?? state.order!.length + a.index) -\r\n (position.get(b.row.rowId) ?? state.order!.length + b.index),\r\n )\r\n .map(({ row }, index) => ({ ...row, order: index }));\r\n}\r\n\r\n/** The writable part of a Local mutation. */\r\nexport interface LocalMutationContent {\r\n localRows: {\r\n rowId: string;\r\n order: number;\r\n version: number;\r\n cells: { fieldId: string; rawValue: string | null }[];\r\n }[];\r\n deletedRowIds: string[];\r\n}\r\n\r\n/**\r\n * What changed, or null when nothing did.\r\n *\r\n * - A loaded row is sent only when a cell or its order changed, with its\r\n * loaded version and only those cells: omission retains a cell or a row, it\r\n * never deletes one. A reorder alone sends no cells.\r\n * - A new row is sent with version 0 and every cell the user filled in.\r\n * - A removed row is listed in `deletedRowIds` and never also submitted.\r\n */\r\nexport function buildLocalMutationContent(\r\n state: LocalEditorState,\r\n): LocalMutationContent | null {\r\n const localRows: LocalMutationContent['localRows'] = [];\r\n\r\n for (const row of orderLocalRows(state)) {\r\n if (row.existing) {\r\n const cells = toCells(state.edited[row.rowId]?.cells ?? {});\r\n if (!cells.length && row.order === (row.existing.order ?? 0)) continue;\r\n localRows.push({\r\n rowId: row.rowId,\r\n order: row.order,\r\n version: row.existing.version ?? 0,\r\n cells,\r\n });\r\n continue;\r\n }\r\n\r\n localRows.push({\r\n rowId: row.rowId,\r\n order: row.order,\r\n version: 0,\r\n cells: toCells(row.created?.draft.cells ?? {}).filter(\r\n (cell) => cell.rawValue !== null,\r\n ),\r\n });\r\n }\r\n\r\n if (!localRows.length && !state.deleted.length) return null;\r\n return { localRows, deletedRowIds: [...state.deleted] };\r\n}\r\n\r\nfunction toCells(\r\n cells: Record<string, string | null>,\r\n): { fieldId: string; rawValue: string | null }[] {\r\n return Object.entries(cells).map(([fieldId, rawValue]) => ({\r\n fieldId,\r\n rawValue,\r\n }));\r\n}\r\n\r\n/**\r\n * The cells of an edited loaded row that differ from what was loaded.\r\n * Setting a cell back to its loaded value drops it, so an edit that is undone\r\n * by hand stops being an edit.\r\n */\r\nexport function diffLocalCells(\r\n loaded: EntityListLocalRow,\r\n next: Record<string, string | null>,\r\n): Record<string, string | null> {\r\n const before = new Map(\r\n (loaded.cells ?? []).map((cell) => [cell.fieldId, cell.rawValue ?? null]),\r\n );\r\n const changed: Record<string, string | null> = {};\r\n for (const [fieldId, rawValue] of Object.entries(next)) {\r\n if ((before.get(fieldId) ?? null) === rawValue) continue;\r\n changed[fieldId] = rawValue;\r\n }\r\n return changed;\r\n}\r\n\r\n/**\r\n * A v4 UUID. Row ids and mutation ids are parsed as GUIDs by the backend.\r\n * `crypto.randomUUID` exists only in secure contexts, and these apps are also\r\n * served over plain HTTP, where `getRandomValues` is still available.\r\n */\r\nexport function newLocalUuid(): string {\r\n if (typeof crypto.randomUUID === 'function') return crypto.randomUUID();\r\n const bytes = crypto.getRandomValues(new Uint8Array(16));\r\n bytes[6] = (bytes[6] & 0x0f) | 0x40;\r\n bytes[8] = (bytes[8] & 0x3f) | 0x80;\r\n const hex = Array.from(bytes, (byte) => byte.toString(16).padStart(2, '0'));\r\n return [\r\n hex.slice(0, 4).join(''),\r\n hex.slice(4, 6).join(''),\r\n hex.slice(6, 8).join(''),\r\n hex.slice(8, 10).join(''),\r\n hex.slice(10, 16).join(''),\r\n ].join('-');\r\n}\r\n","import type {\r\n EntityListSelectionDocument,\r\n EntityListSelectionRecord,\r\n} from '@masterteam/components/entities';\r\n\r\n/**\r\n * Pure editing state of a Selected `EntityList` (`recordMode: \"Selected\"`) —\r\n * which source records the parent holds — and the value it submits. Kept out\r\n * of the component so the submission rules are tested without rendering. See\r\n * `.github/instructions/properties/EntityList.md`.\r\n */\r\n\r\n/** A record the user picked, as the picker listed it. */\r\nexport interface SelectionPick {\r\n id: number;\r\n name: string;\r\n /**\r\n * The option's display values (`metadataJson`), when the backend sent them:\r\n * current candidate data, shown until the parent is saved — never evidence,\r\n * and never submitted.\r\n */\r\n record?: EntityListSelectionRecord | null;\r\n}\r\n\r\n/**\r\n * The display record an option carries in `metadataJson` — a JSON string\r\n * holding `{ entityId, values }`, the shape of a projected `records` entry.\r\n * Null when absent (an older backend), unparsable, or for another record.\r\n */\r\nexport function parseOptionRecord(\r\n metadataJson: unknown,\r\n id: number,\r\n): EntityListSelectionRecord | null {\r\n if (typeof metadataJson !== 'string' || !metadataJson.trim()) return null;\r\n try {\r\n const parsed = JSON.parse(\r\n metadataJson,\r\n ) as Partial<EntityListSelectionRecord>;\r\n if (Number(parsed?.entityId) !== id || !Array.isArray(parsed?.values)) {\r\n return null;\r\n }\r\n return { entityId: id, values: parsed.values };\r\n } catch {\r\n return null;\r\n }\r\n}\r\n\r\nexport interface SelectionEditorState {\r\n /**\r\n * The value as it arrived: the projection `process-form-load` returns\r\n * (`records` rendered, `version` to save against), or a mutation the form\r\n * already held. Null for a list that was never saved.\r\n */\r\n base: EntityListSelectionDocument | null;\r\n /** The selected record ids, in display order. */\r\n ids: number[];\r\n /**\r\n * Names of records picked in this session — what shows when the picker\r\n * sent no display values.\r\n */\r\n names: Record<number, string>;\r\n /**\r\n * Display values of records picked in this session, from the picker's\r\n * option metadata. Only for new picks: a loaded record keeps the values the\r\n * backend rendered for it.\r\n */\r\n records: Record<number, EntityListSelectionRecord>;\r\n /** Kept while the content is unchanged, so a retry reuses it. */\r\n mutationId: string | null;\r\n mutationKey: string | null;\r\n}\r\n\r\nexport function createSelectionEditorState(\r\n base: EntityListSelectionDocument | null,\r\n): SelectionEditorState {\r\n return {\r\n base,\r\n ids: positiveIds(base?.entityIds),\r\n names: {},\r\n records: {},\r\n mutationId: null,\r\n mutationKey: null,\r\n };\r\n}\r\n\r\nfunction positiveIds(ids: readonly unknown[] | null | undefined): number[] {\r\n const out: number[] = [];\r\n for (const entry of ids ?? []) {\r\n const id = Number(entry);\r\n if (Number.isInteger(id) && id > 0 && !out.includes(id)) out.push(id);\r\n }\r\n return out;\r\n}\r\n\r\n/** Same records regardless of order — the backend stores them sorted. */\r\nexport function sameSelection(\r\n a: readonly number[],\r\n b: readonly number[],\r\n): boolean {\r\n if (a.length !== b.length) return false;\r\n const set = new Set(a);\r\n return b.every((id) => set.has(id));\r\n}\r\n\r\n/**\r\n * Replace the selection with the picker's result. Records already selected\r\n * keep their place; new ones are appended in the order they were picked. In\r\n * single mode only the last pick survives.\r\n */\r\nexport function applySelectionPicks(\r\n state: SelectionEditorState,\r\n picks: readonly SelectionPick[],\r\n multiple: boolean,\r\n): SelectionEditorState {\r\n const wanted = positiveIds(picks.map((pick) => pick.id));\r\n const chosen = multiple ? wanted : wanted.slice(-1);\r\n const kept = state.ids.filter((id) => chosen.includes(id));\r\n const added = chosen.filter((id) => !kept.includes(id));\r\n const names = { ...state.names };\r\n const records = { ...state.records };\r\n for (const pick of picks) {\r\n if (!added.includes(pick.id)) continue;\r\n if (pick.name) names[pick.id] = pick.name;\r\n if (pick.record) records[pick.id] = pick.record;\r\n }\r\n return { ...state, ids: [...kept, ...added], names, records };\r\n}\r\n\r\nexport function removeSelectedRecord(\r\n state: SelectionEditorState,\r\n id: number,\r\n): SelectionEditorState {\r\n return { ...state, ids: state.ids.filter((entry) => entry !== id) };\r\n}\r\n\r\n/**\r\n * The control's value for a state.\r\n *\r\n * A changed selection is a mutation: the full replacement `entityIds`, the\r\n * version it was loaded at, and a `mutationId` that stays the same while the\r\n * content does (a retry of the same save) and changes with it. Nothing else is\r\n * sent — the backend discards rendered records and snapshots, and rejects any\r\n * other member.\r\n *\r\n * An unchanged selection is the value it arrived as, which the submission\r\n * leaves out: an omitted Selected list keeps its membership.\r\n */\r\nexport function buildSelectionValue(\r\n next: SelectionEditorState,\r\n newUuid: () => string,\r\n): {\r\n state: SelectionEditorState;\r\n value: EntityListSelectionDocument | null;\r\n} {\r\n const loaded = next.base?.entityIds ?? [];\r\n if (sameSelection(next.ids, positiveIds(loaded))) {\r\n return {\r\n state: { ...next, mutationId: null, mutationKey: null },\r\n value: next.base,\r\n };\r\n }\r\n\r\n const version = Number(next.base?.version ?? 0) || 0;\r\n const entityIds = [...next.ids];\r\n const mutationKey = JSON.stringify({\r\n version,\r\n entityIds: [...entityIds].sort((a, b) => a - b),\r\n });\r\n const mutationId =\r\n next.mutationKey === mutationKey && next.mutationId\r\n ? next.mutationId\r\n : newUuid();\r\n return {\r\n state: { ...next, mutationId, mutationKey },\r\n value: { recordMode: 'Selected', version, mutationId, entityIds },\r\n };\r\n}\r\n","import {\r\n ChangeDetectionStrategy,\r\n Component,\r\n DestroyRef,\r\n OnInit,\r\n computed,\r\n inject,\r\n input,\r\n signal,\r\n} from '@angular/core';\r\nimport { takeUntilDestroyed } from '@angular/core/rxjs-interop';\r\nimport { FormControl, ReactiveFormsModule } from '@angular/forms';\r\nimport {\r\n HttpClient,\r\n HttpContext,\r\n HttpErrorResponse,\r\n HttpParams,\r\n} from '@angular/common/http';\r\nimport { TranslocoPipe } from '@jsverse/transloco';\r\nimport { Skeleton } from 'primeng/skeleton';\r\nimport {\r\n Subscription,\r\n debounceTime,\r\n distinctUntilChanged,\r\n finalize,\r\n map,\r\n} from 'rxjs';\r\nimport { Icon } from '@masterteam/icons';\r\nimport { Button } from '@masterteam/components/button';\r\nimport { ModalRef } from '@masterteam/components/dialog';\r\nimport { ModalService } from '@masterteam/components/modal';\r\nimport { TextField } from '@masterteam/components/text-field';\r\n\r\nimport {\r\n parseOptionRecord,\r\n type SelectionPick,\r\n} from './entity-list-selection-editor';\r\n\r\n/** `GET forms/options/{propertyKey}` — only what the picker reads. */\r\ninterface SelectionOptionsResponse {\r\n data?: {\r\n items?: Array<{\r\n key: string;\r\n name?: string | null;\r\n /** `{ entityId, values }` as a JSON string; see `parseOptionRecord`. */\r\n metadataJson?: string | null;\r\n }> | null;\r\n hasMore?: boolean;\r\n } | null;\r\n}\r\n\r\n/**\r\n * Candidates per request. The backend takes 1–100 and requires `skip` to be a\r\n * multiple of `take`, so paging only ever adds whole pages.\r\n */\r\nconst PAGE_SIZE = 25;\r\n\r\n/** The backend's limit on one list's selection. */\r\nexport const ENTITY_LIST_MAX_SELECTIONS = 100;\r\n\r\n/**\r\n * Picker of a Selected `EntityList` (`recordMode: \"Selected\"`), opened by\r\n * `mt-entity-list-field`.\r\n *\r\n * Candidates come from `GET forms/options/{propertyKey}` with the **parent's**\r\n * context: the backend resolves the source module and its eligibility filter\r\n * from the property's trusted configuration, so the caller never names the\r\n * source. Each candidate is only a key and a name — its field values are\r\n * rendered once the parent is saved.\r\n *\r\n * Closes with the chosen records as `SelectionPick[]`, or `null` on Cancel.\r\n */\r\n@Component({\r\n selector: 'mt-entity-list-selection-dialog',\r\n standalone: true,\r\n imports: [\r\n ReactiveFormsModule,\r\n TranslocoPipe,\r\n Skeleton,\r\n Icon,\r\n Button,\r\n TextField,\r\n ],\r\n templateUrl: './entity-list-selection-dialog.html',\r\n changeDetection: ChangeDetectionStrategy.OnPush,\r\n})\r\nexport class EntityListSelectionDialog implements OnInit {\r\n private readonly ref = inject(ModalRef);\r\n /** Exposes the shared modal content/footer classes to the template. */\r\n protected readonly modal = inject(ModalService);\r\n private readonly http = inject(HttpClient);\r\n private readonly destroyRef = inject(DestroyRef);\r\n\r\n /** The EntityList property's key — the options route. */\r\n readonly propertyKey = input<string>('');\r\n /** The parent form's context, e.g. `Level:3/Module:22`. */\r\n readonly contextKey = input<string>('');\r\n readonly levelDataId = input<number | string | null>(null);\r\n readonly multiple = input<boolean>(true);\r\n /** The records the field holds now. */\r\n readonly selectedIds = input<number[]>([]);\r\n readonly context = input<HttpContext | undefined>(undefined);\r\n\r\n protected readonly searchControl = new FormControl<string>('', {\r\n nonNullable: true,\r\n });\r\n\r\n protected readonly items = signal<SelectionPick[]>([]);\r\n protected readonly loading = signal<boolean>(false);\r\n protected readonly hasMore = signal<boolean>(false);\r\n /** Translation key of the failure to show instead of the list, if any. */\r\n protected readonly failureKey = signal<string | null>(null);\r\n\r\n /** Chosen records, in the order they were picked; id → name. */\r\n protected readonly picked = signal<Map<number, string>>(new Map());\r\n protected readonly pickedCount = computed(() => this.picked().size);\r\n protected readonly atLimit = computed(\r\n () => this.multiple() && this.pickedCount() >= ENTITY_LIST_MAX_SELECTIONS,\r\n );\r\n protected readonly maxSelections = ENTITY_LIST_MAX_SELECTIONS;\r\n\r\n private nextSkip = 0;\r\n private request?: Subscription;\r\n\r\n ngOnInit(): void {\r\n this.picked.set(new Map(this.selectedIds().map((id) => [id, ''])));\r\n this.searchControl.valueChanges\r\n .pipe(\r\n debounceTime(300),\r\n map((value) => value.trim()),\r\n distinctUntilChanged(),\r\n takeUntilDestroyed(this.destroyRef),\r\n )\r\n .subscribe(() => this.load(true));\r\n this.load(true);\r\n }\r\n\r\n protected isPicked(id: number): boolean {\r\n return this.picked().has(id);\r\n }\r\n\r\n /**\r\n * Multiple mode toggles the record. Single mode replaces the choice, and\r\n * picking the chosen record again clears it.\r\n */\r\n protected toggle(item: SelectionPick): void {\r\n const current = this.picked();\r\n if (current.has(item.id)) {\r\n const next = new Map(current);\r\n next.delete(item.id);\r\n this.picked.set(next);\r\n return;\r\n }\r\n if (!this.multiple()) {\r\n this.picked.set(new Map([[item.id, item.name]]));\r\n return;\r\n }\r\n if (this.atLimit()) return;\r\n this.picked.set(new Map(current).set(item.id, item.name));\r\n }\r\n\r\n protected loadMore(): void {\r\n this.load(false);\r\n }\r\n\r\n protected onCancel(): void {\r\n this.ref.close(null);\r\n }\r\n\r\n protected onApply(): void {\r\n const listed = new Map(this.items().map((item) => [item.id, item]));\r\n const picks: SelectionPick[] = [...this.picked()].map(([id, name]) => ({\r\n id,\r\n name: name || listed.get(id)?.name || '',\r\n record: listed.get(id)?.record ?? null,\r\n }));\r\n this.ref.close(picks);\r\n }\r\n\r\n /**\r\n * Load a page of candidates; `reset` starts over from the first page of the\r\n * current search.\r\n *\r\n * The first page of an unfiltered list also asks for the records already\r\n * selected (`includeSelected`), so they show as chosen even when they sit on\r\n * a later page. They are added beside the page, not counted in it.\r\n */\r\n private load(reset: boolean): void {\r\n this.request?.unsubscribe();\r\n if (reset) {\r\n this.nextSkip = 0;\r\n this.items.set([]);\r\n this.hasMore.set(false);\r\n }\r\n this.failureKey.set(null);\r\n\r\n const propertyKey = this.propertyKey();\r\n const contextKey = this.contextKey();\r\n if (!propertyKey || !contextKey) {\r\n this.failureKey.set('components.entityListField.selectionUnavailable');\r\n return;\r\n }\r\n\r\n const search = this.searchControl.value.trim();\r\n const skip = this.nextSkip;\r\n let params = new HttpParams()\r\n .set('contextKey', contextKey)\r\n .set('skip', String(skip))\r\n .set('take', String(PAGE_SIZE));\r\n const levelDataId = this.levelDataId();\r\n if (levelDataId != null && levelDataId !== '') {\r\n params = params.set('levelDataId', String(levelDataId));\r\n }\r\n if (search) {\r\n params = params.set('search', search);\r\n }\r\n const selected = this.selectedIds();\r\n if (skip === 0 && !search && selected.length) {\r\n params = params.set('includeSelected', 'true');\r\n for (const id of selected) {\r\n params = params.append('selectedIds', String(id));\r\n }\r\n }\r\n\r\n this.loading.set(true);\r\n const context = this.context();\r\n this.request = this.http\r\n .get<SelectionOptionsResponse>(\r\n `forms/options/${encodeURIComponent(propertyKey)}`,\r\n {\r\n params,\r\n // Failures are shown inside the dialog, not as a host toast.\r\n headers: { noMessage: 'true' },\r\n ...(context ? { context } : {}),\r\n },\r\n )\r\n .pipe(\r\n finalize(() => this.loading.set(false)),\r\n takeUntilDestroyed(this.destroyRef),\r\n )\r\n .subscribe({\r\n next: (response) => this.applyPage(response, skip),\r\n error: (error: HttpErrorResponse) =>\r\n this.failureKey.set(\r\n error?.error?.errors?.code === 'entity_list.target_read_denied'\r\n ? 'components.entityListField.accessDenied'\r\n : 'components.entityListField.selectionLoadFailed',\r\n ),\r\n });\r\n }\r\n\r\n private applyPage(response: SelectionOptionsResponse, skip: number): void {\r\n const page: SelectionPick[] = [];\r\n for (const item of response?.data?.items ?? []) {\r\n const id = Number(item?.key);\r\n if (!Number.isInteger(id) || id <= 0) continue;\r\n page.push({\r\n id,\r\n name: item.name?.trim() || `#${id}`,\r\n record: parseOptionRecord(item.metadataJson, id),\r\n });\r\n }\r\n\r\n const seen = new Set(this.items().map((item) => item.id));\r\n this.items.set([\r\n ...this.items(),\r\n ...page.filter((item) => !seen.has(item.id)),\r\n ]);\r\n this.hasMore.set(!!response?.data?.hasMore);\r\n this.nextSkip = skip + PAGE_SIZE;\r\n }\r\n}\r\n","<div [class]=\"modal.contentClass + ' flex max-h-[70vh] flex-col gap-3 p-4'\">\r\n <mt-text-field\r\n [formControl]=\"searchControl\"\r\n icon=\"general.search-md\"\r\n [placeholder]=\"'components.entityListField.searchRecords' | transloco\"\r\n />\r\n\r\n @if (multiple()) {\r\n <p\r\n class=\"text-xs\"\r\n [class.text-muted-color]=\"!atLimit()\"\r\n [class.text-amber-700]=\"atLimit()\"\r\n >\r\n {{\r\n (atLimit()\r\n ? \"components.entityListField.selectionLimit\"\r\n : \"components.entityListField.selectedCount\"\r\n ) | transloco: { count: pickedCount(), max: maxSelections }\r\n }}\r\n </p>\r\n }\r\n\r\n @if (failureKey(); as failure) {\r\n <div\r\n class=\"rounded-md border border-red-200 bg-red-50 p-3 text-sm text-red-700\"\r\n >\r\n {{ failure | transloco }}\r\n </div>\r\n } @else {\r\n <div\r\n class=\"flex min-h-40 flex-col gap-1 overflow-y-auto\"\r\n role=\"listbox\"\r\n [attr.aria-multiselectable]=\"multiple()\"\r\n >\r\n @for (item of items(); track item.id) {\r\n @let chosen = isPicked(item.id);\r\n <button\r\n type=\"button\"\r\n role=\"option\"\r\n [attr.aria-selected]=\"chosen\"\r\n [disabled]=\"!chosen && atLimit()\"\r\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\"\r\n [class.border-primary]=\"chosen\"\r\n [class.bg-primary-50]=\"chosen\"\r\n [class.border-surface]=\"!chosen\"\r\n (click)=\"toggle(item)\"\r\n >\r\n <span\r\n class=\"flex size-4 shrink-0 items-center justify-center border\"\r\n [class.rounded-sm]=\"multiple()\"\r\n [class.rounded-full]=\"!multiple()\"\r\n [class.border-primary]=\"chosen\"\r\n [class.bg-primary]=\"chosen\"\r\n [class.text-primary-contrast]=\"chosen\"\r\n [class.border-surface-400]=\"!chosen\"\r\n >\r\n @if (chosen) {\r\n <mt-icon icon=\"general.check\" class=\"text-[0.625rem]\" />\r\n }\r\n </span>\r\n <span class=\"min-w-0 flex-1 truncate text-color\">{{\r\n item.name\r\n }}</span>\r\n </button>\r\n }\r\n\r\n @if (loading()) {\r\n <p-skeleton width=\"100%\" height=\"2.5rem\" borderRadius=\"0.375rem\" />\r\n <p-skeleton width=\"100%\" height=\"2.5rem\" borderRadius=\"0.375rem\" />\r\n <p-skeleton width=\"100%\" height=\"2.5rem\" borderRadius=\"0.375rem\" />\r\n } @else if (!items().length) {\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.noCandidates\" | transloco }}\r\n </div>\r\n }\r\n </div>\r\n\r\n @if (hasMore() && !loading()) {\r\n <div class=\"flex justify-center\">\r\n <mt-button\r\n [label]=\"'components.entityListField.loadMore' | transloco\"\r\n variant=\"text\"\r\n size=\"small\"\r\n (onClick)=\"loadMore()\"\r\n />\r\n </div>\r\n }\r\n }\r\n</div>\r\n\r\n<div [class]=\"modal.footerClass\">\r\n <mt-button\r\n [label]=\"'components.entityListField.cancel' | transloco\"\r\n severity=\"secondary\"\r\n variant=\"outlined\"\r\n (onClick)=\"onCancel()\"\r\n />\r\n <mt-button\r\n [label]=\"'components.entityListField.apply' | transloco\"\r\n severity=\"primary\"\r\n [disabled]=\"!!failureKey()\"\r\n (onClick)=\"onApply()\"\r\n />\r\n</div>\r\n","import {\n Component,\n ChangeDetectionStrategy,\n DestroyRef,\n computed,\n effect,\n inject,\n input,\n signal,\n untracked,\n} from '@angular/core';\nimport {\n AbstractControl,\n ControlValueAccessor,\n NgControl,\n ValidationErrors,\n Validators,\n} from '@angular/forms';\nimport { CommonModule } from '@angular/common';\nimport {\n HttpClient,\n HttpContext,\n HttpErrorResponse,\n} from '@angular/common/http';\nimport { TranslocoPipe, TranslocoService } from '@jsverse/transloco';\nimport { Skeleton } from 'primeng/skeleton';\nimport { Message } from 'primeng/message';\nimport { catchError, finalize, of, take, Subscription } from 'rxjs';\nimport { takeUntilDestroyed, toSignal } from '@angular/core/rxjs-interop';\n\nimport { Button } from '@masterteam/components/button';\nimport { Tabs } from '@masterteam/components/tabs';\nimport { FieldValidation } from '@masterteam/components/field-validation';\nimport { ModalService } from '@masterteam/components/modal';\nimport {\n Table,\n type ColumnDef,\n type TableAction,\n} from '@masterteam/components/table';\nimport {\n EntityRuntimeContextStore,\n isEntityListLocalDocument,\n isEntityListSelectionDocument,\n localCellsByFieldId,\n readEntityValueColor,\n resolveLocalFieldConfiguration,\n resolveLocalFieldLabel,\n resolveLocalFieldViewType,\n resolveLocalizedLabel,\n serializeEntityRawValue,\n visibleLocalSchemaFields,\n} from '@masterteam/components/entities';\nimport type {\n EntityData,\n EntityListLocalDocument,\n EntityListLocalSchema,\n EntityListLocalSchemaField,\n EntityListSelectionDocument,\n EntityListSelectionRecord,\n EntityViewType,\n PropertyValueComparison,\n} from '@masterteam/components/entities';\nimport type { EntityListFieldRuntimeContext } from '@masterteam/components';\nimport { coerceCheckboxValue, MTDateFormatPipe } from '@masterteam/components';\n\nimport {\n ENTITY_LIST_ADD_DIALOG_COMPONENT,\n ENTITY_LIST_LOCAL_ROW_DIALOG_COMPONENT,\n} from './entity-list-add-token';\nimport {\n buildLocalMutationContent,\n createLocalEditorState,\n diffLocalCells,\n newLocalUuid,\n orderLocalRows,\n type LocalEditorState,\n type LocalRowDraft,\n} from './entity-list-local-editor';\nimport {\n applySelectionPicks,\n buildSelectionValue,\n createSelectionEditorState,\n removeSelectedRecord,\n type SelectionEditorState,\n type SelectionPick,\n} from './entity-list-selection-editor';\nimport { EntityListSelectionDialog } from './entity-list-selection-dialog';\n\n// ============================================================================\n// Types — minimal subset of fetch/query Table response (mirrors\n// ClientListFetchQueryResponse from @masterteam/client-components).\n// ============================================================================\n\ninterface FetchPropertyMeta {\n id: number;\n key: string;\n normalizedKey: string;\n label: string;\n viewType: string;\n configuration: EntityData['propertyConfiguration'];\n source?: string;\n order: number;\n isRequired?: boolean;\n isCalculated?: boolean;\n}\n\ninterface FetchValueCell {\n raw?: unknown;\n value?: unknown;\n display?: string | null;\n /** The colour the backend resolved for this value. See `EntityData.color`. */\n color?: string | null;\n comparison?: PropertyValueComparison;\n}\n\ninterface FetchRecord {\n id: number;\n values: Record<string, FetchValueCell>;\n}\n\ninterface FetchTableColumn {\n key: string;\n label: string;\n viewType: string;\n order: number;\n visible: boolean;\n configuration: EntityData['propertyConfiguration'];\n}\n\n/** `POST fetch/query` — only the rows are consumed; columns come from metadata. */\ninterface FetchQueryResponse {\n records?: FetchRecord[];\n}\n\n/**\n * `GET Properties/{propertyId}/entitylist/table-metadata?levelId={levelId}` —\n * the runtime-scoped description of the table this field renders.\n *\n * The backend resolves the level-module configuration override, enforces module\n * read authorization (`403`), and returns the target module's canonical read /\n * write keys plus the same catalog and table-projection shapes `fetch/query`\n * uses. Every field is always emitted; see the \"Table Metadata Endpoint\"\n * section of `.github/instructions/properties/EntityList.md`.\n */\ninterface EntityListTableMetadata {\n propertyId: number;\n levelId: number;\n sourceType: 'Inline' | 'Module';\n moduleId: number;\n /** Effective access mode for this level — not necessarily the stored one. */\n access: string;\n snapshotMode: string;\n /** Canonical readable target keys. Empty when access forbids reading. */\n readFields: string[];\n /** Canonical writable target keys. Empty when access forbids writing. */\n writeFields: string[];\n catalog: { properties?: FetchPropertyMeta[] };\n projectionMeta: { columns?: FetchTableColumn[] };\n /**\n * `Local` rows belong to the parent record and are edited through its own\n * submission; `Linked` rows are records of the target module. See\n * `EntityListLocalDocument`.\n */\n storageMode?: 'Linked' | 'Local';\n /**\n * The *active* Local schema, hidden fields included. A loaded value carries\n * the schema it was projected against, which wins; this is the fallback for\n * a parent whose list was never saved.\n */\n localSchema?: EntityListLocalSchema | null;\n /** Local operation switches; the backend defaults each to `true`. */\n allowCreate?: boolean;\n allowEdit?: boolean;\n allowDelete?: boolean;\n /**\n * `Selected` lists hold the source records the user picked, not every\n * related one; see `EntityListSelectionDocument`. `Related` is the default.\n */\n recordMode?: 'Related' | 'Selected';\n /** How many records a Selected list may hold. */\n selectionMode?: 'Single' | 'Multiple';\n}\n\n/**\n * `GET entity-lists/comparison?ownerKind&ownerId&propertyId` — a saved list's\n * preserved values beside its sources' current ones. Plain JSON, no envelope.\n * Only what the viewer reads; see the Lifecycle API.\n */\ninterface EntityListComparison {\n /** False when no baseline was captured — not an empty saved list. */\n preservedAvailable: boolean;\n preservedAt: string | null;\n preserved: EntityListSelectionRecord[];\n /** Current values; restricted to the saved membership once one exists. */\n live: EntityListSelectionRecord[];\n unavailableIds: number[];\n /**\n * A Local list's rows at the requested revision, rendered against that\n * revision's schema minus fields hidden since. `preserved` / `live` are\n * empty for Local: its rows have no source record to compare with.\n */\n localDocument?: EntityListLocalDocument | null;\n}\n\n/**\n * One saved revision of a list — `GET entity-lists/revisions`, newest first.\n * `createdBy` is an actor id and is never shown; `createdByName` is the\n * author's *current* display name, null when it cannot be resolved, and\n * absent on a backend older than `f039e096`.\n */\ninterface EntityListRevision {\n version: number;\n createdAt: string;\n createdBy?: string | null;\n createdByName?: string | null;\n}\n\n/** A page of the revision index. Plain JSON, no envelope. */\ninterface EntityListRevisionPage {\n items: EntityListRevision[];\n totalCount: number;\n page: number;\n pageSize: number;\n}\n\n/** Revisions fetched per page of the history list (the backend allows 1–100). */\nconst REVISIONS_PAGE_SIZE = 25;\n\n/** The values a compared list shows: as saved, or as the sources are now. */\ntype EntityListComparisonView = 'preserved' | 'current';\n\n/** `snapshotMode` names `Realtime`; anything else — `Snapshot`, omitted — is preserved. */\nfunction isRealtimeSnapshotMode(mode: unknown): boolean {\n return String(mode ?? '').toLowerCase() === 'realtime' || mode === 1;\n}\n\n/**\n * Why the metadata request produced no table.\n *\n * - `forbidden` — `403`: the user may not read the target module in this level.\n * - `unavailable` — `400` / `404`: the property is missing, not an EntityList,\n * invalidly configured, or out of the supplied level's scope.\n * - `failed` — anything else, i.e. an actual request failure.\n */\ntype EntityListMetadataFailure = 'forbidden' | 'unavailable' | 'failed';\n\nfunction resolveMetadataFailure(status: number): EntityListMetadataFailure {\n if (status === 403) return 'forbidden';\n return status === 400 || status === 404 ? 'unavailable' : 'failed';\n}\n\n/** A translated text control value, `{ en, ar }`, not yet given a `display`. */\nfunction isTranslatedText(\n value: unknown,\n): value is { en?: string; ar?: string } {\n if (!value || typeof value !== 'object' || Array.isArray(value)) return false;\n const text = value as Record<string, unknown>;\n return (\n !('display' in text) &&\n (typeof text['en'] === 'string' || typeof text['ar'] === 'string')\n );\n}\n\ninterface EntityListColumnDef extends ColumnDef {\n key: string;\n label: string;\n type: 'entity';\n viewType?: string;\n order?: number;\n visible?: boolean;\n configuration?: EntityData['propertyConfiguration'];\n /** Underlying catalog property key (e.g. \"task_name\") used to look up\n * form values keyed by property key when a new row is added locally. */\n propertyKey?: string;\n}\n\ntype EntityListRow = Record<string, unknown | EntityData>;\n\n/**\n * Configured access mode. Mirrors the backend `EntityList` access matrix:\n * `Auto` and `ReadWrite` allow both, `Read` reads only, `Write` writes only,\n * `None` neither.\n */\ntype EntityListAccess = 'Auto' | 'Read' | 'Write' | 'ReadWrite' | 'None';\n\n/** One submitted row value (`values[]` entry of the stored EntityList JSON). */\ninterface EntityListSubmitValue {\n propertyKey: string;\n rawValue: string | null;\n /**\n * Backend-resolved display value for `rawValue`, present only on a loaded\n * value's rendered rows (a user object, an attachment list, a formatted\n * percentage). It is display-only and never submitted — see `emitValue`.\n */\n value?: unknown;\n}\n\n/**\n * A pending create/update row in the stored EntityList payload.\n * `entityId > 0` updates that target record; `0` creates a new one.\n */\ninterface EntityListSubmitRow {\n rowId: string;\n entityId: number;\n values: EntityListSubmitValue[];\n}\n\n/** Stored EntityList property value (round-tripped through the form). */\ninterface EntityListStoredValue {\n entityIds?: number[];\n createdIds?: number[];\n updatedIds?: number[];\n deletedIds?: number[];\n snapshot?: unknown;\n rows?: EntityListSubmitRow[];\n /**\n * The versioned Related protocol: the parent-owned list version the value\n * was loaded at, one UUID per intended change, and an opaque server token\n * per existing target the change edits or deletes. The form load sends\n * `version` and `expectedVersions`, with `mutationId` empty.\n */\n version?: number;\n mutationId?: string;\n expectedVersions?: Record<string, string>;\n /** Response-only current rows of the targets; never submitted. */\n live?: unknown;\n}\n\n/** Non-persisted view state kept per pending row so dialogs and table cells\n * can use the original (non-stringified) form values and option labels. */\ninterface EntityListRowDraft {\n values: Record<string, unknown>;\n display: Record<string, unknown>;\n}\n\nconst UNSORTABLE_ENTITY_VIEW_TYPES = new Set<EntityViewType>([\n 'Attachment',\n 'Checkbox',\n // A nested list has no scalar to compare — sorting by it would order rows\n // by an object.\n 'EntityList',\n]);\n\nconst ACCESS_ALIASES: Record<string, EntityListAccess> = {\n '0': 'Auto',\n '1': 'Read',\n '2': 'Write',\n '3': 'ReadWrite',\n '4': 'None',\n auto: 'Auto',\n read: 'Read',\n write: 'Write',\n readwrite: 'ReadWrite',\n none: 'None',\n};\n\n/** Internal row keys — not rendered, used to correlate rows with entities. */\nconst ROW_ID_KEY = '__rowId';\nconst ROW_ENTITY_ID_KEY = '__entityId';\nconst ROW_VALUES_KEY = '__values';\nconst ROW_PREFILL_KEY = '__prefill';\n\n/**\n * View types whose form control binds the resolved object rather than the\n * stored scalar, so the edit dialog has to be pre-filled from the rendered\n * `value` of the cell and not its `raw`. Mirrors `resolveLoadedFieldValue`\n * in `@masterteam/forms/client-form`, which makes the same exception for\n * these two at the top level of a form — a user picker renders from the\n * object and would otherwise display a bare id.\n */\nconst OBJECT_VALUED_VIEW_TYPES = new Set(['User', 'MultiUser']);\n\n/**\n * The staged operation a rendered row represents while the field overlays an\n * unapplied submission. A row the request leaves alone carries `null`.\n */\ntype EntityListRowChange = 'added' | 'edited' | 'deleted';\n\n/** Internal row key carrying the staged operation, for export and tests. */\nconst ROW_CHANGE_KEY = '__change';\n\n/** Column key of the synthetic flag column — never a target property key. */\nconst ROW_CHANGE_COLUMN_KEY = '__changeState';\n\n/** Internal row key marking a Local row added in this session. */\nconst ROW_LOCAL_CREATED_KEY = '__localCreated';\n\n/**\n * The editing state behind each Local value this field emitted, keyed by that\n * value.\n *\n * A mutation carries only what changed, so it cannot rebuild the table on its\n * own — and the field is not always the one that emitted it: `mt-dynamic-form`\n * destroys the sections outside the current wizard step, and the field that\n * comes back is a new instance handed the form's current value. Keeping the\n * state out of the payload leaves the submitted JSON exactly the contract,\n * and a `WeakMap` lets it go with the value.\n */\nconst LOCAL_EDITOR_STATES = new WeakMap<object, LocalEditorState>();\n\n/**\n * The editing state behind each Selected value this field emitted, for the\n * same reason as `LOCAL_EDITOR_STATES`: a mutation is only ids, and the names\n * of records picked in this session live nowhere else.\n */\nconst SELECTION_EDITOR_STATES = new WeakMap<object, SelectionEditorState>();\n\n/**\n * Badge colour per staged operation, as a hex: `mt-entity-status` derives its\n * own 12%-alpha background by slicing the value's `color`, so a Tailwind class\n * would render an uncoloured badge.\n */\nconst ROW_CHANGE_COLORS: Record<EntityListRowChange, string> = {\n added: '#16a34a',\n edited: '#d97706',\n deleted: '#dc2626',\n};\n\n@Component({\n selector: 'mt-entity-list-field',\n standalone: true,\n imports: [\n CommonModule,\n FieldValidation,\n Skeleton,\n Message,\n Table,\n Button,\n Tabs,\n TranslocoPipe,\n MTDateFormatPipe,\n ],\n templateUrl: './entity-list-field.html',\n styleUrls: ['./entity-list-field.scss'],\n changeDetection: ChangeDetectionStrategy.OnPush,\n host: { class: 'grid gap-1' },\n // Shuts the ambient runtime context off for everything this field renders.\n // Its own table cells go through `mt-entity-preview`, so a nested EntityList\n // column would otherwise see the host's context and render *another* fetched\n // table inside a cell of this one. A fresh store holds `null`, which is\n // exactly the \"no context, use the drawer\" state.\n providers: [EntityRuntimeContextStore],\n})\nexport class EntityListField implements ControlValueAccessor {\n // Inputs\n readonly label = input<string>('');\n readonly readonly = input<boolean>(false);\n readonly required = input<boolean>(false);\n /**\n * EntityList property id. **Required** — with the owning level it addresses\n * the table-metadata endpoint, which is the only source of this field's\n * effective configuration.\n */\n readonly propertyId = input<number | null>(null);\n /**\n * EntityList property key. A Selected list's picker loads its candidates\n * from `forms/options/{propertyKey}`; no other mode reads it.\n */\n readonly propertyKey = input<string>('');\n /**\n * Stored property configuration (sourceType, moduleId, access, readFields …).\n *\n * Kept for hosts that still bind it, but **not read**: the stored value is\n * the un-overridden one, and the backend resolves the level-module override\n * before answering the metadata request. Everything this field gates on comes\n * from that response.\n */\n readonly configuration = input<Record<string, unknown> | null>(null);\n /** Runtime ids needed to call the read endpoint. */\n readonly runtimeContext = input<EntityListFieldRuntimeContext | null>(null);\n /**\n * The bound value is an unapplied process submission — an Approval step's\n * frozen create/update/delete operations — rather than a persisted record\n * value. Its `rows[]` and `deletedIds` are pending intent the approver has\n * to see staged over the loaded records, not markers of writes the backend\n * already applied. See `.github/instructions/properties/EntityList.md`.\n */\n readonly pendingSubmission = input<boolean>(false);\n /**\n * Full lookup catalog of the host form, forwarded to the add/edit dialog's\n * nested form. `process-form-load` returns only the lookup *id* per field,\n * so without this the target module's Lookup fields render \"no options\".\n */\n readonly lookups = input<unknown[]>([]);\n /** Optional HttpContext (kept for back-compat). */\n readonly context = input<HttpContext | undefined>(undefined);\n /**\n * The stored value, for hosts that render this field **outside a form** —\n * the read-only `mt-entity-list-preview` creates it through\n * `NgComponentOutlet`, which can set inputs but cannot drive a\n * `ControlValueAccessor`.\n *\n * Ignored once a form control is attached, so it can never race\n * `writeValue`. It matters for a `Write`-access list: that field may not read\n * the target module, so its stored `rows[]` are the only thing it has to\n * show.\n */\n readonly initialValue = input<EntityListStoredValue | string | null>(null);\n\n // CVA state — pass-through value (EntityList stored JSON shape).\n private readonly storedValue = signal<EntityListStoredValue | null>(null);\n\n /** Runtime-scoped metadata; null until the endpoint answers. */\n private readonly metadata = signal<EntityListTableMetadata | null>(null);\n protected readonly metadataFailure = signal<EntityListMetadataFailure | null>(\n null,\n );\n\n // Loaded table state.\n protected readonly columns = signal<EntityListColumnDef[]>([]);\n /** Rows loaded from the backend (existing target records). */\n protected readonly rows = signal<EntityListRow[]>([]);\n protected readonly loading = signal<boolean>(false);\n protected readonly errorMessage = signal<string | null>(null);\n\n protected readonly disabled = signal<boolean>(false);\n protected requiredValidator = Validators.required;\n public ngControl: NgControl | null = null;\n\n protected readonly levelId = computed<number | string | null>(() => {\n const raw = this.runtimeContext()?.levelId ?? null;\n return raw == null || raw === '' ? null : raw;\n });\n\n protected readonly levelDataId = computed<number | string | null>(() => {\n const raw = this.runtimeContext()?.levelDataId ?? null;\n return raw == null || raw === '' ? null : raw;\n });\n\n /** EntityList property id as a number; `0` when the host bound none. */\n protected readonly propertyKeyId = computed<number>(() =>\n Number(this.propertyId() ?? 0),\n );\n\n /** Target module id, as resolved for this level. */\n protected readonly moduleId = computed<number | null>(\n () => this.metadata()?.moduleId ?? null,\n );\n\n /** Canonical readable target keys — the columns this field renders. */\n protected readonly readFields = computed<string[]>(\n () => this.metadata()?.readFields ?? [],\n );\n\n /**\n * Keys the row projection asks for: readable **and** writable.\n *\n * A writable key that is not readable has no column, but the edit dialog\n * still renders it — and several are `isRequired` on the target module (the\n * schedule module's `task_planned_finish` is). Projecting only `readFields`\n * left those controls empty, so the form was invalid until the user retyped a\n * value that already existed, and a different value silently overwrote the\n * stored one. Read order first, so the request body stays stable.\n */\n protected readonly projectedKeys = computed<string[]>(() => [\n ...new Set([...this.readFields(), ...this.writeFields()]),\n ]);\n\n /** Effective `access` for this level, as resolved by the backend. */\n protected readonly accessMode = computed<EntityListAccess>(() => {\n const raw = this.metadata()?.access;\n if (raw == null || raw === '') return 'None';\n return ACCESS_ALIASES[String(raw).trim().toLowerCase()] ?? 'None';\n });\n\n /**\n * The table is backed by target module records. Inline lists resolve their\n * rows from the stored value and have no module form to write through, so\n * this field does not render them.\n */\n protected readonly moduleBacked = computed<boolean>(() => {\n const metadata = this.metadata();\n return metadata?.sourceType === 'Module' && Number(metadata.moduleId) > 0;\n });\n\n protected readonly canRead = computed<boolean>(() => {\n const access = this.accessMode();\n return access === 'Auto' || access === 'Read' || access === 'ReadWrite';\n });\n\n /**\n * Whether the field has rows it may display. Write-only access cannot read\n * target module records, but its stored `rows[]` are the value users entered\n * and must remain visible when the host renders the field as read-only.\n */\n protected readonly canDisplayRows = computed<boolean>(\n () => this.canRead() || this.accessMode() === 'Write',\n );\n\n /** Access allows module-backed create/update/delete. */\n private readonly writeAllowed = computed<boolean>(() => {\n const access = this.accessMode();\n return access === 'Auto' || access === 'Write' || access === 'ReadWrite';\n });\n\n /** Write UI is rendered only when access allows it and the field is editable. */\n protected readonly canWrite = computed<boolean>(\n () => this.writeAllowed() && this.moduleBacked() && !this.readonly(),\n );\n\n /**\n * Canonical writable target keys. They are what the add/edit dialog renders\n * and what a submitted row is restricted to — canonical, so a configuration\n * that listed `normalizedKey` aliases still matches the target module's form\n * value keys.\n */\n protected readonly writeFields = computed<string[]>(\n () => this.metadata()?.writeFields ?? [],\n );\n\n /**\n * Write fields a new row must fill: the target's required, non-calculated\n * properties. The backend rejects a create row without any of them\n * (`entity_list.required_field_missing`), while the target module's form —\n * which the add dialog renders — may mark fewer required.\n */\n private readonly createRequiredFields = computed<string[]>(() => {\n const properties = this.propertyByKey();\n return this.writeFields().filter((key) => {\n const property = properties.get(key);\n return !!property?.isRequired && !property.isCalculated;\n });\n });\n\n /**\n * Pending create/update rows, in the exact shape persisted by the backend\n * (`rows[]` of the stored EntityList JSON). Rows with `entityId > 0` are\n * partial updates of existing records; `entityId = 0` rows are creates.\n */\n private readonly pendingRows = signal<EntityListSubmitRow[]>([]);\n /** Existing entity ids the user removed in this session. */\n private readonly stagedDeletedIds = signal<number[]>([]);\n /** `deletedIds` carried by the loaded value, before they mean anything. */\n private readonly loadedDeletedIds = signal<number[]>([]);\n /**\n * Delete intents that apply to the table right now. On a persisted value the\n * loaded `deletedIds` are historical operation markers — the records are\n * already gone — so only this session's removals count. On an unapplied\n * submission they are deletes awaiting approval and must be staged too.\n */\n private readonly deletedIds = computed<number[]>(() => {\n const staged = this.stagedDeletedIds();\n if (!this.pendingSubmission()) return staged;\n return [...new Set([...this.loadedDeletedIds(), ...staged])];\n });\n /** rowId → original form values / option labels (view state only). */\n private readonly rowDrafts = signal<Record<string, EntityListRowDraft>>({});\n private localRowSeq = 0;\n /** Serialized copy of the last value we emitted, to ignore CVA echoes. */\n private lastEmittedJson: string | null = null;\n\n /** Server rows indexed by entity id, for merging pending updates. */\n private readonly rowsByEntityId = computed<Map<number, EntityListRow>>(() => {\n const map = new Map<number, EntityListRow>();\n for (const row of this.rows()) {\n const entityId = Number(row[ROW_ENTITY_ID_KEY]);\n if (entityId > 0) map.set(entityId, row);\n }\n return map;\n });\n\n /** Locally created rows (not yet persisted). */\n private readonly createdRows = computed<EntityListRow[]>(() => {\n const drafts = this.rowDrafts();\n return this.pendingRows()\n .filter((row) => !(row.entityId > 0))\n .map((row) => {\n const draft = drafts[row.rowId];\n return this.buildRow(\n row.rowId,\n row.rowId,\n 0,\n draft?.values ?? this.toValueMap(row.values),\n draft?.display ?? this.toDisplayMap(row.values),\n );\n });\n });\n\n /** Pending edits of existing rows, keyed by entity id. */\n private readonly editedRowsByEntityId = computed<Map<number, EntityListRow>>(\n () => {\n const drafts = this.rowDrafts();\n const serverRows = this.rowsByEntityId();\n const map = new Map<number, EntityListRow>();\n for (const row of this.pendingRows()) {\n if (!(row.entityId > 0)) continue;\n const base = serverRows.get(row.entityId);\n const draft = drafts[row.rowId];\n // A pending update only carries the keys the user changed.\n const changed = draft?.values ?? this.toValueMap(row.values);\n const display = draft?.display ?? this.toDisplayMap(row.values);\n\n if (!base) {\n map.set(\n row.entityId,\n this.buildRow(\n row.entityId,\n row.rowId,\n row.entityId,\n changed,\n display,\n ),\n );\n continue;\n }\n\n // Keep the backend-rendered cells for untouched columns so resolved\n // labels (users, lookups, statuses) are not replaced by raw ids.\n const baseValues =\n (base[ROW_VALUES_KEY] as Record<string, unknown> | undefined) ?? {};\n const basePrefill =\n (base[ROW_PREFILL_KEY] as Record<string, unknown> | undefined) ??\n baseValues;\n const next: EntityListRow = {\n ...base,\n [ROW_ID_KEY]: row.rowId,\n [ROW_VALUES_KEY]: { ...baseValues, ...changed },\n // Re-opening the dialog must still show what the controls bind, so\n // the resolved values survive a pending edit.\n [ROW_PREFILL_KEY]: { ...basePrefill, ...changed },\n };\n for (const column of this.columns()) {\n const key = column.propertyKey ?? column.key;\n if (!(key in changed)) continue;\n next[column.key] = this.buildCell(column, changed[key], display[key]);\n }\n map.set(row.entityId, next);\n }\n return map;\n },\n );\n\n /**\n * Whether the table stages pending operations over the loaded records.\n *\n * Editable write modes stage the user's own edits, and a read-only\n * Write-only field has nothing but its stored rows to show. A pending\n * submission stages them too even though it is read-only and `ReadWrite`:\n * an approver reviewing a request has to see what it *will* do to the target\n * module, not the records as they stand.\n */\n private readonly showsPendingOperations = computed<boolean>(\n () =>\n this.canWrite() ||\n this.accessMode() === 'Write' ||\n this.pendingSubmission(),\n );\n\n /**\n * Whether each row is flagged with the operation the request performs on it,\n * and a removed row stays on screen instead of disappearing.\n *\n * Only while reviewing an unapplied submission. In an editable field the user\n * just pressed delete, so the row leaving *is* the feedback — putting it back\n * with a badge and no way to undo reads as a delete that failed.\n */\n protected readonly showsChangeFlags = computed<boolean>(() =>\n this.pendingSubmission(),\n );\n\n /**\n * Rows rendered in the table: existing rows merged with pending edits, and\n * created rows appended.\n *\n * While reviewing a submission the removed rows stay too, flagged `deleted`,\n * and every row carries the operation it represents. An approver has to see\n * the deletes they are approving — hiding them understated what pressing\n * Approve would do. Everywhere else a removed row is simply gone.\n */\n protected readonly displayRows = computed<EntityListRow[]>(() => {\n if (!this.showsPendingOperations()) return this.rows();\n const deleted = new Set(this.deletedIds());\n const edited = this.editedRowsByEntityId();\n const flagged = this.showsChangeFlags();\n\n const existing: EntityListRow[] = [];\n for (const row of this.rows()) {\n const entityId = Number(row[ROW_ENTITY_ID_KEY]);\n if (deleted.has(entityId)) {\n if (flagged) existing.push(this.withRowChange(row, 'deleted'));\n continue;\n }\n const pending = edited.get(entityId);\n existing.push(\n pending\n ? this.withRowChange(pending, 'edited')\n : this.withRowChange(row, null),\n );\n }\n\n const created = this.createdRows().map((row) =>\n this.withRowChange(row, 'added'),\n );\n\n return [...existing, ...this.orphanDeletedRows(), ...created];\n });\n\n protected readonly hasRows = computed<boolean>(\n () => this.displayRows().length > 0,\n );\n\n /**\n * Tag a rendered row with its staged operation and the cell that displays it.\n * A no-op outside a reviewed submission, so an editable table keeps the rows\n * exactly as the projection built them.\n */\n private withRowChange(\n row: EntityListRow,\n change: EntityListRowChange | null,\n ): EntityListRow {\n if (!this.showsChangeFlags()) return row;\n return {\n ...row,\n [ROW_CHANGE_KEY]: change,\n [ROW_CHANGE_COLUMN_KEY]: change ? this.buildRowChangeCell(change) : null,\n };\n }\n\n /**\n * Deleted ids with no loaded record behind them — already applied elsewhere,\n * or outside the level-data scope this table queries. They render as an empty\n * flagged row rather than vanishing: a review screen that silently drops a\n * delete is the bug this whole overlay exists to avoid, and an id the table\n * cannot describe is still a deletion the approver is signing off on.\n */\n private orphanDeletedRows(): EntityListRow[] {\n if (!this.showsChangeFlags()) return [];\n const loaded = this.rowsByEntityId();\n return this.deletedIds()\n .filter((entityId) => !loaded.has(entityId))\n .map((entityId) => ({\n Id: entityId,\n [ROW_ID_KEY]: `entity-${entityId}`,\n [ROW_ENTITY_ID_KEY]: entityId,\n [ROW_VALUES_KEY]: {},\n [ROW_PREFILL_KEY]: {},\n [ROW_CHANGE_KEY]: 'deleted',\n [ROW_CHANGE_COLUMN_KEY]: this.buildRowChangeCell('deleted'),\n }));\n }\n\n /**\n * The flag cell, built as the `Status` entity `mt-table` already renders — a\n * `rounded-md` badge tinted from the value's own colour. Assembled here\n * rather than as a bespoke cell template so the column looks like every other\n * cell in the table and needs no host wiring.\n */\n private buildRowChangeCell(change: EntityListRowChange): EntityData {\n return {\n key: ROW_CHANGE_COLUMN_KEY,\n name: this.rowChangeLabels().column,\n viewType: 'Status',\n value: {\n key: change,\n display: this.rowChangeLabels()[change],\n color: ROW_CHANGE_COLORS[change],\n },\n };\n }\n\n /**\n * Badge labels, re-resolved when the active language changes. `translate()`\n * is a plain call, so without a language signal to depend on the computed\n * would keep whichever language it first ran in.\n */\n private readonly rowChangeLabels = computed<\n Record<EntityListRowChange | 'column', string>\n >(() => {\n const lang = this.lang();\n const translate = (key: string) =>\n this.transloco.translate(`components.entityListField.${key}`, {}, lang);\n return {\n column: translate('changeColumn'),\n added: translate('changeAdded'),\n edited: translate('changeEdited'),\n deleted: translate('changeDeleted'),\n };\n });\n\n /**\n * Columns bound to the table: the data columns, followed by the flag column\n * while reviewing a submission.\n *\n * Last, not first: the leading column is what identifies a row, and pushing\n * the record's own name aside for a badge makes the table harder to read for\n * the rows nothing happened to — which is most of them.\n *\n * Deliberately separate from `columns()`, which is the metadata projection\n * the row builders iterate — a synthetic column in there would be looked up\n * against the record values and add an empty cell to every row.\n */\n protected readonly tableColumns = computed<EntityListColumnDef[]>(() => {\n const columns = this.columns();\n if (!this.showsChangeFlags()) return columns;\n return [\n ...columns,\n {\n key: ROW_CHANGE_COLUMN_KEY,\n label: this.rowChangeLabels().column,\n type: 'entity' as const,\n sortable: false,\n filterable: false,\n shrink: true,\n exportValue: (row: EntityListRow) =>\n (row[ROW_CHANGE_KEY] as string | null) ?? '',\n },\n ];\n });\n\n // ============================================================================\n // Local storage (`storageMode: \"Local\"`) — rows owned by the parent record\n // ============================================================================\n\n /** Loaded document plus this session's edits; see `LocalEditorState`. */\n private readonly localState = signal<LocalEditorState>(\n createLocalEditorState(null),\n );\n /** The bound value was a Local document, whatever the metadata says yet. */\n private readonly localValueSeen = signal<boolean>(false);\n /** The last Local value emitted, so its echo does not reset the edits. */\n private lastLocalEmit: unknown = null;\n\n /**\n * Rows live inside the parent record: no target records, no `fetch/query`,\n * and the value is a document of its own rather than operation markers.\n * Known from the metadata, or earlier from the value itself.\n */\n protected readonly localMode = computed<boolean>(\n () => this.metadata()?.storageMode === 'Local' || this.localValueSeen(),\n );\n\n /**\n * The schema the table is built from. A loaded value's own schema wins: it\n * is the one its rows were projected against, and pending or approved\n * evidence stays pinned to the schema it was submitted with. The metadata's\n * active schema is the fallback for a list that has never been saved.\n */\n private readonly localSchema = computed<EntityListLocalSchema | null>(\n () =>\n this.localState().base?.schema ?? this.metadata()?.localSchema ?? null,\n );\n\n protected readonly localFields = computed(() =>\n visibleLocalSchemaFields(this.localSchema()),\n );\n\n /**\n * Render the Local table once the metadata answered: it is the access\n * boundary, and it carries the operation switches the table obeys.\n */\n protected readonly localReady = computed<boolean>(\n () => this.localMode() && !!this.metadata(),\n );\n\n /**\n * Writes are staged into the parent's submission, never sent on their own.\n *\n * Whether the host lets this field be edited is the form's call —\n * `readonly` — as it is for a linked list; `pendingSubmission` is not one.\n * A loaded request is not always a review: a returned request is loaded to\n * be corrected and resubmitted, and the backend projects the active schema\n * for exactly that.\n */\n private readonly localWritable = computed<boolean>(\n () =>\n !!this.localDialogComponent &&\n !!this.metadata() &&\n this.writeAllowed() &&\n !this.readonly() &&\n !this.disabled() &&\n this.localFields().length > 0,\n );\n\n protected readonly localCanCreate = computed<boolean>(\n () => this.localWritable() && this.metadata()?.allowCreate !== false,\n );\n private readonly localCanEdit = computed<boolean>(\n () => this.localWritable() && this.metadata()?.allowEdit !== false,\n );\n private readonly localCanDelete = computed<boolean>(\n () => this.localWritable() && this.metadata()?.allowDelete !== false,\n );\n /** Reordering rewrites loaded rows, so it is an edit. */\n protected readonly localCanReorder = computed<boolean>(\n () => this.localCanEdit() && this.localTableRows().length > 1,\n );\n\n /**\n * One column per visible schema field, keyed by the field's local id — the\n * id cells are keyed by. Sorting is off while rows can be dragged: a sorted\n * table would show an order that is not the one being saved.\n */\n protected readonly localColumns = computed<EntityListColumnDef[]>(() =>\n this.buildLocalColumns(this.localFields(), !this.localCanEdit()),\n );\n\n /**\n * Rows as rendered: loaded rows with this session's edits over them, then\n * new rows, in the order they would be saved. A loaded cell renders from the\n * backend's resolved `value`; a cell the user set renders from the dialog's\n * control value and option label, like a locally added linked row.\n */\n protected readonly localTableRows = computed<EntityListRow[]>(() =>\n this.buildLocalRows(\n this.localState(),\n this.localFields(),\n this.localColumns(),\n ),\n );\n\n private buildLocalColumns(\n fields: EntityListLocalSchemaField[],\n sortable: boolean,\n ): EntityListColumnDef[] {\n const lang = this.lang();\n return fields.map((field, index) => {\n const viewType = resolveLocalFieldViewType(field);\n return {\n key: field.id as string,\n label: resolveLocalFieldLabel(field, lang),\n type: 'entity' as const,\n sortable:\n sortable &&\n !UNSORTABLE_ENTITY_VIEW_TYPES.has(viewType as EntityViewType),\n viewType,\n order: index,\n visible: true,\n configuration: null,\n };\n });\n }\n\n private buildLocalRows(\n state: LocalEditorState,\n fields: EntityListLocalSchemaField[],\n localColumns: EntityListColumnDef[],\n ): EntityListRow[] {\n const columns = new Map(localColumns.map((column) => [column.key, column]));\n\n return orderLocalRows(state).map((entry) => {\n const cells = entry.existing\n ? localCellsByFieldId(entry.existing)\n : new Map();\n const draft: LocalRowDraft | undefined =\n entry.created?.draft ?? state.edited[entry.rowId];\n const row: EntityListRow = {\n Id: entry.rowId,\n [ROW_ID_KEY]: entry.rowId,\n [ROW_LOCAL_CREATED_KEY]: !!entry.created,\n };\n\n for (const field of fields) {\n const fieldId = field.id as string;\n const column = columns.get(fieldId);\n if (!column) continue;\n const configuration = resolveLocalFieldConfiguration(field);\n row[fieldId] =\n draft && (entry.created || fieldId in draft.cells)\n ? this.buildLocalDraftCell(column, draft, configuration)\n : this.buildLocalLoadedCell(\n column,\n cells.get(fieldId),\n configuration,\n );\n }\n return row;\n });\n }\n\n /**\n * Edit and delete per row. A row added in this session is still part of the\n * create — changing or dropping it undoes nothing stored — so it follows\n * `allowCreate`; a loaded row follows `allowEdit` / `allowDelete`.\n */\n protected readonly localRowActions = computed<TableAction[]>(() => {\n this.lang();\n const canCreate = this.localCanCreate();\n const canEdit = this.localCanEdit();\n const canDelete = this.localCanDelete();\n const isCreated = (row: EntityListRow) =>\n row[ROW_LOCAL_CREATED_KEY] === true;\n const actions: TableAction[] = [];\n\n if (canCreate || canEdit) {\n actions.push({\n icon: 'custom.pencil' as const,\n tooltip: this.transloco.translate('components.entityListField.edit'),\n hidden: (row: EntityListRow) =>\n isCreated(row) ? !canCreate : !canEdit,\n action: (row: EntityListRow) => this.openLocalRowDialog(row),\n });\n }\n if (canCreate || canDelete) {\n actions.push({\n icon: 'general.trash-01' as const,\n tooltip: this.transloco.translate('components.entityListField.delete'),\n color: 'danger' as const,\n confirmation: {\n type: 'popup' as const,\n confirmationType: 'delete' as const,\n },\n hidden: (row: EntityListRow) =>\n isCreated(row) ? !canCreate : !canDelete,\n action: (row: EntityListRow) => this.deleteLocalRow(row),\n });\n }\n return actions;\n });\n\n // ============================================================================\n // Selected records (`recordMode: \"Selected\"`) — source records the user picked\n // ============================================================================\n\n /** Loaded selection plus this session's picks; see `SelectionEditorState`. */\n private readonly selectionState = signal<SelectionEditorState>(\n createSelectionEditorState(null),\n );\n /** The bound value was a Selected document, whatever the metadata says yet. */\n private readonly selectionValueSeen = signal<boolean>(false);\n /** The last Selected value emitted, so its echo does not reset the picks. */\n private lastSelectionEmit: unknown = null;\n\n /**\n * The list holds only the records the user picked. It never falls back to\n * every related record: an empty selection is empty. Known from the\n * metadata, or earlier from the value itself.\n */\n protected readonly selectionMode = computed<boolean>(\n () =>\n this.metadata()?.recordMode === 'Selected' || this.selectionValueSeen(),\n );\n\n /** Render once the metadata answered: it is the access boundary. */\n protected readonly selectionReady = computed<boolean>(\n () => this.selectionMode() && !!this.metadata(),\n );\n\n private readonly selectionMultiple = computed<boolean>(\n () => this.metadata()?.selectionMode !== 'Single',\n );\n\n /**\n * The picker's `contextKey`: the context of the form that owns the property\n * — never the source module, which the backend resolves from the property's\n * own configuration.\n */\n private readonly selectionContextKey = computed<string | null>(() => {\n const levelId = this.levelId();\n if (levelId == null) return null;\n const moduleId = this.runtimeContext()?.moduleId;\n return moduleId == null || moduleId === ''\n ? `Level:${levelId}`\n : `Level:${levelId}/Module:${moduleId}`;\n });\n\n /**\n * Whether the user may change which records are selected. That is the\n * form's call — `readonly`, from the field's `isWrite` — and not the\n * metadata's `access` or its `allow*` switches: those describe the source\n * records, which selecting never writes.\n */\n protected readonly selectionWritable = computed<boolean>(\n () =>\n this.selectionReady() &&\n !this.readonly() &&\n !this.disabled() &&\n !!this.propertyKey() &&\n !!this.selectionContextKey(),\n );\n\n /**\n * The selected records as table rows, in selection order.\n *\n * A saved record renders from the backend's `records`, cell by cell against\n * the metadata columns — the same cells a related list shows. A record\n * picked in this session renders the display values its option carried\n * (`metadataJson`) the same way; an older backend sends none, and the row\n * then shows its name and \"Shown after saving\". A record in `unavailableIds` was\n * deleted or is no longer visible: the backend keeps it selected but\n * withholds its values, and the row says so, so the user can remove it.\n */\n protected readonly selectionRows = computed<EntityListRow[]>(() => {\n const state = this.selectionState();\n const columns = this.columns();\n const properties = this.propertyByKey();\n const records = new Map(\n (state.base?.records ?? []).map((record) => [record.entityId, record]),\n );\n const unavailable = new Set(state.base?.unavailableIds ?? []);\n\n return state.ids.map((id) => {\n // A loaded record renders the backend's values for it; a record picked\n // in this session renders the picker's display values, when sent.\n const record = records.get(id) ?? state.records[id];\n if (record) return this.recordRow(record, columns, properties);\n\n const row: EntityListRow = {\n Id: id,\n [ROW_ID_KEY]: `entity-${id}`,\n [ROW_ENTITY_ID_KEY]: id,\n };\n const isUnavailable = unavailable.has(id);\n const label = isUnavailable\n ? this.transloco.translate(\n 'components.entityListField.unavailableRecord',\n { id },\n this.lang(),\n )\n : state.names[id] || `#${id}`;\n // The picker returns only names; the other values are rendered once the\n // parent is saved. Say so rather than show a known value as empty.\n const pending = isUnavailable\n ? ''\n : this.transloco.translate(\n 'components.entityListField.shownAfterSave',\n {},\n this.lang(),\n );\n columns.forEach((column, index) => {\n row[column.key] = {\n key: column.key,\n name: column.label,\n viewType: 'Text',\n value: index === 0 ? label : pending,\n } satisfies EntityData;\n });\n return row;\n });\n });\n\n /**\n * One table row from a rendered record — `{ entityId, values }` with each\n * value's `rawValue` and rendered `value` — cell by cell against the\n * metadata columns, the same cells a related list shows. Selected `records`\n * and the comparison's preserved / live rows all have this shape.\n */\n private recordRow(\n record: EntityListSelectionRecord,\n columns: EntityListColumnDef[],\n properties: Map<string, FetchPropertyMeta>,\n ): EntityListRow {\n const id = record.entityId;\n const row: EntityListRow = {\n Id: id,\n [ROW_ID_KEY]: `entity-${id}`,\n [ROW_ENTITY_ID_KEY]: id,\n };\n const values = new Map(\n (record.values ?? []).map((item) => [item.propertyKey, item]),\n );\n for (const column of columns) {\n const propertyKey = column.propertyKey ?? column.key;\n const item = values.get(propertyKey) ?? values.get(column.key);\n row[column.key] = this.toEntityData(\n column,\n item ? { raw: item.rawValue, value: item.value } : undefined,\n properties.get(propertyKey),\n id,\n );\n }\n return row;\n }\n\n // ============================================================================\n // Saved Related list — preserved and current values (`entity-lists/comparison`)\n // ============================================================================\n\n /** The comparison response, once loaded. */\n private readonly comparison = signal<EntityListComparison | null>(null);\n\n /**\n * The record that owns the list, when the host named it (a table cell's\n * drawer). Only a read-only list reads its comparison: an editable one\n * edits the source records it queries.\n */\n private readonly comparisonOwner = computed<{\n ownerKind: 'ModuleData' | 'LevelData';\n ownerId: number;\n } | null>(() => {\n const context = this.runtimeContext();\n const ownerId = Number(context?.ownerId);\n // An approver reviews staged operations over the live records, never a\n // comparison — see `pendingSubmission`.\n if (\n !this.readonly() ||\n this.pendingSubmission() ||\n !context?.ownerKind ||\n !(ownerId > 0)\n ) {\n return null;\n }\n return { ownerKind: context.ownerKind, ownerId };\n });\n\n /**\n * A saved Related list viewed from outside its form: the values preserved\n * when it was saved beside the source records' current ones. Local and\n * Selected lists hold their own rows and never compare.\n */\n protected readonly comparisonMode = computed<boolean>(\n () =>\n !!this.comparisonOwner() &&\n !this.comparisonUnsupported() &&\n !!this.metadata() &&\n !this.localMode() &&\n !this.selectionMode() &&\n this.moduleBacked(),\n );\n\n protected readonly comparisonReady = computed<boolean>(\n () => this.comparisonMode() && !!this.comparison(),\n );\n\n /** Which values a compared list shows, once the user picked one. */\n private readonly chosenComparisonView =\n signal<EntityListComparisonView | null>(null);\n\n /**\n * The values shown: the user's pick, else the property's configured\n * `snapshotMode` — Preserved for `Snapshot` (also the backend's default),\n * Current for `Realtime`. Record previews, cards and table drawers all\n * open on it, so the same list reads the same everywhere.\n */\n protected readonly comparisonView = computed<EntityListComparisonView>(\n () =>\n this.chosenComparisonView() ??\n (isRealtimeSnapshotMode(this.metadata()?.snapshotMode)\n ? 'current'\n : 'preserved'),\n );\n\n protected readonly comparisonViewOptions = computed(() => {\n const lang = this.lang();\n const label = (key: string) =>\n this.transloco.translate(`components.entityListField.${key}`, {}, lang);\n return [\n { label: label('preservedValues'), value: 'preserved' },\n { label: label('currentValues'), value: 'current' },\n ];\n });\n\n protected setComparisonView(view: unknown): void {\n if (view === 'preserved' || view === 'current') {\n this.chosenComparisonView.set(view);\n }\n }\n\n protected readonly liveRows = computed<EntityListRow[]>(() => {\n const columns = this.columns();\n const properties = this.propertyByKey();\n return (this.comparison()?.live ?? []).map((record) =>\n this.recordRow(record, columns, properties),\n );\n });\n\n protected readonly preservedRows = computed<EntityListRow[]>(() => {\n const columns = this.columns();\n const properties = this.propertyByKey();\n return (this.comparison()?.preserved ?? []).map((record) =>\n this.recordRow(record, columns, properties),\n );\n });\n\n /** No baseline was captured yet — not the same as an empty saved list. */\n protected readonly preservedAvailable = computed<boolean>(\n () => this.comparison()?.preservedAvailable === true,\n );\n\n protected readonly preservedAt = computed<string | null>(\n () => this.comparison()?.preservedAt ?? null,\n );\n\n protected readonly unavailableCount = computed<number>(\n () => this.comparison()?.unavailableIds?.length ?? 0,\n );\n\n /** Query of the two read-only review endpoints for this list's owner. */\n private reviewParams(propertyId: number): Record<string, string> | null {\n const owner = this.comparisonOwner();\n if (!owner) return null;\n return {\n ownerKind: owner.ownerKind,\n ownerId: String(owner.ownerId),\n propertyId: String(propertyId),\n };\n }\n\n /**\n * The comparison endpoint answered `404` for this owner, so the list is\n * shown from the source query instead (see `fetchComparison`).\n */\n private readonly comparisonUnsupported = signal<boolean>(false);\n\n private fetchComparison(propertyId: number, fallback?: () => void): void {\n const params = this.reviewParams(propertyId);\n if (!params) return;\n this.loading.set(true);\n const ctx = this.context();\n this.fetchSubscription = this.http\n .get<EntityListComparison>('entity-lists/comparison', {\n params,\n // `403` / `404` are rendered as notices, not toasts.\n headers: { noMessage: 'true' },\n ...(ctx ? { context: ctx } : {}),\n })\n .pipe(takeUntilDestroyed(this.destroyRef))\n .subscribe({\n next: (response) => {\n this.loading.set(false);\n this.comparison.set(response);\n },\n error: (error: HttpErrorResponse) => {\n // The API does not know this owner — a host that named a record the\n // review endpoints do not serve. Show the list as it did before an\n // owner was named, rather than an error in place of the table.\n if (error.status === 404 && fallback) {\n this.comparisonUnsupported.set(true);\n fallback();\n return;\n }\n this.loading.set(false);\n const failure = resolveMetadataFailure(error.status);\n this.metadataFailure.set(failure);\n if (failure === 'failed') {\n this.errorMessage.set(\n this.transloco.translate('components.entityListField.loadFailed'),\n );\n }\n },\n });\n }\n\n // ============================================================================\n // Saved list revisions (`entity-lists/revisions`) — read-only history\n // ============================================================================\n\n /**\n * A list viewed from outside its form, with its owning record named (a\n * table cell's drawer), has saved revisions to browse — Related, Local and\n * Selected alike. Nowhere else: an editable list, a record preview and a\n * form know no owner, and history is read-only anyway.\n */\n protected readonly historyAvailable = computed<boolean>(\n () =>\n this.SHOW_REVISION_HISTORY &&\n !!this.comparisonOwner() &&\n (this.comparisonMode() || this.localReady() || this.selectionReady()),\n );\n\n /**\n * Saved list revisions are not offered for now (product decision): the\n * button and the history panel are hidden, while the backend keeps storing\n * revisions and serving its API. Turning this on needs nothing else.\n */\n private readonly SHOW_REVISION_HISTORY = false;\n\n /**\n * A Local or Selected list shows its value until a revision is picked;\n * then that revision, until *Back to latest*. A Related list always shows\n * a comparison, the latest one when no revision is picked.\n */\n protected readonly showingRevision = computed<boolean>(\n () => this.viewedRevision() != null && !!this.comparison(),\n );\n\n /** The Local rows of the revision being viewed, with that revision's schema. */\n private readonly revisionLocalDocument = computed(() =>\n this.localMode() ? (this.comparison()?.localDocument ?? null) : null,\n );\n\n private readonly revisionLocalFields = computed(() =>\n visibleLocalSchemaFields(this.revisionLocalDocument()?.schema),\n );\n\n protected readonly revisionLocalColumns = computed<EntityListColumnDef[]>(\n () => this.buildLocalColumns(this.revisionLocalFields(), true),\n );\n\n protected readonly revisionLocalRows = computed<EntityListRow[]>(() => {\n const document = this.revisionLocalDocument();\n if (!document) return [];\n return this.buildLocalRows(\n createLocalEditorState(document),\n this.revisionLocalFields(),\n this.revisionLocalColumns(),\n );\n });\n\n /** The history list is open. */\n protected readonly revisionsOpen = signal<boolean>(false);\n /** Revisions loaded so far, newest first. */\n protected readonly revisions = signal<EntityListRevision[]>([]);\n /**\n * The revisions as listed, each with the author to print: the name the\n * backend resolved for the page, or \"Unknown user\" when it resolved none.\n * Plain text — the template interpolates it, never binds it as HTML.\n */\n protected readonly revisionItems = computed(() => {\n const unknown = this.transloco.translate(\n 'components.entityListField.unknownUser',\n {},\n this.lang(),\n );\n return this.revisions().map((revision) => ({\n version: revision.version,\n createdAt: revision.createdAt,\n author: revision.createdByName?.trim() || unknown,\n }));\n });\n private readonly revisionsTotal = signal<number>(0);\n private revisionsPage = 0;\n protected readonly revisionsLoading = signal<boolean>(false);\n protected readonly revisionsError = signal<string | null>(null);\n protected readonly hasMoreRevisions = computed(\n () => this.revisions().length < this.revisionsTotal(),\n );\n /** The revision the comparison shows; null is the list as saved last. */\n protected readonly viewedRevision = signal<number | null>(null);\n /** A revision is being read; the tables stay until it arrives. */\n protected readonly revisionLoading = signal<boolean>(false);\n /** Why the chosen revision could not be read. The last comparison stays. */\n protected readonly revisionError = signal<string | null>(null);\n private revisionSubscription?: Subscription;\n private revisionsSubscription?: Subscription;\n\n protected toggleRevisions(): void {\n const open = !this.revisionsOpen();\n this.revisionsOpen.set(open);\n if (open && this.revisionsPage === 0 && !this.revisionsLoading()) {\n this.loadRevisions();\n }\n }\n\n /** The next page of the revision index. */\n protected loadRevisions(): void {\n const propertyId = this.metadata()?.propertyId ?? 0;\n const params = this.reviewParams(propertyId);\n if (!params) return;\n const page = this.revisionsPage + 1;\n const ctx = this.context();\n this.revisionsLoading.set(true);\n this.revisionsError.set(null);\n this.revisionsSubscription = this.http\n .get<EntityListRevisionPage>('entity-lists/revisions', {\n params: { ...params, page, pageSize: REVISIONS_PAGE_SIZE },\n headers: { noMessage: 'true' },\n ...(ctx ? { context: ctx } : {}),\n })\n .pipe(\n takeUntilDestroyed(this.destroyRef),\n finalize(() => this.revisionsLoading.set(false)),\n )\n .subscribe({\n next: (response) => {\n this.revisionsPage = page;\n this.revisions.set([...this.revisions(), ...(response.items ?? [])]);\n this.revisionsTotal.set(Number(response.totalCount) || 0);\n },\n error: () =>\n this.revisionsError.set(\n this.transloco.translate(\n 'components.entityListField.revisionsLoadFailed',\n ),\n ),\n });\n }\n\n /**\n * Compare a saved revision with today — its preserved rows beside today's\n * values of the records it held; for Local, its rows as saved — or, with\n * `null`, go back to the latest: a Related list re-reads its comparison, a\n * Local or Selected one shows its value again. Read-only: nothing here is\n * ever submitted.\n */\n protected showRevision(version: number | null): void {\n const propertyId = this.metadata()?.propertyId ?? 0;\n const params = this.reviewParams(propertyId);\n if (!params || version === this.viewedRevision()) return;\n this.revisionSubscription?.unsubscribe();\n this.revisionError.set(null);\n if (version == null && !this.comparisonMode()) {\n this.revisionLoading.set(false);\n this.viewedRevision.set(null);\n this.comparison.set(null);\n return;\n }\n const ctx = this.context();\n this.revisionLoading.set(true);\n this.revisionSubscription = this.http\n .get<EntityListComparison>('entity-lists/comparison', {\n params: version == null ? params : { ...params, revision: version },\n headers: { noMessage: 'true' },\n ...(ctx ? { context: ctx } : {}),\n })\n .pipe(\n takeUntilDestroyed(this.destroyRef),\n finalize(() => this.revisionLoading.set(false)),\n )\n .subscribe({\n next: (response) => {\n this.comparison.set(response);\n this.viewedRevision.set(version);\n },\n error: (error: HttpErrorResponse) =>\n this.revisionError.set(this.revisionFailureMessage(error)),\n });\n }\n\n /**\n * `entity_list.history_source_changed` (`400`): the revision was saved with\n * another source configuration. `404`: it no longer exists.\n */\n private revisionFailureMessage(error: HttpErrorResponse): string {\n const code = (error.error as { code?: unknown } | null)?.code;\n const key =\n code === 'entity_list.history_source_changed'\n ? 'revisionSourceChanged'\n : error.status === 404\n ? 'revisionNotFound'\n : 'loadFailed';\n return this.transloco.translate(`components.entityListField.${key}`);\n }\n\n private resetRevisions(): void {\n this.revisionSubscription?.unsubscribe();\n this.revisionsSubscription?.unsubscribe();\n this.revisionsOpen.set(false);\n this.revisions.set([]);\n this.revisionsTotal.set(0);\n this.revisionsPage = 0;\n this.revisionsLoading.set(false);\n this.revisionsError.set(null);\n this.viewedRevision.set(null);\n this.revisionLoading.set(false);\n this.revisionError.set(null);\n }\n\n protected readonly selectionRowActions = computed<TableAction[]>(() => {\n this.lang();\n if (!this.selectionWritable()) return [];\n return [\n {\n icon: 'general.x-close' as const,\n tooltip: this.transloco.translate(\n 'components.entityListField.unselect',\n ),\n color: 'danger' as const,\n action: (row: EntityListRow) =>\n this.emitSelection(\n removeSelectedRecord(\n this.selectionState(),\n Number(row[ROW_ENTITY_ID_KEY]),\n ),\n ),\n },\n ];\n });\n\n /**\n * A required Selected list needs a record. An emptied selection is an\n * object — a mutation with no ids — so `Validators.required` passes it and\n * only the backend would object (`entity_list.selection_required`).\n */\n private readonly selectionRequiredValidator = (\n control: AbstractControl,\n ): ValidationErrors | null => {\n if (!this.required()) return null;\n const value = control.value;\n if (isEntityListSelectionDocument(value)) {\n return value.entityIds?.length ? null : { required: true };\n }\n return value == null && this.selectionMode() ? { required: true } : null;\n };\n\n protected openSelectionDialog(): void {\n if (!this.selectionWritable()) return;\n\n const ref = this.modal.openModal(EntityListSelectionDialog, 'dialog', {\n header: this.transloco.translate(\n 'components.entityListField.selectRecords',\n ),\n styleClass: '!w-[36rem] max-w-[96vw]',\n dismissableMask: true,\n inputValues: {\n propertyKey: this.propertyKey(),\n contextKey: this.selectionContextKey(),\n levelDataId: this.levelDataId(),\n multiple: this.selectionMultiple(),\n selectedIds: this.selectionState().ids,\n context: this.context(),\n },\n });\n\n ref.onClose.pipe(take(1)).subscribe((result: unknown) => {\n if (!Array.isArray(result)) return;\n this.emitSelection(\n applySelectionPicks(\n this.selectionState(),\n result as SelectionPick[],\n this.selectionMultiple(),\n ),\n );\n });\n }\n\n /**\n * Publish the selection as the control's value: a mutation when it differs\n * from what was loaded, else the loaded value, which the submission leaves\n * out. See `buildSelectionValue`.\n */\n private emitSelection(next: SelectionEditorState): void {\n const { state, value } = buildSelectionValue(next, newLocalUuid);\n this.selectionState.set(state);\n if (value) SELECTION_EDITOR_STATES.set(value, state);\n this.lastSelectionEmit = value;\n this.onModelChange(value as unknown as EntityListStoredValue | null);\n this.onTouched();\n }\n\n /**\n * Take a Selected document, and say whether it was one.\n *\n * Our own emission echoed back keeps the session; a value some instance of\n * this field emitted restores that instance's state (see\n * `SELECTION_EDITOR_STATES`); anything else starts a session on it. That is\n * the projection `process-form-load` returns, the stored document a preview\n * gets from the fetch endpoints, or a mutation the form already held — which\n * stays the control's value until the user changes the selection.\n *\n * An empty value resets the session too and still falls through, since\n * which mode the list uses may not be known yet.\n */\n private writeSelectionValue(value: unknown): boolean {\n const incoming = this.coerceStoredValue(value);\n if (!isEntityListSelectionDocument(incoming)) {\n if (incoming == null) {\n this.lastSelectionEmit = null;\n this.selectionState.set(createSelectionEditorState(null));\n }\n return false;\n }\n\n this.selectionValueSeen.set(true);\n if (incoming === this.lastSelectionEmit) return true;\n this.lastSelectionEmit = null;\n\n const restored = SELECTION_EDITOR_STATES.get(incoming);\n this.selectionState.set(\n restored ??\n createSelectionEditorState(incoming as EntityListSelectionDocument),\n );\n return true;\n }\n\n /** Enough context to ask the backend what this field should render. */\n protected readonly hasRequiredContext = computed<boolean>(\n () => this.propertyKeyId() > 0 && Number(this.levelId()) > 0,\n );\n\n /**\n * The non-error state the field renders instead of a table, as a translation\n * key. Null while the metadata request is still in flight, so the template\n * falls through to the skeleton.\n */\n protected readonly noticeKey = computed<string | null>(() => {\n if (!this.hasRequiredContext()) {\n return 'components.entityListField.missingConfiguration';\n }\n switch (this.metadataFailure()) {\n case 'forbidden':\n return 'components.entityListField.accessDenied';\n case 'unavailable':\n return 'components.entityListField.missingConfiguration';\n case 'failed':\n return null;\n }\n if (!this.metadata()) return null;\n // A Local list reads nothing from the source module; it needs only a\n // schema to render its own rows with.\n if (this.localMode()) {\n return this.localFields().length\n ? null\n : 'components.entityListField.missingConfiguration';\n }\n if (!this.moduleBacked()) {\n return 'components.entityListField.missingConfiguration';\n }\n return this.canDisplayRows()\n ? null\n : 'components.entityListField.readingNotAllowed';\n });\n\n protected onTouched: () => void = () => {};\n protected onModelChange: (value: EntityListStoredValue | null) => void =\n () => {};\n\n private readonly http = inject(HttpClient);\n private metadataSubscription?: Subscription;\n private fetchSubscription?: Subscription;\n private readonly destroyRef = inject(DestroyRef);\n private readonly modal = inject(ModalService);\n private readonly transloco = inject(TranslocoService);\n /** Active language — see `rowChangeLabels`. */\n private readonly lang = toSignal(this.transloco.langChanges$, {\n initialValue: this.transloco.getActiveLang(),\n });\n /**\n * Optional rich add-row dialog (provided by `@masterteam/forms` via\n * `provideEntityListAddForm()`). When available, used instead of the local\n * minimal dialog so the popup renders `mt-client-form` filtered by\n * `writeFields`.\n */\n private readonly addDialogComponent = inject(\n ENTITY_LIST_ADD_DIALOG_COMPONENT,\n { optional: true },\n );\n /**\n * Row dialog of a Local list, built from the schema's captured definitions\n * (`provideEntityListAddForm()` registers it beside the linked one). Without\n * it a Local list renders read-only.\n */\n private readonly localDialogComponent = inject(\n ENTITY_LIST_LOCAL_ROW_DIALOG_COMPONENT,\n { optional: true },\n );\n\n constructor() {\n this.ngControl = inject(NgControl, { self: true, optional: true });\n if (this.ngControl) {\n this.ngControl.valueAccessor = this;\n }\n\n // The property and its level address the metadata endpoint; the answer\n // decides everything else, including whether rows are fetched at all.\n // Only these scalars retrigger a load — a host that rebuilds its field\n // config object (language, readonly) must not cost a round trip.\n effect(() => {\n const propertyId = this.propertyKeyId();\n const levelId = this.levelId();\n const levelDataId = this.levelDataId();\n\n untracked(() => this.loadTable(propertyId, levelId, levelDataId));\n });\n\n // The control exists once the form directive has resolved it, which is\n // after construction. The validator reads `required` and the mode itself,\n // so it is added once; the control is re-validated when either changes —\n // the mode is only known once the metadata or the value arrives.\n effect(() => {\n this.selectionMode();\n this.required();\n const control = this.ngControl?.control;\n if (!control) return;\n untracked(() => {\n if (!control.hasValidator(this.selectionRequiredValidator)) {\n control.addValidators(this.selectionRequiredValidator);\n }\n control.updateValueAndValidity({ emitEvent: false });\n });\n });\n\n // Form-less hosts hand the value over as an input instead. `writeValue` is\n // the one entry point that resets the pending rows and deletions with it,\n // so it is reused rather than re-implemented.\n //\n // Purely additive: an absent input never clears a value, so a host that\n // does not bind it — or binds it late — cannot wipe what a form or a direct\n // `writeValue` already put there.\n effect(() => {\n const value = this.initialValue();\n if (this.ngControl || value == null) return;\n\n untracked(() => this.writeValue(value));\n });\n }\n\n // ============================================================================\n // CVA\n // ============================================================================\n\n writeValue(value: EntityListStoredValue | string | null): void {\n if (this.writeLocalValue(value)) return;\n if (this.writeSelectionValue(value)) return;\n const incoming = this.coerceStoredValue(value);\n // Ignore the echo of our own emission (DynamicForm re-writes the model on\n // every value change) so pending edits/deletions are not reset.\n if (this.isEchoOfLastEmit(incoming)) return;\n this.lastEmittedJson = null;\n this.linkedMutation = null;\n this.loadedMutationId = incoming?.mutationId;\n this.storedValue.set(incoming);\n // Restore rows the backend left unprocessed. Whether the loaded\n // `deletedIds` are historical markers or pending intent depends on the\n // value's provenance, which `deletedIds` resolves from `pendingSubmission`\n // — an input, so it cannot be read reliably this early.\n const rows = Array.isArray(incoming?.rows) ? incoming.rows : [];\n this.pendingRows.set(\n rows.filter((row) => !!row && typeof row === 'object'),\n );\n this.loadedDeletedIds.set(\n (Array.isArray(incoming?.deletedIds) ? incoming.deletedIds : [])\n .map((id) => Number(id))\n .filter((id) => Number.isFinite(id) && id > 0),\n );\n this.stagedDeletedIds.set([]);\n this.rowDrafts.set({});\n }\n\n /**\n * Take a Local document, and say whether it was one.\n *\n * - Our own emission echoed back (`mt-dynamic-form` re-writes the model on\n * every change) keeps the session's edits.\n * - A value some instance of this field emitted restores that instance's\n * state — see `LOCAL_EDITOR_STATES`.\n * - A document the backend sent starts a fresh session on it: the projection\n * `process-form-load` and the fetch endpoints return (its `schema` set,\n * cells rendered), or the stored document an older backend's fetch\n * endpoints returned (`schema: null`, cells unrendered) — the schema then\n * comes from the metadata.\n * Every backend document carries the `schema` member, null or not; a\n * mutation never does. So a mutation nobody here emitted has no rows to\n * rebuild the table from and is left as the control's value, untouched\n * until the user edits.\n *\n * An empty value resets the Local session too — a form reset — and still\n * falls through, since which storage the list uses may not be known yet.\n */\n private writeLocalValue(value: unknown): boolean {\n const incoming = this.coerceStoredValue(value);\n if (!isEntityListLocalDocument(incoming)) {\n if (incoming == null) {\n this.lastLocalEmit = null;\n this.localState.set(createLocalEditorState(null));\n }\n return false;\n }\n\n this.localValueSeen.set(true);\n if (incoming === this.lastLocalEmit) return true;\n this.lastLocalEmit = null;\n\n const restored = LOCAL_EDITOR_STATES.get(incoming);\n if (restored) {\n this.localState.set(restored);\n return true;\n }\n this.localState.set(\n createLocalEditorState(\n 'schema' in incoming ? (incoming as EntityListLocalDocument) : null,\n ),\n );\n return true;\n }\n\n /**\n * True when the written value still carries exactly the change we last\n * emitted — i.e. the form is echoing our own value back rather than loading\n * a new one.\n *\n * The list version, change id and tokens are part of it: a reload after a\n * save can carry the same (empty) rows and deletions as the last emission,\n * and taking it for an echo kept the old version, so the next save was\n * refused as a version conflict.\n */\n private isEchoOfLastEmit(incoming: EntityListStoredValue | null): boolean {\n if (this.lastEmittedJson === null) return false;\n return this.echoKey(incoming) === this.lastEmittedJson;\n }\n\n private echoKey(value: EntityListStoredValue | null): string {\n return JSON.stringify({\n rows: value?.rows ?? [],\n deletedIds: value?.deletedIds ?? [],\n version: value?.version ?? null,\n mutationId: value?.mutationId ?? null,\n expectedVersions: value?.expectedVersions ?? null,\n });\n }\n\n /**\n * The stored value is persisted as JSON, so a host may write either the\n * parsed object or its raw string form.\n */\n private coerceStoredValue(value: unknown): EntityListStoredValue | null {\n if (value == null || value === '') return null;\n if (typeof value === 'string') {\n try {\n return this.coerceStoredValue(JSON.parse(value));\n } catch {\n return null;\n }\n }\n return typeof value === 'object' && !Array.isArray(value)\n ? (value as EntityListStoredValue)\n : null;\n }\n\n registerOnChange(fn: (value: EntityListStoredValue | null) => void): void {\n this.onModelChange = fn;\n }\n\n registerOnTouched(fn: () => void): void {\n this.onTouched = fn;\n }\n\n setDisabledState(isDisabled: boolean): void {\n this.disabled.set(isDisabled);\n }\n\n // ============================================================================\n // Write mode — add / edit / delete\n // ============================================================================\n\n /** Row actions shown in write mode — edit and delete. */\n protected readonly writeRowActions = computed<TableAction[]>(() => {\n if (this.disabled()) return [];\n return [\n {\n icon: 'custom.pencil' as const,\n tooltip: this.transloco.translate('components.entityListField.edit'),\n action: (row: EntityListRow) => this.openEditDialog(row),\n },\n {\n icon: 'general.trash-01' as const,\n tooltip: this.transloco.translate('components.entityListField.delete'),\n color: 'danger' as const,\n confirmation: {\n type: 'popup' as const,\n confirmationType: 'delete' as const,\n },\n action: (row: EntityListRow) => this.deleteRow(row),\n },\n ];\n });\n\n protected openAddDialog(): void {\n if (this.disabled()) return;\n const component = this.addDialogComponent;\n if (!component) return;\n\n const ref = this.modal.openModal(component, 'dialog', {\n header: this.transloco.translate('components.entityListField.add'),\n styleClass: '!w-[48rem] max-w-[96vw]',\n dismissableMask: true,\n inputValues: {\n moduleId: this.moduleId(),\n levelId: this.levelId(),\n levelDataId: this.levelDataId(),\n writeFields: this.writeFields(),\n requiredFieldKeys: this.createRequiredFields(),\n lookups: this.lookups(),\n },\n });\n\n ref.onClose.pipe(take(1)).subscribe((result: unknown) => {\n const parsed = this.parseDialogResult(result);\n if (!parsed) return;\n // A create row carries every value the user filled in; empty fields are\n // dropped so the target module keeps its own defaults.\n const values = this.dropEmptyValues(parsed.values);\n const rowId = this.nextRowId();\n this.setRowDraft(rowId, values, parsed.display);\n this.pendingRows.set([\n ...this.pendingRows(),\n {\n rowId,\n entityId: 0,\n values: this.toSubmitValues(values, parsed.submit),\n },\n ]);\n this.emitValue();\n });\n }\n\n protected openEditDialog(row: EntityListRow): void {\n if (this.disabled()) return;\n const component = this.addDialogComponent;\n if (!component) return;\n\n const entityId = Number(row[ROW_ENTITY_ID_KEY]) || 0;\n const rowId = String(row[ROW_ID_KEY] ?? '');\n const initialValues =\n (row[ROW_VALUES_KEY] as Record<string, unknown> | undefined) ?? {};\n // The form is filled with the shapes its controls bind; the diff still\n // runs against `initialValues`, the stored scalars.\n const prefillValues =\n (row[ROW_PREFILL_KEY] as Record<string, unknown> | undefined) ??\n initialValues;\n\n const ref = this.modal.openModal(component, 'dialog', {\n header: this.transloco.translate('components.entityListField.edit'),\n styleClass: '!w-[48rem] max-w-[96vw]',\n dismissableMask: true,\n inputValues: {\n moduleId: this.moduleId(),\n levelId: this.levelId(),\n levelDataId: this.levelDataId(),\n writeFields: this.writeFields(),\n // A row not saved yet is still a create; an existing record's update\n // carries only what changed.\n requiredFieldKeys: entityId > 0 ? [] : this.createRequiredFields(),\n lookups: this.lookups(),\n initialValues: prefillValues,\n isEdit: true,\n },\n });\n\n ref.onClose.pipe(take(1)).subscribe((result: unknown) => {\n const parsed = this.parseDialogResult(result);\n if (!parsed) return;\n if (entityId > 0) {\n this.applyExistingRowEdit(entityId, rowId, initialValues, parsed);\n } else {\n this.applyCreatedRowEdit(rowId, parsed);\n }\n this.emitValue();\n });\n }\n\n /**\n * Existing target records are updated partially: only values the user\n * actually changed are submitted, so fields the dialog could not pre-fill\n * (keys outside `readFields`) are left untouched by the backend.\n */\n private applyExistingRowEdit(\n entityId: number,\n fallbackRowId: string,\n initialValues: Record<string, unknown>,\n parsed: {\n values: Record<string, unknown>;\n display: Record<string, unknown>;\n submit: Record<string, unknown>;\n },\n ): void {\n const changed = this.diffValues(\n initialValues,\n parsed.values,\n parsed.submit,\n );\n const current = this.pendingRows();\n const existing = current.find((row) => row.entityId === entityId);\n const rowId =\n existing?.rowId || (fallbackRowId ? fallbackRowId : `entity-${entityId}`);\n const merged = {\n ...(this.rowDrafts()[rowId]?.values ?? {}),\n ...changed,\n };\n\n if (Object.keys(merged).length === 0) {\n // Nothing left to submit for this record — drop the pending update.\n this.clearRowDraft(rowId);\n this.pendingRows.set(current.filter((row) => row.entityId !== entityId));\n return;\n }\n\n this.setRowDraft(rowId, merged, parsed.display);\n const next: EntityListSubmitRow = {\n rowId,\n entityId,\n values: this.toSubmitValues(merged, parsed.submit),\n };\n this.pendingRows.set(\n existing\n ? current.map((row) => (row.entityId === entityId ? next : row))\n : [...current, next],\n );\n }\n\n /** A locally created row is replaced wholesale by the dialog result. */\n private applyCreatedRowEdit(\n rowId: string,\n parsed: {\n values: Record<string, unknown>;\n display: Record<string, unknown>;\n submit: Record<string, unknown>;\n },\n ): void {\n const values = this.dropEmptyValues(parsed.values);\n this.setRowDraft(rowId, values, parsed.display);\n this.pendingRows.set(\n this.pendingRows().map((row) =>\n row.rowId === rowId\n ? { ...row, values: this.toSubmitValues(values, parsed.submit) }\n : row,\n ),\n );\n }\n\n /**\n * Remove a row. Locally created rows are dropped from the pending payload;\n * existing records are queued in `deletedIds` for the backend to delete.\n */\n protected deleteRow(row: EntityListRow): void {\n if (this.disabled()) return;\n const entityId = Number(row[ROW_ENTITY_ID_KEY]) || 0;\n const rowId = String(row[ROW_ID_KEY] ?? '');\n\n if (entityId > 0) {\n if (!this.deletedIds().includes(entityId)) {\n this.stagedDeletedIds.set([...this.stagedDeletedIds(), entityId]);\n }\n // A queued update for a deleted record is pointless — drop it.\n this.pendingRows.set(\n this.pendingRows().filter((pending) => pending.entityId !== entityId),\n );\n } else {\n this.pendingRows.set(\n this.pendingRows().filter((pending) => pending.rowId !== rowId),\n );\n }\n\n this.clearRowDraft(rowId);\n this.emitValue();\n }\n\n // ============================================================================\n // Local write mode — staged into the parent's own submission\n // ============================================================================\n\n /**\n * Add a Local row (no `row`) or edit one. The dialog is built from the\n * schema; its `submit` map is serialized here into cell `rawValue`s.\n *\n * A loaded row keeps only the cells that differ from what was loaded, so an\n * untouched cell is omitted and retained. Emptying a cell that had a value\n * is a clear, sent as `null` — the dialog is filled from every schema field,\n * so an empty control here really was emptied.\n */\n protected openLocalRowDialog(row?: EntityListRow): void {\n const component = this.localDialogComponent;\n if (!component || this.disabled()) return;\n\n const state = this.localState();\n const rowId = row ? String(row[ROW_ID_KEY] ?? '') : null;\n const created = rowId\n ? state.created.find((entry) => entry.rowId === rowId)\n : undefined;\n const existing =\n rowId && !created\n ? state.base?.localRows?.find((entry) => entry.rowId === rowId)\n : undefined;\n\n const ref = this.modal.openModal(component, 'dialog', {\n header: this.transloco.translate(\n row\n ? 'components.entityListField.edit'\n : 'components.entityListField.add',\n ),\n styleClass: '!w-[48rem] max-w-[96vw]',\n dismissableMask: true,\n inputValues: {\n fields: this.localFields(),\n lookups: this.lookups(),\n initialCells: existing\n ? Object.fromEntries(localCellsByFieldId(existing))\n : undefined,\n initialValues:\n created?.draft.values ??\n (rowId ? state.edited[rowId]?.values : undefined),\n isEdit: !!row,\n },\n });\n\n ref.onClose.pipe(take(1)).subscribe((result: unknown) => {\n const parsed = this.parseDialogResult(result);\n if (!parsed) return;\n const draft: LocalRowDraft = {\n cells: this.toLocalCells(parsed.values, parsed.submit),\n values: parsed.values,\n display: parsed.display,\n };\n const current = this.localState();\n\n if (!rowId) {\n this.emitLocal({\n ...current,\n created: [...current.created, { rowId: newLocalUuid(), draft }],\n });\n return;\n }\n if (created) {\n this.emitLocal({\n ...current,\n created: current.created.map((entry) =>\n entry.rowId === rowId ? { ...entry, draft } : entry,\n ),\n });\n return;\n }\n if (!existing) return;\n\n const edited = { ...current.edited };\n const changed = diffLocalCells(existing, draft.cells);\n if (Object.keys(changed).length > 0) {\n edited[rowId] = { ...draft, cells: changed };\n } else {\n delete edited[rowId];\n }\n this.emitLocal({ ...current, edited });\n });\n }\n\n /**\n * Remove a Local row. A loaded row is listed in `deletedRowIds` and its\n * pending edit dropped — a row is never both deleted and submitted. A row\n * added in this session just disappears.\n */\n protected deleteLocalRow(row: EntityListRow): void {\n if (this.disabled()) return;\n const rowId = String(row[ROW_ID_KEY] ?? '');\n const current = this.localState();\n\n if (current.created.some((entry) => entry.rowId === rowId)) {\n this.emitLocal({\n ...current,\n created: current.created.filter((entry) => entry.rowId !== rowId),\n });\n return;\n }\n\n const edited = { ...current.edited };\n delete edited[rowId];\n this.emitLocal({\n ...current,\n edited,\n deleted: current.deleted.includes(rowId)\n ? current.deleted\n : [...current.deleted, rowId],\n });\n }\n\n /**\n * Apply a drag within the table. Replays PrimeNG's own move on the rows as\n * rendered: `p-table` is bound to a derived array, so the event's `value`\n * is not reliably the reordered one.\n */\n protected onLocalReorder(event: {\n dragIndex?: number;\n dropIndex?: number;\n }): void {\n const from = Number(event?.dragIndex);\n const to = Number(event?.dropIndex);\n const ids = this.localTableRows().map((row) => String(row[ROW_ID_KEY]));\n if (\n !Number.isInteger(from) ||\n !Number.isInteger(to) ||\n from === to ||\n from < 0 ||\n to < 0 ||\n from >= ids.length ||\n to >= ids.length\n ) {\n return;\n }\n const [moved] = ids.splice(from, 1);\n ids.splice(to, 0, moved);\n this.emitLocal({ ...this.localState(), order: ids });\n }\n\n /**\n * Serialize one dialog result into cells, by field id, for every visible\n * field. `submit` is the dialog's reduction to stored scalars and wins over\n * the raw control value, as for linked rows.\n */\n private toLocalCells(\n values: Record<string, unknown>,\n submit: Record<string, unknown>,\n ): Record<string, string | null> {\n const cells: Record<string, string | null> = {};\n for (const field of this.localFields()) {\n const fieldId = field.id as string;\n cells[fieldId] = this.toRawValue(\n fieldId in submit ? submit[fieldId] : values[fieldId],\n );\n }\n return cells;\n }\n\n /**\n * Publish the Local state as the control's value.\n *\n * With changes, the value is a mutation: the loaded list and schema\n * versions, only the changed rows and cells, explicit deletions, and a\n * `mutationId` that stays the same while the content does (a retry of the\n * same save) and changes with it (a new save). Without changes it is the\n * loaded document again, which `mapFormValueToSubmitFields` leaves out of the\n * submission — an unchanged Local list is omitted, never re-sent.\n */\n private emitLocal(next: LocalEditorState): void {\n const content = buildLocalMutationContent(next);\n let state = next;\n let value: EntityListLocalDocument | null = next.base;\n\n if (content) {\n const mutation = {\n storageMode: 'Local' as const,\n formatVersion: 1,\n schemaVersion:\n next.base?.schemaVersion ??\n this.metadata()?.localSchema?.version ??\n '',\n version: next.base?.version ?? 0,\n ...content,\n };\n const mutationKey = JSON.stringify(mutation);\n const mutationId =\n next.mutationKey === mutationKey && next.mutationId\n ? next.mutationId\n : newLocalUuid();\n state = { ...next, mutationId, mutationKey };\n value = { ...mutation, mutationId };\n } else {\n state = { ...next, mutationId: null, mutationKey: null };\n }\n\n this.localState.set(state);\n if (value) LOCAL_EDITOR_STATES.set(value, state);\n this.lastLocalEmit = value;\n this.onModelChange(value as unknown as EntityListStoredValue | null);\n this.onTouched();\n }\n\n /** A cell the user set in this session, shaped like a backend one. */\n private buildLocalDraftCell(\n column: EntityListColumnDef,\n draft: LocalRowDraft,\n configuration: Record<string, unknown> | null,\n ): EntityData {\n const fieldId = column.key;\n const raw = draft.values[fieldId];\n const label = draft.display[fieldId];\n // A multi-select holds ids and resolves to labels; print the labels.\n const value =\n Array.isArray(raw) && Array.isArray(label)\n ? label.join(', ')\n : this.toLocalEntityValue(column.viewType, raw, label);\n return {\n key: fieldId,\n name: column.label,\n viewType: (column.viewType ?? 'Text') as EntityViewType,\n value: (value !== null && typeof value === 'object'\n ? value\n : (this.toRawValue(value) ?? '')) as EntityData['value'],\n rawValue: draft.cells[fieldId] ?? undefined,\n propertyConfiguration: configuration ?? undefined,\n };\n }\n\n /**\n * A loaded cell: the backend's rendered `value` beside its `rawValue`. A\n * stored document (what an older backend's fetch endpoints returned) has no\n * rendered values, so the raw one is shaped the way a locally set cell would\n * be — a user id still renders as a user, though only as its id.\n */\n private buildLocalLoadedCell(\n column: EntityListColumnDef,\n cell: { rawValue: string | null; value?: unknown } | undefined,\n configuration: Record<string, unknown> | null,\n ): EntityData {\n const value =\n cell?.value != null\n ? cell.value\n : this.toLocalEntityValue(column.viewType, cell?.rawValue, undefined);\n return {\n key: column.key,\n name: column.label,\n viewType: (column.viewType ?? 'Text') as EntityViewType,\n value: (value ?? '') as EntityData['value'],\n rawValue: serializeEntityRawValue(cell?.rawValue),\n propertyConfiguration: configuration ?? undefined,\n };\n }\n\n /**\n * Normalize the add/edit dialog close payload. The rich dialog returns\n * `{ values, display }`; a custom add-dialog may still return the raw values\n * object directly (no display map), which we treat as `display = {}`.\n */\n private parseDialogResult(result: unknown): {\n values: Record<string, unknown>;\n display: Record<string, unknown>;\n submit: Record<string, unknown>;\n } | null {\n if (!result || typeof result !== 'object') return null;\n const payload = result as Record<string, unknown>;\n const values = payload['values'];\n if (values && typeof values === 'object') {\n return {\n values: values as Record<string, unknown>,\n display:\n (payload['display'] as Record<string, unknown> | undefined) ?? {},\n submit:\n (payload['submit'] as Record<string, unknown> | undefined) ?? {},\n };\n }\n return { values: payload, display: {}, submit: {} };\n }\n\n private nextRowId(): string {\n const used = new Set(this.pendingRows().map((row) => row.rowId));\n let candidate = '';\n do {\n this.localRowSeq += 1;\n candidate = `client-${this.localRowSeq}`;\n } while (used.has(candidate));\n return candidate;\n }\n\n private setRowDraft(\n rowId: string,\n values: Record<string, unknown>,\n display: Record<string, unknown>,\n ): void {\n this.rowDrafts.set({ ...this.rowDrafts(), [rowId]: { values, display } });\n }\n\n private clearRowDraft(rowId: string): void {\n if (!rowId || !(rowId in this.rowDrafts())) return;\n const next = { ...this.rowDrafts() };\n delete next[rowId];\n this.rowDrafts.set(next);\n }\n\n private buildRow(\n id: string | number,\n rowId: string,\n entityId: number,\n values: Record<string, unknown>,\n display: Record<string, unknown> = {},\n ): EntityListRow {\n const row: EntityListRow = {\n Id: id,\n [ROW_ID_KEY]: rowId,\n [ROW_ENTITY_ID_KEY]: entityId,\n [ROW_VALUES_KEY]: values,\n // A drafted row is built from control values already, so there is\n // nothing to resolve — the two maps are the same.\n [ROW_PREFILL_KEY]: values,\n };\n for (const column of this.columns()) {\n // Form values are keyed by catalog property key (e.g. \"task_name\"),\n // but column.key is the normalizedKey (e.g. \"Name\"). Use propertyKey\n // for the lookup so the value is found.\n const key = column.propertyKey ?? column.key;\n row[column.key] = this.buildCell(column, values[key], display[key]);\n }\n return row;\n }\n\n /**\n * Render one table cell from a raw form value and its resolved label.\n *\n * The cell has to arrive in the shape the backend would have sent, because\n * that is what the entity renderers bind. Two things a control value is not:\n *\n * - **A scalar `value` is a string.** `mt-entity-percentage` reads `d.value`\n * only when `typeof` it is `'string'` and prints its placeholder otherwise,\n * so a numeric control value rendered as a filled bar with no number beside\n * it. Objects and arrays are the resolved shapes the rich renderers want,\n * and pass through untouched.\n * - **The column configuration has to travel with it.** Colour rules live\n * there, and `mt-entity-percentage` falls back to evaluating them itself\n * exactly when no per-value colour was resolved — which is every locally\n * added row. Without it a new 45% row rendered in the default colour while\n * the same value loaded from the backend rendered in its band colour.\n */\n private buildCell(\n column: EntityListColumnDef,\n raw: unknown,\n label: unknown,\n ): EntityData {\n const value = this.toLocalEntityValue(column.viewType, raw, label);\n const propertyKey = column.propertyKey ?? column.key;\n return {\n name: column.label ?? column.key,\n key: column.key,\n viewType: column.viewType ?? 'Text',\n value:\n value !== null && typeof value === 'object'\n ? value\n : (this.toRawValue(value) ?? ''),\n rawValue: this.toRawValue(raw) ?? undefined,\n configuration: column.configuration,\n propertyConfiguration:\n this.propertyByKey().get(propertyKey)?.configuration,\n } as unknown as EntityData;\n }\n\n /**\n * Shape a raw form value into the value an entity renderer expects for the\n * given view type. Locally-added rows carry raw form values, but renderers\n * like `mt-entity-user` need a display object (`{ displayName }`) — a\n * team-member `User` field is a select whose control value is a bare user id.\n * `label` is the resolved option display (present for select-based fields).\n */\n private toLocalEntityValue(\n viewType: string | undefined,\n raw: unknown,\n label: unknown,\n ): unknown {\n // A row loaded from a staged submission carries the backend's resolved\n // value as its label, and for the rich view types that object *is* what\n // the renderer binds — the same shape the raw branches below assemble by\n // hand. A select's resolved option is a plain string and still falls\n // through to them.\n const resolved =\n label != null && typeof label === 'object' && !Array.isArray(label)\n ? (label as Record<string, unknown>)\n : null;\n\n if (viewType === 'User') {\n if (Array.isArray(raw)) {\n const names = raw\n .map((entry) =>\n entry && typeof entry === 'object'\n ? ((entry as Record<string, unknown>)['displayName'] ?? '')\n : entry,\n )\n .filter((name) => name != null && name !== '');\n return names.length ? { displayName: names.join(', ') } : '';\n }\n if (resolved) {\n return {\n ...resolved,\n displayName: resolved['displayName'] ?? '',\n photoUrl: resolved['photoUrl'] ?? resolved['photo'] ?? '',\n };\n }\n if (raw && typeof raw === 'object') {\n const user = raw as Record<string, unknown>;\n return {\n ...user,\n displayName: user['displayName'] ?? label ?? '',\n photoUrl: user['photoUrl'] ?? user['photo'] ?? '',\n };\n }\n if (raw != null && raw !== '') {\n const name = label == null ? String(raw) : String(label);\n return { id: String(raw), displayName: name, userName: name };\n }\n return '';\n }\n\n if (viewType === 'Status' || viewType === 'Lookup') {\n if (resolved) return resolved;\n if (raw && typeof raw === 'object') return raw;\n if (raw != null && raw !== '' && label != null) {\n return { key: String(raw), display: String(label), color: '' };\n }\n return raw ?? '';\n }\n\n if (resolved) return resolved;\n\n // Translated text: the dialog binds `{ en, ar }`, but the text renderers\n // print only the `display` the backend adds to a loaded value — without\n // it the cell shows its placeholder.\n if (\n (viewType === 'Text' || viewType === 'LongText') &&\n isTranslatedText(raw)\n ) {\n return { ...raw, display: resolveLocalizedLabel(raw, this.lang()) };\n }\n\n // Plain / scalar view types: prefer a resolved option label when present,\n // else the raw value (unchanged for text / number / date / percentage).\n if (label != null && (raw == null || typeof raw !== 'object')) {\n return Array.isArray(label) ? label.join(', ') : label;\n }\n return raw ?? '';\n }\n\n // ============================================================================\n // Submit payload (see EntityList.md — \"Stored Value Shape\")\n // ============================================================================\n\n private emitValue(): void {\n // `entityIds` / `createdIds` / `updatedIds` / `snapshot`, and the loaded\n // `version` / `expectedVersions`, are backend-owned and passed through\n // untouched; the frontend only contributes pending rows, delete intents\n // and the change's id. `live` is response-only and stays behind.\n const { live: _live, ...current } = this.storedValue() ?? {};\n // `values[].value` is the backend's rendered label, carried only so the\n // table can print it. Submitting it back would echo a user object where\n // the stored scalar belongs.\n const rows = this.pendingRows().map((row) => ({\n ...row,\n values: (row.values ?? []).map(({ propertyKey, rawValue }) => ({\n propertyKey,\n rawValue,\n })),\n }));\n const deletedIds = this.deletedIds();\n const next: EntityListStoredValue = {\n ...current,\n rows,\n deletedIds,\n ...this.linkedMutationId(current, rows, deletedIds),\n };\n this.storedValue.set(next);\n this.lastEmittedJson = this.echoKey(next);\n this.onModelChange(next);\n this.onTouched();\n }\n\n /**\n * The id of the change a Related list's value carries. The backend rejects\n * a Related change without one (`entity_list.invalid_payload`), and the form\n * load sends it empty — so a value with rows or deletions gets its own: the\n * same while the change is (a retry of the same save), a new one when it\n * differs, since reusing an id for other content is refused\n * (`entity_list.linked_mutation_reused`). A value with nothing to apply keeps\n * what it loaded with; the backend skips it.\n */\n private linkedMutation: { key: string; id: string } | null = null;\n /** The loaded value's `mutationId`, restored once nothing is left to apply. */\n private loadedMutationId: string | undefined;\n\n private linkedMutationId(\n current: EntityListStoredValue,\n rows: EntityListSubmitRow[],\n deletedIds: number[],\n ): Pick<\n EntityListStoredValue,\n 'version' | 'mutationId' | 'expectedVersions'\n > {\n // `current` is the last emission, which may carry this session's id.\n if (rows.length === 0 && deletedIds.length === 0) {\n return { mutationId: this.loadedMutationId };\n }\n const version = Number(current.version ?? 0) || 0;\n const key = JSON.stringify({ version, rows, deletedIds });\n if (this.linkedMutation?.key !== key) {\n this.linkedMutation = { key, id: newLocalUuid() };\n }\n return {\n version,\n mutationId: this.linkedMutation.id,\n expectedVersions: current.expectedVersions ?? {},\n };\n }\n\n /**\n * `values[]` entries, restricted to `writeFields` when configured.\n *\n * `submitShaped` carries the dialog-normalized counterpart of `values`,\n * keyed the same way, and is preferred per key. The control value a rich\n * field holds is not the scalar the backend stores — a user picker holds\n * the whole search result, a date picker a `Date` — and only the dialog\n * knows the target module's view types, so it does that reduction. Without\n * it we would stringify the control value as-is and the row would carry a\n * JSON user object where a bare id belongs.\n */\n private toSubmitValues(\n values: Record<string, unknown>,\n submitShaped: Record<string, unknown> = {},\n ): EntityListSubmitValue[] {\n const allowed = new Set(this.writeFields());\n return Object.entries(values)\n .filter(([propertyKey]) => allowed.size === 0 || allowed.has(propertyKey))\n .map(([propertyKey, value]) => ({\n propertyKey,\n rawValue: this.toRawValue(\n propertyKey in submitShaped ? submitShaped[propertyKey] : value,\n ),\n }));\n }\n\n /** Backend `rawValue` is a serialized scalar; objects/arrays go as JSON. */\n private toRawValue(value: unknown): string | null {\n if (value == null || value === '') return null;\n if (value instanceof Date) return value.toISOString();\n if (typeof value === 'object') return JSON.stringify(value);\n return String(value);\n }\n\n private toValueMap(\n values: EntityListSubmitValue[] | undefined,\n ): Record<string, unknown> {\n const map: Record<string, unknown> = {};\n for (const value of values ?? []) {\n if (!value?.propertyKey) continue;\n map[value.propertyKey] = value.rawValue;\n }\n return map;\n }\n\n /**\n * Backend-resolved display values of a loaded row, keyed like `toValueMap`.\n *\n * A row the user just added carries its labels in a `rowDrafts` entry, but a\n * row that arrived on a loaded value has none — only what the backend\n * rendered beside each `rawValue`. Without this the approver's table prints\n * the stored scalar: a bare GUID where the assignee belongs.\n */\n private toDisplayMap(\n values: EntityListSubmitValue[] | undefined,\n ): Record<string, unknown> {\n const map: Record<string, unknown> = {};\n for (const value of values ?? []) {\n if (!value?.propertyKey || value.value === undefined) continue;\n map[value.propertyKey] = value.value;\n }\n return map;\n }\n\n private dropEmptyValues(\n values: Record<string, unknown>,\n ): Record<string, unknown> {\n const next: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(values)) {\n if (this.isEmptyValue(value)) continue;\n next[key] = value;\n }\n return next;\n }\n\n /**\n * Keys the user actually changed. A key that was empty before and is still\n * empty is skipped (the dialog simply could not pre-fill it); a key that had\n * a value and is now empty is kept so the backend clears it.\n *\n * `initial` holds stored scalars (a `User` column pre-fills as a bare id)\n * while `next` holds control values (the whole picker result), so the two\n * are only comparable once reduced — hence comparing `submitShaped`.\n * Comparing the rich value directly marked every rich-valued column as\n * changed even when untouched, and the partial update then rewrote it.\n */\n private diffValues(\n initial: Record<string, unknown>,\n next: Record<string, unknown>,\n submitShaped: Record<string, unknown> = {},\n ): Record<string, unknown> {\n const changed: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(next)) {\n const before = initial[key];\n const comparable = key in submitShaped ? submitShaped[key] : value;\n if (this.isEmptyValue(value) && this.isEmptyValue(before)) continue;\n if (this.isSameValue(before, comparable)) continue;\n changed[key] = value;\n }\n return changed;\n }\n\n private isEmptyValue(value: unknown): boolean {\n if (value == null || value === '') return true;\n if (Array.isArray(value)) return value.length === 0;\n return false;\n }\n\n private isSameValue(a: unknown, b: unknown): boolean {\n if (a === b) return true;\n // Values arriving from the read endpoint are serialized; compare the\n // submit-shaped representation so \"5\" and 5 are not treated as a change.\n return this.toRawValue(a) === this.toRawValue(b);\n }\n\n // ============================================================================\n // Read endpoints — GET Properties/{id}/entitylist/table-metadata (columns,\n // effective access, canonical keys) + POST fetch/query (rows)\n // ============================================================================\n\n /**\n * Load the runtime-scoped table description, then its rows.\n *\n * The metadata endpoint is the authorization boundary for this field: it\n * answers `403` when the user may not read the target module in this level,\n * so the columns are never built from a source that skipped that check.\n */\n private loadTable(\n propertyId: number,\n levelId: number | string | null,\n levelDataId: number | string | null,\n ): void {\n this.metadataSubscription?.unsubscribe();\n this.fetchSubscription?.unsubscribe();\n this.metadata.set(null);\n this.metadataFailure.set(null);\n this.columns.set([]);\n this.rows.set([]);\n this.comparison.set(null);\n this.comparisonUnsupported.set(false);\n this.chosenComparisonView.set(null);\n this.resetRevisions();\n this.errorMessage.set(null);\n this.loading.set(false);\n if (!(propertyId > 0) || levelId == null || !(Number(levelId) > 0)) return;\n\n this.loading.set(true);\n const ctx = this.context();\n this.metadataSubscription = this.http\n .get<{ data: EntityListTableMetadata }>(\n `Properties/${propertyId}/entitylist/table-metadata`,\n {\n params: { levelId: String(levelId) },\n // `403` (no module read access) and `404` (not configured for this\n // level) are states this field renders inline, not failures worth a\n // toast from the host's message interceptor.\n headers: { noMessage: 'true' },\n ...(ctx ? { context: ctx } : {}),\n },\n )\n .pipe(takeUntilDestroyed(this.destroyRef))\n .subscribe({\n next: (response) => this.applyMetadata(response.data, levelDataId),\n error: (error: HttpErrorResponse) => {\n this.loading.set(false);\n const failure = resolveMetadataFailure(error.status);\n this.metadataFailure.set(failure);\n // `forbidden` and `unavailable` are rendered as their own notice; only\n // a real request failure is an error.\n if (failure === 'failed') {\n this.errorMessage.set(\n this.transloco.translate('components.entityListField.loadFailed'),\n );\n }\n },\n });\n }\n\n /**\n * Apply the metadata, then fetch rows when there is a persisted parent to\n * scope them to. A draft parent (no `levelDataId`) and a write-only field\n * both stop at the columns — the first has no records yet, the second may\n * not read them.\n */\n private applyMetadata(\n metadata: EntityListTableMetadata,\n levelDataId: number | string | null,\n ): void {\n this.metadata.set(metadata);\n\n // A Local list's rows are the value; the source module is not read.\n if (this.localMode()) {\n this.loading.set(false);\n return;\n }\n\n this.columns.set(this.buildColumns(metadata));\n\n // A Selected list's rows are the records in its value. Fetching the source\n // module would list every related record, which is exactly what this mode\n // is not.\n if (this.selectionMode()) {\n this.loading.set(false);\n return;\n }\n\n const loadSourceRows = () => {\n if (\n !this.moduleBacked() ||\n !this.canRead() ||\n levelDataId == null ||\n Number(levelDataId) <= 0\n ) {\n this.loading.set(false);\n return;\n }\n\n this.fetchRows(\n metadata.levelId,\n levelDataId,\n metadata.moduleId,\n this.projectedKeys(),\n );\n };\n\n // A saved Related list opened from outside its form shows its preserved\n // or its current values, as configured — not whatever the source holds\n // today. An owner the comparison API does not know falls back to that.\n if (this.comparisonMode()) {\n this.fetchComparison(metadata.propertyId, loadSourceRows);\n return;\n }\n\n loadSourceRows();\n }\n\n /**\n * Table columns, in the order the backend returned them.\n *\n * `projectionMeta.columns[].key` is the catalog property key here — the same\n * key `fetch/query` keys its record values by — so a column maps onto a row\n * value directly. The lookup still falls back to `normalizedKey` so a column\n * fed from any other projection keeps resolving.\n *\n * The columns are the *union* of readable and writable fields, so a\n * write-only key arrives as a column too — a `Planned Finish` the user may\n * set in the dialog but may not read. It is not projected into the rows and\n * would render as an empty column, so only readable keys become columns.\n * Write-only access is the exception: its readable set is empty by\n * definition, and its stored rows have nothing else to render through.\n */\n private buildColumns(\n metadata: EntityListTableMetadata,\n ): EntityListColumnDef[] {\n const propertyByKey = new Map<string, FetchPropertyMeta>();\n const propertyByNormalizedKey = new Map<string, FetchPropertyMeta>();\n for (const property of metadata.catalog?.properties ?? []) {\n propertyByKey.set(property.key, property);\n propertyByNormalizedKey.set(property.normalizedKey, property);\n }\n const readable = new Set(metadata.readFields);\n\n return (metadata.projectionMeta?.columns ?? [])\n .filter((column) => column.visible)\n .filter((column) => readable.size === 0 || readable.has(column.key))\n .sort((a, b) => a.order - b.order)\n .map((column) => ({\n key: column.key,\n label: column.label,\n type: 'entity' as const,\n sortable: !UNSORTABLE_ENTITY_VIEW_TYPES.has(\n column.viewType as EntityViewType,\n ),\n viewType: column.viewType,\n order: column.order,\n visible: column.visible,\n configuration: column.configuration ?? null,\n propertyKey:\n (propertyByKey.has(column.key)\n ? column.key\n : propertyByNormalizedKey.get(column.key)?.key) ?? column.key,\n }));\n }\n\n /** Catalog properties of the loaded metadata, keyed by property key. */\n private readonly propertyByKey = computed<Map<string, FetchPropertyMeta>>(\n () => {\n const map = new Map<string, FetchPropertyMeta>();\n for (const property of this.metadata()?.catalog?.properties ?? []) {\n map.set(property.key, property);\n if (!map.has(property.normalizedKey)) {\n map.set(property.normalizedKey, property);\n }\n }\n return map;\n },\n );\n\n private fetchRows(\n levelId: number | string,\n levelDataId: number | string,\n moduleId: number | string,\n propertyKeys: string[],\n ): void {\n this.loading.set(true);\n this.errorMessage.set(null);\n\n const ctx = this.context();\n const body = {\n contextKey: `level:${levelId}/module:${moduleId}`,\n projection: 'Table' as const,\n surfaceKey: 'table',\n propertyKeys,\n filters: [\n {\n key: 'levelDataId',\n operator: 'Equals',\n value: String(levelDataId),\n },\n ],\n page: 1,\n pageSize: 3000,\n };\n\n this.fetchSubscription = this.http\n .post<FetchQueryResponse | { data?: FetchQueryResponse }>(\n 'fetch/query',\n body,\n ctx ? { context: ctx } : {},\n )\n .pipe(\n takeUntilDestroyed(this.destroyRef),\n finalize(() => this.loading.set(false)),\n catchError((err) => {\n console.error('EntityList fetch/query failed', err);\n this.errorMessage.set(\n this.transloco.translate('components.entityListField.loadFailed'),\n );\n return of<FetchQueryResponse>({});\n }),\n )\n .subscribe((response) => {\n const payload =\n response && typeof response === 'object' && 'data' in response\n ? ((response.data as FetchQueryResponse | undefined) ?? response)\n : response;\n this.applyRecords((payload as FetchQueryResponse).records ?? []);\n });\n }\n\n /**\n * Project fetched records onto the metadata columns.\n *\n * Cells are built per rendered column, but the row's value maps cover every\n * **projected** key — a writable key without a column has no cell to render\n * and still has to reach the edit dialog and the update diff.\n */\n private applyRecords(records: FetchRecord[]): void {\n const properties = this.propertyByKey();\n const columns = this.columns();\n const valueKeys = [\n ...new Set([\n ...this.projectedKeys(),\n ...columns.map((column) => column.propertyKey ?? column.key),\n ]),\n ];\n const viewTypeByKey = new Map(\n columns.map((column) => [\n column.propertyKey ?? column.key,\n column.viewType,\n ]),\n );\n\n this.rows.set(\n records.map((record) => {\n const values: Record<string, unknown> = {};\n const prefill: Record<string, unknown> = {};\n const row: EntityListRow = {\n Id: record.id,\n [ROW_ID_KEY]: `entity-${record.id}`,\n [ROW_ENTITY_ID_KEY]: record.id,\n };\n for (const column of columns) {\n const propertyKey = column.propertyKey ?? column.key;\n row[column.key] = this.toEntityData(\n column,\n record.values?.[propertyKey],\n properties.get(propertyKey),\n record.id,\n );\n }\n for (const key of valueKeys) {\n const cell = record.values?.[key];\n const viewType =\n viewTypeByKey.get(key) ?? properties.get(key)?.viewType ?? '';\n // Keep the machine-readable value as the baseline a partial update is\n // diffed against — it is the shape the row submits.\n values[key] = cell?.raw ?? cell?.value ?? null;\n // What the edit dialog patches into its form, which is not always the\n // same thing: see OBJECT_VALUED_VIEW_TYPES.\n if (OBJECT_VALUED_VIEW_TYPES.has(viewType)) {\n prefill[key] = cell?.value ?? cell?.raw ?? null;\n } else if (viewType === 'Checkbox') {\n // Stored as text (`'True'`/`'False'`), while `mt-toggle-field`\n // only shows a switch on as a strict `true` — see\n // `coerceCheckboxValue`.\n prefill[key] = coerceCheckboxValue(values[key]);\n } else {\n prefill[key] = values[key];\n }\n }\n row[ROW_VALUES_KEY] = values;\n row[ROW_PREFILL_KEY] = prefill;\n return row;\n }),\n );\n }\n\n private toEntityData(\n column: EntityListColumnDef,\n cell: FetchValueCell | undefined,\n property: FetchPropertyMeta | undefined,\n recordId: number,\n ): EntityData {\n return {\n id: recordId,\n propertyId: property?.id,\n key: property?.key ?? column.key,\n normalizedKey: property?.normalizedKey ?? column.key,\n name: column.label ?? property?.label ?? column.key,\n rawValue: serializeEntityRawValue(cell?.raw),\n color: readEntityValueColor(cell?.color),\n value: (cell?.value ?? '') as EntityData['value'],\n viewType: (column.viewType ?? 'Text') as EntityData['viewType'],\n type: property?.source,\n order: column.order ?? property?.order,\n configuration: column.configuration as\n | EntityData['configuration']\n | undefined,\n propertyConfiguration: property?.configuration ?? undefined,\n comparison: cell?.comparison,\n };\n }\n}\n","<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 (localReady()) {\r\n <!--\r\n A Local list: rows owned by this record, staged into its own submission.\r\n Add / edit / delete / drag follow the Local operation switches. Opened\r\n from a table cell, it can also show a saved revision's rows instead.\r\n -->\r\n @if (historyAvailable()) {\r\n <ng-container [ngTemplateOutlet]=\"history\" />\r\n }\r\n @if (showingRevision()) {\r\n <section\r\n class=\"flex flex-col gap-2 transition-opacity\"\r\n [class.opacity-60]=\"revisionLoading()\"\r\n >\r\n <ng-container [ngTemplateOutlet]=\"preservedHeading\" />\r\n @if (revisionLocalRows().length) {\r\n <mt-table\r\n [noCard]=\"true\"\r\n [data]=\"revisionLocalRows()\"\r\n [columns]=\"revisionLocalColumns()\"\r\n dataKey=\"Id\"\r\n />\r\n } @else {\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.preservedEmpty\" | transloco }}\r\n </div>\r\n }\r\n </section>\r\n } @else {\r\n @if (localCanCreate()) {\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)=\"openLocalRowDialog()\"\r\n />\r\n </div>\r\n }\r\n @if (localTableRows().length || localCanCreate()) {\r\n <mt-table\r\n [noCard]=\"true\"\r\n [data]=\"localTableRows()\"\r\n [columns]=\"localColumns()\"\r\n [rowActions]=\"localRowActions()\"\r\n [reorderableRows]=\"localCanReorder()\"\r\n (rowReorder)=\"onLocalReorder($event)\"\r\n dataKey=\"Id\"\r\n />\r\n } @else {\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.noLocalRows\" | transloco }}\r\n </div>\r\n }\r\n }\r\n } @else if (selectionReady()) {\r\n <!--\r\n A Selected list: the source records picked for this record, and nothing\r\n else. Picking and removing change only which records it holds. Opened\r\n from a table cell, a saved revision compares the records it held then\r\n with their values today.\r\n -->\r\n @if (historyAvailable()) {\r\n <ng-container [ngTemplateOutlet]=\"history\" />\r\n }\r\n @if (showingRevision()) {\r\n <ng-container [ngTemplateOutlet]=\"comparisonSections\" />\r\n } @else {\r\n @if (selectionWritable()) {\r\n <div class=\"flex justify-end\">\r\n <mt-button\r\n [label]=\"'components.entityListField.selectRecords' | transloco\"\r\n icon=\"general.plus\"\r\n size=\"small\"\r\n [disabled]=\"disabled()\"\r\n (onClick)=\"openSelectionDialog()\"\r\n />\r\n </div>\r\n }\r\n @if (selectionRows().length) {\r\n <mt-table\r\n [noCard]=\"true\"\r\n [data]=\"selectionRows()\"\r\n [columns]=\"columns()\"\r\n [rowActions]=\"selectionRowActions()\"\r\n dataKey=\"Id\"\r\n />\r\n } @else {\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.noSelectedRecords\" | transloco }}\r\n </div>\r\n }\r\n }\r\n } @else if (comparisonMode()) {\r\n <!--\r\n A saved Related list opened from outside its form: its sources' current\r\n values, and the values preserved when it was saved. A missing baseline is\r\n said as such — it is not an empty list.\r\n -->\r\n @if (!comparisonReady()) {\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 {\r\n @if (historyAvailable()) {\r\n <ng-container [ngTemplateOutlet]=\"history\" />\r\n }\r\n <ng-container [ngTemplateOutlet]=\"comparisonSections\" />\r\n }\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\r\n<!--\r\n Saved list revisions: each successful save of this list, newest first.\r\n Picking one shows what it preserved — beside today's values of the records\r\n it held, for a linked list. Read-only: history is never submitted.\r\n-->\r\n<ng-template #history>\r\n <div class=\"flex flex-wrap items-center justify-between gap-2\">\r\n <div class=\"flex flex-wrap items-center gap-2\">\r\n @if (viewedRevision(); as version) {\r\n <span\r\n class=\"rounded-md border border-primary-200 bg-primary-50 px-2 py-0.5 text-xs font-medium text-primary-700\"\r\n >\r\n {{\r\n \"components.entityListField.viewingRevision\"\r\n | transloco: { version: version }\r\n }}\r\n </span>\r\n <mt-button\r\n [label]=\"'components.entityListField.backToLatest' | transloco\"\r\n size=\"small\"\r\n variant=\"text\"\r\n [disabled]=\"revisionLoading()\"\r\n (onClick)=\"showRevision(null)\"\r\n />\r\n }\r\n </div>\r\n <mt-button\r\n [label]=\"'components.entityListField.revisions' | transloco\"\r\n icon=\"time.clock-rewind\"\r\n size=\"small\"\r\n severity=\"secondary\"\r\n variant=\"outlined\"\r\n (onClick)=\"toggleRevisions()\"\r\n />\r\n </div>\r\n\r\n @if (revisionsOpen()) {\r\n <div\r\n class=\"flex flex-col gap-2 rounded-md border border-surface bg-surface-50 p-3\"\r\n >\r\n <p class=\"text-xs text-muted-color\">\r\n {{ \"components.entityListField.revisionsHint\" | transloco }}\r\n </p>\r\n @if (revisionsError(); as message) {\r\n <p class=\"text-sm text-red-600\">{{ message }}</p>\r\n }\r\n @for (revision of revisionItems(); track revision.version) {\r\n <button\r\n type=\"button\"\r\n class=\"flex items-center justify-between gap-3 rounded-md border px-3 py-2 text-start text-sm transition-colors\"\r\n [class.border-primary-200]=\"viewedRevision() === revision.version\"\r\n [class.bg-primary-50]=\"viewedRevision() === revision.version\"\r\n [class.border-surface]=\"viewedRevision() !== revision.version\"\r\n [class.bg-content]=\"viewedRevision() !== revision.version\"\r\n [disabled]=\"revisionLoading()\"\r\n (click)=\"showRevision(revision.version)\"\r\n >\r\n <span class=\"font-medium text-color\">\r\n {{\r\n \"components.entityListField.revisionLabel\"\r\n | transloco: { version: revision.version }\r\n }}\r\n </span>\r\n <span\r\n class=\"flex min-w-0 flex-wrap items-center justify-end gap-x-2 text-xs text-muted-color\"\r\n >\r\n <span class=\"truncate\">{{ revision.author }}</span>\r\n <span>{{ revision.createdAt | mtDateFormat: \"dateTime\" }}</span>\r\n </span>\r\n </button>\r\n } @empty {\r\n @if (!revisionsLoading() && !revisionsError()) {\r\n <p class=\"text-sm text-muted-color\">\r\n {{ \"components.entityListField.noRevisions\" | transloco }}\r\n </p>\r\n }\r\n }\r\n @if (revisionsLoading()) {\r\n <p-skeleton width=\"100%\" height=\"2.25rem\" borderRadius=\"0.375rem\" />\r\n } @else if (hasMoreRevisions()) {\r\n <div class=\"flex justify-center\">\r\n <mt-button\r\n [label]=\"'components.entityListField.loadMore' | transloco\"\r\n size=\"small\"\r\n variant=\"text\"\r\n (onClick)=\"loadRevisions()\"\r\n />\r\n </div>\r\n }\r\n </div>\r\n }\r\n\r\n @if (revisionError(); as message) {\r\n <div\r\n class=\"rounded-md border border-red-200 bg-red-50 p-3 text-sm text-red-700\"\r\n >\r\n {{ message }}\r\n </div>\r\n }\r\n</ng-template>\r\n\r\n<!-- \"Preserved values\", with when they were captured. -->\r\n<ng-template #preservedHeading>\r\n <h4\r\n class=\"flex flex-wrap items-baseline gap-2 text-sm font-semibold text-color\"\r\n >\r\n {{ \"components.entityListField.preservedValues\" | transloco }}\r\n @if (preservedAt(); as capturedAt) {\r\n <span class=\"text-xs font-normal text-muted-color\">\r\n {{\r\n \"components.entityListField.preservedAt\"\r\n | transloco: { date: (capturedAt | mtDateFormat: \"dateTime\") }\r\n }}\r\n </span>\r\n }\r\n </h4>\r\n</ng-template>\r\n\r\n<!--\r\n A linked list's comparison, one table at a time: the values preserved when\r\n it was saved, or its source records' current values. It opens on the\r\n property's configured mode. A missing baseline says so — it is never\r\n replaced by the current values.\r\n-->\r\n<ng-template #comparisonSections>\r\n <div class=\"flex flex-wrap items-center justify-between gap-2\">\r\n <mt-tabs\r\n size=\"small\"\r\n [options]=\"comparisonViewOptions()\"\r\n [active]=\"comparisonView()\"\r\n (onChange)=\"setComparisonView($event)\"\r\n />\r\n @if (comparisonView() === \"preserved\" && preservedAvailable()) {\r\n @if (preservedAt(); as capturedAt) {\r\n <span class=\"text-xs text-muted-color\">\r\n {{\r\n \"components.entityListField.preservedAt\"\r\n | transloco: { date: (capturedAt | mtDateFormat: \"dateTime\") }\r\n }}\r\n </span>\r\n }\r\n }\r\n </div>\r\n\r\n <section\r\n class=\"flex flex-col gap-2 transition-opacity\"\r\n [class.opacity-60]=\"revisionLoading()\"\r\n >\r\n @if (comparisonView() === \"current\") {\r\n @if (liveRows().length) {\r\n <mt-table\r\n [noCard]=\"true\"\r\n [data]=\"liveRows()\"\r\n [columns]=\"columns()\"\r\n dataKey=\"Id\"\r\n />\r\n } @else {\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 }\r\n } @else if (!preservedAvailable()) {\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.noPreservedSnapshot\" | transloco }}\r\n </div>\r\n } @else if (preservedRows().length) {\r\n <mt-table\r\n [noCard]=\"true\"\r\n [data]=\"preservedRows()\"\r\n [columns]=\"columns()\"\r\n dataKey=\"Id\"\r\n />\r\n } @else {\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.preservedEmpty\" | transloco }}\r\n </div>\r\n }\r\n </section>\r\n\r\n @if (unavailableCount()) {\r\n <p class=\"text-xs text-muted-color\">\r\n {{\r\n \"components.entityListField.unavailableRecords\"\r\n | transloco: { count: unavailableCount() }\r\n }}\r\n </p>\r\n }\r\n</ng-template>\r\n","import { Provider } from '@angular/core';\r\nimport { ENTITY_LIST_TABLE_COMPONENT } from '@masterteam/components/entities';\r\nimport { EntityListField } from './entity-list-field';\r\n\r\n/**\r\n * Lets `mt-entity-list-preview` render a module-backed `EntityList` as the\r\n * real, fetched table instead of its count-and-drawer trigger.\r\n *\r\n * Pair it with an `EntityRuntimeContextStore` carrying the owning level and\r\n * level-data ids — the preview needs both, and without the context this\r\n * provider changes nothing. `mt-client-instance-preview` sets both up, so a\r\n * host rendering preview cards through it needs neither.\r\n *\r\n * The indirection exists because `entities` cannot import `table`: `table`\r\n * already imports `entities`, and they are separate entry points of\r\n * `@masterteam/components`. See `ENTITY_LIST_TABLE_COMPONENT`.\r\n *\r\n * ```ts\r\n * @Component({\r\n * providers: [EntityRuntimeContextStore, provideEntityListTablePreview()],\r\n * })\r\n * ```\r\n */\r\nexport function provideEntityListTablePreview(): Provider {\r\n return { provide: ENTITY_LIST_TABLE_COMPONENT, useValue: EntityListField };\r\n}\r\n","import {\n ChangeDetectionStrategy,\n Component,\n computed,\n DestroyRef,\n effect,\n inject,\n input,\n signal,\n untracked,\n} from '@angular/core';\nimport { takeUntilDestroyed } from '@angular/core/rxjs-interop';\nimport {\n ControlValueAccessor,\n FormsModule,\n NgControl,\n Validators,\n} from '@angular/forms';\nimport { HttpClient, HttpContext, HttpParams } from '@angular/common/http';\nimport {\n EMPTY,\n Observable,\n catchError,\n expand,\n finalize,\n map,\n of,\n reduce,\n} from 'rxjs';\nimport { MultiSelectField } from '@masterteam/components/multi-select-field';\nimport { SelectField } from '@masterteam/components/select-field';\nimport type { ScheduleItemSelectorFieldRuntimeContext } from '@masterteam/components';\n\n/** One picker option — only the name is shown. */\ninterface ScheduleItemOption {\n label: string;\n value: number;\n}\n\ninterface ScheduleItemSelectorOptionsResponse {\n data?: {\n items?: Array<{ key: string; name: string }> | null;\n hasMore?: boolean;\n } | null;\n}\n\n/** Page size when loading the full deliverable list, and a hard safety cap. */\nconst PAGE_SIZE = 100;\nconst MAX_ITEMS = 5000;\n\n/**\n * Runtime picker for `ScheduleItemSelector` properties.\n *\n * Backend-filtered: the full option list comes from\n * `GET forms/options/{propertyKey}` (which applies the configured rule, e.g.\n * `DeliverableAcceptance.AvailableDeliverables`). All available items are\n * loaded up front and rendered with the standard `mt-select-field` /\n * `mt-multi-select-field`; the field shows only the item name.\n *\n * The control value is always a numeric id array (`valueMode = \"IdArray\"`).\n * In `Single` mode only one id may be selected.\n */\n@Component({\n selector: 'mt-schedule-item-selector-field',\n standalone: true,\n imports: [FormsModule, MultiSelectField, SelectField],\n templateUrl: './schedule-item-selector-field.html',\n changeDetection: ChangeDetectionStrategy.OnPush,\n host: {\n class: 'block',\n },\n})\nexport class ScheduleItemSelectorField implements ControlValueAccessor {\n readonly label = input<string>('');\n readonly placeholder = input<string>('');\n readonly readonly = input<boolean>(false);\n readonly required = input<boolean>(false);\n readonly propertyKey = input<string>('');\n readonly selectionMode = input<'Single' | 'Multi'>('Multi');\n readonly runtimeContext =\n input<ScheduleItemSelectorFieldRuntimeContext | null>(null);\n readonly context = input<HttpContext | undefined>(undefined);\n\n /** Full list of available deliverables (loaded once). */\n readonly options = signal<ScheduleItemOption[]>([]);\n readonly loading = signal(false);\n readonly disabled = signal(false);\n /** Selected ids — the control value (`number[]`). */\n readonly value = signal<number[]>([]);\n\n readonly isMultiple = computed(() => this.selectionMode() !== 'Single');\n /** Single-mode ngModel value (a scalar id, not an array). */\n readonly singleValue = computed(() => this.value()[0] ?? null);\n\n public ngControl: NgControl | null = null;\n\n onTouched: () => void = () => {};\n onModelChange: (value: number[] | null) => void = () => {};\n\n private readonly http = inject(HttpClient);\n private readonly destroyRef = inject(DestroyRef);\n /** Query signature already loaded — prevents duplicate full loads. */\n private loadedKey: string | null = null;\n\n constructor() {\n this.ngControl = inject(NgControl, { self: true, optional: true });\n if (this.ngControl) {\n this.ngControl.valueAccessor = this;\n }\n\n effect(() => {\n if (this.ngControl?.control && this.required()) {\n this.ngControl.control.addValidators(Validators.required);\n this.ngControl.control.updateValueAndValidity();\n }\n });\n\n // Load the full option list as soon as the query context is available.\n effect(() => {\n const key = this.queryKey();\n if (!key || this.loadedKey === key) return;\n untracked(() => this.loadAllOptions(key));\n });\n }\n\n // ── Selection ──────────────────────────────────────────────────────────\n\n onMultiChange(ids: number[] | null): void {\n this.value.set(ids ?? []);\n this.emit();\n }\n\n onSingleChange(id: number | null): void {\n this.value.set(id == null ? [] : [id]);\n this.emit();\n }\n\n // ── ControlValueAccessor ────────────────────────────────────────────────\n\n writeValue(value: unknown): void {\n this.value.set(this.normalizeIds(value));\n }\n\n registerOnChange(fn: (value: number[] | null) => void): void {\n this.onModelChange = fn;\n }\n\n registerOnTouched(fn: () => void): void {\n this.onTouched = fn;\n }\n\n setDisabledState(disabled: boolean): void {\n this.disabled.set(disabled);\n }\n\n // ── Option loading ──────────────────────────────────────────────────────\n\n private loadAllOptions(key: string): void {\n this.loadedKey = key;\n this.loading.set(true);\n\n this.fetchPage(0)\n .pipe(\n expand((page) =>\n page.hasMore && page.nextSkip < MAX_ITEMS\n ? this.fetchPage(page.nextSkip)\n : EMPTY,\n ),\n reduce(\n (acc, page) => acc.concat(page.options),\n [] as ScheduleItemOption[],\n ),\n takeUntilDestroyed(this.destroyRef),\n finalize(() => this.loading.set(false)),\n catchError(() => of([] as ScheduleItemOption[])),\n )\n .subscribe((options) => this.options.set(options));\n }\n\n private fetchPage(skip: number): Observable<{\n options: ScheduleItemOption[];\n hasMore: boolean;\n nextSkip: number;\n }> {\n const params = this.buildParams(skip);\n if (!params) {\n return of({ options: [], hasMore: false, nextSkip: skip });\n }\n\n return this.http\n .get<ScheduleItemSelectorOptionsResponse>(\n `forms/options/${encodeURIComponent(this.propertyKey())}`,\n { params, context: this.context() },\n )\n .pipe(\n map((response) => ({\n options: this.mapOptions(response),\n hasMore: !!response?.data?.hasMore,\n nextSkip: skip + PAGE_SIZE,\n })),\n );\n }\n\n private buildParams(skip: number): HttpParams | null {\n const contextKey = this.buildContextKey();\n const levelDataId = this.runtimeContext()?.levelDataId;\n if (!contextKey || levelDataId == null) return null;\n\n let params = new HttpParams()\n .set('contextKey', contextKey)\n .set('levelDataId', String(levelDataId))\n .set('skip', String(skip))\n .set('take', String(PAGE_SIZE));\n\n const ownerRecordId = this.runtimeContext()?.ownerRecordId;\n if (ownerRecordId != null) {\n params = params.set('ownerRecordId', String(ownerRecordId));\n }\n return params;\n }\n\n private mapOptions(\n response: ScheduleItemSelectorOptionsResponse,\n ): ScheduleItemOption[] {\n const items = response?.data?.items ?? [];\n return items\n .map((item) => {\n const id = Number(item.key);\n if (!Number.isFinite(id)) return null;\n return { label: item.name || String(id), value: id };\n })\n .filter((option): option is ScheduleItemOption => option != null);\n }\n\n // ── Context helpers ─────────────────────────────────────────────────────\n\n private buildContextKey(): string | null {\n const levelId = this.runtimeContext()?.levelId;\n const moduleId = this.runtimeContext()?.moduleId;\n if (levelId == null || moduleId == null) return null;\n return `Level:${levelId}/Module:${moduleId}`;\n }\n\n private queryKey(): string | null {\n const contextKey = this.buildContextKey();\n const levelDataId = this.runtimeContext()?.levelDataId;\n const propertyKey = this.propertyKey();\n if (!contextKey || levelDataId == null || !propertyKey) return null;\n const ownerRecordId = this.runtimeContext()?.ownerRecordId ?? '';\n return `${contextKey}|${levelDataId}|${ownerRecordId}|${propertyKey}`;\n }\n\n private emit(): void {\n this.onModelChange(this.value());\n this.onTouched();\n }\n\n private normalizeIds(value: unknown): number[] {\n const raw = Array.isArray(value) ? value : value == null ? [] : [value];\n const ids: number[] = [];\n for (const entry of raw) {\n const id =\n entry && typeof entry === 'object'\n ? Number((entry as { id?: unknown }).id)\n : Number(entry);\n if (Number.isFinite(id) && id > 0 && !ids.includes(id)) {\n ids.push(id);\n }\n }\n return ids;\n }\n}\n","@if (isMultiple()) {\n <mt-multi-select-field\n [label]=\"label()\"\n [placeholder]=\"placeholder()\"\n [options]=\"options()\"\n [optionLabel]=\"'label'\"\n [optionValue]=\"'value'\"\n [filter]=\"options().length > 10\"\n [showClear]=\"!required()\"\n [required]=\"required()\"\n [readonly]=\"readonly() || disabled()\"\n [ngModel]=\"value()\"\n [ngModelOptions]=\"{ standalone: true }\"\n (ngModelChange)=\"onMultiChange($event)\"\n />\n} @else {\n <mt-select-field\n [label]=\"label()\"\n [placeholder]=\"placeholder()\"\n [options]=\"options()\"\n [optionLabel]=\"'label'\"\n [optionValue]=\"'value'\"\n [filter]=\"options().length > 10\"\n [showClear]=\"!required()\"\n [loading]=\"loading()\"\n [required]=\"required()\"\n [readonly]=\"readonly() || disabled()\"\n [ngModel]=\"singleValue()\"\n [ngModelOptions]=\"{ standalone: true }\"\n (ngModelChange)=\"onSingleChange($event)\"\n />\n}\n","import { InjectionToken, Type } from '@angular/core';\r\nimport type { LookupOptionItemConfig } from '@masterteam/components';\r\n\r\n/**\r\n * Inputs for the injected checklist form (one instance per field). It loads the\r\n * scope module form once and renders a collapsible section per lookup item.\r\n * Passed via `ngComponentOutlet` inputs.\r\n */\r\nexport interface LookupCheckListFormInputs {\r\n /** Lookup items rendered as collapsible sections. */\r\n lookupOptions: LookupOptionItemConfig[];\r\n /** Full lookup catalog used to resolve nested lookup fields. */\r\n lookups: unknown[];\r\n /** Property keys to render in each section form. */\r\n propertyKeys: string[];\r\n /** Scope module id whose form is loaded once via `process-form-load`. */\r\n moduleId: number | string | null;\r\n /** Current level id. */\r\n levelId: number | string | null;\r\n /** Current workspace instance id. */\r\n levelDataId: number | string | null;\r\n /** Current aggregated value (array of `{ lookupKey, props }`). */\r\n value: unknown;\r\n /** Whether the field is read-only. */\r\n readonly: boolean;\r\n /** Called whenever the aggregated checklist value changes. */\r\n valueChange: (value: unknown) => void;\r\n /** Called whenever the aggregated validity changes (true = incomplete). */\r\n validityChange: (invalid: boolean) => void;\r\n}\r\n\r\n/**\r\n * Token used by `mt-lookup-module-check-list-field` to render the checklist\r\n * sections + per-section forms via `@masterteam/forms`'s `mt-client-form`\r\n * machinery (`/api/process-form-load`, loaded once). Apps register it with\r\n * `provideLookupModuleCheckListForm()` from\r\n * `@masterteam/forms/lookup-module-check-list-form`. When the token is not\r\n * registered, the field falls back to plain text inputs per property.\r\n */\r\nexport const LOOKUP_CHECK_LIST_FORM_COMPONENT = new InjectionToken<\r\n Type<unknown>\r\n>('LOOKUP_CHECK_LIST_FORM_COMPONENT');\r\n","import {\r\n ChangeDetectionStrategy,\r\n Component,\r\n computed,\r\n inject,\r\n input,\r\n OnInit,\r\n signal,\r\n} from '@angular/core';\r\nimport { NgComponentOutlet } from '@angular/common';\r\nimport {\r\n AbstractControl,\r\n ControlValueAccessor,\r\n FormsModule,\r\n NgControl,\r\n ValidatorFn,\r\n} from '@angular/forms';\r\nimport { TranslocoPipe } from '@jsverse/transloco';\r\nimport { InputTextModule } from 'primeng/inputtext';\r\n\r\nimport { Icon } from '@masterteam/icons';\r\nimport { FieldValidation } from '@masterteam/components/field-validation';\r\nimport type {\r\n LookupCheckListPropertyConfig,\r\n LookupModuleCheckListFieldRuntimeContext,\r\n LookupOptionItemConfig,\r\n} from '@masterteam/components';\r\n\r\nimport {\r\n LOOKUP_CHECK_LIST_FORM_COMPONENT,\r\n type LookupCheckListFormInputs,\r\n} from './lookup-module-check-list-form-token';\r\n\r\n/** Stored entry as persisted in the property value array. */\r\ninterface StoredCheckListProp {\r\n key: string;\r\n value: unknown;\r\n}\r\ninterface StoredCheckListEntry {\r\n lookupKey: string;\r\n props: StoredCheckListProp[];\r\n}\r\n\r\n/** A collapsible section bound to one lookup item. */\r\ninterface CheckListSection {\r\n lookupKey: string;\r\n label: string;\r\n}\r\n\r\n@Component({\r\n selector: 'mt-lookup-module-check-list-field',\r\n standalone: true,\r\n imports: [\r\n FormsModule,\r\n NgComponentOutlet,\r\n InputTextModule,\r\n Icon,\r\n FieldValidation,\r\n TranslocoPipe,\r\n ],\r\n templateUrl: './lookup-module-check-list-field.html',\r\n changeDetection: ChangeDetectionStrategy.OnPush,\r\n host: { class: 'grid gap-2' },\r\n})\r\nexport class LookupModuleCheckListField\r\n implements ControlValueAccessor, OnInit\r\n{\r\n readonly label = input<string>('');\r\n readonly readonly = input<boolean>(false);\r\n readonly required = input<boolean>(false);\r\n /** Lookup items rendered as collapsible checklist sections. */\r\n readonly lookupOptions = input<LookupOptionItemConfig[]>([]);\r\n /** Full lookup catalog passed to the rich nested form renderer. */\r\n readonly lookups = input<unknown[]>([]);\r\n /** Module property keys/labels (used by the text fallback + labels). */\r\n readonly propertyFields = input<LookupCheckListPropertyConfig[]>([]);\r\n /** Scope module id whose form is loaded for each section. */\r\n readonly scopeId = input<number | string | null>(null);\r\n /** Property keys to render in each section form. */\r\n readonly propertyKeys = input<string[]>([]);\r\n /** Runtime ids needed to load each section form. */\r\n readonly runtimeContext =\r\n input<LookupModuleCheckListFieldRuntimeContext | null>(null);\r\n\r\n /** Per-lookupKey captured values, keyed by property key. */\r\n private readonly sectionValues = signal<\r\n Record<string, Record<string, unknown>>\r\n >({});\r\n private readonly expandedKeys = signal<Set<string>>(new Set());\r\n protected readonly disabled = signal<boolean>(false);\r\n /** True when a section's required inner fields are unfilled. */\r\n private readonly incomplete = signal<boolean>(false);\r\n public ngControl: NgControl | null = null;\r\n\r\n /**\r\n * Rich checklist form provided by `@masterteam/forms`\r\n * (`provideLookupModuleCheckListForm()`). When absent the field falls back to\r\n * plain text inputs per property.\r\n */\r\n protected readonly formComponent = inject(LOOKUP_CHECK_LIST_FORM_COMPONENT, {\r\n optional: true,\r\n });\r\n\r\n protected readonly isReadonly = computed(\r\n () => this.readonly() || this.disabled(),\r\n );\r\n\r\n protected readonly sections = computed<CheckListSection[]>(() =>\r\n this.lookupOptions().map((option) => ({\r\n lookupKey: String(option.value ?? option.key ?? ''),\r\n label: option.label ?? String(option.value ?? option.key ?? ''),\r\n })),\r\n );\r\n\r\n /**\r\n * Use the rich form whenever it's registered and a scope module is set. The\r\n * scope form only needs `scopeId` to load its field definitions; `levelId` /\r\n * `levelDataId` are passed when available but are not required (e.g. they are\r\n * null while creating a brand-new Level instance).\r\n */\r\n protected readonly useRichForm = computed(\r\n () => !!this.formComponent && this.scopeId() != null,\r\n );\r\n\r\n /**\r\n * The last externally-written value (via `writeValue`). Passed to the rich\r\n * form as its initial value. It is intentionally NOT updated from the form's\r\n * own `valueChange` — feeding emitted values back as an input would create an\r\n * infinite change-detection loop.\r\n */\r\n private readonly incomingValue = signal<unknown>(null);\r\n\r\n private onTouched: () => void = () => {};\r\n private onModelChange: (value: StoredCheckListEntry[] | null) => void =\r\n () => {};\r\n\r\n private control: AbstractControl | null = null;\r\n private validatorAttached = false;\r\n /**\r\n * Validator attached imperatively to the host control. Attaching it here\r\n * (rather than via an `NG_VALIDATORS` provider) avoids a circular dependency\r\n * with the self-injected `NgControl` used as the value accessor.\r\n */\r\n private readonly checklistValidator: ValidatorFn = () =>\r\n this.incomplete() ? { checklistIncomplete: true } : null;\r\n\r\n /** Stable callbacks so the outlet inputs object stays referentially calm. */\r\n private readonly emitValue = (value: unknown): void => {\r\n // The rich form is the source of truth; forward its value without writing\r\n // back into `incomingValue` (which would re-feed the form and loop).\r\n this.onModelChange((value as StoredCheckListEntry[] | null) ?? null);\r\n this.onTouched();\r\n };\r\n private readonly emitValidity = (invalid: boolean): void => {\r\n if (this.incomplete() === invalid) return;\r\n this.incomplete.set(invalid);\r\n this.ensureValidator();\r\n this.control?.updateValueAndValidity({ emitEvent: false });\r\n };\r\n\r\n constructor() {\r\n this.ngControl = inject(NgControl, { self: true, optional: true });\r\n if (this.ngControl) {\r\n this.ngControl.valueAccessor = this;\r\n }\r\n }\r\n\r\n ngOnInit(): void {\r\n this.ensureValidator();\r\n this.control?.updateValueAndValidity({ emitEvent: false });\r\n }\r\n\r\n private ensureValidator(): void {\r\n if (this.validatorAttached) return;\r\n const control = this.ngControl?.control;\r\n if (!control) return;\r\n this.control = control;\r\n control.addValidators(this.checklistValidator);\r\n this.validatorAttached = true;\r\n }\r\n\r\n // ============================================================================\r\n // CVA\r\n // ============================================================================\r\n\r\n writeValue(value: unknown): void {\r\n this.incomingValue.set(value);\r\n this.sectionValues.set(this.normalizeIncoming(value));\r\n }\r\n\r\n registerOnChange(fn: (value: StoredCheckListEntry[] | null) => void): void {\r\n this.onModelChange = fn;\r\n }\r\n\r\n registerOnTouched(fn: () => void): void {\r\n this.onTouched = fn;\r\n }\r\n\r\n setDisabledState(isDisabled: boolean): void {\r\n this.disabled.set(isDisabled);\r\n }\r\n\r\n // ============================================================================\r\n // Rich form host\r\n // ============================================================================\r\n\r\n protected readonly formInputs = computed<LookupCheckListFormInputs>(() => ({\r\n lookupOptions: this.lookupOptions(),\r\n lookups: this.lookups(),\r\n propertyKeys: this.propertyKeys(),\r\n moduleId: this.scopeId(),\r\n levelId: this.runtimeContext()?.levelId ?? null,\r\n levelDataId: this.runtimeContext()?.levelDataId ?? null,\r\n value: this.incomingValue(),\r\n readonly: this.isReadonly(),\r\n valueChange: this.emitValue,\r\n validityChange: this.emitValidity,\r\n }));\r\n\r\n // ============================================================================\r\n // Text fallback (no rich form registered)\r\n // ============================================================================\r\n\r\n protected isExpanded(lookupKey: string): boolean {\r\n return this.expandedKeys().has(lookupKey);\r\n }\r\n\r\n protected toggle(lookupKey: string): void {\r\n const next = new Set(this.expandedKeys());\r\n if (next.has(lookupKey)) {\r\n next.delete(lookupKey);\r\n } else {\r\n next.add(lookupKey);\r\n }\r\n this.expandedKeys.set(next);\r\n }\r\n\r\n protected hasValues(lookupKey: string): boolean {\r\n const values = this.sectionValues()[lookupKey];\r\n if (!values) return false;\r\n return Object.values(values).some((v) => v != null && v !== '');\r\n }\r\n\r\n protected fieldValue(lookupKey: string, propKey: string): string {\r\n const raw = this.sectionValues()[lookupKey]?.[propKey];\r\n return raw == null ? '' : String(raw);\r\n }\r\n\r\n protected setFieldValue(\r\n lookupKey: string,\r\n propKey: string,\r\n value: string,\r\n ): void {\r\n this.sectionValues.update((current) => ({\r\n ...current,\r\n [lookupKey]: { ...(current[lookupKey] ?? {}), [propKey]: value },\r\n }));\r\n this.pushModelValue();\r\n }\r\n\r\n // ============================================================================\r\n // Value mapping\r\n // ============================================================================\r\n\r\n private pushModelValue(): void {\r\n const payload = this.buildPayload();\r\n this.onModelChange(payload.length ? payload : null);\r\n this.onTouched();\r\n }\r\n\r\n private buildPayload(): StoredCheckListEntry[] {\r\n const keys = this.propertyKeys();\r\n const values = this.sectionValues();\r\n\r\n return this.sections()\r\n .filter((section) => this.hasValues(section.lookupKey))\r\n .map((section) => ({\r\n lookupKey: section.lookupKey,\r\n props: keys.map((key) => ({\r\n key,\r\n value: values[section.lookupKey]?.[key] ?? null,\r\n })),\r\n }));\r\n }\r\n\r\n private normalizeIncoming(\r\n value: unknown,\r\n ): Record<string, Record<string, unknown>> {\r\n const raw = this.extractEntries(value);\r\n const result: Record<string, Record<string, unknown>> = {};\r\n\r\n for (const entry of raw) {\r\n if (!entry || typeof entry !== 'object') continue;\r\n const record = entry as Record<string, unknown>;\r\n const lookupKeyRaw =\r\n record['lookupKey'] ?? record['Lookupkey'] ?? record['lookupkey'];\r\n const lookupKey = lookupKeyRaw == null ? '' : String(lookupKeyRaw);\r\n if (!lookupKey) continue;\r\n\r\n const propsRaw = record['props'] ?? record['Props'];\r\n const values: Record<string, unknown> = {};\r\n if (Array.isArray(propsRaw)) {\r\n for (const prop of propsRaw) {\r\n const propRecord = (prop ?? {}) as Record<string, unknown>;\r\n const key = String(propRecord['key'] ?? propRecord['Key'] ?? '');\r\n if (!key) continue;\r\n values[key] = propRecord['value'] ?? propRecord['Value'] ?? null;\r\n }\r\n }\r\n result[lookupKey] = values;\r\n }\r\n\r\n return result;\r\n }\r\n\r\n private extractEntries(value: unknown): unknown[] {\r\n if (Array.isArray(value)) {\r\n return value;\r\n }\r\n\r\n const wrapped = (value as { items?: unknown } | null)?.items;\r\n if (Array.isArray(wrapped)) {\r\n return wrapped;\r\n }\r\n\r\n if (typeof value === 'string' && value.trim()) {\r\n try {\r\n return this.extractEntries(JSON.parse(value));\r\n } catch {\r\n return [];\r\n }\r\n }\r\n\r\n return [];\r\n }\r\n}\r\n","<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 (useRichForm()) {\n <ng-container\n [ngComponentOutlet]=\"formComponent!\"\n [ngComponentOutletInputs]=\"formInputs()\"\n />\n } @else if (sections().length) {\n <!-- Fallback: plain text inputs per property (no rich form registered) -->\n <div class=\"flex flex-col gap-2\">\n @for (section of sections(); track section.lookupKey) {\n <div class=\"overflow-hidden rounded-lg border border-surface-200\">\n <button\n type=\"button\"\n class=\"flex w-full cursor-pointer items-center justify-between gap-2 bg-surface-50 px-3 py-2 text-start hover:bg-surface-100\"\n [attr.aria-expanded]=\"isExpanded(section.lookupKey)\"\n (click)=\"toggle(section.lookupKey)\"\n >\n <span class=\"flex min-w-0 items-center gap-2\">\n <mt-icon\n [icon]=\"\n isExpanded(section.lookupKey)\n ? 'arrow.chevron-down'\n : 'arrow.chevron-right'\n \"\n size=\"sm\"\n class=\"shrink-0 text-muted-color rtl:-scale-x-100\"\n />\n <span class=\"truncate text-sm font-medium text-color\">\n {{ section.label }}\n </span>\n </span>\n @if (hasValues(section.lookupKey)) {\n <span\n class=\"shrink-0 rounded-full bg-primary-50 px-2 py-0.5 text-xs font-semibold text-primary-700\"\n >\n {{ \"components.lookupModuleCheckListField.filled\" | transloco }}\n </span>\n }\n </button>\n\n @if (isExpanded(section.lookupKey) && propertyFields().length) {\n <div class=\"border-t border-surface-200 p-3\">\n <div class=\"grid grid-cols-1 gap-3 sm:grid-cols-2\">\n @for (field of propertyFields(); track field.key) {\n <label class=\"flex min-w-0 flex-col gap-1\">\n <span class=\"truncate text-xs text-muted-color\">\n {{ field.label }}\n </span>\n @if (isReadonly()) {\n <span class=\"truncate text-sm text-color\">\n {{ fieldValue(section.lookupKey, field.key) || \"_\" }}\n </span>\n } @else {\n <input\n pInputText\n class=\"w-full\"\n [ngModel]=\"fieldValue(section.lookupKey, field.key)\"\n [ngModelOptions]=\"{ standalone: true }\"\n (ngModelChange)=\"\n setFieldValue(section.lookupKey, field.key, $event)\n \"\n />\n }\n </label>\n }\n </div>\n </div>\n }\n </div>\n }\n </div>\n } @else {\n <div\n class=\"rounded border border-dashed border-surface-300 bg-surface-50 p-3 text-sm text-muted-color\"\n >\n {{ \"components.lookupModuleCheckListField.empty\" | transloco }}\n </div>\n }\n\n @if (ngControl?.control) {\n <mt-field-validation\n [control]=\"ngControl?.control!\"\n [touched]=\"ngControl?.touched ?? false\"\n />\n }\n</div>\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":["PAGE_SIZE","i1","i2"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAiCa,iBAAiB,CAAA;AACnB,IAAA,MAAM,GAAG,KAAK,CAAC,QAAQ,4EAA2B;AAE1C,IAAA,gBAAgB,GAAG,MAAM,CAAC,gBAAgB,EAAE;AAC3D,QAAA,QAAQ,EAAE,IAAI;AACf,KAAA,CAAC;AACe,IAAA,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC;AAC/B,IAAA,SAAS,GAAG,MAAM,CAAC,gBAAgB,CAAC;AACpC,IAAA,YAAY,GAAG,MAAM,CAAC,CAAC,mFAAC;IACjC,iBAAiB,GAA2B,IAAI;AAE/C,IAAA,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,SAAS,+EAAC;AACpD,IAAA,QAAQ,GAAG,QAAQ,CAAC,MAAM,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,IAAI,EAAE,+EAAC;AACvD,IAAA,QAAQ,GAAG,QAAQ,CAAC,MAAM,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,IAAI,EAAE,+EAAC;AACvD,IAAA,SAAS,GAAG,QAAQ,CAAC,MAAM,IAAI,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,gFAAC;IAC1D,OAAO,GAAG,QAAQ,CACzB,MACE,IAAI,GAAG,CACL,IAAI,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,KAAK;QAChC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,aAAa,CAAC;QACpD,IAAI;KACL,CAAC,CACH,8EACJ;AACQ,IAAA,eAAe,GAAG,QA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,eAAA,EAAA,EAAA,CAAA,uBAAA,CAAA,MAAA,EAAA,CAAA;;2FAMJ,0BAA0B,EAAA,UAAA,EAAA,CAAA;kBAftC,SAAS;+BACE,mCAAmC,EAAA,UAAA,EACjC,IAAI,EAAA,OAAA,EACP;wBACP,WAAW;wBACX,iBAAiB;wBACjB,eAAe;wBACf,IAAI;wBACJ,eAAe;wBACf,aAAa;qBACd,EAAA,eAAA,EAEgB,uBAAuB,CAAC,MAAM,EAAA,IAAA,EACzC,EAAE,KAAK,EAAE,YAAY,EAAE,EAAA,QAAA,EAAA,0hHAAA,EAAA;;;AE9D/B;;AAEG;;;;"}
1
+ {"version":3,"file":"masterteam-components-business-fields.mjs","sources":["../../../../packages/masterteam/components/business-fields/lookup-matrix-field/lookup-matrix-field.ts","../../../../packages/masterteam/components/business-fields/lookup-matrix-field/lookup-matrix-field.html","../../../../packages/masterteam/components/business-fields/schema-connection-field/schema-connection-field.ts","../../../../packages/masterteam/components/business-fields/schema-connection-field/schema-connection-field.html","../../../../packages/masterteam/components/business-fields/schedule-predecessor-field/schedule-predecessor-field.ts","../../../../packages/masterteam/components/business-fields/schedule-predecessor-field/schedule-predecessor-field.html","../../../../packages/masterteam/components/business-fields/entity-list-field/entity-list-add-token.ts","../../../../packages/masterteam/components/business-fields/entity-list-field/entity-list-local-editor.ts","../../../../packages/masterteam/components/business-fields/entity-list-field/entity-list-selection-editor.ts","../../../../packages/masterteam/components/business-fields/entity-list-field/entity-list-selection-dialog.ts","../../../../packages/masterteam/components/business-fields/entity-list-field/entity-list-selection-dialog.html","../../../../packages/masterteam/components/business-fields/entity-list-field/entity-list-field.ts","../../../../packages/masterteam/components/business-fields/entity-list-field/entity-list-field.html","../../../../packages/masterteam/components/business-fields/entity-list-field/entity-list-table-token.ts","../../../../packages/masterteam/components/business-fields/schedule-item-selector-field/schedule-item-selector-field.ts","../../../../packages/masterteam/components/business-fields/schedule-item-selector-field/schedule-item-selector-field.html","../../../../packages/masterteam/components/business-fields/lookup-module-check-list-field/lookup-module-check-list-form-token.ts","../../../../packages/masterteam/components/business-fields/lookup-module-check-list-field/lookup-module-check-list-field.ts","../../../../packages/masterteam/components/business-fields/lookup-module-check-list-field/lookup-module-check-list-field.html","../../../../packages/masterteam/components/business-fields/masterteam-components-business-fields.ts"],"sourcesContent":["import { CommonModule } from '@angular/common';\r\nimport {\r\n AfterViewInit,\r\n ChangeDetectionStrategy,\r\n Component,\r\n computed,\r\n DestroyRef,\r\n inject,\r\n input,\r\n signal,\r\n} from '@angular/core';\r\nimport { takeUntilDestroyed } from '@angular/core/rxjs-interop';\r\nimport { AbstractControl, ControlContainer } from '@angular/forms';\r\nimport { TranslocoService } from '@jsverse/transloco';\r\nimport { startWith } from 'rxjs';\r\nimport type {\r\n LookupMatrixCellConfig,\r\n LookupMatrixFieldConfig,\r\n LookupOptionItemConfig,\r\n} from '@masterteam/components';\r\nimport { Tooltip } from '@masterteam/components/tooltip';\r\nimport { Icon } from '@masterteam/icons';\r\n\r\n@Component({\r\n selector: 'mt-lookup-matrix-field',\r\n standalone: true,\r\n imports: [CommonModule, Tooltip, Icon],\r\n templateUrl: './lookup-matrix-field.html',\r\n changeDetection: ChangeDetectionStrategy.OnPush,\r\n host: {\r\n class: 'grid gap-2',\r\n },\r\n})\r\nexport class LookupMatrixField implements AfterViewInit {\r\n readonly config = input.required<LookupMatrixFieldConfig>();\r\n\r\n private readonly controlContainer = inject(ControlContainer, {\r\n optional: true,\r\n });\r\n private readonly destroyRef = inject(DestroyRef);\r\n private readonly transloco = inject(TranslocoService);\r\n private readonly valueVersion = signal(0);\r\n private subscribedControl: AbstractControl | null = null;\r\n\r\n readonly hasYAxis = computed(() => !!this.config().yFieldKey);\r\n readonly xOptions = computed(() => this.config().xOptions ?? []);\r\n readonly yOptions = computed(() => this.config().yOptions ?? []);\r\n readonly hasMatrix = computed(() => this.config().cells.length > 0);\r\n readonly cellMap = computed(\r\n () =>\r\n new Map(\r\n this.config().cells.map((cell) => [\r\n this.cellKey(cell.xLookupItemId, cell.yLookupItemId),\r\n cell,\r\n ]),\r\n ),\r\n );\r\n readonly selectedXOption = computed(() => {\r\n this.valueVersion();\r\n return this.resolveSelectedOption(\r\n this.xOptions(),\r\n this.getControlValue(this.config().xFieldKey),\r\n );\r\n });\r\n readonly selectedYOption = computed(() => {\r\n this.valueVersion();\r\n const yFieldKey = this.config().yFieldKey;\r\n if (!yFieldKey) {\r\n return null;\r\n }\r\n\r\n return this.resolveSelectedOption(\r\n this.yOptions(),\r\n this.getControlValue(yFieldKey),\r\n );\r\n });\r\n readonly activeCell = computed(() => {\r\n const selectedX = this.selectedXOption();\r\n if (!selectedX) {\r\n return null;\r\n }\r\n\r\n if (!this.hasYAxis()) {\r\n return this.getCell(selectedX.id ?? selectedX.value);\r\n }\r\n\r\n const selectedY = this.selectedYOption();\r\n if (!selectedY) {\r\n return null;\r\n }\r\n\r\n return this.getCell(\r\n selectedX.id ?? selectedX.value,\r\n selectedY.id ?? selectedY.value,\r\n );\r\n });\r\n readonly selectionSummary = computed(() => {\r\n const parts: string[] = [];\r\n const xAxisLabel =\r\n this.config().xAxisLabel.trim() ||\r\n this.transloco.translate('components.lookupMatrixField.xAxisFallback');\r\n const selectedX = this.selectedXOption();\r\n\r\n if (selectedX) {\r\n parts.push(`${xAxisLabel}: ${selectedX.label}`);\r\n }\r\n\r\n const selectedY = this.selectedYOption();\r\n const yAxisLabel =\r\n this.config().yAxisLabel?.trim() ||\r\n this.transloco.translate('components.lookupMatrixField.yAxisFallback');\r\n if (selectedY && this.hasYAxis()) {\r\n parts.push(`${yAxisLabel}: ${selectedY.label}`);\r\n }\r\n\r\n return parts.join(' / ');\r\n });\r\n readonly pendingMessage = computed(() => {\r\n const xAxisLabel =\r\n this.config().xAxisLabel.trim() ||\r\n this.transloco.translate(\r\n 'components.lookupMatrixField.firstValueFallback',\r\n );\r\n\r\n if (!this.hasYAxis()) {\r\n return this.transloco.translate(\r\n 'components.lookupMatrixField.selectXAxisFirst',\r\n { xAxisLabel },\r\n );\r\n }\r\n\r\n const yAxisLabel =\r\n this.config().yAxisLabel?.trim() ||\r\n this.transloco.translate(\r\n 'components.lookupMatrixField.secondValueFallback',\r\n );\r\n\r\n return this.transloco.translate(\r\n 'components.lookupMatrixField.selectAxesFirst',\r\n { xAxisLabel, yAxisLabel },\r\n );\r\n });\r\n readonly missingResultMessage = computed(() => {\r\n if (!this.selectedXOption()) {\r\n return this.pendingMessage();\r\n }\r\n\r\n if (this.hasYAxis() && !this.selectedYOption()) {\r\n return this.pendingMessage();\r\n }\r\n\r\n return this.transloco.translate(\r\n 'components.lookupMatrixField.noMatchingValue',\r\n );\r\n });\r\n\r\n ngAfterViewInit(): void {\r\n this.ensureControlSubscription();\r\n }\r\n\r\n getCell(\r\n xLookupItemId: number | string,\r\n yLookupItemId?: number | string,\r\n ): LookupMatrixCellConfig | null {\r\n return (\r\n this.cellMap().get(this.cellKey(xLookupItemId, yLookupItemId)) ?? null\r\n );\r\n }\r\n\r\n getSwatchColor(color?: string | null): string | null {\r\n return this.resolveColor(color);\r\n }\r\n\r\n private getControlValue(path: string): unknown {\r\n if (!path) return null;\r\n return this.controlContainer?.control?.get(path)?.value ?? null;\r\n }\r\n\r\n private ensureControlSubscription(): void {\r\n const control = this.controlContainer?.control;\r\n if (!control || control === this.subscribedControl) {\r\n return;\r\n }\r\n\r\n this.subscribedControl = control;\r\n control.valueChanges\r\n .pipe(\r\n startWith(control.getRawValue()),\r\n takeUntilDestroyed(this.destroyRef),\r\n )\r\n .subscribe(() => {\r\n this.valueVersion.update((value) => value + 1);\r\n });\r\n }\r\n\r\n private resolveSelectedOption(\r\n options: LookupOptionItemConfig[],\r\n rawValue: unknown,\r\n ): LookupOptionItemConfig | null {\r\n if (rawValue == null || rawValue === '') return null;\r\n\r\n return (\r\n options.find((option) => this.optionMatchesValue(option, rawValue)) ??\r\n null\r\n );\r\n }\r\n\r\n private optionMatchesValue(\r\n option: LookupOptionItemConfig,\r\n rawValue: unknown,\r\n ): boolean {\r\n return [option.value, option.key, option.id].some(\r\n (candidate) =>\r\n candidate != null && String(candidate) === String(rawValue),\r\n );\r\n }\r\n\r\n private cellKey(\r\n xLookupItemId: number | string,\r\n yLookupItemId?: number | string,\r\n ): string {\r\n return `${String(xLookupItemId)}::${String(yLookupItemId ?? '')}`;\r\n }\r\n\r\n private resolveColor(color?: string | null): string | null {\r\n if (!color) return null;\r\n\r\n if (\r\n color.startsWith('#') ||\r\n color.startsWith('rgb') ||\r\n color.startsWith('hsl') ||\r\n color.startsWith('var(')\r\n ) {\r\n return color;\r\n }\r\n\r\n return `var(--p-${color}-500)`;\r\n }\r\n}\r\n","@if (config().label) {\r\n <label class=\"font-medium text-color\">\r\n {{ config().label }}\r\n </label>\r\n}\r\n\r\n<div\r\n class=\"rounded-lg border border-surface-200 bg-surface-50 px-3 flex items-center\"\r\n>\r\n @if (activeCell(); as cell) {\r\n <div class=\"flex flex-1 min-h-6 items-center gap-2 justify-between\">\r\n <span\r\n class=\"h-6 w-2 shrink-0 rounded-[2px] border border-surface-200\"\r\n [style.background-color]=\"getSwatchColor(cell.color)\"\r\n [style.border-color]=\"getSwatchColor(cell.color)\"\r\n ></span>\r\n\r\n <div class=\"min-w-0 flex-1 py-2 flex items-center justify-between\">\r\n <div class=\"truncate font-semibold text-gray-500\">\r\n {{ cell.label }}\r\n </div>\r\n\r\n @if (selectionSummary()) {\r\n <div class=\"font-bold text-gray-500\">\r\n <mt-icon\r\n [mtTooltip]=\"selectionSummary()\"\r\n icon=\"general.info-circle\"\r\n />\r\n </div>\r\n }\r\n </div>\r\n </div>\r\n } @else {\r\n <div class=\"flex min-h-6 items-center text-muted-color py-2\">\r\n {{ hasMatrix() ? missingResultMessage() : config().emptyMessage }}\r\n </div>\r\n }\r\n</div>\r\n","import {\r\n Component,\r\n signal,\r\n input,\r\n computed,\r\n inject,\r\n ChangeDetectionStrategy,\r\n ChangeDetectorRef,\r\n effect,\r\n untracked,\r\n DestroyRef,\r\n OnInit,\r\n} from '@angular/core';\r\nimport {\r\n AbstractControl,\r\n ControlValueAccessor,\r\n FormsModule,\r\n NgControl,\r\n ValidationErrors,\r\n ValidatorFn,\r\n} from '@angular/forms';\r\nimport { TranslocoService } from '@jsverse/transloco';\r\nimport { SelectField } from '@masterteam/components/select-field';\r\nimport { MultiSelectField } from '@masterteam/components/multi-select-field';\r\nimport { FieldValidation } from '@masterteam/components/field-validation';\r\nimport { Tooltip } from '@masterteam/components/tooltip';\r\nimport { Icon } from '@masterteam/icons';\r\nimport { HttpClient, HttpContext } from '@angular/common/http';\r\nimport { takeUntilDestroyed, toSignal } from '@angular/core/rxjs-interop';\r\nimport { finalize, catchError, of } from 'rxjs';\r\nimport type { SchemaConnectionFieldRuntimeContext } from '@masterteam/components';\r\n\r\n// ============================================================================\r\n// Types\r\n// ============================================================================\r\n\r\n/**\r\n * One source level inside connection configuration.\r\n * Comes from `field.propertyMetadata.configuration.sourceLevels[]`\r\n *\r\n * A source can be either a **level** (has `levelId`/`levelKey`) or a\r\n * **module** (has `moduleId`/`moduleKey`). Exactly one pair will be present.\r\n */\r\nexport interface ConnectionSourceLevel {\r\n /** Present for level-type sources */\r\n levelId?: number;\r\n /** Present for level-type sources */\r\n levelKey?: string;\r\n /** Present for module-type sources */\r\n moduleId?: number;\r\n /** Present for module-type sources */\r\n moduleKey?: string;\r\n name: { en?: string; ar?: string; [k: string]: string | undefined };\r\n connectionId: number;\r\n isOptional: boolean;\r\n allowManyToMany: boolean;\r\n supportWeights: boolean;\r\n optionsQuery: {\r\n path: string;\r\n method?: string;\r\n query?: Record<string, unknown>;\r\n };\r\n}\r\n\r\n/**\r\n * Full connection configuration from `field.propertyMetadata.configuration`.\r\n * This is passed as a single input to the component.\r\n */\r\nexport interface SchemaConnectionConfig {\r\n targetLevelId: number;\r\n sourceLevelId?: number;\r\n propertyKey?: string;\r\n valueMode?: string;\r\n sourceLevels: ConnectionSourceLevel[];\r\n payloadTemplate?: { levelId: number; sources: any[] };\r\n sourceItemShape?: Record<string, string>;\r\n}\r\n\r\n/** One selected source in the connection payload */\r\nexport interface ConnectionSource {\r\n sourceLevelId?: number;\r\n sourceLevelDataId?: number;\r\n sourceModuleId?: number;\r\n sourceModuleDataId?: number;\r\n}\r\n\r\n/** The value shape for a connection field */\r\nexport interface ConnectionPayload {\r\n levelId: number;\r\n sources: ConnectionSource[];\r\n}\r\n\r\n/**\r\n * Internal state tracked per source level dropdown.\r\n */\r\nexport interface SourceLevelState {\r\n source: ConnectionSourceLevel;\r\n options: any[];\r\n loading: boolean;\r\n}\r\n\r\n/**\r\n * Read a control value as a payload, accepting the serialized JSON string a\r\n * form load can patch in. {@link SchemaConnectionField.writeValue} and the\r\n * required validator must agree on this: while only `writeValue` parsed, a\r\n * string-valued connection rendered as filled but validated as empty.\r\n */\r\nfunction parseConnectionPayload(value: unknown): ConnectionPayload | null {\r\n if (typeof value === 'string') {\r\n const trimmed = value.trim();\r\n if (!trimmed) return null;\r\n try {\r\n const parsed = JSON.parse(trimmed);\r\n return parsed && typeof parsed === 'object'\r\n ? (parsed as ConnectionPayload)\r\n : null;\r\n } catch {\r\n return null;\r\n }\r\n }\r\n\r\n return (value as ConnectionPayload | null) ?? null;\r\n}\r\n\r\n@Component({\r\n selector: 'mt-schema-connection-field',\r\n standalone: true,\r\n imports: [\r\n FormsModule,\r\n SelectField,\r\n MultiSelectField,\r\n FieldValidation,\r\n Tooltip,\r\n Icon,\r\n ],\r\n templateUrl: './schema-connection-field.html',\r\n styleUrls: ['./schema-connection-field.scss'],\r\n changeDetection: ChangeDetectionStrategy.OnPush,\r\n host: {\r\n class: 'grid gap-1',\r\n },\r\n})\r\nexport class SchemaConnectionField implements ControlValueAccessor, OnInit {\r\n // ============================================================================\r\n // Inputs\r\n // ============================================================================\r\n\r\n readonly label = input<string>('');\r\n readonly placeholder = input<string>('');\r\n readonly readonly = input<boolean>(false);\r\n /**\r\n * Kept for direct-host API compatibility. Dynamic/client forms do not bind\r\n * it; runtime requiredness is defined per source by\r\n * `configuration.sourceLevels[].isOptional`.\r\n */\r\n readonly required = input<boolean>(false);\r\n readonly filter = input<boolean>(true);\r\n\r\n /**\r\n * Full connection configuration object from the API.\r\n * Includes `targetLevelId`, `sourceLevels[]`, `payloadTemplate`, etc.\r\n */\r\n readonly configuration = input.required<SchemaConnectionConfig>();\r\n\r\n /**\r\n * Runtime scope for this field's options queries. When `templateId` is\r\n * present, it is sent as a `templateId` structural filter on every source\r\n * level's `fetch/query` request, scoping the dropdown to the active plan\r\n * instance. Absent means options load unscoped, same as before this input\r\n * existed.\r\n */\r\n readonly runtimeContext = input<SchemaConnectionFieldRuntimeContext | null>(\r\n null,\r\n );\r\n\r\n /**\r\n * Optional HttpContext for API requests (e.g. to set base URL behavior).\r\n */\r\n readonly context = input<HttpContext | undefined>(undefined);\r\n\r\n // ============================================================================\r\n // Internal State\r\n // ============================================================================\r\n\r\n /** The full ConnectionPayload value */\r\n value = signal<ConnectionPayload | null>(null);\r\n disabled = signal<boolean>(false);\r\n\r\n /** Per-source-level state: options + loading */\r\n sourceLevelStates = signal<SourceLevelState[]>([]);\r\n\r\n /** Mutable selections per source level: sourceLevelId -> selected value */\r\n selections: Record<number, any> = {};\r\n\r\n onTouched: () => void = () => {};\r\n onModelChange: (value: ConnectionPayload | null) => void = () => {};\r\n\r\n /**\r\n * Every source whose `isOptional` is false must have at least one selected\r\n * record. The field-level `isRequired` flag is intentionally ignored because\r\n * one Connection property can mix optional and required source levels.\r\n */\r\n private readonly requiredSourcesValidator: ValidatorFn = (\r\n control: AbstractControl,\r\n ): ValidationErrors | null => {\r\n const value = parseConnectionPayload(control.value);\r\n const selectedSources = Array.isArray(value?.sources) ? value.sources : [];\r\n const allRequiredSourcesSelected = this.sourceLevels()\r\n .filter((source) => source.isOptional !== true)\r\n .every((source) => {\r\n const sourceId = this.getSourceId(source);\r\n return selectedSources.some(\r\n (selected) =>\r\n (selected.sourceLevelId ?? selected.sourceModuleId) === sourceId &&\r\n (selected.sourceLevelDataId ?? selected.sourceModuleDataId) != null,\r\n );\r\n });\r\n\r\n return allRequiredSourcesSelected ? null : { required: true };\r\n };\r\n\r\n public ngControl: NgControl | null = null;\r\n private http = inject(HttpClient);\r\n private destroyRef = inject(DestroyRef);\r\n private readonly cdr = inject(ChangeDetectorRef);\r\n private transloco = inject(TranslocoService);\r\n\r\n /** Active UI language, kept reactive so source labels re-resolve on switch. */\r\n private readonly activeLang = toSignal(this.transloco.langChanges$, {\r\n initialValue: this.transloco.getActiveLang(),\r\n });\r\n\r\n /**\r\n * Resolve a source level's display name in the active locale, falling back\r\n * to English, Arabic, then the level/module key.\r\n */\r\n protected resolveSourceName(source: ConnectionSourceLevel): string {\r\n const name = source.name;\r\n return (\r\n name?.[this.activeLang()] ||\r\n name?.en ||\r\n name?.ar ||\r\n source.levelKey ||\r\n source.moduleKey ||\r\n ''\r\n );\r\n }\r\n\r\n /**\r\n * Source levels from configuration.\r\n */\r\n readonly sourceLevels = computed<ConnectionSourceLevel[]>(() => {\r\n return this.configuration()?.sourceLevels ?? [];\r\n });\r\n\r\n /**\r\n * Tooltip for the marker rendered next to every source label — it is what\r\n * tells the user these dropdowns belong to a connection, now that the\r\n * connection's own label no longer occupies a row above them. Reads\r\n * {@link activeLang} so the text re-translates on language switch.\r\n */\r\n readonly connectionHint = computed<string>(() => {\r\n this.activeLang();\r\n return this.transloco.translate('components.schemaConnection.hint');\r\n });\r\n\r\n /**\r\n * Placeholder for a source dropdown: its own source name, matching the label\r\n * above it. Falls back to the field-level placeholder only when the source\r\n * has no resolvable name.\r\n */\r\n protected sourcePlaceholder(source: ConnectionSourceLevel): string {\r\n return (\r\n this.resolveSourceName(source) ||\r\n this.placeholder() ||\r\n this.transloco.translate('components.selectPlaceholder')\r\n );\r\n }\r\n\r\n /**\r\n * Percentage width for each dropdown, evenly divided.\r\n */\r\n readonly dropdownWidth = computed<string>(() => {\r\n const count = this.sourceLevels().length;\r\n if (count <= 0) return '100%';\r\n return `${100 / count}%`;\r\n });\r\n\r\n constructor() {\r\n this.ngControl = inject(NgControl, { self: true, optional: true });\r\n if (this.ngControl) {\r\n this.ngControl.valueAccessor = this;\r\n }\r\n\r\n effect(() => {\r\n const control = this.ngControl?.control;\r\n if (!control) return;\r\n const hasRequiredSources = this.sourceLevels().some(\r\n (source) => source.isOptional !== true,\r\n );\r\n untracked(() => {\r\n if (hasRequiredSources) {\r\n control.addValidators(this.requiredSourcesValidator);\r\n } else {\r\n control.removeValidators(this.requiredSourcesValidator);\r\n }\r\n control.updateValueAndValidity({ emitEvent: false });\r\n });\r\n });\r\n\r\n // Load options for each source level when configuration changes\r\n effect(() => {\r\n const levels = this.sourceLevels();\r\n if (!levels.length) return;\r\n\r\n // Everything below must NOT create signal dependencies,\r\n // only sourceLevels() (→ configuration) should trigger this effect.\r\n untracked(() => {\r\n // Initialize per-source states + selections\r\n this.sourceLevelStates.set(\r\n levels.map((source) => ({\r\n source,\r\n options: [],\r\n loading: false,\r\n })),\r\n );\r\n\r\n for (const source of levels) {\r\n const sourceId = this.getSourceId(source);\r\n if (!(sourceId in this.selections)) {\r\n this.selections[sourceId] = source.allowManyToMany ? [] : null;\r\n }\r\n }\r\n\r\n // Distribute existing value to selections\r\n this.distributeToSelections(this.value());\r\n\r\n // Load options for each source level\r\n for (const source of levels) {\r\n this.loadOptions(source);\r\n }\r\n });\r\n });\r\n }\r\n\r\n /**\r\n * Repaint when the control's own state changes.\r\n *\r\n * `touched` and validity are plain `AbstractControl` state, not signals, and\r\n * this component is `OnPush` — so a host that calls `markAllAsTouched()` on a\r\n * failed submit marked the connection invalid and nothing re-rendered. The\r\n * required message only appeared once the user happened to touch a dropdown,\r\n * which is the one moment they no longer need telling.\r\n *\r\n * `ngOnInit` rather than the constructor: `formControl` / `formControlName`\r\n * only expose `.control` after their first `ngOnChanges`.\r\n */\r\n ngOnInit(): void {\r\n this.ngControl?.control?.events\r\n .pipe(takeUntilDestroyed(this.destroyRef))\r\n .subscribe(() => this.cdr.markForCheck());\r\n }\r\n\r\n // ============================================================================\r\n // Source Level Helpers\r\n // ============================================================================\r\n\r\n /**\r\n * Returns a stable numeric ID for a source regardless of whether it is a\r\n * level (`levelId`) or a module (`moduleId`). Used as the key in `selections`\r\n * and `sourceLevelStates`.\r\n */\r\n protected getSourceId(source: ConnectionSourceLevel): number {\r\n return (source.levelId ?? source.moduleId)!;\r\n }\r\n\r\n /**\r\n * A source that must be selected and is not. Mirrors\r\n * {@link requiredSourcesValidator}, which decides the same thing from the\r\n * control value.\r\n *\r\n * A method, not a computed: `selections` is a plain object that `ngModel`\r\n * mutates in place and carries no signal, so only re-reading it every change\r\n * detection cycle stays truthful.\r\n */\r\n protected isSourceMissing(source: ConnectionSourceLevel): boolean {\r\n if (source.isOptional === true) return false;\r\n\r\n const selected = this.selections[this.getSourceId(source)];\r\n return Array.isArray(selected) ? selected.length === 0 : selected == null;\r\n }\r\n\r\n /**\r\n * The control, but only for the source the message belongs under — every\r\n * other source gets `null` and renders nothing. `mt-field-validation` still\r\n * decides whether to paint: it waits for `touched`.\r\n *\r\n * Field height stays stable because the reserved line moves rather than\r\n * appears. A null control reserves nothing, so exactly one slot is live at a\r\n * time — the missing source's, or {@link unattributedErrorControl}'s below\r\n * the row.\r\n */\r\n protected sourceErrorControl(\r\n source: ConnectionSourceLevel,\r\n ): AbstractControl | null {\r\n return this.isSourceMissing(source)\r\n ? (this.ngControl?.control ?? null)\r\n : null;\r\n }\r\n\r\n /**\r\n * The control, but only while no source owns the failure — a server error on\r\n * a fully selected connection has nowhere else to render. Null as soon as a\r\n * source is missing, so one failure never prints twice.\r\n */\r\n protected unattributedErrorControl(): AbstractControl | null {\r\n const control = this.ngControl?.control ?? null;\r\n if (!control) return null;\r\n\r\n return this.sourceLevels().some((source) => this.isSourceMissing(source))\r\n ? null\r\n : control;\r\n }\r\n\r\n /**\r\n * Builds the `contextKey` for the `fetch/query` request based on source type.\r\n */\r\n private getContextKey(source: ConnectionSourceLevel): string {\r\n return source.levelId != null\r\n ? `level:${source.levelId}`\r\n : `module:${source.moduleId}`;\r\n }\r\n\r\n // ============================================================================\r\n // Option Loading (per source level)\r\n // ============================================================================\r\n\r\n private loadOptions(source: ConnectionSourceLevel): void {\r\n this.updateSourceState(this.getSourceId(source), { loading: true });\r\n\r\n const ctx = this.context();\r\n const templateId = this.runtimeContext()?.templateId;\r\n const payload = {\r\n contextKey: this.getContextKey(source),\r\n projection: 'Flat',\r\n propertyKeys: ['name'],\r\n ...(templateId != null\r\n ? {\r\n filters: [\r\n {\r\n key: 'templateId',\r\n operator: 'Equals',\r\n value: String(templateId),\r\n },\r\n ],\r\n }\r\n : {}),\r\n };\r\n\r\n this.http\r\n .post<unknown>('fetch/query', payload, {\r\n ...(ctx ? { context: ctx } : {}),\r\n })\r\n .pipe(\r\n takeUntilDestroyed(this.destroyRef),\r\n finalize(() =>\r\n this.updateSourceState(this.getSourceId(source), { loading: false }),\r\n ),\r\n catchError((err) => {\r\n console.error(\r\n `Connection options load failed for ${source.levelKey ?? source.moduleKey}:`,\r\n err,\r\n );\r\n return of({ data: { records: [] } });\r\n }),\r\n )\r\n .subscribe((response: any) => {\r\n const options = (response?.data?.records ?? [])\r\n .filter((record: any) => record?.id != null)\r\n .map((record: any) => ({\r\n ...record,\r\n id: record.id,\r\n name: record.name,\r\n }));\r\n\r\n this.updateSourceState(this.getSourceId(source), {\r\n options,\r\n loading: false,\r\n });\r\n });\r\n }\r\n\r\n private updateSourceState(\r\n sourceId: number,\r\n patch: Partial<Pick<SourceLevelState, 'options' | 'loading'>>,\r\n ): void {\r\n this.sourceLevelStates.update((states) =>\r\n states.map((s) =>\r\n this.getSourceId(s.source) === sourceId ? { ...s, ...patch } : s,\r\n ),\r\n );\r\n }\r\n\r\n // ============================================================================\r\n // Value Handling\r\n // ============================================================================\r\n\r\n /**\r\n * Single handler — no params. Reads all selections, builds the combined payload.\r\n */\r\n syncValue(): void {\r\n const cfg = this.configuration();\r\n const states = this.sourceLevelStates();\r\n const sources: ConnectionSource[] = [];\r\n\r\n for (const state of states) {\r\n const val = this.selections[this.getSourceId(state.source)];\r\n if (val == null) continue;\r\n\r\n const effectiveId = this.getSourceId(state.source);\r\n if (state.source.allowManyToMany && Array.isArray(val)) {\r\n for (const id of val) {\r\n sources.push({\r\n sourceLevelId: effectiveId,\r\n sourceLevelDataId: id,\r\n });\r\n }\r\n } else if (typeof val === 'number') {\r\n sources.push({\r\n sourceLevelId: effectiveId,\r\n sourceLevelDataId: val,\r\n });\r\n }\r\n }\r\n\r\n const payload: ConnectionPayload | null =\r\n sources.length > 0 ? { levelId: cfg.targetLevelId, sources } : null;\r\n\r\n this.value.set(payload);\r\n this.onModelChange(payload);\r\n this.onTouched();\r\n }\r\n\r\n private distributeToSelections(payload: ConnectionPayload | null): void {\r\n const states = this.sourceLevelStates();\r\n for (const state of states) {\r\n const sourceId = this.getSourceId(state.source);\r\n const ids = (payload?.sources ?? [])\r\n .filter((s) => (s.sourceLevelId ?? s.sourceModuleId) === sourceId)\r\n .map((s) => s.sourceLevelDataId ?? s.sourceModuleDataId)\r\n .filter((id): id is number => id != null);\r\n\r\n this.selections[sourceId] = state.source.allowManyToMany\r\n ? ids\r\n : (ids[0] ?? null);\r\n }\r\n }\r\n\r\n // ============================================================================\r\n // ControlValueAccessor\r\n // ============================================================================\r\n\r\n writeValue(value: ConnectionPayload | string | null): void {\r\n const payload = parseConnectionPayload(value);\r\n this.value.set(payload);\r\n this.distributeToSelections(payload);\r\n }\r\n\r\n registerOnChange(fn: (value: ConnectionPayload | null) => void): void {\r\n this.onModelChange = fn;\r\n }\r\n\r\n registerOnTouched(fn: any): void {\r\n this.onTouched = fn;\r\n }\r\n\r\n setDisabledState(disabled: boolean): void {\r\n this.disabled.set(disabled);\r\n }\r\n}\r\n","<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→control 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 — 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","import { CommonModule } from '@angular/common';\r\nimport {\r\n ChangeDetectionStrategy,\r\n Component,\r\n computed,\r\n DestroyRef,\r\n effect,\r\n inject,\r\n input,\r\n linkedSignal,\r\n signal,\r\n TemplateRef,\r\n untracked,\r\n viewChild,\r\n} from '@angular/core';\r\nimport { takeUntilDestroyed, toSignal } from '@angular/core/rxjs-interop';\r\nimport {\r\n ControlValueAccessor,\r\n FormsModule,\r\n NgControl,\r\n Validators,\r\n} from '@angular/forms';\r\nimport { HttpClient } from '@angular/common/http';\r\nimport { catchError, finalize, of } from 'rxjs';\r\nimport { TranslocoModule, TranslocoService } from '@jsverse/transloco';\r\nimport { Button } from '@masterteam/components/button';\r\nimport { FieldValidation } from '@masterteam/components/field-validation';\r\nimport { NumberField } from '@masterteam/components/number-field';\r\nimport { SelectField } from '@masterteam/components/select-field';\r\nimport {\r\n Table,\r\n type ColumnDef,\r\n type TableAction,\r\n} from '@masterteam/components/table';\r\nimport type { SchedulePredecessorFieldRuntimeContext } from '@masterteam/components';\r\nimport { newFieldId } from '@masterteam/components';\r\n\r\ntype PredecessorType = 0 | 1 | 2 | 3;\r\ntype PredecessorTypeToken = 'FS' | 'SS' | 'FF' | 'SF';\r\n\r\ninterface ScheduleQueryRecord {\r\n id: number | string;\r\n name?: string | null;\r\n children?: ScheduleQueryRecord[] | null;\r\n}\r\n\r\ninterface ScheduleQueryData {\r\n records?: ScheduleQueryRecord[] | null;\r\n projectionMeta?: {\r\n rootIds?: Array<number | string> | null;\r\n } | null;\r\n}\r\n\r\ninterface ScheduleQueryResponse {\r\n data?: ScheduleQueryData | null;\r\n}\r\n\r\ninterface SchedulePredecessorValue {\r\n predecessorId: number | string;\r\n type: PredecessorType;\r\n lagDays: number;\r\n}\r\n\r\ninterface SchedulePredecessorRow extends SchedulePredecessorValue {\r\n key: string;\r\n}\r\n\r\ninterface SelectOption {\r\n label: string;\r\n value: number | string;\r\n}\r\n\r\nconst PREDECESSOR_TYPE_BY_TOKEN: Record<PredecessorTypeToken, PredecessorType> =\r\n {\r\n FS: 0,\r\n SS: 1,\r\n FF: 2,\r\n SF: 3,\r\n };\r\n\r\nconst PREDECESSOR_TOKEN_BY_TYPE: Record<PredecessorType, PredecessorTypeToken> =\r\n {\r\n 0: 'FS',\r\n 1: 'SS',\r\n 2: 'FF',\r\n 3: 'SF',\r\n };\r\n\r\n@Component({\r\n selector: 'mt-schedule-predecessor-field',\r\n standalone: true,\r\n imports: [\r\n CommonModule,\r\n FormsModule,\r\n Button,\r\n FieldValidation,\r\n NumberField,\r\n SelectField,\r\n Table,\r\n TranslocoModule,\r\n ],\r\n templateUrl: './schedule-predecessor-field.html',\r\n changeDetection: ChangeDetectionStrategy.OnPush,\r\n host: {\r\n class: 'grid gap-1',\r\n },\r\n})\r\nexport class SchedulePredecessorField implements ControlValueAccessor {\r\n private readonly predecessorCellTpl =\r\n viewChild.required<TemplateRef<any>>('predecessorCellTpl');\r\n private readonly typeCellTpl =\r\n viewChild.required<TemplateRef<any>>('typeCellTpl');\r\n private readonly lagCellTpl =\r\n viewChild.required<TemplateRef<any>>('lagCellTpl');\r\n\r\n readonly label = input<string>('');\r\n\r\n /** Unique; shared by the control and its <label for>. See src/lib/utils/field-id. */\r\n readonly fieldId = newFieldId('mt-schedule-predecessor-field');\r\n readonly placeholder = input<string>('');\r\n readonly readonly = input<boolean>(false);\r\n readonly required = input<boolean>(false);\r\n readonly configuration = input<unknown>(null);\r\n readonly runtimeContext =\r\n input<SchedulePredecessorFieldRuntimeContext | null>(null);\r\n\r\n readonly loading = signal(false);\r\n readonly taskOptions = signal<SelectOption[]>([]);\r\n readonly rows = signal<SchedulePredecessorRow[]>([]);\r\n readonly disabled = signal(false);\r\n\r\n readonly typeOptions = computed<SelectOption[]>(() => [\r\n { label: 'FS', value: 0 },\r\n { label: 'SS', value: 1 },\r\n { label: 'FF', value: 2 },\r\n { label: 'SF', value: 3 },\r\n ]);\r\n\r\n readonly availableTaskOptions = computed(() => {\r\n const currentTaskId = this.runtimeContext()?.moduleDataId;\r\n return this.taskOptions().filter(\r\n (item) => String(item.value) !== String(currentTaskId ?? ''),\r\n );\r\n });\r\n\r\n readonly canAddRow = computed(\r\n () =>\r\n !!this.runtimeContext()?.levelId &&\r\n !!this.runtimeContext()?.levelDataId &&\r\n this.availableTaskOptions().length > 0,\r\n );\r\n\r\n readonly addTooltip = computed(() =>\r\n this.canAddRow() ? undefined : this.texts().noAvailable,\r\n );\r\n readonly pageSize = computed(() =>\r\n this.rows().length > 0 ? this.rows().length : 1,\r\n );\r\n\r\n readonly columns = linkedSignal<ColumnDef[]>(() => [\r\n {\r\n key: 'predecessorId',\r\n label: this.texts().predecessor,\r\n type: 'custom',\r\n customCellTpl: this.predecessorCellTpl(),\r\n },\r\n {\r\n key: 'type',\r\n label: this.texts().type,\r\n type: 'custom',\r\n customCellTpl: this.typeCellTpl(),\r\n },\r\n {\r\n key: 'lagDays',\r\n label: this.texts().lagDays,\r\n type: 'custom',\r\n customCellTpl: this.lagCellTpl(),\r\n },\r\n ]);\r\n\r\n readonly rowActions = computed<TableAction[]>(() => [\r\n {\r\n icon: 'general.trash-01',\r\n color: 'danger',\r\n variant: 'text',\r\n tooltip: this.texts().delete,\r\n hidden: () => this.disabled() || this.readonly(),\r\n action: (row) => this.removeRow(row.key),\r\n },\r\n ]);\r\n\r\n requiredValidator = Validators.required;\r\n onTouched: () => void = () => {};\r\n onModelChange: (value: string | null) => void = () => {};\r\n\r\n public ngControl: NgControl | null = null;\r\n\r\n private readonly http = inject(HttpClient);\r\n private readonly transloco = inject(TranslocoService);\r\n private readonly destroyRef = inject(DestroyRef);\r\n private readonly activeLang = toSignal(this.transloco.langChanges$, {\r\n initialValue: this.transloco.getActiveLang(),\r\n });\r\n private rowKey = 0;\r\n\r\n readonly texts = computed(() => {\r\n this.activeLang();\r\n\r\n return {\r\n noAvailable: this.transloco.translate(\r\n 'components.schedulePredecessorField.noAvailable',\r\n ),\r\n predecessor: this.transloco.translate(\r\n 'components.schedulePredecessorField.predecessor',\r\n ),\r\n type: this.transloco.translate(\r\n 'components.schedulePredecessorField.type',\r\n ),\r\n lagDays: this.transloco.translate(\r\n 'components.schedulePredecessorField.lagDays',\r\n ),\r\n delete: this.transloco.translate(\r\n 'components.schedulePredecessorField.delete',\r\n ),\r\n };\r\n });\r\n\r\n constructor() {\r\n this.ngControl = inject(NgControl, { self: true, optional: true });\r\n if (this.ngControl) {\r\n this.ngControl.valueAccessor = this;\r\n }\r\n\r\n effect(() => {\r\n if (this.ngControl?.control && this.required()) {\r\n this.ngControl.control.addValidators(Validators.required);\r\n this.ngControl.control.updateValueAndValidity();\r\n }\r\n });\r\n\r\n effect(() => {\r\n const context = this.runtimeContext();\r\n const levelId = context?.levelId;\r\n const levelDataId = context?.levelDataId;\r\n\r\n if (levelId == null || levelDataId == null) {\r\n this.taskOptions.set([]);\r\n return;\r\n }\r\n\r\n untracked(() => this.loadTaskOptions(levelId, levelDataId));\r\n });\r\n }\r\n\r\n addRow(): void {\r\n if (this.disabled() || this.readonly() || !this.canAddRow()) {\r\n return;\r\n }\r\n\r\n this.syncRows([\r\n ...this.rows(),\r\n {\r\n key: this.nextRowKey(),\r\n predecessorId: '',\r\n type: 0,\r\n lagDays: 0,\r\n },\r\n ]);\r\n }\r\n\r\n removeRow(key: string): void {\r\n if (this.disabled() || this.readonly()) {\r\n return;\r\n }\r\n\r\n this.syncRows(this.rows().filter((row) => row.key !== key));\r\n }\r\n\r\n updateRow(key: string, patch: Partial<SchedulePredecessorRow>): void {\r\n if (this.disabled() || this.readonly()) {\r\n return;\r\n }\r\n\r\n this.syncRows(\r\n this.rows().map((row) => (row.key === key ? { ...row, ...patch } : row)),\r\n );\r\n }\r\n\r\n writeValue(value: unknown): void {\r\n const rows =\r\n typeof value === 'string'\r\n ? value\r\n .split(',')\r\n .map((item) => item.trim())\r\n .filter(Boolean)\r\n .map((item) => this.parseCompactValue(item))\r\n .filter((item): item is SchedulePredecessorValue => item != null)\r\n .map((item) => ({\r\n key: this.nextRowKey(),\r\n ...item,\r\n }))\r\n : [];\r\n\r\n this.rows.set(rows);\r\n }\r\n\r\n registerOnChange(fn: (value: string | null) => void): void {\r\n this.onModelChange = fn;\r\n }\r\n\r\n registerOnTouched(fn: () => void): void {\r\n this.onTouched = fn;\r\n }\r\n\r\n setDisabledState(disabled: boolean): void {\r\n this.disabled.set(disabled);\r\n }\r\n\r\n private syncRows(rows: SchedulePredecessorRow[]): void {\r\n this.rows.set(rows);\r\n const value = rows\r\n .filter(\r\n (row) =>\r\n row.predecessorId !== null &&\r\n row.predecessorId !== undefined &&\r\n String(row.predecessorId).trim() !== '',\r\n )\r\n .map((row) => this.formatCompactValue(row))\r\n .join(',');\r\n\r\n this.onModelChange(value || null);\r\n this.onTouched();\r\n }\r\n\r\n private loadTaskOptions(\r\n levelId: number | string,\r\n levelDataId: number | string,\r\n ): void {\r\n this.loading.set(true);\r\n\r\n this.http\r\n .post<ScheduleQueryResponse>(\r\n `levels/${levelId}/${levelDataId}/schedule/query`,\r\n {\r\n projection: 'Tree',\r\n propertyKeys: ['name'],\r\n },\r\n )\r\n .pipe(\r\n takeUntilDestroyed(this.destroyRef),\r\n finalize(() => this.loading.set(false)),\r\n catchError(() => of({ data: { records: [] } })),\r\n )\r\n .subscribe((response) => {\r\n this.taskOptions.set(this.mapTaskOptions(response.data));\r\n });\r\n }\r\n\r\n private mapTaskOptions(\r\n data: ScheduleQueryData | null | undefined,\r\n ): SelectOption[] {\r\n // Labels show the ROW NUMBER (1-based position in the same pre-order walk\r\n // the grid's ID column numbers), not the backend id — the two surfaces\r\n // must speak one coordinate. The option VALUE stays the real id: the\r\n // compact predecessor string this field produces is wire format.\r\n return this.flattenRecords(\r\n this.resolveRootRecords(\r\n data?.records ?? [],\r\n data?.projectionMeta?.rootIds ?? [],\r\n ),\r\n ).map((record, index) => ({\r\n label: `${index + 1} - ${record.name ?? record.id}`,\r\n value: String(record.id),\r\n }));\r\n }\r\n\r\n private resolveRootRecords(\r\n records: ScheduleQueryRecord[],\r\n rootIds: Array<number | string> | null | undefined,\r\n ): ScheduleQueryRecord[] {\r\n if (!rootIds?.length) {\r\n return records;\r\n }\r\n\r\n const recordsById = new Map(\r\n records.map((record) => [String(record.id), record]),\r\n );\r\n\r\n return rootIds\r\n .map((id) => recordsById.get(String(id)))\r\n .filter((record): record is ScheduleQueryRecord => record != null);\r\n }\r\n\r\n private flattenRecords(\r\n records: ScheduleQueryRecord[],\r\n ): ScheduleQueryRecord[] {\r\n const output: ScheduleQueryRecord[] = [];\r\n\r\n const walk = (items: ScheduleQueryRecord[]): void => {\r\n items.forEach((item) => {\r\n output.push(item);\r\n walk(item.children ?? []);\r\n });\r\n };\r\n\r\n walk(records);\r\n return output;\r\n }\r\n\r\n private nextRowKey(): string {\r\n this.rowKey += 1;\r\n return `predecessor-${this.rowKey}`;\r\n }\r\n\r\n private parseCompactValue(value: string): SchedulePredecessorValue | null {\r\n const match = value.match(/^(.+?)(FS|SS|FF|SF)([+-]\\d+)?$/);\r\n\r\n if (!match) {\r\n return null;\r\n }\r\n\r\n return {\r\n predecessorId: match[1],\r\n type: PREDECESSOR_TYPE_BY_TOKEN[match[2] as PredecessorTypeToken],\r\n lagDays: match[3] ? Number(match[3]) : 0,\r\n };\r\n }\r\n\r\n private formatCompactValue(row: SchedulePredecessorValue): string {\r\n const lag =\r\n row.lagDays > 0 ? `+${row.lagDays}` : row.lagDays < 0 ? row.lagDays : '';\r\n\r\n return `${row.predecessorId}${PREDECESSOR_TOKEN_BY_TYPE[row.type]}${lag}`;\r\n }\r\n}\r\n","<div class=\"gap-3 overflow-auto\">\r\n <div class=\"flex items-center justify-between mb-2\">\r\n <div>\r\n @if (label()) {\r\n <label\r\n [class.required]=\"ngControl?.control?.hasValidator(requiredValidator)\"\r\n [for]=\"fieldId\"\r\n >\r\n {{ label() }}\r\n </label>\r\n }\r\n </div>\r\n <mt-button\r\n icon=\"general.plus\"\r\n [label]=\"'components.schedulePredecessorField.add' | transloco\"\r\n severity=\"secondary\"\r\n variant=\"outlined\"\r\n size=\"small\"\r\n [disabled]=\"disabled() || readonly() || !canAddRow()\"\r\n [tooltip]=\"addTooltip()\"\r\n (onClick)=\"addRow()\"\r\n />\r\n </div>\r\n\r\n <ng-template #predecessorCellTpl let-row>\r\n <mt-select-field\r\n [field]=\"false\"\r\n [options]=\"availableTaskOptions()\"\r\n optionLabel=\"label\"\r\n optionValue=\"value\"\r\n [placeholder]=\"\r\n placeholder() ||\r\n ('components.schedulePredecessorField.selectPredecessor' | transloco)\r\n \"\r\n [filter]=\"true\"\r\n [showClear]=\"true\"\r\n [loading]=\"loading()\"\r\n [readonly]=\"disabled() || readonly()\"\r\n [ngModel]=\"row.predecessorId || undefined\"\r\n (onChange)=\"updateRow(row.key, { predecessorId: $event ?? '' })\"\r\n />\r\n </ng-template>\r\n\r\n <ng-template #typeCellTpl let-row>\r\n <mt-select-field\r\n [field]=\"false\"\r\n [options]=\"typeOptions()\"\r\n optionLabel=\"label\"\r\n optionValue=\"value\"\r\n [readonly]=\"disabled() || readonly()\"\r\n [ngModel]=\"row.type\"\r\n (onChange)=\"updateRow(row.key, { type: $event ?? 0 })\"\r\n />\r\n </ng-template>\r\n\r\n <ng-template #lagCellTpl let-row>\r\n <mt-number-field\r\n [field]=\"false\"\r\n [useGrouping]=\"false\"\r\n [placeholder]=\"'components.schedulePredecessorField.lagDays' | transloco\"\r\n [readonly]=\"disabled() || readonly()\"\r\n [ngModel]=\"row.lagDays\"\r\n (ngModelChange)=\"updateRow(row.key, { lagDays: $event ?? 0 })\"\r\n />\r\n </ng-template>\r\n\r\n <mt-table\r\n noCard\r\n [data]=\"rows()\"\r\n [columns]=\"columns()\"\r\n [rowActions]=\"rowActions()\"\r\n [pageSize]=\"pageSize()\"\r\n [generalSearch]=\"false\"\r\n [showFilters]=\"false\"\r\n [dataKey]=\"'key'\"\r\n storageKey=\"schedule-predecessor-field-table\"\r\n [loading]=\"loading()\"\r\n >\r\n <ng-template #empty>\r\n <div\r\n class=\"rounded-xl border border-dashed border-surface px-4 py-5 text-sm text-muted-color\"\r\n >\r\n {{ \"components.schedulePredecessorField.empty\" | transloco }}\r\n </div>\r\n </ng-template>\r\n </mt-table>\r\n</div>\r\n\r\n<mt-field-validation [control]=\"ngControl?.control\"></mt-field-validation>\r\n","import { InjectionToken, Type } from '@angular/core';\r\nimport type {\r\n EntityListLocalCell,\r\n EntityListLocalSchemaField,\r\n} from '@masterteam/components/entities';\r\n\r\n/** Inputs the EntityList add-row dialog will receive via ModalService inputValues. */\r\nexport interface EntityListAddDialogInputs {\r\n moduleId: number | string | null;\r\n levelId: number | string | null;\r\n levelDataId: number | string | null;\r\n /** Property keys that should be editable in the dialog. */\r\n writeFields: string[];\r\n /**\r\n * Host form's lookup catalog. The dialog's nested form needs it to resolve\r\n * options for the target module's `Lookup` / `LookupMultiSelect` fields.\r\n */\r\n lookups?: unknown[];\r\n /** Pre-populated form values (keyed by property key) for the Edit flow. */\r\n initialValues?: Record<string, unknown>;\r\n /** True when the dialog edits an existing row rather than adding one. */\r\n isEdit?: boolean;\r\n}\r\n\r\n/**\r\n * Token used by `mt-entity-list-field` (Write mode) to open the rich add-row\r\n * dialog backed by `@masterteam/forms`'s `mt-client-form`. Apps that want this\r\n * behavior should call `provideEntityListAddForm()` from\r\n * `@masterteam/forms/entity-list-add-form` in their app providers. When the\r\n * token is not registered, the field falls back to a minimal text-only popup.\r\n */\r\nexport const ENTITY_LIST_ADD_DIALOG_COMPONENT = new InjectionToken<\r\n Type<unknown>\r\n>('ENTITY_LIST_ADD_DIALOG_COMPONENT');\r\n\r\n/**\r\n * Inputs the Local row dialog receives via `ModalService` `inputValues`.\r\n *\r\n * A Local list (`storageMode: \"Local\"`) has no source form to load: its rows\r\n * belong to the parent record, and the source module only lent its field\r\n * definitions, which the published schema captured. So the dialog is built\r\n * from `fields` — never from `process-form-load` of the source module, which\r\n * may not even be mapped to this level.\r\n */\r\nexport interface EntityListLocalRowDialogInputs {\r\n /** Visible schema fields, in order, each with its captured definition. */\r\n fields: EntityListLocalSchemaField[];\r\n /** Host form's lookup catalog, for `Lookup` / `LookupMultiSelect` fields. */\r\n lookups?: unknown[];\r\n /**\r\n * The loaded cells of the row being edited, by field id. Each is mapped the\r\n * way a top-level form maps a loaded value (a `User` from its rendered\r\n * object, a `Checkbox` from its stored text …).\r\n */\r\n initialCells?: Record<string, EntityListLocalCell>;\r\n /** Control values from this session, by field id; win over `initialCells`. */\r\n initialValues?: Record<string, unknown>;\r\n isEdit?: boolean;\r\n}\r\n\r\n/**\r\n * Close payload of the Local row dialog, keyed by field id. Same three maps as\r\n * the linked dialog: `values` refills the form, `display` renders option\r\n * labels, and `submit` is each value reduced to the scalar the backend\r\n * stores — the field only serializes it.\r\n */\r\nexport interface EntityListLocalRowDialogResult {\r\n values: Record<string, unknown>;\r\n display: Record<string, unknown>;\r\n submit: Record<string, unknown>;\r\n}\r\n\r\n/**\r\n * Local counterpart of `ENTITY_LIST_ADD_DIALOG_COMPONENT`, registered by the\r\n * same `provideEntityListAddForm()`. Without it a Local list is read-only.\r\n */\r\nexport const ENTITY_LIST_LOCAL_ROW_DIALOG_COMPONENT = new InjectionToken<\r\n Type<unknown>\r\n>('ENTITY_LIST_LOCAL_ROW_DIALOG_COMPONENT');\r\n","import {\r\n sortLocalRows,\r\n type EntityListLocalDocument,\r\n type EntityListLocalRow,\r\n} from '@masterteam/components/entities';\r\n\r\n/**\r\n * Editing state of a Local `EntityList` (`storageMode: \"Local\"`) and the\r\n * mutation it produces. Pure functions over plain objects, so the rules the\r\n * backend enforces are tested without a TestBed. The contract is the \"Submit\r\n * rows through the parent process\" table of\r\n * `.github/instructions/properties/EntityList.md`.\r\n */\r\n\r\n/** What the user did to one row in this session. */\r\nexport interface LocalRowDraft {\r\n /**\r\n * Serialized cell values, by field id — the wire format. On an existing row\r\n * only the cells that differ from the loaded ones; `null` clears a cell.\r\n */\r\n cells: Record<string, string | null>;\r\n /** Control values, by field id, to refill the dialog on the next edit. */\r\n values: Record<string, unknown>;\r\n /** Resolved option labels, by field id, so the table can print the row. */\r\n display: Record<string, unknown>;\r\n}\r\n\r\n/** A row added in this session. Its id is final: rows are client-keyed. */\r\nexport interface LocalCreatedRow {\r\n rowId: string;\r\n draft: LocalRowDraft;\r\n}\r\n\r\nexport interface LocalEditorState {\r\n /**\r\n * The projected document the form loaded — current list and row versions,\r\n * rendered cells and the schema they were projected against. Null before\r\n * the parent's list was ever saved (a create form, or a record that has\r\n * never had rows).\r\n */\r\n base: EntityListLocalDocument | null;\r\n created: LocalCreatedRow[];\r\n /** Edits of loaded rows, by row id. */\r\n edited: Record<string, LocalRowDraft>;\r\n /** Loaded rows the user removed. */\r\n deleted: string[];\r\n /** Row ids in the order the user dragged them into; null until they do. */\r\n order: string[] | null;\r\n /**\r\n * The mutation id of the last emitted payload, and that payload's content.\r\n * A retry of an unchanged save must reuse the id — the backend treats the\r\n * same id with the same content as the same save — and any change of\r\n * content is a new logical save that needs a new one.\r\n */\r\n mutationId: string | null;\r\n mutationKey: string | null;\r\n}\r\n\r\nexport function createLocalEditorState(\r\n base: EntityListLocalDocument | null,\r\n): LocalEditorState {\r\n return {\r\n base,\r\n created: [],\r\n edited: {},\r\n deleted: [],\r\n order: null,\r\n mutationId: null,\r\n mutationKey: null,\r\n };\r\n}\r\n\r\n/** One rendered row, in display order, with the order it would be saved at. */\r\nexport interface LocalOrderedRow {\r\n rowId: string;\r\n order: number;\r\n existing?: EntityListLocalRow;\r\n created?: LocalCreatedRow;\r\n}\r\n\r\n/**\r\n * Rows in display order. Until the user reorders, loaded rows keep their\r\n * stored `order` and new rows go after the last one. After a reorder every row\r\n * takes its position — the backend requires a non-negative order and nothing\r\n * more, so positions are the simplest valid numbering.\r\n */\r\nexport function orderLocalRows(state: LocalEditorState): LocalOrderedRow[] {\r\n const deleted = new Set(state.deleted);\r\n const loaded = sortLocalRows(state.base?.localRows).filter(\r\n (row) => !deleted.has(row.rowId),\r\n );\r\n const maxOrder = loaded.reduce(\r\n (max, row) => Math.max(max, row.order ?? 0),\r\n -1,\r\n );\r\n\r\n const rows: LocalOrderedRow[] = [\r\n ...loaded.map((row) => ({\r\n rowId: row.rowId,\r\n order: row.order ?? 0,\r\n existing: row,\r\n })),\r\n ...state.created.map((row, index) => ({\r\n rowId: row.rowId,\r\n order: maxOrder + 1 + index,\r\n created: row,\r\n })),\r\n ];\r\n\r\n if (!state.order) return rows;\r\n\r\n const position = new Map(state.order.map((rowId, index) => [rowId, index]));\r\n return rows\r\n .map((row, index) => ({ row, index }))\r\n .sort(\r\n (a, b) =>\r\n (position.get(a.row.rowId) ?? state.order!.length + a.index) -\r\n (position.get(b.row.rowId) ?? state.order!.length + b.index),\r\n )\r\n .map(({ row }, index) => ({ ...row, order: index }));\r\n}\r\n\r\n/** The writable part of a Local mutation. */\r\nexport interface LocalMutationContent {\r\n localRows: {\r\n rowId: string;\r\n order: number;\r\n version: number;\r\n cells: { fieldId: string; rawValue: string | null }[];\r\n }[];\r\n deletedRowIds: string[];\r\n}\r\n\r\n/**\r\n * What changed, or null when nothing did.\r\n *\r\n * - A loaded row is sent only when a cell or its order changed, with its\r\n * loaded version and only those cells: omission retains a cell or a row, it\r\n * never deletes one. A reorder alone sends no cells.\r\n * - A new row is sent with version 0 and every cell the user filled in.\r\n * - A removed row is listed in `deletedRowIds` and never also submitted.\r\n */\r\nexport function buildLocalMutationContent(\r\n state: LocalEditorState,\r\n): LocalMutationContent | null {\r\n const localRows: LocalMutationContent['localRows'] = [];\r\n\r\n for (const row of orderLocalRows(state)) {\r\n if (row.existing) {\r\n const cells = toCells(state.edited[row.rowId]?.cells ?? {});\r\n if (!cells.length && row.order === (row.existing.order ?? 0)) continue;\r\n localRows.push({\r\n rowId: row.rowId,\r\n order: row.order,\r\n version: row.existing.version ?? 0,\r\n cells,\r\n });\r\n continue;\r\n }\r\n\r\n localRows.push({\r\n rowId: row.rowId,\r\n order: row.order,\r\n version: 0,\r\n cells: toCells(row.created?.draft.cells ?? {}).filter(\r\n (cell) => cell.rawValue !== null,\r\n ),\r\n });\r\n }\r\n\r\n if (!localRows.length && !state.deleted.length) return null;\r\n return { localRows, deletedRowIds: [...state.deleted] };\r\n}\r\n\r\nfunction toCells(\r\n cells: Record<string, string | null>,\r\n): { fieldId: string; rawValue: string | null }[] {\r\n return Object.entries(cells).map(([fieldId, rawValue]) => ({\r\n fieldId,\r\n rawValue,\r\n }));\r\n}\r\n\r\n/**\r\n * The cells of an edited loaded row that differ from what was loaded.\r\n * Setting a cell back to its loaded value drops it, so an edit that is undone\r\n * by hand stops being an edit.\r\n */\r\nexport function diffLocalCells(\r\n loaded: EntityListLocalRow,\r\n next: Record<string, string | null>,\r\n): Record<string, string | null> {\r\n const before = new Map(\r\n (loaded.cells ?? []).map((cell) => [cell.fieldId, cell.rawValue ?? null]),\r\n );\r\n const changed: Record<string, string | null> = {};\r\n for (const [fieldId, rawValue] of Object.entries(next)) {\r\n if ((before.get(fieldId) ?? null) === rawValue) continue;\r\n changed[fieldId] = rawValue;\r\n }\r\n return changed;\r\n}\r\n\r\n/**\r\n * A v4 UUID. Row ids and mutation ids are parsed as GUIDs by the backend.\r\n * `crypto.randomUUID` exists only in secure contexts, and these apps are also\r\n * served over plain HTTP, where `getRandomValues` is still available.\r\n */\r\nexport function newLocalUuid(): string {\r\n if (typeof crypto.randomUUID === 'function') return crypto.randomUUID();\r\n const bytes = crypto.getRandomValues(new Uint8Array(16));\r\n bytes[6] = (bytes[6] & 0x0f) | 0x40;\r\n bytes[8] = (bytes[8] & 0x3f) | 0x80;\r\n const hex = Array.from(bytes, (byte) => byte.toString(16).padStart(2, '0'));\r\n return [\r\n hex.slice(0, 4).join(''),\r\n hex.slice(4, 6).join(''),\r\n hex.slice(6, 8).join(''),\r\n hex.slice(8, 10).join(''),\r\n hex.slice(10, 16).join(''),\r\n ].join('-');\r\n}\r\n","import type {\r\n EntityListSelectionDocument,\r\n EntityListSelectionRecord,\r\n} from '@masterteam/components/entities';\r\n\r\n/**\r\n * Pure editing state of a Selected `EntityList` (`recordMode: \"Selected\"`) —\r\n * which source records the parent holds — and the value it submits. Kept out\r\n * of the component so the submission rules are tested without rendering. See\r\n * `.github/instructions/properties/EntityList.md`.\r\n */\r\n\r\n/** A record the user picked, as the picker listed it. */\r\nexport interface SelectionPick {\r\n id: number;\r\n name: string;\r\n /**\r\n * The option's display values (`metadataJson`), when the backend sent them:\r\n * current candidate data, shown until the parent is saved — never evidence,\r\n * and never submitted.\r\n */\r\n record?: EntityListSelectionRecord | null;\r\n}\r\n\r\n/**\r\n * The display record an option carries in `metadataJson` — a JSON string\r\n * holding `{ entityId, values }`, the shape of a projected `records` entry.\r\n * Null when absent (an older backend), unparsable, or for another record.\r\n */\r\nexport function parseOptionRecord(\r\n metadataJson: unknown,\r\n id: number,\r\n): EntityListSelectionRecord | null {\r\n if (typeof metadataJson !== 'string' || !metadataJson.trim()) return null;\r\n try {\r\n const parsed = JSON.parse(\r\n metadataJson,\r\n ) as Partial<EntityListSelectionRecord>;\r\n if (Number(parsed?.entityId) !== id || !Array.isArray(parsed?.values)) {\r\n return null;\r\n }\r\n return { entityId: id, values: parsed.values };\r\n } catch {\r\n return null;\r\n }\r\n}\r\n\r\nexport interface SelectionEditorState {\r\n /**\r\n * The value as it arrived: the projection `process-form-load` returns\r\n * (`records` rendered, `version` to save against), or a mutation the form\r\n * already held. Null for a list that was never saved.\r\n */\r\n base: EntityListSelectionDocument | null;\r\n /** The selected record ids, in display order. */\r\n ids: number[];\r\n /**\r\n * Names of records picked in this session — what shows when the picker\r\n * sent no display values.\r\n */\r\n names: Record<number, string>;\r\n /**\r\n * Display values of records picked in this session, from the picker's\r\n * option metadata. Only for new picks: a loaded record keeps the values the\r\n * backend rendered for it.\r\n */\r\n records: Record<number, EntityListSelectionRecord>;\r\n /** Kept while the content is unchanged, so a retry reuses it. */\r\n mutationId: string | null;\r\n mutationKey: string | null;\r\n}\r\n\r\nexport function createSelectionEditorState(\r\n base: EntityListSelectionDocument | null,\r\n): SelectionEditorState {\r\n return {\r\n base,\r\n ids: positiveIds(base?.entityIds),\r\n names: {},\r\n records: {},\r\n mutationId: null,\r\n mutationKey: null,\r\n };\r\n}\r\n\r\nfunction positiveIds(ids: readonly unknown[] | null | undefined): number[] {\r\n const out: number[] = [];\r\n for (const entry of ids ?? []) {\r\n const id = Number(entry);\r\n if (Number.isInteger(id) && id > 0 && !out.includes(id)) out.push(id);\r\n }\r\n return out;\r\n}\r\n\r\n/** Same records regardless of order — the backend stores them sorted. */\r\nexport function sameSelection(\r\n a: readonly number[],\r\n b: readonly number[],\r\n): boolean {\r\n if (a.length !== b.length) return false;\r\n const set = new Set(a);\r\n return b.every((id) => set.has(id));\r\n}\r\n\r\n/**\r\n * Replace the selection with the picker's result. Records already selected\r\n * keep their place; new ones are appended in the order they were picked. In\r\n * single mode only the last pick survives.\r\n */\r\nexport function applySelectionPicks(\r\n state: SelectionEditorState,\r\n picks: readonly SelectionPick[],\r\n multiple: boolean,\r\n): SelectionEditorState {\r\n const wanted = positiveIds(picks.map((pick) => pick.id));\r\n const chosen = multiple ? wanted : wanted.slice(-1);\r\n const kept = state.ids.filter((id) => chosen.includes(id));\r\n const added = chosen.filter((id) => !kept.includes(id));\r\n const names = { ...state.names };\r\n const records = { ...state.records };\r\n for (const pick of picks) {\r\n if (!added.includes(pick.id)) continue;\r\n if (pick.name) names[pick.id] = pick.name;\r\n if (pick.record) records[pick.id] = pick.record;\r\n }\r\n return { ...state, ids: [...kept, ...added], names, records };\r\n}\r\n\r\nexport function removeSelectedRecord(\r\n state: SelectionEditorState,\r\n id: number,\r\n): SelectionEditorState {\r\n return { ...state, ids: state.ids.filter((entry) => entry !== id) };\r\n}\r\n\r\n/**\r\n * The control's value for a state.\r\n *\r\n * A changed selection is a mutation: the full replacement `entityIds`, the\r\n * version it was loaded at, and a `mutationId` that stays the same while the\r\n * content does (a retry of the same save) and changes with it. Nothing else is\r\n * sent — the backend discards rendered records and snapshots, and rejects any\r\n * other member.\r\n *\r\n * An unchanged selection is the value it arrived as, which the submission\r\n * leaves out: an omitted Selected list keeps its membership.\r\n */\r\nexport function buildSelectionValue(\r\n next: SelectionEditorState,\r\n newUuid: () => string,\r\n): {\r\n state: SelectionEditorState;\r\n value: EntityListSelectionDocument | null;\r\n} {\r\n const loaded = next.base?.entityIds ?? [];\r\n if (sameSelection(next.ids, positiveIds(loaded))) {\r\n return {\r\n state: { ...next, mutationId: null, mutationKey: null },\r\n value: next.base,\r\n };\r\n }\r\n\r\n const version = Number(next.base?.version ?? 0) || 0;\r\n const entityIds = [...next.ids];\r\n const mutationKey = JSON.stringify({\r\n version,\r\n entityIds: [...entityIds].sort((a, b) => a - b),\r\n });\r\n const mutationId =\r\n next.mutationKey === mutationKey && next.mutationId\r\n ? next.mutationId\r\n : newUuid();\r\n return {\r\n state: { ...next, mutationId, mutationKey },\r\n value: { recordMode: 'Selected', version, mutationId, entityIds },\r\n };\r\n}\r\n","import {\r\n ChangeDetectionStrategy,\r\n Component,\r\n DestroyRef,\r\n OnInit,\r\n computed,\r\n inject,\r\n input,\r\n signal,\r\n} from '@angular/core';\r\nimport { takeUntilDestroyed } from '@angular/core/rxjs-interop';\r\nimport { FormControl, ReactiveFormsModule } from '@angular/forms';\r\nimport {\r\n HttpClient,\r\n HttpContext,\r\n HttpErrorResponse,\r\n HttpParams,\r\n} from '@angular/common/http';\r\nimport { TranslocoPipe } from '@jsverse/transloco';\r\nimport { Skeleton } from 'primeng/skeleton';\r\nimport {\r\n Subscription,\r\n debounceTime,\r\n distinctUntilChanged,\r\n finalize,\r\n map,\r\n} from 'rxjs';\r\nimport { Icon } from '@masterteam/icons';\r\nimport { Button } from '@masterteam/components/button';\r\nimport { ModalRef } from '@masterteam/components/dialog';\r\nimport { ModalService } from '@masterteam/components/modal';\r\nimport { TextField } from '@masterteam/components/text-field';\r\n\r\nimport {\r\n parseOptionRecord,\r\n type SelectionPick,\r\n} from './entity-list-selection-editor';\r\n\r\n/** `GET forms/options/{propertyKey}` — only what the picker reads. */\r\ninterface SelectionOptionsResponse {\r\n data?: {\r\n items?: Array<{\r\n key: string;\r\n name?: string | null;\r\n /** `{ entityId, values }` as a JSON string; see `parseOptionRecord`. */\r\n metadataJson?: string | null;\r\n }> | null;\r\n hasMore?: boolean;\r\n } | null;\r\n}\r\n\r\n/**\r\n * Candidates per request. The backend takes 1–100 and requires `skip` to be a\r\n * multiple of `take`, so paging only ever adds whole pages.\r\n */\r\nconst PAGE_SIZE = 25;\r\n\r\n/** The backend's limit on one list's selection. */\r\nexport const ENTITY_LIST_MAX_SELECTIONS = 100;\r\n\r\n/**\r\n * Picker of a Selected `EntityList` (`recordMode: \"Selected\"`), opened by\r\n * `mt-entity-list-field`.\r\n *\r\n * Candidates come from `GET forms/options/{propertyKey}` with the **parent's**\r\n * context: the backend resolves the source module and its eligibility filter\r\n * from the property's trusted configuration, so the caller never names the\r\n * source. Each candidate is only a key and a name — its field values are\r\n * rendered once the parent is saved.\r\n *\r\n * Closes with the chosen records as `SelectionPick[]`, or `null` on Cancel.\r\n */\r\n@Component({\r\n selector: 'mt-entity-list-selection-dialog',\r\n standalone: true,\r\n imports: [\r\n ReactiveFormsModule,\r\n TranslocoPipe,\r\n Skeleton,\r\n Icon,\r\n Button,\r\n TextField,\r\n ],\r\n templateUrl: './entity-list-selection-dialog.html',\r\n changeDetection: ChangeDetectionStrategy.OnPush,\r\n})\r\nexport class EntityListSelectionDialog implements OnInit {\r\n private readonly ref = inject(ModalRef);\r\n /** Exposes the shared modal content/footer classes to the template. */\r\n protected readonly modal = inject(ModalService);\r\n private readonly http = inject(HttpClient);\r\n private readonly destroyRef = inject(DestroyRef);\r\n\r\n /** The EntityList property's key — the options route. */\r\n readonly propertyKey = input<string>('');\r\n /** The parent form's context, e.g. `Level:3/Module:22`. */\r\n readonly contextKey = input<string>('');\r\n readonly levelDataId = input<number | string | null>(null);\r\n readonly multiple = input<boolean>(true);\r\n /** The records the field holds now. */\r\n readonly selectedIds = input<number[]>([]);\r\n readonly context = input<HttpContext | undefined>(undefined);\r\n\r\n protected readonly searchControl = new FormControl<string>('', {\r\n nonNullable: true,\r\n });\r\n\r\n protected readonly items = signal<SelectionPick[]>([]);\r\n protected readonly loading = signal<boolean>(false);\r\n protected readonly hasMore = signal<boolean>(false);\r\n /** Translation key of the failure to show instead of the list, if any. */\r\n protected readonly failureKey = signal<string | null>(null);\r\n\r\n /** Chosen records, in the order they were picked; id → name. */\r\n protected readonly picked = signal<Map<number, string>>(new Map());\r\n protected readonly pickedCount = computed(() => this.picked().size);\r\n protected readonly atLimit = computed(\r\n () => this.multiple() && this.pickedCount() >= ENTITY_LIST_MAX_SELECTIONS,\r\n );\r\n protected readonly maxSelections = ENTITY_LIST_MAX_SELECTIONS;\r\n\r\n private nextSkip = 0;\r\n private request?: Subscription;\r\n\r\n ngOnInit(): void {\r\n this.picked.set(new Map(this.selectedIds().map((id) => [id, ''])));\r\n this.searchControl.valueChanges\r\n .pipe(\r\n debounceTime(300),\r\n map((value) => value.trim()),\r\n distinctUntilChanged(),\r\n takeUntilDestroyed(this.destroyRef),\r\n )\r\n .subscribe(() => this.load(true));\r\n this.load(true);\r\n }\r\n\r\n protected isPicked(id: number): boolean {\r\n return this.picked().has(id);\r\n }\r\n\r\n /**\r\n * Multiple mode toggles the record. Single mode replaces the choice, and\r\n * picking the chosen record again clears it.\r\n */\r\n protected toggle(item: SelectionPick): void {\r\n const current = this.picked();\r\n if (current.has(item.id)) {\r\n const next = new Map(current);\r\n next.delete(item.id);\r\n this.picked.set(next);\r\n return;\r\n }\r\n if (!this.multiple()) {\r\n this.picked.set(new Map([[item.id, item.name]]));\r\n return;\r\n }\r\n if (this.atLimit()) return;\r\n this.picked.set(new Map(current).set(item.id, item.name));\r\n }\r\n\r\n protected loadMore(): void {\r\n this.load(false);\r\n }\r\n\r\n protected onCancel(): void {\r\n this.ref.close(null);\r\n }\r\n\r\n protected onApply(): void {\r\n const listed = new Map(this.items().map((item) => [item.id, item]));\r\n const picks: SelectionPick[] = [...this.picked()].map(([id, name]) => ({\r\n id,\r\n name: name || listed.get(id)?.name || '',\r\n record: listed.get(id)?.record ?? null,\r\n }));\r\n this.ref.close(picks);\r\n }\r\n\r\n /**\r\n * Load a page of candidates; `reset` starts over from the first page of the\r\n * current search.\r\n *\r\n * The first page of an unfiltered list also asks for the records already\r\n * selected (`includeSelected`), so they show as chosen even when they sit on\r\n * a later page. They are added beside the page, not counted in it.\r\n */\r\n private load(reset: boolean): void {\r\n this.request?.unsubscribe();\r\n if (reset) {\r\n this.nextSkip = 0;\r\n this.items.set([]);\r\n this.hasMore.set(false);\r\n }\r\n this.failureKey.set(null);\r\n\r\n const propertyKey = this.propertyKey();\r\n const contextKey = this.contextKey();\r\n if (!propertyKey || !contextKey) {\r\n this.failureKey.set('components.entityListField.selectionUnavailable');\r\n return;\r\n }\r\n\r\n const search = this.searchControl.value.trim();\r\n const skip = this.nextSkip;\r\n let params = new HttpParams()\r\n .set('contextKey', contextKey)\r\n .set('skip', String(skip))\r\n .set('take', String(PAGE_SIZE));\r\n const levelDataId = this.levelDataId();\r\n if (levelDataId != null && levelDataId !== '') {\r\n params = params.set('levelDataId', String(levelDataId));\r\n }\r\n if (search) {\r\n params = params.set('search', search);\r\n }\r\n const selected = this.selectedIds();\r\n if (skip === 0 && !search && selected.length) {\r\n params = params.set('includeSelected', 'true');\r\n for (const id of selected) {\r\n params = params.append('selectedIds', String(id));\r\n }\r\n }\r\n\r\n this.loading.set(true);\r\n const context = this.context();\r\n this.request = this.http\r\n .get<SelectionOptionsResponse>(\r\n `forms/options/${encodeURIComponent(propertyKey)}`,\r\n {\r\n params,\r\n // Failures are shown inside the dialog, not as a host toast.\r\n headers: { noMessage: 'true' },\r\n ...(context ? { context } : {}),\r\n },\r\n )\r\n .pipe(\r\n finalize(() => this.loading.set(false)),\r\n takeUntilDestroyed(this.destroyRef),\r\n )\r\n .subscribe({\r\n next: (response) => this.applyPage(response, skip),\r\n error: (error: HttpErrorResponse) =>\r\n this.failureKey.set(\r\n error?.error?.errors?.code === 'entity_list.target_read_denied'\r\n ? 'components.entityListField.accessDenied'\r\n : 'components.entityListField.selectionLoadFailed',\r\n ),\r\n });\r\n }\r\n\r\n private applyPage(response: SelectionOptionsResponse, skip: number): void {\r\n const page: SelectionPick[] = [];\r\n for (const item of response?.data?.items ?? []) {\r\n const id = Number(item?.key);\r\n if (!Number.isInteger(id) || id <= 0) continue;\r\n page.push({\r\n id,\r\n name: item.name?.trim() || `#${id}`,\r\n record: parseOptionRecord(item.metadataJson, id),\r\n });\r\n }\r\n\r\n const seen = new Set(this.items().map((item) => item.id));\r\n this.items.set([\r\n ...this.items(),\r\n ...page.filter((item) => !seen.has(item.id)),\r\n ]);\r\n this.hasMore.set(!!response?.data?.hasMore);\r\n this.nextSkip = skip + PAGE_SIZE;\r\n }\r\n}\r\n","<div [class]=\"modal.contentClass + ' flex max-h-[70vh] flex-col gap-3 p-4'\">\r\n <mt-text-field\r\n [formControl]=\"searchControl\"\r\n icon=\"general.search-md\"\r\n [placeholder]=\"'components.entityListField.searchRecords' | transloco\"\r\n />\r\n\r\n @if (multiple()) {\r\n <p\r\n class=\"text-xs\"\r\n [class.text-muted-color]=\"!atLimit()\"\r\n [class.text-amber-700]=\"atLimit()\"\r\n >\r\n {{\r\n (atLimit()\r\n ? \"components.entityListField.selectionLimit\"\r\n : \"components.entityListField.selectedCount\"\r\n ) | transloco: { count: pickedCount(), max: maxSelections }\r\n }}\r\n </p>\r\n }\r\n\r\n @if (failureKey(); as failure) {\r\n <div\r\n class=\"rounded-md border border-red-200 bg-red-50 p-3 text-sm text-red-700\"\r\n >\r\n {{ failure | transloco }}\r\n </div>\r\n } @else {\r\n <div\r\n class=\"flex min-h-40 flex-col gap-1 overflow-y-auto\"\r\n role=\"listbox\"\r\n [attr.aria-multiselectable]=\"multiple()\"\r\n >\r\n @for (item of items(); track item.id) {\r\n @let chosen = isPicked(item.id);\r\n <button\r\n type=\"button\"\r\n role=\"option\"\r\n [attr.aria-selected]=\"chosen\"\r\n [disabled]=\"!chosen && atLimit()\"\r\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\"\r\n [class.border-primary]=\"chosen\"\r\n [class.bg-primary-50]=\"chosen\"\r\n [class.border-surface]=\"!chosen\"\r\n (click)=\"toggle(item)\"\r\n >\r\n <span\r\n class=\"flex size-4 shrink-0 items-center justify-center border\"\r\n [class.rounded-sm]=\"multiple()\"\r\n [class.rounded-full]=\"!multiple()\"\r\n [class.border-primary]=\"chosen\"\r\n [class.bg-primary]=\"chosen\"\r\n [class.text-primary-contrast]=\"chosen\"\r\n [class.border-surface-400]=\"!chosen\"\r\n >\r\n @if (chosen) {\r\n <mt-icon icon=\"general.check\" class=\"text-[0.625rem]\" />\r\n }\r\n </span>\r\n <span class=\"min-w-0 flex-1 truncate text-color\">{{\r\n item.name\r\n }}</span>\r\n </button>\r\n }\r\n\r\n @if (loading()) {\r\n <p-skeleton width=\"100%\" height=\"2.5rem\" borderRadius=\"0.375rem\" />\r\n <p-skeleton width=\"100%\" height=\"2.5rem\" borderRadius=\"0.375rem\" />\r\n <p-skeleton width=\"100%\" height=\"2.5rem\" borderRadius=\"0.375rem\" />\r\n } @else if (!items().length) {\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.noCandidates\" | transloco }}\r\n </div>\r\n }\r\n </div>\r\n\r\n @if (hasMore() && !loading()) {\r\n <div class=\"flex justify-center\">\r\n <mt-button\r\n [label]=\"'components.entityListField.loadMore' | transloco\"\r\n variant=\"text\"\r\n size=\"small\"\r\n (onClick)=\"loadMore()\"\r\n />\r\n </div>\r\n }\r\n }\r\n</div>\r\n\r\n<div [class]=\"modal.footerClass\">\r\n <mt-button\r\n [label]=\"'components.entityListField.cancel' | transloco\"\r\n severity=\"secondary\"\r\n variant=\"outlined\"\r\n (onClick)=\"onCancel()\"\r\n />\r\n <mt-button\r\n [label]=\"'components.entityListField.apply' | transloco\"\r\n severity=\"primary\"\r\n [disabled]=\"!!failureKey()\"\r\n (onClick)=\"onApply()\"\r\n />\r\n</div>\r\n","import {\r\n Component,\r\n ChangeDetectionStrategy,\r\n DestroyRef,\r\n computed,\r\n effect,\r\n inject,\r\n input,\r\n signal,\r\n untracked,\r\n} from '@angular/core';\r\nimport {\r\n AbstractControl,\r\n ControlValueAccessor,\r\n NgControl,\r\n ValidationErrors,\r\n Validators,\r\n} from '@angular/forms';\r\nimport { CommonModule } from '@angular/common';\r\nimport {\r\n HttpClient,\r\n HttpContext,\r\n HttpErrorResponse,\r\n} from '@angular/common/http';\r\nimport { TranslocoPipe, TranslocoService } from '@jsverse/transloco';\r\nimport { Skeleton } from 'primeng/skeleton';\r\nimport { Message } from 'primeng/message';\r\nimport { catchError, finalize, of, take, Subscription } from 'rxjs';\r\nimport { takeUntilDestroyed, toSignal } from '@angular/core/rxjs-interop';\r\n\r\nimport { Button } from '@masterteam/components/button';\r\nimport { Tabs } from '@masterteam/components/tabs';\r\nimport { FieldValidation } from '@masterteam/components/field-validation';\r\nimport { ModalService } from '@masterteam/components/modal';\r\nimport {\r\n Table,\r\n type ColumnDef,\r\n type TableAction,\r\n} from '@masterteam/components/table';\r\nimport {\r\n EntityRuntimeContextStore,\r\n isEntityListLocalDocument,\r\n isEntityListSelectionDocument,\r\n localCellsByFieldId,\r\n readEntityValueColor,\r\n resolveLocalFieldConfiguration,\r\n resolveLocalFieldLabel,\r\n resolveLocalFieldViewType,\r\n resolveLocalizedLabel,\r\n serializeEntityRawValue,\r\n visibleLocalSchemaFields,\r\n} from '@masterteam/components/entities';\r\nimport type {\r\n EntityData,\r\n EntityListLocalDocument,\r\n EntityListLocalSchema,\r\n EntityListLocalSchemaField,\r\n EntityListSelectionDocument,\r\n EntityListSelectionRecord,\r\n EntityViewType,\r\n PropertyValueComparison,\r\n} from '@masterteam/components/entities';\r\nimport type { EntityListFieldRuntimeContext } from '@masterteam/components';\r\nimport { coerceCheckboxValue, MTDateFormatPipe } from '@masterteam/components';\r\n\r\nimport {\r\n ENTITY_LIST_ADD_DIALOG_COMPONENT,\r\n ENTITY_LIST_LOCAL_ROW_DIALOG_COMPONENT,\r\n} from './entity-list-add-token';\r\nimport {\r\n buildLocalMutationContent,\r\n createLocalEditorState,\r\n diffLocalCells,\r\n newLocalUuid,\r\n orderLocalRows,\r\n type LocalEditorState,\r\n type LocalRowDraft,\r\n} from './entity-list-local-editor';\r\nimport {\r\n applySelectionPicks,\r\n buildSelectionValue,\r\n createSelectionEditorState,\r\n removeSelectedRecord,\r\n type SelectionEditorState,\r\n type SelectionPick,\r\n} from './entity-list-selection-editor';\r\nimport { EntityListSelectionDialog } from './entity-list-selection-dialog';\r\n\r\n// ============================================================================\r\n// Types — minimal subset of fetch/query Table response (mirrors\r\n// ClientListFetchQueryResponse from @masterteam/client-components).\r\n// ============================================================================\r\n\r\ninterface FetchPropertyMeta {\r\n id: number;\r\n key: string;\r\n normalizedKey: string;\r\n label: string;\r\n viewType: string;\r\n configuration: EntityData['propertyConfiguration'];\r\n source?: string;\r\n order: number;\r\n isRequired?: boolean;\r\n isCalculated?: boolean;\r\n}\r\n\r\ninterface FetchValueCell {\r\n raw?: unknown;\r\n value?: unknown;\r\n display?: string | null;\r\n /** The colour the backend resolved for this value. See `EntityData.color`. */\r\n color?: string | null;\r\n comparison?: PropertyValueComparison;\r\n}\r\n\r\ninterface FetchRecord {\r\n id: number;\r\n values: Record<string, FetchValueCell>;\r\n}\r\n\r\ninterface FetchTableColumn {\r\n key: string;\r\n label: string;\r\n viewType: string;\r\n order: number;\r\n visible: boolean;\r\n configuration: EntityData['propertyConfiguration'];\r\n}\r\n\r\n/** `POST fetch/query` — only the rows are consumed; columns come from metadata. */\r\ninterface FetchQueryResponse {\r\n records?: FetchRecord[];\r\n}\r\n\r\n/**\r\n * `GET Properties/{propertyId}/entitylist/table-metadata?levelId={levelId}` —\r\n * the runtime-scoped description of the table this field renders.\r\n *\r\n * The backend resolves the level-module configuration override, enforces module\r\n * read authorization (`403`), and returns the target module's canonical read /\r\n * write keys plus the same catalog and table-projection shapes `fetch/query`\r\n * uses. Every field is always emitted; see the \"Table Metadata Endpoint\"\r\n * section of `.github/instructions/properties/EntityList.md`.\r\n */\r\ninterface EntityListTableMetadata {\r\n propertyId: number;\r\n levelId: number;\r\n sourceType: 'Inline' | 'Module';\r\n moduleId: number;\r\n /** Effective access mode for this level — not necessarily the stored one. */\r\n access: string;\r\n snapshotMode: string;\r\n /** Canonical readable target keys. Empty when access forbids reading. */\r\n readFields: string[];\r\n /** Canonical writable target keys. Empty when access forbids writing. */\r\n writeFields: string[];\r\n catalog: { properties?: FetchPropertyMeta[] };\r\n projectionMeta: { columns?: FetchTableColumn[] };\r\n /**\r\n * `Local` rows belong to the parent record and are edited through its own\r\n * submission; `Linked` rows are records of the target module. See\r\n * `EntityListLocalDocument`.\r\n */\r\n storageMode?: 'Linked' | 'Local';\r\n /**\r\n * The *active* Local schema, hidden fields included. A loaded value carries\r\n * the schema it was projected against, which wins; this is the fallback for\r\n * a parent whose list was never saved.\r\n */\r\n localSchema?: EntityListLocalSchema | null;\r\n /** Local operation switches; the backend defaults each to `true`. */\r\n allowCreate?: boolean;\r\n allowEdit?: boolean;\r\n allowDelete?: boolean;\r\n /**\r\n * `Selected` lists hold the source records the user picked, not every\r\n * related one; see `EntityListSelectionDocument`. `Related` is the default.\r\n */\r\n recordMode?: 'Related' | 'Selected';\r\n /** How many records a Selected list may hold. */\r\n selectionMode?: 'Single' | 'Multiple';\r\n}\r\n\r\n/**\r\n * `GET entity-lists/comparison?ownerKind&ownerId&propertyId` — a saved list's\r\n * preserved values beside its sources' current ones. Plain JSON, no envelope.\r\n * Only what the viewer reads; see the Lifecycle API.\r\n */\r\ninterface EntityListComparison {\r\n /** False when no baseline was captured — not an empty saved list. */\r\n preservedAvailable: boolean;\r\n preservedAt: string | null;\r\n preserved: EntityListSelectionRecord[];\r\n /** Current values; restricted to the saved membership once one exists. */\r\n live: EntityListSelectionRecord[];\r\n unavailableIds: number[];\r\n /**\r\n * A Local list's rows at the requested revision, rendered against that\r\n * revision's schema minus fields hidden since. `preserved` / `live` are\r\n * empty for Local: its rows have no source record to compare with.\r\n */\r\n localDocument?: EntityListLocalDocument | null;\r\n}\r\n\r\n/**\r\n * One saved revision of a list — `GET entity-lists/revisions`, newest first.\r\n * `createdBy` is an actor id and is never shown; `createdByName` is the\r\n * author's *current* display name, null when it cannot be resolved, and\r\n * absent on a backend older than `f039e096`.\r\n */\r\ninterface EntityListRevision {\r\n version: number;\r\n createdAt: string;\r\n createdBy?: string | null;\r\n createdByName?: string | null;\r\n}\r\n\r\n/** A page of the revision index. Plain JSON, no envelope. */\r\ninterface EntityListRevisionPage {\r\n items: EntityListRevision[];\r\n totalCount: number;\r\n page: number;\r\n pageSize: number;\r\n}\r\n\r\n/** Revisions fetched per page of the history list (the backend allows 1–100). */\r\nconst REVISIONS_PAGE_SIZE = 25;\r\n\r\n/** The values a compared list shows: as saved, or as the sources are now. */\r\ntype EntityListComparisonView = 'preserved' | 'current';\r\n\r\n/** `snapshotMode` names `Realtime`; anything else — `Snapshot`, omitted — is preserved. */\r\nfunction isRealtimeSnapshotMode(mode: unknown): boolean {\r\n return String(mode ?? '').toLowerCase() === 'realtime' || mode === 1;\r\n}\r\n\r\n/**\r\n * Why the metadata request produced no table.\r\n *\r\n * - `forbidden` — `403`: the user may not read the target module in this level.\r\n * - `unavailable` — `400` / `404`: the property is missing, not an EntityList,\r\n * invalidly configured, or out of the supplied level's scope.\r\n * - `failed` — anything else, i.e. an actual request failure.\r\n */\r\ntype EntityListMetadataFailure = 'forbidden' | 'unavailable' | 'failed';\r\n\r\nfunction resolveMetadataFailure(status: number): EntityListMetadataFailure {\r\n if (status === 403) return 'forbidden';\r\n return status === 400 || status === 404 ? 'unavailable' : 'failed';\r\n}\r\n\r\n/** A translated text control value, `{ en, ar }`, not yet given a `display`. */\r\nfunction isTranslatedText(\r\n value: unknown,\r\n): value is { en?: string; ar?: string } {\r\n if (!value || typeof value !== 'object' || Array.isArray(value)) return false;\r\n const text = value as Record<string, unknown>;\r\n return (\r\n !('display' in text) &&\r\n (typeof text['en'] === 'string' || typeof text['ar'] === 'string')\r\n );\r\n}\r\n\r\ninterface EntityListColumnDef extends ColumnDef {\r\n key: string;\r\n label: string;\r\n type: 'entity';\r\n viewType?: string;\r\n order?: number;\r\n visible?: boolean;\r\n configuration?: EntityData['propertyConfiguration'];\r\n /** Underlying catalog property key (e.g. \"task_name\") used to look up\r\n * form values keyed by property key when a new row is added locally. */\r\n propertyKey?: string;\r\n}\r\n\r\ntype EntityListRow = Record<string, unknown | EntityData>;\r\n\r\n/**\r\n * Configured access mode. Mirrors the backend `EntityList` access matrix:\r\n * `Auto` and `ReadWrite` allow both, `Read` reads only, `Write` writes only,\r\n * `None` neither.\r\n */\r\ntype EntityListAccess = 'Auto' | 'Read' | 'Write' | 'ReadWrite' | 'None';\r\n\r\n/** One submitted row value (`values[]` entry of the stored EntityList JSON). */\r\ninterface EntityListSubmitValue {\r\n propertyKey: string;\r\n rawValue: string | null;\r\n /**\r\n * Backend-resolved display value for `rawValue`, present only on a loaded\r\n * value's rendered rows (a user object, an attachment list, a formatted\r\n * percentage). It is display-only and never submitted — see `emitValue`.\r\n */\r\n value?: unknown;\r\n}\r\n\r\n/**\r\n * A pending create/update row in the stored EntityList payload.\r\n * `entityId > 0` updates that target record; `0` creates a new one.\r\n */\r\ninterface EntityListSubmitRow {\r\n rowId: string;\r\n entityId: number;\r\n values: EntityListSubmitValue[];\r\n}\r\n\r\n/** Stored EntityList property value (round-tripped through the form). */\r\ninterface EntityListStoredValue {\r\n entityIds?: number[];\r\n createdIds?: number[];\r\n updatedIds?: number[];\r\n deletedIds?: number[];\r\n snapshot?: unknown;\r\n rows?: EntityListSubmitRow[];\r\n /**\r\n * The versioned Related protocol: the parent-owned list version the value\r\n * was loaded at, one UUID per intended change, and an opaque server token\r\n * per existing target the change edits or deletes. The form load sends\r\n * `version` and `expectedVersions`, with `mutationId` empty.\r\n */\r\n version?: number;\r\n mutationId?: string;\r\n expectedVersions?: Record<string, string>;\r\n /** Response-only current rows of the targets; never submitted. */\r\n live?: unknown;\r\n}\r\n\r\n/** Non-persisted view state kept per pending row so dialogs and table cells\r\n * can use the original (non-stringified) form values and option labels. */\r\ninterface EntityListRowDraft {\r\n values: Record<string, unknown>;\r\n display: Record<string, unknown>;\r\n}\r\n\r\nconst UNSORTABLE_ENTITY_VIEW_TYPES = new Set<EntityViewType>([\r\n 'Attachment',\r\n 'Checkbox',\r\n // A nested list has no scalar to compare — sorting by it would order rows\r\n // by an object.\r\n 'EntityList',\r\n]);\r\n\r\nconst ACCESS_ALIASES: Record<string, EntityListAccess> = {\r\n '0': 'Auto',\r\n '1': 'Read',\r\n '2': 'Write',\r\n '3': 'ReadWrite',\r\n '4': 'None',\r\n auto: 'Auto',\r\n read: 'Read',\r\n write: 'Write',\r\n readwrite: 'ReadWrite',\r\n none: 'None',\r\n};\r\n\r\n/** Internal row keys — not rendered, used to correlate rows with entities. */\r\nconst ROW_ID_KEY = '__rowId';\r\nconst ROW_ENTITY_ID_KEY = '__entityId';\r\nconst ROW_VALUES_KEY = '__values';\r\nconst ROW_PREFILL_KEY = '__prefill';\r\n\r\n/**\r\n * View types whose form control binds the resolved object rather than the\r\n * stored scalar, so the edit dialog has to be pre-filled from the rendered\r\n * `value` of the cell and not its `raw`. Mirrors `resolveLoadedFieldValue`\r\n * in `@masterteam/forms/client-form`, which makes the same exception for\r\n * these two at the top level of a form — a user picker renders from the\r\n * object and would otherwise display a bare id.\r\n */\r\nconst OBJECT_VALUED_VIEW_TYPES = new Set(['User', 'MultiUser']);\r\n\r\n/**\r\n * The staged operation a rendered row represents while the field overlays an\r\n * unapplied submission. A row the request leaves alone carries `null`.\r\n */\r\ntype EntityListRowChange = 'added' | 'edited' | 'deleted';\r\n\r\n/** Internal row key carrying the staged operation, for export and tests. */\r\nconst ROW_CHANGE_KEY = '__change';\r\n\r\n/** Column key of the synthetic flag column — never a target property key. */\r\nconst ROW_CHANGE_COLUMN_KEY = '__changeState';\r\n\r\n/** Internal row key marking a Local row added in this session. */\r\nconst ROW_LOCAL_CREATED_KEY = '__localCreated';\r\n\r\n/**\r\n * The editing state behind each Local value this field emitted, keyed by that\r\n * value.\r\n *\r\n * A mutation carries only what changed, so it cannot rebuild the table on its\r\n * own — and the field is not always the one that emitted it: `mt-dynamic-form`\r\n * destroys the sections outside the current wizard step, and the field that\r\n * comes back is a new instance handed the form's current value. Keeping the\r\n * state out of the payload leaves the submitted JSON exactly the contract,\r\n * and a `WeakMap` lets it go with the value.\r\n */\r\nconst LOCAL_EDITOR_STATES = new WeakMap<object, LocalEditorState>();\r\n\r\n/**\r\n * The editing state behind each Selected value this field emitted, for the\r\n * same reason as `LOCAL_EDITOR_STATES`: a mutation is only ids, and the names\r\n * of records picked in this session live nowhere else.\r\n */\r\nconst SELECTION_EDITOR_STATES = new WeakMap<object, SelectionEditorState>();\r\n\r\n/**\r\n * Badge colour per staged operation, as a hex: `mt-entity-status` derives its\r\n * own 12%-alpha background by slicing the value's `color`, so a Tailwind class\r\n * would render an uncoloured badge.\r\n */\r\nconst ROW_CHANGE_COLORS: Record<EntityListRowChange, string> = {\r\n added: '#16a34a',\r\n edited: '#d97706',\r\n deleted: '#dc2626',\r\n};\r\n\r\n@Component({\r\n selector: 'mt-entity-list-field',\r\n standalone: true,\r\n imports: [\r\n CommonModule,\r\n FieldValidation,\r\n Skeleton,\r\n Message,\r\n Table,\r\n Button,\r\n Tabs,\r\n TranslocoPipe,\r\n MTDateFormatPipe,\r\n ],\r\n templateUrl: './entity-list-field.html',\r\n styleUrls: ['./entity-list-field.scss'],\r\n changeDetection: ChangeDetectionStrategy.OnPush,\r\n host: { class: 'grid gap-1' },\r\n // Shuts the ambient runtime context off for everything this field renders.\r\n // Its own table cells go through `mt-entity-preview`, so a nested EntityList\r\n // column would otherwise see the host's context and render *another* fetched\r\n // table inside a cell of this one. A fresh store holds `null`, which is\r\n // exactly the \"no context, use the drawer\" state.\r\n providers: [EntityRuntimeContextStore],\r\n})\r\nexport class EntityListField implements ControlValueAccessor {\r\n // Inputs\r\n readonly label = input<string>('');\r\n readonly readonly = input<boolean>(false);\r\n readonly required = input<boolean>(false);\r\n /**\r\n * EntityList property id. **Required** — with the owning level it addresses\r\n * the table-metadata endpoint, which is the only source of this field's\r\n * effective configuration.\r\n */\r\n readonly propertyId = input<number | null>(null);\r\n /**\r\n * EntityList property key. A Selected list's picker loads its candidates\r\n * from `forms/options/{propertyKey}`; no other mode reads it.\r\n */\r\n readonly propertyKey = input<string>('');\r\n /**\r\n * Stored property configuration (sourceType, moduleId, access, readFields …).\r\n *\r\n * Kept for hosts that still bind it, but **not read**: the stored value is\r\n * the un-overridden one, and the backend resolves the level-module override\r\n * before answering the metadata request. Everything this field gates on comes\r\n * from that response.\r\n */\r\n readonly configuration = input<Record<string, unknown> | null>(null);\r\n /** Runtime ids needed to call the read endpoint. */\r\n readonly runtimeContext = input<EntityListFieldRuntimeContext | null>(null);\r\n /**\r\n * The bound value is an unapplied process submission — an Approval step's\r\n * frozen create/update/delete operations — rather than a persisted record\r\n * value. Its `rows[]` and `deletedIds` are pending intent the approver has\r\n * to see staged over the loaded records, not markers of writes the backend\r\n * already applied. See `.github/instructions/properties/EntityList.md`.\r\n */\r\n readonly pendingSubmission = input<boolean>(false);\r\n /**\r\n * Full lookup catalog of the host form, forwarded to the add/edit dialog's\r\n * nested form. `process-form-load` returns only the lookup *id* per field,\r\n * so without this the target module's Lookup fields render \"no options\".\r\n */\r\n readonly lookups = input<unknown[]>([]);\r\n /** Optional HttpContext (kept for back-compat). */\r\n readonly context = input<HttpContext | undefined>(undefined);\r\n /**\r\n * The stored value, for hosts that render this field **outside a form** —\r\n * the read-only `mt-entity-list-preview` creates it through\r\n * `NgComponentOutlet`, which can set inputs but cannot drive a\r\n * `ControlValueAccessor`.\r\n *\r\n * Ignored once a form control is attached, so it can never race\r\n * `writeValue`. It matters for a `Write`-access list: that field may not read\r\n * the target module, so its stored `rows[]` are the only thing it has to\r\n * show.\r\n */\r\n readonly initialValue = input<EntityListStoredValue | string | null>(null);\r\n\r\n // CVA state — pass-through value (EntityList stored JSON shape).\r\n private readonly storedValue = signal<EntityListStoredValue | null>(null);\r\n\r\n /** Runtime-scoped metadata; null until the endpoint answers. */\r\n private readonly metadata = signal<EntityListTableMetadata | null>(null);\r\n protected readonly metadataFailure = signal<EntityListMetadataFailure | null>(\r\n null,\r\n );\r\n\r\n // Loaded table state.\r\n protected readonly columns = signal<EntityListColumnDef[]>([]);\r\n /** Rows loaded from the backend (existing target records). */\r\n protected readonly rows = signal<EntityListRow[]>([]);\r\n protected readonly loading = signal<boolean>(false);\r\n protected readonly errorMessage = signal<string | null>(null);\r\n\r\n protected readonly disabled = signal<boolean>(false);\r\n protected requiredValidator = Validators.required;\r\n public ngControl: NgControl | null = null;\r\n\r\n protected readonly levelId = computed<number | string | null>(() => {\r\n const raw = this.runtimeContext()?.levelId ?? null;\r\n return raw == null || raw === '' ? null : raw;\r\n });\r\n\r\n protected readonly levelDataId = computed<number | string | null>(() => {\r\n const raw = this.runtimeContext()?.levelDataId ?? null;\r\n return raw == null || raw === '' ? null : raw;\r\n });\r\n\r\n /** EntityList property id as a number; `0` when the host bound none. */\r\n protected readonly propertyKeyId = computed<number>(() =>\r\n Number(this.propertyId() ?? 0),\r\n );\r\n\r\n /** Target module id, as resolved for this level. */\r\n protected readonly moduleId = computed<number | null>(\r\n () => this.metadata()?.moduleId ?? null,\r\n );\r\n\r\n /** Canonical readable target keys — the columns this field renders. */\r\n protected readonly readFields = computed<string[]>(\r\n () => this.metadata()?.readFields ?? [],\r\n );\r\n\r\n /**\r\n * Keys the row projection asks for: readable **and** writable.\r\n *\r\n * A writable key that is not readable has no column, but the edit dialog\r\n * still renders it — and several are `isRequired` on the target module (the\r\n * schedule module's `task_planned_finish` is). Projecting only `readFields`\r\n * left those controls empty, so the form was invalid until the user retyped a\r\n * value that already existed, and a different value silently overwrote the\r\n * stored one. Read order first, so the request body stays stable.\r\n */\r\n protected readonly projectedKeys = computed<string[]>(() => [\r\n ...new Set([...this.readFields(), ...this.writeFields()]),\r\n ]);\r\n\r\n /** Effective `access` for this level, as resolved by the backend. */\r\n protected readonly accessMode = computed<EntityListAccess>(() => {\r\n const raw = this.metadata()?.access;\r\n if (raw == null || raw === '') return 'None';\r\n return ACCESS_ALIASES[String(raw).trim().toLowerCase()] ?? 'None';\r\n });\r\n\r\n /**\r\n * The table is backed by target module records. Inline lists resolve their\r\n * rows from the stored value and have no module form to write through, so\r\n * this field does not render them.\r\n */\r\n protected readonly moduleBacked = computed<boolean>(() => {\r\n const metadata = this.metadata();\r\n return metadata?.sourceType === 'Module' && Number(metadata.moduleId) > 0;\r\n });\r\n\r\n protected readonly canRead = computed<boolean>(() => {\r\n const access = this.accessMode();\r\n return access === 'Auto' || access === 'Read' || access === 'ReadWrite';\r\n });\r\n\r\n /**\r\n * Whether the field has rows it may display. Write-only access cannot read\r\n * target module records, but its stored `rows[]` are the value users entered\r\n * and must remain visible when the host renders the field as read-only.\r\n */\r\n protected readonly canDisplayRows = computed<boolean>(\r\n () => this.canRead() || this.accessMode() === 'Write',\r\n );\r\n\r\n /** Access allows module-backed create/update/delete. */\r\n private readonly writeAllowed = computed<boolean>(() => {\r\n const access = this.accessMode();\r\n return access === 'Auto' || access === 'Write' || access === 'ReadWrite';\r\n });\r\n\r\n /** Write UI is rendered only when access allows it and the field is editable. */\r\n protected readonly canWrite = computed<boolean>(\r\n () => this.writeAllowed() && this.moduleBacked() && !this.readonly(),\r\n );\r\n\r\n /**\r\n * Canonical writable target keys. They are what the add/edit dialog renders\r\n * and what a submitted row is restricted to — canonical, so a configuration\r\n * that listed `normalizedKey` aliases still matches the target module's form\r\n * value keys.\r\n */\r\n protected readonly writeFields = computed<string[]>(\r\n () => this.metadata()?.writeFields ?? [],\r\n );\r\n\r\n /**\r\n * Write fields a new row must fill: the target's required, non-calculated\r\n * properties. The backend rejects a create row without any of them\r\n * (`entity_list.required_field_missing`), while the target module's form —\r\n * which the add dialog renders — may mark fewer required.\r\n */\r\n private readonly createRequiredFields = computed<string[]>(() => {\r\n const properties = this.propertyByKey();\r\n return this.writeFields().filter((key) => {\r\n const property = properties.get(key);\r\n return !!property?.isRequired && !property.isCalculated;\r\n });\r\n });\r\n\r\n /**\r\n * Pending create/update rows, in the exact shape persisted by the backend\r\n * (`rows[]` of the stored EntityList JSON). Rows with `entityId > 0` are\r\n * partial updates of existing records; `entityId = 0` rows are creates.\r\n */\r\n private readonly pendingRows = signal<EntityListSubmitRow[]>([]);\r\n /** Existing entity ids the user removed in this session. */\r\n private readonly stagedDeletedIds = signal<number[]>([]);\r\n /** `deletedIds` carried by the loaded value, before they mean anything. */\r\n private readonly loadedDeletedIds = signal<number[]>([]);\r\n /**\r\n * Delete intents that apply to the table right now. On a persisted value the\r\n * loaded `deletedIds` are historical operation markers — the records are\r\n * already gone — so only this session's removals count. On an unapplied\r\n * submission they are deletes awaiting approval and must be staged too.\r\n */\r\n private readonly deletedIds = computed<number[]>(() => {\r\n const staged = this.stagedDeletedIds();\r\n if (!this.pendingSubmission()) return staged;\r\n return [...new Set([...this.loadedDeletedIds(), ...staged])];\r\n });\r\n /** rowId → original form values / option labels (view state only). */\r\n private readonly rowDrafts = signal<Record<string, EntityListRowDraft>>({});\r\n private localRowSeq = 0;\r\n /** Serialized copy of the last value we emitted, to ignore CVA echoes. */\r\n private lastEmittedJson: string | null = null;\r\n\r\n /** Server rows indexed by entity id, for merging pending updates. */\r\n private readonly rowsByEntityId = computed<Map<number, EntityListRow>>(() => {\r\n const map = new Map<number, EntityListRow>();\r\n for (const row of this.rows()) {\r\n const entityId = Number(row[ROW_ENTITY_ID_KEY]);\r\n if (entityId > 0) map.set(entityId, row);\r\n }\r\n return map;\r\n });\r\n\r\n /** Locally created rows (not yet persisted). */\r\n private readonly createdRows = computed<EntityListRow[]>(() => {\r\n const drafts = this.rowDrafts();\r\n return this.pendingRows()\r\n .filter((row) => !(row.entityId > 0))\r\n .map((row) => {\r\n const draft = drafts[row.rowId];\r\n return this.buildRow(\r\n row.rowId,\r\n row.rowId,\r\n 0,\r\n draft?.values ?? this.toValueMap(row.values),\r\n draft?.display ?? this.toDisplayMap(row.values),\r\n );\r\n });\r\n });\r\n\r\n /** Pending edits of existing rows, keyed by entity id. */\r\n private readonly editedRowsByEntityId = computed<Map<number, EntityListRow>>(\r\n () => {\r\n const drafts = this.rowDrafts();\r\n const serverRows = this.rowsByEntityId();\r\n const map = new Map<number, EntityListRow>();\r\n for (const row of this.pendingRows()) {\r\n if (!(row.entityId > 0)) continue;\r\n const base = serverRows.get(row.entityId);\r\n const draft = drafts[row.rowId];\r\n // A pending update only carries the keys the user changed.\r\n const changed = draft?.values ?? this.toValueMap(row.values);\r\n const display = draft?.display ?? this.toDisplayMap(row.values);\r\n\r\n if (!base) {\r\n map.set(\r\n row.entityId,\r\n this.buildRow(\r\n row.entityId,\r\n row.rowId,\r\n row.entityId,\r\n changed,\r\n display,\r\n ),\r\n );\r\n continue;\r\n }\r\n\r\n // Keep the backend-rendered cells for untouched columns so resolved\r\n // labels (users, lookups, statuses) are not replaced by raw ids.\r\n const baseValues =\r\n (base[ROW_VALUES_KEY] as Record<string, unknown> | undefined) ?? {};\r\n const basePrefill =\r\n (base[ROW_PREFILL_KEY] as Record<string, unknown> | undefined) ??\r\n baseValues;\r\n const next: EntityListRow = {\r\n ...base,\r\n [ROW_ID_KEY]: row.rowId,\r\n [ROW_VALUES_KEY]: { ...baseValues, ...changed },\r\n // Re-opening the dialog must still show what the controls bind, so\r\n // the resolved values survive a pending edit.\r\n [ROW_PREFILL_KEY]: { ...basePrefill, ...changed },\r\n };\r\n for (const column of this.columns()) {\r\n const key = column.propertyKey ?? column.key;\r\n if (!(key in changed)) continue;\r\n next[column.key] = this.buildCell(column, changed[key], display[key]);\r\n }\r\n map.set(row.entityId, next);\r\n }\r\n return map;\r\n },\r\n );\r\n\r\n /**\r\n * Whether the table stages pending operations over the loaded records.\r\n *\r\n * Editable write modes stage the user's own edits, and a read-only\r\n * Write-only field has nothing but its stored rows to show. A pending\r\n * submission stages them too even though it is read-only and `ReadWrite`:\r\n * an approver reviewing a request has to see what it *will* do to the target\r\n * module, not the records as they stand.\r\n */\r\n private readonly showsPendingOperations = computed<boolean>(\r\n () =>\r\n this.canWrite() ||\r\n this.accessMode() === 'Write' ||\r\n this.pendingSubmission(),\r\n );\r\n\r\n /**\r\n * Whether each row is flagged with the operation the request performs on it,\r\n * and a removed row stays on screen instead of disappearing.\r\n *\r\n * Only while reviewing an unapplied submission. In an editable field the user\r\n * just pressed delete, so the row leaving *is* the feedback — putting it back\r\n * with a badge and no way to undo reads as a delete that failed.\r\n *\r\n * And only for a list that can write: a `Read` list never stages an\r\n * operation (the backend refuses one with `operation_denied`), so its\r\n * approver saw a Change column that could only ever be empty.\r\n */\r\n protected readonly showsChangeFlags = computed<boolean>(\r\n () => this.pendingSubmission() && this.writeAllowed(),\r\n );\r\n\r\n /**\r\n * Rows rendered in the table: existing rows merged with pending edits, and\r\n * created rows appended.\r\n *\r\n * While reviewing a submission the removed rows stay too, flagged `deleted`,\r\n * and every row carries the operation it represents. An approver has to see\r\n * the deletes they are approving — hiding them understated what pressing\r\n * Approve would do. Everywhere else a removed row is simply gone.\r\n */\r\n protected readonly displayRows = computed<EntityListRow[]>(() => {\r\n if (!this.showsPendingOperations()) return this.rows();\r\n const deleted = new Set(this.deletedIds());\r\n const edited = this.editedRowsByEntityId();\r\n const flagged = this.showsChangeFlags();\r\n\r\n const existing: EntityListRow[] = [];\r\n for (const row of this.rows()) {\r\n const entityId = Number(row[ROW_ENTITY_ID_KEY]);\r\n if (deleted.has(entityId)) {\r\n if (flagged) existing.push(this.withRowChange(row, 'deleted'));\r\n continue;\r\n }\r\n const pending = edited.get(entityId);\r\n existing.push(\r\n pending\r\n ? this.withRowChange(pending, 'edited')\r\n : this.withRowChange(row, null),\r\n );\r\n }\r\n\r\n const created = this.createdRows().map((row) =>\r\n this.withRowChange(row, 'added'),\r\n );\r\n\r\n return [...existing, ...this.orphanDeletedRows(), ...created];\r\n });\r\n\r\n protected readonly hasRows = computed<boolean>(\r\n () => this.displayRows().length > 0,\r\n );\r\n\r\n /**\r\n * Tag a rendered row with its staged operation and the cell that displays it.\r\n * A no-op outside a reviewed submission, so an editable table keeps the rows\r\n * exactly as the projection built them.\r\n */\r\n private withRowChange(\r\n row: EntityListRow,\r\n change: EntityListRowChange | null,\r\n ): EntityListRow {\r\n if (!this.showsChangeFlags()) return row;\r\n return {\r\n ...row,\r\n [ROW_CHANGE_KEY]: change,\r\n [ROW_CHANGE_COLUMN_KEY]: change ? this.buildRowChangeCell(change) : null,\r\n };\r\n }\r\n\r\n /**\r\n * Deleted ids with no loaded record behind them — already applied elsewhere,\r\n * or outside the level-data scope this table queries. They render as an empty\r\n * flagged row rather than vanishing: a review screen that silently drops a\r\n * delete is the bug this whole overlay exists to avoid, and an id the table\r\n * cannot describe is still a deletion the approver is signing off on.\r\n */\r\n private orphanDeletedRows(): EntityListRow[] {\r\n if (!this.showsChangeFlags()) return [];\r\n const loaded = this.rowsByEntityId();\r\n return this.deletedIds()\r\n .filter((entityId) => !loaded.has(entityId))\r\n .map((entityId) => ({\r\n Id: entityId,\r\n [ROW_ID_KEY]: `entity-${entityId}`,\r\n [ROW_ENTITY_ID_KEY]: entityId,\r\n [ROW_VALUES_KEY]: {},\r\n [ROW_PREFILL_KEY]: {},\r\n [ROW_CHANGE_KEY]: 'deleted',\r\n [ROW_CHANGE_COLUMN_KEY]: this.buildRowChangeCell('deleted'),\r\n }));\r\n }\r\n\r\n /**\r\n * The flag cell, built as the `Status` entity `mt-table` already renders — a\r\n * `rounded-md` badge tinted from the value's own colour. Assembled here\r\n * rather than as a bespoke cell template so the column looks like every other\r\n * cell in the table and needs no host wiring.\r\n */\r\n private buildRowChangeCell(change: EntityListRowChange): EntityData {\r\n return {\r\n key: ROW_CHANGE_COLUMN_KEY,\r\n name: this.rowChangeLabels().column,\r\n viewType: 'Status',\r\n value: {\r\n key: change,\r\n display: this.rowChangeLabels()[change],\r\n color: ROW_CHANGE_COLORS[change],\r\n },\r\n };\r\n }\r\n\r\n /**\r\n * Badge labels, re-resolved when the active language changes. `translate()`\r\n * is a plain call, so without a language signal to depend on the computed\r\n * would keep whichever language it first ran in.\r\n */\r\n private readonly rowChangeLabels = computed<\r\n Record<EntityListRowChange | 'column', string>\r\n >(() => {\r\n const lang = this.lang();\r\n const translate = (key: string) =>\r\n this.transloco.translate(`components.entityListField.${key}`, {}, lang);\r\n return {\r\n column: translate('changeColumn'),\r\n added: translate('changeAdded'),\r\n edited: translate('changeEdited'),\r\n deleted: translate('changeDeleted'),\r\n };\r\n });\r\n\r\n /**\r\n * Columns bound to the table: the data columns, followed by the flag column\r\n * while reviewing a submission.\r\n *\r\n * Last, not first: the leading column is what identifies a row, and pushing\r\n * the record's own name aside for a badge makes the table harder to read for\r\n * the rows nothing happened to — which is most of them.\r\n *\r\n * Deliberately separate from `columns()`, which is the metadata projection\r\n * the row builders iterate — a synthetic column in there would be looked up\r\n * against the record values and add an empty cell to every row.\r\n */\r\n protected readonly tableColumns = computed<EntityListColumnDef[]>(() => {\r\n const columns = this.columns();\r\n if (!this.showsChangeFlags()) return columns;\r\n return [\r\n ...columns,\r\n {\r\n key: ROW_CHANGE_COLUMN_KEY,\r\n label: this.rowChangeLabels().column,\r\n type: 'entity' as const,\r\n sortable: false,\r\n filterable: false,\r\n shrink: true,\r\n exportValue: (row: EntityListRow) =>\r\n (row[ROW_CHANGE_KEY] as string | null) ?? '',\r\n },\r\n ];\r\n });\r\n\r\n // ============================================================================\r\n // Local storage (`storageMode: \"Local\"`) — rows owned by the parent record\r\n // ============================================================================\r\n\r\n /** Loaded document plus this session's edits; see `LocalEditorState`. */\r\n private readonly localState = signal<LocalEditorState>(\r\n createLocalEditorState(null),\r\n );\r\n /** The bound value was a Local document, whatever the metadata says yet. */\r\n private readonly localValueSeen = signal<boolean>(false);\r\n /** The last Local value emitted, so its echo does not reset the edits. */\r\n private lastLocalEmit: unknown = null;\r\n\r\n /**\r\n * Rows live inside the parent record: no target records, no `fetch/query`,\r\n * and the value is a document of its own rather than operation markers.\r\n * Known from the metadata, or earlier from the value itself.\r\n */\r\n protected readonly localMode = computed<boolean>(\r\n () => this.metadata()?.storageMode === 'Local' || this.localValueSeen(),\r\n );\r\n\r\n /**\r\n * The schema the table is built from. A loaded value's own schema wins: it\r\n * is the one its rows were projected against, and pending or approved\r\n * evidence stays pinned to the schema it was submitted with. The metadata's\r\n * active schema is the fallback for a list that has never been saved.\r\n */\r\n private readonly localSchema = computed<EntityListLocalSchema | null>(\r\n () =>\r\n this.localState().base?.schema ?? this.metadata()?.localSchema ?? null,\r\n );\r\n\r\n protected readonly localFields = computed(() =>\r\n visibleLocalSchemaFields(this.localSchema()),\r\n );\r\n\r\n /**\r\n * Render the Local table once the metadata answered: it is the access\r\n * boundary, and it carries the operation switches the table obeys.\r\n */\r\n protected readonly localReady = computed<boolean>(\r\n () => this.localMode() && !!this.metadata(),\r\n );\r\n\r\n /**\r\n * Writes are staged into the parent's submission, never sent on their own.\r\n *\r\n * Whether the host lets this field be edited is the form's call —\r\n * `readonly` — as it is for a linked list; `pendingSubmission` is not one.\r\n * A loaded request is not always a review: a returned request is loaded to\r\n * be corrected and resubmitted, and the backend projects the active schema\r\n * for exactly that.\r\n */\r\n private readonly localWritable = computed<boolean>(\r\n () =>\r\n !!this.localDialogComponent &&\r\n !!this.metadata() &&\r\n this.writeAllowed() &&\r\n !this.readonly() &&\r\n !this.disabled() &&\r\n this.localFields().length > 0,\r\n );\r\n\r\n protected readonly localCanCreate = computed<boolean>(\r\n () => this.localWritable() && this.metadata()?.allowCreate !== false,\r\n );\r\n private readonly localCanEdit = computed<boolean>(\r\n () => this.localWritable() && this.metadata()?.allowEdit !== false,\r\n );\r\n private readonly localCanDelete = computed<boolean>(\r\n () => this.localWritable() && this.metadata()?.allowDelete !== false,\r\n );\r\n /** Reordering rewrites loaded rows, so it is an edit. */\r\n protected readonly localCanReorder = computed<boolean>(\r\n () => this.localCanEdit() && this.localTableRows().length > 1,\r\n );\r\n\r\n /**\r\n * One column per visible schema field, keyed by the field's local id — the\r\n * id cells are keyed by. Sorting is off while rows can be dragged: a sorted\r\n * table would show an order that is not the one being saved.\r\n */\r\n protected readonly localColumns = computed<EntityListColumnDef[]>(() =>\r\n this.buildLocalColumns(this.localFields(), !this.localCanEdit()),\r\n );\r\n\r\n /**\r\n * Rows as rendered: loaded rows with this session's edits over them, then\r\n * new rows, in the order they would be saved. A loaded cell renders from the\r\n * backend's resolved `value`; a cell the user set renders from the dialog's\r\n * control value and option label, like a locally added linked row.\r\n */\r\n protected readonly localTableRows = computed<EntityListRow[]>(() =>\r\n this.buildLocalRows(\r\n this.localState(),\r\n this.localFields(),\r\n this.localColumns(),\r\n ),\r\n );\r\n\r\n private buildLocalColumns(\r\n fields: EntityListLocalSchemaField[],\r\n sortable: boolean,\r\n ): EntityListColumnDef[] {\r\n const lang = this.lang();\r\n return fields.map((field, index) => {\r\n const viewType = resolveLocalFieldViewType(field);\r\n return {\r\n key: field.id as string,\r\n label: resolveLocalFieldLabel(field, lang),\r\n type: 'entity' as const,\r\n sortable:\r\n sortable &&\r\n !UNSORTABLE_ENTITY_VIEW_TYPES.has(viewType as EntityViewType),\r\n viewType,\r\n order: index,\r\n visible: true,\r\n configuration: null,\r\n };\r\n });\r\n }\r\n\r\n private buildLocalRows(\r\n state: LocalEditorState,\r\n fields: EntityListLocalSchemaField[],\r\n localColumns: EntityListColumnDef[],\r\n ): EntityListRow[] {\r\n const columns = new Map(localColumns.map((column) => [column.key, column]));\r\n\r\n return orderLocalRows(state).map((entry) => {\r\n const cells = entry.existing\r\n ? localCellsByFieldId(entry.existing)\r\n : new Map();\r\n const draft: LocalRowDraft | undefined =\r\n entry.created?.draft ?? state.edited[entry.rowId];\r\n const row: EntityListRow = {\r\n Id: entry.rowId,\r\n [ROW_ID_KEY]: entry.rowId,\r\n [ROW_LOCAL_CREATED_KEY]: !!entry.created,\r\n };\r\n\r\n for (const field of fields) {\r\n const fieldId = field.id as string;\r\n const column = columns.get(fieldId);\r\n if (!column) continue;\r\n const configuration = resolveLocalFieldConfiguration(field);\r\n row[fieldId] =\r\n draft && (entry.created || fieldId in draft.cells)\r\n ? this.buildLocalDraftCell(column, draft, configuration)\r\n : this.buildLocalLoadedCell(\r\n column,\r\n cells.get(fieldId),\r\n configuration,\r\n );\r\n }\r\n return row;\r\n });\r\n }\r\n\r\n /**\r\n * Edit and delete per row. A row added in this session is still part of the\r\n * create — changing or dropping it undoes nothing stored — so it follows\r\n * `allowCreate`; a loaded row follows `allowEdit` / `allowDelete`.\r\n */\r\n protected readonly localRowActions = computed<TableAction[]>(() => {\r\n this.lang();\r\n const canCreate = this.localCanCreate();\r\n const canEdit = this.localCanEdit();\r\n const canDelete = this.localCanDelete();\r\n const isCreated = (row: EntityListRow) =>\r\n row[ROW_LOCAL_CREATED_KEY] === true;\r\n const actions: TableAction[] = [];\r\n\r\n if (canCreate || canEdit) {\r\n actions.push({\r\n icon: 'custom.pencil' as const,\r\n tooltip: this.transloco.translate('components.entityListField.edit'),\r\n hidden: (row: EntityListRow) =>\r\n isCreated(row) ? !canCreate : !canEdit,\r\n action: (row: EntityListRow) => this.openLocalRowDialog(row),\r\n });\r\n }\r\n if (canCreate || canDelete) {\r\n actions.push({\r\n icon: 'general.trash-01' as const,\r\n tooltip: this.transloco.translate('components.entityListField.delete'),\r\n color: 'danger' as const,\r\n confirmation: {\r\n type: 'popup' as const,\r\n confirmationType: 'delete' as const,\r\n },\r\n hidden: (row: EntityListRow) =>\r\n isCreated(row) ? !canCreate : !canDelete,\r\n action: (row: EntityListRow) => this.deleteLocalRow(row),\r\n });\r\n }\r\n return actions;\r\n });\r\n\r\n // ============================================================================\r\n // Selected records (`recordMode: \"Selected\"`) — source records the user picked\r\n // ============================================================================\r\n\r\n /** Loaded selection plus this session's picks; see `SelectionEditorState`. */\r\n private readonly selectionState = signal<SelectionEditorState>(\r\n createSelectionEditorState(null),\r\n );\r\n /** The bound value was a Selected document, whatever the metadata says yet. */\r\n private readonly selectionValueSeen = signal<boolean>(false);\r\n /** The last Selected value emitted, so its echo does not reset the picks. */\r\n private lastSelectionEmit: unknown = null;\r\n\r\n /**\r\n * The list holds only the records the user picked. It never falls back to\r\n * every related record: an empty selection is empty. Known from the\r\n * metadata, or earlier from the value itself.\r\n */\r\n protected readonly selectionMode = computed<boolean>(\r\n () =>\r\n this.metadata()?.recordMode === 'Selected' || this.selectionValueSeen(),\r\n );\r\n\r\n /** Render once the metadata answered: it is the access boundary. */\r\n protected readonly selectionReady = computed<boolean>(\r\n () => this.selectionMode() && !!this.metadata(),\r\n );\r\n\r\n private readonly selectionMultiple = computed<boolean>(\r\n () => this.metadata()?.selectionMode !== 'Single',\r\n );\r\n\r\n /**\r\n * The picker's `contextKey`: the context of the form that owns the property\r\n * — never the source module, which the backend resolves from the property's\r\n * own configuration.\r\n */\r\n private readonly selectionContextKey = computed<string | null>(() => {\r\n const levelId = this.levelId();\r\n if (levelId == null) return null;\r\n const moduleId = this.runtimeContext()?.moduleId;\r\n return moduleId == null || moduleId === ''\r\n ? `Level:${levelId}`\r\n : `Level:${levelId}/Module:${moduleId}`;\r\n });\r\n\r\n /**\r\n * Whether the user may change which records are selected. That is the\r\n * form's call — `readonly`, from the field's `isWrite` — and not the\r\n * metadata's `access` or its `allow*` switches: those describe the source\r\n * records, which selecting never writes.\r\n */\r\n protected readonly selectionWritable = computed<boolean>(\r\n () =>\r\n this.selectionReady() &&\r\n !this.readonly() &&\r\n !this.disabled() &&\r\n !!this.propertyKey() &&\r\n !!this.selectionContextKey(),\r\n );\r\n\r\n /**\r\n * The selected records as table rows, in selection order.\r\n *\r\n * A saved record renders from the backend's `records`, cell by cell against\r\n * the metadata columns — the same cells a related list shows. A record\r\n * picked in this session renders the display values its option carried\r\n * (`metadataJson`) the same way; an older backend sends none, and the row\r\n * then shows its name and \"Shown after saving\". A record in `unavailableIds` was\r\n * deleted or is no longer visible: the backend keeps it selected but\r\n * withholds its values, and the row says so, so the user can remove it.\r\n */\r\n protected readonly selectionRows = computed<EntityListRow[]>(() => {\r\n const state = this.selectionState();\r\n const columns = this.columns();\r\n const properties = this.propertyByKey();\r\n const records = new Map(\r\n (state.base?.records ?? []).map((record) => [record.entityId, record]),\r\n );\r\n const unavailable = new Set(state.base?.unavailableIds ?? []);\r\n\r\n return state.ids.map((id) => {\r\n // A loaded record renders the backend's values for it; a record picked\r\n // in this session renders the picker's display values, when sent.\r\n const record = records.get(id) ?? state.records[id];\r\n if (record) return this.recordRow(record, columns, properties);\r\n\r\n const row: EntityListRow = {\r\n Id: id,\r\n [ROW_ID_KEY]: `entity-${id}`,\r\n [ROW_ENTITY_ID_KEY]: id,\r\n };\r\n const isUnavailable = unavailable.has(id);\r\n const label = isUnavailable\r\n ? this.transloco.translate(\r\n 'components.entityListField.unavailableRecord',\r\n { id },\r\n this.lang(),\r\n )\r\n : state.names[id] || `#${id}`;\r\n // The picker returns only names; the other values are rendered once the\r\n // parent is saved. Say so rather than show a known value as empty.\r\n const pending = isUnavailable\r\n ? ''\r\n : this.transloco.translate(\r\n 'components.entityListField.shownAfterSave',\r\n {},\r\n this.lang(),\r\n );\r\n columns.forEach((column, index) => {\r\n row[column.key] = {\r\n key: column.key,\r\n name: column.label,\r\n viewType: 'Text',\r\n value: index === 0 ? label : pending,\r\n } satisfies EntityData;\r\n });\r\n return row;\r\n });\r\n });\r\n\r\n /**\r\n * One table row from a rendered record — `{ entityId, values }` with each\r\n * value's `rawValue` and rendered `value` — cell by cell against the\r\n * metadata columns, the same cells a related list shows. Selected `records`\r\n * and the comparison's preserved / live rows all have this shape.\r\n */\r\n private recordRow(\r\n record: EntityListSelectionRecord,\r\n columns: EntityListColumnDef[],\r\n properties: Map<string, FetchPropertyMeta>,\r\n ): EntityListRow {\r\n const id = record.entityId;\r\n const row: EntityListRow = {\r\n Id: id,\r\n [ROW_ID_KEY]: `entity-${id}`,\r\n [ROW_ENTITY_ID_KEY]: id,\r\n };\r\n const values = new Map(\r\n (record.values ?? []).map((item) => [item.propertyKey, item]),\r\n );\r\n for (const column of columns) {\r\n const propertyKey = column.propertyKey ?? column.key;\r\n const item = values.get(propertyKey) ?? values.get(column.key);\r\n row[column.key] = this.toEntityData(\r\n column,\r\n item ? { raw: item.rawValue, value: item.value } : undefined,\r\n properties.get(propertyKey),\r\n id,\r\n );\r\n }\r\n return row;\r\n }\r\n\r\n // ============================================================================\r\n // Saved Related list — preserved and current values (`entity-lists/comparison`)\r\n // ============================================================================\r\n\r\n /** The comparison response, once loaded. */\r\n private readonly comparison = signal<EntityListComparison | null>(null);\r\n\r\n /**\r\n * The record that owns the list, when the host named it (a table cell's\r\n * drawer). Only a read-only list reads its comparison: an editable one\r\n * edits the source records it queries.\r\n */\r\n private readonly comparisonOwner = computed<{\r\n ownerKind: 'ModuleData' | 'LevelData';\r\n ownerId: number;\r\n } | null>(() => {\r\n const context = this.runtimeContext();\r\n const ownerId = Number(context?.ownerId);\r\n // An approver reviews staged operations over the live records, never a\r\n // comparison — see `pendingSubmission`.\r\n if (\r\n !this.readonly() ||\r\n this.pendingSubmission() ||\r\n !context?.ownerKind ||\r\n !(ownerId > 0)\r\n ) {\r\n return null;\r\n }\r\n return { ownerKind: context.ownerKind, ownerId };\r\n });\r\n\r\n /**\r\n * A saved Related list viewed from outside its form: the values preserved\r\n * when it was saved beside the source records' current ones. Local and\r\n * Selected lists hold their own rows and never compare.\r\n */\r\n protected readonly comparisonMode = computed<boolean>(\r\n () =>\r\n !!this.comparisonOwner() &&\r\n !this.comparisonUnsupported() &&\r\n !!this.metadata() &&\r\n !this.localMode() &&\r\n !this.selectionMode() &&\r\n this.moduleBacked(),\r\n );\r\n\r\n protected readonly comparisonReady = computed<boolean>(\r\n () => this.comparisonMode() && !!this.comparison(),\r\n );\r\n\r\n /** Which values a compared list shows, once the user picked one. */\r\n private readonly chosenComparisonView =\r\n signal<EntityListComparisonView | null>(null);\r\n\r\n /**\r\n * The values shown: the user's pick, else the property's configured\r\n * `snapshotMode` — Preserved for `Snapshot` (also the backend's default),\r\n * Current for `Realtime`. Record previews, cards and table drawers all\r\n * open on it, so the same list reads the same everywhere.\r\n */\r\n protected readonly comparisonView = computed<EntityListComparisonView>(\r\n () =>\r\n this.chosenComparisonView() ??\r\n (isRealtimeSnapshotMode(this.metadata()?.snapshotMode)\r\n ? 'current'\r\n : 'preserved'),\r\n );\r\n\r\n protected readonly comparisonViewOptions = computed(() => {\r\n const lang = this.lang();\r\n const label = (key: string) =>\r\n this.transloco.translate(`components.entityListField.${key}`, {}, lang);\r\n return [\r\n { label: label('preservedValues'), value: 'preserved' },\r\n { label: label('currentValues'), value: 'current' },\r\n ];\r\n });\r\n\r\n protected setComparisonView(view: unknown): void {\r\n if (view === 'preserved' || view === 'current') {\r\n this.chosenComparisonView.set(view);\r\n }\r\n }\r\n\r\n protected readonly liveRows = computed<EntityListRow[]>(() => {\r\n const columns = this.columns();\r\n const properties = this.propertyByKey();\r\n return (this.comparison()?.live ?? []).map((record) =>\r\n this.recordRow(record, columns, properties),\r\n );\r\n });\r\n\r\n protected readonly preservedRows = computed<EntityListRow[]>(() => {\r\n const columns = this.columns();\r\n const properties = this.propertyByKey();\r\n return (this.comparison()?.preserved ?? []).map((record) =>\r\n this.recordRow(record, columns, properties),\r\n );\r\n });\r\n\r\n /** No baseline was captured yet — not the same as an empty saved list. */\r\n protected readonly preservedAvailable = computed<boolean>(\r\n () => this.comparison()?.preservedAvailable === true,\r\n );\r\n\r\n protected readonly preservedAt = computed<string | null>(\r\n () => this.comparison()?.preservedAt ?? null,\r\n );\r\n\r\n protected readonly unavailableCount = computed<number>(\r\n () => this.comparison()?.unavailableIds?.length ?? 0,\r\n );\r\n\r\n /** Query of the two read-only review endpoints for this list's owner. */\r\n private reviewParams(propertyId: number): Record<string, string> | null {\r\n const owner = this.comparisonOwner();\r\n if (!owner) return null;\r\n return {\r\n ownerKind: owner.ownerKind,\r\n ownerId: String(owner.ownerId),\r\n propertyId: String(propertyId),\r\n };\r\n }\r\n\r\n /**\r\n * The comparison endpoint answered `404` for this owner, so the list is\r\n * shown from the source query instead (see `fetchComparison`).\r\n */\r\n private readonly comparisonUnsupported = signal<boolean>(false);\r\n\r\n private fetchComparison(propertyId: number, fallback?: () => void): void {\r\n const params = this.reviewParams(propertyId);\r\n if (!params) return;\r\n this.loading.set(true);\r\n const ctx = this.context();\r\n this.fetchSubscription = this.http\r\n .get<EntityListComparison>('entity-lists/comparison', {\r\n params,\r\n // `403` / `404` are rendered as notices, not toasts.\r\n headers: { noMessage: 'true' },\r\n ...(ctx ? { context: ctx } : {}),\r\n })\r\n .pipe(takeUntilDestroyed(this.destroyRef))\r\n .subscribe({\r\n next: (response) => {\r\n this.loading.set(false);\r\n this.comparison.set(response);\r\n },\r\n error: (error: HttpErrorResponse) => {\r\n // The API does not know this owner — a host that named a record the\r\n // review endpoints do not serve. Show the list as it did before an\r\n // owner was named, rather than an error in place of the table.\r\n if (error.status === 404 && fallback) {\r\n this.comparisonUnsupported.set(true);\r\n fallback();\r\n return;\r\n }\r\n this.loading.set(false);\r\n const failure = resolveMetadataFailure(error.status);\r\n this.metadataFailure.set(failure);\r\n if (failure === 'failed') {\r\n this.errorMessage.set(\r\n this.transloco.translate('components.entityListField.loadFailed'),\r\n );\r\n }\r\n },\r\n });\r\n }\r\n\r\n // ============================================================================\r\n // Saved list revisions (`entity-lists/revisions`) — read-only history\r\n // ============================================================================\r\n\r\n /**\r\n * A list viewed from outside its form, with its owning record named (a\r\n * table cell's drawer), has saved revisions to browse — Related, Local and\r\n * Selected alike. Nowhere else: an editable list, a record preview and a\r\n * form know no owner, and history is read-only anyway.\r\n */\r\n protected readonly historyAvailable = computed<boolean>(\r\n () =>\r\n this.SHOW_REVISION_HISTORY &&\r\n !!this.comparisonOwner() &&\r\n (this.comparisonMode() || this.localReady() || this.selectionReady()),\r\n );\r\n\r\n /**\r\n * Saved list revisions are not offered for now (product decision): the\r\n * button and the history panel are hidden, while the backend keeps storing\r\n * revisions and serving its API. Turning this on needs nothing else.\r\n */\r\n private readonly SHOW_REVISION_HISTORY = false;\r\n\r\n /**\r\n * A Local or Selected list shows its value until a revision is picked;\r\n * then that revision, until *Back to latest*. A Related list always shows\r\n * a comparison, the latest one when no revision is picked.\r\n */\r\n protected readonly showingRevision = computed<boolean>(\r\n () => this.viewedRevision() != null && !!this.comparison(),\r\n );\r\n\r\n /** The Local rows of the revision being viewed, with that revision's schema. */\r\n private readonly revisionLocalDocument = computed(() =>\r\n this.localMode() ? (this.comparison()?.localDocument ?? null) : null,\r\n );\r\n\r\n private readonly revisionLocalFields = computed(() =>\r\n visibleLocalSchemaFields(this.revisionLocalDocument()?.schema),\r\n );\r\n\r\n protected readonly revisionLocalColumns = computed<EntityListColumnDef[]>(\r\n () => this.buildLocalColumns(this.revisionLocalFields(), true),\r\n );\r\n\r\n protected readonly revisionLocalRows = computed<EntityListRow[]>(() => {\r\n const document = this.revisionLocalDocument();\r\n if (!document) return [];\r\n return this.buildLocalRows(\r\n createLocalEditorState(document),\r\n this.revisionLocalFields(),\r\n this.revisionLocalColumns(),\r\n );\r\n });\r\n\r\n /** The history list is open. */\r\n protected readonly revisionsOpen = signal<boolean>(false);\r\n /** Revisions loaded so far, newest first. */\r\n protected readonly revisions = signal<EntityListRevision[]>([]);\r\n /**\r\n * The revisions as listed, each with the author to print: the name the\r\n * backend resolved for the page, or \"Unknown user\" when it resolved none.\r\n * Plain text — the template interpolates it, never binds it as HTML.\r\n */\r\n protected readonly revisionItems = computed(() => {\r\n const unknown = this.transloco.translate(\r\n 'components.entityListField.unknownUser',\r\n {},\r\n this.lang(),\r\n );\r\n return this.revisions().map((revision) => ({\r\n version: revision.version,\r\n createdAt: revision.createdAt,\r\n author: revision.createdByName?.trim() || unknown,\r\n }));\r\n });\r\n private readonly revisionsTotal = signal<number>(0);\r\n private revisionsPage = 0;\r\n protected readonly revisionsLoading = signal<boolean>(false);\r\n protected readonly revisionsError = signal<string | null>(null);\r\n protected readonly hasMoreRevisions = computed(\r\n () => this.revisions().length < this.revisionsTotal(),\r\n );\r\n /** The revision the comparison shows; null is the list as saved last. */\r\n protected readonly viewedRevision = signal<number | null>(null);\r\n /** A revision is being read; the tables stay until it arrives. */\r\n protected readonly revisionLoading = signal<boolean>(false);\r\n /** Why the chosen revision could not be read. The last comparison stays. */\r\n protected readonly revisionError = signal<string | null>(null);\r\n private revisionSubscription?: Subscription;\r\n private revisionsSubscription?: Subscription;\r\n\r\n protected toggleRevisions(): void {\r\n const open = !this.revisionsOpen();\r\n this.revisionsOpen.set(open);\r\n if (open && this.revisionsPage === 0 && !this.revisionsLoading()) {\r\n this.loadRevisions();\r\n }\r\n }\r\n\r\n /** The next page of the revision index. */\r\n protected loadRevisions(): void {\r\n const propertyId = this.metadata()?.propertyId ?? 0;\r\n const params = this.reviewParams(propertyId);\r\n if (!params) return;\r\n const page = this.revisionsPage + 1;\r\n const ctx = this.context();\r\n this.revisionsLoading.set(true);\r\n this.revisionsError.set(null);\r\n this.revisionsSubscription = this.http\r\n .get<EntityListRevisionPage>('entity-lists/revisions', {\r\n params: { ...params, page, pageSize: REVISIONS_PAGE_SIZE },\r\n headers: { noMessage: 'true' },\r\n ...(ctx ? { context: ctx } : {}),\r\n })\r\n .pipe(\r\n takeUntilDestroyed(this.destroyRef),\r\n finalize(() => this.revisionsLoading.set(false)),\r\n )\r\n .subscribe({\r\n next: (response) => {\r\n this.revisionsPage = page;\r\n this.revisions.set([...this.revisions(), ...(response.items ?? [])]);\r\n this.revisionsTotal.set(Number(response.totalCount) || 0);\r\n },\r\n error: () =>\r\n this.revisionsError.set(\r\n this.transloco.translate(\r\n 'components.entityListField.revisionsLoadFailed',\r\n ),\r\n ),\r\n });\r\n }\r\n\r\n /**\r\n * Compare a saved revision with today — its preserved rows beside today's\r\n * values of the records it held; for Local, its rows as saved — or, with\r\n * `null`, go back to the latest: a Related list re-reads its comparison, a\r\n * Local or Selected one shows its value again. Read-only: nothing here is\r\n * ever submitted.\r\n */\r\n protected showRevision(version: number | null): void {\r\n const propertyId = this.metadata()?.propertyId ?? 0;\r\n const params = this.reviewParams(propertyId);\r\n if (!params || version === this.viewedRevision()) return;\r\n this.revisionSubscription?.unsubscribe();\r\n this.revisionError.set(null);\r\n if (version == null && !this.comparisonMode()) {\r\n this.revisionLoading.set(false);\r\n this.viewedRevision.set(null);\r\n this.comparison.set(null);\r\n return;\r\n }\r\n const ctx = this.context();\r\n this.revisionLoading.set(true);\r\n this.revisionSubscription = this.http\r\n .get<EntityListComparison>('entity-lists/comparison', {\r\n params: version == null ? params : { ...params, revision: version },\r\n headers: { noMessage: 'true' },\r\n ...(ctx ? { context: ctx } : {}),\r\n })\r\n .pipe(\r\n takeUntilDestroyed(this.destroyRef),\r\n finalize(() => this.revisionLoading.set(false)),\r\n )\r\n .subscribe({\r\n next: (response) => {\r\n this.comparison.set(response);\r\n this.viewedRevision.set(version);\r\n },\r\n error: (error: HttpErrorResponse) =>\r\n this.revisionError.set(this.revisionFailureMessage(error)),\r\n });\r\n }\r\n\r\n /**\r\n * `entity_list.history_source_changed` (`400`): the revision was saved with\r\n * another source configuration. `404`: it no longer exists.\r\n */\r\n private revisionFailureMessage(error: HttpErrorResponse): string {\r\n const code = (error.error as { code?: unknown } | null)?.code;\r\n const key =\r\n code === 'entity_list.history_source_changed'\r\n ? 'revisionSourceChanged'\r\n : error.status === 404\r\n ? 'revisionNotFound'\r\n : 'loadFailed';\r\n return this.transloco.translate(`components.entityListField.${key}`);\r\n }\r\n\r\n private resetRevisions(): void {\r\n this.revisionSubscription?.unsubscribe();\r\n this.revisionsSubscription?.unsubscribe();\r\n this.revisionsOpen.set(false);\r\n this.revisions.set([]);\r\n this.revisionsTotal.set(0);\r\n this.revisionsPage = 0;\r\n this.revisionsLoading.set(false);\r\n this.revisionsError.set(null);\r\n this.viewedRevision.set(null);\r\n this.revisionLoading.set(false);\r\n this.revisionError.set(null);\r\n }\r\n\r\n protected readonly selectionRowActions = computed<TableAction[]>(() => {\r\n this.lang();\r\n if (!this.selectionWritable()) return [];\r\n return [\r\n {\r\n icon: 'general.x-close' as const,\r\n tooltip: this.transloco.translate(\r\n 'components.entityListField.unselect',\r\n ),\r\n color: 'danger' as const,\r\n action: (row: EntityListRow) =>\r\n this.emitSelection(\r\n removeSelectedRecord(\r\n this.selectionState(),\r\n Number(row[ROW_ENTITY_ID_KEY]),\r\n ),\r\n ),\r\n },\r\n ];\r\n });\r\n\r\n /**\r\n * A required Selected list needs a record. An emptied selection is an\r\n * object — a mutation with no ids — so `Validators.required` passes it and\r\n * only the backend would object (`entity_list.selection_required`).\r\n */\r\n private readonly selectionRequiredValidator = (\r\n control: AbstractControl,\r\n ): ValidationErrors | null => {\r\n if (!this.required()) return null;\r\n const value = control.value;\r\n if (isEntityListSelectionDocument(value)) {\r\n return value.entityIds?.length ? null : { required: true };\r\n }\r\n return value == null && this.selectionMode() ? { required: true } : null;\r\n };\r\n\r\n protected openSelectionDialog(): void {\r\n if (!this.selectionWritable()) return;\r\n\r\n const ref = this.modal.openModal(EntityListSelectionDialog, 'dialog', {\r\n header: this.transloco.translate(\r\n 'components.entityListField.selectRecords',\r\n ),\r\n styleClass: '!w-[36rem] max-w-[96vw]',\r\n dismissableMask: true,\r\n inputValues: {\r\n propertyKey: this.propertyKey(),\r\n contextKey: this.selectionContextKey(),\r\n levelDataId: this.levelDataId(),\r\n multiple: this.selectionMultiple(),\r\n selectedIds: this.selectionState().ids,\r\n context: this.context(),\r\n },\r\n });\r\n\r\n ref.onClose.pipe(take(1)).subscribe((result: unknown) => {\r\n if (!Array.isArray(result)) return;\r\n this.emitSelection(\r\n applySelectionPicks(\r\n this.selectionState(),\r\n result as SelectionPick[],\r\n this.selectionMultiple(),\r\n ),\r\n );\r\n });\r\n }\r\n\r\n /**\r\n * Publish the selection as the control's value: a mutation when it differs\r\n * from what was loaded, else the loaded value, which the submission leaves\r\n * out. See `buildSelectionValue`.\r\n */\r\n private emitSelection(next: SelectionEditorState): void {\r\n const { state, value } = buildSelectionValue(next, newLocalUuid);\r\n this.selectionState.set(state);\r\n if (value) SELECTION_EDITOR_STATES.set(value, state);\r\n this.lastSelectionEmit = value;\r\n this.onModelChange(value as unknown as EntityListStoredValue | null);\r\n this.onTouched();\r\n }\r\n\r\n /**\r\n * Take a Selected document, and say whether it was one.\r\n *\r\n * Our own emission echoed back keeps the session; a value some instance of\r\n * this field emitted restores that instance's state (see\r\n * `SELECTION_EDITOR_STATES`); anything else starts a session on it. That is\r\n * the projection `process-form-load` returns, the stored document a preview\r\n * gets from the fetch endpoints, or a mutation the form already held — which\r\n * stays the control's value until the user changes the selection.\r\n *\r\n * An empty value resets the session too and still falls through, since\r\n * which mode the list uses may not be known yet.\r\n */\r\n private writeSelectionValue(value: unknown): boolean {\r\n const incoming = this.coerceStoredValue(value);\r\n if (!isEntityListSelectionDocument(incoming)) {\r\n if (incoming == null) {\r\n this.lastSelectionEmit = null;\r\n this.selectionState.set(createSelectionEditorState(null));\r\n }\r\n return false;\r\n }\r\n\r\n this.selectionValueSeen.set(true);\r\n if (incoming === this.lastSelectionEmit) return true;\r\n this.lastSelectionEmit = null;\r\n\r\n const restored = SELECTION_EDITOR_STATES.get(incoming);\r\n this.selectionState.set(\r\n restored ??\r\n createSelectionEditorState(incoming as EntityListSelectionDocument),\r\n );\r\n return true;\r\n }\r\n\r\n /** Enough context to ask the backend what this field should render. */\r\n protected readonly hasRequiredContext = computed<boolean>(\r\n () => this.propertyKeyId() > 0 && Number(this.levelId()) > 0,\r\n );\r\n\r\n /**\r\n * The non-error state the field renders instead of a table, as a translation\r\n * key. Null while the metadata request is still in flight, so the template\r\n * falls through to the skeleton.\r\n */\r\n protected readonly noticeKey = computed<string | null>(() => {\r\n if (!this.hasRequiredContext()) {\r\n return 'components.entityListField.missingConfiguration';\r\n }\r\n switch (this.metadataFailure()) {\r\n case 'forbidden':\r\n return 'components.entityListField.accessDenied';\r\n case 'unavailable':\r\n return 'components.entityListField.missingConfiguration';\r\n case 'failed':\r\n return null;\r\n }\r\n if (!this.metadata()) return null;\r\n // A Local list reads nothing from the source module; it needs only a\r\n // schema to render its own rows with.\r\n if (this.localMode()) {\r\n return this.localFields().length\r\n ? null\r\n : 'components.entityListField.missingConfiguration';\r\n }\r\n if (!this.moduleBacked()) {\r\n return 'components.entityListField.missingConfiguration';\r\n }\r\n return this.canDisplayRows()\r\n ? null\r\n : 'components.entityListField.readingNotAllowed';\r\n });\r\n\r\n protected onTouched: () => void = () => {};\r\n protected onModelChange: (value: EntityListStoredValue | null) => void =\r\n () => {};\r\n\r\n private readonly http = inject(HttpClient);\r\n private metadataSubscription?: Subscription;\r\n private fetchSubscription?: Subscription;\r\n private readonly destroyRef = inject(DestroyRef);\r\n private readonly modal = inject(ModalService);\r\n private readonly transloco = inject(TranslocoService);\r\n /** Active language — see `rowChangeLabels`. */\r\n private readonly lang = toSignal(this.transloco.langChanges$, {\r\n initialValue: this.transloco.getActiveLang(),\r\n });\r\n /**\r\n * Optional rich add-row dialog (provided by `@masterteam/forms` via\r\n * `provideEntityListAddForm()`). When available, used instead of the local\r\n * minimal dialog so the popup renders `mt-client-form` filtered by\r\n * `writeFields`.\r\n */\r\n private readonly addDialogComponent = inject(\r\n ENTITY_LIST_ADD_DIALOG_COMPONENT,\r\n { optional: true },\r\n );\r\n /**\r\n * Row dialog of a Local list, built from the schema's captured definitions\r\n * (`provideEntityListAddForm()` registers it beside the linked one). Without\r\n * it a Local list renders read-only.\r\n */\r\n private readonly localDialogComponent = inject(\r\n ENTITY_LIST_LOCAL_ROW_DIALOG_COMPONENT,\r\n { optional: true },\r\n );\r\n\r\n constructor() {\r\n this.ngControl = inject(NgControl, { self: true, optional: true });\r\n if (this.ngControl) {\r\n this.ngControl.valueAccessor = this;\r\n }\r\n\r\n // The property and its level address the metadata endpoint; the answer\r\n // decides everything else, including whether rows are fetched at all.\r\n // Only these scalars retrigger a load — a host that rebuilds its field\r\n // config object (language, readonly) must not cost a round trip.\r\n effect(() => {\r\n const propertyId = this.propertyKeyId();\r\n const levelId = this.levelId();\r\n const levelDataId = this.levelDataId();\r\n\r\n untracked(() => this.loadTable(propertyId, levelId, levelDataId));\r\n });\r\n\r\n // The control exists once the form directive has resolved it, which is\r\n // after construction. The validator reads `required` and the mode itself,\r\n // so it is added once; the control is re-validated when either changes —\r\n // the mode is only known once the metadata or the value arrives.\r\n effect(() => {\r\n this.selectionMode();\r\n this.required();\r\n const control = this.ngControl?.control;\r\n if (!control) return;\r\n untracked(() => {\r\n if (!control.hasValidator(this.selectionRequiredValidator)) {\r\n control.addValidators(this.selectionRequiredValidator);\r\n }\r\n control.updateValueAndValidity({ emitEvent: false });\r\n });\r\n });\r\n\r\n // Form-less hosts hand the value over as an input instead. `writeValue` is\r\n // the one entry point that resets the pending rows and deletions with it,\r\n // so it is reused rather than re-implemented.\r\n //\r\n // Purely additive: an absent input never clears a value, so a host that\r\n // does not bind it — or binds it late — cannot wipe what a form or a direct\r\n // `writeValue` already put there.\r\n effect(() => {\r\n const value = this.initialValue();\r\n if (this.ngControl || value == null) return;\r\n\r\n untracked(() => this.writeValue(value));\r\n });\r\n }\r\n\r\n // ============================================================================\r\n // CVA\r\n // ============================================================================\r\n\r\n writeValue(value: EntityListStoredValue | string | null): void {\r\n if (this.writeLocalValue(value)) return;\r\n if (this.writeSelectionValue(value)) return;\r\n const incoming = this.coerceStoredValue(value);\r\n // Ignore the echo of our own emission (DynamicForm re-writes the model on\r\n // every value change) so pending edits/deletions are not reset.\r\n if (this.isEchoOfLastEmit(incoming)) return;\r\n this.lastEmittedJson = null;\r\n this.linkedMutation = null;\r\n this.loadedMutationId = incoming?.mutationId;\r\n this.storedValue.set(incoming);\r\n // Restore rows the backend left unprocessed. Whether the loaded\r\n // `deletedIds` are historical markers or pending intent depends on the\r\n // value's provenance, which `deletedIds` resolves from `pendingSubmission`\r\n // — an input, so it cannot be read reliably this early.\r\n const rows = Array.isArray(incoming?.rows) ? incoming.rows : [];\r\n this.pendingRows.set(\r\n rows.filter((row) => !!row && typeof row === 'object'),\r\n );\r\n this.loadedDeletedIds.set(\r\n (Array.isArray(incoming?.deletedIds) ? incoming.deletedIds : [])\r\n .map((id) => Number(id))\r\n .filter((id) => Number.isFinite(id) && id > 0),\r\n );\r\n this.stagedDeletedIds.set([]);\r\n this.rowDrafts.set({});\r\n }\r\n\r\n /**\r\n * Take a Local document, and say whether it was one.\r\n *\r\n * - Our own emission echoed back (`mt-dynamic-form` re-writes the model on\r\n * every change) keeps the session's edits.\r\n * - A value some instance of this field emitted restores that instance's\r\n * state — see `LOCAL_EDITOR_STATES`.\r\n * - A document the backend sent starts a fresh session on it: the projection\r\n * `process-form-load` and the fetch endpoints return (its `schema` set,\r\n * cells rendered), or the stored document an older backend's fetch\r\n * endpoints returned (`schema: null`, cells unrendered) — the schema then\r\n * comes from the metadata.\r\n * Every backend document carries the `schema` member, null or not; a\r\n * mutation never does. So a mutation nobody here emitted has no rows to\r\n * rebuild the table from and is left as the control's value, untouched\r\n * until the user edits.\r\n *\r\n * An empty value resets the Local session too — a form reset — and still\r\n * falls through, since which storage the list uses may not be known yet.\r\n */\r\n private writeLocalValue(value: unknown): boolean {\r\n const incoming = this.coerceStoredValue(value);\r\n if (!isEntityListLocalDocument(incoming)) {\r\n if (incoming == null) {\r\n this.lastLocalEmit = null;\r\n this.localState.set(createLocalEditorState(null));\r\n }\r\n return false;\r\n }\r\n\r\n this.localValueSeen.set(true);\r\n if (incoming === this.lastLocalEmit) return true;\r\n this.lastLocalEmit = null;\r\n\r\n const restored = LOCAL_EDITOR_STATES.get(incoming);\r\n if (restored) {\r\n this.localState.set(restored);\r\n return true;\r\n }\r\n this.localState.set(\r\n createLocalEditorState(\r\n 'schema' in incoming ? (incoming as EntityListLocalDocument) : null,\r\n ),\r\n );\r\n return true;\r\n }\r\n\r\n /**\r\n * True when the written value still carries exactly the change we last\r\n * emitted — i.e. the form is echoing our own value back rather than loading\r\n * a new one.\r\n *\r\n * The list version, change id and tokens are part of it: a reload after a\r\n * save can carry the same (empty) rows and deletions as the last emission,\r\n * and taking it for an echo kept the old version, so the next save was\r\n * refused as a version conflict.\r\n */\r\n private isEchoOfLastEmit(incoming: EntityListStoredValue | null): boolean {\r\n if (this.lastEmittedJson === null) return false;\r\n return this.echoKey(incoming) === this.lastEmittedJson;\r\n }\r\n\r\n private echoKey(value: EntityListStoredValue | null): string {\r\n return JSON.stringify({\r\n rows: value?.rows ?? [],\r\n deletedIds: value?.deletedIds ?? [],\r\n version: value?.version ?? null,\r\n mutationId: value?.mutationId ?? null,\r\n expectedVersions: value?.expectedVersions ?? null,\r\n });\r\n }\r\n\r\n /**\r\n * The stored value is persisted as JSON, so a host may write either the\r\n * parsed object or its raw string form.\r\n */\r\n private coerceStoredValue(value: unknown): EntityListStoredValue | null {\r\n if (value == null || value === '') return null;\r\n if (typeof value === 'string') {\r\n try {\r\n return this.coerceStoredValue(JSON.parse(value));\r\n } catch {\r\n return null;\r\n }\r\n }\r\n return typeof value === 'object' && !Array.isArray(value)\r\n ? (value as EntityListStoredValue)\r\n : null;\r\n }\r\n\r\n registerOnChange(fn: (value: EntityListStoredValue | null) => void): void {\r\n this.onModelChange = fn;\r\n }\r\n\r\n registerOnTouched(fn: () => void): void {\r\n this.onTouched = fn;\r\n }\r\n\r\n setDisabledState(isDisabled: boolean): void {\r\n this.disabled.set(isDisabled);\r\n }\r\n\r\n // ============================================================================\r\n // Write mode — add / edit / delete\r\n // ============================================================================\r\n\r\n /** Row actions shown in write mode — edit and delete. */\r\n protected readonly writeRowActions = computed<TableAction[]>(() => {\r\n if (this.disabled()) return [];\r\n return [\r\n {\r\n icon: 'custom.pencil' as const,\r\n tooltip: this.transloco.translate('components.entityListField.edit'),\r\n action: (row: EntityListRow) => this.openEditDialog(row),\r\n },\r\n {\r\n icon: 'general.trash-01' as const,\r\n tooltip: this.transloco.translate('components.entityListField.delete'),\r\n color: 'danger' as const,\r\n confirmation: {\r\n type: 'popup' as const,\r\n confirmationType: 'delete' as const,\r\n },\r\n action: (row: EntityListRow) => this.deleteRow(row),\r\n },\r\n ];\r\n });\r\n\r\n protected openAddDialog(): void {\r\n if (this.disabled()) return;\r\n const component = this.addDialogComponent;\r\n if (!component) return;\r\n\r\n const ref = this.modal.openModal(component, 'dialog', {\r\n header: this.transloco.translate('components.entityListField.add'),\r\n styleClass: '!w-[48rem] max-w-[96vw]',\r\n dismissableMask: true,\r\n inputValues: {\r\n moduleId: this.moduleId(),\r\n levelId: this.levelId(),\r\n levelDataId: this.levelDataId(),\r\n writeFields: this.writeFields(),\r\n requiredFieldKeys: this.createRequiredFields(),\r\n lookups: this.lookups(),\r\n },\r\n });\r\n\r\n ref.onClose.pipe(take(1)).subscribe((result: unknown) => {\r\n const parsed = this.parseDialogResult(result);\r\n if (!parsed) return;\r\n // A create row carries every value the user filled in; empty fields are\r\n // dropped so the target module keeps its own defaults.\r\n const values = this.dropEmptyValues(parsed.values);\r\n const rowId = this.nextRowId();\r\n this.setRowDraft(rowId, values, parsed.display);\r\n this.pendingRows.set([\r\n ...this.pendingRows(),\r\n {\r\n rowId,\r\n entityId: 0,\r\n values: this.toSubmitValues(values, parsed.submit),\r\n },\r\n ]);\r\n this.emitValue();\r\n });\r\n }\r\n\r\n protected openEditDialog(row: EntityListRow): void {\r\n if (this.disabled()) return;\r\n const component = this.addDialogComponent;\r\n if (!component) return;\r\n\r\n const entityId = Number(row[ROW_ENTITY_ID_KEY]) || 0;\r\n const rowId = String(row[ROW_ID_KEY] ?? '');\r\n const initialValues =\r\n (row[ROW_VALUES_KEY] as Record<string, unknown> | undefined) ?? {};\r\n // The form is filled with the shapes its controls bind; the diff still\r\n // runs against `initialValues`, the stored scalars.\r\n const prefillValues =\r\n (row[ROW_PREFILL_KEY] as Record<string, unknown> | undefined) ??\r\n initialValues;\r\n\r\n const ref = this.modal.openModal(component, 'dialog', {\r\n header: this.transloco.translate('components.entityListField.edit'),\r\n styleClass: '!w-[48rem] max-w-[96vw]',\r\n dismissableMask: true,\r\n inputValues: {\r\n moduleId: this.moduleId(),\r\n levelId: this.levelId(),\r\n levelDataId: this.levelDataId(),\r\n writeFields: this.writeFields(),\r\n // A row not saved yet is still a create; an existing record's update\r\n // carries only what changed.\r\n requiredFieldKeys: entityId > 0 ? [] : this.createRequiredFields(),\r\n lookups: this.lookups(),\r\n initialValues: prefillValues,\r\n isEdit: true,\r\n },\r\n });\r\n\r\n ref.onClose.pipe(take(1)).subscribe((result: unknown) => {\r\n const parsed = this.parseDialogResult(result);\r\n if (!parsed) return;\r\n if (entityId > 0) {\r\n this.applyExistingRowEdit(entityId, rowId, initialValues, parsed);\r\n } else {\r\n this.applyCreatedRowEdit(rowId, parsed);\r\n }\r\n this.emitValue();\r\n });\r\n }\r\n\r\n /**\r\n * Existing target records are updated partially: only values the user\r\n * actually changed are submitted, so fields the dialog could not pre-fill\r\n * (keys outside `readFields`) are left untouched by the backend.\r\n */\r\n private applyExistingRowEdit(\r\n entityId: number,\r\n fallbackRowId: string,\r\n initialValues: Record<string, unknown>,\r\n parsed: {\r\n values: Record<string, unknown>;\r\n display: Record<string, unknown>;\r\n submit: Record<string, unknown>;\r\n },\r\n ): void {\r\n const changed = this.diffValues(\r\n initialValues,\r\n parsed.values,\r\n parsed.submit,\r\n );\r\n const current = this.pendingRows();\r\n const existing = current.find((row) => row.entityId === entityId);\r\n const rowId =\r\n existing?.rowId || (fallbackRowId ? fallbackRowId : `entity-${entityId}`);\r\n const merged = {\r\n ...(this.rowDrafts()[rowId]?.values ?? {}),\r\n ...changed,\r\n };\r\n\r\n if (Object.keys(merged).length === 0) {\r\n // Nothing left to submit for this record — drop the pending update.\r\n this.clearRowDraft(rowId);\r\n this.pendingRows.set(current.filter((row) => row.entityId !== entityId));\r\n return;\r\n }\r\n\r\n this.setRowDraft(rowId, merged, parsed.display);\r\n const next: EntityListSubmitRow = {\r\n rowId,\r\n entityId,\r\n values: this.toSubmitValues(merged, parsed.submit),\r\n };\r\n this.pendingRows.set(\r\n existing\r\n ? current.map((row) => (row.entityId === entityId ? next : row))\r\n : [...current, next],\r\n );\r\n }\r\n\r\n /** A locally created row is replaced wholesale by the dialog result. */\r\n private applyCreatedRowEdit(\r\n rowId: string,\r\n parsed: {\r\n values: Record<string, unknown>;\r\n display: Record<string, unknown>;\r\n submit: Record<string, unknown>;\r\n },\r\n ): void {\r\n const values = this.dropEmptyValues(parsed.values);\r\n this.setRowDraft(rowId, values, parsed.display);\r\n this.pendingRows.set(\r\n this.pendingRows().map((row) =>\r\n row.rowId === rowId\r\n ? { ...row, values: this.toSubmitValues(values, parsed.submit) }\r\n : row,\r\n ),\r\n );\r\n }\r\n\r\n /**\r\n * Remove a row. Locally created rows are dropped from the pending payload;\r\n * existing records are queued in `deletedIds` for the backend to delete.\r\n */\r\n protected deleteRow(row: EntityListRow): void {\r\n if (this.disabled()) return;\r\n const entityId = Number(row[ROW_ENTITY_ID_KEY]) || 0;\r\n const rowId = String(row[ROW_ID_KEY] ?? '');\r\n\r\n if (entityId > 0) {\r\n if (!this.deletedIds().includes(entityId)) {\r\n this.stagedDeletedIds.set([...this.stagedDeletedIds(), entityId]);\r\n }\r\n // A queued update for a deleted record is pointless — drop it.\r\n this.pendingRows.set(\r\n this.pendingRows().filter((pending) => pending.entityId !== entityId),\r\n );\r\n } else {\r\n this.pendingRows.set(\r\n this.pendingRows().filter((pending) => pending.rowId !== rowId),\r\n );\r\n }\r\n\r\n this.clearRowDraft(rowId);\r\n this.emitValue();\r\n }\r\n\r\n // ============================================================================\r\n // Local write mode — staged into the parent's own submission\r\n // ============================================================================\r\n\r\n /**\r\n * Add a Local row (no `row`) or edit one. The dialog is built from the\r\n * schema; its `submit` map is serialized here into cell `rawValue`s.\r\n *\r\n * A loaded row keeps only the cells that differ from what was loaded, so an\r\n * untouched cell is omitted and retained. Emptying a cell that had a value\r\n * is a clear, sent as `null` — the dialog is filled from every schema field,\r\n * so an empty control here really was emptied.\r\n */\r\n protected openLocalRowDialog(row?: EntityListRow): void {\r\n const component = this.localDialogComponent;\r\n if (!component || this.disabled()) return;\r\n\r\n const state = this.localState();\r\n const rowId = row ? String(row[ROW_ID_KEY] ?? '') : null;\r\n const created = rowId\r\n ? state.created.find((entry) => entry.rowId === rowId)\r\n : undefined;\r\n const existing =\r\n rowId && !created\r\n ? state.base?.localRows?.find((entry) => entry.rowId === rowId)\r\n : undefined;\r\n\r\n const ref = this.modal.openModal(component, 'dialog', {\r\n header: this.transloco.translate(\r\n row\r\n ? 'components.entityListField.edit'\r\n : 'components.entityListField.add',\r\n ),\r\n styleClass: '!w-[48rem] max-w-[96vw]',\r\n dismissableMask: true,\r\n inputValues: {\r\n fields: this.localFields(),\r\n lookups: this.lookups(),\r\n initialCells: existing\r\n ? Object.fromEntries(localCellsByFieldId(existing))\r\n : undefined,\r\n initialValues:\r\n created?.draft.values ??\r\n (rowId ? state.edited[rowId]?.values : undefined),\r\n isEdit: !!row,\r\n },\r\n });\r\n\r\n ref.onClose.pipe(take(1)).subscribe((result: unknown) => {\r\n const parsed = this.parseDialogResult(result);\r\n if (!parsed) return;\r\n const draft: LocalRowDraft = {\r\n cells: this.toLocalCells(parsed.values, parsed.submit),\r\n values: parsed.values,\r\n display: parsed.display,\r\n };\r\n const current = this.localState();\r\n\r\n if (!rowId) {\r\n this.emitLocal({\r\n ...current,\r\n created: [...current.created, { rowId: newLocalUuid(), draft }],\r\n });\r\n return;\r\n }\r\n if (created) {\r\n this.emitLocal({\r\n ...current,\r\n created: current.created.map((entry) =>\r\n entry.rowId === rowId ? { ...entry, draft } : entry,\r\n ),\r\n });\r\n return;\r\n }\r\n if (!existing) return;\r\n\r\n const edited = { ...current.edited };\r\n const changed = diffLocalCells(existing, draft.cells);\r\n if (Object.keys(changed).length > 0) {\r\n edited[rowId] = { ...draft, cells: changed };\r\n } else {\r\n delete edited[rowId];\r\n }\r\n this.emitLocal({ ...current, edited });\r\n });\r\n }\r\n\r\n /**\r\n * Remove a Local row. A loaded row is listed in `deletedRowIds` and its\r\n * pending edit dropped — a row is never both deleted and submitted. A row\r\n * added in this session just disappears.\r\n */\r\n protected deleteLocalRow(row: EntityListRow): void {\r\n if (this.disabled()) return;\r\n const rowId = String(row[ROW_ID_KEY] ?? '');\r\n const current = this.localState();\r\n\r\n if (current.created.some((entry) => entry.rowId === rowId)) {\r\n this.emitLocal({\r\n ...current,\r\n created: current.created.filter((entry) => entry.rowId !== rowId),\r\n });\r\n return;\r\n }\r\n\r\n const edited = { ...current.edited };\r\n delete edited[rowId];\r\n this.emitLocal({\r\n ...current,\r\n edited,\r\n deleted: current.deleted.includes(rowId)\r\n ? current.deleted\r\n : [...current.deleted, rowId],\r\n });\r\n }\r\n\r\n /**\r\n * Apply a drag within the table. Replays PrimeNG's own move on the rows as\r\n * rendered: `p-table` is bound to a derived array, so the event's `value`\r\n * is not reliably the reordered one.\r\n */\r\n protected onLocalReorder(event: {\r\n dragIndex?: number;\r\n dropIndex?: number;\r\n }): void {\r\n const from = Number(event?.dragIndex);\r\n const to = Number(event?.dropIndex);\r\n const ids = this.localTableRows().map((row) => String(row[ROW_ID_KEY]));\r\n if (\r\n !Number.isInteger(from) ||\r\n !Number.isInteger(to) ||\r\n from === to ||\r\n from < 0 ||\r\n to < 0 ||\r\n from >= ids.length ||\r\n to >= ids.length\r\n ) {\r\n return;\r\n }\r\n const [moved] = ids.splice(from, 1);\r\n ids.splice(to, 0, moved);\r\n this.emitLocal({ ...this.localState(), order: ids });\r\n }\r\n\r\n /**\r\n * Serialize one dialog result into cells, by field id, for every visible\r\n * field. `submit` is the dialog's reduction to stored scalars and wins over\r\n * the raw control value, as for linked rows.\r\n */\r\n private toLocalCells(\r\n values: Record<string, unknown>,\r\n submit: Record<string, unknown>,\r\n ): Record<string, string | null> {\r\n const cells: Record<string, string | null> = {};\r\n for (const field of this.localFields()) {\r\n const fieldId = field.id as string;\r\n cells[fieldId] = this.toRawValue(\r\n fieldId in submit ? submit[fieldId] : values[fieldId],\r\n );\r\n }\r\n return cells;\r\n }\r\n\r\n /**\r\n * Publish the Local state as the control's value.\r\n *\r\n * With changes, the value is a mutation: the loaded list and schema\r\n * versions, only the changed rows and cells, explicit deletions, and a\r\n * `mutationId` that stays the same while the content does (a retry of the\r\n * same save) and changes with it (a new save). Without changes it is the\r\n * loaded document again, which `mapFormValueToSubmitFields` leaves out of the\r\n * submission — an unchanged Local list is omitted, never re-sent.\r\n */\r\n private emitLocal(next: LocalEditorState): void {\r\n const content = buildLocalMutationContent(next);\r\n let state = next;\r\n let value: EntityListLocalDocument | null = next.base;\r\n\r\n if (content) {\r\n const mutation = {\r\n storageMode: 'Local' as const,\r\n formatVersion: 1,\r\n schemaVersion:\r\n next.base?.schemaVersion ??\r\n this.metadata()?.localSchema?.version ??\r\n '',\r\n version: next.base?.version ?? 0,\r\n ...content,\r\n };\r\n const mutationKey = JSON.stringify(mutation);\r\n const mutationId =\r\n next.mutationKey === mutationKey && next.mutationId\r\n ? next.mutationId\r\n : newLocalUuid();\r\n state = { ...next, mutationId, mutationKey };\r\n value = { ...mutation, mutationId };\r\n } else {\r\n state = { ...next, mutationId: null, mutationKey: null };\r\n }\r\n\r\n this.localState.set(state);\r\n if (value) LOCAL_EDITOR_STATES.set(value, state);\r\n this.lastLocalEmit = value;\r\n this.onModelChange(value as unknown as EntityListStoredValue | null);\r\n this.onTouched();\r\n }\r\n\r\n /** A cell the user set in this session, shaped like a backend one. */\r\n private buildLocalDraftCell(\r\n column: EntityListColumnDef,\r\n draft: LocalRowDraft,\r\n configuration: Record<string, unknown> | null,\r\n ): EntityData {\r\n const fieldId = column.key;\r\n const raw = draft.values[fieldId];\r\n const label = draft.display[fieldId];\r\n // A multi-select holds ids and resolves to labels; print the labels.\r\n const value =\r\n Array.isArray(raw) && Array.isArray(label)\r\n ? label.join(', ')\r\n : this.toLocalEntityValue(column.viewType, raw, label);\r\n return {\r\n key: fieldId,\r\n name: column.label,\r\n viewType: (column.viewType ?? 'Text') as EntityViewType,\r\n value: (value !== null && typeof value === 'object'\r\n ? value\r\n : (this.toRawValue(value) ?? '')) as EntityData['value'],\r\n rawValue: draft.cells[fieldId] ?? undefined,\r\n propertyConfiguration: configuration ?? undefined,\r\n };\r\n }\r\n\r\n /**\r\n * A loaded cell: the backend's rendered `value` beside its `rawValue`. A\r\n * stored document (what an older backend's fetch endpoints returned) has no\r\n * rendered values, so the raw one is shaped the way a locally set cell would\r\n * be — a user id still renders as a user, though only as its id.\r\n */\r\n private buildLocalLoadedCell(\r\n column: EntityListColumnDef,\r\n cell: { rawValue: string | null; value?: unknown } | undefined,\r\n configuration: Record<string, unknown> | null,\r\n ): EntityData {\r\n const value =\r\n cell?.value != null\r\n ? cell.value\r\n : this.toLocalEntityValue(column.viewType, cell?.rawValue, undefined);\r\n return {\r\n key: column.key,\r\n name: column.label,\r\n viewType: (column.viewType ?? 'Text') as EntityViewType,\r\n value: (value ?? '') as EntityData['value'],\r\n rawValue: serializeEntityRawValue(cell?.rawValue),\r\n propertyConfiguration: configuration ?? undefined,\r\n };\r\n }\r\n\r\n /**\r\n * Normalize the add/edit dialog close payload. The rich dialog returns\r\n * `{ values, display }`; a custom add-dialog may still return the raw values\r\n * object directly (no display map), which we treat as `display = {}`.\r\n */\r\n private parseDialogResult(result: unknown): {\r\n values: Record<string, unknown>;\r\n display: Record<string, unknown>;\r\n submit: Record<string, unknown>;\r\n } | null {\r\n if (!result || typeof result !== 'object') return null;\r\n const payload = result as Record<string, unknown>;\r\n const values = payload['values'];\r\n if (values && typeof values === 'object') {\r\n return {\r\n values: values as Record<string, unknown>,\r\n display:\r\n (payload['display'] as Record<string, unknown> | undefined) ?? {},\r\n submit:\r\n (payload['submit'] as Record<string, unknown> | undefined) ?? {},\r\n };\r\n }\r\n return { values: payload, display: {}, submit: {} };\r\n }\r\n\r\n private nextRowId(): string {\r\n const used = new Set(this.pendingRows().map((row) => row.rowId));\r\n let candidate = '';\r\n do {\r\n this.localRowSeq += 1;\r\n candidate = `client-${this.localRowSeq}`;\r\n } while (used.has(candidate));\r\n return candidate;\r\n }\r\n\r\n private setRowDraft(\r\n rowId: string,\r\n values: Record<string, unknown>,\r\n display: Record<string, unknown>,\r\n ): void {\r\n this.rowDrafts.set({ ...this.rowDrafts(), [rowId]: { values, display } });\r\n }\r\n\r\n private clearRowDraft(rowId: string): void {\r\n if (!rowId || !(rowId in this.rowDrafts())) return;\r\n const next = { ...this.rowDrafts() };\r\n delete next[rowId];\r\n this.rowDrafts.set(next);\r\n }\r\n\r\n private buildRow(\r\n id: string | number,\r\n rowId: string,\r\n entityId: number,\r\n values: Record<string, unknown>,\r\n display: Record<string, unknown> = {},\r\n ): EntityListRow {\r\n const row: EntityListRow = {\r\n Id: id,\r\n [ROW_ID_KEY]: rowId,\r\n [ROW_ENTITY_ID_KEY]: entityId,\r\n [ROW_VALUES_KEY]: values,\r\n // A drafted row is built from control values already, so there is\r\n // nothing to resolve — the two maps are the same.\r\n [ROW_PREFILL_KEY]: values,\r\n };\r\n for (const column of this.columns()) {\r\n // Form values are keyed by catalog property key (e.g. \"task_name\"),\r\n // but column.key is the normalizedKey (e.g. \"Name\"). Use propertyKey\r\n // for the lookup so the value is found.\r\n const key = column.propertyKey ?? column.key;\r\n row[column.key] = this.buildCell(column, values[key], display[key]);\r\n }\r\n return row;\r\n }\r\n\r\n /**\r\n * Render one table cell from a raw form value and its resolved label.\r\n *\r\n * The cell has to arrive in the shape the backend would have sent, because\r\n * that is what the entity renderers bind. Two things a control value is not:\r\n *\r\n * - **A scalar `value` is a string.** `mt-entity-percentage` reads `d.value`\r\n * only when `typeof` it is `'string'` and prints its placeholder otherwise,\r\n * so a numeric control value rendered as a filled bar with no number beside\r\n * it. Objects and arrays are the resolved shapes the rich renderers want,\r\n * and pass through untouched.\r\n * - **The column configuration has to travel with it.** Colour rules live\r\n * there, and `mt-entity-percentage` falls back to evaluating them itself\r\n * exactly when no per-value colour was resolved — which is every locally\r\n * added row. Without it a new 45% row rendered in the default colour while\r\n * the same value loaded from the backend rendered in its band colour.\r\n */\r\n private buildCell(\r\n column: EntityListColumnDef,\r\n raw: unknown,\r\n label: unknown,\r\n ): EntityData {\r\n const value = this.toLocalEntityValue(column.viewType, raw, label);\r\n const propertyKey = column.propertyKey ?? column.key;\r\n return {\r\n name: column.label ?? column.key,\r\n key: column.key,\r\n viewType: column.viewType ?? 'Text',\r\n value:\r\n value !== null && typeof value === 'object'\r\n ? value\r\n : (this.toRawValue(value) ?? ''),\r\n rawValue: this.toRawValue(raw) ?? undefined,\r\n configuration: column.configuration,\r\n propertyConfiguration:\r\n this.propertyByKey().get(propertyKey)?.configuration,\r\n } as unknown as EntityData;\r\n }\r\n\r\n /**\r\n * Shape a raw form value into the value an entity renderer expects for the\r\n * given view type. Locally-added rows carry raw form values, but renderers\r\n * like `mt-entity-user` need a display object (`{ displayName }`) — a\r\n * team-member `User` field is a select whose control value is a bare user id.\r\n * `label` is the resolved option display (present for select-based fields).\r\n */\r\n private toLocalEntityValue(\r\n viewType: string | undefined,\r\n raw: unknown,\r\n label: unknown,\r\n ): unknown {\r\n // A row loaded from a staged submission carries the backend's resolved\r\n // value as its label, and for the rich view types that object *is* what\r\n // the renderer binds — the same shape the raw branches below assemble by\r\n // hand. A select's resolved option is a plain string and still falls\r\n // through to them.\r\n const resolved =\r\n label != null && typeof label === 'object' && !Array.isArray(label)\r\n ? (label as Record<string, unknown>)\r\n : null;\r\n\r\n if (viewType === 'User') {\r\n if (Array.isArray(raw)) {\r\n const names = raw\r\n .map((entry) =>\r\n entry && typeof entry === 'object'\r\n ? ((entry as Record<string, unknown>)['displayName'] ?? '')\r\n : entry,\r\n )\r\n .filter((name) => name != null && name !== '');\r\n return names.length ? { displayName: names.join(', ') } : '';\r\n }\r\n if (resolved) {\r\n return {\r\n ...resolved,\r\n displayName: resolved['displayName'] ?? '',\r\n photoUrl: resolved['photoUrl'] ?? resolved['photo'] ?? '',\r\n };\r\n }\r\n if (raw && typeof raw === 'object') {\r\n const user = raw as Record<string, unknown>;\r\n return {\r\n ...user,\r\n displayName: user['displayName'] ?? label ?? '',\r\n photoUrl: user['photoUrl'] ?? user['photo'] ?? '',\r\n };\r\n }\r\n if (raw != null && raw !== '') {\r\n const name = label == null ? String(raw) : String(label);\r\n return { id: String(raw), displayName: name, userName: name };\r\n }\r\n return '';\r\n }\r\n\r\n if (viewType === 'Status' || viewType === 'Lookup') {\r\n if (resolved) return resolved;\r\n if (raw && typeof raw === 'object') return raw;\r\n if (raw != null && raw !== '' && label != null) {\r\n return { key: String(raw), display: String(label), color: '' };\r\n }\r\n return raw ?? '';\r\n }\r\n\r\n if (resolved) return resolved;\r\n\r\n // Translated text: the dialog binds `{ en, ar }`, but the text renderers\r\n // print only the `display` the backend adds to a loaded value — without\r\n // it the cell shows its placeholder.\r\n if (\r\n (viewType === 'Text' || viewType === 'LongText') &&\r\n isTranslatedText(raw)\r\n ) {\r\n return { ...raw, display: resolveLocalizedLabel(raw, this.lang()) };\r\n }\r\n\r\n // Plain / scalar view types: prefer a resolved option label when present,\r\n // else the raw value (unchanged for text / number / date / percentage).\r\n if (label != null && (raw == null || typeof raw !== 'object')) {\r\n return Array.isArray(label) ? label.join(', ') : label;\r\n }\r\n return raw ?? '';\r\n }\r\n\r\n // ============================================================================\r\n // Submit payload (see EntityList.md — \"Stored Value Shape\")\r\n // ============================================================================\r\n\r\n private emitValue(): void {\r\n // `entityIds` / `createdIds` / `updatedIds` / `snapshot`, and the loaded\r\n // `version` / `expectedVersions`, are backend-owned and passed through\r\n // untouched; the frontend only contributes pending rows, delete intents\r\n // and the change's id. `live` is response-only and stays behind.\r\n const { live: _live, ...current } = this.storedValue() ?? {};\r\n // `values[].value` is the backend's rendered label, carried only so the\r\n // table can print it. Submitting it back would echo a user object where\r\n // the stored scalar belongs.\r\n const rows = this.pendingRows().map((row) => ({\r\n ...row,\r\n values: (row.values ?? []).map(({ propertyKey, rawValue }) => ({\r\n propertyKey,\r\n rawValue,\r\n })),\r\n }));\r\n const deletedIds = this.deletedIds();\r\n const next: EntityListStoredValue = {\r\n ...current,\r\n rows,\r\n deletedIds,\r\n ...this.linkedMutationId(current, rows, deletedIds),\r\n };\r\n this.storedValue.set(next);\r\n this.lastEmittedJson = this.echoKey(next);\r\n this.onModelChange(next);\r\n this.onTouched();\r\n }\r\n\r\n /**\r\n * The id of the change a Related list's value carries. The backend rejects\r\n * a Related change without one (`entity_list.invalid_payload`), and the form\r\n * load sends it empty — so a value with rows or deletions gets its own: the\r\n * same while the change is (a retry of the same save), a new one when it\r\n * differs, since reusing an id for other content is refused\r\n * (`entity_list.linked_mutation_reused`). A value with nothing to apply keeps\r\n * what it loaded with; the backend skips it.\r\n */\r\n private linkedMutation: { key: string; id: string } | null = null;\r\n /** The loaded value's `mutationId`, restored once nothing is left to apply. */\r\n private loadedMutationId: string | undefined;\r\n\r\n private linkedMutationId(\r\n current: EntityListStoredValue,\r\n rows: EntityListSubmitRow[],\r\n deletedIds: number[],\r\n ): Pick<\r\n EntityListStoredValue,\r\n 'version' | 'mutationId' | 'expectedVersions'\r\n > {\r\n // `current` is the last emission, which may carry this session's id.\r\n if (rows.length === 0 && deletedIds.length === 0) {\r\n return { mutationId: this.loadedMutationId };\r\n }\r\n const version = Number(current.version ?? 0) || 0;\r\n const key = JSON.stringify({ version, rows, deletedIds });\r\n if (this.linkedMutation?.key !== key) {\r\n this.linkedMutation = { key, id: newLocalUuid() };\r\n }\r\n return {\r\n version,\r\n mutationId: this.linkedMutation.id,\r\n expectedVersions: current.expectedVersions ?? {},\r\n };\r\n }\r\n\r\n /**\r\n * `values[]` entries, restricted to `writeFields` when configured.\r\n *\r\n * `submitShaped` carries the dialog-normalized counterpart of `values`,\r\n * keyed the same way, and is preferred per key. The control value a rich\r\n * field holds is not the scalar the backend stores — a user picker holds\r\n * the whole search result, a date picker a `Date` — and only the dialog\r\n * knows the target module's view types, so it does that reduction. Without\r\n * it we would stringify the control value as-is and the row would carry a\r\n * JSON user object where a bare id belongs.\r\n */\r\n private toSubmitValues(\r\n values: Record<string, unknown>,\r\n submitShaped: Record<string, unknown> = {},\r\n ): EntityListSubmitValue[] {\r\n const allowed = new Set(this.writeFields());\r\n return Object.entries(values)\r\n .filter(([propertyKey]) => allowed.size === 0 || allowed.has(propertyKey))\r\n .map(([propertyKey, value]) => ({\r\n propertyKey,\r\n rawValue: this.toRawValue(\r\n propertyKey in submitShaped ? submitShaped[propertyKey] : value,\r\n ),\r\n }));\r\n }\r\n\r\n /** Backend `rawValue` is a serialized scalar; objects/arrays go as JSON. */\r\n private toRawValue(value: unknown): string | null {\r\n if (value == null || value === '') return null;\r\n if (value instanceof Date) return value.toISOString();\r\n if (typeof value === 'object') return JSON.stringify(value);\r\n return String(value);\r\n }\r\n\r\n private toValueMap(\r\n values: EntityListSubmitValue[] | undefined,\r\n ): Record<string, unknown> {\r\n const map: Record<string, unknown> = {};\r\n for (const value of values ?? []) {\r\n if (!value?.propertyKey) continue;\r\n map[value.propertyKey] = value.rawValue;\r\n }\r\n return map;\r\n }\r\n\r\n /**\r\n * Backend-resolved display values of a loaded row, keyed like `toValueMap`.\r\n *\r\n * A row the user just added carries its labels in a `rowDrafts` entry, but a\r\n * row that arrived on a loaded value has none — only what the backend\r\n * rendered beside each `rawValue`. Without this the approver's table prints\r\n * the stored scalar: a bare GUID where the assignee belongs.\r\n */\r\n private toDisplayMap(\r\n values: EntityListSubmitValue[] | undefined,\r\n ): Record<string, unknown> {\r\n const map: Record<string, unknown> = {};\r\n for (const value of values ?? []) {\r\n if (!value?.propertyKey || value.value === undefined) continue;\r\n map[value.propertyKey] = value.value;\r\n }\r\n return map;\r\n }\r\n\r\n private dropEmptyValues(\r\n values: Record<string, unknown>,\r\n ): Record<string, unknown> {\r\n const next: Record<string, unknown> = {};\r\n for (const [key, value] of Object.entries(values)) {\r\n if (this.isEmptyValue(value)) continue;\r\n next[key] = value;\r\n }\r\n return next;\r\n }\r\n\r\n /**\r\n * Keys the user actually changed. A key that was empty before and is still\r\n * empty is skipped (the dialog simply could not pre-fill it); a key that had\r\n * a value and is now empty is kept so the backend clears it.\r\n *\r\n * `initial` holds stored scalars (a `User` column pre-fills as a bare id)\r\n * while `next` holds control values (the whole picker result), so the two\r\n * are only comparable once reduced — hence comparing `submitShaped`.\r\n * Comparing the rich value directly marked every rich-valued column as\r\n * changed even when untouched, and the partial update then rewrote it.\r\n */\r\n private diffValues(\r\n initial: Record<string, unknown>,\r\n next: Record<string, unknown>,\r\n submitShaped: Record<string, unknown> = {},\r\n ): Record<string, unknown> {\r\n const changed: Record<string, unknown> = {};\r\n for (const [key, value] of Object.entries(next)) {\r\n const before = initial[key];\r\n const comparable = key in submitShaped ? submitShaped[key] : value;\r\n if (this.isEmptyValue(value) && this.isEmptyValue(before)) continue;\r\n if (this.isSameValue(before, comparable)) continue;\r\n changed[key] = value;\r\n }\r\n return changed;\r\n }\r\n\r\n private isEmptyValue(value: unknown): boolean {\r\n if (value == null || value === '') return true;\r\n if (Array.isArray(value)) return value.length === 0;\r\n return false;\r\n }\r\n\r\n private isSameValue(a: unknown, b: unknown): boolean {\r\n if (a === b) return true;\r\n // Values arriving from the read endpoint are serialized; compare the\r\n // submit-shaped representation so \"5\" and 5 are not treated as a change.\r\n return this.toRawValue(a) === this.toRawValue(b);\r\n }\r\n\r\n // ============================================================================\r\n // Read endpoints — GET Properties/{id}/entitylist/table-metadata (columns,\r\n // effective access, canonical keys) + POST fetch/query (rows)\r\n // ============================================================================\r\n\r\n /**\r\n * Load the runtime-scoped table description, then its rows.\r\n *\r\n * The metadata endpoint is the authorization boundary for this field: it\r\n * answers `403` when the user may not read the target module in this level,\r\n * so the columns are never built from a source that skipped that check.\r\n */\r\n private loadTable(\r\n propertyId: number,\r\n levelId: number | string | null,\r\n levelDataId: number | string | null,\r\n ): void {\r\n this.metadataSubscription?.unsubscribe();\r\n this.fetchSubscription?.unsubscribe();\r\n this.metadata.set(null);\r\n this.metadataFailure.set(null);\r\n this.columns.set([]);\r\n this.rows.set([]);\r\n this.comparison.set(null);\r\n this.comparisonUnsupported.set(false);\r\n this.chosenComparisonView.set(null);\r\n this.resetRevisions();\r\n this.errorMessage.set(null);\r\n this.loading.set(false);\r\n if (!(propertyId > 0) || levelId == null || !(Number(levelId) > 0)) return;\r\n\r\n this.loading.set(true);\r\n const ctx = this.context();\r\n this.metadataSubscription = this.http\r\n .get<{ data: EntityListTableMetadata }>(\r\n `Properties/${propertyId}/entitylist/table-metadata`,\r\n {\r\n params: { levelId: String(levelId) },\r\n // `403` (no module read access) and `404` (not configured for this\r\n // level) are states this field renders inline, not failures worth a\r\n // toast from the host's message interceptor.\r\n headers: { noMessage: 'true' },\r\n ...(ctx ? { context: ctx } : {}),\r\n },\r\n )\r\n .pipe(takeUntilDestroyed(this.destroyRef))\r\n .subscribe({\r\n next: (response) => this.applyMetadata(response.data, levelDataId),\r\n error: (error: HttpErrorResponse) => {\r\n this.loading.set(false);\r\n const failure = resolveMetadataFailure(error.status);\r\n this.metadataFailure.set(failure);\r\n // `forbidden` and `unavailable` are rendered as their own notice; only\r\n // a real request failure is an error.\r\n if (failure === 'failed') {\r\n this.errorMessage.set(\r\n this.transloco.translate('components.entityListField.loadFailed'),\r\n );\r\n }\r\n },\r\n });\r\n }\r\n\r\n /**\r\n * Apply the metadata, then fetch rows when there is a persisted parent to\r\n * scope them to. A draft parent (no `levelDataId`) and a write-only field\r\n * both stop at the columns — the first has no records yet, the second may\r\n * not read them.\r\n */\r\n private applyMetadata(\r\n metadata: EntityListTableMetadata,\r\n levelDataId: number | string | null,\r\n ): void {\r\n this.metadata.set(metadata);\r\n\r\n // A Local list's rows are the value; the source module is not read.\r\n if (this.localMode()) {\r\n this.loading.set(false);\r\n return;\r\n }\r\n\r\n this.columns.set(this.buildColumns(metadata));\r\n\r\n // A Selected list's rows are the records in its value. Fetching the source\r\n // module would list every related record, which is exactly what this mode\r\n // is not.\r\n if (this.selectionMode()) {\r\n this.loading.set(false);\r\n return;\r\n }\r\n\r\n const loadSourceRows = () => {\r\n if (\r\n !this.moduleBacked() ||\r\n !this.canRead() ||\r\n levelDataId == null ||\r\n Number(levelDataId) <= 0\r\n ) {\r\n this.loading.set(false);\r\n return;\r\n }\r\n\r\n this.fetchRows(\r\n metadata.levelId,\r\n levelDataId,\r\n metadata.moduleId,\r\n this.projectedKeys(),\r\n );\r\n };\r\n\r\n // A saved Related list opened from outside its form shows its preserved\r\n // or its current values, as configured — not whatever the source holds\r\n // today. An owner the comparison API does not know falls back to that.\r\n if (this.comparisonMode()) {\r\n this.fetchComparison(metadata.propertyId, loadSourceRows);\r\n return;\r\n }\r\n\r\n loadSourceRows();\r\n }\r\n\r\n /**\r\n * Table columns, in the order the backend returned them.\r\n *\r\n * `projectionMeta.columns[].key` is the catalog property key here — the same\r\n * key `fetch/query` keys its record values by — so a column maps onto a row\r\n * value directly. The lookup still falls back to `normalizedKey` so a column\r\n * fed from any other projection keeps resolving.\r\n *\r\n * The columns are the *union* of readable and writable fields, so a\r\n * write-only key arrives as a column too — a `Planned Finish` the user may\r\n * set in the dialog but may not read. It is not projected into the rows and\r\n * would render as an empty column, so only readable keys become columns.\r\n * Write-only access is the exception: its readable set is empty by\r\n * definition, and its stored rows have nothing else to render through.\r\n */\r\n private buildColumns(\r\n metadata: EntityListTableMetadata,\r\n ): EntityListColumnDef[] {\r\n const propertyByKey = new Map<string, FetchPropertyMeta>();\r\n const propertyByNormalizedKey = new Map<string, FetchPropertyMeta>();\r\n for (const property of metadata.catalog?.properties ?? []) {\r\n propertyByKey.set(property.key, property);\r\n propertyByNormalizedKey.set(property.normalizedKey, property);\r\n }\r\n const readable = new Set(metadata.readFields);\r\n\r\n return (metadata.projectionMeta?.columns ?? [])\r\n .filter((column) => column.visible)\r\n .filter((column) => readable.size === 0 || readable.has(column.key))\r\n .sort((a, b) => a.order - b.order)\r\n .map((column) => ({\r\n key: column.key,\r\n label: column.label,\r\n type: 'entity' as const,\r\n sortable: !UNSORTABLE_ENTITY_VIEW_TYPES.has(\r\n column.viewType as EntityViewType,\r\n ),\r\n viewType: column.viewType,\r\n order: column.order,\r\n visible: column.visible,\r\n configuration: column.configuration ?? null,\r\n propertyKey:\r\n (propertyByKey.has(column.key)\r\n ? column.key\r\n : propertyByNormalizedKey.get(column.key)?.key) ?? column.key,\r\n }));\r\n }\r\n\r\n /** Catalog properties of the loaded metadata, keyed by property key. */\r\n private readonly propertyByKey = computed<Map<string, FetchPropertyMeta>>(\r\n () => {\r\n const map = new Map<string, FetchPropertyMeta>();\r\n for (const property of this.metadata()?.catalog?.properties ?? []) {\r\n map.set(property.key, property);\r\n if (!map.has(property.normalizedKey)) {\r\n map.set(property.normalizedKey, property);\r\n }\r\n }\r\n return map;\r\n },\r\n );\r\n\r\n private fetchRows(\r\n levelId: number | string,\r\n levelDataId: number | string,\r\n moduleId: number | string,\r\n propertyKeys: string[],\r\n ): void {\r\n this.loading.set(true);\r\n this.errorMessage.set(null);\r\n\r\n const ctx = this.context();\r\n const body = {\r\n contextKey: `level:${levelId}/module:${moduleId}`,\r\n projection: 'Table' as const,\r\n surfaceKey: 'table',\r\n propertyKeys,\r\n filters: [\r\n {\r\n key: 'levelDataId',\r\n operator: 'Equals',\r\n value: String(levelDataId),\r\n },\r\n ],\r\n page: 1,\r\n pageSize: 3000,\r\n };\r\n\r\n this.fetchSubscription = this.http\r\n .post<FetchQueryResponse | { data?: FetchQueryResponse }>(\r\n 'fetch/query',\r\n body,\r\n ctx ? { context: ctx } : {},\r\n )\r\n .pipe(\r\n takeUntilDestroyed(this.destroyRef),\r\n finalize(() => this.loading.set(false)),\r\n catchError((err) => {\r\n console.error('EntityList fetch/query failed', err);\r\n this.errorMessage.set(\r\n this.transloco.translate('components.entityListField.loadFailed'),\r\n );\r\n return of<FetchQueryResponse>({});\r\n }),\r\n )\r\n .subscribe((response) => {\r\n const payload =\r\n response && typeof response === 'object' && 'data' in response\r\n ? ((response.data as FetchQueryResponse | undefined) ?? response)\r\n : response;\r\n this.applyRecords((payload as FetchQueryResponse).records ?? []);\r\n });\r\n }\r\n\r\n /**\r\n * Project fetched records onto the metadata columns.\r\n *\r\n * Cells are built per rendered column, but the row's value maps cover every\r\n * **projected** key — a writable key without a column has no cell to render\r\n * and still has to reach the edit dialog and the update diff.\r\n */\r\n private applyRecords(records: FetchRecord[]): void {\r\n const properties = this.propertyByKey();\r\n const columns = this.columns();\r\n const valueKeys = [\r\n ...new Set([\r\n ...this.projectedKeys(),\r\n ...columns.map((column) => column.propertyKey ?? column.key),\r\n ]),\r\n ];\r\n const viewTypeByKey = new Map(\r\n columns.map((column) => [\r\n column.propertyKey ?? column.key,\r\n column.viewType,\r\n ]),\r\n );\r\n\r\n this.rows.set(\r\n records.map((record) => {\r\n const values: Record<string, unknown> = {};\r\n const prefill: Record<string, unknown> = {};\r\n const row: EntityListRow = {\r\n Id: record.id,\r\n [ROW_ID_KEY]: `entity-${record.id}`,\r\n [ROW_ENTITY_ID_KEY]: record.id,\r\n };\r\n for (const column of columns) {\r\n const propertyKey = column.propertyKey ?? column.key;\r\n row[column.key] = this.toEntityData(\r\n column,\r\n record.values?.[propertyKey],\r\n properties.get(propertyKey),\r\n record.id,\r\n );\r\n }\r\n for (const key of valueKeys) {\r\n const cell = record.values?.[key];\r\n const viewType =\r\n viewTypeByKey.get(key) ?? properties.get(key)?.viewType ?? '';\r\n // Keep the machine-readable value as the baseline a partial update is\r\n // diffed against — it is the shape the row submits.\r\n values[key] = cell?.raw ?? cell?.value ?? null;\r\n // What the edit dialog patches into its form, which is not always the\r\n // same thing: see OBJECT_VALUED_VIEW_TYPES.\r\n if (OBJECT_VALUED_VIEW_TYPES.has(viewType)) {\r\n prefill[key] = cell?.value ?? cell?.raw ?? null;\r\n } else if (viewType === 'Checkbox') {\r\n // Stored as text (`'True'`/`'False'`), while `mt-toggle-field`\r\n // only shows a switch on as a strict `true` — see\r\n // `coerceCheckboxValue`.\r\n prefill[key] = coerceCheckboxValue(values[key]);\r\n } else {\r\n prefill[key] = values[key];\r\n }\r\n }\r\n row[ROW_VALUES_KEY] = values;\r\n row[ROW_PREFILL_KEY] = prefill;\r\n return row;\r\n }),\r\n );\r\n }\r\n\r\n private toEntityData(\r\n column: EntityListColumnDef,\r\n cell: FetchValueCell | undefined,\r\n property: FetchPropertyMeta | undefined,\r\n recordId: number,\r\n ): EntityData {\r\n return {\r\n id: recordId,\r\n propertyId: property?.id,\r\n key: property?.key ?? column.key,\r\n normalizedKey: property?.normalizedKey ?? column.key,\r\n name: column.label ?? property?.label ?? column.key,\r\n rawValue: serializeEntityRawValue(cell?.raw),\r\n color: readEntityValueColor(cell?.color),\r\n value: (cell?.value ?? '') as EntityData['value'],\r\n viewType: (column.viewType ?? 'Text') as EntityData['viewType'],\r\n type: property?.source,\r\n order: column.order ?? property?.order,\r\n configuration: column.configuration as\r\n | EntityData['configuration']\r\n | undefined,\r\n propertyConfiguration: property?.configuration ?? undefined,\r\n comparison: cell?.comparison,\r\n };\r\n }\r\n}\r\n","<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 (localReady()) {\r\n <!--\r\n A Local list: rows owned by this record, staged into its own submission.\r\n Add / edit / delete / drag follow the Local operation switches. Opened\r\n from a table cell, it can also show a saved revision's rows instead.\r\n -->\r\n @if (historyAvailable()) {\r\n <ng-container [ngTemplateOutlet]=\"history\" />\r\n }\r\n @if (showingRevision()) {\r\n <section\r\n class=\"flex flex-col gap-2 transition-opacity\"\r\n [class.opacity-60]=\"revisionLoading()\"\r\n >\r\n <ng-container [ngTemplateOutlet]=\"preservedHeading\" />\r\n @if (revisionLocalRows().length) {\r\n <mt-table\r\n [noCard]=\"true\"\r\n [data]=\"revisionLocalRows()\"\r\n [columns]=\"revisionLocalColumns()\"\r\n dataKey=\"Id\"\r\n />\r\n } @else {\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.preservedEmpty\" | transloco }}\r\n </div>\r\n }\r\n </section>\r\n } @else {\r\n @if (localCanCreate()) {\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)=\"openLocalRowDialog()\"\r\n />\r\n </div>\r\n }\r\n @if (localTableRows().length || localCanCreate()) {\r\n <mt-table\r\n [noCard]=\"true\"\r\n [data]=\"localTableRows()\"\r\n [columns]=\"localColumns()\"\r\n [rowActions]=\"localRowActions()\"\r\n [reorderableRows]=\"localCanReorder()\"\r\n (rowReorder)=\"onLocalReorder($event)\"\r\n dataKey=\"Id\"\r\n />\r\n } @else {\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.noLocalRows\" | transloco }}\r\n </div>\r\n }\r\n }\r\n } @else if (selectionReady()) {\r\n <!--\r\n A Selected list: the source records picked for this record, and nothing\r\n else. Picking and removing change only which records it holds. Opened\r\n from a table cell, a saved revision compares the records it held then\r\n with their values today.\r\n -->\r\n @if (historyAvailable()) {\r\n <ng-container [ngTemplateOutlet]=\"history\" />\r\n }\r\n @if (showingRevision()) {\r\n <ng-container [ngTemplateOutlet]=\"comparisonSections\" />\r\n } @else {\r\n @if (selectionWritable()) {\r\n <div class=\"flex justify-end\">\r\n <mt-button\r\n [label]=\"'components.entityListField.selectRecords' | transloco\"\r\n icon=\"general.plus\"\r\n size=\"small\"\r\n [disabled]=\"disabled()\"\r\n (onClick)=\"openSelectionDialog()\"\r\n />\r\n </div>\r\n }\r\n @if (selectionRows().length) {\r\n <mt-table\r\n [noCard]=\"true\"\r\n [data]=\"selectionRows()\"\r\n [columns]=\"columns()\"\r\n [rowActions]=\"selectionRowActions()\"\r\n dataKey=\"Id\"\r\n />\r\n } @else {\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.noSelectedRecords\" | transloco }}\r\n </div>\r\n }\r\n }\r\n } @else if (comparisonMode()) {\r\n <!--\r\n A saved Related list opened from outside its form: its sources' current\r\n values, and the values preserved when it was saved. A missing baseline is\r\n said as such — it is not an empty list.\r\n -->\r\n @if (!comparisonReady()) {\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 {\r\n @if (historyAvailable()) {\r\n <ng-container [ngTemplateOutlet]=\"history\" />\r\n }\r\n <ng-container [ngTemplateOutlet]=\"comparisonSections\" />\r\n }\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\r\n<!--\r\n Saved list revisions: each successful save of this list, newest first.\r\n Picking one shows what it preserved — beside today's values of the records\r\n it held, for a linked list. Read-only: history is never submitted.\r\n-->\r\n<ng-template #history>\r\n <div class=\"flex flex-wrap items-center justify-between gap-2\">\r\n <div class=\"flex flex-wrap items-center gap-2\">\r\n @if (viewedRevision(); as version) {\r\n <span\r\n class=\"rounded-md border border-primary-200 bg-primary-50 px-2 py-0.5 text-xs font-medium text-primary-700\"\r\n >\r\n {{\r\n \"components.entityListField.viewingRevision\"\r\n | transloco: { version: version }\r\n }}\r\n </span>\r\n <mt-button\r\n [label]=\"'components.entityListField.backToLatest' | transloco\"\r\n size=\"small\"\r\n variant=\"text\"\r\n [disabled]=\"revisionLoading()\"\r\n (onClick)=\"showRevision(null)\"\r\n />\r\n }\r\n </div>\r\n <mt-button\r\n [label]=\"'components.entityListField.revisions' | transloco\"\r\n icon=\"time.clock-rewind\"\r\n size=\"small\"\r\n severity=\"secondary\"\r\n variant=\"outlined\"\r\n (onClick)=\"toggleRevisions()\"\r\n />\r\n </div>\r\n\r\n @if (revisionsOpen()) {\r\n <div\r\n class=\"flex flex-col gap-2 rounded-md border border-surface bg-surface-50 p-3\"\r\n >\r\n <p class=\"text-xs text-muted-color\">\r\n {{ \"components.entityListField.revisionsHint\" | transloco }}\r\n </p>\r\n @if (revisionsError(); as message) {\r\n <p class=\"text-sm text-red-600\">{{ message }}</p>\r\n }\r\n @for (revision of revisionItems(); track revision.version) {\r\n <button\r\n type=\"button\"\r\n class=\"flex items-center justify-between gap-3 rounded-md border px-3 py-2 text-start text-sm transition-colors\"\r\n [class.border-primary-200]=\"viewedRevision() === revision.version\"\r\n [class.bg-primary-50]=\"viewedRevision() === revision.version\"\r\n [class.border-surface]=\"viewedRevision() !== revision.version\"\r\n [class.bg-content]=\"viewedRevision() !== revision.version\"\r\n [disabled]=\"revisionLoading()\"\r\n (click)=\"showRevision(revision.version)\"\r\n >\r\n <span class=\"font-medium text-color\">\r\n {{\r\n \"components.entityListField.revisionLabel\"\r\n | transloco: { version: revision.version }\r\n }}\r\n </span>\r\n <span\r\n class=\"flex min-w-0 flex-wrap items-center justify-end gap-x-2 text-xs text-muted-color\"\r\n >\r\n <span class=\"truncate\">{{ revision.author }}</span>\r\n <span>{{ revision.createdAt | mtDateFormat: \"dateTime\" }}</span>\r\n </span>\r\n </button>\r\n } @empty {\r\n @if (!revisionsLoading() && !revisionsError()) {\r\n <p class=\"text-sm text-muted-color\">\r\n {{ \"components.entityListField.noRevisions\" | transloco }}\r\n </p>\r\n }\r\n }\r\n @if (revisionsLoading()) {\r\n <p-skeleton width=\"100%\" height=\"2.25rem\" borderRadius=\"0.375rem\" />\r\n } @else if (hasMoreRevisions()) {\r\n <div class=\"flex justify-center\">\r\n <mt-button\r\n [label]=\"'components.entityListField.loadMore' | transloco\"\r\n size=\"small\"\r\n variant=\"text\"\r\n (onClick)=\"loadRevisions()\"\r\n />\r\n </div>\r\n }\r\n </div>\r\n }\r\n\r\n @if (revisionError(); as message) {\r\n <div\r\n class=\"rounded-md border border-red-200 bg-red-50 p-3 text-sm text-red-700\"\r\n >\r\n {{ message }}\r\n </div>\r\n }\r\n</ng-template>\r\n\r\n<!-- \"Preserved values\", with when they were captured. -->\r\n<ng-template #preservedHeading>\r\n <h4\r\n class=\"flex flex-wrap items-baseline gap-2 text-sm font-semibold text-color\"\r\n >\r\n {{ \"components.entityListField.preservedValues\" | transloco }}\r\n @if (preservedAt(); as capturedAt) {\r\n <span class=\"text-xs font-normal text-muted-color\">\r\n {{\r\n \"components.entityListField.preservedAt\"\r\n | transloco: { date: (capturedAt | mtDateFormat: \"dateTime\") }\r\n }}\r\n </span>\r\n }\r\n </h4>\r\n</ng-template>\r\n\r\n<!--\r\n A linked list's comparison, one table at a time: the values preserved when\r\n it was saved, or its source records' current values. It opens on the\r\n property's configured mode. A missing baseline says so — it is never\r\n replaced by the current values.\r\n-->\r\n<ng-template #comparisonSections>\r\n <div class=\"flex flex-wrap items-center justify-between gap-2\">\r\n <mt-tabs\r\n size=\"small\"\r\n [options]=\"comparisonViewOptions()\"\r\n [active]=\"comparisonView()\"\r\n (onChange)=\"setComparisonView($event)\"\r\n />\r\n @if (comparisonView() === \"preserved\" && preservedAvailable()) {\r\n @if (preservedAt(); as capturedAt) {\r\n <span class=\"text-xs text-muted-color\">\r\n {{\r\n \"components.entityListField.preservedAt\"\r\n | transloco: { date: (capturedAt | mtDateFormat: \"dateTime\") }\r\n }}\r\n </span>\r\n }\r\n }\r\n </div>\r\n\r\n <section\r\n class=\"flex flex-col gap-2 transition-opacity\"\r\n [class.opacity-60]=\"revisionLoading()\"\r\n >\r\n @if (comparisonView() === \"current\") {\r\n @if (liveRows().length) {\r\n <mt-table\r\n [noCard]=\"true\"\r\n [data]=\"liveRows()\"\r\n [columns]=\"columns()\"\r\n dataKey=\"Id\"\r\n />\r\n } @else {\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 }\r\n } @else if (!preservedAvailable()) {\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.noPreservedSnapshot\" | transloco }}\r\n </div>\r\n } @else if (preservedRows().length) {\r\n <mt-table\r\n [noCard]=\"true\"\r\n [data]=\"preservedRows()\"\r\n [columns]=\"columns()\"\r\n dataKey=\"Id\"\r\n />\r\n } @else {\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.preservedEmpty\" | transloco }}\r\n </div>\r\n }\r\n </section>\r\n\r\n @if (unavailableCount()) {\r\n <p class=\"text-xs text-muted-color\">\r\n {{\r\n \"components.entityListField.unavailableRecords\"\r\n | transloco: { count: unavailableCount() }\r\n }}\r\n </p>\r\n }\r\n</ng-template>\r\n","import { Provider } from '@angular/core';\r\nimport { ENTITY_LIST_TABLE_COMPONENT } from '@masterteam/components/entities';\r\nimport { EntityListField } from './entity-list-field';\r\n\r\n/**\r\n * Lets `mt-entity-list-preview` render a module-backed `EntityList` as the\r\n * real, fetched table instead of its count-and-drawer trigger.\r\n *\r\n * Pair it with an `EntityRuntimeContextStore` carrying the owning level and\r\n * level-data ids — the preview needs both, and without the context this\r\n * provider changes nothing. `mt-client-instance-preview` sets both up, so a\r\n * host rendering preview cards through it needs neither.\r\n *\r\n * The indirection exists because `entities` cannot import `table`: `table`\r\n * already imports `entities`, and they are separate entry points of\r\n * `@masterteam/components`. See `ENTITY_LIST_TABLE_COMPONENT`.\r\n *\r\n * ```ts\r\n * @Component({\r\n * providers: [EntityRuntimeContextStore, provideEntityListTablePreview()],\r\n * })\r\n * ```\r\n */\r\nexport function provideEntityListTablePreview(): Provider {\r\n return { provide: ENTITY_LIST_TABLE_COMPONENT, useValue: EntityListField };\r\n}\r\n","import {\r\n ChangeDetectionStrategy,\r\n Component,\r\n computed,\r\n DestroyRef,\r\n effect,\r\n inject,\r\n input,\r\n signal,\r\n untracked,\r\n} from '@angular/core';\r\nimport { takeUntilDestroyed } from '@angular/core/rxjs-interop';\r\nimport {\r\n ControlValueAccessor,\r\n FormsModule,\r\n NgControl,\r\n Validators,\r\n} from '@angular/forms';\r\nimport { HttpClient, HttpContext, HttpParams } from '@angular/common/http';\r\nimport {\r\n EMPTY,\r\n Observable,\r\n catchError,\r\n expand,\r\n finalize,\r\n map,\r\n of,\r\n reduce,\r\n} from 'rxjs';\r\nimport { MultiSelectField } from '@masterteam/components/multi-select-field';\r\nimport { SelectField } from '@masterteam/components/select-field';\r\nimport type { ScheduleItemSelectorFieldRuntimeContext } from '@masterteam/components';\r\n\r\n/** One picker option — only the name is shown. */\r\ninterface ScheduleItemOption {\r\n label: string;\r\n value: number;\r\n}\r\n\r\ninterface ScheduleItemSelectorOptionsResponse {\r\n data?: {\r\n items?: Array<{ key: string; name: string }> | null;\r\n hasMore?: boolean;\r\n } | null;\r\n}\r\n\r\n/** Page size when loading the full deliverable list, and a hard safety cap. */\r\nconst PAGE_SIZE = 100;\r\nconst MAX_ITEMS = 5000;\r\n\r\n/**\r\n * Runtime picker for `ScheduleItemSelector` properties.\r\n *\r\n * Backend-filtered: the full option list comes from\r\n * `GET forms/options/{propertyKey}` (which applies the configured rule, e.g.\r\n * `DeliverableAcceptance.AvailableDeliverables`). All available items are\r\n * loaded up front and rendered with the standard `mt-select-field` /\r\n * `mt-multi-select-field`; the field shows only the item name.\r\n *\r\n * The control value is always a numeric id array (`valueMode = \"IdArray\"`).\r\n * In `Single` mode only one id may be selected.\r\n */\r\n@Component({\r\n selector: 'mt-schedule-item-selector-field',\r\n standalone: true,\r\n imports: [FormsModule, MultiSelectField, SelectField],\r\n templateUrl: './schedule-item-selector-field.html',\r\n changeDetection: ChangeDetectionStrategy.OnPush,\r\n host: {\r\n class: 'block',\r\n },\r\n})\r\nexport class ScheduleItemSelectorField implements ControlValueAccessor {\r\n readonly label = input<string>('');\r\n readonly placeholder = input<string>('');\r\n readonly readonly = input<boolean>(false);\r\n readonly required = input<boolean>(false);\r\n readonly propertyKey = input<string>('');\r\n readonly selectionMode = input<'Single' | 'Multi'>('Multi');\r\n readonly runtimeContext =\r\n input<ScheduleItemSelectorFieldRuntimeContext | null>(null);\r\n readonly context = input<HttpContext | undefined>(undefined);\r\n\r\n /** Full list of available deliverables (loaded once). */\r\n readonly options = signal<ScheduleItemOption[]>([]);\r\n readonly loading = signal(false);\r\n readonly disabled = signal(false);\r\n /** Selected ids — the control value (`number[]`). */\r\n readonly value = signal<number[]>([]);\r\n\r\n readonly isMultiple = computed(() => this.selectionMode() !== 'Single');\r\n /** Single-mode ngModel value (a scalar id, not an array). */\r\n readonly singleValue = computed(() => this.value()[0] ?? null);\r\n\r\n public ngControl: NgControl | null = null;\r\n\r\n onTouched: () => void = () => {};\r\n onModelChange: (value: number[] | null) => void = () => {};\r\n\r\n private readonly http = inject(HttpClient);\r\n private readonly destroyRef = inject(DestroyRef);\r\n /** Query signature already loaded — prevents duplicate full loads. */\r\n private loadedKey: string | null = null;\r\n\r\n constructor() {\r\n this.ngControl = inject(NgControl, { self: true, optional: true });\r\n if (this.ngControl) {\r\n this.ngControl.valueAccessor = this;\r\n }\r\n\r\n effect(() => {\r\n if (this.ngControl?.control && this.required()) {\r\n this.ngControl.control.addValidators(Validators.required);\r\n this.ngControl.control.updateValueAndValidity();\r\n }\r\n });\r\n\r\n // Load the full option list as soon as the query context is available.\r\n effect(() => {\r\n const key = this.queryKey();\r\n if (!key || this.loadedKey === key) return;\r\n untracked(() => this.loadAllOptions(key));\r\n });\r\n }\r\n\r\n // ── Selection ──────────────────────────────────────────────────────────\r\n\r\n onMultiChange(ids: number[] | null): void {\r\n this.value.set(ids ?? []);\r\n this.emit();\r\n }\r\n\r\n onSingleChange(id: number | null): void {\r\n this.value.set(id == null ? [] : [id]);\r\n this.emit();\r\n }\r\n\r\n // ── ControlValueAccessor ────────────────────────────────────────────────\r\n\r\n writeValue(value: unknown): void {\r\n this.value.set(this.normalizeIds(value));\r\n }\r\n\r\n registerOnChange(fn: (value: number[] | null) => void): void {\r\n this.onModelChange = fn;\r\n }\r\n\r\n registerOnTouched(fn: () => void): void {\r\n this.onTouched = fn;\r\n }\r\n\r\n setDisabledState(disabled: boolean): void {\r\n this.disabled.set(disabled);\r\n }\r\n\r\n // ── Option loading ──────────────────────────────────────────────────────\r\n\r\n private loadAllOptions(key: string): void {\r\n this.loadedKey = key;\r\n this.loading.set(true);\r\n\r\n this.fetchPage(0)\r\n .pipe(\r\n expand((page) =>\r\n page.hasMore && page.nextSkip < MAX_ITEMS\r\n ? this.fetchPage(page.nextSkip)\r\n : EMPTY,\r\n ),\r\n reduce(\r\n (acc, page) => acc.concat(page.options),\r\n [] as ScheduleItemOption[],\r\n ),\r\n takeUntilDestroyed(this.destroyRef),\r\n finalize(() => this.loading.set(false)),\r\n catchError(() => of([] as ScheduleItemOption[])),\r\n )\r\n .subscribe((options) => this.options.set(options));\r\n }\r\n\r\n private fetchPage(skip: number): Observable<{\r\n options: ScheduleItemOption[];\r\n hasMore: boolean;\r\n nextSkip: number;\r\n }> {\r\n const params = this.buildParams(skip);\r\n if (!params) {\r\n return of({ options: [], hasMore: false, nextSkip: skip });\r\n }\r\n\r\n return this.http\r\n .get<ScheduleItemSelectorOptionsResponse>(\r\n `forms/options/${encodeURIComponent(this.propertyKey())}`,\r\n { params, context: this.context() },\r\n )\r\n .pipe(\r\n map((response) => ({\r\n options: this.mapOptions(response),\r\n hasMore: !!response?.data?.hasMore,\r\n nextSkip: skip + PAGE_SIZE,\r\n })),\r\n );\r\n }\r\n\r\n private buildParams(skip: number): HttpParams | null {\r\n const contextKey = this.buildContextKey();\r\n const levelDataId = this.runtimeContext()?.levelDataId;\r\n if (!contextKey || levelDataId == null) return null;\r\n\r\n let params = new HttpParams()\r\n .set('contextKey', contextKey)\r\n .set('levelDataId', String(levelDataId))\r\n .set('skip', String(skip))\r\n .set('take', String(PAGE_SIZE));\r\n\r\n const ownerRecordId = this.runtimeContext()?.ownerRecordId;\r\n if (ownerRecordId != null) {\r\n params = params.set('ownerRecordId', String(ownerRecordId));\r\n }\r\n return params;\r\n }\r\n\r\n private mapOptions(\r\n response: ScheduleItemSelectorOptionsResponse,\r\n ): ScheduleItemOption[] {\r\n const items = response?.data?.items ?? [];\r\n return items\r\n .map((item) => {\r\n const id = Number(item.key);\r\n if (!Number.isFinite(id)) return null;\r\n return { label: item.name || String(id), value: id };\r\n })\r\n .filter((option): option is ScheduleItemOption => option != null);\r\n }\r\n\r\n // ── Context helpers ─────────────────────────────────────────────────────\r\n\r\n private buildContextKey(): string | null {\r\n const levelId = this.runtimeContext()?.levelId;\r\n const moduleId = this.runtimeContext()?.moduleId;\r\n if (levelId == null || moduleId == null) return null;\r\n return `Level:${levelId}/Module:${moduleId}`;\r\n }\r\n\r\n private queryKey(): string | null {\r\n const contextKey = this.buildContextKey();\r\n const levelDataId = this.runtimeContext()?.levelDataId;\r\n const propertyKey = this.propertyKey();\r\n if (!contextKey || levelDataId == null || !propertyKey) return null;\r\n const ownerRecordId = this.runtimeContext()?.ownerRecordId ?? '';\r\n return `${contextKey}|${levelDataId}|${ownerRecordId}|${propertyKey}`;\r\n }\r\n\r\n private emit(): void {\r\n this.onModelChange(this.value());\r\n this.onTouched();\r\n }\r\n\r\n private normalizeIds(value: unknown): number[] {\r\n const raw = Array.isArray(value) ? value : value == null ? [] : [value];\r\n const ids: number[] = [];\r\n for (const entry of raw) {\r\n const id =\r\n entry && typeof entry === 'object'\r\n ? Number((entry as { id?: unknown }).id)\r\n : Number(entry);\r\n if (Number.isFinite(id) && id > 0 && !ids.includes(id)) {\r\n ids.push(id);\r\n }\r\n }\r\n return ids;\r\n }\r\n}\r\n","@if (isMultiple()) {\r\n <mt-multi-select-field\r\n [label]=\"label()\"\r\n [placeholder]=\"placeholder()\"\r\n [options]=\"options()\"\r\n [optionLabel]=\"'label'\"\r\n [optionValue]=\"'value'\"\r\n [filter]=\"options().length > 10\"\r\n [showClear]=\"!required()\"\r\n [required]=\"required()\"\r\n [readonly]=\"readonly() || disabled()\"\r\n [ngModel]=\"value()\"\r\n [ngModelOptions]=\"{ standalone: true }\"\r\n (ngModelChange)=\"onMultiChange($event)\"\r\n />\r\n} @else {\r\n <mt-select-field\r\n [label]=\"label()\"\r\n [placeholder]=\"placeholder()\"\r\n [options]=\"options()\"\r\n [optionLabel]=\"'label'\"\r\n [optionValue]=\"'value'\"\r\n [filter]=\"options().length > 10\"\r\n [showClear]=\"!required()\"\r\n [loading]=\"loading()\"\r\n [required]=\"required()\"\r\n [readonly]=\"readonly() || disabled()\"\r\n [ngModel]=\"singleValue()\"\r\n [ngModelOptions]=\"{ standalone: true }\"\r\n (ngModelChange)=\"onSingleChange($event)\"\r\n />\r\n}\r\n","import { InjectionToken, Type } from '@angular/core';\r\nimport type { LookupOptionItemConfig } from '@masterteam/components';\r\n\r\n/**\r\n * Inputs for the injected checklist form (one instance per field). It loads the\r\n * scope module form once and renders a collapsible section per lookup item.\r\n * Passed via `ngComponentOutlet` inputs.\r\n */\r\nexport interface LookupCheckListFormInputs {\r\n /** Lookup items rendered as collapsible sections. */\r\n lookupOptions: LookupOptionItemConfig[];\r\n /** Full lookup catalog used to resolve nested lookup fields. */\r\n lookups: unknown[];\r\n /** Property keys to render in each section form. */\r\n propertyKeys: string[];\r\n /** Scope module id whose form is loaded once via `process-form-load`. */\r\n moduleId: number | string | null;\r\n /** Current level id. */\r\n levelId: number | string | null;\r\n /** Current workspace instance id. */\r\n levelDataId: number | string | null;\r\n /** Current aggregated value (array of `{ lookupKey, props }`). */\r\n value: unknown;\r\n /** Whether the field is read-only. */\r\n readonly: boolean;\r\n /** Called whenever the aggregated checklist value changes. */\r\n valueChange: (value: unknown) => void;\r\n /** Called whenever the aggregated validity changes (true = incomplete). */\r\n validityChange: (invalid: boolean) => void;\r\n}\r\n\r\n/**\r\n * Token used by `mt-lookup-module-check-list-field` to render the checklist\r\n * sections + per-section forms via `@masterteam/forms`'s `mt-client-form`\r\n * machinery (`/api/process-form-load`, loaded once). Apps register it with\r\n * `provideLookupModuleCheckListForm()` from\r\n * `@masterteam/forms/lookup-module-check-list-form`. When the token is not\r\n * registered, the field falls back to plain text inputs per property.\r\n */\r\nexport const LOOKUP_CHECK_LIST_FORM_COMPONENT = new InjectionToken<\r\n Type<unknown>\r\n>('LOOKUP_CHECK_LIST_FORM_COMPONENT');\r\n","import {\r\n ChangeDetectionStrategy,\r\n Component,\r\n computed,\r\n inject,\r\n input,\r\n OnInit,\r\n signal,\r\n} from '@angular/core';\r\nimport { NgComponentOutlet } from '@angular/common';\r\nimport {\r\n AbstractControl,\r\n ControlValueAccessor,\r\n FormsModule,\r\n NgControl,\r\n ValidatorFn,\r\n} from '@angular/forms';\r\nimport { TranslocoPipe } from '@jsverse/transloco';\r\nimport { InputTextModule } from 'primeng/inputtext';\r\n\r\nimport { Icon } from '@masterteam/icons';\r\nimport { FieldValidation } from '@masterteam/components/field-validation';\r\nimport type {\r\n LookupCheckListPropertyConfig,\r\n LookupModuleCheckListFieldRuntimeContext,\r\n LookupOptionItemConfig,\r\n} from '@masterteam/components';\r\n\r\nimport {\r\n LOOKUP_CHECK_LIST_FORM_COMPONENT,\r\n type LookupCheckListFormInputs,\r\n} from './lookup-module-check-list-form-token';\r\n\r\n/** Stored entry as persisted in the property value array. */\r\ninterface StoredCheckListProp {\r\n key: string;\r\n value: unknown;\r\n}\r\ninterface StoredCheckListEntry {\r\n lookupKey: string;\r\n props: StoredCheckListProp[];\r\n}\r\n\r\n/** A collapsible section bound to one lookup item. */\r\ninterface CheckListSection {\r\n lookupKey: string;\r\n label: string;\r\n}\r\n\r\n@Component({\r\n selector: 'mt-lookup-module-check-list-field',\r\n standalone: true,\r\n imports: [\r\n FormsModule,\r\n NgComponentOutlet,\r\n InputTextModule,\r\n Icon,\r\n FieldValidation,\r\n TranslocoPipe,\r\n ],\r\n templateUrl: './lookup-module-check-list-field.html',\r\n changeDetection: ChangeDetectionStrategy.OnPush,\r\n host: { class: 'grid gap-2' },\r\n})\r\nexport class LookupModuleCheckListField\r\n implements ControlValueAccessor, OnInit\r\n{\r\n readonly label = input<string>('');\r\n readonly readonly = input<boolean>(false);\r\n readonly required = input<boolean>(false);\r\n /** Lookup items rendered as collapsible checklist sections. */\r\n readonly lookupOptions = input<LookupOptionItemConfig[]>([]);\r\n /** Full lookup catalog passed to the rich nested form renderer. */\r\n readonly lookups = input<unknown[]>([]);\r\n /** Module property keys/labels (used by the text fallback + labels). */\r\n readonly propertyFields = input<LookupCheckListPropertyConfig[]>([]);\r\n /** Scope module id whose form is loaded for each section. */\r\n readonly scopeId = input<number | string | null>(null);\r\n /** Property keys to render in each section form. */\r\n readonly propertyKeys = input<string[]>([]);\r\n /** Runtime ids needed to load each section form. */\r\n readonly runtimeContext =\r\n input<LookupModuleCheckListFieldRuntimeContext | null>(null);\r\n\r\n /** Per-lookupKey captured values, keyed by property key. */\r\n private readonly sectionValues = signal<\r\n Record<string, Record<string, unknown>>\r\n >({});\r\n private readonly expandedKeys = signal<Set<string>>(new Set());\r\n protected readonly disabled = signal<boolean>(false);\r\n /** True when a section's required inner fields are unfilled. */\r\n private readonly incomplete = signal<boolean>(false);\r\n public ngControl: NgControl | null = null;\r\n\r\n /**\r\n * Rich checklist form provided by `@masterteam/forms`\r\n * (`provideLookupModuleCheckListForm()`). When absent the field falls back to\r\n * plain text inputs per property.\r\n */\r\n protected readonly formComponent = inject(LOOKUP_CHECK_LIST_FORM_COMPONENT, {\r\n optional: true,\r\n });\r\n\r\n protected readonly isReadonly = computed(\r\n () => this.readonly() || this.disabled(),\r\n );\r\n\r\n protected readonly sections = computed<CheckListSection[]>(() =>\r\n this.lookupOptions().map((option) => ({\r\n lookupKey: String(option.value ?? option.key ?? ''),\r\n label: option.label ?? String(option.value ?? option.key ?? ''),\r\n })),\r\n );\r\n\r\n /**\r\n * Use the rich form whenever it's registered and a scope module is set. The\r\n * scope form only needs `scopeId` to load its field definitions; `levelId` /\r\n * `levelDataId` are passed when available but are not required (e.g. they are\r\n * null while creating a brand-new Level instance).\r\n */\r\n protected readonly useRichForm = computed(\r\n () => !!this.formComponent && this.scopeId() != null,\r\n );\r\n\r\n /**\r\n * The last externally-written value (via `writeValue`). Passed to the rich\r\n * form as its initial value. It is intentionally NOT updated from the form's\r\n * own `valueChange` — feeding emitted values back as an input would create an\r\n * infinite change-detection loop.\r\n */\r\n private readonly incomingValue = signal<unknown>(null);\r\n\r\n private onTouched: () => void = () => {};\r\n private onModelChange: (value: StoredCheckListEntry[] | null) => void =\r\n () => {};\r\n\r\n private control: AbstractControl | null = null;\r\n private validatorAttached = false;\r\n /**\r\n * Validator attached imperatively to the host control. Attaching it here\r\n * (rather than via an `NG_VALIDATORS` provider) avoids a circular dependency\r\n * with the self-injected `NgControl` used as the value accessor.\r\n */\r\n private readonly checklistValidator: ValidatorFn = () =>\r\n this.incomplete() ? { checklistIncomplete: true } : null;\r\n\r\n /** Stable callbacks so the outlet inputs object stays referentially calm. */\r\n private readonly emitValue = (value: unknown): void => {\r\n // The rich form is the source of truth; forward its value without writing\r\n // back into `incomingValue` (which would re-feed the form and loop).\r\n this.onModelChange((value as StoredCheckListEntry[] | null) ?? null);\r\n this.onTouched();\r\n };\r\n private readonly emitValidity = (invalid: boolean): void => {\r\n if (this.incomplete() === invalid) return;\r\n this.incomplete.set(invalid);\r\n this.ensureValidator();\r\n this.control?.updateValueAndValidity({ emitEvent: false });\r\n };\r\n\r\n constructor() {\r\n this.ngControl = inject(NgControl, { self: true, optional: true });\r\n if (this.ngControl) {\r\n this.ngControl.valueAccessor = this;\r\n }\r\n }\r\n\r\n ngOnInit(): void {\r\n this.ensureValidator();\r\n this.control?.updateValueAndValidity({ emitEvent: false });\r\n }\r\n\r\n private ensureValidator(): void {\r\n if (this.validatorAttached) return;\r\n const control = this.ngControl?.control;\r\n if (!control) return;\r\n this.control = control;\r\n control.addValidators(this.checklistValidator);\r\n this.validatorAttached = true;\r\n }\r\n\r\n // ============================================================================\r\n // CVA\r\n // ============================================================================\r\n\r\n writeValue(value: unknown): void {\r\n this.incomingValue.set(value);\r\n this.sectionValues.set(this.normalizeIncoming(value));\r\n }\r\n\r\n registerOnChange(fn: (value: StoredCheckListEntry[] | null) => void): void {\r\n this.onModelChange = fn;\r\n }\r\n\r\n registerOnTouched(fn: () => void): void {\r\n this.onTouched = fn;\r\n }\r\n\r\n setDisabledState(isDisabled: boolean): void {\r\n this.disabled.set(isDisabled);\r\n }\r\n\r\n // ============================================================================\r\n // Rich form host\r\n // ============================================================================\r\n\r\n protected readonly formInputs = computed<LookupCheckListFormInputs>(() => ({\r\n lookupOptions: this.lookupOptions(),\r\n lookups: this.lookups(),\r\n propertyKeys: this.propertyKeys(),\r\n moduleId: this.scopeId(),\r\n levelId: this.runtimeContext()?.levelId ?? null,\r\n levelDataId: this.runtimeContext()?.levelDataId ?? null,\r\n value: this.incomingValue(),\r\n readonly: this.isReadonly(),\r\n valueChange: this.emitValue,\r\n validityChange: this.emitValidity,\r\n }));\r\n\r\n // ============================================================================\r\n // Text fallback (no rich form registered)\r\n // ============================================================================\r\n\r\n protected isExpanded(lookupKey: string): boolean {\r\n return this.expandedKeys().has(lookupKey);\r\n }\r\n\r\n protected toggle(lookupKey: string): void {\r\n const next = new Set(this.expandedKeys());\r\n if (next.has(lookupKey)) {\r\n next.delete(lookupKey);\r\n } else {\r\n next.add(lookupKey);\r\n }\r\n this.expandedKeys.set(next);\r\n }\r\n\r\n protected hasValues(lookupKey: string): boolean {\r\n const values = this.sectionValues()[lookupKey];\r\n if (!values) return false;\r\n return Object.values(values).some((v) => v != null && v !== '');\r\n }\r\n\r\n protected fieldValue(lookupKey: string, propKey: string): string {\r\n const raw = this.sectionValues()[lookupKey]?.[propKey];\r\n return raw == null ? '' : String(raw);\r\n }\r\n\r\n protected setFieldValue(\r\n lookupKey: string,\r\n propKey: string,\r\n value: string,\r\n ): void {\r\n this.sectionValues.update((current) => ({\r\n ...current,\r\n [lookupKey]: { ...(current[lookupKey] ?? {}), [propKey]: value },\r\n }));\r\n this.pushModelValue();\r\n }\r\n\r\n // ============================================================================\r\n // Value mapping\r\n // ============================================================================\r\n\r\n private pushModelValue(): void {\r\n const payload = this.buildPayload();\r\n this.onModelChange(payload.length ? payload : null);\r\n this.onTouched();\r\n }\r\n\r\n private buildPayload(): StoredCheckListEntry[] {\r\n const keys = this.propertyKeys();\r\n const values = this.sectionValues();\r\n\r\n return this.sections()\r\n .filter((section) => this.hasValues(section.lookupKey))\r\n .map((section) => ({\r\n lookupKey: section.lookupKey,\r\n props: keys.map((key) => ({\r\n key,\r\n value: values[section.lookupKey]?.[key] ?? null,\r\n })),\r\n }));\r\n }\r\n\r\n private normalizeIncoming(\r\n value: unknown,\r\n ): Record<string, Record<string, unknown>> {\r\n const raw = this.extractEntries(value);\r\n const result: Record<string, Record<string, unknown>> = {};\r\n\r\n for (const entry of raw) {\r\n if (!entry || typeof entry !== 'object') continue;\r\n const record = entry as Record<string, unknown>;\r\n const lookupKeyRaw =\r\n record['lookupKey'] ?? record['Lookupkey'] ?? record['lookupkey'];\r\n const lookupKey = lookupKeyRaw == null ? '' : String(lookupKeyRaw);\r\n if (!lookupKey) continue;\r\n\r\n const propsRaw = record['props'] ?? record['Props'];\r\n const values: Record<string, unknown> = {};\r\n if (Array.isArray(propsRaw)) {\r\n for (const prop of propsRaw) {\r\n const propRecord = (prop ?? {}) as Record<string, unknown>;\r\n const key = String(propRecord['key'] ?? propRecord['Key'] ?? '');\r\n if (!key) continue;\r\n values[key] = propRecord['value'] ?? propRecord['Value'] ?? null;\r\n }\r\n }\r\n result[lookupKey] = values;\r\n }\r\n\r\n return result;\r\n }\r\n\r\n private extractEntries(value: unknown): unknown[] {\r\n if (Array.isArray(value)) {\r\n return value;\r\n }\r\n\r\n const wrapped = (value as { items?: unknown } | null)?.items;\r\n if (Array.isArray(wrapped)) {\r\n return wrapped;\r\n }\r\n\r\n if (typeof value === 'string' && value.trim()) {\r\n try {\r\n return this.extractEntries(JSON.parse(value));\r\n } catch {\r\n return [];\r\n }\r\n }\r\n\r\n return [];\r\n }\r\n}\r\n","<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 (useRichForm()) {\r\n <ng-container\r\n [ngComponentOutlet]=\"formComponent!\"\r\n [ngComponentOutletInputs]=\"formInputs()\"\r\n />\r\n } @else if (sections().length) {\r\n <!-- Fallback: plain text inputs per property (no rich form registered) -->\r\n <div class=\"flex flex-col gap-2\">\r\n @for (section of sections(); track section.lookupKey) {\r\n <div class=\"overflow-hidden rounded-lg border border-surface-200\">\r\n <button\r\n type=\"button\"\r\n class=\"flex w-full cursor-pointer items-center justify-between gap-2 bg-surface-50 px-3 py-2 text-start hover:bg-surface-100\"\r\n [attr.aria-expanded]=\"isExpanded(section.lookupKey)\"\r\n (click)=\"toggle(section.lookupKey)\"\r\n >\r\n <span class=\"flex min-w-0 items-center gap-2\">\r\n <mt-icon\r\n [icon]=\"\r\n isExpanded(section.lookupKey)\r\n ? 'arrow.chevron-down'\r\n : 'arrow.chevron-right'\r\n \"\r\n size=\"sm\"\r\n class=\"shrink-0 text-muted-color rtl:-scale-x-100\"\r\n />\r\n <span class=\"truncate text-sm font-medium text-color\">\r\n {{ section.label }}\r\n </span>\r\n </span>\r\n @if (hasValues(section.lookupKey)) {\r\n <span\r\n class=\"shrink-0 rounded-full bg-primary-50 px-2 py-0.5 text-xs font-semibold text-primary-700\"\r\n >\r\n {{ \"components.lookupModuleCheckListField.filled\" | transloco }}\r\n </span>\r\n }\r\n </button>\r\n\r\n @if (isExpanded(section.lookupKey) && propertyFields().length) {\r\n <div class=\"border-t border-surface-200 p-3\">\r\n <div class=\"grid grid-cols-1 gap-3 sm:grid-cols-2\">\r\n @for (field of propertyFields(); track field.key) {\r\n <label class=\"flex min-w-0 flex-col gap-1\">\r\n <span class=\"truncate text-xs text-muted-color\">\r\n {{ field.label }}\r\n </span>\r\n @if (isReadonly()) {\r\n <span class=\"truncate text-sm text-color\">\r\n {{ fieldValue(section.lookupKey, field.key) || \"_\" }}\r\n </span>\r\n } @else {\r\n <input\r\n pInputText\r\n class=\"w-full\"\r\n [ngModel]=\"fieldValue(section.lookupKey, field.key)\"\r\n [ngModelOptions]=\"{ standalone: true }\"\r\n (ngModelChange)=\"\r\n setFieldValue(section.lookupKey, field.key, $event)\r\n \"\r\n />\r\n }\r\n </label>\r\n }\r\n </div>\r\n </div>\r\n }\r\n </div>\r\n }\r\n </div>\r\n } @else {\r\n <div\r\n class=\"rounded border border-dashed border-surface-300 bg-surface-50 p-3 text-sm text-muted-color\"\r\n >\r\n {{ \"components.lookupModuleCheckListField.empty\" | transloco }}\r\n </div>\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","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":["PAGE_SIZE","i1","i2"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAiCa,iBAAiB,CAAA;AACnB,IAAA,MAAM,GAAG,KAAK,CAAC,QAAQ,4EAA2B;AAE1C,IAAA,gBAAgB,GAAG,MAAM,CAAC,gBAAgB,EAAE;AAC3D,QAAA,QAAQ,EAAE,IAAI;AACf,KAAA,CAAC;AACe,IAAA,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC;AAC/B,IAAA,SAAS,GAAG,MAAM,CAAC,gBAAgB,CAAC;AACpC,IAAA,YAAY,GAAG,MAAM,CAAC,CAAC,mFAAC;IACjC,iBAAiB,GAA2B,IAAI;AAE/C,IAAA,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,SAAS,+EAAC;AACpD,IAAA,QAAQ,GAAG,QAAQ,CAAC,MAAM,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,IAAI,EAAE,+EAAC;AACvD,IAAA,QAAQ,GAAG,QAAQ,CAAC,MAAM,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,IAAI,EAAE,+E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