@memberjunction/ng-base-forms 6.2.0-edge.0 → 6.2.0-edge.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/base-form-section-info.js +5 -5
- package/dist/lib/base-form-section-info.js.map +1 -1
- package/dist/lib/chrome/resolve-form-chrome.d.ts.map +1 -1
- package/dist/lib/chrome/resolve-form-chrome.js +22 -12
- package/dist/lib/chrome/resolve-form-chrome.js.map +1 -1
- package/dist/lib/container/record-form-container.component.d.ts +20 -12
- package/dist/lib/container/record-form-container.component.d.ts.map +1 -1
- package/dist/lib/container/record-form-container.component.js +129 -113
- package/dist/lib/container/record-form-container.component.js.map +1 -1
- package/dist/lib/explorer-entity-data-grid.component.d.ts +18 -1
- package/dist/lib/explorer-entity-data-grid.component.d.ts.map +1 -1
- package/dist/lib/explorer-entity-data-grid.component.js +38 -10
- package/dist/lib/explorer-entity-data-grid.component.js.map +1 -1
- package/dist/lib/field/form-field.component.d.ts +37 -5
- package/dist/lib/field/form-field.component.d.ts.map +1 -1
- package/dist/lib/field/form-field.component.js +106 -20
- package/dist/lib/field/form-field.component.js.map +1 -1
- package/dist/lib/form-state.service.d.ts +58 -0
- package/dist/lib/form-state.service.d.ts.map +1 -1
- package/dist/lib/form-state.service.js +156 -40
- package/dist/lib/form-state.service.js.map +1 -1
- package/dist/lib/host/entity-form-host.component.d.ts +10 -2
- package/dist/lib/host/entity-form-host.component.d.ts.map +1 -1
- package/dist/lib/host/entity-form-host.component.js +24 -8
- package/dist/lib/host/entity-form-host.component.js.map +1 -1
- package/dist/lib/interactive-form/interactive-form.component.d.ts +16 -4
- package/dist/lib/interactive-form/interactive-form.component.d.ts.map +1 -1
- package/dist/lib/interactive-form/interactive-form.component.js +38 -12
- package/dist/lib/interactive-form/interactive-form.component.js.map +1 -1
- package/dist/lib/isa-related-panel/isa-related-card.component.d.ts +3 -3
- package/dist/lib/isa-related-panel/isa-related-card.component.js +6 -6
- package/dist/lib/isa-related-panel/isa-related-card.component.js.map +1 -1
- package/dist/lib/isa-related-panel/isa-related-panel.component.d.ts +3 -3
- package/dist/lib/isa-related-panel/isa-related-panel.component.js +8 -8
- package/dist/lib/isa-related-panel/isa-related-panel.component.js.map +1 -1
- package/dist/lib/overlays/form-slide-in.component.d.ts +2 -0
- package/dist/lib/overlays/form-slide-in.component.d.ts.map +1 -1
- package/dist/lib/overlays/form-slide-in.component.js +5 -1
- package/dist/lib/overlays/form-slide-in.component.js.map +1 -1
- package/dist/lib/panel/collapsible-panel.component.d.ts +9 -9
- package/dist/lib/panel/collapsible-panel.component.js +23 -23
- package/dist/lib/panel/collapsible-panel.component.js.map +1 -1
- package/dist/lib/panel-slot/base-form-panel.d.ts +2 -0
- package/dist/lib/panel-slot/base-form-panel.d.ts.map +1 -1
- package/dist/lib/panel-slot/base-form-panel.js +5 -1
- package/dist/lib/panel-slot/base-form-panel.js.map +1 -1
- package/dist/lib/panel-slot/form-contribution.d.ts +12 -0
- package/dist/lib/panel-slot/form-contribution.d.ts.map +1 -1
- package/dist/lib/panel-slot/form-contribution.js +43 -10
- package/dist/lib/panel-slot/form-contribution.js.map +1 -1
- package/dist/lib/panel-slot/form-slot-coordinator.service.d.ts +10 -0
- package/dist/lib/panel-slot/form-slot-coordinator.service.d.ts.map +1 -1
- package/dist/lib/panel-slot/form-slot-coordinator.service.js +25 -5
- package/dist/lib/panel-slot/form-slot-coordinator.service.js.map +1 -1
- package/dist/lib/panel-slot/related-entity-grid-panel.component.d.ts +2 -0
- package/dist/lib/panel-slot/related-entity-grid-panel.component.d.ts.map +1 -1
- package/dist/lib/panel-slot/related-entity-grid-panel.component.js +5 -1
- package/dist/lib/panel-slot/related-entity-grid-panel.component.js.map +1 -1
- package/dist/lib/section-loader-component.d.ts +5 -1
- package/dist/lib/section-loader-component.d.ts.map +1 -1
- package/dist/lib/section-loader-component.js +13 -5
- package/dist/lib/section-loader-component.js.map +1 -1
- package/dist/lib/section-manager/section-manager.component.d.ts +2 -2
- package/dist/lib/section-manager/section-manager.component.js +6 -6
- package/dist/lib/section-manager/section-manager.component.js.map +1 -1
- package/dist/lib/toolbar/form-toolbar.component.d.ts +5 -5
- package/dist/lib/toolbar/form-toolbar.component.js +22 -22
- package/dist/lib/toolbar/form-toolbar.component.js.map +1 -1
- package/dist/lib/types/form-types.d.ts +2 -0
- package/dist/lib/types/form-types.d.ts.map +1 -1
- package/dist/lib/types/form-types.js +5 -1
- package/dist/lib/types/form-types.js.map +1 -1
- package/package.json +18 -18
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interactive-form.component.js","sourceRoot":"","sources":["../../../src/lib/interactive-form/interactive-form.component.ts","../../../src/lib/interactive-form/interactive-form.component.html"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,YAAY,EAAE,KAAK,EAAqB,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAChI,OAAO,EAA4B,QAAQ,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AACnF,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAEvE,OAAO,EAEH,cAAc,EACd,eAAe,EAIf,UAAU,GACb,MAAM,mDAAmD,CAAC;AAC3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,6CAA6C,CAAC;AACpF,OAAO,EAAoB,kBAAkB,EAAuB,MAAM,0BAA0B,CAAC;AACrG,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;;;;;;;ICVnD,mCAA0B;IAAA,YAAe;IAAA,iBAAW;;;IAA1B,cAAe;IAAf,sCAAe;;;;IAEzC,gDAKoD;IAAhD,AADA,6PAAkB,oCAA6B,KAAC,oPAC5B,iCAA0B,KAAC;IACnD,iBAAqB;;;IAHjB,AADA,gDAA2B,wCACK;;;IAKpC,8BAA8B;IAC1B,uBAA2C;IAC3C,4BAAM;IAAA,kCAAa;IACvB,AADuB,iBAAO,EACxB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B,KAAK;;kBAiBL,KAAK;;kBAaL,KAAK;;kBAcL,KAAK;;kBAqBL,MAAM;;kBAaN,SAAS;mBAAC,gBAAgB;;kFA7FlB,wBAAwB;AAidrC;;;GAGG;AACH,MAAM,UAAU,4BAA4B;IACxC,0CAA0C;IAC1C,IAAI,KAAgB,EAAE,CAAC;QACnB,6DAA6D;QAC7D,MAAM,CAAC,GAAY,wBAAwB,CAAC;IAChD,CAAC;AACL,CAAC","sourcesContent":["import { ChangeDetectorRef, Component, EventEmitter, Input, OnDestroy, OnInit, Output, ViewChild, inject } from '@angular/core';\nimport { BaseEntity, CompositeKey, LogError, RunView } from '@memberjunction/core';\nimport { InteractiveFormsEngine } from '@memberjunction/core-entities';\nimport { ComponentSpec } from '@memberjunction/interactive-component-types';\nimport {\n FormHostProps,\n FormEventNames,\n FormMethodNames,\n FormBeforeSaveArgs,\n FormBeforeDeleteArgs,\n FormEditModeChangeRequestedArgs,\n isFormRole,\n} from '@memberjunction/interactive-component-types/forms';\nimport { SimpleEntityFieldInfo } from '@memberjunction/interactive-component-types';\nimport { MJReactComponent, ReactBridgeService, ReactComponentEvent } from '@memberjunction/ng-react';\nimport { BaseFormComponent } from '../base-form-component';\n\n/**\n * Wraps a Component (the IC kind — declared `componentRole: 'form'`) so it can\n * stand in for an Angular form on any entity.\n *\n * **Layering invariant:** the React component never touches BaseEntity. This\n * wrapper owns the entity lifecycle (`record.Save`, `record.Delete`, mode\n * transitions). The React component sees only the snapshot in\n * {@link FormHostProps} and communicates back via `BeforeSave` /\n * `BeforeDelete` / `EditModeChangeRequested` events plus its dirty-field diff.\n *\n * Instantiated by `SingleRecordComponent.LoadForm` when the resolver finds an\n * `EntityFormOverride` matching the user's scope. Behaves exactly like the\n * generated Angular form from the host's perspective: same `record` setter,\n * same `EditMode` toggle, same outputs.\n */\n@Component({\n standalone: false,\n selector: 'mj-interactive-form',\n templateUrl: './interactive-form.component.html',\n})\nexport class InteractiveFormComponent extends BaseFormComponent implements OnInit, OnDestroy {\n\n /**\n * The bound record. Backed by a setter so swapping records *after*\n * the component has mounted (e.g. Form Builder cockpit preview record\n * picker) triggers a fresh `originalSnapshot` capture + a\n * `formHostProps` rebuild — without this, the React form keeps\n * rendering the original record's values even after the input\n * changes. Guarded on `_recordInitialized` so the post-mount path\n * doesn't fire during the first input assignment (handled by\n * `ngOnInit`, which sets both `originalSnapshot` and `formHostProps`).\n */\n private _record!: BaseEntity;\n private _recordInitialized = false;\n\n @Input()\n public override set record(value: BaseEntity) {\n if (this._record === value) return;\n this._record = value;\n if (this._recordInitialized && value) {\n this.originalSnapshot = value.GetAll();\n this.rebuildFormHostProps();\n this.cdr.markForCheck();\n }\n }\n public override get record(): BaseEntity { return this._record; }\n\n /**\n * The Component row ID resolved for this (entity, user, roles) tuple. Set\n * by `SingleRecordComponent.LoadForm` after the resolver returns an\n * override.\n */\n @Input() public ComponentID: string | null = null;\n\n /**\n * Loaded ComponentSpec, parsed from the Component row's `Specification` JSON.\n *\n * Two ways to populate this:\n * 1. **Via `ComponentID`** (the standard path): set the input, ngOnInit\n * fetches the row from `MJ: Components` and assigns the parsed spec.\n * 2. **Direct assignment** (the artifact-viewer path): the caller already\n * has the spec in hand (parsed from an artifact JSON blob) and sets\n * `componentSpec` directly. In that case `ComponentID` should be left\n * null and the DB fetch is skipped.\n */\n @Input() public componentSpec: ComponentSpec | null = null;\n\n /**\n * When true, render the React component **without** the\n * `<mj-record-form-container>` wrapper — i.e. no toolbar (no Save /\n * Cancel / Edit / Delete / History / Tags / Lists).\n *\n * Used by the Form Builder cockpit's Preview tab where the toolbar's\n * actions don't apply (Save would save the *record*, but the cockpit's\n * own Save button saves the *spec*; History/Tags assume a real\n * persistent record, but the preview record can be a synthetic\n * NewRecord). Keeping just the form body produces a clean \"this is\n * what the form looks like\" view.\n */\n @Input() public previewMode = false;\n\n /** FormHostProps passed to the React component. Recomputed when record or mode changes. */\n public formHostProps: FormHostProps | null = null;\n\n /** Loaded-spec error (component row missing, JSON parse failure, etc.). */\n private _loadError: string | null = null;\n\n /**\n * Loaded-spec error (component row missing, JSON parse failure,\n * React-runtime bootstrap failure, etc.). Setter auto-emits\n * `LoadErrorChanged` so host surfaces (e.g. Form Builder cockpit\n * Preview tab) can show their own error state — retrospective fix #10.\n */\n public get loadError(): string | null { return this._loadError; }\n public set loadError(v: string | null) {\n if (v === this._loadError) return;\n this._loadError = v;\n this.LoadErrorChanged.emit(v);\n }\n\n @Output() public LoadErrorChanged = new EventEmitter<string | null>();\n\n /** Tracks last-known field snapshot for computing the dirty-field diff on save. */\n private originalSnapshot: Record<string, unknown> = {};\n\n /**\n * Reference to the mounted React component. Used by the SaveRecord /\n * CancelEdit overrides below to invoke the component's registered\n * `RequestSave` / `RequestCancel` methods when the host toolbar fires\n * Save/Cancel — so the single user-visible Save lives on the toolbar\n * (consistent with every other entity form in MJ) and not duplicated\n * inside the form body.\n */\n @ViewChild('reactComponent') public reactComponent?: MJReactComponent;\n\n /**\n * Promise resolver populated when `SaveRecord` invokes `RequestSave`\n * on the React component. `handleBeforeSave` resolves it after the\n * BeforeSave-driven entity save completes, so SaveRecord can return\n * a meaningful success boolean and honor `StopEditModeAfterSave`.\n */\n private pendingSaveResolver: ((success: boolean) => void) | null = null;\n\n private readonly changeDetector = inject(ChangeDetectorRef);\n private readonly reactBridge = inject(ReactBridgeService);\n\n public override async ngOnInit(): Promise<void> {\n await super.ngOnInit();\n // Force the React bridge to be initialized BEFORE we let our template\n // mount the `<mj-react-component>` child. Without this, the child's\n // ngAfterViewInit can race the adapter bootstrap and throw \"React\n // runtime not initialized\" — which then prevents the form from\n // rendering and silently breaks the save flow.\n try {\n await this.reactBridge.getReactContext();\n } catch (err) {\n LogError(`InteractiveFormComponent: React bridge bootstrap failed: ${err instanceof Error ? err.message : String(err)}`);\n this.loadError ='React runtime failed to load. Try a hard refresh.';\n return;\n }\n if (this.record) {\n this.originalSnapshot = this.record.GetAll();\n this.rebuildFormHostProps();\n }\n // Mark init complete so the `record` setter rebuilds on subsequent\n // input changes (post-mount record swaps from the Form Builder\n // cockpit preview picker, etc.). Before this flag flips, the setter\n // intentionally does nothing because ngOnInit already handles the\n // initial assignment.\n this._recordInitialized = true;\n // Direct-spec path (artifact viewer) takes precedence; DB fetch only\n // when no spec was supplied and we have an ID to look up.\n if (!this.componentSpec && this.ComponentID) {\n await this.loadComponentSpec();\n }\n }\n\n /**\n * Called by the React component via `mj-react-component`'s `componentEvent`\n * @Output. Maps the form-role event names to BaseEntity operations.\n */\n public async OnReactComponentEvent(event: ReactComponentEvent): Promise<void> {\n switch (event.type) {\n case FormEventNames.BeforeSave:\n await this.handleBeforeSave(event.payload as FormBeforeSaveArgs);\n break;\n case FormEventNames.BeforeDelete:\n await this.handleBeforeDelete(event.payload as FormBeforeDeleteArgs);\n break;\n case FormEventNames.EditModeChangeRequested:\n this.handleEditModeChangeRequested(event.payload as FormEditModeChangeRequestedArgs);\n break;\n // FieldChanged / DirtyStateChanged / ValidationChanged are read-only signals;\n // the wrapper doesn't need to react beyond what the component does internally.\n }\n }\n\n /**\n * Called when the form-role component drills into a related record via\n * `callbacks.OpenEntityRecord(...)`. Relays it upward as a `Navigate` event\n * (the same path normal FK links use) so the host opens the target record.\n */\n public OnOpenEntityRecord(event: { entityName: string; key: CompositeKey }): void {\n this.Navigate.emit({ Kind: 'record', EntityName: event.entityName, PrimaryKey: event.key });\n }\n\n /**\n * Apply the React component's dirty-field diff to the BaseEntity, save,\n * and refresh the snapshot. Errors surface via `LatestResult.CompleteMessage`\n * per the BaseEntity Save contract.\n *\n * Resolves `pendingSaveResolver` if {@link SaveRecord} initiated this\n * flow via the toolbar — so the toolbar can return a meaningful boolean\n * and honor `StopEditModeAfterSave`.\n */\n private async handleBeforeSave(args: FormBeforeSaveArgs): Promise<void> {\n if (args.cancel) {\n this.resolvePendingSave(false);\n return;\n }\n if (!this.record) {\n LogError('InteractiveFormComponent.handleBeforeSave: no record loaded');\n this.resolvePendingSave(false);\n return;\n }\n\n const dirtyEntries = Object.entries(args.dirtyFields ?? {});\n if (dirtyEntries.length === 0 && this.record.IsSaved) {\n // No dirty fields on an already-persisted record — a genuine no-op.\n // Most likely the user clicked Save without changing anything, or the\n // React draft didn't reach the host before RequestSave fired. Surface\n // it so the user sees why their edits didn't land.\n console.warn(\n '[InteractiveFormComponent] BeforeSave fired with no dirtyFields. ' +\n 'Either the user clicked Save without changing anything, or the ' +\n 'React draft did not propagate before save fired.'\n );\n // Skip Save() + rebuildFormHostProps(): re-rendering the React form\n // would re-fire BeforeSave on a form that emits it on mount/render —\n // an infinite re-mount loop that starves the form's async data load\n // (it unmounts before setState commits). Treat it as a no-op.\n //\n // Guard on IsSaved so this only short-circuits existing records. A\n // NEW record with no dirty fields must still fall through to Save()\n // so the insert is attempted (and any validation failure surfaced)\n // rather than masked as a reported success with no row inserted.\n this.resolvePendingSave(true);\n return;\n }\n for (const [fieldName, value] of dirtyEntries) {\n const field = this.record.Fields.find(f =>\n f.Name.trim().toLowerCase() === fieldName.trim().toLowerCase());\n if (field) {\n // Use the canonical field name from the lookup so case\n // mismatches between the React draft and the entity schema\n // don't silently drop the value.\n this.record.Set(field.Name, value);\n } else {\n console.warn(\n `[InteractiveFormComponent] Unknown field \"${fieldName}\" in dirtyFields ` +\n `for entity ${this.record.EntityInfo.Name}. Value not applied.`\n );\n }\n }\n\n const saved = await this.record.Save();\n if (saved) {\n this.originalSnapshot = this.record.GetAll();\n this.rebuildFormHostProps();\n } else {\n LogError(`InteractiveFormComponent: save failed for ${this.record.EntityInfo.Name}: ${this.record.LatestResult?.CompleteMessage ?? 'unknown error'}`);\n }\n this.resolvePendingSave(saved);\n }\n\n private resolvePendingSave(success: boolean): void {\n if (this.pendingSaveResolver) {\n this.pendingSaveResolver(success);\n this.pendingSaveResolver = null;\n }\n }\n\n private async handleBeforeDelete(args: FormBeforeDeleteArgs): Promise<void> {\n if (args.cancel) {\n return;\n }\n if (!this.record) {\n return;\n }\n const deleted = await this.record.Delete();\n if (!deleted) {\n LogError(`InteractiveFormComponent: delete failed for ${this.record.EntityInfo.Name}: ${this.record.LatestResult?.CompleteMessage ?? 'unknown error'}`);\n }\n }\n\n private handleEditModeChangeRequested(args: FormEditModeChangeRequestedArgs): void {\n if (args.cancel) {\n return;\n }\n if (args.requestedMode === 'edit') {\n this.StartEditMode();\n } else {\n this.EndEditMode();\n }\n }\n\n /**\n * Propagate Angular-toolbar-driven mode changes into the React component's\n * `FormHostProps.mode`. Without these overrides, clicking Edit on the\n * `<mj-record-form-container>` toolbar flips `this.EditMode` but the React\n * side still sees `mode: 'view'`.\n */\n public override StartEditMode(): void {\n super.StartEditMode();\n this.rebuildFormHostProps();\n }\n\n public override EndEditMode(): void {\n super.EndEditMode();\n this.rebuildFormHostProps();\n }\n\n /**\n * Toolbar **Save** override. Routes the click through the React\n * component's registered `RequestSave` method so the React layer can\n * (a) run its own validation, (b) flush its draft state, (c) emit\n * `BeforeSave` with the dirty-field diff — exactly the flow the\n * in-form Save button would trigger. The wrapper then awaits the\n * BeforeSave handler via `pendingSaveResolver`, gets a real\n * success/failure boolean, and honors `StopEditModeAfterSave`.\n *\n * Falls back to the base implementation for components that haven't\n * registered `RequestSave` — preserves correctness for forms that\n * keep their own in-form Save button (older sample, hand-authored\n * forms that pre-date this contract).\n */\n public override async SaveRecord(StopEditModeAfterSave: boolean): Promise<boolean> {\n if (!this.reactComponent?.hasMethod?.(FormMethodNames.RequestSave)) {\n return super.SaveRecord(StopEditModeAfterSave);\n }\n const completion = new Promise<boolean>(resolve => {\n this.pendingSaveResolver = resolve;\n });\n try {\n this.reactComponent.invokeMethod(FormMethodNames.RequestSave);\n } catch (err) {\n this.pendingSaveResolver = null;\n LogError(`InteractiveFormComponent.SaveRecord: RequestSave threw: ${err instanceof Error ? err.message : String(err)}`);\n return false;\n }\n const success = await completion;\n if (success && StopEditModeAfterSave) {\n this.EndEditMode();\n }\n return success;\n }\n\n /**\n * Toolbar **Cancel** override. Asks the React component to discard\n * its draft via `RequestCancel`, then flips out of edit mode the\n * same way the base implementation would. The React component is\n * expected to (a) clear its local draft state and (b) emit\n * `EditModeChangeRequested({ requestedMode: 'view' })` — though we\n * call `EndEditMode` here directly anyway, so even a no-op handler\n * leaves the form in a coherent state.\n */\n public override CancelEdit(): void {\n if (this.reactComponent?.hasMethod?.(FormMethodNames.RequestCancel)) {\n try {\n this.reactComponent.invokeMethod(FormMethodNames.RequestCancel);\n } catch (err) {\n LogError(`InteractiveFormComponent.CancelEdit: RequestCancel threw: ${err instanceof Error ? err.message : String(err)}`);\n }\n // Don't call super.CancelEdit() — base reverts the BaseEntity,\n // but for interactive forms the BaseEntity never received the\n // React draft in the first place, so there's nothing to revert.\n // Just flip mode.\n this.EndEditMode();\n return;\n }\n super.CancelEdit();\n }\n\n /**\n * Resolve the Component row, parse its `Specification`, and surface either\n * the spec or an error. Backed by `InteractiveFormsEngine` (in-memory\n * cache, BaseEntity event-driven invalidation) so this is a sub-ms JS\n * lookup once the engine has loaded — the engine handles freshness\n * via remote-invalidate events, replacing the prior RunView's\n * `BypassCache: true` escape hatch. Falls through to a one-shot\n * RunView only on engine-cache miss (defensive — the engine should\n * always have a Type='Form' Component, but if a brand-new Component\n * was just created on the server and the invalidation event hasn't\n * propagated yet, we still want to render rather than blank-screen).\n */\n private async loadComponentSpec(): Promise<void> {\n if (!this.ComponentID) {\n this.loadError ='No ComponentID provided to InteractiveFormComponent.';\n return;\n }\n try {\n const provider = this.ProviderToUse;\n const user = provider.CurrentUser;\n // Lazy-load the form-metadata cache. No-op when already loaded.\n try {\n await InteractiveFormsEngine.Instance.Config(false, user, provider);\n } catch (err) {\n LogError(`InteractiveFormComponent: InteractiveFormsEngine.Config failed: ${err instanceof Error ? err.message : String(err)}`);\n // Fall through to RunView path below — engine miss isn't fatal.\n }\n\n let specJson: string | null = null;\n let nameForError: string | undefined;\n\n const cached = InteractiveFormsEngine.Instance.FindFormByID(this.ComponentID);\n if (cached) {\n specJson = cached.Specification;\n nameForError = cached.Name;\n } else {\n // Engine miss — one-shot RunView fallback. This covers the\n // narrow window where a freshly-created Component hasn't\n // propagated to the engine yet (cross-process remote-invalidate\n // is debounced ~1.5s). After the propagation lands subsequent\n // form opens hit the cache.\n const rv = RunView.FromMetadataProvider(provider);\n const result = await rv.RunView<{ ID: string; Specification: string; Name: string }>({\n EntityName: 'MJ: Components',\n Fields: ['ID', 'Name', 'Specification'],\n ExtraFilter: `ID='${this.ComponentID}'`,\n MaxRows: 1,\n ResultType: 'simple',\n BypassCache: true,\n }, user);\n if (!result.Success || !result.Results?.length) {\n this.loadError =`Component ${this.ComponentID} not found.`;\n return;\n }\n specJson = result.Results[0].Specification;\n nameForError = result.Results[0].Name;\n }\n\n try {\n this.componentSpec = JSON.parse(specJson ?? 'null') as ComponentSpec;\n } catch (err) {\n this.loadError =`Component ${nameForError ?? this.ComponentID} has invalid Specification JSON: ${err instanceof Error ? err.message : String(err)}`;\n return;\n }\n if (!this.componentSpec) {\n this.loadError =`Component ${nameForError ?? this.ComponentID} has an empty Specification.`;\n return;\n }\n // Validate the spec commits to the form-role contract. We use the\n // helper (whose signature is structural via Pick<>) so this stays\n // robust across ComponentSpec field additions.\n if (!isFormRole(this.componentSpec)) {\n this.loadError =`Component ${nameForError ?? this.ComponentID} does not declare componentRole='form'.`;\n return;\n }\n } finally {\n this.changeDetector.markForCheck();\n }\n }\n\n /**\n * Build `FormHostProps` from the current record + permissions + edit mode.\n * Called whenever the record loads, mode changes, or save completes.\n */\n private rebuildFormHostProps(): void {\n if (!this.record) {\n this.formHostProps = null;\n return;\n }\n const fields: SimpleEntityFieldInfo[] = this.record.Fields.map(f =>\n SimpleEntityFieldInfo.FromEntityFieldInfo(f.EntityFieldInfo));\n\n const pk = this.record.PrimaryKey;\n const primaryKey: Record<string, unknown> | null = (pk && pk.HasValue)\n ? this.primaryKeyToPlain(pk)\n : null;\n\n this.formHostProps = {\n entityName: this.record.EntityInfo.Name,\n primaryKey,\n record: this.record.GetAll(),\n entityMetadata: {\n fields,\n displayName: this.record.EntityInfo.DisplayName ?? this.record.EntityInfo.Name,\n nameField: this.record.EntityInfo.NameField?.Name,\n },\n mode: this.EditMode ? 'edit' : (pk && pk.HasValue ? 'view' : 'create'),\n canEdit: this.UserCanEdit,\n canDelete: this.UserCanDelete,\n canCreate: this.UserCanCreate,\n };\n }\n\n private primaryKeyToPlain(pk: CompositeKey): Record<string, unknown> {\n const obj: Record<string, unknown> = {};\n for (const kvp of pk.KeyValuePairs ?? []) {\n obj[kvp.FieldName] = kvp.Value;\n }\n return obj;\n }\n}\n\n/**\n * Tree-shaking guard. Imported and called from public-api.ts so bundlers don't\n * drop the component when no consumer references it by name.\n */\nexport function LoadInteractiveFormComponent(): void {\n // Force the class reference to stay live.\n if (false as boolean) {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const _: unknown = InteractiveFormComponent;\n }\n}\n","@if (record) {\n@if (previewMode) {\n <!-- Preview mode — no toolbar wrap. Just the form body for clean\n \"what the form looks like\" previews (Form Builder cockpit). -->\n @if (loadError) {\n <mj-alert Variant=\"error\">{{ loadError }}</mj-alert>\n } @else if (componentSpec && formHostProps) {\n <mj-react-component\n #reactComponent\n [component]=\"componentSpec\"\n [componentProps]=\"formHostProps\"\n (componentEvent)=\"OnReactComponentEvent($event)\"\n (openEntityRecord)=\"OnOpenEntityRecord($event)\">\n </mj-react-component>\n } @else {\n <div class=\"mj-loading-state\">\n <i class=\"fa-solid fa-spinner fa-spin\"></i>\n <span>Loading form…</span>\n </div>\n }\n} @else {\n<mj-record-form-container\n [Record]=\"record\"\n [FormComponent]=\"this\"\n (Navigate)=\"OnFormNavigate($event)\"\n (DeleteRequested)=\"OnDeleteRequested()\"\n (FavoriteToggled)=\"OnFavoriteToggled()\"\n (HistoryRequested)=\"OnHistoryRequested()\"\n (ListManagementRequested)=\"OnListManagementRequested()\">\n\n @if (loadError) {\n <mj-alert Variant=\"error\">{{ loadError }}</mj-alert>\n } @else if (componentSpec && formHostProps) {\n <mj-react-component\n #reactComponent\n [component]=\"componentSpec\"\n [componentProps]=\"formHostProps\"\n (componentEvent)=\"OnReactComponentEvent($event)\"\n (openEntityRecord)=\"OnOpenEntityRecord($event)\">\n </mj-react-component>\n } @else {\n <div class=\"mj-loading-state\">\n <i class=\"fa-solid fa-spinner fa-spin\"></i>\n <span>Loading form…</span>\n </div>\n }\n\n</mj-record-form-container>\n}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"interactive-form.component.js","sourceRoot":"","sources":["../../../src/lib/interactive-form/interactive-form.component.ts","../../../src/lib/interactive-form/interactive-form.component.html"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,YAAY,EAAE,KAAK,EAAqB,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAChI,OAAO,EAA4B,QAAQ,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AACnF,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAEvE,OAAO,EAEH,cAAc,EACd,eAAe,EAIf,UAAU,GACb,MAAM,mDAAmD,CAAC;AAC3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,6CAA6C,CAAC;AACpF,OAAO,EAAoB,kBAAkB,EAAuB,MAAM,0BAA0B,CAAC;AACrG,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;;;;;;;ICVnD,mCAA0B;IAAA,YAAe;IAAA,iBAAW;;;IAA1B,cAAe;IAAf,sCAAe;;;;IAEzC,gDAKoD;IAAhD,AADA,6PAAkB,oCAA6B,KAAC,oPAC5B,iCAA0B,KAAC;IACnD,iBAAqB;;;IAHjB,AADA,gDAA2B,wCACK;;;IAKpC,8BAA8B;IAC1B,uBAA2C;IAC3C,4BAAM;IAAA,kCAAa;IACvB,AADuB,iBAAO,EACxB;;;IAJR,AARA,AAFF,2HAAiB,+GAE4B,gGAQpC;;;IAVT,6FAeC;;;IAYG,mCAA0B;IAAA,YAAe;IAAA,iBAAW;;;IAA1B,cAAe;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SAChC,CAAC;IACN,CAAC;IAEO,iBAAiB,CAAC,EAAgB;QACtC,MAAM,GAAG,GAA4B,EAAE,CAAC;QACxC,KAAK,MAAM,GAAG,IAAI,EAAE,CAAC,aAAa,IAAI,EAAE,EAAE,CAAC;YACvC,GAAG,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC;QACnC,CAAC;QACD,OAAO,GAAG,CAAC;IACf,CAAC;6QAzeQ,wBAAwB,yBAAxB,wBAAwB;6DAAxB,wBAAwB;;;;;;YCrCrC,gFAAc;;YAAd,qCAiDC;;;iFDZY,wBAAwB;cALpC,SAAS;6BACM,KAAK,YACP,qBAAqB;;kBAkB9B,KAAK;;kBAiBL,KAAK;;kBAaL,KAAK;;kBAcL,KAAK;;kBAGL,KAAK;;kBAoCL,MAAM;;kBAaN,SAAS;mBAAC,gBAAgB;;kFA/GlB,wBAAwB;AA4erC;;;GAGG;AACH,MAAM,UAAU,4BAA4B;IACxC,0CAA0C;IAC1C,IAAI,KAAgB,EAAE,CAAC;QACnB,6DAA6D;QAC7D,MAAM,CAAC,GAAY,wBAAwB,CAAC;IAChD,CAAC;AACL,CAAC","sourcesContent":["import { ChangeDetectorRef, Component, EventEmitter, Input, OnDestroy, OnInit, Output, ViewChild, inject } from '@angular/core';\nimport { BaseEntity, CompositeKey, LogError, RunView } from '@memberjunction/core';\nimport { InteractiveFormsEngine } from '@memberjunction/core-entities';\nimport { ComponentSpec } from '@memberjunction/interactive-component-types';\nimport {\n FormHostProps,\n FormEventNames,\n FormMethodNames,\n FormBeforeSaveArgs,\n FormBeforeDeleteArgs,\n FormEditModeChangeRequestedArgs,\n isFormRole,\n} from '@memberjunction/interactive-component-types/forms';\nimport { SimpleEntityFieldInfo } from '@memberjunction/interactive-component-types';\nimport { MJReactComponent, ReactBridgeService, ReactComponentEvent } from '@memberjunction/ng-react';\nimport { BaseFormComponent } from '../base-form-component';\n\n/**\n * Wraps a Component (the IC kind — declared `componentRole: 'form'`) so it can\n * stand in for an Angular form on any entity.\n *\n * **Layering invariant:** the React component never touches BaseEntity. This\n * wrapper owns the entity lifecycle (`record.Save`, `record.Delete`, mode\n * transitions). The React component sees only the snapshot in\n * {@link FormHostProps} and communicates back via `BeforeSave` /\n * `BeforeDelete` / `EditModeChangeRequested` events plus its dirty-field diff.\n *\n * Instantiated by `SingleRecordComponent.LoadForm` when the resolver finds an\n * `EntityFormOverride` matching the user's scope. Behaves exactly like the\n * generated Angular form from the host's perspective: same `record` setter,\n * same `EditMode` toggle, same outputs.\n */\n@Component({\n standalone: false,\n selector: 'mj-interactive-form',\n templateUrl: './interactive-form.component.html',\n})\nexport class InteractiveFormComponent extends BaseFormComponent implements OnInit, OnDestroy {\n\n /**\n * The bound record. Backed by a setter so swapping records *after*\n * the component has mounted (e.g. Form Builder cockpit preview record\n * picker) triggers a fresh `originalSnapshot` capture + a\n * `formHostProps` rebuild — without this, the React form keeps\n * rendering the original record's values even after the input\n * changes. Guarded on `_recordInitialized` so the post-mount path\n * doesn't fire during the first input assignment (handled by\n * `ngOnInit`, which sets both `originalSnapshot` and `formHostProps`).\n */\n private _record!: BaseEntity;\n private _recordInitialized = false;\n\n @Input()\n public override set record(value: BaseEntity) {\n if (this._record === value) return;\n this._record = value;\n if (this._recordInitialized && value) {\n this.originalSnapshot = value.GetAll();\n this.rebuildFormHostProps();\n this.cdr.markForCheck();\n }\n }\n public override get record(): BaseEntity { return this._record; }\n\n /**\n * The Component row ID resolved for this (entity, user, roles) tuple. Set\n * by `SingleRecordComponent.LoadForm` after the resolver returns an\n * override.\n */\n @Input() public ComponentID: string | null = null;\n\n /**\n * Loaded ComponentSpec, parsed from the Component row's `Specification` JSON.\n *\n * Two ways to populate this:\n * 1. **Via `ComponentID`** (the standard path): set the input, ngOnInit\n * fetches the row from `MJ: Components` and assigns the parsed spec.\n * 2. **Direct assignment** (the artifact-viewer path): the caller already\n * has the spec in hand (parsed from an artifact JSON blob) and sets\n * `componentSpec` directly. In that case `ComponentID` should be left\n * null and the DB fetch is skipped.\n */\n @Input() public componentSpec: ComponentSpec | null = null;\n\n /**\n * When true, render the React component **without** the\n * `<mj-record-form-container>` wrapper — i.e. no toolbar (no Save /\n * Cancel / Edit / Delete / History / Tags / Lists).\n *\n * Used by the Form Builder cockpit's Preview tab where the toolbar's\n * actions don't apply (Save would save the *record*, but the cockpit's\n * own Save button saves the *spec*; History/Tags assume a real\n * persistent record, but the preview record can be a synthetic\n * NewRecord). Keeping just the form body produces a clean \"this is\n * what the form looks like\" view.\n */\n @Input() public PreviewMode = false;\n\n /** @deprecated Use {@link PreviewMode}. */\n @Input() public set previewMode(value: InteractiveFormComponent['PreviewMode']) {\n this.PreviewMode = value;\n }\n /** @deprecated Use {@link PreviewMode}. */\n public get previewMode(): InteractiveFormComponent['PreviewMode'] {\n return this.PreviewMode;\n }\n\n /** FormHostProps passed to the React component. Recomputed when record or mode changes. */\n public FormHostProps: FormHostProps | null = null;\n\n /** @deprecated Use {@link FormHostProps}. */\n public get formHostProps(): FormHostProps | null {\n return this.FormHostProps;\n }\n /** @deprecated Use {@link FormHostProps}. */\n public set formHostProps(value: FormHostProps | null) {\n this.FormHostProps = value;\n }\n\n /** Loaded-spec error (component row missing, JSON parse failure, etc.). */\n private _loadError: string | null = null;\n\n /**\n * Loaded-spec error (component row missing, JSON parse failure,\n * React-runtime bootstrap failure, etc.). Setter auto-emits\n * `LoadErrorChanged` so host surfaces (e.g. Form Builder cockpit\n * Preview tab) can show their own error state — retrospective fix #10.\n */\n public get loadError(): string | null { return this._loadError; }\n public set loadError(v: string | null) {\n if (v === this._loadError) return;\n this._loadError = v;\n this.LoadErrorChanged.emit(v);\n }\n\n @Output() public LoadErrorChanged = new EventEmitter<string | null>();\n\n /** Tracks last-known field snapshot for computing the dirty-field diff on save. */\n private originalSnapshot: Record<string, unknown> = {};\n\n /**\n * Reference to the mounted React component. Used by the SaveRecord /\n * CancelEdit overrides below to invoke the component's registered\n * `RequestSave` / `RequestCancel` methods when the host toolbar fires\n * Save/Cancel — so the single user-visible Save lives on the toolbar\n * (consistent with every other entity form in MJ) and not duplicated\n * inside the form body.\n */\n @ViewChild('reactComponent') public ReactComponent?: MJReactComponent;\n\n /** @deprecated Use {@link ReactComponent}. */\n public get reactComponent(): MJReactComponent | undefined {\n return this.ReactComponent;\n }\n /** @deprecated Use {@link ReactComponent}. */\n public set reactComponent(value: MJReactComponent | undefined) {\n this.ReactComponent = value;\n }\n\n /**\n * Promise resolver populated when `SaveRecord` invokes `RequestSave`\n * on the React component. `handleBeforeSave` resolves it after the\n * BeforeSave-driven entity save completes, so SaveRecord can return\n * a meaningful success boolean and honor `StopEditModeAfterSave`.\n */\n private pendingSaveResolver: ((success: boolean) => void) | null = null;\n\n private readonly changeDetector = inject(ChangeDetectorRef);\n private readonly reactBridge = inject(ReactBridgeService);\n\n public override async ngOnInit(): Promise<void> {\n await super.ngOnInit();\n // Force the React bridge to be initialized BEFORE we let our template\n // mount the `<mj-react-component>` child. Without this, the child's\n // ngAfterViewInit can race the adapter bootstrap and throw \"React\n // runtime not initialized\" — which then prevents the form from\n // rendering and silently breaks the save flow.\n try {\n await this.reactBridge.getReactContext();\n } catch (err) {\n LogError(`InteractiveFormComponent: React bridge bootstrap failed: ${err instanceof Error ? err.message : String(err)}`);\n this.loadError ='React runtime failed to load. Try a hard refresh.';\n return;\n }\n if (this.record) {\n this.originalSnapshot = this.record.GetAll();\n this.rebuildFormHostProps();\n }\n // Mark init complete so the `record` setter rebuilds on subsequent\n // input changes (post-mount record swaps from the Form Builder\n // cockpit preview picker, etc.). Before this flag flips, the setter\n // intentionally does nothing because ngOnInit already handles the\n // initial assignment.\n this._recordInitialized = true;\n // Direct-spec path (artifact viewer) takes precedence; DB fetch only\n // when no spec was supplied and we have an ID to look up.\n if (!this.componentSpec && this.ComponentID) {\n await this.loadComponentSpec();\n }\n }\n\n /**\n * Called by the React component via `mj-react-component`'s `componentEvent`\n * @Output. Maps the form-role event names to BaseEntity operations.\n */\n public async OnReactComponentEvent(event: ReactComponentEvent): Promise<void> {\n switch (event.type) {\n case FormEventNames.BeforeSave:\n await this.handleBeforeSave(event.payload as FormBeforeSaveArgs);\n break;\n case FormEventNames.BeforeDelete:\n await this.handleBeforeDelete(event.payload as FormBeforeDeleteArgs);\n break;\n case FormEventNames.EditModeChangeRequested:\n this.handleEditModeChangeRequested(event.payload as FormEditModeChangeRequestedArgs);\n break;\n // FieldChanged / DirtyStateChanged / ValidationChanged are read-only signals;\n // the wrapper doesn't need to react beyond what the component does internally.\n }\n }\n\n /**\n * Called when the form-role component drills into a related record via\n * `callbacks.OpenEntityRecord(...)`. Relays it upward as a `Navigate` event\n * (the same path normal FK links use) so the host opens the target record.\n */\n public OnOpenEntityRecord(event: { entityName: string; key: CompositeKey }): void {\n this.Navigate.emit({ Kind: 'record', EntityName: event.entityName, PrimaryKey: event.key });\n }\n\n /**\n * Apply the React component's dirty-field diff to the BaseEntity, save,\n * and refresh the snapshot. Errors surface via `LatestResult.CompleteMessage`\n * per the BaseEntity Save contract.\n *\n * Resolves `pendingSaveResolver` if {@link SaveRecord} initiated this\n * flow via the toolbar — so the toolbar can return a meaningful boolean\n * and honor `StopEditModeAfterSave`.\n */\n private async handleBeforeSave(args: FormBeforeSaveArgs): Promise<void> {\n if (args.cancel) {\n this.resolvePendingSave(false);\n return;\n }\n if (!this.record) {\n LogError('InteractiveFormComponent.handleBeforeSave: no record loaded');\n this.resolvePendingSave(false);\n return;\n }\n\n const dirtyEntries = Object.entries(args.dirtyFields ?? {});\n if (dirtyEntries.length === 0 && this.record.IsSaved) {\n // No dirty fields on an already-persisted record — a genuine no-op.\n // Most likely the user clicked Save without changing anything, or the\n // React draft didn't reach the host before RequestSave fired. Surface\n // it so the user sees why their edits didn't land.\n console.warn(\n '[InteractiveFormComponent] BeforeSave fired with no dirtyFields. ' +\n 'Either the user clicked Save without changing anything, or the ' +\n 'React draft did not propagate before save fired.'\n );\n // Skip Save() + rebuildFormHostProps(): re-rendering the React form\n // would re-fire BeforeSave on a form that emits it on mount/render —\n // an infinite re-mount loop that starves the form's async data load\n // (it unmounts before setState commits). Treat it as a no-op.\n //\n // Guard on IsSaved so this only short-circuits existing records. A\n // NEW record with no dirty fields must still fall through to Save()\n // so the insert is attempted (and any validation failure surfaced)\n // rather than masked as a reported success with no row inserted.\n this.resolvePendingSave(true);\n return;\n }\n for (const [fieldName, value] of dirtyEntries) {\n const field = this.record.Fields.find(f =>\n f.Name.trim().toLowerCase() === fieldName.trim().toLowerCase());\n if (field) {\n // Use the canonical field name from the lookup so case\n // mismatches between the React draft and the entity schema\n // don't silently drop the value.\n this.record.Set(field.Name, value);\n } else {\n console.warn(\n `[InteractiveFormComponent] Unknown field \"${fieldName}\" in dirtyFields ` +\n `for entity ${this.record.EntityInfo.Name}. Value not applied.`\n );\n }\n }\n\n const saved = await this.record.Save();\n if (saved) {\n this.originalSnapshot = this.record.GetAll();\n this.rebuildFormHostProps();\n } else {\n LogError(`InteractiveFormComponent: save failed for ${this.record.EntityInfo.Name}: ${this.record.LatestResult?.CompleteMessage ?? 'unknown error'}`);\n }\n this.resolvePendingSave(saved);\n }\n\n private resolvePendingSave(success: boolean): void {\n if (this.pendingSaveResolver) {\n this.pendingSaveResolver(success);\n this.pendingSaveResolver = null;\n }\n }\n\n private async handleBeforeDelete(args: FormBeforeDeleteArgs): Promise<void> {\n if (args.cancel) {\n return;\n }\n if (!this.record) {\n return;\n }\n const deleted = await this.record.Delete();\n if (!deleted) {\n LogError(`InteractiveFormComponent: delete failed for ${this.record.EntityInfo.Name}: ${this.record.LatestResult?.CompleteMessage ?? 'unknown error'}`);\n }\n }\n\n private handleEditModeChangeRequested(args: FormEditModeChangeRequestedArgs): void {\n if (args.cancel) {\n return;\n }\n if (args.requestedMode === 'edit') {\n this.StartEditMode();\n } else {\n this.EndEditMode();\n }\n }\n\n /**\n * Propagate Angular-toolbar-driven mode changes into the React component's\n * `FormHostProps.mode`. Without these overrides, clicking Edit on the\n * `<mj-record-form-container>` toolbar flips `this.EditMode` but the React\n * side still sees `mode: 'view'`.\n */\n public override StartEditMode(): void {\n super.StartEditMode();\n this.rebuildFormHostProps();\n }\n\n public override EndEditMode(): void {\n super.EndEditMode();\n this.rebuildFormHostProps();\n }\n\n /**\n * Toolbar **Save** override. Routes the click through the React\n * component's registered `RequestSave` method so the React layer can\n * (a) run its own validation, (b) flush its draft state, (c) emit\n * `BeforeSave` with the dirty-field diff — exactly the flow the\n * in-form Save button would trigger. The wrapper then awaits the\n * BeforeSave handler via `pendingSaveResolver`, gets a real\n * success/failure boolean, and honors `StopEditModeAfterSave`.\n *\n * Falls back to the base implementation for components that haven't\n * registered `RequestSave` — preserves correctness for forms that\n * keep their own in-form Save button (older sample, hand-authored\n * forms that pre-date this contract).\n */\n public override async SaveRecord(StopEditModeAfterSave: boolean): Promise<boolean> {\n if (!this.ReactComponent?.hasMethod?.(FormMethodNames.RequestSave)) {\n return super.SaveRecord(StopEditModeAfterSave);\n }\n const completion = new Promise<boolean>(resolve => {\n this.pendingSaveResolver = resolve;\n });\n try {\n this.ReactComponent.invokeMethod(FormMethodNames.RequestSave);\n } catch (err) {\n this.pendingSaveResolver = null;\n LogError(`InteractiveFormComponent.SaveRecord: RequestSave threw: ${err instanceof Error ? err.message : String(err)}`);\n return false;\n }\n const success = await completion;\n if (success && StopEditModeAfterSave) {\n this.EndEditMode();\n }\n return success;\n }\n\n /**\n * Toolbar **Cancel** override. Asks the React component to discard\n * its draft via `RequestCancel`, then flips out of edit mode the\n * same way the base implementation would. The React component is\n * expected to (a) clear its local draft state and (b) emit\n * `EditModeChangeRequested({ requestedMode: 'view' })` — though we\n * call `EndEditMode` here directly anyway, so even a no-op handler\n * leaves the form in a coherent state.\n */\n public override CancelEdit(): void {\n if (this.ReactComponent?.hasMethod?.(FormMethodNames.RequestCancel)) {\n try {\n this.ReactComponent.invokeMethod(FormMethodNames.RequestCancel);\n } catch (err) {\n LogError(`InteractiveFormComponent.CancelEdit: RequestCancel threw: ${err instanceof Error ? err.message : String(err)}`);\n }\n // Don't call super.CancelEdit() — base reverts the BaseEntity,\n // but for interactive forms the BaseEntity never received the\n // React draft in the first place, so there's nothing to revert.\n // Just flip mode.\n this.EndEditMode();\n return;\n }\n super.CancelEdit();\n }\n\n /**\n * Resolve the Component row, parse its `Specification`, and surface either\n * the spec or an error. Backed by `InteractiveFormsEngine` (in-memory\n * cache, BaseEntity event-driven invalidation) so this is a sub-ms JS\n * lookup once the engine has loaded — the engine handles freshness\n * via remote-invalidate events, replacing the prior RunView's\n * `BypassCache: true` escape hatch. Falls through to a one-shot\n * RunView only on engine-cache miss (defensive — the engine should\n * always have a Type='Form' Component, but if a brand-new Component\n * was just created on the server and the invalidation event hasn't\n * propagated yet, we still want to render rather than blank-screen).\n */\n private async loadComponentSpec(): Promise<void> {\n if (!this.ComponentID) {\n this.loadError ='No ComponentID provided to InteractiveFormComponent.';\n return;\n }\n try {\n const provider = this.ProviderToUse;\n const user = provider.CurrentUser;\n // Lazy-load the form-metadata cache. No-op when already loaded.\n try {\n await InteractiveFormsEngine.Instance.Config(false, user, provider);\n } catch (err) {\n LogError(`InteractiveFormComponent: InteractiveFormsEngine.Config failed: ${err instanceof Error ? err.message : String(err)}`);\n // Fall through to RunView path below — engine miss isn't fatal.\n }\n\n let specJson: string | null = null;\n let nameForError: string | undefined;\n\n const cached = InteractiveFormsEngine.Instance.FindFormByID(this.ComponentID);\n if (cached) {\n specJson = cached.Specification;\n nameForError = cached.Name;\n } else {\n // Engine miss — one-shot RunView fallback. This covers the\n // narrow window where a freshly-created Component hasn't\n // propagated to the engine yet (cross-process remote-invalidate\n // is debounced ~1.5s). After the propagation lands subsequent\n // form opens hit the cache.\n const rv = RunView.FromMetadataProvider(provider);\n const result = await rv.RunView<{ ID: string; Specification: string; Name: string }>({\n EntityName: 'MJ: Components',\n Fields: ['ID', 'Name', 'Specification'],\n ExtraFilter: `ID='${this.ComponentID}'`,\n MaxRows: 1,\n ResultType: 'simple',\n BypassCache: true,\n }, user);\n if (!result.Success || !result.Results?.length) {\n this.loadError =`Component ${this.ComponentID} not found.`;\n return;\n }\n specJson = result.Results[0].Specification;\n nameForError = result.Results[0].Name;\n }\n\n try {\n this.componentSpec = JSON.parse(specJson ?? 'null') as ComponentSpec;\n } catch (err) {\n this.loadError =`Component ${nameForError ?? this.ComponentID} has invalid Specification JSON: ${err instanceof Error ? err.message : String(err)}`;\n return;\n }\n if (!this.componentSpec) {\n this.loadError =`Component ${nameForError ?? this.ComponentID} has an empty Specification.`;\n return;\n }\n // Validate the spec commits to the form-role contract. We use the\n // helper (whose signature is structural via Pick<>) so this stays\n // robust across ComponentSpec field additions.\n if (!isFormRole(this.componentSpec)) {\n this.loadError =`Component ${nameForError ?? this.ComponentID} does not declare componentRole='form'.`;\n return;\n }\n } finally {\n this.changeDetector.markForCheck();\n }\n }\n\n /**\n * Build `FormHostProps` from the current record + permissions + edit mode.\n * Called whenever the record loads, mode changes, or save completes.\n */\n private rebuildFormHostProps(): void {\n if (!this.record) {\n this.FormHostProps = null;\n return;\n }\n const fields: SimpleEntityFieldInfo[] = this.record.Fields.map(f =>\n SimpleEntityFieldInfo.FromEntityFieldInfo(f.EntityFieldInfo));\n\n const pk = this.record.PrimaryKey;\n const primaryKey: Record<string, unknown> | null = (pk && pk.HasValue)\n ? this.primaryKeyToPlain(pk)\n : null;\n\n this.FormHostProps = {\n entityName: this.record.EntityInfo.Name,\n primaryKey,\n record: this.record.GetAll(),\n entityMetadata: {\n fields,\n displayName: this.record.EntityInfo.DisplayName ?? this.record.EntityInfo.Name,\n nameField: this.record.EntityInfo.NameField?.Name,\n },\n mode: this.EditMode ? 'edit' : (pk && pk.HasValue ? 'view' : 'create'),\n canEdit: this.UserCanEdit,\n canDelete: this.UserCanDelete,\n canCreate: this.UserCanCreate,\n };\n }\n\n private primaryKeyToPlain(pk: CompositeKey): Record<string, unknown> {\n const obj: Record<string, unknown> = {};\n for (const kvp of pk.KeyValuePairs ?? []) {\n obj[kvp.FieldName] = kvp.Value;\n }\n return obj;\n }\n}\n\n/**\n * Tree-shaking guard. Imported and called from public-api.ts so bundlers don't\n * drop the component when no consumer references it by name.\n */\nexport function LoadInteractiveFormComponent(): void {\n // Force the class reference to stay live.\n if (false as boolean) {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const _: unknown = InteractiveFormComponent;\n }\n}\n","@if (record) {\n@if (previewMode) {\n <!-- Preview mode — no toolbar wrap. Just the form body for clean\n \"what the form looks like\" previews (Form Builder cockpit). -->\n @if (loadError) {\n <mj-alert Variant=\"error\">{{ loadError }}</mj-alert>\n } @else if (componentSpec && formHostProps) {\n <mj-react-component\n #reactComponent\n [component]=\"componentSpec\"\n [componentProps]=\"formHostProps\"\n (componentEvent)=\"OnReactComponentEvent($event)\"\n (openEntityRecord)=\"OnOpenEntityRecord($event)\">\n </mj-react-component>\n } @else {\n <div class=\"mj-loading-state\">\n <i class=\"fa-solid fa-spinner fa-spin\"></i>\n <span>Loading form…</span>\n </div>\n }\n} @else {\n<mj-record-form-container\n [Record]=\"record\"\n [FormComponent]=\"this\"\n (Navigate)=\"OnFormNavigate($event)\"\n (DeleteRequested)=\"OnDeleteRequested()\"\n (FavoriteToggled)=\"OnFavoriteToggled()\"\n (HistoryRequested)=\"OnHistoryRequested()\"\n (ListManagementRequested)=\"OnListManagementRequested()\">\n\n @if (loadError) {\n <mj-alert Variant=\"error\">{{ loadError }}</mj-alert>\n } @else if (componentSpec && formHostProps) {\n <mj-react-component\n #reactComponent\n [component]=\"componentSpec\"\n [componentProps]=\"formHostProps\"\n (componentEvent)=\"OnReactComponentEvent($event)\"\n (openEntityRecord)=\"OnOpenEntityRecord($event)\">\n </mj-react-component>\n } @else {\n <div class=\"mj-loading-state\">\n <i class=\"fa-solid fa-spinner fa-spin\"></i>\n <span>Loading form…</span>\n </div>\n }\n\n</mj-record-form-container>\n}\n}\n"]}
|
|
@@ -55,11 +55,11 @@ export declare class MjIsaRelatedCardComponent extends BaseAngularComponent impl
|
|
|
55
55
|
/** Load the related entity record and extract field data */
|
|
56
56
|
LoadRelatedRecord(): Promise<void>;
|
|
57
57
|
/** Split fields into DefaultInView (shown by default) and extra (hidden) */
|
|
58
|
-
private
|
|
58
|
+
private buildFieldDisplayLists;
|
|
59
59
|
/** Create a display representation of a single field value */
|
|
60
|
-
private
|
|
60
|
+
private buildFieldDisplay;
|
|
61
61
|
/** Format a field value for compact display */
|
|
62
|
-
private
|
|
62
|
+
private formatFieldValue;
|
|
63
63
|
/** Toggle expanded state to show/hide extra fields */
|
|
64
64
|
ToggleExpand(): void;
|
|
65
65
|
/** Handle "Open" link click — emit navigation event */
|
|
@@ -202,7 +202,7 @@ export class MjIsaRelatedCardComponent extends BaseAngularComponent {
|
|
|
202
202
|
return;
|
|
203
203
|
}
|
|
204
204
|
this.RelatedRecord = entity;
|
|
205
|
-
this.
|
|
205
|
+
this.buildFieldDisplayLists();
|
|
206
206
|
}
|
|
207
207
|
catch {
|
|
208
208
|
this.LoadError = true;
|
|
@@ -213,7 +213,7 @@ export class MjIsaRelatedCardComponent extends BaseAngularComponent {
|
|
|
213
213
|
}
|
|
214
214
|
}
|
|
215
215
|
/** Split fields into DefaultInView (shown by default) and extra (hidden) */
|
|
216
|
-
|
|
216
|
+
buildFieldDisplayLists() {
|
|
217
217
|
if (!this.RelatedRecord || !this.EntityInfoRef)
|
|
218
218
|
return;
|
|
219
219
|
const parentFieldNames = this.EntityInfoRef.ParentEntityFieldNames;
|
|
@@ -232,7 +232,7 @@ export class MjIsaRelatedCardComponent extends BaseAngularComponent {
|
|
|
232
232
|
const defaultFields = [];
|
|
233
233
|
const extraFields = [];
|
|
234
234
|
for (const field of ownFields) {
|
|
235
|
-
const display = this.
|
|
235
|
+
const display = this.buildFieldDisplay(field);
|
|
236
236
|
if (field.DefaultInView) {
|
|
237
237
|
defaultFields.push(display);
|
|
238
238
|
}
|
|
@@ -244,7 +244,7 @@ export class MjIsaRelatedCardComponent extends BaseAngularComponent {
|
|
|
244
244
|
this.ExtraFields = extraFields;
|
|
245
245
|
}
|
|
246
246
|
/** Create a display representation of a single field value */
|
|
247
|
-
|
|
247
|
+
buildFieldDisplay(field) {
|
|
248
248
|
const rawValue = this.RelatedRecord.Get(field.Name);
|
|
249
249
|
const label = field.DisplayNameOrName;
|
|
250
250
|
// Handle boolean fields
|
|
@@ -259,11 +259,11 @@ export class MjIsaRelatedCardComponent extends BaseAngularComponent {
|
|
|
259
259
|
// Format the value for display
|
|
260
260
|
return {
|
|
261
261
|
Label: label,
|
|
262
|
-
Value: this.
|
|
262
|
+
Value: this.formatFieldValue(rawValue, field)
|
|
263
263
|
};
|
|
264
264
|
}
|
|
265
265
|
/** Format a field value for compact display */
|
|
266
|
-
|
|
266
|
+
formatFieldValue(value, field) {
|
|
267
267
|
if (value == null)
|
|
268
268
|
return '';
|
|
269
269
|
// Date formatting. A `date` column is a calendar day that arrives as UTC midnight; a local-zone
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isa-related-card.component.js","sourceRoot":"","sources":["../../../src/lib/isa-related-panel/isa-related-card.component.ts","../../../src/lib/isa-related-panel/isa-related-card.component.html"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,YAAY,EACtC,uBAAuB,EAAE,iBAAiB,EAAE,MAAM,EAChB,iBAAiB,EACpD,MAAM,eAAe,CAAC;AACvB,OAAO,EAC4D,iBAAiB,EAAE,cAAc,EACnG,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;;;;;ICG7D,+BAAuC;IAAA,YAAgB;IAAA,iBAAO;;;IAAvB,cAAgB;IAAhB,uCAAgB;;;IAQ3D,8BAA0D;IAExD,AADA,0BAA4C,cACgC;IAC9E,iBAAM;;;IAMJ,AADF,8BAAwD,eAChB;IAAA,qCAAqB;IAC7D,AAD6D,iBAAO,EAC9D;;;IAQA,AADF,+BAAgC,eACS;IAAA,YAAiB;IAAA,iBAAO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AKC;YAGD,cAIC;YAJD,2DAIC;YAGD,cA2CC;YA3CD,iFA2CC;YAGD,cAcC;YAdD,qEAcC;4BDxDU,yBAAyB;;iFAAzB,yBAAyB;cARrC,SAAS;6BACI,KAAK,YACP,qBAAqB,mBACd,uBAAuB,CAAC,MAAM,iBAChC,iBAAiB,CAAC,IAAI;;kBAQpC,KAAK;;kBAGL,KAAK;;kBAGL,KAAK;;kBAGL,KAAK;;kBAGL,KAAK;;kBAGL,KAAK;;kBAGL,MAAM;;kFAtBI,yBAAyB","sourcesContent":["import {\n Component, Input, Output, EventEmitter,\n ChangeDetectionStrategy, ChangeDetectorRef, inject,\n OnInit, OnChanges, SimpleChanges, ViewEncapsulation\n} from '@angular/core';\nimport {\n BaseEntity, EntityInfo, EntityFieldInfo, Metadata, CompositeKey, IsDateOnlySQLType, FormatDateOnly\n} from '@memberjunction/core';\nimport { EntityHierarchyNavigationEvent } from '../types/navigation-events';\nimport { BaseAngularComponent } from '@memberjunction/ng-base-types';\nimport { IsaRelatedItem } from './isa-hierarchy-utils';\n\n/**\n * Represents a single field value displayed in the ISA related card.\n */\nexport interface IsaCardFieldDisplay {\n Label: string;\n Value: string;\n IsBooleanTrue?: boolean;\n IsBooleanFalse?: boolean;\n}\n\n/**\n * Compact card showing summary fields for one IS-A related entity record\n * (sibling or child). Displays DefaultInView fields by default with\n * expand/collapse for remaining fields.\n *\n * Used inside `<mj-isa-related-panel>` to show related IS-A records\n * alongside the main form.\n */\n@Component({\n standalone: false,\n selector: 'mj-isa-related-card',\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n templateUrl: './isa-related-card.component.html',\n styleUrls: ['./isa-related-card.component.css']\n})\nexport class MjIsaRelatedCardComponent extends BaseAngularComponent implements OnInit, OnChanges {\n private cdr = inject(ChangeDetectorRef);\n\n /** The entity name for the related record (e.g., \"Members\", \"Speakers\") */\n @Input() EntityName = '';\n\n /** The primary key shared with the parent record */\n @Input() PrimaryKey: CompositeKey | null = null;\n\n /** The record name of the current form's entity (to suppress if same) */\n @Input() CurrentRecordName = '';\n\n /** The relationship type label */\n @Input() Relationship: 'sibling' | 'child' = 'sibling';\n\n /** Depth in the IS-A hierarchy (0 = direct child/sibling, 1 = grandchild, etc.) */\n @Input() Depth = 0;\n\n /** Child items nested under this entity (rendered as sub-cards within this card) */\n @Input() Children: IsaRelatedItem[] = [];\n\n /** Emitted when user clicks \"Open\" to navigate to this related record */\n @Output() Navigate = new EventEmitter<EntityHierarchyNavigationEvent>();\n\n // Internal state\n EntityInfoRef: EntityInfo | null = null;\n RelatedRecord: BaseEntity | null = null;\n IsLoading = true;\n LoadError = false;\n Expanded = false;\n\n DefaultFields: IsaCardFieldDisplay[] = [];\n ExtraFields: IsaCardFieldDisplay[] = [];\n\n /** Display name for the entity */\n get DisplayName(): string {\n return this.EntityInfoRef?.DisplayNameOrName ?? this.EntityName;\n }\n\n /** Icon class from entity metadata */\n get IconClass(): string {\n return this.EntityInfoRef?.Icon ?? 'fa-solid fa-link';\n }\n\n /** Record name of the related record (suppressed if same as current) */\n get RecordName(): string {\n if (!this.RelatedRecord) return '';\n const name = this.RelatedRecord.GetRecordName();\n if (!name) return '';\n const nameStr = String(name);\n // Suppress if same as the current form's record name\n if (nameStr === this.CurrentRecordName) return '';\n return nameStr;\n }\n\n ngOnInit(): void {\n this.LoadRelatedRecord();\n }\n\n ngOnChanges(changes: SimpleChanges): void {\n if ((changes['EntityName'] || changes['PrimaryKey']) && !changes['EntityName']?.firstChange) {\n this.LoadRelatedRecord();\n }\n }\n\n /** Load the related entity record and extract field data */\n async LoadRelatedRecord(): Promise<void> {\n if (!this.EntityName || !this.PrimaryKey) return;\n\n this.IsLoading = true;\n this.LoadError = false;\n this.cdr.markForCheck();\n\n try {\n const md = this.ProviderToUse;\n this.EntityInfoRef = md.EntityByName(this.EntityName) ?? null;\n if (!this.EntityInfoRef) {\n this.LoadError = true;\n return;\n }\n\n const entity = await md.GetEntityObject<BaseEntity>(this.EntityName);\n const loaded = await entity.InnerLoad(this.PrimaryKey);\n if (!loaded) {\n this.LoadError = true;\n return;\n }\n\n this.RelatedRecord = entity;\n this.BuildFieldDisplayLists();\n } catch {\n this.LoadError = true;\n } finally {\n this.IsLoading = false;\n this.cdr.markForCheck();\n }\n }\n\n /** Split fields into DefaultInView (shown by default) and extra (hidden) */\n private BuildFieldDisplayLists(): void {\n if (!this.RelatedRecord || !this.EntityInfoRef) return;\n\n const parentFieldNames = this.EntityInfoRef.ParentEntityFieldNames;\n // Field-level security is filtered here rather than at render time because BuildFieldDisplay\n // calls Get(), which THROWS on a denied field — one denied column would take out the whole\n // card instead of omitting a row. This is the IS-A sibling's entity, not the host form's, so\n // its permissions are independent of anything the form has already checked.\n const user = this.ProviderToUse?.CurrentUser;\n const ownFields = this.EntityInfoRef.Fields.filter(f =>\n !f.IsPrimaryKey &&\n !f.IsVirtual &&\n !parentFieldNames.has(f.Name) &&\n f.Name !== '__mj_CreatedAt' &&\n f.Name !== '__mj_UpdatedAt' &&\n f.IncludeInGeneratedForm &&\n this.EntityInfoRef!.IsFieldReadableByUser(f.Name, user)\n );\n\n const defaultFields: IsaCardFieldDisplay[] = [];\n const extraFields: IsaCardFieldDisplay[] = [];\n\n for (const field of ownFields) {\n const display = this.BuildFieldDisplay(field);\n if (field.DefaultInView) {\n defaultFields.push(display);\n } else {\n extraFields.push(display);\n }\n }\n\n this.DefaultFields = defaultFields;\n this.ExtraFields = extraFields;\n }\n\n /** Create a display representation of a single field value */\n private BuildFieldDisplay(field: EntityFieldInfo): IsaCardFieldDisplay {\n const rawValue = this.RelatedRecord!.Get(field.Name);\n const label = field.DisplayNameOrName;\n\n // Handle boolean fields\n if (field.TSType === 'boolean') {\n return {\n Label: label,\n Value: rawValue ? 'Yes' : 'No',\n IsBooleanTrue: !!rawValue,\n IsBooleanFalse: !rawValue\n };\n }\n\n // Format the value for display\n return {\n Label: label,\n Value: this.FormatFieldValue(rawValue, field)\n };\n }\n\n /** Format a field value for compact display */\n private FormatFieldValue(value: unknown, field: EntityFieldInfo): string {\n if (value == null) return '';\n\n // Date formatting. A `date` column is a calendar day that arrives as UTC midnight; a local-zone\n // formatter would land on the previous day for every reader west of Greenwich (MJ#4210).\n // A timestamp names an instant and stays in local time.\n if (value instanceof Date) {\n const options: Intl.DateTimeFormatOptions = { month: 'short', day: 'numeric', year: 'numeric' };\n return IsDateOnlySQLType(field.Type) ? FormatDateOnly(value, options, 'en-US') : value.toLocaleDateString('en-US', options);\n }\n\n // Number formatting\n if (typeof value === 'number') {\n if (field.Type?.toLowerCase().includes('money')) {\n return new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD' }).format(value);\n }\n return value.toLocaleString();\n }\n\n return String(value);\n }\n\n /** Toggle expanded state to show/hide extra fields */\n ToggleExpand(): void {\n this.Expanded = !this.Expanded;\n this.cdr.markForCheck();\n }\n\n /** Handle \"Open\" link click — emit navigation event */\n OnOpenClick(event: MouseEvent): void {\n event.preventDefault();\n if (!this.PrimaryKey) return;\n\n this.Navigate.emit({\n Kind: 'entity-hierarchy',\n EntityName: this.EntityName,\n PrimaryKey: this.PrimaryKey,\n Direction: this.Relationship === 'sibling' ? 'child' : 'child'\n });\n }\n}\n","<!-- ISA Related Card: compact summary of one sibling/child entity record -->\n<div class=\"mj-isa-card\"\n [class.mj-isa-card--loading]=\"IsLoading\"\n [class.mj-isa-card--error]=\"LoadError\"\n [class.mj-isa-card--nested]=\"Depth > 0\">\n\n <!-- Card Header -->\n <div class=\"mj-isa-card__header\">\n <div class=\"mj-isa-card__header-left\">\n <i [class]=\"IconClass\" class=\"mj-isa-card__icon\"></i>\n <span class=\"mj-isa-card__entity-name\">{{ DisplayName }}</span>\n @if (RecordName) {\n <span class=\"mj-isa-card__record-name\">{{ RecordName }}</span>\n }\n </div>\n <a href=\"#\" class=\"mj-isa-card__open-link\" (click)=\"OnOpenClick($event)\">Open →</a>\n </div>\n\n <!-- Loading State -->\n @if (IsLoading) {\n <div class=\"mj-isa-card__body mj-isa-card__body--loading\">\n <div class=\"mj-isa-card__loading-bar\"></div>\n <div class=\"mj-isa-card__loading-bar mj-isa-card__loading-bar--short\"></div>\n </div>\n }\n\n <!-- Error State -->\n @if (LoadError && !IsLoading) {\n <div class=\"mj-isa-card__body mj-isa-card__body--error\">\n <span class=\"mj-isa-card__error-text\">Unable to load record</span>\n </div>\n }\n\n <!-- Field Values -->\n @if (!IsLoading && !LoadError && RelatedRecord) {\n <div class=\"mj-isa-card__body\">\n @for (field of DefaultFields; track field.Label) {\n <div class=\"mj-isa-card__field\">\n <span class=\"mj-isa-card__field-label\">{{ field.Label }}</span>\n <span class=\"mj-isa-card__field-value\"\n [class.mj-isa-card__field-value--bool-yes]=\"field.IsBooleanTrue\"\n [class.mj-isa-card__field-value--bool-no]=\"field.IsBooleanFalse\">\n {{ field.Value }}\n </span>\n </div>\n }\n </div>\n\n <!-- Expand/Collapse for extra fields -->\n @if (ExtraFields.length > 0) {\n <div class=\"mj-isa-card__expand-row\">\n <button class=\"mj-isa-card__expand-btn\" (click)=\"ToggleExpand()\">\n @if (!Expanded) {\n Show {{ ExtraFields.length }} more field{{ ExtraFields.length > 1 ? 's' : '' }}\n <i class=\"fa-solid fa-chevron-down mj-isa-card__expand-chevron\"></i>\n } @else {\n Show fewer fields\n <i class=\"fa-solid fa-chevron-up mj-isa-card__expand-chevron\"></i>\n }\n </button>\n </div>\n\n @if (Expanded) {\n <div class=\"mj-isa-card__extra-fields\">\n @for (field of ExtraFields; track field.Label) {\n <div class=\"mj-isa-card__field\">\n <span class=\"mj-isa-card__field-label\">{{ field.Label }}</span>\n <span class=\"mj-isa-card__field-value\"\n [class.mj-isa-card__field-value--bool-yes]=\"field.IsBooleanTrue\"\n [class.mj-isa-card__field-value--bool-no]=\"field.IsBooleanFalse\">\n {{ field.Value }}\n </span>\n </div>\n }\n </div>\n }\n }\n }\n\n <!-- Nested sub-cards for IS-A children (e.g., Gold Members inside Members) -->\n @if (Children.length > 0 && !IsLoading) {\n <div class=\"mj-isa-card__children\">\n @for (child of Children; track child.EntityName) {\n <mj-isa-related-card\n [EntityName]=\"child.EntityName\"\n [PrimaryKey]=\"PrimaryKey\"\n [CurrentRecordName]=\"CurrentRecordName\"\n [Relationship]=\"'child'\"\n [Depth]=\"Depth + 1\"\n [Children]=\"child.Children\"\n (Navigate)=\"Navigate.emit($event)\">\n </mj-isa-related-card>\n }\n </div>\n }\n</div>\n"]}
|
|
1
|
+
{"version":3,"file":"isa-related-card.component.js","sourceRoot":"","sources":["../../../src/lib/isa-related-panel/isa-related-card.component.ts","../../../src/lib/isa-related-panel/isa-related-card.component.html"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,YAAY,EACtC,uBAAuB,EAAE,iBAAiB,EAAE,MAAM,EAChB,iBAAiB,EACpD,MAAM,eAAe,CAAC;AACvB,OAAO,EAC4D,iBAAiB,EAAE,cAAc,EACnG,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;;;;;ICG7D,+BAAuC;IAAA,YAAgB;IAAA,iBAAO;;;IAAvB,cAAgB;IAAhB,uCAAgB;;;IAQ3D,8BAA0D;IAExD,AADA,0BAA4C,cACgC;IAC9E,iBAAM;;;IAMJ,AADF,8BAAwD,eAChB;IAAA,qCAAqB;IAC7D,AAD6D,iBAAO,EAC9D;;;IAQA,AADF,+BAAgC,eACS;IAAA,YAAiB;IAAA,iBAAO;IAC/D,gCAEuE;IACrE,YACF;IACF,AADE,iBAAO,EACH;;;IANmC,eAAiB;IAAjB,oCAAiB;IAElD,cAAgE;IAChE,AADA,4EAAgE,8DACA;IACpE,cACF;IADE,+CACF;;;IAUE,YACA;IAAA,wBAAoE;;;IADpE,wHACA;;;IAEA,mCACA;IAAA,wBAAkE;;;IAShE,AADF,+BAAgC,eACS;IAAA,YAAiB;IAAA,iBAAO;IAC/D,gCAEuE;IACrE,YACF;IACF,AADE,iBAAO,EACH;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;kFAtBI,yBAAyB","sourcesContent":["import {\n Component, Input, Output, EventEmitter,\n ChangeDetectionStrategy, ChangeDetectorRef, inject,\n OnInit, OnChanges, SimpleChanges, ViewEncapsulation\n} from '@angular/core';\nimport {\n BaseEntity, EntityInfo, EntityFieldInfo, Metadata, CompositeKey, IsDateOnlySQLType, FormatDateOnly\n} from '@memberjunction/core';\nimport { EntityHierarchyNavigationEvent } from '../types/navigation-events';\nimport { BaseAngularComponent } from '@memberjunction/ng-base-types';\nimport { IsaRelatedItem } from './isa-hierarchy-utils';\n\n/**\n * Represents a single field value displayed in the ISA related card.\n */\nexport interface IsaCardFieldDisplay {\n Label: string;\n Value: string;\n IsBooleanTrue?: boolean;\n IsBooleanFalse?: boolean;\n}\n\n/**\n * Compact card showing summary fields for one IS-A related entity record\n * (sibling or child). Displays DefaultInView fields by default with\n * expand/collapse for remaining fields.\n *\n * Used inside `<mj-isa-related-panel>` to show related IS-A records\n * alongside the main form.\n */\n@Component({\n standalone: false,\n selector: 'mj-isa-related-card',\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n templateUrl: './isa-related-card.component.html',\n styleUrls: ['./isa-related-card.component.css']\n})\nexport class MjIsaRelatedCardComponent extends BaseAngularComponent implements OnInit, OnChanges {\n private cdr = inject(ChangeDetectorRef);\n\n /** The entity name for the related record (e.g., \"Members\", \"Speakers\") */\n @Input() EntityName = '';\n\n /** The primary key shared with the parent record */\n @Input() PrimaryKey: CompositeKey | null = null;\n\n /** The record name of the current form's entity (to suppress if same) */\n @Input() CurrentRecordName = '';\n\n /** The relationship type label */\n @Input() Relationship: 'sibling' | 'child' = 'sibling';\n\n /** Depth in the IS-A hierarchy (0 = direct child/sibling, 1 = grandchild, etc.) */\n @Input() Depth = 0;\n\n /** Child items nested under this entity (rendered as sub-cards within this card) */\n @Input() Children: IsaRelatedItem[] = [];\n\n /** Emitted when user clicks \"Open\" to navigate to this related record */\n @Output() Navigate = new EventEmitter<EntityHierarchyNavigationEvent>();\n\n // Internal state\n EntityInfoRef: EntityInfo | null = null;\n RelatedRecord: BaseEntity | null = null;\n IsLoading = true;\n LoadError = false;\n Expanded = false;\n\n DefaultFields: IsaCardFieldDisplay[] = [];\n ExtraFields: IsaCardFieldDisplay[] = [];\n\n /** Display name for the entity */\n get DisplayName(): string {\n return this.EntityInfoRef?.DisplayNameOrName ?? this.EntityName;\n }\n\n /** Icon class from entity metadata */\n get IconClass(): string {\n return this.EntityInfoRef?.Icon ?? 'fa-solid fa-link';\n }\n\n /** Record name of the related record (suppressed if same as current) */\n get RecordName(): string {\n if (!this.RelatedRecord) return '';\n const name = this.RelatedRecord.GetRecordName();\n if (!name) return '';\n const nameStr = String(name);\n // Suppress if same as the current form's record name\n if (nameStr === this.CurrentRecordName) return '';\n return nameStr;\n }\n\n ngOnInit(): void {\n this.LoadRelatedRecord();\n }\n\n ngOnChanges(changes: SimpleChanges): void {\n if ((changes['EntityName'] || changes['PrimaryKey']) && !changes['EntityName']?.firstChange) {\n this.LoadRelatedRecord();\n }\n }\n\n /** Load the related entity record and extract field data */\n async LoadRelatedRecord(): Promise<void> {\n if (!this.EntityName || !this.PrimaryKey) return;\n\n this.IsLoading = true;\n this.LoadError = false;\n this.cdr.markForCheck();\n\n try {\n const md = this.ProviderToUse;\n this.EntityInfoRef = md.EntityByName(this.EntityName) ?? null;\n if (!this.EntityInfoRef) {\n this.LoadError = true;\n return;\n }\n\n const entity = await md.GetEntityObject<BaseEntity>(this.EntityName);\n const loaded = await entity.InnerLoad(this.PrimaryKey);\n if (!loaded) {\n this.LoadError = true;\n return;\n }\n\n this.RelatedRecord = entity;\n this.buildFieldDisplayLists();\n } catch {\n this.LoadError = true;\n } finally {\n this.IsLoading = false;\n this.cdr.markForCheck();\n }\n }\n\n /** Split fields into DefaultInView (shown by default) and extra (hidden) */\n private buildFieldDisplayLists(): void {\n if (!this.RelatedRecord || !this.EntityInfoRef) return;\n\n const parentFieldNames = this.EntityInfoRef.ParentEntityFieldNames;\n // Field-level security is filtered here rather than at render time because BuildFieldDisplay\n // calls Get(), which THROWS on a denied field — one denied column would take out the whole\n // card instead of omitting a row. This is the IS-A sibling's entity, not the host form's, so\n // its permissions are independent of anything the form has already checked.\n const user = this.ProviderToUse?.CurrentUser;\n const ownFields = this.EntityInfoRef.Fields.filter(f =>\n !f.IsPrimaryKey &&\n !f.IsVirtual &&\n !parentFieldNames.has(f.Name) &&\n f.Name !== '__mj_CreatedAt' &&\n f.Name !== '__mj_UpdatedAt' &&\n f.IncludeInGeneratedForm &&\n this.EntityInfoRef!.IsFieldReadableByUser(f.Name, user)\n );\n\n const defaultFields: IsaCardFieldDisplay[] = [];\n const extraFields: IsaCardFieldDisplay[] = [];\n\n for (const field of ownFields) {\n const display = this.buildFieldDisplay(field);\n if (field.DefaultInView) {\n defaultFields.push(display);\n } else {\n extraFields.push(display);\n }\n }\n\n this.DefaultFields = defaultFields;\n this.ExtraFields = extraFields;\n }\n\n /** Create a display representation of a single field value */\n private buildFieldDisplay(field: EntityFieldInfo): IsaCardFieldDisplay {\n const rawValue = this.RelatedRecord!.Get(field.Name);\n const label = field.DisplayNameOrName;\n\n // Handle boolean fields\n if (field.TSType === 'boolean') {\n return {\n Label: label,\n Value: rawValue ? 'Yes' : 'No',\n IsBooleanTrue: !!rawValue,\n IsBooleanFalse: !rawValue\n };\n }\n\n // Format the value for display\n return {\n Label: label,\n Value: this.formatFieldValue(rawValue, field)\n };\n }\n\n /** Format a field value for compact display */\n private formatFieldValue(value: unknown, field: EntityFieldInfo): string {\n if (value == null) return '';\n\n // Date formatting. A `date` column is a calendar day that arrives as UTC midnight; a local-zone\n // formatter would land on the previous day for every reader west of Greenwich (MJ#4210).\n // A timestamp names an instant and stays in local time.\n if (value instanceof Date) {\n const options: Intl.DateTimeFormatOptions = { month: 'short', day: 'numeric', year: 'numeric' };\n return IsDateOnlySQLType(field.Type) ? FormatDateOnly(value, options, 'en-US') : value.toLocaleDateString('en-US', options);\n }\n\n // Number formatting\n if (typeof value === 'number') {\n if (field.Type?.toLowerCase().includes('money')) {\n return new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD' }).format(value);\n }\n return value.toLocaleString();\n }\n\n return String(value);\n }\n\n /** Toggle expanded state to show/hide extra fields */\n ToggleExpand(): void {\n this.Expanded = !this.Expanded;\n this.cdr.markForCheck();\n }\n\n /** Handle \"Open\" link click — emit navigation event */\n OnOpenClick(event: MouseEvent): void {\n event.preventDefault();\n if (!this.PrimaryKey) return;\n\n this.Navigate.emit({\n Kind: 'entity-hierarchy',\n EntityName: this.EntityName,\n PrimaryKey: this.PrimaryKey,\n Direction: this.Relationship === 'sibling' ? 'child' : 'child'\n });\n }\n}\n","<!-- ISA Related Card: compact summary of one sibling/child entity record -->\n<div class=\"mj-isa-card\"\n [class.mj-isa-card--loading]=\"IsLoading\"\n [class.mj-isa-card--error]=\"LoadError\"\n [class.mj-isa-card--nested]=\"Depth > 0\">\n\n <!-- Card Header -->\n <div class=\"mj-isa-card__header\">\n <div class=\"mj-isa-card__header-left\">\n <i [class]=\"IconClass\" class=\"mj-isa-card__icon\"></i>\n <span class=\"mj-isa-card__entity-name\">{{ DisplayName }}</span>\n @if (RecordName) {\n <span class=\"mj-isa-card__record-name\">{{ RecordName }}</span>\n }\n </div>\n <a href=\"#\" class=\"mj-isa-card__open-link\" (click)=\"OnOpenClick($event)\">Open →</a>\n </div>\n\n <!-- Loading State -->\n @if (IsLoading) {\n <div class=\"mj-isa-card__body mj-isa-card__body--loading\">\n <div class=\"mj-isa-card__loading-bar\"></div>\n <div class=\"mj-isa-card__loading-bar mj-isa-card__loading-bar--short\"></div>\n </div>\n }\n\n <!-- Error State -->\n @if (LoadError && !IsLoading) {\n <div class=\"mj-isa-card__body mj-isa-card__body--error\">\n <span class=\"mj-isa-card__error-text\">Unable to load record</span>\n </div>\n }\n\n <!-- Field Values -->\n @if (!IsLoading && !LoadError && RelatedRecord) {\n <div class=\"mj-isa-card__body\">\n @for (field of DefaultFields; track field.Label) {\n <div class=\"mj-isa-card__field\">\n <span class=\"mj-isa-card__field-label\">{{ field.Label }}</span>\n <span class=\"mj-isa-card__field-value\"\n [class.mj-isa-card__field-value--bool-yes]=\"field.IsBooleanTrue\"\n [class.mj-isa-card__field-value--bool-no]=\"field.IsBooleanFalse\">\n {{ field.Value }}\n </span>\n </div>\n }\n </div>\n\n <!-- Expand/Collapse for extra fields -->\n @if (ExtraFields.length > 0) {\n <div class=\"mj-isa-card__expand-row\">\n <button class=\"mj-isa-card__expand-btn\" (click)=\"ToggleExpand()\">\n @if (!Expanded) {\n Show {{ ExtraFields.length }} more field{{ ExtraFields.length > 1 ? 's' : '' }}\n <i class=\"fa-solid fa-chevron-down mj-isa-card__expand-chevron\"></i>\n } @else {\n Show fewer fields\n <i class=\"fa-solid fa-chevron-up mj-isa-card__expand-chevron\"></i>\n }\n </button>\n </div>\n\n @if (Expanded) {\n <div class=\"mj-isa-card__extra-fields\">\n @for (field of ExtraFields; track field.Label) {\n <div class=\"mj-isa-card__field\">\n <span class=\"mj-isa-card__field-label\">{{ field.Label }}</span>\n <span class=\"mj-isa-card__field-value\"\n [class.mj-isa-card__field-value--bool-yes]=\"field.IsBooleanTrue\"\n [class.mj-isa-card__field-value--bool-no]=\"field.IsBooleanFalse\">\n {{ field.Value }}\n </span>\n </div>\n }\n </div>\n }\n }\n }\n\n <!-- Nested sub-cards for IS-A children (e.g., Gold Members inside Members) -->\n @if (Children.length > 0 && !IsLoading) {\n <div class=\"mj-isa-card__children\">\n @for (child of Children; track child.EntityName) {\n <mj-isa-related-card\n [EntityName]=\"child.EntityName\"\n [PrimaryKey]=\"PrimaryKey\"\n [CurrentRecordName]=\"CurrentRecordName\"\n [Relationship]=\"'child'\"\n [Depth]=\"Depth + 1\"\n [Children]=\"child.Children\"\n (Navigate)=\"Navigate.emit($event)\">\n </mj-isa-related-card>\n }\n </div>\n }\n</div>\n"]}
|
|
@@ -55,18 +55,18 @@ export declare class MjIsaRelatedPanelComponent extends BaseAngularComponent imp
|
|
|
55
55
|
* entity hierarchy. Finds siblings (other children of the same parent)
|
|
56
56
|
* and all descendants (children, grandchildren, etc.) as a tree.
|
|
57
57
|
*/
|
|
58
|
-
private
|
|
58
|
+
private discoverRelatedItems;
|
|
59
59
|
/**
|
|
60
60
|
* When viewing a child entity (e.g., Member), find sibling entities
|
|
61
61
|
* (e.g., Speaker) that also have records with the same parent PK.
|
|
62
62
|
* Uses the parent's ISAChildren if the parent uses overlapping subtypes.
|
|
63
63
|
*/
|
|
64
|
-
private
|
|
64
|
+
private discoverSiblingsFromParent;
|
|
65
65
|
/**
|
|
66
66
|
* Recursively discover all IS-A descendants and build a tree structure.
|
|
67
67
|
* Root-level children appear as top-level cards; grandchildren nest inside.
|
|
68
68
|
*/
|
|
69
|
-
private
|
|
69
|
+
private discoverDescendants;
|
|
70
70
|
/** Relay navigation events from child cards */
|
|
71
71
|
OnCardNavigate(event: EntityHierarchyNavigationEvent): void;
|
|
72
72
|
static ɵfac: i0.ɵɵFactoryDeclaration<MjIsaRelatedPanelComponent, never>;
|
|
@@ -107,7 +107,7 @@ export class MjIsaRelatedPanelComponent extends BaseAngularComponent {
|
|
|
107
107
|
}
|
|
108
108
|
ngOnInit() {
|
|
109
109
|
this.recordRefresh?.Refreshed$.pipe(takeUntil(this.destroy$)).subscribe(() => {
|
|
110
|
-
void this.
|
|
110
|
+
void this.discoverRelatedItems();
|
|
111
111
|
});
|
|
112
112
|
}
|
|
113
113
|
ngOnDestroy() {
|
|
@@ -116,7 +116,7 @@ export class MjIsaRelatedPanelComponent extends BaseAngularComponent {
|
|
|
116
116
|
}
|
|
117
117
|
ngOnChanges(changes) {
|
|
118
118
|
if (changes['Record']) {
|
|
119
|
-
this.
|
|
119
|
+
this.discoverRelatedItems();
|
|
120
120
|
return;
|
|
121
121
|
}
|
|
122
122
|
// Leaving edit mode is the OTHER moment this answer can change, and until now nothing
|
|
@@ -133,7 +133,7 @@ export class MjIsaRelatedPanelComponent extends BaseAngularComponent {
|
|
|
133
133
|
// An overlapping parent (AllowMultipleSubtypes) does load its child entities, so that
|
|
134
134
|
// configuration pays one extra discovery per edit session.
|
|
135
135
|
if (changes['EditMode'] && changes['EditMode'].previousValue === true && !this.EditMode) {
|
|
136
|
-
this.
|
|
136
|
+
this.discoverRelatedItems();
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
139
|
/**
|
|
@@ -141,7 +141,7 @@ export class MjIsaRelatedPanelComponent extends BaseAngularComponent {
|
|
|
141
141
|
* entity hierarchy. Finds siblings (other children of the same parent)
|
|
142
142
|
* and all descendants (children, grandchildren, etc.) as a tree.
|
|
143
143
|
*/
|
|
144
|
-
async
|
|
144
|
+
async discoverRelatedItems() {
|
|
145
145
|
this.RelatedItems = [];
|
|
146
146
|
if (!this.Record)
|
|
147
147
|
return;
|
|
@@ -150,11 +150,11 @@ export class MjIsaRelatedPanelComponent extends BaseAngularComponent {
|
|
|
150
150
|
return;
|
|
151
151
|
// Case 1: Current entity is a child type — find siblings via parent
|
|
152
152
|
if (entityInfo.IsChildType && entityInfo.ParentEntityInfo) {
|
|
153
|
-
this.
|
|
153
|
+
this.discoverSiblingsFromParent(entityInfo);
|
|
154
154
|
}
|
|
155
155
|
// Case 2: Current entity is a parent type — discover all descendants as tree
|
|
156
156
|
if (entityInfo.IsParentType) {
|
|
157
|
-
await this.
|
|
157
|
+
await this.discoverDescendants();
|
|
158
158
|
}
|
|
159
159
|
this.cdr.markForCheck();
|
|
160
160
|
}
|
|
@@ -163,7 +163,7 @@ export class MjIsaRelatedPanelComponent extends BaseAngularComponent {
|
|
|
163
163
|
* (e.g., Speaker) that also have records with the same parent PK.
|
|
164
164
|
* Uses the parent's ISAChildren if the parent uses overlapping subtypes.
|
|
165
165
|
*/
|
|
166
|
-
|
|
166
|
+
discoverSiblingsFromParent(entityInfo) {
|
|
167
167
|
const parent = this.Record?.ISAParent;
|
|
168
168
|
if (!parent)
|
|
169
169
|
return;
|
|
@@ -188,7 +188,7 @@ export class MjIsaRelatedPanelComponent extends BaseAngularComponent {
|
|
|
188
188
|
* Recursively discover all IS-A descendants and build a tree structure.
|
|
189
189
|
* Root-level children appear as top-level cards; grandchildren nest inside.
|
|
190
190
|
*/
|
|
191
|
-
async
|
|
191
|
+
async discoverDescendants() {
|
|
192
192
|
if (!this.Record)
|
|
193
193
|
return;
|
|
194
194
|
const descendants = await DiscoverISADescendants(this.Record, this.ProviderToUse);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isa-related-panel.component.js","sourceRoot":"","sources":["../../../src/lib/isa-related-panel/isa-related-panel.component.ts","../../../src/lib/isa-related-panel/isa-related-panel.component.html"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,YAAY,EACtC,uBAAuB,EAAE,iBAAiB,EAAE,MAAM,EACL,iBAAiB,EAC/D,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAErE,OAAO,EAAE,sBAAsB,EAAE,mBAAmB,EAAkB,MAAM,uBAAuB,CAAC;AACpG,OAAO,EAAE,4BAA4B,EAAE,MAAM,oCAAoC,CAAC;;;;;ICHxE,8BAAoE;IAClE,uBAAgC;IAClC,iBAAM;;;IAFoC,0CAAyB;;;IAFvE,8BAA2C;IACzC,yHAIC;IACH,iBAAM;;;IALJ,cAIC;IAJD,kCAIC;;;;IAMC,8CAOsC;IAApC,4OAAY,6BAAsB,KAAC;IACrC,iBAAsB;;;;IAFpB,AADA,AADA,AADA,AADA,AADA,+CAA8B,uCACC,+CACQ,sCACL,wBACd,8BACM;;;IARhC,8BAAiC;IAC/B,yIAUC;IACH,iBAAM;;;IAXJ,cAUC;IAVD,kCAUC;;;IAxBP,8BAAsE;IAWlE,AARF,0GAAiB,oFAQR;IAgBX,iBA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,mBACf,uBAAuB,CAAC,MAAM,iBAChC,iBAAiB,CAAC,IAAI;;kBAUpC,KAAK;;kBAGL,KAAK;;kBAGL,KAAK;;kBAGL,MAAM;;kFAfI,0BAA0B","sourcesContent":["import {\n Component, Input, Output, EventEmitter,\n ChangeDetectionStrategy, ChangeDetectorRef, inject,\n OnChanges, OnInit, OnDestroy, SimpleChanges, ViewEncapsulation\n} from '@angular/core';\nimport { Subject } from 'rxjs';\nimport { takeUntil } from 'rxjs/operators';\nimport { BaseEntity, EntityInfo, CompositeKey } from '@memberjunction/core';\nimport { BaseAngularComponent } from '@memberjunction/ng-base-types';\nimport { FormNavigationEvent, EntityHierarchyNavigationEvent } from '../types/navigation-events';\nimport { DiscoverISADescendants, BuildDescendantTree, IsaRelatedItem } from './isa-hierarchy-utils';\nimport { FormRecordRefreshCoordinator } from '../form-record-refresh.coordinator';\n\n/**\n * Container panel that discovers and displays IS-A related entity records\n * (siblings and children) for the current form's record.\n *\n * **Placement**: Sits to the right of the main form panels inside\n * `<mj-record-form-container>`. Hidden when in edit mode or when\n * no related IS-A records exist.\n *\n * **Data flow**:\n * - Receives the current `Record` (BaseEntity) as input\n * - Inspects `EntityInfo.ParentEntityInfo` and `ISAChildren` to discover related records\n * - Builds a tree structure for nested sub-card rendering\n * - Renders an `<mj-isa-related-card>` for each root-level related entity\n * (grandchildren render as nested sub-cards inside their parent card)\n *\n * @example\n * ```html\n * <mj-isa-related-panel\n * [Record]=\"record\"\n * (Navigate)=\"OnNavigate($event)\">\n * </mj-isa-related-panel>\n * ```\n */\n@Component({\n standalone: false,\n selector: 'mj-isa-related-panel',\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n templateUrl: './isa-related-panel.component.html',\n styleUrls: ['./isa-related-panel.component.css']\n})\nexport class MjIsaRelatedPanelComponent extends BaseAngularComponent implements OnChanges, OnInit, OnDestroy {\n private cdr = inject(ChangeDetectorRef);\n private recordRefresh = inject(FormRecordRefreshCoordinator, { optional: true });\n private destroy$ = new Subject<void>();\n\n /** The entity record currently displayed in the form */\n @Input() Record: BaseEntity | null = null;\n\n /** Whether the form is in edit mode (panel hides during edit) */\n @Input() EditMode = false;\n\n /** Whether the panel is collapsed (icon-only strip in full-width mode) */\n @Input() Collapsed = false;\n\n /** Emitted for navigation to a related record */\n @Output() Navigate = new EventEmitter<FormNavigationEvent>();\n\n /** Root-level related IS-A entities to display cards for (children nested inside) */\n RelatedItems: IsaRelatedItem[] = [];\n\n /** Whether there are any related IS-A items to show */\n get HasItems(): boolean {\n return this.RelatedItems.length > 0;\n }\n\n /** The current record's display name (to suppress in child cards when identical) */\n get CurrentRecordName(): string {\n if (!this.Record) return '';\n const name = this.Record.GetRecordName();\n return name ? String(name) : '';\n }\n\n /** The shared primary key for all IS-A related records */\n get SharedPrimaryKey(): CompositeKey | null {\n return this.Record?.PrimaryKey ?? null;\n }\n\n ngOnInit(): void {\n this.recordRefresh?.Refreshed$.pipe(takeUntil(this.destroy$)).subscribe(() => {\n void this.DiscoverRelatedItems();\n });\n }\n\n ngOnDestroy(): void {\n this.destroy$.next();\n this.destroy$.complete();\n }\n\n ngOnChanges(changes: SimpleChanges): void {\n if (changes['Record']) {\n this.DiscoverRelatedItems();\n return;\n }\n\n // Leaving edit mode is the OTHER moment this answer can change, and until now nothing\n // re-asked. A save can ATTACH a subtype that did not exist when this panel last looked —\n // IS-A writes parent and child in one transaction — and the form deliberately keeps the\n // SAME record object across that save (EntityFormHostComponent's PrimaryKey setter skips\n // the reload when the incoming key is just the now-saved PK), so `changes['Record']` never\n // fires; and `FormRecordRefreshCoordinator.Notify()` is reached only from the Refresh\n // button. The result was a panel that stayed empty on a record that plainly had a subtype\n // until the user pressed Refresh.\n //\n // Re-discovering here is close to free on the common path: for a disjoint hierarchy\n // DiscoverISADescendants walks the in-memory ISAChild chain and issues no query at all.\n // An overlapping parent (AllowMultipleSubtypes) does load its child entities, so that\n // configuration pays one extra discovery per edit session.\n if (changes['EditMode'] && changes['EditMode'].previousValue === true && !this.EditMode) {\n this.DiscoverRelatedItems();\n }\n }\n\n /**\n * Discover IS-A related entities by examining the current record's\n * entity hierarchy. Finds siblings (other children of the same parent)\n * and all descendants (children, grandchildren, etc.) as a tree.\n */\n private async DiscoverRelatedItems(): Promise<void> {\n this.RelatedItems = [];\n\n if (!this.Record) return;\n\n const entityInfo = this.Record.EntityInfo;\n if (!entityInfo) return;\n\n // Case 1: Current entity is a child type — find siblings via parent\n if (entityInfo.IsChildType && entityInfo.ParentEntityInfo) {\n this.DiscoverSiblingsFromParent(entityInfo);\n }\n\n // Case 2: Current entity is a parent type — discover all descendants as tree\n if (entityInfo.IsParentType) {\n await this.DiscoverDescendants();\n }\n\n this.cdr.markForCheck();\n }\n\n /**\n * When viewing a child entity (e.g., Member), find sibling entities\n * (e.g., Speaker) that also have records with the same parent PK.\n * Uses the parent's ISAChildren if the parent uses overlapping subtypes.\n */\n private DiscoverSiblingsFromParent(entityInfo: EntityInfo): void {\n const parent = this.Record?.ISAParent;\n if (!parent) return;\n\n const parentInfo = entityInfo.ParentEntityInfo!;\n\n if (parentInfo.AllowMultipleSubtypes) {\n const children = parent.ISAChildren;\n if (children) {\n for (const child of children) {\n if (child.entityName !== entityInfo.Name) {\n this.RelatedItems.push({\n EntityName: child.entityName,\n Relationship: 'sibling',\n Depth: 0,\n Children: []\n });\n }\n }\n }\n }\n }\n\n /**\n * Recursively discover all IS-A descendants and build a tree structure.\n * Root-level children appear as top-level cards; grandchildren nest inside.\n */\n private async DiscoverDescendants(): Promise<void> {\n if (!this.Record) return;\n\n const descendants = await DiscoverISADescendants(this.Record, this.ProviderToUse);\n const tree = BuildDescendantTree(descendants);\n this.RelatedItems.push(...tree);\n }\n\n /** Relay navigation events from child cards */\n OnCardNavigate(event: EntityHierarchyNavigationEvent): void {\n this.Navigate.emit(event);\n }\n}\n","<!-- ISA Related Panel: side panel container for all related IS-A entity cards -->\n@if (HasItems && !EditMode) {\n <div class=\"mj-isa-panel\" [class.mj-isa-panel--collapsed]=\"Collapsed\">\n\n <!-- Collapsed state: icon-only strip -->\n @if (Collapsed) {\n <div class=\"mj-isa-panel__collapsed-strip\">\n @for (item of RelatedItems; track item.EntityName) {\n <div class=\"mj-isa-panel__collapsed-icon\" [title]=\"item.EntityName\">\n <i class=\"fa-solid fa-link\"></i>\n </div>\n }\n </div>\n } @else {\n <!-- Expanded state: full card list -->\n <div class=\"mj-isa-panel__cards\">\n @for (item of RelatedItems; track item.EntityName) {\n <mj-isa-related-card\n [EntityName]=\"item.EntityName\"\n [PrimaryKey]=\"SharedPrimaryKey\"\n [CurrentRecordName]=\"CurrentRecordName\"\n [Relationship]=\"item.Relationship\"\n [Depth]=\"item.Depth\"\n [Children]=\"item.Children\"\n (Navigate)=\"OnCardNavigate($event)\">\n </mj-isa-related-card>\n }\n </div>\n }\n </div>\n}\n"]}
|
|
1
|
+
{"version":3,"file":"isa-related-panel.component.js","sourceRoot":"","sources":["../../../src/lib/isa-related-panel/isa-related-panel.component.ts","../../../src/lib/isa-related-panel/isa-related-panel.component.html"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,YAAY,EACtC,uBAAuB,EAAE,iBAAiB,EAAE,MAAM,EACL,iBAAiB,EAC/D,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAErE,OAAO,EAAE,sBAAsB,EAAE,mBAAmB,EAAkB,MAAM,uBAAuB,CAAC;AACpG,OAAO,EAAE,4BAA4B,EAAE,MAAM,oCAAoC,CAAC;;;;;ICHxE,8BAAoE;IAClE,uBAAgC;IAClC,iBAAM;;;IAFoC,0CAAyB;;;IAFvE,8BAA2C;IACzC,yHAIC;IACH,iBAAM;;;IALJ,cAIC;IAJD,kCAIC;;;;IAMC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C;IAED,+CAA+C;IAC/C,cAAc,CAAC,KAAqC;QAClD,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC5B,CAAC;qRA7IU,0BAA0B,yBAA1B,0BAA0B;6DAA1B,0BAA0B;YC3CvC,4FAA6B;;YAA7B,wDA6BC;;;iFDcY,0BAA0B;cARtC,SAAS;6BACI,KAAK,YACP,sBAAsB,mBACf,uBAAuB,CAAC,MAAM,iBAChC,iBAAiB,CAAC,IAAI;;kBAUpC,KAAK;;kBAGL,KAAK;;kBAGL,KAAK;;kBAGL,MAAM;;kFAfI,0BAA0B","sourcesContent":["import {\n Component, Input, Output, EventEmitter,\n ChangeDetectionStrategy, ChangeDetectorRef, inject,\n OnChanges, OnInit, OnDestroy, SimpleChanges, ViewEncapsulation\n} from '@angular/core';\nimport { Subject } from 'rxjs';\nimport { takeUntil } from 'rxjs/operators';\nimport { BaseEntity, EntityInfo, CompositeKey } from '@memberjunction/core';\nimport { BaseAngularComponent } from '@memberjunction/ng-base-types';\nimport { FormNavigationEvent, EntityHierarchyNavigationEvent } from '../types/navigation-events';\nimport { DiscoverISADescendants, BuildDescendantTree, IsaRelatedItem } from './isa-hierarchy-utils';\nimport { FormRecordRefreshCoordinator } from '../form-record-refresh.coordinator';\n\n/**\n * Container panel that discovers and displays IS-A related entity records\n * (siblings and children) for the current form's record.\n *\n * **Placement**: Sits to the right of the main form panels inside\n * `<mj-record-form-container>`. Hidden when in edit mode or when\n * no related IS-A records exist.\n *\n * **Data flow**:\n * - Receives the current `Record` (BaseEntity) as input\n * - Inspects `EntityInfo.ParentEntityInfo` and `ISAChildren` to discover related records\n * - Builds a tree structure for nested sub-card rendering\n * - Renders an `<mj-isa-related-card>` for each root-level related entity\n * (grandchildren render as nested sub-cards inside their parent card)\n *\n * @example\n * ```html\n * <mj-isa-related-panel\n * [Record]=\"record\"\n * (Navigate)=\"OnNavigate($event)\">\n * </mj-isa-related-panel>\n * ```\n */\n@Component({\n standalone: false,\n selector: 'mj-isa-related-panel',\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n templateUrl: './isa-related-panel.component.html',\n styleUrls: ['./isa-related-panel.component.css']\n})\nexport class MjIsaRelatedPanelComponent extends BaseAngularComponent implements OnChanges, OnInit, OnDestroy {\n private cdr = inject(ChangeDetectorRef);\n private recordRefresh = inject(FormRecordRefreshCoordinator, { optional: true });\n private destroy$ = new Subject<void>();\n\n /** The entity record currently displayed in the form */\n @Input() Record: BaseEntity | null = null;\n\n /** Whether the form is in edit mode (panel hides during edit) */\n @Input() EditMode = false;\n\n /** Whether the panel is collapsed (icon-only strip in full-width mode) */\n @Input() Collapsed = false;\n\n /** Emitted for navigation to a related record */\n @Output() Navigate = new EventEmitter<FormNavigationEvent>();\n\n /** Root-level related IS-A entities to display cards for (children nested inside) */\n RelatedItems: IsaRelatedItem[] = [];\n\n /** Whether there are any related IS-A items to show */\n get HasItems(): boolean {\n return this.RelatedItems.length > 0;\n }\n\n /** The current record's display name (to suppress in child cards when identical) */\n get CurrentRecordName(): string {\n if (!this.Record) return '';\n const name = this.Record.GetRecordName();\n return name ? String(name) : '';\n }\n\n /** The shared primary key for all IS-A related records */\n get SharedPrimaryKey(): CompositeKey | null {\n return this.Record?.PrimaryKey ?? null;\n }\n\n ngOnInit(): void {\n this.recordRefresh?.Refreshed$.pipe(takeUntil(this.destroy$)).subscribe(() => {\n void this.discoverRelatedItems();\n });\n }\n\n ngOnDestroy(): void {\n this.destroy$.next();\n this.destroy$.complete();\n }\n\n ngOnChanges(changes: SimpleChanges): void {\n if (changes['Record']) {\n this.discoverRelatedItems();\n return;\n }\n\n // Leaving edit mode is the OTHER moment this answer can change, and until now nothing\n // re-asked. A save can ATTACH a subtype that did not exist when this panel last looked —\n // IS-A writes parent and child in one transaction — and the form deliberately keeps the\n // SAME record object across that save (EntityFormHostComponent's PrimaryKey setter skips\n // the reload when the incoming key is just the now-saved PK), so `changes['Record']` never\n // fires; and `FormRecordRefreshCoordinator.Notify()` is reached only from the Refresh\n // button. The result was a panel that stayed empty on a record that plainly had a subtype\n // until the user pressed Refresh.\n //\n // Re-discovering here is close to free on the common path: for a disjoint hierarchy\n // DiscoverISADescendants walks the in-memory ISAChild chain and issues no query at all.\n // An overlapping parent (AllowMultipleSubtypes) does load its child entities, so that\n // configuration pays one extra discovery per edit session.\n if (changes['EditMode'] && changes['EditMode'].previousValue === true && !this.EditMode) {\n this.discoverRelatedItems();\n }\n }\n\n /**\n * Discover IS-A related entities by examining the current record's\n * entity hierarchy. Finds siblings (other children of the same parent)\n * and all descendants (children, grandchildren, etc.) as a tree.\n */\n private async discoverRelatedItems(): Promise<void> {\n this.RelatedItems = [];\n\n if (!this.Record) return;\n\n const entityInfo = this.Record.EntityInfo;\n if (!entityInfo) return;\n\n // Case 1: Current entity is a child type — find siblings via parent\n if (entityInfo.IsChildType && entityInfo.ParentEntityInfo) {\n this.discoverSiblingsFromParent(entityInfo);\n }\n\n // Case 2: Current entity is a parent type — discover all descendants as tree\n if (entityInfo.IsParentType) {\n await this.discoverDescendants();\n }\n\n this.cdr.markForCheck();\n }\n\n /**\n * When viewing a child entity (e.g., Member), find sibling entities\n * (e.g., Speaker) that also have records with the same parent PK.\n * Uses the parent's ISAChildren if the parent uses overlapping subtypes.\n */\n private discoverSiblingsFromParent(entityInfo: EntityInfo): void {\n const parent = this.Record?.ISAParent;\n if (!parent) return;\n\n const parentInfo = entityInfo.ParentEntityInfo!;\n\n if (parentInfo.AllowMultipleSubtypes) {\n const children = parent.ISAChildren;\n if (children) {\n for (const child of children) {\n if (child.entityName !== entityInfo.Name) {\n this.RelatedItems.push({\n EntityName: child.entityName,\n Relationship: 'sibling',\n Depth: 0,\n Children: []\n });\n }\n }\n }\n }\n }\n\n /**\n * Recursively discover all IS-A descendants and build a tree structure.\n * Root-level children appear as top-level cards; grandchildren nest inside.\n */\n private async discoverDescendants(): Promise<void> {\n if (!this.Record) return;\n\n const descendants = await DiscoverISADescendants(this.Record, this.ProviderToUse);\n const tree = BuildDescendantTree(descendants);\n this.RelatedItems.push(...tree);\n }\n\n /** Relay navigation events from child cards */\n OnCardNavigate(event: EntityHierarchyNavigationEvent): void {\n this.Navigate.emit(event);\n }\n}\n","<!-- ISA Related Panel: side panel container for all related IS-A entity cards -->\n@if (HasItems && !EditMode) {\n <div class=\"mj-isa-panel\" [class.mj-isa-panel--collapsed]=\"Collapsed\">\n\n <!-- Collapsed state: icon-only strip -->\n @if (Collapsed) {\n <div class=\"mj-isa-panel__collapsed-strip\">\n @for (item of RelatedItems; track item.EntityName) {\n <div class=\"mj-isa-panel__collapsed-icon\" [title]=\"item.EntityName\">\n <i class=\"fa-solid fa-link\"></i>\n </div>\n }\n </div>\n } @else {\n <!-- Expanded state: full card list -->\n <div class=\"mj-isa-panel__cards\">\n @for (item of RelatedItems; track item.EntityName) {\n <mj-isa-related-card\n [EntityName]=\"item.EntityName\"\n [PrimaryKey]=\"SharedPrimaryKey\"\n [CurrentRecordName]=\"CurrentRecordName\"\n [Relationship]=\"item.Relationship\"\n [Depth]=\"item.Depth\"\n [Children]=\"item.Children\"\n (Navigate)=\"OnCardNavigate($event)\">\n </mj-isa-related-card>\n }\n </div>\n }\n </div>\n}\n"]}
|
|
@@ -30,6 +30,8 @@ export declare class MjFormSlideInComponent extends BaseFormOverlay implements O
|
|
|
30
30
|
private widthEntity;
|
|
31
31
|
ngOnInit(): void;
|
|
32
32
|
/** Persist the user's resize, scoped per-entity (cross-device via User Settings). */
|
|
33
|
+
OnWidthChanged(width: number): void;
|
|
34
|
+
/** @deprecated Use {@link OnWidthChanged}. */
|
|
33
35
|
onWidthChanged(width: number): void;
|
|
34
36
|
private widthKey;
|
|
35
37
|
static ɵfac: i0.ɵɵFactoryDeclaration<MjFormSlideInComponent, never>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"form-slide-in.component.d.ts","sourceRoot":"","sources":["../../../src/lib/overlays/form-slide-in.component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,MAAM,EAAE,MAAM,eAAe,CAAC;AAMzD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;;AAGtD;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAOa,sBAAuB,SAAQ,eAAgB,YAAW,MAAM;IAC3E,+EAA+E;IACtE,OAAO,SAAO;IACvB,2CAA2C;IAClC,SAAS,UAAQ;IAE1B,4EAA4E;IAC5E,cAAuB,YAAY,2DAAkC;IAErE,mEAAmE;IACnE,OAAO,CAAC,WAAW,CAAuB;IAE1C,QAAQ,IAAI,IAAI;IAWhB,qFAAqF;IACrF,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAOnC,OAAO,CAAC,QAAQ;
|
|
1
|
+
{"version":3,"file":"form-slide-in.component.d.ts","sourceRoot":"","sources":["../../../src/lib/overlays/form-slide-in.component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,MAAM,EAAE,MAAM,eAAe,CAAC;AAMzD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;;AAGtD;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAOa,sBAAuB,SAAQ,eAAgB,YAAW,MAAM;IAC3E,+EAA+E;IACtE,OAAO,SAAO;IACvB,2CAA2C;IAClC,SAAS,UAAQ;IAE1B,4EAA4E;IAC5E,cAAuB,YAAY,2DAAkC;IAErE,mEAAmE;IACnE,OAAO,CAAC,WAAW,CAAuB;IAE1C,QAAQ,IAAI,IAAI;IAWhB,qFAAqF;IACrF,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAOnC,8CAA8C;IAC9C,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAInC,OAAO,CAAC,QAAQ;yCApCL,sBAAsB;2CAAtB,sBAAsB;CAuClC"}
|
|
@@ -67,12 +67,16 @@ export class MjFormSlideInComponent extends BaseFormOverlay {
|
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
/** Persist the user's resize, scoped per-entity (cross-device via User Settings). */
|
|
70
|
-
|
|
70
|
+
OnWidthChanged(width) {
|
|
71
71
|
this.WidthPx = width;
|
|
72
72
|
if (this.widthEntity) {
|
|
73
73
|
UserInfoEngine.Instance.SetSettingDebounced(this.widthKey(this.widthEntity), String(width));
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
|
+
/** @deprecated Use {@link OnWidthChanged}. */
|
|
77
|
+
onWidthChanged(width) {
|
|
78
|
+
return this.OnWidthChanged(width);
|
|
79
|
+
}
|
|
76
80
|
widthKey(entity) {
|
|
77
81
|
return `mj.formSlideIn.width.${entity.toLowerCase()}`;
|
|
78
82
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"form-slide-in.component.js","sourceRoot":"","sources":["../../../src/lib/overlays/form-slide-in.component.ts","../../../src/lib/overlays/form-slide-in.component.html"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAU,MAAM,eAAe,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAC5F,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAE/D,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;;;;;IC2B1D,AADF,8BAAqC,gBAC4C;IAAxB,0LAAS,oBAAa,KAAC;IAAC,YAAoB;IAAA,iBAAS;IAC5G,iCAA0D;IAArB,0LAAS,iBAAU,KAAC;IAAC,YAAsB;IAClF,AADkF,iBAAS,EACrF;;;IAF+B,cAAmB;IAAnB,wCAAmB;IAAyB,cAAoB;IAApB,2CAAoB;IAClF,cAAmB;IAAnB,wCAAmB;IAAsB,cAAsB;IAAtB,6CAAsB;;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in.component.js","sourceRoot":"","sources":["../../../src/lib/overlays/form-slide-in.component.ts","../../../src/lib/overlays/form-slide-in.component.html"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAU,MAAM,eAAe,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAC5F,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAE/D,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;;;;;IC2B1D,AADF,8BAAqC,gBAC4C;IAAxB,0LAAS,oBAAa,KAAC;IAAC,YAAoB;IAAA,iBAAS;IAC5G,iCAA0D;IAArB,0LAAS,iBAAU,KAAC;IAAC,YAAsB;IAClF,AADkF,iBAAS,EACrF;;;IAF+B,cAAmB;IAAnB,wCAAmB;IAAyB,cAAoB;IAApB,2CAAoB;IAClF,cAAmB;IAAnB,wCAAmB;IAAsB,cAAsB;IAAtB,6CAAsB;;AD1BxF;;;;;;;;;;;;;;;;;GAiBG;AAQH,MAAM,OAAO,sBAAuB,SAAQ,eAAe;IACzD,+EAA+E;IACtE,OAAO,GAAG,GAAG,CAAC;IACvB,2CAA2C;IAClC,SAAS,GAAG,IAAI,CAAC;IAE1B,4EAA4E;IAC5E,IAAuB,YAAY,KAAK,OAAO,mBAAmB,CAAC,CAAC,CAAC;IAErE,mEAAmE;IAC3D,WAAW,GAAkB,IAAI,CAAC;IAE1C,QAAQ;QACN,uEAAuE;QACvE,6DAA6D;QAC7D,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,MAAM,EAAE,UAAU,EAAE,IAAI,IAAI,IAAI,CAAC;QAC5E,IAAI,IAAI,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BAAsB,IAAC;YAExC,AADE,iBAAsB,EAClB;YAEN,wFAAkB;YAOtB,AADE,iBAAM,EACS;;YAlCf,AADA,AADA,AADA,qCAAmB,6BACK,4BACD,wBACJ;YAOb,eAAyB;YAOzB,AADA,AADA,AADA,AADA,AADA,AADA,AADA,2CAAyB,uCACU,sBAClB,wCACkB,gCACR,0BACN,+BACK,0BACL;YAazB,eAKC;YALD,yCAKC;4BDPO,YAAY,EAAE,eAAe,gCAAE,qBAAqB,EAAE,iBAAiB;;iFAItE,sBAAsB;cAPlC,SAAS;6BACI,IAAI,YACN,kBAAkB,WACnB,CAAC,YAAY,EAAE,eAAe,EAAE,qBAAqB,EAAE,iBAAiB,CAAC;;kBAMjF,KAAK;;kBAEL,KAAK;;kFAJK,sBAAsB","sourcesContent":["import { Component, Input, OnInit } from '@angular/core';\nimport { CommonModule } from '@angular/common';\nimport { MjSlidePanelComponent, MJButtonDirective } from '@memberjunction/ng-ui-components';\nimport { UserInfoEngine } from '@memberjunction/core-entities';\n\nimport { BaseFormsModule } from '../../module';\nimport { BaseFormOverlay } from './base-form-overlay';\nimport { SLIDEIN_FORM_CONFIG } from '../types/entity-form-config';\n\n/**\n * Opens any MemberJunction entity form inside a right-edge slide-in panel.\n *\n * Wraps {@link MjEntityFormHostComponent} in `<mj-slide-panel>` (resizable) with\n * a sticky Save/Cancel footer. Defaults to {@link SLIDEIN_FORM_CONFIG} (no in-form\n * toolbar, related grids hidden, full-width body, in-form links inert).\n *\n * Standalone — import it directly:\n * ```typescript\n * import { MjFormSlideInComponent } from '@memberjunction/ng-base-forms';\n * ```\n *\n * @example Declarative\n * ```html\n * <mj-form-slide-in [EntityName]=\"'MJ: Credentials'\" [Record]=\"cred\"\n * [(Visible)]=\"open\" (Saved)=\"refresh()\"></mj-form-slide-in>\n * ```\n */\n@Component({\n standalone: true,\n selector: 'mj-form-slide-in',\n imports: [CommonModule, BaseFormsModule, MjSlidePanelComponent, MJButtonDirective],\n templateUrl: './form-slide-in.component.html',\n styleUrls: ['./form-slide-in.component.css'],\n})\nexport class MjFormSlideInComponent extends BaseFormOverlay implements OnInit {\n /** Initial panel width in px (resizable by the user; persisted per-entity). */\n @Input() WidthPx = 720;\n /** Whether the panel is user-resizable. */\n @Input() Resizable = true;\n\n /** Form config. Defaults to the slide-in preset; consumers can override. */\n protected override get PresetConfig() { return SLIDEIN_FORM_CONFIG; }\n\n /** Entity used to scope the persisted width (resolved on init). */\n private widthEntity: string | null = null;\n\n ngOnInit(): void {\n // Resolve the entity up-front so we can restore the user's saved width\n // before the panel animates in (avoids a mid-render resize).\n this.widthEntity = this.EntityName ?? this.Record?.EntityInfo?.Name ?? null;\n if (this.widthEntity) {\n const saved = UserInfoEngine.Instance.GetSetting(this.widthKey(this.widthEntity));\n const px = saved ? parseInt(saved, 10) : 0;\n if (px > 0) this.WidthPx = px;\n }\n }\n\n /** Persist the user's resize, scoped per-entity (cross-device via User Settings). */\n OnWidthChanged(width: number): void {\n this.WidthPx = width;\n if (this.widthEntity) {\n UserInfoEngine.Instance.SetSettingDebounced(this.widthKey(this.widthEntity), String(width));\n }\n }\n\n /** @deprecated Use {@link OnWidthChanged}. */\n onWidthChanged(width: number): void {\n return this.OnWidthChanged(width);\n }\n\n private widthKey(entity: string): string {\n return `mj.formSlideIn.width.${entity.toLowerCase()}`;\n }\n}\n","<mj-slide-panel\n Mode=\"slide\"\n [Visible]=\"Visible\"\n [Title]=\"effectiveTitle\"\n [Resizable]=\"Resizable\"\n [WidthPx]=\"WidthPx\"\n (WidthChanged)=\"onWidthChanged($event)\"\n (Closed)=\"onCancel()\">\n\n <div class=\"mj-form-slide-in-layout\">\n <div class=\"mj-form-slide-in-body\">\n <mj-entity-form-host #host\n [EntityName]=\"EntityName\"\n [PrimaryKey]=\"effectivePrimaryKey!\"\n [Record]=\"Record\"\n [NewRecordValues]=\"NewRecordValues\"\n [SectionName]=\"SectionName\"\n [EditMode]=\"EditMode\"\n [Config]=\"EffectiveConfig\"\n [Provider]=\"Provider\"\n (Saved)=\"onHostSaved($event)\"\n (Dismissed)=\"onHostDismissed()\"\n (FormCreated)=\"onFormCreated($event)\"\n (Navigate)=\"Navigate.emit($event)\"\n (Notification)=\"Notification.emit($event)\"\n (RecordDeleted)=\"RecordDeleted.emit($event)\"\n (RecordSaveFailed)=\"RecordSaveFailed.emit($event)\"\n (ValidationFailed)=\"ValidationFailed.emit($event)\"\n (LoadError)=\"LoadError.emit($event)\">\n </mj-entity-form-host>\n </div>\n\n @if (ShowFooter) {\n <div class=\"mj-form-slide-in-footer\">\n <button mjButton variant=\"primary\" [disabled]=\"saving\" (click)=\"onSaveClick()\">{{ SaveButtonText }}</button>\n <button mjButton [disabled]=\"saving\" (click)=\"onCancel()\">{{ CancelButtonText }}</button>\n </div>\n }\n </div>\n</mj-slide-panel>\n"]}
|