@memberjunction/ng-base-forms 6.1.0-edge.6 → 6.1.0

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.
@@ -298,6 +298,29 @@ export declare abstract class BaseFormComponent extends BaseRecordComponent impl
298
298
  * to allowed when unspecified (classic tab behavior).
299
299
  */
300
300
  private resolveAllowSectionReorder;
301
+ /**
302
+ * Bumped on every {@link publishValidationFailure}; published as `FormContext.validationRevision`
303
+ * so a field can tell an edit made before the failure from one made after it.
304
+ */
305
+ private _validationRevision;
306
+ /**
307
+ * The ONE way validation errors reach the fields and the user — used by both the local
308
+ * `Validate()` refusal and a server-side refusal that came back on `LatestResult.Errors`, so the
309
+ * two cannot drift: broadcast through `FormContext` (fields match `Source === FieldName`), bump
310
+ * the revision, toast the messages, and raise `ValidationFailed`.
311
+ */
312
+ private publishValidationFailure;
313
+ /**
314
+ * The structured errors of the last failed save, when at least one names a field on this record.
315
+ *
316
+ * `LatestResult.Errors` is untyped and may hold anything a provider put there, so it is normalised
317
+ * through `DeserializeValidationErrors` first. Returns `[]` unless some entry's `Source` is one of
318
+ * this record's field names — a refusal that is purely record-level ("the database timed out",
319
+ * "not authorised") has nothing to paint and keeps the plain error toast. When there IS a
320
+ * field-sourced entry, the WHOLE set is returned: field-agnostic entries paint nothing (no field
321
+ * matches an empty Source) but still belong in the toast.
322
+ */
323
+ private fieldSourcedServerErrors;
301
324
  /** Clears all validation display state (called on save success, cancel, end edit) */
302
325
  private clearValidationState;
303
326
  private filterSubject;
