@memberjunction/ng-base-forms 6.2.0-edge.1 → 6.2.0-edge.3
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/apply/form-placement-dialog.component.d.ts +266 -0
- package/dist/lib/apply/form-placement-dialog.component.d.ts.map +1 -0
- package/dist/lib/apply/form-placement-dialog.component.js +1522 -0
- package/dist/lib/apply/form-placement-dialog.component.js.map +1 -0
- package/dist/lib/apply/form-placement-order.d.ts +37 -0
- package/dist/lib/apply/form-placement-order.d.ts.map +1 -0
- package/dist/lib/apply/form-placement-order.js +111 -0
- package/dist/lib/apply/form-placement-order.js.map +1 -0
- package/dist/lib/apply/form-placement-preview.component.d.ts +112 -0
- package/dist/lib/apply/form-placement-preview.component.d.ts.map +1 -0
- package/dist/lib/apply/form-placement-preview.component.js +346 -0
- package/dist/lib/apply/form-placement-preview.component.js.map +1 -0
- package/dist/lib/apply/form-placement-text.d.ts +61 -0
- package/dist/lib/apply/form-placement-text.d.ts.map +1 -0
- package/dist/lib/apply/form-placement-text.js +279 -0
- package/dist/lib/apply/form-placement-text.js.map +1 -0
- package/dist/lib/apply/form-placement.d.ts +320 -0
- package/dist/lib/apply/form-placement.d.ts.map +1 -0
- package/dist/lib/apply/form-placement.js +432 -0
- package/dist/lib/apply/form-placement.js.map +1 -0
- package/dist/lib/apply/form-slot-probe.service.d.ts +121 -0
- package/dist/lib/apply/form-slot-probe.service.d.ts.map +1 -0
- package/dist/lib/apply/form-slot-probe.service.js +264 -0
- package/dist/lib/apply/form-slot-probe.service.js.map +1 -0
- package/dist/lib/base-form-component-internals.d.ts +11 -0
- package/dist/lib/base-form-component-internals.d.ts.map +1 -0
- package/dist/lib/base-form-component-internals.js +33 -0
- package/dist/lib/base-form-component-internals.js.map +1 -0
- package/dist/lib/base-form-component.d.ts +166 -1
- package/dist/lib/base-form-component.d.ts.map +1 -1
- package/dist/lib/base-form-component.js +296 -20
- package/dist/lib/base-form-component.js.map +1 -1
- package/dist/lib/chrome/form-chrome.d.ts +78 -0
- package/dist/lib/chrome/form-chrome.d.ts.map +1 -1
- package/dist/lib/chrome/form-chrome.js +128 -2
- package/dist/lib/chrome/form-chrome.js.map +1 -1
- package/dist/lib/chrome/form-composition-registry.d.ts +34 -0
- package/dist/lib/chrome/form-composition-registry.d.ts.map +1 -0
- package/dist/lib/chrome/form-composition-registry.js +56 -0
- package/dist/lib/chrome/form-composition-registry.js.map +1 -0
- package/dist/lib/chrome/form-composition-snapshot.d.ts +151 -0
- package/dist/lib/chrome/form-composition-snapshot.d.ts.map +1 -0
- package/dist/lib/chrome/form-composition-snapshot.js +137 -0
- package/dist/lib/chrome/form-composition-snapshot.js.map +1 -0
- package/dist/lib/chrome/resolve-form-chrome.d.ts +15 -0
- package/dist/lib/chrome/resolve-form-chrome.d.ts.map +1 -1
- package/dist/lib/chrome/resolve-form-chrome.js +31 -2
- package/dist/lib/chrome/resolve-form-chrome.js.map +1 -1
- package/dist/lib/container/record-form-container.component.d.ts +261 -5
- package/dist/lib/container/record-form-container.component.d.ts.map +1 -1
- package/dist/lib/container/record-form-container.component.js +1180 -371
- package/dist/lib/container/record-form-container.component.js.map +1 -1
- package/dist/lib/duplicate-entry-check/duplicate-entry-check.d.ts +150 -0
- package/dist/lib/duplicate-entry-check/duplicate-entry-check.d.ts.map +1 -0
- package/dist/lib/duplicate-entry-check/duplicate-entry-check.js +263 -0
- package/dist/lib/duplicate-entry-check/duplicate-entry-check.js.map +1 -0
- package/dist/lib/field/form-field.component.d.ts +22 -0
- package/dist/lib/field/form-field.component.d.ts.map +1 -1
- package/dist/lib/field/form-field.component.js +51 -6
- package/dist/lib/field/form-field.component.js.map +1 -1
- package/dist/lib/form-field-edit.coordinator.d.ts +25 -0
- package/dist/lib/form-field-edit.coordinator.d.ts.map +1 -0
- package/dist/lib/form-field-edit.coordinator.js +27 -0
- package/dist/lib/form-field-edit.coordinator.js.map +1 -0
- package/dist/lib/form-state.service.d.ts +5 -0
- package/dist/lib/form-state.service.d.ts.map +1 -1
- package/dist/lib/form-state.service.js +6 -1
- package/dist/lib/form-state.service.js.map +1 -1
- package/dist/lib/host/entity-form-host.component.d.ts +16 -1
- package/dist/lib/host/entity-form-host.component.d.ts.map +1 -1
- package/dist/lib/host/entity-form-host.component.js +27 -6
- package/dist/lib/host/entity-form-host.component.js.map +1 -1
- package/dist/lib/interactive-form/form-panel-host-props.builder.d.ts +24 -0
- package/dist/lib/interactive-form/form-panel-host-props.builder.d.ts.map +1 -0
- package/dist/lib/interactive-form/form-panel-host-props.builder.js +99 -0
- package/dist/lib/interactive-form/form-panel-host-props.builder.js.map +1 -0
- package/dist/lib/interactive-form/interactive-form-panel.component.d.ts +109 -0
- package/dist/lib/interactive-form/interactive-form-panel.component.d.ts.map +1 -0
- package/dist/lib/interactive-form/interactive-form-panel.component.js +424 -0
- package/dist/lib/interactive-form/interactive-form-panel.component.js.map +1 -0
- package/dist/lib/interactive-form/interactive-form.component.d.ts +2 -0
- package/dist/lib/interactive-form/interactive-form.component.d.ts.map +1 -1
- package/dist/lib/interactive-form/interactive-form.component.js +4 -5
- package/dist/lib/interactive-form/interactive-form.component.js.map +1 -1
- package/dist/lib/panel/collapsible-panel.component.d.ts +69 -1
- package/dist/lib/panel/collapsible-panel.component.d.ts.map +1 -1
- package/dist/lib/panel/collapsible-panel.component.js +148 -12
- package/dist/lib/panel/collapsible-panel.component.js.map +1 -1
- package/dist/lib/panel-manager/form-audience.d.ts +46 -0
- package/dist/lib/panel-manager/form-audience.d.ts.map +1 -0
- package/dist/lib/panel-manager/form-audience.js +34 -0
- package/dist/lib/panel-manager/form-audience.js.map +1 -0
- package/dist/lib/panel-manager/form-panel-admin.service.d.ts +150 -0
- package/dist/lib/panel-manager/form-panel-admin.service.d.ts.map +1 -0
- package/dist/lib/panel-manager/form-panel-admin.service.js +433 -0
- package/dist/lib/panel-manager/form-panel-admin.service.js.map +1 -0
- package/dist/lib/panel-manager/form-panel-inventory.d.ts +255 -0
- package/dist/lib/panel-manager/form-panel-inventory.d.ts.map +1 -0
- package/dist/lib/panel-manager/form-panel-inventory.js +293 -0
- package/dist/lib/panel-manager/form-panel-inventory.js.map +1 -0
- package/dist/lib/panel-manager/panel-manager.component.d.ts +232 -0
- package/dist/lib/panel-manager/panel-manager.component.d.ts.map +1 -0
- package/dist/lib/panel-manager/panel-manager.component.js +1112 -0
- package/dist/lib/panel-manager/panel-manager.component.js.map +1 -0
- package/dist/lib/panel-slot/base-contribution-panel.d.ts +40 -0
- package/dist/lib/panel-slot/base-contribution-panel.d.ts.map +1 -0
- package/dist/lib/panel-slot/base-contribution-panel.js +55 -0
- package/dist/lib/panel-slot/base-contribution-panel.js.map +1 -0
- package/dist/lib/panel-slot/base-form-panel.d.ts +116 -8
- package/dist/lib/panel-slot/base-form-panel.d.ts.map +1 -1
- package/dist/lib/panel-slot/base-form-panel.js +76 -5
- package/dist/lib/panel-slot/base-form-panel.js.map +1 -1
- package/dist/lib/panel-slot/collect-form-contribution-registrations.d.ts +29 -0
- package/dist/lib/panel-slot/collect-form-contribution-registrations.d.ts.map +1 -0
- package/dist/lib/panel-slot/collect-form-contribution-registrations.js +214 -0
- package/dist/lib/panel-slot/collect-form-contribution-registrations.js.map +1 -0
- package/dist/lib/panel-slot/collect-form-panel-registrations.d.ts +6 -3
- package/dist/lib/panel-slot/collect-form-panel-registrations.d.ts.map +1 -1
- package/dist/lib/panel-slot/collect-form-panel-registrations.js +8 -14
- package/dist/lib/panel-slot/collect-form-panel-registrations.js.map +1 -1
- package/dist/lib/panel-slot/form-contribution.d.ts +170 -7
- package/dist/lib/panel-slot/form-contribution.d.ts.map +1 -1
- package/dist/lib/panel-slot/form-contribution.js +242 -64
- package/dist/lib/panel-slot/form-contribution.js.map +1 -1
- package/dist/lib/panel-slot/form-contributions.component.d.ts +16 -5
- package/dist/lib/panel-slot/form-contributions.component.d.ts.map +1 -1
- package/dist/lib/panel-slot/form-contributions.component.js +43 -7
- package/dist/lib/panel-slot/form-contributions.component.js.map +1 -1
- package/dist/lib/panel-slot/form-field-panel-slot.component.d.ts +66 -0
- package/dist/lib/panel-slot/form-field-panel-slot.component.d.ts.map +1 -0
- package/dist/lib/panel-slot/form-field-panel-slot.component.js +190 -0
- package/dist/lib/panel-slot/form-field-panel-slot.component.js.map +1 -0
- package/dist/lib/panel-slot/form-panel-slot.component.d.ts +52 -16
- package/dist/lib/panel-slot/form-panel-slot.component.d.ts.map +1 -1
- package/dist/lib/panel-slot/form-panel-slot.component.js +190 -66
- package/dist/lib/panel-slot/form-panel-slot.component.js.map +1 -1
- package/dist/lib/panel-slot/form-slot-coordinator.service.d.ts +11 -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 +17 -0
- package/dist/lib/panel-slot/form-slot-coordinator.service.js.map +1 -1
- package/dist/lib/panel-slot/merge-panel-validation.d.ts +7 -0
- package/dist/lib/panel-slot/merge-panel-validation.d.ts.map +1 -0
- package/dist/lib/panel-slot/merge-panel-validation.js +16 -0
- package/dist/lib/panel-slot/merge-panel-validation.js.map +1 -0
- package/dist/lib/panel-slot/mount-form-contribution.d.ts +15 -0
- package/dist/lib/panel-slot/mount-form-contribution.d.ts.map +1 -0
- package/dist/lib/panel-slot/mount-form-contribution.js +37 -0
- package/dist/lib/panel-slot/mount-form-contribution.js.map +1 -0
- package/dist/lib/panel-slot/panel-hides.d.ts +35 -0
- package/dist/lib/panel-slot/panel-hides.d.ts.map +1 -0
- package/dist/lib/panel-slot/panel-hides.js +111 -0
- package/dist/lib/panel-slot/panel-hides.js.map +1 -0
- package/dist/lib/panel-slot/placement-preview-panel.component.d.ts +16 -0
- package/dist/lib/panel-slot/placement-preview-panel.component.d.ts.map +1 -0
- package/dist/lib/panel-slot/placement-preview-panel.component.js +112 -0
- package/dist/lib/panel-slot/placement-preview-panel.component.js.map +1 -0
- package/dist/lib/panel-slot/placement-preview.d.ts +57 -0
- package/dist/lib/panel-slot/placement-preview.d.ts.map +1 -0
- package/dist/lib/panel-slot/placement-preview.js +86 -0
- package/dist/lib/panel-slot/placement-preview.js.map +1 -0
- 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 +10 -3
- package/dist/lib/panel-slot/related-entity-grid-panel.component.js.map +1 -1
- package/dist/lib/panel-slot/slot-order.d.ts +19 -0
- package/dist/lib/panel-slot/slot-order.d.ts.map +1 -0
- package/dist/lib/panel-slot/slot-order.js +53 -0
- package/dist/lib/panel-slot/slot-order.js.map +1 -0
- package/dist/lib/resolver/form-resolver.service.d.ts +4 -2
- package/dist/lib/resolver/form-resolver.service.d.ts.map +1 -1
- package/dist/lib/resolver/form-resolver.service.js +18 -8
- package/dist/lib/resolver/form-resolver.service.js.map +1 -1
- package/dist/lib/resolver/form-variants.d.ts +28 -0
- package/dist/lib/resolver/form-variants.d.ts.map +1 -0
- package/dist/lib/resolver/form-variants.js +40 -0
- package/dist/lib/resolver/form-variants.js.map +1 -0
- package/dist/lib/section-counts/form-section-counts.d.ts +99 -0
- package/dist/lib/section-counts/form-section-counts.d.ts.map +1 -0
- package/dist/lib/section-counts/form-section-counts.js +223 -0
- package/dist/lib/section-counts/form-section-counts.js.map +1 -0
- package/dist/lib/toolbar/form-toolbar.component.d.ts +129 -2
- package/dist/lib/toolbar/form-toolbar.component.d.ts.map +1 -1
- package/dist/lib/toolbar/form-toolbar.component.js +974 -307
- package/dist/lib/toolbar/form-toolbar.component.js.map +1 -1
- package/dist/lib/types/form-events.d.ts +6 -0
- package/dist/lib/types/form-events.d.ts.map +1 -1
- package/dist/lib/types/form-events.js +6 -0
- package/dist/lib/types/form-events.js.map +1 -1
- package/dist/lib/types/form-toolbar-item.d.ts +20 -1
- package/dist/lib/types/form-toolbar-item.d.ts.map +1 -1
- package/dist/lib/types/form-toolbar-item.js.map +1 -1
- package/dist/lib/types/form-types.d.ts +13 -0
- package/dist/lib/types/form-types.d.ts.map +1 -1
- package/dist/lib/types/form-types.js.map +1 -1
- package/dist/lib/types/toolbar-config.d.ts +16 -0
- package/dist/lib/types/toolbar-config.d.ts.map +1 -1
- package/dist/lib/types/toolbar-config.js +3 -0
- package/dist/lib/types/toolbar-config.js.map +1 -1
- package/dist/module.d.ts +29 -22
- package/dist/module.d.ts.map +1 -1
- package/dist/module.js +50 -8
- package/dist/module.js.map +1 -1
- package/dist/public-api.d.ts +22 -0
- package/dist/public-api.d.ts.map +1 -1
- package/dist/public-api.js +24 -0
- package/dist/public-api.js.map +1 -1
- package/package.json +20 -18
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
import { ChangeDetectorRef, Component, EventEmitter, Input, NgZone, Output, ViewChild, inject, } from '@angular/core';
|
|
2
|
+
import { CompositeKey, LogError, RunView } from '@memberjunction/core';
|
|
3
|
+
import { BaseAngularComponent } from '@memberjunction/ng-base-types';
|
|
4
|
+
import { FORM_PLACEMENT_PREVIEW, FormPlacementPreview } from '../panel-slot/placement-preview';
|
|
5
|
+
import { FormStateService } from '../form-state.service';
|
|
6
|
+
import * as i0 from "@angular/core";
|
|
7
|
+
import * as i1 from "@memberjunction/ng-shared-generic";
|
|
8
|
+
import * as i2 from "../host/entity-form-host.component";
|
|
9
|
+
const _c0 = ["viewport"];
|
|
10
|
+
const _c1 = ["stage"];
|
|
11
|
+
function MjFormPlacementPreviewComponent_Conditional_0_Template(rf, ctx) { if (rf & 1) {
|
|
12
|
+
i0.ɵɵelementStart(0, "p", 2);
|
|
13
|
+
i0.ɵɵelement(1, "i", 7);
|
|
14
|
+
i0.ɵɵtext(2);
|
|
15
|
+
i0.ɵɵelementEnd();
|
|
16
|
+
} if (rf & 2) {
|
|
17
|
+
const ctx_r0 = i0.ɵɵnextContext();
|
|
18
|
+
i0.ɵɵadvance(2);
|
|
19
|
+
i0.ɵɵtextInterpolate1(" ", ctx_r0.RecordLabel);
|
|
20
|
+
} }
|
|
21
|
+
function MjFormPlacementPreviewComponent_Conditional_5_Template(rf, ctx) { if (rf & 1) {
|
|
22
|
+
const _r2 = i0.ɵɵgetCurrentView();
|
|
23
|
+
i0.ɵɵelementStart(0, "mj-entity-form-host", 8);
|
|
24
|
+
i0.ɵɵlistener("LoadComplete", function MjFormPlacementPreviewComponent_Conditional_5_Template_mj_entity_form_host_LoadComplete_0_listener() { i0.ɵɵrestoreView(_r2); const ctx_r0 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r0.OnLoaded()); })("LoadError", function MjFormPlacementPreviewComponent_Conditional_5_Template_mj_entity_form_host_LoadError_0_listener() { i0.ɵɵrestoreView(_r2); const ctx_r0 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r0.OnLoadError()); });
|
|
25
|
+
i0.ɵɵelementEnd();
|
|
26
|
+
} if (rf & 2) {
|
|
27
|
+
const ctx_r0 = i0.ɵɵnextContext();
|
|
28
|
+
i0.ɵɵproperty("Provider", ctx_r0.Provider)("EntityName", ctx_r0.EntityName)("PrimaryKey", ctx_r0.PrimaryKey)("EditMode", false)("Config", ctx_r0.FormConfig);
|
|
29
|
+
} }
|
|
30
|
+
function MjFormPlacementPreviewComponent_Conditional_6_Template(rf, ctx) { if (rf & 1) {
|
|
31
|
+
i0.ɵɵelementStart(0, "div", 6);
|
|
32
|
+
i0.ɵɵelement(1, "mj-loading", 9);
|
|
33
|
+
i0.ɵɵelementEnd();
|
|
34
|
+
} }
|
|
35
|
+
/** A form state of its own for the preview, kept in memory, so the user's real form is untouched. */
|
|
36
|
+
function previewFormState() {
|
|
37
|
+
const state = new FormStateService();
|
|
38
|
+
state.Persist = false;
|
|
39
|
+
return state;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* The entity's real form, scaled down, with the placement dialog's panel drawn on it.
|
|
43
|
+
*
|
|
44
|
+
* The form is rendered by the same host every other surface uses, with a
|
|
45
|
+
* {@link FormPlacementPreview} provided to it, so the form itself places the unsaved panel,
|
|
46
|
+
* hides what it replaces and gives it a rail item.
|
|
47
|
+
*
|
|
48
|
+
* Read-only: the form is `inert` and every answer is made in the dialog's controls. The form
|
|
49
|
+
* shows the rail tab the panel is on; the preview scrolls to it. It has a form state of its own,
|
|
50
|
+
* held in memory, so opening that tab and its sections changes neither the user's saved form state
|
|
51
|
+
* nor the real form open behind the dialog.
|
|
52
|
+
*/
|
|
53
|
+
export class MjFormPlacementPreviewComponent extends BaseAngularComponent {
|
|
54
|
+
/**
|
|
55
|
+
* The narrowest width the form is laid out at. A narrower column shows it scaled down; a
|
|
56
|
+
* wider one shows it at its real size, never enlarged.
|
|
57
|
+
*/
|
|
58
|
+
static MIN_STAGE_WIDTH = 1100;
|
|
59
|
+
/** A form that never finishes loading must not leave the dialog without a preview. */
|
|
60
|
+
static LOAD_TIMEOUT_MS = 10000;
|
|
61
|
+
/** How long the answers must be still before the panel is redrawn. */
|
|
62
|
+
static REDRAW_DELAY_MS = 150;
|
|
63
|
+
set EntityName(value) {
|
|
64
|
+
const changed = value !== this._entityName;
|
|
65
|
+
this._entityName = value;
|
|
66
|
+
this.showSpec();
|
|
67
|
+
if (changed)
|
|
68
|
+
this.queueResolveRecord();
|
|
69
|
+
}
|
|
70
|
+
get EntityName() { return this._entityName; }
|
|
71
|
+
/**
|
|
72
|
+
* The record to show. Null shows a sample: the entity's first record, as Form Builder's
|
|
73
|
+
* preview picks it, or a new empty record when the entity has none.
|
|
74
|
+
*/
|
|
75
|
+
set RecordKey(value) {
|
|
76
|
+
this._recordKey = value;
|
|
77
|
+
this.queueResolveRecord();
|
|
78
|
+
}
|
|
79
|
+
/** The panel to draw on the form. */
|
|
80
|
+
set Spec(value) {
|
|
81
|
+
this._spec = value;
|
|
82
|
+
this.showSpec();
|
|
83
|
+
}
|
|
84
|
+
/** The saved row the panel is an edit of, left off the preview. */
|
|
85
|
+
set ReplacesRowID(value) {
|
|
86
|
+
this._replacesRowID = value;
|
|
87
|
+
this.showSpec();
|
|
88
|
+
}
|
|
89
|
+
/** The panel's component, not saved yet. Drawn in place of the placeholder. */
|
|
90
|
+
set PanelComponentSpec(value) {
|
|
91
|
+
this._componentSpec = value;
|
|
92
|
+
this.showSpec();
|
|
93
|
+
}
|
|
94
|
+
/** The saved component of the panel being edited. Drawn in place of the placeholder. */
|
|
95
|
+
set PanelComponentID(value) {
|
|
96
|
+
this._componentID = value;
|
|
97
|
+
this.showSpec();
|
|
98
|
+
}
|
|
99
|
+
/** The form did not render, so the dialog should show its list instead. */
|
|
100
|
+
Failed = new EventEmitter();
|
|
101
|
+
viewport;
|
|
102
|
+
stage;
|
|
103
|
+
PrimaryKey = new CompositeKey();
|
|
104
|
+
/** False until the record to show is known, so the form is drawn once, not blank and then again. */
|
|
105
|
+
RecordResolved = false;
|
|
106
|
+
/** Which record the preview shows, in words. */
|
|
107
|
+
RecordLabel = '';
|
|
108
|
+
FormConfig = { Toolbar: null, EnableRecordLinks: false };
|
|
109
|
+
Scale = 1;
|
|
110
|
+
StageWidth = MjFormPlacementPreviewComponent.MIN_STAGE_WIDTH;
|
|
111
|
+
StageHeight = 0;
|
|
112
|
+
Loaded = false;
|
|
113
|
+
_entityName = '';
|
|
114
|
+
_recordKey = null;
|
|
115
|
+
resolveRun = 0;
|
|
116
|
+
resolveQueued = false;
|
|
117
|
+
_spec = null;
|
|
118
|
+
_replacesRowID = null;
|
|
119
|
+
_componentSpec = null;
|
|
120
|
+
_componentID = null;
|
|
121
|
+
resizeObserver = null;
|
|
122
|
+
mutationObserver = null;
|
|
123
|
+
frame = 0;
|
|
124
|
+
loadTimer = null;
|
|
125
|
+
showTimer = null;
|
|
126
|
+
sizeSignature = '';
|
|
127
|
+
/** Set after each redraw, until the panel has been brought into view. */
|
|
128
|
+
revealPending = false;
|
|
129
|
+
preview = inject(FORM_PLACEMENT_PREVIEW);
|
|
130
|
+
zone = inject(NgZone);
|
|
131
|
+
cdr = inject(ChangeDetectorRef);
|
|
132
|
+
ngAfterViewInit() {
|
|
133
|
+
this.zone.runOutsideAngular(() => {
|
|
134
|
+
this.resizeObserver = new ResizeObserver(() => this.scheduleMeasure());
|
|
135
|
+
this.resizeObserver.observe(this.viewport.nativeElement);
|
|
136
|
+
this.resizeObserver.observe(this.stage.nativeElement);
|
|
137
|
+
this.mutationObserver = new MutationObserver(() => this.scheduleMeasure());
|
|
138
|
+
this.mutationObserver.observe(this.stage.nativeElement, {
|
|
139
|
+
childList: true, subtree: true, attributes: true, attributeFilter: ['class', 'style', 'hidden'],
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
this.loadTimer = setTimeout(() => { if (!this.Loaded)
|
|
143
|
+
this.Failed.emit(); }, MjFormPlacementPreviewComponent.LOAD_TIMEOUT_MS);
|
|
144
|
+
}
|
|
145
|
+
ngOnDestroy() {
|
|
146
|
+
this.resizeObserver?.disconnect();
|
|
147
|
+
this.mutationObserver?.disconnect();
|
|
148
|
+
if (this.frame)
|
|
149
|
+
cancelAnimationFrame(this.frame);
|
|
150
|
+
if (this.loadTimer)
|
|
151
|
+
clearTimeout(this.loadTimer);
|
|
152
|
+
if (this.showTimer)
|
|
153
|
+
clearTimeout(this.showTimer);
|
|
154
|
+
}
|
|
155
|
+
OnLoaded() {
|
|
156
|
+
this.Loaded = true;
|
|
157
|
+
if (this.loadTimer)
|
|
158
|
+
clearTimeout(this.loadTimer);
|
|
159
|
+
this.scheduleMeasure();
|
|
160
|
+
}
|
|
161
|
+
OnLoadError() {
|
|
162
|
+
this.Failed.emit();
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Resolves the record once the current round of input changes is over, so the entity and the
|
|
166
|
+
* record key arriving together look up a sample record once.
|
|
167
|
+
*/
|
|
168
|
+
queueResolveRecord() {
|
|
169
|
+
if (this.resolveQueued)
|
|
170
|
+
return;
|
|
171
|
+
this.resolveQueued = true;
|
|
172
|
+
queueMicrotask(() => {
|
|
173
|
+
this.resolveQueued = false;
|
|
174
|
+
void this.resolveRecord();
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
/** Settles which record the form shows, then lets the form draw. */
|
|
178
|
+
async resolveRecord() {
|
|
179
|
+
const run = ++this.resolveRun;
|
|
180
|
+
this.RecordResolved = false;
|
|
181
|
+
this.Loaded = false;
|
|
182
|
+
const entity = this._entityName ? this.ProviderToUse?.EntityByName(this._entityName) : undefined;
|
|
183
|
+
let key = this._recordKey;
|
|
184
|
+
let label = key ? 'Showing the record you have open' : '';
|
|
185
|
+
if (!key && entity) {
|
|
186
|
+
const sample = await this.sampleRecord(entity);
|
|
187
|
+
if (run !== this.resolveRun)
|
|
188
|
+
return;
|
|
189
|
+
key = sample?.Key ?? null;
|
|
190
|
+
label = sample ? `Showing ${sample.Label}, a sample record` : 'Showing a new, empty record — this entity has no records yet';
|
|
191
|
+
}
|
|
192
|
+
this.PrimaryKey = key ?? new CompositeKey();
|
|
193
|
+
this.RecordLabel = label;
|
|
194
|
+
this.RecordResolved = !!this._entityName;
|
|
195
|
+
this.cdr.markForCheck();
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* The entity's first record, ordered the way Form Builder's preview orders it: by name when
|
|
199
|
+
* the entity has a name field, so every user sees the same one, else newest first.
|
|
200
|
+
*/
|
|
201
|
+
async sampleRecord(entity) {
|
|
202
|
+
const provider = this.ProviderToUse;
|
|
203
|
+
if (!provider)
|
|
204
|
+
return null;
|
|
205
|
+
const nameField = entity.NameField?.Name;
|
|
206
|
+
const keyFields = entity.PrimaryKeys.map((pk) => pk.Name);
|
|
207
|
+
try {
|
|
208
|
+
const result = await RunView.FromMetadataProvider(provider).RunView({
|
|
209
|
+
EntityName: entity.Name,
|
|
210
|
+
Fields: nameField && !keyFields.includes(nameField) ? [...keyFields, nameField] : keyFields,
|
|
211
|
+
OrderBy: nameField ? `${nameField} ASC` : '__mj_CreatedAt DESC',
|
|
212
|
+
MaxRows: 1,
|
|
213
|
+
ResultType: 'simple',
|
|
214
|
+
}, provider.CurrentUser);
|
|
215
|
+
const row = result.Success ? result.Results?.[0] : undefined;
|
|
216
|
+
if (!row)
|
|
217
|
+
return null;
|
|
218
|
+
const key = CompositeKey.FromEntityRecord(entity, row);
|
|
219
|
+
const name = nameField ? String(row[nameField] ?? '').trim() : '';
|
|
220
|
+
return { Key: key, Label: name ? `“${name}”` : 'the first record' };
|
|
221
|
+
}
|
|
222
|
+
catch (err) {
|
|
223
|
+
LogError(`MjFormPlacementPreviewComponent: sample record for ${entity.Name} failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
224
|
+
return null;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Redraws the panel on the form, shortly after the last change. Each redraw remounts the
|
|
229
|
+
* panel's component, so typing a label must not remount it on every key.
|
|
230
|
+
*/
|
|
231
|
+
showSpec() {
|
|
232
|
+
if (this.showTimer)
|
|
233
|
+
clearTimeout(this.showTimer);
|
|
234
|
+
this.showTimer = setTimeout(() => {
|
|
235
|
+
this.showTimer = null;
|
|
236
|
+
const component = this._componentSpec || this._componentID
|
|
237
|
+
? { Spec: this._componentSpec, ComponentID: this._componentID }
|
|
238
|
+
: null;
|
|
239
|
+
this.preview.Show(this.EntityName, this._spec, this._replacesRowID, component);
|
|
240
|
+
this.revealPending = true;
|
|
241
|
+
this.scheduleMeasure();
|
|
242
|
+
}, MjFormPlacementPreviewComponent.REDRAW_DELAY_MS);
|
|
243
|
+
}
|
|
244
|
+
scheduleMeasure() {
|
|
245
|
+
if (this.frame)
|
|
246
|
+
return;
|
|
247
|
+
this.frame = requestAnimationFrame(() => {
|
|
248
|
+
this.frame = 0;
|
|
249
|
+
this.measure();
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
/** Fit the stage to the viewport, then keep the panel in view. Enters Angular only on a change. */
|
|
253
|
+
measure() {
|
|
254
|
+
const viewport = this.viewport.nativeElement;
|
|
255
|
+
const stage = this.stage.nativeElement;
|
|
256
|
+
const available = viewport.clientWidth;
|
|
257
|
+
const width = available > 0 ? Math.max(MjFormPlacementPreviewComponent.MIN_STAGE_WIDTH, available) : this.StageWidth;
|
|
258
|
+
const scale = available > 0 ? available / width : this.Scale;
|
|
259
|
+
const height = stage.offsetHeight * scale;
|
|
260
|
+
if (this.Loaded && this.revealPending)
|
|
261
|
+
this.revealPanel(stage);
|
|
262
|
+
const signature = `${width}|${scale}|${height}`;
|
|
263
|
+
if (signature === this.sizeSignature)
|
|
264
|
+
return;
|
|
265
|
+
this.sizeSignature = signature;
|
|
266
|
+
this.zone.run(() => {
|
|
267
|
+
this.StageWidth = width;
|
|
268
|
+
this.Scale = scale;
|
|
269
|
+
this.StageHeight = height;
|
|
270
|
+
this.cdr.markForCheck();
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Scrolls the panel into view once it draws after a redraw.
|
|
275
|
+
*
|
|
276
|
+
* On a form with a side rail the form itself shows the tab that holds the panel; this only
|
|
277
|
+
* waits for it to draw and then brings it into view.
|
|
278
|
+
*/
|
|
279
|
+
revealPanel(stage) {
|
|
280
|
+
const panel = stage.querySelector('[data-placement-preview]');
|
|
281
|
+
if (!panel)
|
|
282
|
+
return;
|
|
283
|
+
const box = (panel.querySelector('mj-collapsible-panel') ?? panel).getBoundingClientRect();
|
|
284
|
+
if (box.width === 0 && box.height === 0)
|
|
285
|
+
return;
|
|
286
|
+
this.revealPending = false;
|
|
287
|
+
panel.scrollIntoView({ block: 'nearest', behavior: 'smooth' });
|
|
288
|
+
}
|
|
289
|
+
static ɵfac = /*@__PURE__*/ (() => { let ɵMjFormPlacementPreviewComponent_BaseFactory; return function MjFormPlacementPreviewComponent_Factory(__ngFactoryType__) { return (ɵMjFormPlacementPreviewComponent_BaseFactory || (ɵMjFormPlacementPreviewComponent_BaseFactory = i0.ɵɵgetInheritedFactory(MjFormPlacementPreviewComponent)))(__ngFactoryType__ || MjFormPlacementPreviewComponent); }; })();
|
|
290
|
+
static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: MjFormPlacementPreviewComponent, selectors: [["mj-form-placement-preview"]], viewQuery: function MjFormPlacementPreviewComponent_Query(rf, ctx) { if (rf & 1) {
|
|
291
|
+
i0.ɵɵviewQuery(_c0, 7)(_c1, 7);
|
|
292
|
+
} if (rf & 2) {
|
|
293
|
+
let _t;
|
|
294
|
+
i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.viewport = _t.first);
|
|
295
|
+
i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.stage = _t.first);
|
|
296
|
+
} }, inputs: { EntityName: "EntityName", RecordKey: "RecordKey", Spec: "Spec", ReplacesRowID: "ReplacesRowID", PanelComponentSpec: "PanelComponentSpec", PanelComponentID: "PanelComponentID" }, outputs: { Failed: "Failed" }, standalone: false, features: [i0.ɵɵProvidersFeature([
|
|
297
|
+
{ provide: FORM_PLACEMENT_PREVIEW, useFactory: () => new FormPlacementPreview() },
|
|
298
|
+
{ provide: FormStateService, useFactory: previewFormState },
|
|
299
|
+
]), i0.ɵɵInheritDefinitionFeature], decls: 7, vars: 9, consts: [["viewport", ""], ["stage", ""], [1, "mj-pp-record"], [1, "mj-pp-viewport"], ["inert", "", 1, "mj-pp-stage"], [3, "Provider", "EntityName", "PrimaryKey", "EditMode", "Config"], [1, "mj-pp-loading"], ["aria-hidden", "true", 1, "fa-solid", "fa-eye"], [3, "LoadComplete", "LoadError", "Provider", "EntityName", "PrimaryKey", "EditMode", "Config"], ["text", "Drawing the form\u2026", "size", "small"]], template: function MjFormPlacementPreviewComponent_Template(rf, ctx) { if (rf & 1) {
|
|
300
|
+
i0.ɵɵconditionalCreate(0, MjFormPlacementPreviewComponent_Conditional_0_Template, 3, 1, "p", 2);
|
|
301
|
+
i0.ɵɵelementStart(1, "div", 3, 0)(3, "div", 4, 1);
|
|
302
|
+
i0.ɵɵconditionalCreate(5, MjFormPlacementPreviewComponent_Conditional_5_Template, 1, 5, "mj-entity-form-host", 5);
|
|
303
|
+
i0.ɵɵelementEnd();
|
|
304
|
+
i0.ɵɵconditionalCreate(6, MjFormPlacementPreviewComponent_Conditional_6_Template, 2, 0, "div", 6);
|
|
305
|
+
i0.ɵɵelementEnd();
|
|
306
|
+
} if (rf & 2) {
|
|
307
|
+
i0.ɵɵconditional(ctx.RecordLabel ? 0 : -1);
|
|
308
|
+
i0.ɵɵadvance();
|
|
309
|
+
i0.ɵɵstyleProp("height", ctx.StageHeight, "px");
|
|
310
|
+
i0.ɵɵadvance(2);
|
|
311
|
+
i0.ɵɵstyleProp("width", ctx.StageWidth, "px")("transform", "scale(" + ctx.Scale + ")");
|
|
312
|
+
i0.ɵɵadvance(2);
|
|
313
|
+
i0.ɵɵconditional(ctx.RecordResolved ? 5 : -1);
|
|
314
|
+
i0.ɵɵadvance();
|
|
315
|
+
i0.ɵɵconditional(!ctx.Loaded ? 6 : -1);
|
|
316
|
+
} }, dependencies: [i1.LoadingComponent, i2.MjEntityFormHostComponent], styles: ["[_nghost-%COMP%] {\n display: block;\n min-width: 0;\n}\n\n\n\n.mj-pp-viewport[_ngcontent-%COMP%] {\n position: relative;\n min-height: 240px;\n overflow: hidden;\n border: 1px solid var(--mj-border-default);\n border-radius: var(--mj-radius-md);\n background: var(--mj-bg-page);\n}\n\n.mj-pp-record[_ngcontent-%COMP%] {\n margin: 0 0 var(--mj-space-2);\n font-size: var(--mj-text-sm);\n color: var(--mj-text-secondary);\n}\n\n.mj-pp-stage[_ngcontent-%COMP%] {\n position: absolute;\n top: 0;\n left: 0;\n transform-origin: top left;\n}\n\n.mj-pp-loading[_ngcontent-%COMP%] {\n position: absolute;\n inset: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n background: var(--mj-bg-page);\n}"] });
|
|
317
|
+
}
|
|
318
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(MjFormPlacementPreviewComponent, [{
|
|
319
|
+
type: Component,
|
|
320
|
+
args: [{ standalone: false, selector: 'mj-form-placement-preview', providers: [
|
|
321
|
+
{ provide: FORM_PLACEMENT_PREVIEW, useFactory: () => new FormPlacementPreview() },
|
|
322
|
+
{ provide: FormStateService, useFactory: previewFormState },
|
|
323
|
+
], template: "@if (RecordLabel) {\n <p class=\"mj-pp-record\"><i class=\"fa-solid fa-eye\" aria-hidden=\"true\"></i> {{ RecordLabel }}</p>\n}\n<div class=\"mj-pp-viewport\" #viewport [style.height.px]=\"StageHeight\">\n <div class=\"mj-pp-stage\" #stage inert\n [style.width.px]=\"StageWidth\"\n [style.transform]=\"'scale(' + Scale + ')'\">\n @if (RecordResolved) {\n <!-- Read-only: a preview shows the form as it reads, and an empty required field in\n edit mode would paint the whole form with validation errors. -->\n <mj-entity-form-host\n [Provider]=\"Provider\"\n [EntityName]=\"EntityName\"\n [PrimaryKey]=\"PrimaryKey\"\n [EditMode]=\"false\"\n [Config]=\"FormConfig\"\n (LoadComplete)=\"OnLoaded()\"\n (LoadError)=\"OnLoadError()\">\n </mj-entity-form-host>\n }\n </div>\n\n @if (!Loaded) {\n <div class=\"mj-pp-loading\">\n <mj-loading text=\"Drawing the form\u2026\" size=\"small\"></mj-loading>\n </div>\n }\n</div>\n", styles: [":host {\n display: block;\n min-width: 0;\n}\n\n/* Holds the scaled form. Its height is the form's height after scaling, so the column that\n contains it scrolls the whole preview as one piece. */\n.mj-pp-viewport {\n position: relative;\n min-height: 240px;\n overflow: hidden;\n border: 1px solid var(--mj-border-default);\n border-radius: var(--mj-radius-md);\n background: var(--mj-bg-page);\n}\n\n.mj-pp-record {\n margin: 0 0 var(--mj-space-2);\n font-size: var(--mj-text-sm);\n color: var(--mj-text-secondary);\n}\n\n.mj-pp-stage {\n position: absolute;\n top: 0;\n left: 0;\n transform-origin: top left;\n}\n\n.mj-pp-loading {\n position: absolute;\n inset: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n background: var(--mj-bg-page);\n}\n"] }]
|
|
324
|
+
}], null, { EntityName: [{
|
|
325
|
+
type: Input
|
|
326
|
+
}], RecordKey: [{
|
|
327
|
+
type: Input
|
|
328
|
+
}], Spec: [{
|
|
329
|
+
type: Input
|
|
330
|
+
}], ReplacesRowID: [{
|
|
331
|
+
type: Input
|
|
332
|
+
}], PanelComponentSpec: [{
|
|
333
|
+
type: Input
|
|
334
|
+
}], PanelComponentID: [{
|
|
335
|
+
type: Input
|
|
336
|
+
}], Failed: [{
|
|
337
|
+
type: Output
|
|
338
|
+
}], viewport: [{
|
|
339
|
+
type: ViewChild,
|
|
340
|
+
args: ['viewport', { static: true }]
|
|
341
|
+
}], stage: [{
|
|
342
|
+
type: ViewChild,
|
|
343
|
+
args: ['stage', { static: true }]
|
|
344
|
+
}] }); })();
|
|
345
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(MjFormPlacementPreviewComponent, { className: "MjFormPlacementPreviewComponent", filePath: "src/lib/apply/form-placement-preview.component.ts", lineNumber: 42 }); })();
|
|
346
|
+
//# sourceMappingURL=form-placement-preview.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"form-placement-preview.component.js","sourceRoot":"","sources":["../../../src/lib/apply/form-placement-preview.component.ts","../../../src/lib/apply/form-placement-preview.component.html"],"names":[],"mappings":"AAAA,OAAO,EACY,iBAAiB,EAAE,SAAS,EAAc,YAAY,EAAE,KAAK,EAAE,MAAM,EAAa,MAAM,EACvG,SAAS,EAAE,MAAM,GACpB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,OAAO,EAAmB,MAAM,sBAAsB,CAAC;AACxF,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAGrE,OAAO,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAE/F,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;;;;;;;ICTvD,4BAAwB;IAAA,uBAAkD;IAAC,YAAiB;IAAA,iBAAI;;;IAArB,eAAiB;IAAjB,8CAAiB;;;;IAS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F,iCAAsE,gBAGpB;YAC9C,iHAAsB;YAaxB,iBAAM;YAEN,iGAAe;YAKjB,iBAAM;;YA3BN,0CAEC;YACqC,cAA+B;YAA/B,+CAA+B;YAE9D,eAA6B;YAC7B,AADA,6CAA6B,yCACa;YAC7C,eAYC;YAZD,6CAYC;YAGH,cAIC;YAJD,sCAIC;;;iFDeU,+BAA+B;cAV3C,SAAS;6BACM,KAAK,YACP,2BAA2B,aAG1B;oBACP,EAAE,OAAO,EAAE,sBAAsB,EAAE,UAAU,EAAE,GAAG,EAAE,CAAC,IAAI,oBAAoB,EAAE,EAAE;oBACjF,EAAE,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,gBAAgB,EAAE;iBAC9D;;kBAeA,KAAK;;kBAaL,KAAK;;kBAOL,KAAK;;kBAOL,KAAK;;kBAOL,KAAK;;kBAOL,KAAK;;kBAOL,MAAM;;kBAEN,SAAS;mBAAC,UAAU,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE;;kBACtC,SAAS;mBAAC,OAAO,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE;;kFAhE3B,+BAA+B","sourcesContent":["import {\n AfterViewInit, ChangeDetectorRef, Component, ElementRef, EventEmitter, Input, NgZone, OnDestroy, Output,\n ViewChild, inject,\n} from '@angular/core';\nimport { CompositeKey, LogError, RunView, type EntityInfo } from '@memberjunction/core';\nimport { BaseAngularComponent } from '@memberjunction/ng-base-types';\nimport type { FormContributionSpec } from '@memberjunction/interactive-component-types/forms';\nimport type { ComponentSpec } from '@memberjunction/interactive-component-types';\nimport { FORM_PLACEMENT_PREVIEW, FormPlacementPreview } from '../panel-slot/placement-preview';\nimport type { EntityFormConfig } from '../types/entity-form-config';\nimport { FormStateService } from '../form-state.service';\n\n/** A form state of its own for the preview, kept in memory, so the user's real form is untouched. */\nfunction previewFormState(): FormStateService {\n const state = new FormStateService();\n state.Persist = false;\n return state;\n}\n\n/**\n * The entity's real form, scaled down, with the placement dialog's panel drawn on it.\n *\n * The form is rendered by the same host every other surface uses, with a\n * {@link FormPlacementPreview} provided to it, so the form itself places the unsaved panel,\n * hides what it replaces and gives it a rail item.\n *\n * Read-only: the form is `inert` and every answer is made in the dialog's controls. The form\n * shows the rail tab the panel is on; the preview scrolls to it. It has a form state of its own,\n * held in memory, so opening that tab and its sections changes neither the user's saved form state\n * nor the real form open behind the dialog.\n */\n@Component({\n standalone: false,\n selector: 'mj-form-placement-preview',\n templateUrl: './form-placement-preview.component.html',\n styleUrls: ['./form-placement-preview.component.css'],\n providers: [\n { provide: FORM_PLACEMENT_PREVIEW, useFactory: () => new FormPlacementPreview() },\n { provide: FormStateService, useFactory: previewFormState },\n ],\n})\nexport class MjFormPlacementPreviewComponent extends BaseAngularComponent implements AfterViewInit, OnDestroy {\n /**\n * The narrowest width the form is laid out at. A narrower column shows it scaled down; a\n * wider one shows it at its real size, never enlarged.\n */\n public static readonly MIN_STAGE_WIDTH = 1100;\n\n /** A form that never finishes loading must not leave the dialog without a preview. */\n private static readonly LOAD_TIMEOUT_MS = 10000;\n\n /** How long the answers must be still before the panel is redrawn. */\n private static readonly REDRAW_DELAY_MS = 150;\n\n @Input()\n set EntityName(value: string) {\n const changed = value !== this._entityName;\n this._entityName = value;\n this.showSpec();\n if (changed) this.queueResolveRecord();\n }\n get EntityName(): string { return this._entityName; }\n\n /**\n * The record to show. Null shows a sample: the entity's first record, as Form Builder's\n * preview picks it, or a new empty record when the entity has none.\n */\n @Input()\n set RecordKey(value: CompositeKey | null) {\n this._recordKey = value;\n this.queueResolveRecord();\n }\n\n /** The panel to draw on the form. */\n @Input()\n set Spec(value: FormContributionSpec | null) {\n this._spec = value;\n this.showSpec();\n }\n\n /** The saved row the panel is an edit of, left off the preview. */\n @Input()\n set ReplacesRowID(value: string | null) {\n this._replacesRowID = value;\n this.showSpec();\n }\n\n /** The panel's component, not saved yet. Drawn in place of the placeholder. */\n @Input()\n set PanelComponentSpec(value: ComponentSpec | null) {\n this._componentSpec = value;\n this.showSpec();\n }\n\n /** The saved component of the panel being edited. Drawn in place of the placeholder. */\n @Input()\n set PanelComponentID(value: string | null) {\n this._componentID = value;\n this.showSpec();\n }\n\n /** The form did not render, so the dialog should show its list instead. */\n @Output() Failed = new EventEmitter<void>();\n\n @ViewChild('viewport', { static: true }) private viewport!: ElementRef<HTMLElement>;\n @ViewChild('stage', { static: true }) private stage!: ElementRef<HTMLElement>;\n\n public PrimaryKey = new CompositeKey();\n /** False until the record to show is known, so the form is drawn once, not blank and then again. */\n public RecordResolved = false;\n /** Which record the preview shows, in words. */\n public RecordLabel = '';\n public readonly FormConfig: EntityFormConfig = { Toolbar: null, EnableRecordLinks: false };\n public Scale = 1;\n public StageWidth = MjFormPlacementPreviewComponent.MIN_STAGE_WIDTH;\n public StageHeight = 0;\n public Loaded = false;\n\n private _entityName = '';\n private _recordKey: CompositeKey | null = null;\n private resolveRun = 0;\n private resolveQueued = false;\n private _spec: FormContributionSpec | null = null;\n private _replacesRowID: string | null = null;\n private _componentSpec: ComponentSpec | null = null;\n private _componentID: string | null = null;\n private resizeObserver: ResizeObserver | null = null;\n private mutationObserver: MutationObserver | null = null;\n private frame = 0;\n private loadTimer: ReturnType<typeof setTimeout> | null = null;\n private showTimer: ReturnType<typeof setTimeout> | null = null;\n private sizeSignature = '';\n /** Set after each redraw, until the panel has been brought into view. */\n private revealPending = false;\n\n private readonly preview = inject(FORM_PLACEMENT_PREVIEW);\n private readonly zone = inject(NgZone);\n private readonly cdr = inject(ChangeDetectorRef);\n\n public ngAfterViewInit(): void {\n this.zone.runOutsideAngular(() => {\n this.resizeObserver = new ResizeObserver(() => this.scheduleMeasure());\n this.resizeObserver.observe(this.viewport.nativeElement);\n this.resizeObserver.observe(this.stage.nativeElement);\n this.mutationObserver = new MutationObserver(() => this.scheduleMeasure());\n this.mutationObserver.observe(this.stage.nativeElement, {\n childList: true, subtree: true, attributes: true, attributeFilter: ['class', 'style', 'hidden'],\n });\n });\n this.loadTimer = setTimeout(() => { if (!this.Loaded) this.Failed.emit(); }, MjFormPlacementPreviewComponent.LOAD_TIMEOUT_MS);\n }\n\n public ngOnDestroy(): void {\n this.resizeObserver?.disconnect();\n this.mutationObserver?.disconnect();\n if (this.frame) cancelAnimationFrame(this.frame);\n if (this.loadTimer) clearTimeout(this.loadTimer);\n if (this.showTimer) clearTimeout(this.showTimer);\n }\n\n public OnLoaded(): void {\n this.Loaded = true;\n if (this.loadTimer) clearTimeout(this.loadTimer);\n this.scheduleMeasure();\n }\n\n public OnLoadError(): void {\n this.Failed.emit();\n }\n\n /**\n * Resolves the record once the current round of input changes is over, so the entity and the\n * record key arriving together look up a sample record once.\n */\n private queueResolveRecord(): void {\n if (this.resolveQueued) return;\n this.resolveQueued = true;\n queueMicrotask(() => {\n this.resolveQueued = false;\n void this.resolveRecord();\n });\n }\n\n /** Settles which record the form shows, then lets the form draw. */\n private async resolveRecord(): Promise<void> {\n const run = ++this.resolveRun;\n this.RecordResolved = false;\n this.Loaded = false;\n const entity = this._entityName ? this.ProviderToUse?.EntityByName(this._entityName) : undefined;\n let key = this._recordKey;\n let label = key ? 'Showing the record you have open' : '';\n if (!key && entity) {\n const sample = await this.sampleRecord(entity);\n if (run !== this.resolveRun) return;\n key = sample?.Key ?? null;\n label = sample ? `Showing ${sample.Label}, a sample record` : 'Showing a new, empty record — this entity has no records yet';\n }\n this.PrimaryKey = key ?? new CompositeKey();\n this.RecordLabel = label;\n this.RecordResolved = !!this._entityName;\n this.cdr.markForCheck();\n }\n\n /**\n * The entity's first record, ordered the way Form Builder's preview orders it: by name when\n * the entity has a name field, so every user sees the same one, else newest first.\n */\n private async sampleRecord(entity: EntityInfo): Promise<{ Key: CompositeKey; Label: string } | null> {\n const provider = this.ProviderToUse;\n if (!provider) return null;\n const nameField = entity.NameField?.Name;\n const keyFields = entity.PrimaryKeys.map((pk) => pk.Name);\n try {\n const result = await RunView.FromMetadataProvider(provider).RunView<Record<string, unknown>>({\n EntityName: entity.Name,\n Fields: nameField && !keyFields.includes(nameField) ? [...keyFields, nameField] : keyFields,\n OrderBy: nameField ? `${nameField} ASC` : '__mj_CreatedAt DESC',\n MaxRows: 1,\n ResultType: 'simple',\n }, provider.CurrentUser);\n const row = result.Success ? result.Results?.[0] : undefined;\n if (!row) return null;\n const key = CompositeKey.FromEntityRecord(entity, row);\n const name = nameField ? String(row[nameField] ?? '').trim() : '';\n return { Key: key, Label: name ? `“${name}”` : 'the first record' };\n } catch (err) {\n LogError(`MjFormPlacementPreviewComponent: sample record for ${entity.Name} failed: ${err instanceof Error ? err.message : String(err)}`);\n return null;\n }\n }\n\n /**\n * Redraws the panel on the form, shortly after the last change. Each redraw remounts the\n * panel's component, so typing a label must not remount it on every key.\n */\n private showSpec(): void {\n if (this.showTimer) clearTimeout(this.showTimer);\n this.showTimer = setTimeout(() => {\n this.showTimer = null;\n const component = this._componentSpec || this._componentID\n ? { Spec: this._componentSpec, ComponentID: this._componentID }\n : null;\n this.preview.Show(this.EntityName, this._spec, this._replacesRowID, component);\n this.revealPending = true;\n this.scheduleMeasure();\n }, MjFormPlacementPreviewComponent.REDRAW_DELAY_MS);\n }\n\n private scheduleMeasure(): void {\n if (this.frame) return;\n this.frame = requestAnimationFrame(() => {\n this.frame = 0;\n this.measure();\n });\n }\n\n /** Fit the stage to the viewport, then keep the panel in view. Enters Angular only on a change. */\n private measure(): void {\n const viewport = this.viewport.nativeElement;\n const stage = this.stage.nativeElement;\n const available = viewport.clientWidth;\n const width = available > 0 ? Math.max(MjFormPlacementPreviewComponent.MIN_STAGE_WIDTH, available) : this.StageWidth;\n const scale = available > 0 ? available / width : this.Scale;\n const height = stage.offsetHeight * scale;\n if (this.Loaded && this.revealPending) this.revealPanel(stage);\n const signature = `${width}|${scale}|${height}`;\n if (signature === this.sizeSignature) return;\n this.sizeSignature = signature;\n this.zone.run(() => {\n this.StageWidth = width;\n this.Scale = scale;\n this.StageHeight = height;\n this.cdr.markForCheck();\n });\n }\n\n /**\n * Scrolls the panel into view once it draws after a redraw.\n *\n * On a form with a side rail the form itself shows the tab that holds the panel; this only\n * waits for it to draw and then brings it into view.\n */\n private revealPanel(stage: HTMLElement): void {\n const panel = stage.querySelector<HTMLElement>('[data-placement-preview]');\n if (!panel) return;\n const box = (panel.querySelector('mj-collapsible-panel') ?? panel).getBoundingClientRect();\n if (box.width === 0 && box.height === 0) return;\n this.revealPending = false;\n panel.scrollIntoView({ block: 'nearest', behavior: 'smooth' });\n }\n}\n","@if (RecordLabel) {\n <p class=\"mj-pp-record\"><i class=\"fa-solid fa-eye\" aria-hidden=\"true\"></i> {{ RecordLabel }}</p>\n}\n<div class=\"mj-pp-viewport\" #viewport [style.height.px]=\"StageHeight\">\n <div class=\"mj-pp-stage\" #stage inert\n [style.width.px]=\"StageWidth\"\n [style.transform]=\"'scale(' + Scale + ')'\">\n @if (RecordResolved) {\n <!-- Read-only: a preview shows the form as it reads, and an empty required field in\n edit mode would paint the whole form with validation errors. -->\n <mj-entity-form-host\n [Provider]=\"Provider\"\n [EntityName]=\"EntityName\"\n [PrimaryKey]=\"PrimaryKey\"\n [EditMode]=\"false\"\n [Config]=\"FormConfig\"\n (LoadComplete)=\"OnLoaded()\"\n (LoadError)=\"OnLoadError()\">\n </mj-entity-form-host>\n }\n </div>\n\n @if (!Loaded) {\n <div class=\"mj-pp-loading\">\n <mj-loading text=\"Drawing the form…\" size=\"small\"></mj-loading>\n </div>\n }\n</div>\n"]}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview The sentences that describe a placement: the line under "Where it goes", the
|
|
3
|
+
* summary beside Apply, and the labels and lists they are built from.
|
|
4
|
+
*
|
|
5
|
+
* Both sentences read what the answers point at through one lookup ({@link placementTarget}),
|
|
6
|
+
* so they always name the same sections, fields, grid, panel or tab.
|
|
7
|
+
*/
|
|
8
|
+
import { type FormPlacementContext, type FormPlacementDroppedClaim, type FormPlacementSection, type FormPlacementState } from './form-placement';
|
|
9
|
+
/** What the dialog knows about its starting answers that the summary reports. */
|
|
10
|
+
export interface PlacementSummaryNotes {
|
|
11
|
+
/** The fields the dialog's starting answers stood in for, by entity field name. */
|
|
12
|
+
FieldsStoodInFor?: readonly string[];
|
|
13
|
+
/**
|
|
14
|
+
* A proposal's claim the seed dropped because the form could not confirm it. The summary
|
|
15
|
+
* leaves it out while the answers make that claim themselves.
|
|
16
|
+
*/
|
|
17
|
+
DroppedClaim?: FormPlacementDroppedClaim | null;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* How one section reads in the list, told apart from the tab that contains it.
|
|
21
|
+
*
|
|
22
|
+
* CodeGen names a generated field section "Details" whenever the entity has fields it
|
|
23
|
+
* files nowhere else, and the rail then folds that section — with every other field
|
|
24
|
+
* section — into a tab it also calls "Details". Two different targets under one name,
|
|
25
|
+
* one of them a part of the other, so the section is qualified.
|
|
26
|
+
*/
|
|
27
|
+
export declare function SectionOptionLabel(section: FormPlacementSection, context: FormPlacementContext): string;
|
|
28
|
+
/** Section titles joined for a sentence: "A and B", "A, B and C". */
|
|
29
|
+
export declare function DescribeSectionList(titles: readonly string[]): string;
|
|
30
|
+
/**
|
|
31
|
+
* A readable list of field labels: up to three by name ("the A, B and C fields"), and past
|
|
32
|
+
* three the first two and a count of the rest ("the A, B and 2 other fields").
|
|
33
|
+
*
|
|
34
|
+
* Counted past three because the sentence is one line beside the buttons, and a panel
|
|
35
|
+
* standing in for eight fields would push the rest of it off the end.
|
|
36
|
+
*/
|
|
37
|
+
export declare function DescribeFieldList(labels: readonly string[]): string;
|
|
38
|
+
/**
|
|
39
|
+
* Who sees a panel, as the end of "visible to …": the caller alone, a named role, or everyone.
|
|
40
|
+
* A panel added from a conversation is always the caller's own; one edited from the Manage
|
|
41
|
+
* drawer keeps the audience it has.
|
|
42
|
+
*/
|
|
43
|
+
export declare function DescribeVisibleTo(scope: string | null | undefined, roleName?: string | null): string;
|
|
44
|
+
/** The fields a field claim stands in for, as {@link DescribeFieldList} words them. */
|
|
45
|
+
export declare function DescribeChosenFields(state: FormPlacementState, context: FormPlacementContext): string;
|
|
46
|
+
/**
|
|
47
|
+
* Where the panel goes and what it replaces, in one short line: "In place of the Details and
|
|
48
|
+
* Dates sections", "At the top of Details, in place of the Name field", "After the fields".
|
|
49
|
+
*/
|
|
50
|
+
export declare function DescribePlacementLine(state: FormPlacementState, context: FormPlacementContext): string;
|
|
51
|
+
/**
|
|
52
|
+
* One sentence saying what pressing Apply does, in the same terms the user just chose.
|
|
53
|
+
*
|
|
54
|
+
* It is the only place the separate answers are stated together, so a contradiction the
|
|
55
|
+
* form allows — a panel that is active but invisible behind a full form — reads plainly.
|
|
56
|
+
*
|
|
57
|
+
* @param visibleTo Who sees the panel, from {@link DescribeVisibleTo}.
|
|
58
|
+
* @param notes What the dialog's starting answers stood in for, and what its seed dropped.
|
|
59
|
+
*/
|
|
60
|
+
export declare function SummarizePlacement(state: FormPlacementState, context: FormPlacementContext, visibleTo?: string, notes?: PlacementSummaryNotes): string;
|
|
61
|
+
//# sourceMappingURL=form-placement-text.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"form-placement-text.d.ts","sourceRoot":"","sources":["../../../src/lib/apply/form-placement-text.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EASH,KAAK,oBAAoB,EACzB,KAAK,yBAAyB,EAC9B,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EAC1B,MAAM,kBAAkB,CAAC;AAE1B,iFAAiF;AACjF,MAAM,WAAW,qBAAqB;IAClC,mFAAmF;IACnF,gBAAgB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC;;;OAGG;IACH,YAAY,CAAC,EAAE,yBAAyB,GAAG,IAAI,CAAC;CACnD;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,oBAAoB,EAAE,OAAO,EAAE,oBAAoB,GAAG,MAAM,CAMvG;AAED,qEAAqE;AACrE,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAGrE;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAMnE;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAIpG;AAED,uFAAuF;AACvF,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,kBAAkB,EAAE,OAAO,EAAE,oBAAoB,GAAG,MAAM,CAErG;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,kBAAkB,EAAE,OAAO,EAAE,oBAAoB,GAAG,MAAM,CAsBtG;AAED;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAC9B,KAAK,EAAE,kBAAkB,EACzB,OAAO,EAAE,oBAAoB,EAC7B,SAAS,SAA4B,EACrC,KAAK,GAAE,qBAA0B,GAClC,MAAM,CAsBR"}
|