@masterteam/components 0.0.299 → 0.0.300

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-field.ts","../../../../packages/masterteam/components/business-fields/entity-list-field/entity-list-field.html","../../../../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 effect,\r\n untracked,\r\n DestroyRef,\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 {\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 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 * Required-validation for a connection: emptiness is decided by the selected\r\n * `sources`, not by the value being null. The runtime loads an unselected\r\n * connection as `{ levelId, sources: [] }` — a non-null object that Angular's\r\n * stock `Validators.required` accepts — so a plain required check would let an\r\n * empty connection pass and the form submit. Mirrors {@link syncValue}, which\r\n * collapses a source-less selection to `null`.\r\n */\r\n private readonly connectionRequiredValidator: ValidatorFn = (\r\n control: AbstractControl,\r\n ): ValidationErrors | null => {\r\n const value = parseConnectionPayload(control.value);\r\n const hasSources =\r\n !!value && Array.isArray(value.sources) && value.sources.length > 0;\r\n return hasSources ? 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 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 required = this.required();\r\n untracked(() => {\r\n if (required) {\r\n control.addValidators(this.connectionRequiredValidator);\r\n } else {\r\n control.removeValidators(this.connectionRequiredValidator);\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 // 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 * 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 class=\"truncate\" [class.required]=\"required()\">\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]=\"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]=\"true\"\r\n />\r\n }\r\n </div>\r\n }\r\n</div>\r\n\r\n<mt-field-validation [control]=\"ngControl?.control\"></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\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","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 { ControlValueAccessor, NgControl, Validators } 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 { 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 readEntityValueColor,\r\n serializeEntityRawValue,\r\n} from '@masterteam/components/entities';\r\nimport type {\r\n EntityData,\r\n EntityViewType,\r\n PropertyValueComparison,\r\n} from '@masterteam/components/entities';\r\nimport type { EntityListFieldRuntimeContext } from '@masterteam/components';\r\n\r\nimport { ENTITY_LIST_ADD_DIALOG_COMPONENT } from './entity-list-add-token';\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}\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\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\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\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/**\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 TranslocoPipe,\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})\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 * 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 // 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 * 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 protected readonly showsChangeFlags = computed<boolean>(() =>\r\n this.pendingSubmission(),\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 /** 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 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 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\r\n // ============================================================================\r\n // CVA\r\n // ============================================================================\r\n\r\n writeValue(value: EntityListStoredValue | string | null): void {\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.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 * True when the written value still carries exactly the rows and deletions\r\n * we last emitted — i.e. the form is echoing our own value back rather than\r\n * loading a new one.\r\n */\r\n private isEchoOfLastEmit(incoming: EntityListStoredValue | null): boolean {\r\n if (this.lastEmittedJson === null) return false;\r\n return (\r\n JSON.stringify({\r\n rows: incoming?.rows ?? [],\r\n deletedIds: incoming?.deletedIds ?? [],\r\n }) === this.lastEmittedJson\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 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 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 * 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 // 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 const current = this.storedValue();\r\n // `entityIds` / `createdIds` / `updatedIds` / `snapshot` are backend-owned\r\n // and passed through untouched; the frontend only contributes pending rows\r\n // and delete intents.\r\n const next: EntityListStoredValue = {\r\n ...(current ?? {}),\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 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 deletedIds: this.deletedIds(),\r\n };\r\n this.storedValue.set(next);\r\n this.lastEmittedJson = JSON.stringify({\r\n rows: next.rows,\r\n deletedIds: next.deletedIds,\r\n });\r\n this.onModelChange(next);\r\n this.onTouched();\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.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 this.columns.set(this.buildColumns(metadata));\r\n\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 /**\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 // 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 prefill[key] = OBJECT_VALUED_VIEW_TYPES.has(\r\n viewTypeByKey.get(key) ?? properties.get(key)?.viewType ?? '',\r\n )\r\n ? (cell?.value ?? cell?.raw ?? null)\r\n : values[key];\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\">\n @if (label()) {\n <label class=\"font-medium text-color\">\n {{ label() }}\n @if (required()) {\n <span class=\"text-red-500\">*</span>\n }\n </label>\n }\n\n @if (errorMessage(); as err) {\n <p-message severity=\"error\" [text]=\"err\" styleClass=\"w-full\" />\n } @else if (noticeKey(); as notice) {\n <div\n class=\"rounded-md border border-dashed border-surface-300 bg-surface-50 p-3 text-sm text-muted-color\"\n >\n {{ notice | transloco }}\n </div>\n } @else if (canWrite()) {\n <div class=\"flex justify-end\">\n <mt-button\n [label]=\"'components.entityListField.add' | transloco\"\n icon=\"general.plus\"\n size=\"small\"\n [disabled]=\"disabled()\"\n (onClick)=\"openAddDialog()\"\n />\n </div>\n <mt-table\n [noCard]=\"true\"\n [data]=\"displayRows()\"\n [columns]=\"tableColumns()\"\n [rowActions]=\"writeRowActions()\"\n dataKey=\"Id\"\n [loading]=\"loading()\"\n />\n } @else if (loading() && !hasRows()) {\n <div class=\"flex flex-col gap-2\">\n <p-skeleton width=\"100%\" height=\"3rem\" borderRadius=\"0.375rem\" />\n <p-skeleton width=\"100%\" height=\"3rem\" borderRadius=\"0.375rem\" />\n </div>\n } @else if (!hasRows()) {\n <div\n class=\"rounded-md border border-dashed border-surface-300 bg-surface-50 p-3 text-sm text-muted-color\"\n >\n {{ \"components.entityListField.noRelatedItems\" | transloco }}\n </div>\n } @else {\n <mt-table\n [noCard]=\"true\"\n [data]=\"displayRows()\"\n [columns]=\"tableColumns()\"\n dataKey=\"Id\"\n [loading]=\"loading()\"\n />\n }\n\n @if (ngControl?.control) {\n <mt-field-validation\n [control]=\"ngControl?.control!\"\n [touched]=\"ngControl?.touched ?? false\"\n />\n }\n</div>\n","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":["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,M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AA,SAAA,EAAA,OAAA,EAAA,SAAA,CAAA,EAAA,EAAA,EAAA,IAAA,EAAA,WAAA,EAAA,IAAA,EACf,IAAI,EAAA,QAAA,EAAA,SAAA,EAAA,MAAA,EAAA,CAAA,MAAA,CAAA,EAAA,EAAA,EAAA,IAAA,EAAA,WAAA,EAAA,IAAA,EACJ,eAAe,wGACf,aAAa,EAAA,IAAA,EAAA,WAAA,EAAA,CAAA,EAAA,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-field.ts","../../../../packages/masterteam/components/business-fields/entity-list-field/entity-list-field.html","../../../../packages/masterteam/components/business-fields/entity-list-field/provide-entity-list-table.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 effect,\r\n untracked,\r\n DestroyRef,\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 {\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 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 * Required-validation for a connection: emptiness is decided by the selected\r\n * `sources`, not by the value being null. The runtime loads an unselected\r\n * connection as `{ levelId, sources: [] }` — a non-null object that Angular's\r\n * stock `Validators.required` accepts — so a plain required check would let an\r\n * empty connection pass and the form submit. Mirrors {@link syncValue}, which\r\n * collapses a source-less selection to `null`.\r\n */\r\n private readonly connectionRequiredValidator: ValidatorFn = (\r\n control: AbstractControl,\r\n ): ValidationErrors | null => {\r\n const value = parseConnectionPayload(control.value);\r\n const hasSources =\r\n !!value && Array.isArray(value.sources) && value.sources.length > 0;\r\n return hasSources ? 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 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 required = this.required();\r\n untracked(() => {\r\n if (required) {\r\n control.addValidators(this.connectionRequiredValidator);\r\n } else {\r\n control.removeValidators(this.connectionRequiredValidator);\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 // 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 * 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 class=\"truncate\" [class.required]=\"required()\">\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]=\"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]=\"true\"\r\n />\r\n }\r\n </div>\r\n }\r\n</div>\r\n\r\n<mt-field-validation [control]=\"ngControl?.control\"></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\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","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 { ControlValueAccessor, NgControl, Validators } 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 { 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 readEntityValueColor,\r\n serializeEntityRawValue,\r\n} from '@masterteam/components/entities';\r\nimport type {\r\n EntityData,\r\n EntityViewType,\r\n PropertyValueComparison,\r\n} from '@masterteam/components/entities';\r\nimport type { EntityListFieldRuntimeContext } from '@masterteam/components';\r\n\r\nimport { ENTITY_LIST_ADD_DIALOG_COMPONENT } from './entity-list-add-token';\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}\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\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\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\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/**\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 TranslocoPipe,\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})\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 * 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 * Stored value for a host that renders this field **outside a form** — a\r\n * preview card, where there is no `FormControl` to write through and so\r\n * `writeValue` is never called.\r\n *\r\n * Ignored whenever a form control is bound: that control owns the value, and\r\n * letting an input race it would overwrite the user's pending edits.\r\n */\r\n readonly value = 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 * 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 protected readonly showsChangeFlags = computed<boolean>(() =>\r\n this.pendingSubmission(),\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 /** 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 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 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 // Outside a form nothing ever calls `writeValue`, so a bound `value` is\r\n // the only way the stored rows reach the table. A form control, when there\r\n // is one, stays the single owner.\r\n //\r\n // An absent value writes nothing rather than writing null: this effect\r\n // also runs on init, and a host that drives the field by calling\r\n // `writeValue` directly would otherwise have it cleared underneath.\r\n effect(() => {\r\n const value = this.value();\r\n if (this.ngControl || value == null) return;\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 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.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 * True when the written value still carries exactly the rows and deletions\r\n * we last emitted — i.e. the form is echoing our own value back rather than\r\n * loading a new one.\r\n */\r\n private isEchoOfLastEmit(incoming: EntityListStoredValue | null): boolean {\r\n if (this.lastEmittedJson === null) return false;\r\n return (\r\n JSON.stringify({\r\n rows: incoming?.rows ?? [],\r\n deletedIds: incoming?.deletedIds ?? [],\r\n }) === this.lastEmittedJson\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 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 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 * 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 // 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 const current = this.storedValue();\r\n // `entityIds` / `createdIds` / `updatedIds` / `snapshot` are backend-owned\r\n // and passed through untouched; the frontend only contributes pending rows\r\n // and delete intents.\r\n const next: EntityListStoredValue = {\r\n ...(current ?? {}),\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 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 deletedIds: this.deletedIds(),\r\n };\r\n this.storedValue.set(next);\r\n this.lastEmittedJson = JSON.stringify({\r\n rows: next.rows,\r\n deletedIds: next.deletedIds,\r\n });\r\n this.onModelChange(next);\r\n this.onTouched();\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.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 this.columns.set(this.buildColumns(metadata));\r\n\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 /**\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 // 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 prefill[key] = OBJECT_VALUED_VIEW_TYPES.has(\r\n viewTypeByKey.get(key) ?? properties.get(key)?.viewType ?? '',\r\n )\r\n ? (cell?.value ?? cell?.raw ?? null)\r\n : values[key];\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\">\n @if (label()) {\n <label class=\"font-medium text-color\">\n {{ label() }}\n @if (required()) {\n <span class=\"text-red-500\">*</span>\n }\n </label>\n }\n\n @if (errorMessage(); as err) {\n <p-message severity=\"error\" [text]=\"err\" styleClass=\"w-full\" />\n } @else if (noticeKey(); as notice) {\n <div\n class=\"rounded-md border border-dashed border-surface-300 bg-surface-50 p-3 text-sm text-muted-color\"\n >\n {{ notice | transloco }}\n </div>\n } @else if (canWrite()) {\n <div class=\"flex justify-end\">\n <mt-button\n [label]=\"'components.entityListField.add' | transloco\"\n icon=\"general.plus\"\n size=\"small\"\n [disabled]=\"disabled()\"\n (onClick)=\"openAddDialog()\"\n />\n </div>\n <mt-table\n [noCard]=\"true\"\n [data]=\"displayRows()\"\n [columns]=\"tableColumns()\"\n [rowActions]=\"writeRowActions()\"\n dataKey=\"Id\"\n [loading]=\"loading()\"\n />\n } @else if (loading() && !hasRows()) {\n <div class=\"flex flex-col gap-2\">\n <p-skeleton width=\"100%\" height=\"3rem\" borderRadius=\"0.375rem\" />\n <p-skeleton width=\"100%\" height=\"3rem\" borderRadius=\"0.375rem\" />\n </div>\n } @else if (!hasRows()) {\n <div\n class=\"rounded-md border border-dashed border-surface-300 bg-surface-50 p-3 text-sm text-muted-color\"\n >\n {{ \"components.entityListField.noRelatedItems\" | transloco }}\n </div>\n } @else {\n <mt-table\n [noCard]=\"true\"\n [data]=\"displayRows()\"\n [columns]=\"tableColumns()\"\n dataKey=\"Id\"\n [loading]=\"loading()\"\n />\n }\n\n @if (ngControl?.control) {\n <mt-field-validation\n [control]=\"ngControl?.control!\"\n [touched]=\"ngControl?.touched ?? false\"\n />\n }\n</div>\n","import { Provider } from '@angular/core';\nimport { ENTITY_LIST_TABLE_COMPONENT } from '@masterteam/components/entities';\n\nimport { EntityListField } from './entity-list-field';\n\n/**\n * Lets a preview render an `EntityList` property as the same read-only table\n * the form shows, instead of the compact count-and-drawer.\n *\n * Register it once in app providers, beside `provideEntityListAddForm()`. It\n * only takes effect where a call site passes an `entityListContext` — the card\n * grid does, a table cell deliberately does not — so registering it does not\n * change how nested lists render inside another table.\n *\n * The field is bound `readonly`, so it loads its own metadata and rows and\n * renders no Add / Edit / Delete.\n */\nexport function provideEntityListTable(): Provider {\n return {\n provide: ENTITY_LIST_TABLE_COMPONENT,\n useValue: EntityListField,\n };\n}\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":["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,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