@masterteam/components 0.0.293 → 0.0.295

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@masterteam/components",
3
- "version": "0.0.293",
3
+ "version": "0.0.295",
4
4
  "publishConfig": {
5
5
  "directory": "../../../dist/masterteam/components",
6
6
  "linkDirectory": true,
@@ -275,6 +275,15 @@ declare class SchedulePredecessorField implements ControlValueAccessor {
275
275
  static ɵcmp: _angular_core.ɵɵComponentDeclaration<SchedulePredecessorField, "mt-schedule-predecessor-field", never, { "label": { "alias": "label"; "required": false; "isSignal": true; }; "placeholder": { "alias": "placeholder"; "required": false; "isSignal": true; }; "readonly": { "alias": "readonly"; "required": false; "isSignal": true; }; "required": { "alias": "required"; "required": false; "isSignal": true; }; "configuration": { "alias": "configuration"; "required": false; "isSignal": true; }; "runtimeContext": { "alias": "runtimeContext"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
276
276
  }
277
277
 
278
+ /**
279
+ * Why the metadata request produced no table.
280
+ *
281
+ * - `forbidden` — `403`: the user may not read the target module in this level.
282
+ * - `unavailable` — `400` / `404`: the property is missing, not an EntityList,
283
+ * invalidly configured, or out of the supplied level's scope.
284
+ * - `failed` — anything else, i.e. an actual request failure.
285
+ */
286
+ type EntityListMetadataFailure = 'forbidden' | 'unavailable' | 'failed';
278
287
  interface EntityListColumnDef extends ColumnDef {
279
288
  key: string;
280
289
  label: string;
@@ -327,9 +336,20 @@ declare class EntityListField implements ControlValueAccessor {
327
336
  readonly label: _angular_core.InputSignal<string>;
328
337
  readonly readonly: _angular_core.InputSignal<boolean>;
329
338
  readonly required: _angular_core.InputSignal<boolean>;
330
- /** EntityList property id (kept for back-compat; unused by fetch/query). */
339
+ /**
340
+ * EntityList property id. **Required** — with the owning level it addresses
341
+ * the table-metadata endpoint, which is the only source of this field's
342
+ * effective configuration.
343
+ */
331
344
  readonly propertyId: _angular_core.InputSignal<number | null>;
332
- /** Property configuration (sourceType, moduleId, access, readFields, etc). */
345
+ /**
346
+ * Stored property configuration (sourceType, moduleId, access, readFields …).
347
+ *
348
+ * Kept for hosts that still bind it, but **not read**: the stored value is
349
+ * the un-overridden one, and the backend resolves the level-module override
350
+ * before answering the metadata request. Everything this field gates on comes
351
+ * from that response.
352
+ */
333
353
  readonly configuration: _angular_core.InputSignal<Record<string, unknown> | null>;
334
354
  /** Runtime ids needed to call the read endpoint. */
335
355
  readonly runtimeContext: _angular_core.InputSignal<EntityListFieldRuntimeContext | null>;
@@ -350,6 +370,9 @@ declare class EntityListField implements ControlValueAccessor {
350
370
  /** Optional HttpContext (kept for back-compat). */
351
371
  readonly context: _angular_core.InputSignal<HttpContext | undefined>;
352
372
  private readonly storedValue;
373
+ /** Runtime-scoped metadata; null until the endpoint answers. */
374
+ private readonly metadata;
375
+ protected readonly metadataFailure: _angular_core.WritableSignal<EntityListMetadataFailure | null>;
353
376
  protected readonly columns: _angular_core.WritableSignal<EntityListColumnDef[]>;
354
377
  /** Rows loaded from the backend (existing target records). */
355
378
  protected readonly rows: _angular_core.WritableSignal<EntityListRow[]>;
@@ -360,10 +383,39 @@ declare class EntityListField implements ControlValueAccessor {
360
383
  ngControl: NgControl | null;
361
384
  protected readonly levelId: _angular_core.Signal<string | number | null>;
362
385
  protected readonly levelDataId: _angular_core.Signal<string | number | null>;
363
- protected readonly moduleId: _angular_core.Signal<string | number | null>;
386
+ /** EntityList property id as a number; `0` when the host bound none. */
387
+ protected readonly propertyKeyId: _angular_core.Signal<number>;
388
+ /** Target module id, as resolved for this level. */
389
+ protected readonly moduleId: _angular_core.Signal<number | null>;
390
+ /** Canonical readable target keys — the columns this field renders. */
364
391
  protected readonly readFields: _angular_core.Signal<string[]>;
365
- /** Normalized `access` from the property configuration. */
392
+ /**
393
+ * Keys the row projection asks for: readable **and** writable.
394
+ *
395
+ * A writable key that is not readable has no column, but the edit dialog
396
+ * still renders it — and several are `isRequired` on the target module (the
397
+ * schedule module's `task_planned_finish` is). Projecting only `readFields`
398
+ * left those controls empty, so the form was invalid until the user retyped a
399
+ * value that already existed, and a different value silently overwrote the
400
+ * stored one. Read order first, so the request body stays stable.
401
+ */
402
+ protected readonly projectedKeys: _angular_core.Signal<string[]>;
403
+ /** Effective `access` for this level, as resolved by the backend. */
366
404
  protected readonly accessMode: _angular_core.Signal<EntityListAccess>;
405
+ /**
406
+ * The table is backed by target module records. Inline lists resolve their
407
+ * rows from the stored value and have no module form to write through, so
408
+ * this field does not render them.
409
+ */
410
+ protected readonly moduleBacked: _angular_core.Signal<boolean>;
411
+ /**
412
+ * Rows live in this property's own value rather than in target records: the
413
+ * module supplies the columns and the editors, nothing else. The whole row
414
+ * array is submitted on every save and no target record is ever written.
415
+ */
416
+ protected readonly embedded: _angular_core.Signal<boolean>;
417
+ /** The module record that owns an embedded value — the rows `instanceId`. */
418
+ protected readonly ownerRecordId: _angular_core.Signal<number>;
367
419
  protected readonly canRead: _angular_core.Signal<boolean>;
368
420
  /**
369
421
  * Whether the field has rows it may display. Write-only access cannot read
@@ -375,6 +427,12 @@ declare class EntityListField implements ControlValueAccessor {
375
427
  private readonly writeAllowed;
376
428
  /** Write UI is rendered only when access allows it and the field is editable. */
377
429
  protected readonly canWrite: _angular_core.Signal<boolean>;
430
+ /**
431
+ * Canonical writable target keys. They are what the add/edit dialog renders
432
+ * and what a submitted row is restricted to — canonical, so a configuration
433
+ * that listed `normalizedKey` aliases still matches the target module's form
434
+ * value keys.
435
+ */
378
436
  protected readonly writeFields: _angular_core.Signal<string[]>;
379
437
  /**
380
438
  * Pending create/update rows, in the exact shape persisted by the backend
@@ -395,12 +453,25 @@ declare class EntityListField implements ControlValueAccessor {
395
453
  private readonly deletedIds;
396
454
  /** rowId → original form values / option labels (view state only). */
397
455
  private readonly rowDrafts;
456
+ /**
457
+ * rowId → the backend's rendered cells for a saved embedded row, from the
458
+ * rows endpoint. View state only: the submitted values stay `pendingRows`.
459
+ */
460
+ private readonly renderedRows;
398
461
  private localRowSeq;
399
462
  /** Serialized copy of the last value we emitted, to ignore CVA echoes. */
400
463
  private lastEmittedJson;
401
464
  /** Server rows indexed by entity id, for merging pending updates. */
402
465
  private readonly rowsByEntityId;
403
- /** Locally created rows (not yet persisted). */
466
+ /**
467
+ * Rows with no target record: locally created ones in a linked list, and
468
+ * *every* row of an embedded list.
469
+ *
470
+ * Three sources, in order: what the user last entered (`rowDrafts`), what the
471
+ * rows endpoint rendered for a saved embedded row, and the stored value's own
472
+ * cells. The middle one is what turns a saved `rawValue` of `"3fa85f64…"`
473
+ * back into an assignee's name after a reload.
474
+ */
404
475
  private readonly createdRows;
405
476
  /** Pending edits of existing rows, keyed by entity id. */
406
477
  private readonly editedRowsByEntityId;
@@ -420,10 +491,18 @@ declare class EntityListField implements ControlValueAccessor {
420
491
  */
421
492
  protected readonly displayRows: _angular_core.Signal<EntityListRow[]>;
422
493
  protected readonly hasRows: _angular_core.Signal<boolean>;
494
+ /** Enough context to ask the backend what this field should render. */
423
495
  protected readonly hasRequiredContext: _angular_core.Signal<boolean>;
496
+ /**
497
+ * The non-error state the field renders instead of a table, as a translation
498
+ * key. Null while the metadata request is still in flight, so the template
499
+ * falls through to the skeleton.
500
+ */
501
+ protected readonly noticeKey: _angular_core.Signal<string | null>;
424
502
  protected onTouched: () => void;
425
503
  protected onModelChange: (value: EntityListStoredValue | null) => void;
426
504
  private readonly http;
505
+ private metadataSubscription?;
427
506
  private fetchSubscription?;
428
507
  private readonly destroyRef;
429
508
  private readonly modal;
@@ -478,7 +557,23 @@ declare class EntityListField implements ControlValueAccessor {
478
557
  private setRowDraft;
479
558
  private clearRowDraft;
480
559
  private buildRow;
481
- /** Render one table cell from a raw form value and its resolved label. */
560
+ /**
561
+ * Render one table cell from a raw form value and its resolved label.
562
+ *
563
+ * The cell has to arrive in the shape the backend would have sent, because
564
+ * that is what the entity renderers bind. Two things a control value is not:
565
+ *
566
+ * - **A scalar `value` is a string.** `mt-entity-percentage` reads `d.value`
567
+ * only when `typeof` it is `'string'` and prints its placeholder otherwise,
568
+ * so a numeric control value rendered as a filled bar with no number beside
569
+ * it. Objects and arrays are the resolved shapes the rich renderers want,
570
+ * and pass through untouched.
571
+ * - **The column configuration has to travel with it.** Colour rules live
572
+ * there, and `mt-entity-percentage` falls back to evaluating them itself
573
+ * exactly when no per-value colour was resolved — which is every locally
574
+ * added row. Without it a new 45% row rendered in the default colour while
575
+ * the same value loaded from the backend rendered in its band colour.
576
+ */
482
577
  private buildCell;
483
578
  /**
484
579
  * Shape a raw form value into the value an entity renderer expects for the
@@ -528,16 +623,66 @@ declare class EntityListField implements ControlValueAccessor {
528
623
  private diffValues;
529
624
  private isEmptyValue;
530
625
  private isSameValue;
531
- private fetchDraftColumns;
532
626
  /**
533
- * Project a Create form into the catalog shape the column builder expects.
534
- * Sections and their fields are flattened into reading order and renumbered
535
- * from there — a field's own `order` is section-relative, so carrying it over
536
- * as the column order interleaves the sections once `applyResponse` sorts.
627
+ * Load the runtime-scoped table description, then its rows.
628
+ *
629
+ * The metadata endpoint is the authorization boundary for this field: it
630
+ * answers `403` when the user may not read the target module in this level,
631
+ * so the columns are never built from a source that skipped that check.
632
+ */
633
+ private loadTable;
634
+ /**
635
+ * Apply the metadata, then fetch rows when there is a persisted parent to
636
+ * scope them to. A draft parent (no `levelDataId`) and a write-only field
637
+ * both stop at the columns — the first has no records yet, the second may
638
+ * not read them.
639
+ */
640
+ private applyMetadata;
641
+ /**
642
+ * Saved rows of an embedded list, rendered by the backend.
643
+ *
644
+ * They are not merged into `rows` — that signal is target module records,
645
+ * which an embedded list has none of. They land in `renderedRows`, which
646
+ * `createdRows` consults to render the value's own rows with resolved labels
647
+ * instead of stored scalars.
648
+ *
649
+ * The stored value stays authoritative for *which* rows exist, so a value
650
+ * that already carries them is left alone; the response only seeds the array
651
+ * when the control arrived without one.
537
652
  */
538
- private mapProcessFormProperties;
653
+ private fetchEmbeddedRows;
654
+ private applyEmbeddedRows;
655
+ /**
656
+ * Table columns, in the order the backend returned them.
657
+ *
658
+ * `projectionMeta.columns[].key` is the catalog property key here — the same
659
+ * key `fetch/query` keys its record values by — so a column maps onto a row
660
+ * value directly. The lookup still falls back to `normalizedKey` so a column
661
+ * fed from any other projection keeps resolving.
662
+ *
663
+ * The columns are the *union* of readable and writable fields, so in a
664
+ * **linked** list a write-only key arrives as a column too — a `Planned
665
+ * Finish` the user may set in the dialog but may not read. It is not
666
+ * projected into the rows and would render as an empty column, so only
667
+ * readable keys become columns there. Two exceptions keep the union:
668
+ *
669
+ * - **Write-only access**, whose readable set is empty by definition and
670
+ * whose stored rows have nothing else to render through.
671
+ * - **Embedded storage**, where the rows endpoint returns cells for the whole
672
+ * union by design, "so saved editor values can be rendered after reload".
673
+ */
674
+ private buildColumns;
675
+ /** Catalog properties of the loaded metadata, keyed by property key. */
676
+ private readonly propertyByKey;
539
677
  private fetchRows;
540
- private applyResponse;
678
+ /**
679
+ * Project fetched records onto the metadata columns.
680
+ *
681
+ * Cells are built per rendered column, but the row's value maps cover every
682
+ * **projected** key — a writable key without a column has no cell to render
683
+ * and still has to reach the edit dialog and the update diff.
684
+ */
685
+ private applyRecords;
541
686
  private toEntityData;
542
687
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<EntityListField, never>;
543
688
  static ɵcmp: _angular_core.ɵɵComponentDeclaration<EntityListField, "mt-entity-list-field", never, { "label": { "alias": "label"; "required": false; "isSignal": true; }; "readonly": { "alias": "readonly"; "required": false; "isSignal": true; }; "required": { "alias": "required"; "required": false; "isSignal": true; }; "propertyId": { "alias": "propertyId"; "required": false; "isSignal": true; }; "configuration": { "alias": "configuration"; "required": false; "isSignal": true; }; "runtimeContext": { "alias": "runtimeContext"; "required": false; "isSignal": true; }; "pendingSubmission": { "alias": "pendingSubmission"; "required": false; "isSignal": true; }; "lookups": { "alias": "lookups"; "required": false; "isSignal": true; }; "context": { "alias": "context"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
@@ -559,6 +704,16 @@ interface EntityListAddDialogInputs {
559
704
  initialValues?: Record<string, unknown>;
560
705
  /** True when the dialog edits an existing row rather than adding one. */
561
706
  isEdit?: boolean;
707
+ /**
708
+ * Load the target module's **root** form rather than its level-scoped one,
709
+ * by omitting `levelId` / `levelDataId` from the form load.
710
+ *
711
+ * Set for an embedded list. Its columns, its saved cells and the backend's
712
+ * own write validation all resolve from root module definitions, so a
713
+ * level-scoped editor could render a property that does not exist at root —
714
+ * and the save would reject that cell as unknown.
715
+ */
716
+ useRootModuleSchema?: boolean;
562
717
  }
563
718
  /**
564
719
  * Token used by `mt-entity-list-field` (Write mode) to open the rich add-row
@@ -728,6 +728,13 @@ interface EntityListFieldRuntimeContext {
728
728
  /** Current level id (used to build the fetch/query contextKey). */
729
729
  levelId?: number | string | null;
730
730
  levelDataId?: number | string | null;
731
+ /**
732
+ * The module record that owns this property value — `instanceId` of the
733
+ * embedded rows endpoint. Distinct from `sourceId`, which falls back to the
734
+ * level-data id: an embedded list is only served for a module-owned record,
735
+ * so the level-data id must not be sent in its place.
736
+ */
737
+ moduleDataId?: number | string | null;
731
738
  }
732
739
  declare class EntityListFieldConfig extends BaseFieldConfig {
733
740
  /** EntityList property id (used in the read endpoint route). */