@@ -1 +1 @@
1
- {"version":3,"file":"base-form-component.d.ts","sourceRoot":"","sources":["../../src/lib/base-form-component.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EAAE,MAAM,EAAE,SAAS,EAClB,SAAS,EAAE,UAAU,EAAE,iBAAiB,EAC9C,YAAY,EACrB,MAAM,eAAe,CAAC;AAGvB,OAAO,EACL,UAAU,EAAE,gBAAgB,EAAE,UAAU,EAAE,oBAA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import { EntityInfo, EntityPermissionType, LogError, RunView } from '@memberjunction/core';
4
- import { MJEventType, MJGlobal } from '@memberjunction/global';
4
+ import { DeserializeValidationErrors, MJEventType, MJGlobal } from '@memberjunction/global';
5
5
  import { FormEditingCompleteEvent, BaseFormComponentEventCodes } from '@memberjunction/ng-base-types';
6
6
  import { BaseRecordComponent } from './base-record-component';
7
7
  import { BaseFormSectionInfo } from './base-form-section-info';
@@ -376,22 +376,23 @@ export class BaseFormComponent extends BaseRecordComponent {
376
376
  else {
377
377
  const serverMsg = this.record.LatestResult?.Message || '';
378
378
  const errorMsg = serverMsg ? `Save failed: ${serverMsg}` : 'Error saving record';
379
- this.Notification.emit({ Message: errorMsg, Type: 'error', Duration: 5000 });
379
+ // A server-side Validate()/ValidateAsync() refusal comes back with its field-named
380
+ // reasons in LatestResult.Errors (rehydrated by the provider). When any of them names a
381
+ // field on this record, publish them through the SAME path the local Validate() branch
382
+ // uses below, so the field paints red with its message instead of the user getting a
383
+ // toast and a form with nothing marked. Errors with no field source stay toast-only.
384
+ const serverErrors = this.fieldSourcedServerErrors();
385
+ if (serverErrors.length > 0) {
386
+ this.publishValidationFailure(serverErrors);
387
+ }
388
+ else {
389
+ this.Notification.emit({ Message: errorMsg, Type: 'error', Duration: 5000 });
390
+ }
380
391
  this.RecordSaveFailed.emit({ EntityName: this.record.EntityInfo.Name, ErrorMessage: errorMsg });
381
392
  }
382
393
  }
383
394
  else {
384
- // Broadcast validation errors to all fields via FormContext
385
- this._showValidation = true;
386
- this._validationErrors = valResults.Errors;
387
- this.cdr.markForCheck();
388
- const errorMessages = valResults.Errors.map(x => x.Message);
389
- this.Notification.emit({
390
- Message: 'Validation Errors\n' + errorMessages.join('\n'),
391
- Type: 'warning',
392
- Duration: 5000
393
- });
394
- this.ValidationFailed.emit({ EntityName: this.record.EntityInfo.Name, Errors: errorMessages });
395
+ this.publishValidationFailure(valResults.Errors);
395
396
  }
396
397
  }
397
398
  LogError("Could not save record: Record not found");
@@ -803,6 +804,7 @@ export class BaseFormComponent extends BaseRecordComponent {
803
804
  showEmptyFields: this.showEmptyFields,
804
805
  showValidation: this._showValidation,
805
806
  validationErrors: this._validationErrors,
807
+ validationRevision: this._validationRevision,
806
808
  collapsibleSections: this.Config?.CollapsibleSections,
807
809
  enableRecordLinks: this.Config?.EnableRecordLinks,
808
810
  showRelatedEntities: this.Config?.ShowRelatedEntities,
@@ -841,6 +843,47 @@ export class BaseFormComponent extends BaseRecordComponent {
841
843
  return false;
842
844
  return this.Config.Toolbar?.AllowSectionReorder ?? true;
843
845
  }
846
+ /**
847
+ * Bumped on every {@link publishValidationFailure}; published as `FormContext.validationRevision`
848
+ * so a field can tell an edit made before the failure from one made after it.
849
+ */
850
+ _validationRevision = 0;
851
+ /**
852
+ * The ONE way validation errors reach the fields and the user — used by both the local
853
+ * `Validate()` refusal and a server-side refusal that came back on `LatestResult.Errors`, so the
854
+ * two cannot drift: broadcast through `FormContext` (fields match `Source === FieldName`), bump
855
+ * the revision, toast the messages, and raise `ValidationFailed`.
856
+ */
857
+ publishValidationFailure(errors) {
858
+ this._showValidation = true;
859
+ this._validationErrors = errors;
860
+ this._validationRevision++;
861
+ this.cdr.markForCheck();
862
+ const errorMessages = errors.map(x => x.Message);
863
+ this.Notification.emit({
864
+ Message: 'Validation Errors\n' + errorMessages.join('\n'),
865
+ Type: 'warning',
866
+ Duration: 5000
867
+ });
868
+ this.ValidationFailed.emit({ EntityName: this.record.EntityInfo.Name, Errors: errorMessages });
869
+ }
870
+ /**
871
+ * The structured errors of the last failed save, when at least one names a field on this record.
872
+ *
873
+ * `LatestResult.Errors` is untyped and may hold anything a provider put there, so it is normalised
874
+ * through `DeserializeValidationErrors` first. Returns `[]` unless some entry's `Source` is one of
875
+ * this record's field names — a refusal that is purely record-level ("the database timed out",
876
+ * "not authorised") has nothing to paint and keeps the plain error toast. When there IS a
877
+ * field-sourced entry, the WHOLE set is returned: field-agnostic entries paint nothing (no field
878
+ * matches an empty Source) but still belong in the toast.
879
+ */
880
+ fieldSourcedServerErrors() {
881
+ const errors = DeserializeValidationErrors(this.record?.LatestResult?.Errors);
882
+ if (errors.length === 0)
883
+ return [];
884
+ const fieldNames = new Set(this.record.EntityInfo.Fields.map(f => f.Name));
885
+ return errors.some(e => e.Source.length > 0 && fieldNames.has(e.Source)) ? errors : [];
886
+ }
844
887
  /** Clears all validation display state (called on save success, cancel, end edit) */
845
888
  clearValidationState() {
846
889
  this._showValidation = false;
@@ -1 +1 @@
1
- {"version":3,"file":"base-form-component.js","sourceRoot":"","sources":["../../src/lib/base-form-component.ts"],"names":[],"mappings":"AAAA,OAAO,EAC6B,SAAS,EAC3C,YAAY,EAAa,UAAU,EAAE,iBAAiB,EACtD,MAAM,EAAE,YAAY,EAAE,MAAM,EAC7B,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,OAAO,EAAgB,YAAY,EAAE,MAAM,MAAM,CAAC;AAC3D,OAAO,EACL,UAAU,EAAgC,oBAAoB,EAErC,QAAQ,EACgB,OAAO,EACzD,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAuB,MAAM,wBAAwB,CAAC;AACpF,OAAO,EAAE,wBAAwB,EAAqB,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAGzH,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,2BAA2B,EAAE,MAAM,qCAAqC,CAAC;AAYlF,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAGxD,OAAO,EAAE,6BAA6B,EAAE,MAAM,+CAA+C,CAAC;AAC9F,OAAO,EAAE,6BAA6B,EAAE,MAAM,gCAAgC,CAAC;;AAE/E;;;;;;;;;;;;;;;GAeG;AAEH,MAAM,OAAgB,iBAAkB,SAAQ,mBAAmB;IAC1D,QAAQ,GAAY,KAAK,CAAC;IAC1B,YAAY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B","sourcesContent":["import {\n AfterViewInit, OnInit, OnDestroy, Directive,\n ViewChildren, QueryList, ElementRef, ChangeDetectorRef,\n Output, EventEmitter, inject\n} from '@angular/core';\n\nimport { Subject, Subscription, debounceTime } from 'rxjs';\nimport {\n EntityInfo, ValidationResult, BaseEntity, EntityPermissionType,\n EntityRelationshipInfo, EntityOrganicKeyInfo, EntityOrganicKeyRelatedEntityInfo,\n Metadata, RunViewParams, LogError,\n RecordDependency, BaseEntityEvent, CompositeKey, RunView, RunViewResult\n} from '@memberjunction/core';\nimport { MJEventType, MJGlobal, ValidationErrorInfo } from '@memberjunction/global';\nimport { FormEditingCompleteEvent, PendingRecordItem, BaseFormComponentEventCodes } from '@memberjunction/ng-base-types';\nimport { MJListEntity } from '@memberjunction/core-entities';\n\nimport { BaseRecordComponent } from './base-record-component';\nimport { BaseFormSectionInfo } from './base-form-section-info';\nimport { MjCollapsiblePanelComponent } from './panel/collapsible-panel.component';\nimport { FormNavigationEvent } from './types/navigation-events';\nimport {\n FormContext,\n FormNotificationEvent,\n RecordSavedEvent,\n RecordRefreshedEvent,\n RecordDeletedEvent,\n RecordSaveFailedEvent,\n RecordDeleteFailedEvent,\n ValidationFailedEvent\n} from './types/form-types';\nimport { FormStateService } from './form-state.service';\nimport { EntityFormConfig } from './types/entity-form-config';\nimport { FormToolbarItemConfig, FormToolbarItemKey, FormToolbarItemClickEventArgs } from './types/form-toolbar-item';\nimport { CollectFormPanelRegistrations } from './panel-slot/collect-form-panel-registrations';\nimport { ContributionHiddenSectionKeys } from './panel-slot/form-contribution';\n\n/**\n * Abstract base class for all entity record forms in MemberJunction.\n *\n * Generated forms (via CodeGen) and custom forms extend this class.\n * It provides core form logic — section management, validation, pending records,\n * permissions, favorites, related entity helpers — with ZERO Explorer dependencies.\n *\n * Instead of calling Explorer services directly, events are emitted via @Output:\n * - **Navigate**: Form navigation requests (record links, new records, external links)\n * - **Notification**: User-facing notifications (save success, validation errors, etc.)\n * - **RecordSaved**: Emitted after a successful save\n * - **RecordDeleted**: Emitted after a successful delete\n *\n * The host application (e.g. SingleRecordComponent in Explorer) subscribes to\n * these events and maps them to its own services (NavigationService, SharedService, etc.).\n */\n@Directive()\nexport abstract class BaseFormComponent extends BaseRecordComponent implements AfterViewInit, OnInit, OnDestroy {\n public EditMode: boolean = false;\n public IsRefreshing: boolean = false;\n public FavoriteInitDone: boolean = false;\n\n /**\n * Per-instance presentation config (toolbar visibility, related-entity\n * sections, collapsibility, width, in-form navigation). Set by the form host\n * (`MjEntityFormHostComponent`) or any consumer that instantiates the form\n * directly. Read back by `MjRecordFormContainerComponent` and the collapsible\n * panels through the `FormComponent` reference, so it takes effect WITHOUT\n * regenerating the CodeGen-produced template. Null means \"use the container's\n * own defaults\" (the classic full-page tab behavior).\n */\n public Config: EntityFormConfig | null = null;\n\n /**\n * Variants applicable to the current (entity, user) tuple, supplied by the\n * Explorer-level form resolver. When more than one entry is present, the\n * record-form-container shows a picker that lets the user switch between\n * variants. Empty / single-entry arrays hide the picker.\n *\n * The container reads this via its `EffectiveVariants` accessor — generated\n * form templates do NOT need to bind it explicitly.\n */\n public Variants: { ID: string; Label: string; Scope: 'User' | 'Role' | 'Global'; Status: 'Active' | 'Pending' | 'Inactive' }[] = [];\n\n /**\n * ID of the currently-rendered variant (null when no override is active and\n * the form is the CodeGen / @RegisterClass default).\n */\n public CurrentVariantID: string | null = null;\n\n /**\n * Hook called when the user picks a different variant from the picker.\n * Default is a no-op; the Explorer-level single-record component replaces\n * this on the form instance to wire `FormResolverService.SetSelectedVariant`\n * and reload the record. Kept as a method (not an EventEmitter) so the host\n * doesn't need to subscribe — assignment is enough.\n */\n public OnVariantChanged: (variantID: string | null) => void = (_id) => {\n // host installs the real handler post-construction\n };\n public isHistoryDialogOpen: boolean = false;\n public IsTagsPanelOpen: boolean = false;\n public TagCount: number = 0;\n public showDeleteDialog: boolean = false;\n public showCreateDialog: boolean = false;\n\n /**\n * Height of the top area when a splitter layout is used.\n * Referenced by CodeGen-generated templates for entities with \"top area\" sections.\n */\n public TopAreaHeight: string = '300px';\n\n /**\n * Size of the top area as a percentage (0-100) for angular-split.\n * Used by CodeGen-generated templates with as-split.\n */\n public TopAreaSize: number = 40;\n\n /**\n * Size of the bottom area as a percentage (0-100) for angular-split.\n * Used by CodeGen-generated templates with as-split.\n */\n public BottomAreaSize: number = 60;\n\n /**\n * Called when the splitter layout changes (for entities with \"top area\" sections).\n * No-op in the generic version; override in host application if splitter resizing is needed.\n */\n public splitterLayoutChange(): void {\n // No-op — host application can override\n }\n\n private _pendingRecords: PendingRecordItem[] = [];\n private _registeredToolbarItems = new Map<string, FormToolbarItemConfig>();\n private _toolbarItemOverrides = new Map<string, Partial<FormToolbarItemConfig>>();\n\n /**\n * Registers a dynamic toolbar action item / button.\n * Can be called during ngOnInit or at runtime.\n */\n public RegisterToolbarItem(item: FormToolbarItemConfig): void {\n this._registeredToolbarItems.set(item.Key, { ...item });\n this.cdr?.markForCheck();\n }\n\n /**\n * Unregisters a previously registered dynamic toolbar item by key.\n */\n public UnregisterToolbarItem(key: string): void {\n if (this._registeredToolbarItems.delete(key)) {\n this.cdr?.markForCheck();\n }\n }\n\n /**\n * Configures overrides for any toolbar item (standard built-in items like 'edit',\n * 'delete', 'favorite', 'history', etc., or custom items).\n * Allows dynamically changing visibility, disabled state, tooltips, order, icon, etc.\n */\n public ConfigureToolbarItem(key: FormToolbarItemKey, overrides: Partial<FormToolbarItemConfig>): void {\n const existing = this._toolbarItemOverrides.get(key) || {};\n this._toolbarItemOverrides.set(key, { ...existing, ...overrides });\n this.cdr?.markForCheck();\n }\n\n /**\n * Dynamically hides a toolbar item by key.\n */\n public HideToolbarItem(key: FormToolbarItemKey): void {\n this.ConfigureToolbarItem(key, { Visible: false });\n }\n\n /**\n * Dynamically shows a toolbar item by key.\n */\n public ShowToolbarItem(key: FormToolbarItemKey): void {\n this.ConfigureToolbarItem(key, { Visible: true });\n }\n\n /**\n * Dynamically disables a toolbar item by key, with an optional reason string for the tooltip.\n */\n public DisableToolbarItem(key: FormToolbarItemKey, reason?: string): void {\n this.ConfigureToolbarItem(key, { Disabled: reason ?? true });\n }\n\n /**\n * Dynamically enables a toolbar item by key.\n */\n public EnableToolbarItem(key: FormToolbarItemKey): void {\n this.ConfigureToolbarItem(key, { Disabled: false });\n }\n\n /**\n * Sets the numeric display order for a toolbar item (lower numbers appear earlier).\n */\n public SetToolbarItemOrder(key: FormToolbarItemKey, order: number): void {\n this.ConfigureToolbarItem(key, { Order: order });\n }\n\n /**\n * Returns all dynamically registered toolbar items.\n */\n public get RegisteredToolbarItems(): FormToolbarItemConfig[] {\n return Array.from(this._registeredToolbarItems.values());\n }\n\n /**\n * Returns the map of toolbar item overrides.\n */\n public get ToolbarItemOverrides(): ReadonlyMap<string, Partial<FormToolbarItemConfig>> {\n return this._toolbarItemOverrides;\n }\n\n /**\n * Hook invoked when a custom or dynamic toolbar item is clicked.\n * Subclasses can override this method to handle custom button clicks.\n */\n public OnCustomToolbarButtonClick(event: FormToolbarItemClickEventArgs): void {\n // Subclasses can override\n }\n\n // #region Injected Dependencies (no constructor params)\n\n protected elementRef = inject(ElementRef);\n public cdr = inject(ChangeDetectorRef);\n protected formStateService = inject(FormStateService);\n\n // #endregion\n\n // #region @Output Events\n\n /** Emitted when navigation is requested (record link, external link, email, new record, etc.) */\n @Output() Navigate = new EventEmitter<FormNavigationEvent>();\n\n /** Emitted when a user-facing notification should be shown */\n @Output() Notification = new EventEmitter<FormNotificationEvent>();\n\n /** Emitted after a record is saved successfully */\n @Output() RecordSaved = new EventEmitter<RecordSavedEvent>();\n\n /** Emitted after a record is refreshed from the database successfully */\n @Output() RecordRefreshed = new EventEmitter<RecordRefreshedEvent>();\n\n /** Emitted after a record is deleted successfully */\n @Output() RecordDeleted = new EventEmitter<RecordDeletedEvent>();\n\n /** Emitted when a record save fails */\n @Output() RecordSaveFailed = new EventEmitter<RecordSaveFailedEvent>();\n\n /** Emitted when a record delete fails */\n @Output() RecordDeleteFailed = new EventEmitter<RecordDeleteFailedEvent>();\n\n /** Emitted when validation fails before save */\n @Output() ValidationFailed = new EventEmitter<ValidationFailedEvent>();\n\n /**\n * Emitted once after ngOnInit completes and the record is fully initialized\n * (favorites loaded, form state initialized). This is the safe point for\n * the container to start loading badge counts and other record-dependent data.\n */\n @Output() RecordReady = new EventEmitter<BaseEntity>();\n\n // #endregion\n\n /** Subscription to form state changes */\n private formStateSubscription?: Subscription;\n\n @ViewChildren(MjCollapsiblePanelComponent)\n collapsiblePanels!: QueryList<MjCollapsiblePanelComponent>;\n\n async ngOnInit() {\n if (this.record) {\n if (!this.record.IsSaved) {\n this.StartEditMode();\n }\n const md = this.ProviderToUse;\n // Bind FormStateService to the same provider this form is using.\n this.formStateService.Provider = md;\n this._isFavorite = await md.GetRecordFavoriteStatus(md.CurrentUser.ID, this.record.EntityInfo.Name, this.record.PrimaryKey);\n this.FavoriteInitDone = true;\n\n // Initialize form state from User Settings\n const entityName = this.getEntityName();\n if (entityName) {\n await this.formStateService.initializeState(entityName);\n this.formStateSubscription = this.formStateService.getState$(entityName).subscribe(state => {\n this.showEmptyFields = state.showEmptyFields;\n this.cdr.markForCheck();\n });\n }\n }\n\n // Signal that the record is fully initialized and ready for dependent operations\n if (this.record) {\n this.RecordReady.emit(this.record);\n }\n\n // Set up debounced filter subscription\n this.filterSubscription = this.filterSubject\n .pipe(debounceTime(100))\n .subscribe(searchTerm => {\n this.searchFilter = searchTerm;\n // After change detection propagates FormContext to panels and they update\n // their IsVisible state, expand any visible (matching) sections that are collapsed\n if (searchTerm) {\n Promise.resolve().then(() => this.expandMatchingSections());\n }\n });\n }\n\n ngAfterViewInit(): void {\n // Subclasses can override for post-view-init logic\n }\n\n ngOnDestroy(): void {\n if (this.filterSubscription) {\n this.filterSubscription.unsubscribe();\n }\n if (this.formStateSubscription) {\n this.formStateSubscription.unsubscribe();\n }\n }\n\n // #region Pending Records\n\n protected get PendingRecords(): PendingRecordItem[] {\n return this._pendingRecords;\n }\n\n /**\n * Unsaved changes a form holds OUTSIDE its record's fields and pending records.\n *\n * A form whose sections own editors — a flow canvas, a designer, a grid — accumulates edits that\n * neither `record.Dirty` nor `PendingRecordsDirty()` can see, because nothing on the entity\n * changed. Without this the toolbar reports \"no changes\" while the user is looking at their own\n * work, and the navigate-away guard lets them lose it silently.\n *\n * Default `false`, so no existing form changes behaviour. Override to consult whatever holds the\n * extra state.\n */\n public get HasAdditionalUnsavedChanges(): boolean {\n return false;\n }\n\n protected PendingRecordsDirty(): boolean {\n this.PopulatePendingRecords();\n const pendingRecords = this.PendingRecords;\n if (pendingRecords && pendingRecords.length > 0) {\n for (const p of pendingRecords) {\n if (p.action === 'delete')\n return true;\n else if (p.entityObject.Dirty)\n return true;\n }\n }\n return false;\n }\n\n protected PopulatePendingRecords() {\n this._pendingRecords = [];\n this.RaiseEvent(BaseFormComponentEventCodes.EDITING_COMPLETE);\n const result = this.RaiseEvent(BaseFormComponentEventCodes.POPULATE_PENDING_RECORDS);\n if (result && result.pendingChanges) {\n for (const p of result.pendingChanges)\n this.PendingRecords.push(p);\n }\n }\n\n protected ValidatePendingRecords(): ValidationResult[] {\n const results: ValidationResult[] = [];\n for (let i = 0; i < this._pendingRecords.length; i++) {\n const pendingRecord = this._pendingRecords[i];\n results.push(pendingRecord.entityObject.Validate());\n }\n return results;\n }\n\n // #endregion\n\n // #region Edit Mode\n\n public StartEditMode(): void {\n this.EditMode = true;\n const entityName = this.getEntityName();\n if (entityName) {\n this.formStateService.setEditMode(entityName, true);\n }\n }\n\n public EndEditMode(): void {\n this.EditMode = false;\n this.clearValidationState();\n const entityName = this.getEntityName();\n if (entityName) {\n this.formStateService.setEditMode(entityName, false);\n }\n }\n\n public handleHistoryDialog(): void {\n this.isHistoryDialogOpen = !this.isHistoryDialogOpen;\n }\n\n public HandleTagsPanel(): void {\n this.IsTagsPanelOpen = !this.IsTagsPanelOpen;\n }\n\n // #endregion\n\n // #region Core Form Operations\n\n public Validate(): ValidationResult {\n const valResults = (<BaseEntity>this.record).Validate();\n const pendingValResults = this.ValidatePendingRecords();\n for (let i = 0; i < pendingValResults.length; i++) {\n const pendingValResult = pendingValResults[i];\n if (!pendingValResult.Success) {\n valResults.Success = false;\n valResults.Errors.push(...pendingValResult.Errors);\n }\n }\n return valResults;\n }\n\n protected RaiseEvent(eventCode: BaseFormComponentEventCodes) {\n const event = new FormEditingCompleteEvent();\n event.elementRef = this.elementRef;\n event.subEventCode = eventCode;\n\n MJGlobal.Instance.RaiseEvent({\n event: MJEventType.ComponentEvent,\n component: this,\n eventCode: BaseFormComponentEventCodes.BASE_CODE,\n args: event\n });\n\n return event;\n }\n\n public async SaveRecord(StopEditModeAfterSave: boolean): Promise<boolean> {\n try {\n try {\n (document.activeElement as HTMLElement).blur();\n this.RaiseEvent(BaseFormComponentEventCodes.EDITING_COMPLETE);\n } catch (_e) {\n // ignore blur errors\n }\n\n if (this.record) {\n this.PopulatePendingRecords();\n const valResults = this.Validate();\n if (valResults.Success) {\n const result = await this.InternalSaveRecord();\n if (result) {\n this._pendingRecords = [];\n this.clearValidationState();\n if (StopEditModeAfterSave)\n this.EndEditMode();\n\n this.Notification.emit({ Message: 'Record saved successfully', Type: 'success', Duration: 2500 });\n this.RecordSaved.emit({\n EntityName: this.record.EntityInfo.Name,\n RecordId: this.record.PrimaryKey.ToString(),\n Result: { Success: true }\n });\n return true;\n } else {\n const serverMsg = this.record.LatestResult?.Message || '';\n const errorMsg = serverMsg ? `Save failed: ${serverMsg}` : 'Error saving record';\n this.Notification.emit({ Message: errorMsg, Type: 'error', Duration: 5000 });\n this.RecordSaveFailed.emit({ EntityName: this.record.EntityInfo.Name, ErrorMessage: errorMsg });\n }\n } else {\n // Broadcast validation errors to all fields via FormContext\n this._showValidation = true;\n this._validationErrors = valResults.Errors;\n this.cdr.markForCheck();\n\n const errorMessages = valResults.Errors.map(x => x.Message);\n this.Notification.emit({\n Message: 'Validation Errors\\n' + errorMessages.join('\\n'),\n Type: 'warning',\n Duration: 5000\n });\n this.ValidationFailed.emit({ EntityName: this.record.EntityInfo.Name, Errors: errorMessages });\n }\n }\n\n LogError(\"Could not save record: Record not found\");\n return false;\n } catch (e) {\n const errorMsg = 'Error saving record: ' + e;\n this.Notification.emit({ Message: errorMsg, Type: 'error', Duration: 5000 });\n if (this.record) {\n this.RecordSaveFailed.emit({ EntityName: this.record.EntityInfo.Name, ErrorMessage: errorMsg });\n }\n return false;\n }\n }\n\n public CancelEdit() {\n if (this.record) {\n const r = <BaseEntity>this.record;\n // Capture BEFORE any mutation — Revert() can clear the \"new\" flag on some\n // entities. We need to know whether this record was ever persisted so we\n // can tell the host to dismiss the form (there's nothing to view).\n const wasNeverSaved = !r.IsSaved;\n\n if (r.Dirty || this.PendingRecordsDirty()) {\n // Revert is safe here — the toolbar's discard dialog already confirmed with the user\n r.Revert();\n\n const pendingRecords = this.PendingRecords;\n if (pendingRecords && pendingRecords.length > 0) {\n pendingRecords.forEach(p => {\n if (p.action === 'save')\n p.entityObject.Revert();\n });\n }\n this.RaiseEvent(BaseFormComponentEventCodes.REVERT_PENDING_CHANGES);\n }\n this.EndEditMode();\n\n // For never-saved records, ask the host to dismiss the form — leaving it\n // in view mode shows an empty record (there IS no record) and any\n // subsequent \"Create New\" click for the same entity would silently\n // reuse this abandoned form. Hosts that don't have a meaningful close\n // semantic can ignore this event.\n if (wasNeverSaved) {\n this.Navigate.emit({ Kind: 'dismiss', Reason: 'new-record-discarded' });\n }\n }\n }\n\n /**\n * Re-fetches the current record from the database, updating field values\n * in-place and resetting dirty flags. No-op in edit mode or on an unsaved\n * record. Related-entity grids are notified via the form container's\n * {@link FormRecordRefreshCoordinator} after this emits {@link RecordRefreshed}.\n *\n * @returns true if the record was reloaded from the database.\n */\n public async RefreshRecord(): Promise<boolean> {\n if (!this.canRefreshRecord()) {\n return false;\n }\n\n this.IsRefreshing = true;\n this.cdr.markForCheck();\n\n try {\n return await this.executeRecordRefresh();\n } finally {\n this.IsRefreshing = false;\n this.cdr.markForCheck();\n }\n }\n\n private canRefreshRecord(): boolean {\n return !!this.record && this.record.IsSaved && !this.EditMode;\n }\n\n private async executeRecordRefresh(): Promise<boolean> {\n const record = this.record;\n if (!record) {\n return false;\n }\n\n try {\n const ok = await record.Refresh();\n if (!ok) {\n this.Notification.emit({\n Message: 'Failed to refresh record from database',\n Type: 'error',\n Duration: 5000,\n });\n return false;\n }\n\n await this.reloadFavoriteStatusAfterRefresh(record);\n this.Notification.emit({\n Message: 'Record refreshed from database',\n Type: 'info',\n Duration: 2000,\n });\n this.RecordRefreshed.emit({\n EntityName: record.EntityInfo.Name,\n Record: record,\n });\n return true;\n } catch (e) {\n const detail = e instanceof Error ? e.message : String(e);\n this.Notification.emit({\n Message: 'Error refreshing record: ' + detail,\n Type: 'error',\n Duration: 5000,\n });\n return false;\n }\n }\n\n private async reloadFavoriteStatusAfterRefresh(record: BaseEntity): Promise<void> {\n const md = this.ProviderToUse;\n try {\n this._isFavorite = await md.GetRecordFavoriteStatus(\n md.CurrentUser.ID,\n record.EntityInfo.Name,\n record.PrimaryKey,\n );\n } catch {\n // Non-critical — favorite status remains as is\n }\n }\n\n protected async InternalSaveRecord(): Promise<boolean> {\n if (this.record) {\n if (this._pendingRecords.length > 0) {\n const md = this.ProviderToUse;\n const tg = await md.CreateTransactionGroup();\n this.record.TransactionGroup = tg;\n await this.record.Save();\n\n for (const x of this._pendingRecords) {\n x.entityObject.TransactionGroup = tg;\n if (x.action === 'save') {\n await x.entityObject.Save();\n } else {\n await x.entityObject.Delete();\n }\n }\n return await tg.Submit();\n } else {\n return await this.record.Save();\n }\n } else {\n return false;\n }\n }\n\n public async Wait(duration: number): Promise<void> {\n return new Promise<void>(resolve => setTimeout(resolve, duration));\n }\n\n // #endregion\n\n // #region Permissions\n\n private _userPermissions: { permission: EntityPermissionType; canDo: boolean }[] = [];\n\n public CheckUserPermission(type: EntityPermissionType): boolean {\n try {\n if (this.record) {\n const perm = this._userPermissions.find(x => x.permission === type);\n if (perm)\n return perm.canDo;\n else {\n const result = this.record.CheckPermissions(type, false);\n this._userPermissions.push({ permission: type, canDo: result });\n return result;\n }\n } else {\n return false;\n }\n } catch (e) {\n LogError(e);\n return false;\n }\n }\n\n public get UserCanEdit(): boolean {\n return this.CheckUserPermission(EntityPermissionType.Update);\n }\n\n public get UserCanRead(): boolean {\n return this.CheckUserPermission(EntityPermissionType.Read);\n }\n\n public get UserCanCreate(): boolean {\n return this.CheckUserPermission(EntityPermissionType.Create);\n }\n\n public get UserCanDelete(): boolean {\n return this.CheckUserPermission(EntityPermissionType.Delete);\n }\n\n // #endregion\n\n // #region Grid Edit Mode\n\n public GridEditMode(): \"None\" | \"Save\" | \"Queue\" {\n return this.EditMode ? \"Queue\" : \"None\";\n }\n\n // #endregion\n\n // #region Favorites\n\n private _isFavorite: boolean = false;\n\n public get IsFavorite(): boolean {\n return this._isFavorite;\n }\n\n public async RemoveFavorite(): Promise<void> {\n return this.SetFavoriteStatus(false);\n }\n\n public async MakeFavorite(): Promise<void> {\n return this.SetFavoriteStatus(true);\n }\n\n public async SetFavoriteStatus(isFavorite: boolean) {\n const md = this.ProviderToUse;\n await md.SetRecordFavoriteStatus(md.CurrentUser.ID, this.record.EntityInfo.Name, this.record.PrimaryKey, isFavorite, md.CurrentUser);\n this._isFavorite = isFavorite;\n }\n\n // #endregion\n\n // #region Related Entity Helpers\n\n public BuildRelationshipViewParams(item: EntityRelationshipInfo): RunViewParams {\n return EntityInfo.BuildRelationshipViewParams(this.record, item);\n }\n\n public BuildRelationshipViewParamsByEntityName(relatedEntityName: string, relatedEntityJoinField?: string): RunViewParams {\n const eri = this.GetEntityRelationshipByRelatedEntityName(relatedEntityName, relatedEntityJoinField);\n if (eri)\n return this.BuildRelationshipViewParams(eri);\n else\n return {};\n }\n\n /**\n * One grid over several FKs to the same related entity (Bill-To OR Ship-To).\n */\n public BuildRelationshipViewParamsForJoinFields(relatedEntityName: string, joinFields: readonly string[]): RunViewParams {\n if (!this.record) return {};\n return EntityInfo.BuildRelationshipViewParamsForJoinFields(this.record, relatedEntityName, joinFields);\n }\n\n public GetEntityRelationshipByRelatedEntityName(relatedEntityName: string, relatedEntityJoinField?: string): EntityRelationshipInfo | undefined {\n if (this.record) {\n const r = <BaseEntity>this.record;\n const ret = r.EntityInfo.RelatedEntities.filter(x => x.RelatedEntity.trim().toLowerCase() === relatedEntityName.trim().toLowerCase());\n if (ret.length > 1 && relatedEntityJoinField) {\n const ret2 = ret.find(x => x.RelatedEntityJoinField.trim().toLowerCase() === relatedEntityJoinField.trim().toLowerCase());\n if (ret2)\n return ret2;\n } else if (ret.length === 1) {\n return ret[0];\n } else {\n return undefined;\n }\n }\n return undefined;\n }\n\n /**\n * Default values for a new related-entity record so it links back here.\n * Pass `relatedEntityJoinField` when more than one relationship targets the\n * same entity (Bill-To vs Ship-To). When omitted and several matches exist,\n * every matching FK is set — same fields the related grid is filtering on.\n */\n public NewRecordValues(relatedEntityName: string, relatedEntityJoinField?: string): Record<string, unknown> {\n if (!this.record) return {};\n if (relatedEntityJoinField) {\n const eri = this.GetEntityRelationshipByRelatedEntityName(relatedEntityName, relatedEntityJoinField);\n if (eri) return this.NewRecordValuesByEntityRelationship(eri);\n return EntityInfo.BuildRelationshipNewRecordValuesForJoinFields(this.record, [relatedEntityJoinField]);\n }\n const matches = this.record.EntityInfo.RelatedEntities.filter(\n (x) => x.RelatedEntity.trim().toLowerCase() === relatedEntityName.trim().toLowerCase(),\n );\n if (matches.length === 0) return {};\n if (matches.length === 1) return this.NewRecordValuesByEntityRelationship(matches[0]);\n return EntityInfo.BuildRelationshipNewRecordValuesForJoinFields(\n this.record,\n matches.map((m) => m.RelatedEntityJoinField),\n );\n }\n\n /**\n * Default values for a new related record, setting every listed join field\n * to this record's key. Pair with {@link BuildRelationshipViewParamsForJoinFields}.\n */\n public NewRecordValuesForJoinFields(relatedEntityName: string, joinFields: readonly string[]): Record<string, unknown> {\n if (!this.record || !relatedEntityName) return {};\n return EntityInfo.BuildRelationshipNewRecordValuesForJoinFields(this.record, joinFields);\n }\n\n public NewRecordValuesByEntityRelationship(item: EntityRelationshipInfo): Record<string, unknown> {\n return EntityInfo.BuildRelationshipNewRecordValues(this.record, item);\n }\n\n public GetRelatedEntityTabDisplayName(relatedEntityName: string): string {\n if (this.record) {\n const eri = (<BaseEntity>this.record).EntityInfo.RelatedEntities.find(x => x.RelatedEntity === relatedEntityName);\n if (eri)\n return eri.DisplayName;\n }\n return relatedEntityName;\n }\n\n public get HasRelatedEntities(): boolean {\n if (this.record) {\n const relatedEntities = (<BaseEntity>this.record).EntityInfo.RelatedEntities;\n return relatedEntities && relatedEntities.length > 0;\n }\n return false;\n }\n\n // #endregion\n\n // #region Organic Key Helpers\n\n /**\n * Returns all active organic keys for the current entity, or an empty array if none.\n */\n public get OrganicKeys(): EntityOrganicKeyInfo[] {\n if (this.record) {\n return (<BaseEntity>this.record).EntityInfo.OrganicKeys || [];\n }\n return [];\n }\n\n /**\n * Whether the current entity has any active organic keys with related entities configured.\n */\n public get HasOrganicKeys(): boolean {\n return this.OrganicKeys.some(ok => ok.RelatedEntities.length > 0);\n }\n\n /**\n * Returns all organic key related entities across all organic keys, flattened and sorted.\n */\n public get AllOrganicKeyRelatedEntities(): { OrganicKey: EntityOrganicKeyInfo; RelatedEntity: EntityOrganicKeyRelatedEntityInfo }[] {\n const result: { OrganicKey: EntityOrganicKeyInfo; RelatedEntity: EntityOrganicKeyRelatedEntityInfo }[] = [];\n for (const ok of this.OrganicKeys) {\n for (const re of ok.RelatedEntities) {\n result.push({ OrganicKey: ok, RelatedEntity: re });\n }\n }\n return result;\n }\n\n /**\n * Builds RunViewParams for a specific organic key related entity.\n */\n public BuildOrganicKeyViewParams(\n organicKeyRelatedEntity: EntityOrganicKeyRelatedEntityInfo,\n organicKey: EntityOrganicKeyInfo\n ): RunViewParams {\n if (this.record) {\n return EntityInfo.BuildOrganicKeyViewParams(this.record, organicKeyRelatedEntity, organicKey);\n }\n return {};\n }\n\n /**\n * Convenience method to build organic key view params by organic key name and related entity name.\n */\n public BuildOrganicKeyViewParamsByNames(organicKeyName: string, relatedEntityName: string): RunViewParams {\n const ok = this.OrganicKeys.find(k => k.Name.trim().toLowerCase() === organicKeyName.trim().toLowerCase());\n if (ok) {\n const re = ok.RelatedEntities.find(r => r.RelatedEntity.trim().toLowerCase() === relatedEntityName.trim().toLowerCase());\n if (re) {\n return this.BuildOrganicKeyViewParams(re, ok);\n }\n }\n return {};\n }\n\n // #endregion\n\n // #region Entity Info & Dependencies\n\n public get EntityInfo(): EntityInfo | undefined {\n try {\n const r = <BaseEntity>this.record;\n if (r)\n return r.EntityInfo;\n else\n return undefined;\n } catch (e) {\n LogError(e);\n return undefined;\n }\n }\n\n public async ShowDependencies() {\n const md = this.ProviderToUse;\n const dep = await md.GetRecordDependencies(this.record.EntityInfo.Name, this.record.PrimaryKey);\n console.log('Dependencies for: ' + this.record.EntityInfo.Name + ' ' + this.record.PrimaryKey.ToString());\n console.log(dep);\n }\n\n public ShowChanges(): void {\n if (this.record) {\n const changes = this.record.GetAll(false, true);\n const oldValues = this.record.GetAll(true, true);\n const message =\n 'Changes for: ' + this.record.EntityInfo.Name + ' ' + this.record.PrimaryKey.ToString() +\n '\\n\\n' + JSON.stringify(changes, null, 2) +\n '\\n\\nOld Values\\n\\n' + JSON.stringify(oldValues, null, 2);\n console.log(message);\n this.Notification.emit({ Message: message, Type: 'info', Duration: 30000 });\n }\n }\n\n public async GetListsCanAddTo(): Promise<MJListEntity[]> {\n if (!this.record) {\n LogError('Unable to fetch List records: Record not found');\n return [];\n }\n\n const rv = RunView.FromMetadataProvider(this.ProviderToUse);\n const md = this.ProviderToUse;\n\n const rvResult: RunViewResult<MJListEntity> = await rv.RunView({\n EntityName: 'MJ: Lists',\n ExtraFilter: `UserID = '${md.CurrentUser.ID}' AND EntityID = '${this.record.EntityInfo.ID}'`,\n ResultType: 'entity_object'\n });\n\n if (!rvResult.Success) {\n LogError('Error running view to fetch lists', undefined, rvResult.ErrorMessage);\n return [];\n }\n\n return rvResult.Results;\n }\n\n public async GetRecordDependencies(): Promise<RecordDependency[]> {\n const md = this.ProviderToUse;\n const dependencies: RecordDependency[] = await md.GetRecordDependencies(this.record.EntityInfo.Name, this.record.PrimaryKey);\n return dependencies;\n }\n\n // #endregion\n\n // #region Collapsible Section Management\n\n protected sections: BaseFormSectionInfo[] = [];\n private sectionMap: Map<string, BaseFormSectionInfo> = new Map();\n\n public searchFilter: string = '';\n public showEmptyFields: boolean = false;\n\n /** Whether to show all validation errors on fields (set after save failure) */\n private _showValidation = false;\n /** Validation errors from the most recent failed save attempt */\n private _validationErrors: ValidationErrorInfo[] = [];\n\n public get formContext(): FormContext {\n return {\n sectionFilter: this.searchFilter,\n showEmptyFields: this.showEmptyFields,\n showValidation: this._showValidation,\n validationErrors: this._validationErrors,\n collapsibleSections: this.Config?.CollapsibleSections,\n enableRecordLinks: this.Config?.EnableRecordLinks,\n showRelatedEntities: this.Config?.ShowRelatedEntities,\n hiddenSectionKeys: this.resolveHiddenSectionKeys(),\n visibleSectionKeys: this.Config?.VisibleSectionKeys,\n allowSectionReorder: this.resolveAllowSectionReorder()\n };\n }\n\n /**\n * Config HiddenSectionKeys plus section keys winning contributions asked\n * to hide (related-entity claims and `replacesSectionKey` field panels).\n */\n private resolveHiddenSectionKeys(): string[] | undefined {\n const claimed = this.contributionHiddenSectionKeys();\n const configured = this.Config?.HiddenSectionKeys;\n if (claimed.length === 0) return configured;\n return [...(configured ?? []), ...claimed];\n }\n\n private contributionHiddenSectionKeys(): string[] {\n const entity = this.record?.EntityInfo;\n if (!entity) return [];\n return ContributionHiddenSectionKeys(\n entity.Name,\n entity.RelatedEntities,\n entity.ChildEntities.map((child) => child.ID),\n CollectFormPanelRegistrations(),\n );\n }\n\n /**\n * Resolves whether section drag-reorder is allowed for the current Config.\n * When no toolbar is rendered (dialog/slide-in, `Config.Toolbar === null`)\n * reorder is disabled; otherwise we honor the toolbar config's flag, defaulting\n * to allowed when unspecified (classic tab behavior).\n */\n private resolveAllowSectionReorder(): boolean {\n if (!this.Config) return true;\n if (this.Config.Toolbar === null) return false;\n return this.Config.Toolbar?.AllowSectionReorder ?? true;\n }\n\n /** Clears all validation display state (called on save success, cancel, end edit) */\n private clearValidationState(): void {\n this._showValidation = false;\n this._validationErrors = [];\n }\n\n private filterSubject = new Subject<string>();\n private filterSubscription?: Subscription;\n\n protected initSections(sections: (BaseFormSectionInfo | { sectionKey: string; sectionName: string; isExpanded: boolean; rowCount?: number; metadata?: unknown })[]): void {\n this.sections = sections.map(s =>\n s instanceof BaseFormSectionInfo\n ? s\n : new BaseFormSectionInfo(s.sectionKey, s.sectionName, s.isExpanded, s.rowCount, s.metadata)\n );\n this.sectionMap.clear();\n this.sections.forEach(section => {\n this.sectionMap.set(section.sectionKey, section);\n });\n }\n\n protected getSection(sectionKey: string): BaseFormSectionInfo | undefined {\n return this.sectionMap.get(sectionKey);\n }\n\n public IsSectionExpanded(sectionKey: string, defaultExpanded?: boolean): boolean {\n const section = this.sectionMap.get(sectionKey);\n // When the caller doesn't pass an explicit default, fall back to the value seeded by\n // initSections() — related-entity and System Metadata panels are seeded collapsed there.\n // Without this, FormStateService falls back to its global DEFAULT_SECTION_STATE (isExpanded=true),\n // which reports a never-before-visited related-entity panel as expanded and causes its data grid\n // (bound [AllowLoad]=\"IsSectionExpanded(key)\") to fetch on form open even while the panel is collapsed.\n // When the caller passes no explicit default, fall back to the value seeded by initSections().\n // If the section isn't in sectionMap yet — which happens during the window before the form's\n // async ngOnInit calls initSections(), e.g. when a record is opened already-loaded via an\n // in-app double-click so the grids render in the first change-detection pass — coalesce to\n // FALSE rather than letting FormStateService fall through to its global expanded default. A\n // missing section must NOT report as expanded, or its data grid (bound [AllowLoad]=\"IsSectionExpanded(key)\")\n // fires a RunView on open before the seeded collapsed default is applied.\n const resolvedDefault = defaultExpanded !== undefined ? defaultExpanded : (section?.isExpanded ?? false);\n const entityName = this.getEntityName();\n if (entityName) {\n return this.formStateService.isSectionExpanded(entityName, sectionKey, resolvedDefault);\n }\n return section ? section.isExpanded : (defaultExpanded !== undefined ? defaultExpanded : true);\n }\n\n public SetSectionExpanded(sectionKey: string, isExpanded: boolean): void {\n const entityName = this.getEntityName();\n if (entityName) {\n this.formStateService.setSectionExpanded(entityName, sectionKey, isExpanded);\n }\n const section = this.sectionMap.get(sectionKey);\n if (section) {\n section.isExpanded = isExpanded;\n }\n }\n\n public GetSectionRowCount(sectionKey: string): number | undefined {\n const section = this.sectionMap.get(sectionKey);\n return section?.rowCount;\n }\n\n public SetSectionRowCount(sectionKey: string, rowCount: number): void {\n let section = this.sectionMap.get(sectionKey);\n if (!section) {\n // Contribution panels use their own SectionKey (e.g. 'orders') which\n // is never seeded by generated initSections(). Upsert so the left-nav\n // rail badge can read the count the same way baked grids do.\n section = new BaseFormSectionInfo(sectionKey, sectionKey, false, rowCount);\n this.sections.push(section);\n this.sectionMap.set(sectionKey, section);\n } else {\n section.rowCount = rowCount;\n }\n this.cdr.markForCheck();\n }\n\n public GetSectionPanelHeight(sectionKey: string): number | undefined {\n const entityName = this.getEntityName();\n if (entityName) {\n return this.formStateService.getSectionPanelHeight(entityName, sectionKey);\n }\n return undefined;\n }\n\n public SetSectionPanelHeight(sectionKey: string, height: number): void {\n const entityName = this.getEntityName();\n if (entityName) {\n this.formStateService.setSectionPanelHeight(entityName, sectionKey, height);\n }\n }\n\n public toggleSection(sectionKey: string): void {\n const entityName = this.getEntityName();\n if (entityName) {\n this.formStateService.toggleSection(entityName, sectionKey);\n }\n const section = this.sectionMap.get(sectionKey);\n if (section) {\n section.isExpanded = !section.isExpanded;\n }\n }\n\n /**\n * Expand any sections that are visible (match the current filter) but currently collapsed.\n * Called after filter changes so the user can immediately see matching content.\n */\n private expandMatchingSections(): void {\n if (!this.collapsiblePanels) return;\n this.collapsiblePanels.forEach(panel => {\n if (panel.IsVisible && !panel.Expanded) {\n this.SetSectionExpanded(panel.SectionKey, true);\n }\n });\n }\n\n public expandAllSections(): void {\n const entityName = this.getEntityName();\n const sectionKeys = this.sections.map(s => s.sectionKey);\n if (entityName && sectionKeys.length > 0) {\n this.formStateService.expandAllSections(entityName, sectionKeys);\n }\n this.sections.forEach(section => {\n section.isExpanded = true;\n });\n }\n\n public collapseAllSections(): void {\n const entityName = this.getEntityName();\n const sectionKeys = this.sections.map(s => s.sectionKey);\n if (entityName && sectionKeys.length > 0) {\n this.formStateService.collapseAllSections(entityName, sectionKeys);\n }\n this.sections.forEach(section => {\n section.isExpanded = false;\n });\n }\n\n public getExpandedCount(): number {\n const entityName = this.getEntityName();\n const sectionKeys = this.sections.map(s => s.sectionKey);\n if (entityName && sectionKeys.length > 0) {\n return this.formStateService.getExpandedCount(entityName, sectionKeys);\n }\n return this.sections.filter(section => section.isExpanded).length;\n }\n\n public getVisibleSectionCount(): number {\n if (!this.collapsiblePanels || this.collapsiblePanels.length === 0) {\n return this.sections.length;\n }\n return this.collapsiblePanels.filter(panel => panel.IsVisible).length;\n }\n\n public getTotalSectionCount(): number {\n return this.sections.length;\n }\n\n public onFilterChange(searchTerm: string): void {\n this.filterSubject.next(searchTerm);\n }\n\n public getEntityName(): string {\n return this.record?.EntityInfo?.Name || '';\n }\n\n /**\n * Component-level default width mode, used when the user has NOT\n * explicitly chosen a width for this entity yet (first visit, nothing\n * persisted in User Settings). Subclasses can override this — for\n * example, custom forms with full-bleed layouts should return\n * `'full-width'` here and the container will respect it on first open.\n *\n * Once the user toggles the width via the toolbar, their choice\n * persists via `setFormWidthMode()` and takes priority over this\n * default on subsequent opens.\n */\n public getDefaultFormWidthMode(): 'centered' | 'full-width' {\n return this.Config?.WidthMode ?? 'centered';\n }\n\n public getFormWidthMode(): 'centered' | 'full-width' {\n const entityName = this.getEntityName();\n if (entityName && this.formStateService.hasExplicitWidthMode(entityName)) {\n return this.formStateService.getWidthMode(entityName);\n }\n return this.getDefaultFormWidthMode();\n }\n\n public setFormWidthMode(widthMode: 'centered' | 'full-width'): void {\n const entityName = this.getEntityName();\n if (entityName) {\n this.formStateService.setWidthMode(entityName, widthMode);\n }\n }\n\n public toggleFormWidthMode(): void {\n const entityName = this.getEntityName();\n if (entityName) {\n this.formStateService.toggleWidthMode(entityName);\n }\n }\n\n // #endregion\n\n // #region Section Ordering\n\n public getSectionOrder(): string[] {\n const entityName = this.getEntityName();\n if (entityName) {\n const customOrder = this.formStateService.getSectionOrder(entityName);\n if (customOrder && customOrder.length > 0) {\n return customOrder;\n }\n }\n return this.sections.map(s => s.sectionKey);\n }\n\n public setSectionOrder(sectionOrder: string[]): void {\n const entityName = this.getEntityName();\n if (entityName) {\n this.formStateService.setSectionOrder(entityName, sectionOrder);\n }\n }\n\n public resetSectionOrder(): void {\n const entityName = this.getEntityName();\n if (entityName) {\n this.formStateService.resetSectionOrder(entityName);\n }\n }\n\n public hasCustomSectionOrder(): boolean {\n const entityName = this.getEntityName();\n if (entityName) {\n return this.formStateService.hasCustomSectionOrder(entityName);\n }\n return false;\n }\n\n public getMoreSectionKeys(): string[] {\n const entityName = this.getEntityName();\n if (!entityName) return [];\n return this.formStateService.getMoreSectionKeys(entityName) ?? [];\n }\n\n public getFirstClassSectionKeys(): string[] {\n const entityName = this.getEntityName();\n if (!entityName) return [];\n return this.formStateService.getFirstClassSectionKeys(entityName) ?? [];\n }\n\n public setChromeMembership(moreSectionKeys: string[], firstClassSectionKeys: string[]): void {\n const entityName = this.getEntityName();\n if (entityName) {\n this.formStateService.setChromeMembership(entityName, moreSectionKeys, firstClassSectionKeys);\n }\n }\n\n public getSectionDisplayOrder(sectionKey: string): number {\n const order = this.getSectionOrder();\n const index = order.indexOf(sectionKey);\n return index >= 0 ? index : this.sections.length;\n }\n\n // #endregion\n\n // #region Form Container Event Handlers\n\n /**\n * Handles navigation events from the form container and related entity grids.\n * Relays the event upward via the Navigate @Output for the host application to handle.\n * Generated form templates bind this as: (Navigate)=\"OnFormNavigate($event)\"\n */\n public OnFormNavigate(event: FormNavigationEvent): void {\n this.Navigate.emit(event);\n }\n\n /**\n * Handles delete requests from the form container.\n * Emits RecordDeleted on success, RecordDeleteFailed on failure.\n * Generated form templates bind this as: (DeleteRequested)=\"OnDeleteRequested()\"\n */\n public async OnDeleteRequested(): Promise<void> {\n if (!this.record || !this.record.IsSaved) return;\n try {\n const result = await this.record.Delete();\n if (result) {\n this.Notification.emit({ Message: 'Record deleted successfully', Type: 'success', Duration: 2500 });\n this.RecordDeleted.emit({\n EntityName: this.record.EntityInfo.Name,\n RecordId: this.record.PrimaryKey.ToString()\n });\n } else {\n const errorMsg = 'Error deleting record';\n this.Notification.emit({ Message: errorMsg, Type: 'error', Duration: 5000 });\n this.RecordDeleteFailed.emit({ EntityName: this.record.EntityInfo.Name, ErrorMessage: errorMsg });\n }\n } catch (e) {\n const errorMsg = 'Error deleting record: ' + e;\n this.Notification.emit({ Message: errorMsg, Type: 'error', Duration: 5000 });\n this.RecordDeleteFailed.emit({ EntityName: this.record.EntityInfo.Name, ErrorMessage: errorMsg });\n }\n }\n\n /**\n * Handles favorite toggle from the form container.\n * Generated form templates bind this as: (FavoriteToggled)=\"OnFavoriteToggled()\"\n */\n public async OnFavoriteToggled(): Promise<void> {\n await this.SetFavoriteStatus(!this.IsFavorite);\n }\n\n /**\n * Handles history view requests from the form container.\n * Generated form templates bind this as: (HistoryRequested)=\"OnHistoryRequested()\"\n */\n public OnHistoryRequested(): void {\n this.handleHistoryDialog();\n }\n\n /**\n * Handles list management requests from the form container.\n * Generated form templates bind this as: (ListManagementRequested)=\"OnListManagementRequested()\"\n */\n public OnListManagementRequested(): void {\n // List management dialog is handled by the host application\n // Subclasses can override this to implement custom list management\n }\n\n // #endregion\n}\n"]}
1
+ {"version":3,"file":"base-form-component.js","sourceRoot":"","sources":["../../src/lib/base-form-component.ts"],"names":[],"mappings":"AAAA,OAAO,EAC6B,SAAS,EAC3C,YAAY,EAAa,UAAU,EAAE,iBAAiB,EACtD,MAAM,EAAE,YAAY,EAAE,MAAM,EAC7B,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,OAAO,EAAgB,YAAY,E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AED;;;OAGG;IACI,KAAK,CAAC,iBAAiB;QAC5B,MAAM,IAAI,CAAC,iBAAiB,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACjD,CAAC;IAED;;;OAGG;IACI,kBAAkB;QACvB,IAAI,CAAC,mBAAmB,EAAE,CAAC;IAC7B,CAAC;IAED;;;OAGG;IACI,yBAAyB;QAC9B,4DAA4D;QAC5D,mEAAmE;IACrE,CAAC;iPAvyCmB,iBAAiB,yBAAjB,iBAAiB;6DAAjB,iBAAiB;2BAmNvB,2BAA2B;;;;;;iFAnNrB,iBAAiB;cADtC,SAAS;;kBAiLP,MAAM;;kBAGN,MAAM;;kBAGN,MAAM;;kBAGN,MAAM;;kBAGN,MAAM;;kBAGN,MAAM;;kBAGN,MAAM;;kBAGN,MAAM;;kBAON,MAAM;;kBAON,YAAY;mBAAC,2BAA2B","sourcesContent":["import {\n AfterViewInit, OnInit, OnDestroy, Directive,\n ViewChildren, QueryList, ElementRef, ChangeDetectorRef,\n Output, EventEmitter, inject\n} from '@angular/core';\n\nimport { Subject, Subscription, debounceTime } from 'rxjs';\nimport {\n EntityInfo, ValidationResult, BaseEntity, EntityPermissionType,\n EntityRelationshipInfo, EntityOrganicKeyInfo, EntityOrganicKeyRelatedEntityInfo,\n Metadata, RunViewParams, LogError,\n RecordDependency, BaseEntityEvent, CompositeKey, RunView, RunViewResult\n} from '@memberjunction/core';\nimport { DeserializeValidationErrors, MJEventType, MJGlobal, ValidationErrorInfo } from '@memberjunction/global';\nimport { FormEditingCompleteEvent, PendingRecordItem, BaseFormComponentEventCodes } from '@memberjunction/ng-base-types';\nimport { MJListEntity } from '@memberjunction/core-entities';\n\nimport { BaseRecordComponent } from './base-record-component';\nimport { BaseFormSectionInfo } from './base-form-section-info';\nimport { MjCollapsiblePanelComponent } from './panel/collapsible-panel.component';\nimport { FormNavigationEvent } from './types/navigation-events';\nimport {\n FormContext,\n FormNotificationEvent,\n RecordSavedEvent,\n RecordRefreshedEvent,\n RecordDeletedEvent,\n RecordSaveFailedEvent,\n RecordDeleteFailedEvent,\n ValidationFailedEvent\n} from './types/form-types';\nimport { FormStateService } from './form-state.service';\nimport { EntityFormConfig } from './types/entity-form-config';\nimport { FormToolbarItemConfig, FormToolbarItemKey, FormToolbarItemClickEventArgs } from './types/form-toolbar-item';\nimport { CollectFormPanelRegistrations } from './panel-slot/collect-form-panel-registrations';\nimport { ContributionHiddenSectionKeys } from './panel-slot/form-contribution';\n\n/**\n * Abstract base class for all entity record forms in MemberJunction.\n *\n * Generated forms (via CodeGen) and custom forms extend this class.\n * It provides core form logic — section management, validation, pending records,\n * permissions, favorites, related entity helpers — with ZERO Explorer dependencies.\n *\n * Instead of calling Explorer services directly, events are emitted via @Output:\n * - **Navigate**: Form navigation requests (record links, new records, external links)\n * - **Notification**: User-facing notifications (save success, validation errors, etc.)\n * - **RecordSaved**: Emitted after a successful save\n * - **RecordDeleted**: Emitted after a successful delete\n *\n * The host application (e.g. SingleRecordComponent in Explorer) subscribes to\n * these events and maps them to its own services (NavigationService, SharedService, etc.).\n */\n@Directive()\nexport abstract class BaseFormComponent extends BaseRecordComponent implements AfterViewInit, OnInit, OnDestroy {\n public EditMode: boolean = false;\n public IsRefreshing: boolean = false;\n public FavoriteInitDone: boolean = false;\n\n /**\n * Per-instance presentation config (toolbar visibility, related-entity\n * sections, collapsibility, width, in-form navigation). Set by the form host\n * (`MjEntityFormHostComponent`) or any consumer that instantiates the form\n * directly. Read back by `MjRecordFormContainerComponent` and the collapsible\n * panels through the `FormComponent` reference, so it takes effect WITHOUT\n * regenerating the CodeGen-produced template. Null means \"use the container's\n * own defaults\" (the classic full-page tab behavior).\n */\n public Config: EntityFormConfig | null = null;\n\n /**\n * Variants applicable to the current (entity, user) tuple, supplied by the\n * Explorer-level form resolver. When more than one entry is present, the\n * record-form-container shows a picker that lets the user switch between\n * variants. Empty / single-entry arrays hide the picker.\n *\n * The container reads this via its `EffectiveVariants` accessor — generated\n * form templates do NOT need to bind it explicitly.\n */\n public Variants: { ID: string; Label: string; Scope: 'User' | 'Role' | 'Global'; Status: 'Active' | 'Pending' | 'Inactive' }[] = [];\n\n /**\n * ID of the currently-rendered variant (null when no override is active and\n * the form is the CodeGen / @RegisterClass default).\n */\n public CurrentVariantID: string | null = null;\n\n /**\n * Hook called when the user picks a different variant from the picker.\n * Default is a no-op; the Explorer-level single-record component replaces\n * this on the form instance to wire `FormResolverService.SetSelectedVariant`\n * and reload the record. Kept as a method (not an EventEmitter) so the host\n * doesn't need to subscribe — assignment is enough.\n */\n public OnVariantChanged: (variantID: string | null) => void = (_id) => {\n // host installs the real handler post-construction\n };\n public isHistoryDialogOpen: boolean = false;\n public IsTagsPanelOpen: boolean = false;\n public TagCount: number = 0;\n public showDeleteDialog: boolean = false;\n public showCreateDialog: boolean = false;\n\n /**\n * Height of the top area when a splitter layout is used.\n * Referenced by CodeGen-generated templates for entities with \"top area\" sections.\n */\n public TopAreaHeight: string = '300px';\n\n /**\n * Size of the top area as a percentage (0-100) for angular-split.\n * Used by CodeGen-generated templates with as-split.\n */\n public TopAreaSize: number = 40;\n\n /**\n * Size of the bottom area as a percentage (0-100) for angular-split.\n * Used by CodeGen-generated templates with as-split.\n */\n public BottomAreaSize: number = 60;\n\n /**\n * Called when the splitter layout changes (for entities with \"top area\" sections).\n * No-op in the generic version; override in host application if splitter resizing is needed.\n */\n public splitterLayoutChange(): void {\n // No-op — host application can override\n }\n\n private _pendingRecords: PendingRecordItem[] = [];\n private _registeredToolbarItems = new Map<string, FormToolbarItemConfig>();\n private _toolbarItemOverrides = new Map<string, Partial<FormToolbarItemConfig>>();\n\n /**\n * Registers a dynamic toolbar action item / button.\n * Can be called during ngOnInit or at runtime.\n */\n public RegisterToolbarItem(item: FormToolbarItemConfig): void {\n this._registeredToolbarItems.set(item.Key, { ...item });\n this.cdr?.markForCheck();\n }\n\n /**\n * Unregisters a previously registered dynamic toolbar item by key.\n */\n public UnregisterToolbarItem(key: string): void {\n if (this._registeredToolbarItems.delete(key)) {\n this.cdr?.markForCheck();\n }\n }\n\n /**\n * Configures overrides for any toolbar item (standard built-in items like 'edit',\n * 'delete', 'favorite', 'history', etc., or custom items).\n * Allows dynamically changing visibility, disabled state, tooltips, order, icon, etc.\n */\n public ConfigureToolbarItem(key: FormToolbarItemKey, overrides: Partial<FormToolbarItemConfig>): void {\n const existing = this._toolbarItemOverrides.get(key) || {};\n this._toolbarItemOverrides.set(key, { ...existing, ...overrides });\n this.cdr?.markForCheck();\n }\n\n /**\n * Dynamically hides a toolbar item by key.\n */\n public HideToolbarItem(key: FormToolbarItemKey): void {\n this.ConfigureToolbarItem(key, { Visible: false });\n }\n\n /**\n * Dynamically shows a toolbar item by key.\n */\n public ShowToolbarItem(key: FormToolbarItemKey): void {\n this.ConfigureToolbarItem(key, { Visible: true });\n }\n\n /**\n * Dynamically disables a toolbar item by key, with an optional reason string for the tooltip.\n */\n public DisableToolbarItem(key: FormToolbarItemKey, reason?: string): void {\n this.ConfigureToolbarItem(key, { Disabled: reason ?? true });\n }\n\n /**\n * Dynamically enables a toolbar item by key.\n */\n public EnableToolbarItem(key: FormToolbarItemKey): void {\n this.ConfigureToolbarItem(key, { Disabled: false });\n }\n\n /**\n * Sets the numeric display order for a toolbar item (lower numbers appear earlier).\n */\n public SetToolbarItemOrder(key: FormToolbarItemKey, order: number): void {\n this.ConfigureToolbarItem(key, { Order: order });\n }\n\n /**\n * Returns all dynamically registered toolbar items.\n */\n public get RegisteredToolbarItems(): FormToolbarItemConfig[] {\n return Array.from(this._registeredToolbarItems.values());\n }\n\n /**\n * Returns the map of toolbar item overrides.\n */\n public get ToolbarItemOverrides(): ReadonlyMap<string, Partial<FormToolbarItemConfig>> {\n return this._toolbarItemOverrides;\n }\n\n /**\n * Hook invoked when a custom or dynamic toolbar item is clicked.\n * Subclasses can override this method to handle custom button clicks.\n */\n public OnCustomToolbarButtonClick(event: FormToolbarItemClickEventArgs): void {\n // Subclasses can override\n }\n\n // #region Injected Dependencies (no constructor params)\n\n protected elementRef = inject(ElementRef);\n public cdr = inject(ChangeDetectorRef);\n protected formStateService = inject(FormStateService);\n\n // #endregion\n\n // #region @Output Events\n\n /** Emitted when navigation is requested (record link, external link, email, new record, etc.) */\n @Output() Navigate = new EventEmitter<FormNavigationEvent>();\n\n /** Emitted when a user-facing notification should be shown */\n @Output() Notification = new EventEmitter<FormNotificationEvent>();\n\n /** Emitted after a record is saved successfully */\n @Output() RecordSaved = new EventEmitter<RecordSavedEvent>();\n\n /** Emitted after a record is refreshed from the database successfully */\n @Output() RecordRefreshed = new EventEmitter<RecordRefreshedEvent>();\n\n /** Emitted after a record is deleted successfully */\n @Output() RecordDeleted = new EventEmitter<RecordDeletedEvent>();\n\n /** Emitted when a record save fails */\n @Output() RecordSaveFailed = new EventEmitter<RecordSaveFailedEvent>();\n\n /** Emitted when a record delete fails */\n @Output() RecordDeleteFailed = new EventEmitter<RecordDeleteFailedEvent>();\n\n /** Emitted when validation fails before save */\n @Output() ValidationFailed = new EventEmitter<ValidationFailedEvent>();\n\n /**\n * Emitted once after ngOnInit completes and the record is fully initialized\n * (favorites loaded, form state initialized). This is the safe point for\n * the container to start loading badge counts and other record-dependent data.\n */\n @Output() RecordReady = new EventEmitter<BaseEntity>();\n\n // #endregion\n\n /** Subscription to form state changes */\n private formStateSubscription?: Subscription;\n\n @ViewChildren(MjCollapsiblePanelComponent)\n collapsiblePanels!: QueryList<MjCollapsiblePanelComponent>;\n\n async ngOnInit() {\n if (this.record) {\n if (!this.record.IsSaved) {\n this.StartEditMode();\n }\n const md = this.ProviderToUse;\n // Bind FormStateService to the same provider this form is using.\n this.formStateService.Provider = md;\n this._isFavorite = await md.GetRecordFavoriteStatus(md.CurrentUser.ID, this.record.EntityInfo.Name, this.record.PrimaryKey);\n this.FavoriteInitDone = true;\n\n // Initialize form state from User Settings\n const entityName = this.getEntityName();\n if (entityName) {\n await this.formStateService.initializeState(entityName);\n this.formStateSubscription = this.formStateService.getState$(entityName).subscribe(state => {\n this.showEmptyFields = state.showEmptyFields;\n this.cdr.markForCheck();\n });\n }\n }\n\n // Signal that the record is fully initialized and ready for dependent operations\n if (this.record) {\n this.RecordReady.emit(this.record);\n }\n\n // Set up debounced filter subscription\n this.filterSubscription = this.filterSubject\n .pipe(debounceTime(100))\n .subscribe(searchTerm => {\n this.searchFilter = searchTerm;\n // After change detection propagates FormContext to panels and they update\n // their IsVisible state, expand any visible (matching) sections that are collapsed\n if (searchTerm) {\n Promise.resolve().then(() => this.expandMatchingSections());\n }\n });\n }\n\n ngAfterViewInit(): void {\n // Subclasses can override for post-view-init logic\n }\n\n ngOnDestroy(): void {\n if (this.filterSubscription) {\n this.filterSubscription.unsubscribe();\n }\n if (this.formStateSubscription) {\n this.formStateSubscription.unsubscribe();\n }\n }\n\n // #region Pending Records\n\n protected get PendingRecords(): PendingRecordItem[] {\n return this._pendingRecords;\n }\n\n /**\n * Unsaved changes a form holds OUTSIDE its record's fields and pending records.\n *\n * A form whose sections own editors — a flow canvas, a designer, a grid — accumulates edits that\n * neither `record.Dirty` nor `PendingRecordsDirty()` can see, because nothing on the entity\n * changed. Without this the toolbar reports \"no changes\" while the user is looking at their own\n * work, and the navigate-away guard lets them lose it silently.\n *\n * Default `false`, so no existing form changes behaviour. Override to consult whatever holds the\n * extra state.\n */\n public get HasAdditionalUnsavedChanges(): boolean {\n return false;\n }\n\n protected PendingRecordsDirty(): boolean {\n this.PopulatePendingRecords();\n const pendingRecords = this.PendingRecords;\n if (pendingRecords && pendingRecords.length > 0) {\n for (const p of pendingRecords) {\n if (p.action === 'delete')\n return true;\n else if (p.entityObject.Dirty)\n return true;\n }\n }\n return false;\n }\n\n protected PopulatePendingRecords() {\n this._pendingRecords = [];\n this.RaiseEvent(BaseFormComponentEventCodes.EDITING_COMPLETE);\n const result = this.RaiseEvent(BaseFormComponentEventCodes.POPULATE_PENDING_RECORDS);\n if (result && result.pendingChanges) {\n for (const p of result.pendingChanges)\n this.PendingRecords.push(p);\n }\n }\n\n protected ValidatePendingRecords(): ValidationResult[] {\n const results: ValidationResult[] = [];\n for (let i = 0; i < this._pendingRecords.length; i++) {\n const pendingRecord = this._pendingRecords[i];\n results.push(pendingRecord.entityObject.Validate());\n }\n return results;\n }\n\n // #endregion\n\n // #region Edit Mode\n\n public StartEditMode(): void {\n this.EditMode = true;\n const entityName = this.getEntityName();\n if (entityName) {\n this.formStateService.setEditMode(entityName, true);\n }\n }\n\n public EndEditMode(): void {\n this.EditMode = false;\n this.clearValidationState();\n const entityName = this.getEntityName();\n if (entityName) {\n this.formStateService.setEditMode(entityName, false);\n }\n }\n\n public handleHistoryDialog(): void {\n this.isHistoryDialogOpen = !this.isHistoryDialogOpen;\n }\n\n public HandleTagsPanel(): void {\n this.IsTagsPanelOpen = !this.IsTagsPanelOpen;\n }\n\n // #endregion\n\n // #region Core Form Operations\n\n public Validate(): ValidationResult {\n const valResults = (<BaseEntity>this.record).Validate();\n const pendingValResults = this.ValidatePendingRecords();\n for (let i = 0; i < pendingValResults.length; i++) {\n const pendingValResult = pendingValResults[i];\n if (!pendingValResult.Success) {\n valResults.Success = false;\n valResults.Errors.push(...pendingValResult.Errors);\n }\n }\n return valResults;\n }\n\n protected RaiseEvent(eventCode: BaseFormComponentEventCodes) {\n const event = new FormEditingCompleteEvent();\n event.elementRef = this.elementRef;\n event.subEventCode = eventCode;\n\n MJGlobal.Instance.RaiseEvent({\n event: MJEventType.ComponentEvent,\n component: this,\n eventCode: BaseFormComponentEventCodes.BASE_CODE,\n args: event\n });\n\n return event;\n }\n\n public async SaveRecord(StopEditModeAfterSave: boolean): Promise<boolean> {\n try {\n try {\n (document.activeElement as HTMLElement).blur();\n this.RaiseEvent(BaseFormComponentEventCodes.EDITING_COMPLETE);\n } catch (_e) {\n // ignore blur errors\n }\n\n if (this.record) {\n this.PopulatePendingRecords();\n const valResults = this.Validate();\n if (valResults.Success) {\n const result = await this.InternalSaveRecord();\n if (result) {\n this._pendingRecords = [];\n this.clearValidationState();\n if (StopEditModeAfterSave)\n this.EndEditMode();\n\n this.Notification.emit({ Message: 'Record saved successfully', Type: 'success', Duration: 2500 });\n this.RecordSaved.emit({\n EntityName: this.record.EntityInfo.Name,\n RecordId: this.record.PrimaryKey.ToString(),\n Result: { Success: true }\n });\n return true;\n } else {\n const serverMsg = this.record.LatestResult?.Message || '';\n const errorMsg = serverMsg ? `Save failed: ${serverMsg}` : 'Error saving record';\n // A server-side Validate()/ValidateAsync() refusal comes back with its field-named\n // reasons in LatestResult.Errors (rehydrated by the provider). When any of them names a\n // field on this record, publish them through the SAME path the local Validate() branch\n // uses below, so the field paints red with its message instead of the user getting a\n // toast and a form with nothing marked. Errors with no field source stay toast-only.\n const serverErrors = this.fieldSourcedServerErrors();\n if (serverErrors.length > 0) {\n this.publishValidationFailure(serverErrors);\n } else {\n this.Notification.emit({ Message: errorMsg, Type: 'error', Duration: 5000 });\n }\n this.RecordSaveFailed.emit({ EntityName: this.record.EntityInfo.Name, ErrorMessage: errorMsg });\n }\n } else {\n this.publishValidationFailure(valResults.Errors);\n }\n }\n\n LogError(\"Could not save record: Record not found\");\n return false;\n } catch (e) {\n const errorMsg = 'Error saving record: ' + e;\n this.Notification.emit({ Message: errorMsg, Type: 'error', Duration: 5000 });\n if (this.record) {\n this.RecordSaveFailed.emit({ EntityName: this.record.EntityInfo.Name, ErrorMessage: errorMsg });\n }\n return false;\n }\n }\n\n public CancelEdit() {\n if (this.record) {\n const r = <BaseEntity>this.record;\n // Capture BEFORE any mutation — Revert() can clear the \"new\" flag on some\n // entities. We need to know whether this record was ever persisted so we\n // can tell the host to dismiss the form (there's nothing to view).\n const wasNeverSaved = !r.IsSaved;\n\n if (r.Dirty || this.PendingRecordsDirty()) {\n // Revert is safe here — the toolbar's discard dialog already confirmed with the user\n r.Revert();\n\n const pendingRecords = this.PendingRecords;\n if (pendingRecords && pendingRecords.length > 0) {\n pendingRecords.forEach(p => {\n if (p.action === 'save')\n p.entityObject.Revert();\n });\n }\n this.RaiseEvent(BaseFormComponentEventCodes.REVERT_PENDING_CHANGES);\n }\n this.EndEditMode();\n\n // For never-saved records, ask the host to dismiss the form — leaving it\n // in view mode shows an empty record (there IS no record) and any\n // subsequent \"Create New\" click for the same entity would silently\n // reuse this abandoned form. Hosts that don't have a meaningful close\n // semantic can ignore this event.\n if (wasNeverSaved) {\n this.Navigate.emit({ Kind: 'dismiss', Reason: 'new-record-discarded' });\n }\n }\n }\n\n /**\n * Re-fetches the current record from the database, updating field values\n * in-place and resetting dirty flags. No-op in edit mode or on an unsaved\n * record. Related-entity grids are notified via the form container's\n * {@link FormRecordRefreshCoordinator} after this emits {@link RecordRefreshed}.\n *\n * @returns true if the record was reloaded from the database.\n */\n public async RefreshRecord(): Promise<boolean> {\n if (!this.canRefreshRecord()) {\n return false;\n }\n\n this.IsRefreshing = true;\n this.cdr.markForCheck();\n\n try {\n return await this.executeRecordRefresh();\n } finally {\n this.IsRefreshing = false;\n this.cdr.markForCheck();\n }\n }\n\n private canRefreshRecord(): boolean {\n return !!this.record && this.record.IsSaved && !this.EditMode;\n }\n\n private async executeRecordRefresh(): Promise<boolean> {\n const record = this.record;\n if (!record) {\n return false;\n }\n\n try {\n const ok = await record.Refresh();\n if (!ok) {\n this.Notification.emit({\n Message: 'Failed to refresh record from database',\n Type: 'error',\n Duration: 5000,\n });\n return false;\n }\n\n await this.reloadFavoriteStatusAfterRefresh(record);\n this.Notification.emit({\n Message: 'Record refreshed from database',\n Type: 'info',\n Duration: 2000,\n });\n this.RecordRefreshed.emit({\n EntityName: record.EntityInfo.Name,\n Record: record,\n });\n return true;\n } catch (e) {\n const detail = e instanceof Error ? e.message : String(e);\n this.Notification.emit({\n Message: 'Error refreshing record: ' + detail,\n Type: 'error',\n Duration: 5000,\n });\n return false;\n }\n }\n\n private async reloadFavoriteStatusAfterRefresh(record: BaseEntity): Promise<void> {\n const md = this.ProviderToUse;\n try {\n this._isFavorite = await md.GetRecordFavoriteStatus(\n md.CurrentUser.ID,\n record.EntityInfo.Name,\n record.PrimaryKey,\n );\n } catch {\n // Non-critical — favorite status remains as is\n }\n }\n\n protected async InternalSaveRecord(): Promise<boolean> {\n if (this.record) {\n if (this._pendingRecords.length > 0) {\n const md = this.ProviderToUse;\n const tg = await md.CreateTransactionGroup();\n this.record.TransactionGroup = tg;\n await this.record.Save();\n\n for (const x of this._pendingRecords) {\n x.entityObject.TransactionGroup = tg;\n if (x.action === 'save') {\n await x.entityObject.Save();\n } else {\n await x.entityObject.Delete();\n }\n }\n return await tg.Submit();\n } else {\n return await this.record.Save();\n }\n } else {\n return false;\n }\n }\n\n public async Wait(duration: number): Promise<void> {\n return new Promise<void>(resolve => setTimeout(resolve, duration));\n }\n\n // #endregion\n\n // #region Permissions\n\n private _userPermissions: { permission: EntityPermissionType; canDo: boolean }[] = [];\n\n public CheckUserPermission(type: EntityPermissionType): boolean {\n try {\n if (this.record) {\n const perm = this._userPermissions.find(x => x.permission === type);\n if (perm)\n return perm.canDo;\n else {\n const result = this.record.CheckPermissions(type, false);\n this._userPermissions.push({ permission: type, canDo: result });\n return result;\n }\n } else {\n return false;\n }\n } catch (e) {\n LogError(e);\n return false;\n }\n }\n\n public get UserCanEdit(): boolean {\n return this.CheckUserPermission(EntityPermissionType.Update);\n }\n\n public get UserCanRead(): boolean {\n return this.CheckUserPermission(EntityPermissionType.Read);\n }\n\n public get UserCanCreate(): boolean {\n return this.CheckUserPermission(EntityPermissionType.Create);\n }\n\n public get UserCanDelete(): boolean {\n return this.CheckUserPermission(EntityPermissionType.Delete);\n }\n\n // #endregion\n\n // #region Grid Edit Mode\n\n public GridEditMode(): \"None\" | \"Save\" | \"Queue\" {\n return this.EditMode ? \"Queue\" : \"None\";\n }\n\n // #endregion\n\n // #region Favorites\n\n private _isFavorite: boolean = false;\n\n public get IsFavorite(): boolean {\n return this._isFavorite;\n }\n\n public async RemoveFavorite(): Promise<void> {\n return this.SetFavoriteStatus(false);\n }\n\n public async MakeFavorite(): Promise<void> {\n return this.SetFavoriteStatus(true);\n }\n\n public async SetFavoriteStatus(isFavorite: boolean) {\n const md = this.ProviderToUse;\n await md.SetRecordFavoriteStatus(md.CurrentUser.ID, this.record.EntityInfo.Name, this.record.PrimaryKey, isFavorite, md.CurrentUser);\n this._isFavorite = isFavorite;\n }\n\n // #endregion\n\n // #region Related Entity Helpers\n\n public BuildRelationshipViewParams(item: EntityRelationshipInfo): RunViewParams {\n return EntityInfo.BuildRelationshipViewParams(this.record, item);\n }\n\n public BuildRelationshipViewParamsByEntityName(relatedEntityName: string, relatedEntityJoinField?: string): RunViewParams {\n const eri = this.GetEntityRelationshipByRelatedEntityName(relatedEntityName, relatedEntityJoinField);\n if (eri)\n return this.BuildRelationshipViewParams(eri);\n else\n return {};\n }\n\n /**\n * One grid over several FKs to the same related entity (Bill-To OR Ship-To).\n */\n public BuildRelationshipViewParamsForJoinFields(relatedEntityName: string, joinFields: readonly string[]): RunViewParams {\n if (!this.record) return {};\n return EntityInfo.BuildRelationshipViewParamsForJoinFields(this.record, relatedEntityName, joinFields);\n }\n\n public GetEntityRelationshipByRelatedEntityName(relatedEntityName: string, relatedEntityJoinField?: string): EntityRelationshipInfo | undefined {\n if (this.record) {\n const r = <BaseEntity>this.record;\n const ret = r.EntityInfo.RelatedEntities.filter(x => x.RelatedEntity.trim().toLowerCase() === relatedEntityName.trim().toLowerCase());\n if (ret.length > 1 && relatedEntityJoinField) {\n const ret2 = ret.find(x => x.RelatedEntityJoinField.trim().toLowerCase() === relatedEntityJoinField.trim().toLowerCase());\n if (ret2)\n return ret2;\n } else if (ret.length === 1) {\n return ret[0];\n } else {\n return undefined;\n }\n }\n return undefined;\n }\n\n /**\n * Default values for a new related-entity record so it links back here.\n * Pass `relatedEntityJoinField` when more than one relationship targets the\n * same entity (Bill-To vs Ship-To). When omitted and several matches exist,\n * every matching FK is set — same fields the related grid is filtering on.\n */\n public NewRecordValues(relatedEntityName: string, relatedEntityJoinField?: string): Record<string, unknown> {\n if (!this.record) return {};\n if (relatedEntityJoinField) {\n const eri = this.GetEntityRelationshipByRelatedEntityName(relatedEntityName, relatedEntityJoinField);\n if (eri) return this.NewRecordValuesByEntityRelationship(eri);\n return EntityInfo.BuildRelationshipNewRecordValuesForJoinFields(this.record, [relatedEntityJoinField]);\n }\n const matches = this.record.EntityInfo.RelatedEntities.filter(\n (x) => x.RelatedEntity.trim().toLowerCase() === relatedEntityName.trim().toLowerCase(),\n );\n if (matches.length === 0) return {};\n if (matches.length === 1) return this.NewRecordValuesByEntityRelationship(matches[0]);\n return EntityInfo.BuildRelationshipNewRecordValuesForJoinFields(\n this.record,\n matches.map((m) => m.RelatedEntityJoinField),\n );\n }\n\n /**\n * Default values for a new related record, setting every listed join field\n * to this record's key. Pair with {@link BuildRelationshipViewParamsForJoinFields}.\n */\n public NewRecordValuesForJoinFields(relatedEntityName: string, joinFields: readonly string[]): Record<string, unknown> {\n if (!this.record || !relatedEntityName) return {};\n return EntityInfo.BuildRelationshipNewRecordValuesForJoinFields(this.record, joinFields);\n }\n\n public NewRecordValuesByEntityRelationship(item: EntityRelationshipInfo): Record<string, unknown> {\n return EntityInfo.BuildRelationshipNewRecordValues(this.record, item);\n }\n\n public GetRelatedEntityTabDisplayName(relatedEntityName: string): string {\n if (this.record) {\n const eri = (<BaseEntity>this.record).EntityInfo.RelatedEntities.find(x => x.RelatedEntity === relatedEntityName);\n if (eri)\n return eri.DisplayName;\n }\n return relatedEntityName;\n }\n\n public get HasRelatedEntities(): boolean {\n if (this.record) {\n const relatedEntities = (<BaseEntity>this.record).EntityInfo.RelatedEntities;\n return relatedEntities && relatedEntities.length > 0;\n }\n return false;\n }\n\n // #endregion\n\n // #region Organic Key Helpers\n\n /**\n * Returns all active organic keys for the current entity, or an empty array if none.\n */\n public get OrganicKeys(): EntityOrganicKeyInfo[] {\n if (this.record) {\n return (<BaseEntity>this.record).EntityInfo.OrganicKeys || [];\n }\n return [];\n }\n\n /**\n * Whether the current entity has any active organic keys with related entities configured.\n */\n public get HasOrganicKeys(): boolean {\n return this.OrganicKeys.some(ok => ok.RelatedEntities.length > 0);\n }\n\n /**\n * Returns all organic key related entities across all organic keys, flattened and sorted.\n */\n public get AllOrganicKeyRelatedEntities(): { OrganicKey: EntityOrganicKeyInfo; RelatedEntity: EntityOrganicKeyRelatedEntityInfo }[] {\n const result: { OrganicKey: EntityOrganicKeyInfo; RelatedEntity: EntityOrganicKeyRelatedEntityInfo }[] = [];\n for (const ok of this.OrganicKeys) {\n for (const re of ok.RelatedEntities) {\n result.push({ OrganicKey: ok, RelatedEntity: re });\n }\n }\n return result;\n }\n\n /**\n * Builds RunViewParams for a specific organic key related entity.\n */\n public BuildOrganicKeyViewParams(\n organicKeyRelatedEntity: EntityOrganicKeyRelatedEntityInfo,\n organicKey: EntityOrganicKeyInfo\n ): RunViewParams {\n if (this.record) {\n return EntityInfo.BuildOrganicKeyViewParams(this.record, organicKeyRelatedEntity, organicKey);\n }\n return {};\n }\n\n /**\n * Convenience method to build organic key view params by organic key name and related entity name.\n */\n public BuildOrganicKeyViewParamsByNames(organicKeyName: string, relatedEntityName: string): RunViewParams {\n const ok = this.OrganicKeys.find(k => k.Name.trim().toLowerCase() === organicKeyName.trim().toLowerCase());\n if (ok) {\n const re = ok.RelatedEntities.find(r => r.RelatedEntity.trim().toLowerCase() === relatedEntityName.trim().toLowerCase());\n if (re) {\n return this.BuildOrganicKeyViewParams(re, ok);\n }\n }\n return {};\n }\n\n // #endregion\n\n // #region Entity Info & Dependencies\n\n public get EntityInfo(): EntityInfo | undefined {\n try {\n const r = <BaseEntity>this.record;\n if (r)\n return r.EntityInfo;\n else\n return undefined;\n } catch (e) {\n LogError(e);\n return undefined;\n }\n }\n\n public async ShowDependencies() {\n const md = this.ProviderToUse;\n const dep = await md.GetRecordDependencies(this.record.EntityInfo.Name, this.record.PrimaryKey);\n console.log('Dependencies for: ' + this.record.EntityInfo.Name + ' ' + this.record.PrimaryKey.ToString());\n console.log(dep);\n }\n\n public ShowChanges(): void {\n if (this.record) {\n const changes = this.record.GetAll(false, true);\n const oldValues = this.record.GetAll(true, true);\n const message =\n 'Changes for: ' + this.record.EntityInfo.Name + ' ' + this.record.PrimaryKey.ToString() +\n '\\n\\n' + JSON.stringify(changes, null, 2) +\n '\\n\\nOld Values\\n\\n' + JSON.stringify(oldValues, null, 2);\n console.log(message);\n this.Notification.emit({ Message: message, Type: 'info', Duration: 30000 });\n }\n }\n\n public async GetListsCanAddTo(): Promise<MJListEntity[]> {\n if (!this.record) {\n LogError('Unable to fetch List records: Record not found');\n return [];\n }\n\n const rv = RunView.FromMetadataProvider(this.ProviderToUse);\n const md = this.ProviderToUse;\n\n const rvResult: RunViewResult<MJListEntity> = await rv.RunView({\n EntityName: 'MJ: Lists',\n ExtraFilter: `UserID = '${md.CurrentUser.ID}' AND EntityID = '${this.record.EntityInfo.ID}'`,\n ResultType: 'entity_object'\n });\n\n if (!rvResult.Success) {\n LogError('Error running view to fetch lists', undefined, rvResult.ErrorMessage);\n return [];\n }\n\n return rvResult.Results;\n }\n\n public async GetRecordDependencies(): Promise<RecordDependency[]> {\n const md = this.ProviderToUse;\n const dependencies: RecordDependency[] = await md.GetRecordDependencies(this.record.EntityInfo.Name, this.record.PrimaryKey);\n return dependencies;\n }\n\n // #endregion\n\n // #region Collapsible Section Management\n\n protected sections: BaseFormSectionInfo[] = [];\n private sectionMap: Map<string, BaseFormSectionInfo> = new Map();\n\n public searchFilter: string = '';\n public showEmptyFields: boolean = false;\n\n /** Whether to show all validation errors on fields (set after save failure) */\n private _showValidation = false;\n /** Validation errors from the most recent failed save attempt */\n private _validationErrors: ValidationErrorInfo[] = [];\n\n public get formContext(): FormContext {\n return {\n sectionFilter: this.searchFilter,\n showEmptyFields: this.showEmptyFields,\n showValidation: this._showValidation,\n validationErrors: this._validationErrors,\n validationRevision: this._validationRevision,\n collapsibleSections: this.Config?.CollapsibleSections,\n enableRecordLinks: this.Config?.EnableRecordLinks,\n showRelatedEntities: this.Config?.ShowRelatedEntities,\n hiddenSectionKeys: this.resolveHiddenSectionKeys(),\n visibleSectionKeys: this.Config?.VisibleSectionKeys,\n allowSectionReorder: this.resolveAllowSectionReorder()\n };\n }\n\n /**\n * Config HiddenSectionKeys plus section keys winning contributions asked\n * to hide (related-entity claims and `replacesSectionKey` field panels).\n */\n private resolveHiddenSectionKeys(): string[] | undefined {\n const claimed = this.contributionHiddenSectionKeys();\n const configured = this.Config?.HiddenSectionKeys;\n if (claimed.length === 0) return configured;\n return [...(configured ?? []), ...claimed];\n }\n\n private contributionHiddenSectionKeys(): string[] {\n const entity = this.record?.EntityInfo;\n if (!entity) return [];\n return ContributionHiddenSectionKeys(\n entity.Name,\n entity.RelatedEntities,\n entity.ChildEntities.map((child) => child.ID),\n CollectFormPanelRegistrations(),\n );\n }\n\n /**\n * Resolves whether section drag-reorder is allowed for the current Config.\n * When no toolbar is rendered (dialog/slide-in, `Config.Toolbar === null`)\n * reorder is disabled; otherwise we honor the toolbar config's flag, defaulting\n * to allowed when unspecified (classic tab behavior).\n */\n private resolveAllowSectionReorder(): boolean {\n if (!this.Config) return true;\n if (this.Config.Toolbar === null) return false;\n return this.Config.Toolbar?.AllowSectionReorder ?? true;\n }\n\n /**\n * Bumped on every {@link publishValidationFailure}; published as `FormContext.validationRevision`\n * so a field can tell an edit made before the failure from one made after it.\n */\n private _validationRevision = 0;\n\n /**\n * The ONE way validation errors reach the fields and the user — used by both the local\n * `Validate()` refusal and a server-side refusal that came back on `LatestResult.Errors`, so the\n * two cannot drift: broadcast through `FormContext` (fields match `Source === FieldName`), bump\n * the revision, toast the messages, and raise `ValidationFailed`.\n */\n private publishValidationFailure(errors: ValidationErrorInfo[]): void {\n this._showValidation = true;\n this._validationErrors = errors;\n this._validationRevision++;\n this.cdr.markForCheck();\n\n const errorMessages = errors.map(x => x.Message);\n this.Notification.emit({\n Message: 'Validation Errors\\n' + errorMessages.join('\\n'),\n Type: 'warning',\n Duration: 5000\n });\n this.ValidationFailed.emit({ EntityName: this.record.EntityInfo.Name, Errors: errorMessages });\n }\n\n /**\n * The structured errors of the last failed save, when at least one names a field on this record.\n *\n * `LatestResult.Errors` is untyped and may hold anything a provider put there, so it is normalised\n * through `DeserializeValidationErrors` first. Returns `[]` unless some entry's `Source` is one of\n * this record's field names — a refusal that is purely record-level (\"the database timed out\",\n * \"not authorised\") has nothing to paint and keeps the plain error toast. When there IS a\n * field-sourced entry, the WHOLE set is returned: field-agnostic entries paint nothing (no field\n * matches an empty Source) but still belong in the toast.\n */\n private fieldSourcedServerErrors(): ValidationErrorInfo[] {\n const errors = DeserializeValidationErrors(this.record?.LatestResult?.Errors);\n if (errors.length === 0) return [];\n const fieldNames = new Set(this.record.EntityInfo.Fields.map(f => f.Name));\n return errors.some(e => e.Source.length > 0 && fieldNames.has(e.Source)) ? errors : [];\n }\n\n /** Clears all validation display state (called on save success, cancel, end edit) */\n private clearValidationState(): void {\n this._showValidation = false;\n this._validationErrors = [];\n }\n\n private filterSubject = new Subject<string>();\n private filterSubscription?: Subscription;\n\n protected initSections(sections: (BaseFormSectionInfo | { sectionKey: string; sectionName: string; isExpanded: boolean; rowCount?: number; metadata?: unknown })[]): void {\n this.sections = sections.map(s =>\n s instanceof BaseFormSectionInfo\n ? s\n : new BaseFormSectionInfo(s.sectionKey, s.sectionName, s.isExpanded, s.rowCount, s.metadata)\n );\n this.sectionMap.clear();\n this.sections.forEach(section => {\n this.sectionMap.set(section.sectionKey, section);\n });\n }\n\n protected getSection(sectionKey: string): BaseFormSectionInfo | undefined {\n return this.sectionMap.get(sectionKey);\n }\n\n public IsSectionExpanded(sectionKey: string, defaultExpanded?: boolean): boolean {\n const section = this.sectionMap.get(sectionKey);\n // When the caller doesn't pass an explicit default, fall back to the value seeded by\n // initSections() — related-entity and System Metadata panels are seeded collapsed there.\n // Without this, FormStateService falls back to its global DEFAULT_SECTION_STATE (isExpanded=true),\n // which reports a never-before-visited related-entity panel as expanded and causes its data grid\n // (bound [AllowLoad]=\"IsSectionExpanded(key)\") to fetch on form open even while the panel is collapsed.\n // When the caller passes no explicit default, fall back to the value seeded by initSections().\n // If the section isn't in sectionMap yet — which happens during the window before the form's\n // async ngOnInit calls initSections(), e.g. when a record is opened already-loaded via an\n // in-app double-click so the grids render in the first change-detection pass — coalesce to\n // FALSE rather than letting FormStateService fall through to its global expanded default. A\n // missing section must NOT report as expanded, or its data grid (bound [AllowLoad]=\"IsSectionExpanded(key)\")\n // fires a RunView on open before the seeded collapsed default is applied.\n const resolvedDefault = defaultExpanded !== undefined ? defaultExpanded : (section?.isExpanded ?? false);\n const entityName = this.getEntityName();\n if (entityName) {\n return this.formStateService.isSectionExpanded(entityName, sectionKey, resolvedDefault);\n }\n return section ? section.isExpanded : (defaultExpanded !== undefined ? defaultExpanded : true);\n }\n\n public SetSectionExpanded(sectionKey: string, isExpanded: boolean): void {\n const entityName = this.getEntityName();\n if (entityName) {\n this.formStateService.setSectionExpanded(entityName, sectionKey, isExpanded);\n }\n const section = this.sectionMap.get(sectionKey);\n if (section) {\n section.isExpanded = isExpanded;\n }\n }\n\n public GetSectionRowCount(sectionKey: string): number | undefined {\n const section = this.sectionMap.get(sectionKey);\n return section?.rowCount;\n }\n\n public SetSectionRowCount(sectionKey: string, rowCount: number): void {\n let section = this.sectionMap.get(sectionKey);\n if (!section) {\n // Contribution panels use their own SectionKey (e.g. 'orders') which\n // is never seeded by generated initSections(). Upsert so the left-nav\n // rail badge can read the count the same way baked grids do.\n section = new BaseFormSectionInfo(sectionKey, sectionKey, false, rowCount);\n this.sections.push(section);\n this.sectionMap.set(sectionKey, section);\n } else {\n section.rowCount = rowCount;\n }\n this.cdr.markForCheck();\n }\n\n public GetSectionPanelHeight(sectionKey: string): number | undefined {\n const entityName = this.getEntityName();\n if (entityName) {\n return this.formStateService.getSectionPanelHeight(entityName, sectionKey);\n }\n return undefined;\n }\n\n public SetSectionPanelHeight(sectionKey: string, height: number): void {\n const entityName = this.getEntityName();\n if (entityName) {\n this.formStateService.setSectionPanelHeight(entityName, sectionKey, height);\n }\n }\n\n public toggleSection(sectionKey: string): void {\n const entityName = this.getEntityName();\n if (entityName) {\n this.formStateService.toggleSection(entityName, sectionKey);\n }\n const section = this.sectionMap.get(sectionKey);\n if (section) {\n section.isExpanded = !section.isExpanded;\n }\n }\n\n /**\n * Expand any sections that are visible (match the current filter) but currently collapsed.\n * Called after filter changes so the user can immediately see matching content.\n */\n private expandMatchingSections(): void {\n if (!this.collapsiblePanels) return;\n this.collapsiblePanels.forEach(panel => {\n if (panel.IsVisible && !panel.Expanded) {\n this.SetSectionExpanded(panel.SectionKey, true);\n }\n });\n }\n\n public expandAllSections(): void {\n const entityName = this.getEntityName();\n const sectionKeys = this.sections.map(s => s.sectionKey);\n if (entityName && sectionKeys.length > 0) {\n this.formStateService.expandAllSections(entityName, sectionKeys);\n }\n this.sections.forEach(section => {\n section.isExpanded = true;\n });\n }\n\n public collapseAllSections(): void {\n const entityName = this.getEntityName();\n const sectionKeys = this.sections.map(s => s.sectionKey);\n if (entityName && sectionKeys.length > 0) {\n this.formStateService.collapseAllSections(entityName, sectionKeys);\n }\n this.sections.forEach(section => {\n section.isExpanded = false;\n });\n }\n\n public getExpandedCount(): number {\n const entityName = this.getEntityName();\n const sectionKeys = this.sections.map(s => s.sectionKey);\n if (entityName && sectionKeys.length > 0) {\n return this.formStateService.getExpandedCount(entityName, sectionKeys);\n }\n return this.sections.filter(section => section.isExpanded).length;\n }\n\n public getVisibleSectionCount(): number {\n if (!this.collapsiblePanels || this.collapsiblePanels.length === 0) {\n return this.sections.length;\n }\n return this.collapsiblePanels.filter(panel => panel.IsVisible).length;\n }\n\n public getTotalSectionCount(): number {\n return this.sections.length;\n }\n\n public onFilterChange(searchTerm: string): void {\n this.filterSubject.next(searchTerm);\n }\n\n public getEntityName(): string {\n return this.record?.EntityInfo?.Name || '';\n }\n\n /**\n * Component-level default width mode, used when the user has NOT\n * explicitly chosen a width for this entity yet (first visit, nothing\n * persisted in User Settings). Subclasses can override this — for\n * example, custom forms with full-bleed layouts should return\n * `'full-width'` here and the container will respect it on first open.\n *\n * Once the user toggles the width via the toolbar, their choice\n * persists via `setFormWidthMode()` and takes priority over this\n * default on subsequent opens.\n */\n public getDefaultFormWidthMode(): 'centered' | 'full-width' {\n return this.Config?.WidthMode ?? 'centered';\n }\n\n public getFormWidthMode(): 'centered' | 'full-width' {\n const entityName = this.getEntityName();\n if (entityName && this.formStateService.hasExplicitWidthMode(entityName)) {\n return this.formStateService.getWidthMode(entityName);\n }\n return this.getDefaultFormWidthMode();\n }\n\n public setFormWidthMode(widthMode: 'centered' | 'full-width'): void {\n const entityName = this.getEntityName();\n if (entityName) {\n this.formStateService.setWidthMode(entityName, widthMode);\n }\n }\n\n public toggleFormWidthMode(): void {\n const entityName = this.getEntityName();\n if (entityName) {\n this.formStateService.toggleWidthMode(entityName);\n }\n }\n\n // #endregion\n\n // #region Section Ordering\n\n public getSectionOrder(): string[] {\n const entityName = this.getEntityName();\n if (entityName) {\n const customOrder = this.formStateService.getSectionOrder(entityName);\n if (customOrder && customOrder.length > 0) {\n return customOrder;\n }\n }\n return this.sections.map(s => s.sectionKey);\n }\n\n public setSectionOrder(sectionOrder: string[]): void {\n const entityName = this.getEntityName();\n if (entityName) {\n this.formStateService.setSectionOrder(entityName, sectionOrder);\n }\n }\n\n public resetSectionOrder(): void {\n const entityName = this.getEntityName();\n if (entityName) {\n this.formStateService.resetSectionOrder(entityName);\n }\n }\n\n public hasCustomSectionOrder(): boolean {\n const entityName = this.getEntityName();\n if (entityName) {\n return this.formStateService.hasCustomSectionOrder(entityName);\n }\n return false;\n }\n\n public getMoreSectionKeys(): string[] {\n const entityName = this.getEntityName();\n if (!entityName) return [];\n return this.formStateService.getMoreSectionKeys(entityName) ?? [];\n }\n\n public getFirstClassSectionKeys(): string[] {\n const entityName = this.getEntityName();\n if (!entityName) return [];\n return this.formStateService.getFirstClassSectionKeys(entityName) ?? [];\n }\n\n public setChromeMembership(moreSectionKeys: string[], firstClassSectionKeys: string[]): void {\n const entityName = this.getEntityName();\n if (entityName) {\n this.formStateService.setChromeMembership(entityName, moreSectionKeys, firstClassSectionKeys);\n }\n }\n\n public getSectionDisplayOrder(sectionKey: string): number {\n const order = this.getSectionOrder();\n const index = order.indexOf(sectionKey);\n return index >= 0 ? index : this.sections.length;\n }\n\n // #endregion\n\n // #region Form Container Event Handlers\n\n /**\n * Handles navigation events from the form container and related entity grids.\n * Relays the event upward via the Navigate @Output for the host application to handle.\n * Generated form templates bind this as: (Navigate)=\"OnFormNavigate($event)\"\n */\n public OnFormNavigate(event: FormNavigationEvent): void {\n this.Navigate.emit(event);\n }\n\n /**\n * Handles delete requests from the form container.\n * Emits RecordDeleted on success, RecordDeleteFailed on failure.\n * Generated form templates bind this as: (DeleteRequested)=\"OnDeleteRequested()\"\n */\n public async OnDeleteRequested(): Promise<void> {\n if (!this.record || !this.record.IsSaved) return;\n try {\n const result = await this.record.Delete();\n if (result) {\n this.Notification.emit({ Message: 'Record deleted successfully', Type: 'success', Duration: 2500 });\n this.RecordDeleted.emit({\n EntityName: this.record.EntityInfo.Name,\n RecordId: this.record.PrimaryKey.ToString()\n });\n } else {\n const errorMsg = 'Error deleting record';\n this.Notification.emit({ Message: errorMsg, Type: 'error', Duration: 5000 });\n this.RecordDeleteFailed.emit({ EntityName: this.record.EntityInfo.Name, ErrorMessage: errorMsg });\n }\n } catch (e) {\n const errorMsg = 'Error deleting record: ' + e;\n this.Notification.emit({ Message: errorMsg, Type: 'error', Duration: 5000 });\n this.RecordDeleteFailed.emit({ EntityName: this.record.EntityInfo.Name, ErrorMessage: errorMsg });\n }\n }\n\n /**\n * Handles favorite toggle from the form container.\n * Generated form templates bind this as: (FavoriteToggled)=\"OnFavoriteToggled()\"\n */\n public async OnFavoriteToggled(): Promise<void> {\n await this.SetFavoriteStatus(!this.IsFavorite);\n }\n\n /**\n * Handles history view requests from the form container.\n * Generated form templates bind this as: (HistoryRequested)=\"OnHistoryRequested()\"\n */\n public OnHistoryRequested(): void {\n this.handleHistoryDialog();\n }\n\n /**\n * Handles list management requests from the form container.\n * Generated form templates bind this as: (ListManagementRequested)=\"OnListManagementRequested()\"\n */\n public OnListManagementRequested(): void {\n // List management dialog is handled by the host application\n // Subclasses can override this to implement custom list management\n }\n\n // #endregion\n}\n"]}