@memberjunction/ng-dashboard-viewer 6.2.0-edge.4 → 6.2.0-edge.6

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.
Files changed (84) hide show
  1. package/README.md +17 -3
  2. package/dist/lib/config-panels/artifact-config-panel.component.js +2 -2
  3. package/dist/lib/config-panels/component-config-panel.component.d.ts +51 -0
  4. package/dist/lib/config-panels/component-config-panel.component.d.ts.map +1 -0
  5. package/dist/lib/config-panels/component-config-panel.component.js +246 -0
  6. package/dist/lib/config-panels/component-config-panel.component.js.map +1 -0
  7. package/dist/lib/config-panels/index.d.ts +1 -0
  8. package/dist/lib/config-panels/index.d.ts.map +1 -1
  9. package/dist/lib/config-panels/index.js +1 -0
  10. package/dist/lib/config-panels/index.js.map +1 -1
  11. package/dist/lib/config-panels/query-config-panel.component.js +2 -2
  12. package/dist/lib/config-panels/view-config-panel.component.js +2 -2
  13. package/dist/lib/config-panels/weburl-config-panel.component.js +2 -2
  14. package/dist/lib/dashboard-viewer/dashboard-viewer.component.d.ts +58 -1
  15. package/dist/lib/dashboard-viewer/dashboard-viewer.component.d.ts.map +1 -1
  16. package/dist/lib/dashboard-viewer/dashboard-viewer.component.js +186 -4
  17. package/dist/lib/dashboard-viewer/dashboard-viewer.component.js.map +1 -1
  18. package/dist/lib/dashboard-viewer.module.d.ts +22 -17
  19. package/dist/lib/dashboard-viewer.module.d.ts.map +1 -1
  20. package/dist/lib/dashboard-viewer.module.js +29 -4
  21. package/dist/lib/dashboard-viewer.module.js.map +1 -1
  22. package/dist/lib/dialogs/part-dialog/dashboard-part-dialog.component.d.ts +35 -1
  23. package/dist/lib/dialogs/part-dialog/dashboard-part-dialog.component.d.ts.map +1 -1
  24. package/dist/lib/dialogs/part-dialog/dashboard-part-dialog.component.js +307 -34
  25. package/dist/lib/dialogs/part-dialog/dashboard-part-dialog.component.js.map +1 -1
  26. package/dist/lib/dialogs/properties-dialog/dashboard-properties-dialog.component.d.ts +79 -0
  27. package/dist/lib/dialogs/properties-dialog/dashboard-properties-dialog.component.d.ts.map +1 -0
  28. package/dist/lib/dialogs/properties-dialog/dashboard-properties-dialog.component.js +461 -0
  29. package/dist/lib/dialogs/properties-dialog/dashboard-properties-dialog.component.js.map +1 -0
  30. package/dist/lib/dialogs/property-default-editor/property-default-editor.component.d.ts +41 -0
  31. package/dist/lib/dialogs/property-default-editor/property-default-editor.component.d.ts.map +1 -0
  32. package/dist/lib/dialogs/property-default-editor/property-default-editor.component.js +248 -0
  33. package/dist/lib/dialogs/property-default-editor/property-default-editor.component.js.map +1 -0
  34. package/dist/lib/models/dashboard-config-validator.d.ts +30 -0
  35. package/dist/lib/models/dashboard-config-validator.d.ts.map +1 -0
  36. package/dist/lib/models/dashboard-config-validator.js +107 -0
  37. package/dist/lib/models/dashboard-config-validator.js.map +1 -0
  38. package/dist/lib/models/dashboard-part-interfaces.d.ts +42 -0
  39. package/dist/lib/models/dashboard-part-interfaces.d.ts.map +1 -0
  40. package/dist/lib/models/dashboard-part-interfaces.js +180 -0
  41. package/dist/lib/models/dashboard-part-interfaces.js.map +1 -0
  42. package/dist/lib/models/dashboard-properties.d.ts +182 -0
  43. package/dist/lib/models/dashboard-properties.d.ts.map +1 -0
  44. package/dist/lib/models/dashboard-properties.js +263 -0
  45. package/dist/lib/models/dashboard-properties.js.map +1 -0
  46. package/dist/lib/models/dashboard-types.d.ts +8 -0
  47. package/dist/lib/models/dashboard-types.d.ts.map +1 -1
  48. package/dist/lib/models/dashboard-types.js.map +1 -1
  49. package/dist/lib/models/part-inputs-editor.d.ts +36 -0
  50. package/dist/lib/models/part-inputs-editor.d.ts.map +1 -0
  51. package/dist/lib/models/part-inputs-editor.js +53 -0
  52. package/dist/lib/models/part-inputs-editor.js.map +1 -0
  53. package/dist/lib/parts/artifact-part.component.d.ts.map +1 -1
  54. package/dist/lib/parts/artifact-part.component.js +5 -4
  55. package/dist/lib/parts/artifact-part.component.js.map +1 -1
  56. package/dist/lib/parts/base-dashboard-part.d.ts +50 -1
  57. package/dist/lib/parts/base-dashboard-part.d.ts.map +1 -1
  58. package/dist/lib/parts/base-dashboard-part.js +108 -1
  59. package/dist/lib/parts/base-dashboard-part.js.map +1 -1
  60. package/dist/lib/parts/component-part.component.d.ts +54 -0
  61. package/dist/lib/parts/component-part.component.d.ts.map +1 -0
  62. package/dist/lib/parts/component-part.component.js +221 -0
  63. package/dist/lib/parts/component-part.component.js.map +1 -0
  64. package/dist/lib/parts/index.d.ts +1 -0
  65. package/dist/lib/parts/index.d.ts.map +1 -1
  66. package/dist/lib/parts/index.js +1 -0
  67. package/dist/lib/parts/index.js.map +1 -1
  68. package/dist/lib/parts/query-part.component.d.ts +25 -1
  69. package/dist/lib/parts/query-part.component.d.ts.map +1 -1
  70. package/dist/lib/parts/query-part.component.js +93 -10
  71. package/dist/lib/parts/query-part.component.js.map +1 -1
  72. package/dist/lib/parts/view-part.component.d.ts +18 -1
  73. package/dist/lib/parts/view-part.component.d.ts.map +1 -1
  74. package/dist/lib/parts/view-part.component.js +74 -10
  75. package/dist/lib/parts/view-part.component.js.map +1 -1
  76. package/dist/lib/parts/weburl-part.component.d.ts +14 -0
  77. package/dist/lib/parts/weburl-part.component.d.ts.map +1 -1
  78. package/dist/lib/parts/weburl-part.component.js +62 -5
  79. package/dist/lib/parts/weburl-part.component.js.map +1 -1
  80. package/dist/public-api.d.ts +8 -0
  81. package/dist/public-api.d.ts.map +1 -1
  82. package/dist/public-api.js +8 -0
  83. package/dist/public-api.js.map +1 -1
  84. package/package.json +15 -13
@@ -0,0 +1,221 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { Component } from '@angular/core';
8
+ import { RegisterClass } from '@memberjunction/global';
9
+ import { BaseDashboardPart } from './base-dashboard-part';
10
+ import { PartInputProblemMessage } from '../models/dashboard-properties';
11
+ import { ComponentPartInterface, LoadComponentSpec, COMPONENT_NAME_KEY } from '../models/dashboard-part-interfaces';
12
+ import * as i0 from "@angular/core";
13
+ import * as i1 from "@memberjunction/ng-shared-generic";
14
+ import * as i2 from "@memberjunction/ng-react";
15
+ import * as i3 from "@memberjunction/ng-ui-components";
16
+ function ComponentPartComponent_Conditional_1_Template(rf, ctx) { if (rf & 1) {
17
+ i0.ɵɵelementStart(0, "div", 1);
18
+ i0.ɵɵelement(1, "mj-loading", 5);
19
+ i0.ɵɵelementEnd();
20
+ } }
21
+ function ComponentPartComponent_Conditional_2_Template(rf, ctx) { if (rf & 1) {
22
+ i0.ɵɵelement(0, "mj-empty-state", 2);
23
+ } if (rf & 2) {
24
+ const ctx_r0 = i0.ɵɵnextContext();
25
+ i0.ɵɵproperty("Message", ctx_r0.ErrorMessage);
26
+ } }
27
+ function ComponentPartComponent_Conditional_3_Template(rf, ctx) { if (rf & 1) {
28
+ i0.ɵɵelement(0, "mj-empty-state", 3);
29
+ } }
30
+ function ComponentPartComponent_Conditional_4_Template(rf, ctx) { if (rf & 1) {
31
+ const _r2 = i0.ɵɵgetCurrentView();
32
+ i0.ɵɵelementStart(0, "mj-react-component", 6);
33
+ i0.ɵɵlistener("ComponentEvent", function ComponentPartComponent_Conditional_4_Template_mj_react_component_ComponentEvent_0_listener($event) { i0.ɵɵrestoreView(_r2); const ctx_r0 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r0.OnReactComponentEvent($event)); })("OpenEntityRecord", function ComponentPartComponent_Conditional_4_Template_mj_react_component_OpenEntityRecord_0_listener($event) { i0.ɵɵrestoreView(_r2); const ctx_r0 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r0.OnOpenEntityRecord($event)); });
34
+ i0.ɵɵelementEnd();
35
+ } if (rf & 2) {
36
+ const ctx_r0 = i0.ɵɵnextContext();
37
+ i0.ɵɵproperty("Provider", ctx_r0.ProviderToUse)("Component", ctx_r0.Spec)("ComponentProps", ctx_r0.ComponentProps);
38
+ } }
39
+ /**
40
+ * Runtime renderer for Interactive Component dashboard parts.
41
+ *
42
+ * Renders a registered component (`MJ: Components`, by name, and namespace and version when the part
43
+ * gives them) in the React host, with its props from the part's input mappings and, for an unmapped
44
+ * prop, the prop's own `defaultValue`. The React host's `utilities` (`md`, `rv`, `rq`) come from the
45
+ * part's `ProviderToUse`, so the dashboard's provider reaches the component's data access.
46
+ *
47
+ * The component's declared events are the part's events: each is passed to the component as a
48
+ * callback prop of the same name (`onSelect(id)`), and is also heard when the component raises it
49
+ * through `callbacks.NotifyEvent`. Its values are the event's declared parameters.
50
+ */
51
+ let ComponentPartComponent = class ComponentPartComponent extends BaseDashboardPart {
52
+ /** The component's specification, once loaded. */
53
+ Spec = null;
54
+ /** Whether the part names a component. */
55
+ HasComponent = false;
56
+ /** The props the component gets: mapped values, prop defaults, and a callback per declared event. */
57
+ ComponentProps = {};
58
+ /** True while the part shows a problem with its mappings rather than a load error. */
59
+ showingInputProblem = false;
60
+ constructor(cdr) {
61
+ super(cdr);
62
+ }
63
+ ngAfterViewInit() {
64
+ if (this.Panel) {
65
+ this.loadContent();
66
+ }
67
+ }
68
+ async loadContent() {
69
+ const config = this.getConfig();
70
+ if (!config?.[COMPONENT_NAME_KEY]) {
71
+ this.HasComponent = false;
72
+ this.Spec = null;
73
+ this.cdr.detectChanges();
74
+ return;
75
+ }
76
+ this.setLoading(true);
77
+ try {
78
+ const spec = await LoadComponentSpec(config, this.ProviderToUse);
79
+ this.Spec = spec;
80
+ this.HasComponent = true;
81
+ const resolution = this.UpdateInputs(ComponentPartInterface(spec).Inputs);
82
+ if (!this.showInputs(resolution))
83
+ return;
84
+ this.setLoading(false);
85
+ }
86
+ catch (error) {
87
+ this.showingInputProblem = false;
88
+ this.setError(error instanceof Error ? error.message : 'Failed to load component');
89
+ }
90
+ }
91
+ /** New input values: the component re-renders with new props; the component isn't reloaded. */
92
+ ApplyInputs(resolution) {
93
+ if (this.ErrorMessage && !this.showingInputProblem)
94
+ return; // a load error stays until the next load
95
+ if (this.showInputs(resolution)) {
96
+ this.ErrorMessage = null;
97
+ this.cdr.detectChanges();
98
+ }
99
+ }
100
+ /** Shows the inputs' problem, or builds the props from them. Returns false when the part stops. */
101
+ showInputs(resolution) {
102
+ const problem = PartInputProblemMessage(resolution);
103
+ this.showingInputProblem = problem !== null;
104
+ if (problem) {
105
+ this.setError(problem);
106
+ return false;
107
+ }
108
+ this.ComponentProps = this.buildProps(resolution);
109
+ return true;
110
+ }
111
+ /** Each declared prop's mapped value, else its `defaultValue`; and a callback for each declared event. */
112
+ buildProps(resolution) {
113
+ const props = {};
114
+ for (const prop of this.Spec?.properties ?? []) {
115
+ if (resolution && Object.prototype.hasOwnProperty.call(resolution.Values, prop.name)) {
116
+ props[prop.name] = resolution.Values[prop.name];
117
+ }
118
+ else if (prop.defaultValue !== undefined) {
119
+ props[prop.name] = prop.defaultValue;
120
+ }
121
+ }
122
+ for (const event of this.Spec?.events ?? []) {
123
+ props[event.name] = (...args) => this.raiseDeclaredEvent(event, args);
124
+ }
125
+ return props;
126
+ }
127
+ /**
128
+ * Raises a declared event with its parameters by position. An event whose parameters are all
129
+ * empty clears the selection it set.
130
+ */
131
+ raiseDeclaredEvent(event, args) {
132
+ const parameters = event.parameters ?? [];
133
+ const values = {};
134
+ parameters.forEach((p, i) => { values[p.name] = args[i]; });
135
+ const cleared = parameters.length > 0 && parameters.every((_, i) => args[i] === null || args[i] === undefined);
136
+ this.EmitPartEvent(event.name, cleared ? null : values);
137
+ }
138
+ /** An event the component raised through `callbacks.NotifyEvent`: a declared one is a part event. */
139
+ OnReactComponentEvent(event) {
140
+ const declared = this.Spec?.events?.find(e => e.name === event.type);
141
+ if (!declared)
142
+ return;
143
+ const payload = (event.payload ?? {});
144
+ this.raiseDeclaredEvent(declared, (declared.parameters ?? []).map(p => payload[p.name]));
145
+ }
146
+ /** The component asked to open a record. */
147
+ OnOpenEntityRecord(event) {
148
+ if (event.entityName && event.key) {
149
+ this.RequestOpenEntityRecord(event.entityName, event.key.ToURLSegment(), 'view', false);
150
+ }
151
+ }
152
+ cleanup() {
153
+ this.Spec = null;
154
+ this.ComponentProps = {};
155
+ }
156
+ static ɵfac = function ComponentPartComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || ComponentPartComponent)(i0.ɵɵdirectiveInject(i0.ChangeDetectorRef)); };
157
+ static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: ComponentPartComponent, selectors: [["mj-component-part"]], standalone: false, features: [i0.ɵɵInheritDefinitionFeature], decls: 5, vars: 4, consts: [[1, "component-part"], [1, "loading-state"], ["Variant", "error", "Icon", "fa-solid fa-triangle-exclamation", "Title", "Couldn't load component", "Size", "compact", 1, "part-placeholder", 3, "Message"], ["Icon", "fa-solid fa-cubes", "Title", "No Component Selected", "Message", "Use Edit part to choose a component.", "Size", "compact", 1, "part-placeholder"], [3, "Provider", "Component", "ComponentProps"], ["text", "Loading component..."], [3, "ComponentEvent", "OpenEntityRecord", "Provider", "Component", "ComponentProps"]], template: function ComponentPartComponent_Template(rf, ctx) { if (rf & 1) {
158
+ i0.ɵɵelementStart(0, "div", 0);
159
+ i0.ɵɵconditionalCreate(1, ComponentPartComponent_Conditional_1_Template, 2, 0, "div", 1);
160
+ i0.ɵɵconditionalCreate(2, ComponentPartComponent_Conditional_2_Template, 1, 1, "mj-empty-state", 2);
161
+ i0.ɵɵconditionalCreate(3, ComponentPartComponent_Conditional_3_Template, 1, 0, "mj-empty-state", 3);
162
+ i0.ɵɵconditionalCreate(4, ComponentPartComponent_Conditional_4_Template, 1, 3, "mj-react-component", 4);
163
+ i0.ɵɵelementEnd();
164
+ } if (rf & 2) {
165
+ i0.ɵɵadvance();
166
+ i0.ɵɵconditional(ctx.IsLoading ? 1 : -1);
167
+ i0.ɵɵadvance();
168
+ i0.ɵɵconditional(ctx.ErrorMessage && !ctx.IsLoading ? 2 : -1);
169
+ i0.ɵɵadvance();
170
+ i0.ɵɵconditional(!ctx.IsLoading && !ctx.ErrorMessage && !ctx.HasComponent ? 3 : -1);
171
+ i0.ɵɵadvance();
172
+ i0.ɵɵconditional(!ctx.IsLoading && !ctx.ErrorMessage && ctx.HasComponent && ctx.Spec ? 4 : -1);
173
+ } }, dependencies: [i1.LoadingComponent, i2.MJReactComponent, i3.MJEmptyStateComponent], styles: ["[_nghost-%COMP%] {\n display: block;\n width: 100%;\n height: 100%;\n }\n\n .component-part[_ngcontent-%COMP%] {\n width: 100%;\n height: 100%;\n display: flex;\n flex-direction: column;\n background: var(--mj-bg-surface);\n }\n\n .loading-state[_ngcontent-%COMP%] {\n display: flex;\n align-items: center;\n justify-content: center;\n height: 100%;\n padding: 24px;\n }\n\n .part-placeholder[_ngcontent-%COMP%] {\n height: 100%;\n }\n\n mj-react-component[_ngcontent-%COMP%] {\n flex: 1;\n min-height: 0;\n }"] });
174
+ };
175
+ ComponentPartComponent = __decorate([
176
+ RegisterClass(BaseDashboardPart, 'ComponentPanelRenderer')
177
+ ], ComponentPartComponent);
178
+ export { ComponentPartComponent };
179
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ComponentPartComponent, [{
180
+ type: Component,
181
+ args: [{ standalone: false, selector: 'mj-component-part', template: `
182
+ <div class="component-part">
183
+ @if (IsLoading) {
184
+ <div class="loading-state">
185
+ <mj-loading text="Loading component..."></mj-loading>
186
+ </div>
187
+ }
188
+
189
+ @if (ErrorMessage && !IsLoading) {
190
+ <mj-empty-state
191
+ class="part-placeholder"
192
+ Variant="error"
193
+ Icon="fa-solid fa-triangle-exclamation"
194
+ Title="Couldn't load component"
195
+ [Message]="ErrorMessage"
196
+ Size="compact" />
197
+ }
198
+
199
+ @if (!IsLoading && !ErrorMessage && !HasComponent) {
200
+ <mj-empty-state
201
+ class="part-placeholder"
202
+ Icon="fa-solid fa-cubes"
203
+ Title="No Component Selected"
204
+ Message="Use Edit part to choose a component."
205
+ Size="compact" />
206
+ }
207
+
208
+ @if (!IsLoading && !ErrorMessage && HasComponent && Spec) {
209
+ <mj-react-component
210
+ [Provider]="ProviderToUse"
211
+ [Component]="Spec"
212
+ [ComponentProps]="ComponentProps"
213
+ (ComponentEvent)="OnReactComponentEvent($event)"
214
+ (OpenEntityRecord)="OnOpenEntityRecord($event)">
215
+ </mj-react-component>
216
+ }
217
+ </div>
218
+ `, styles: ["\n :host {\n display: block;\n width: 100%;\n height: 100%;\n }\n\n .component-part {\n width: 100%;\n height: 100%;\n display: flex;\n flex-direction: column;\n background: var(--mj-bg-surface);\n }\n\n .loading-state {\n display: flex;\n align-items: center;\n justify-content: center;\n height: 100%;\n padding: 24px;\n }\n\n .part-placeholder {\n height: 100%;\n }\n\n mj-react-component {\n flex: 1;\n min-height: 0;\n }\n "] }]
219
+ }], () => [{ type: i0.ChangeDetectorRef }], null); })();
220
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(ComponentPartComponent, { className: "ComponentPartComponent", filePath: "src/lib/parts/component-part.component.ts", lineNumber: 98 }); })();
221
+ //# sourceMappingURL=component-part.component.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"component-part.component.js","sourceRoot":"","sources":["../../../src/lib/parts/component-part.component.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,SAAS,EAAoC,MAAM,eAAe,CAAC;AAE5E,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAGvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE1D,OAAO,EAAE,uBAAuB,EAAuB,MAAM,gCAAgC,CAAC;AAC9F,OAAO,EAAE,sBAAsB,EAAE,iBAAiB,EA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,cAQC;YARD,6DAQC;YAED,cAOC;YAPD,mFAOC;YAED,cAQC;YARD,8FAQC;;;AAoCE,sBAAsB;IA3ElC,aAAa,CAAC,iBAAiB,EAAE,wBAAwB,CAAC;GA2E9C,sBAAsB,CAiHlC;;iFAjHY,sBAAsB;cA1ElC,SAAS;6BACM,KAAK,YACP,mBAAmB,YACnB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAqCT;;kFAkCQ,sBAAsB","sourcesContent":["import { Component, ChangeDetectorRef, AfterViewInit } from '@angular/core';\nimport { CompositeKey } from '@memberjunction/core';\nimport { RegisterClass } from '@memberjunction/global';\nimport type { ComponentEvent, ComponentSpec } from '@memberjunction/interactive-component-types';\nimport type { ReactComponentEvent } from '@memberjunction/ng-react';\nimport { BaseDashboardPart } from './base-dashboard-part';\nimport { PanelConfig } from '../models/dashboard-types';\nimport { PartInputProblemMessage, PartInputResolution } from '../models/dashboard-properties';\nimport { ComponentPartInterface, LoadComponentSpec, COMPONENT_NAME_KEY } from '../models/dashboard-part-interfaces';\n\n/**\n * Runtime renderer for Interactive Component dashboard parts.\n *\n * Renders a registered component (`MJ: Components`, by name, and namespace and version when the part\n * gives them) in the React host, with its props from the part's input mappings and, for an unmapped\n * prop, the prop's own `defaultValue`. The React host's `utilities` (`md`, `rv`, `rq`) come from the\n * part's `ProviderToUse`, so the dashboard's provider reaches the component's data access.\n *\n * The component's declared events are the part's events: each is passed to the component as a\n * callback prop of the same name (`onSelect(id)`), and is also heard when the component raises it\n * through `callbacks.NotifyEvent`. Its values are the event's declared parameters.\n */\n@RegisterClass(BaseDashboardPart, 'ComponentPanelRenderer')\n@Component({\n standalone: false,\n selector: 'mj-component-part',\n template: `\n <div class=\"component-part\">\n @if (IsLoading) {\n <div class=\"loading-state\">\n <mj-loading text=\"Loading component...\"></mj-loading>\n </div>\n }\n\n @if (ErrorMessage && !IsLoading) {\n <mj-empty-state\n class=\"part-placeholder\"\n Variant=\"error\"\n Icon=\"fa-solid fa-triangle-exclamation\"\n Title=\"Couldn't load component\"\n [Message]=\"ErrorMessage\"\n Size=\"compact\" />\n }\n\n @if (!IsLoading && !ErrorMessage && !HasComponent) {\n <mj-empty-state\n class=\"part-placeholder\"\n Icon=\"fa-solid fa-cubes\"\n Title=\"No Component Selected\"\n Message=\"Use Edit part to choose a component.\"\n Size=\"compact\" />\n }\n\n @if (!IsLoading && !ErrorMessage && HasComponent && Spec) {\n <mj-react-component\n [Provider]=\"ProviderToUse\"\n [Component]=\"Spec\"\n [ComponentProps]=\"ComponentProps\"\n (ComponentEvent)=\"OnReactComponentEvent($event)\"\n (OpenEntityRecord)=\"OnOpenEntityRecord($event)\">\n </mj-react-component>\n }\n </div>\n `,\n styles: [`\n :host {\n display: block;\n width: 100%;\n height: 100%;\n }\n\n .component-part {\n width: 100%;\n height: 100%;\n display: flex;\n flex-direction: column;\n background: var(--mj-bg-surface);\n }\n\n .loading-state {\n display: flex;\n align-items: center;\n justify-content: center;\n height: 100%;\n padding: 24px;\n }\n\n .part-placeholder {\n height: 100%;\n }\n\n mj-react-component {\n flex: 1;\n min-height: 0;\n }\n `]\n})\nexport class ComponentPartComponent extends BaseDashboardPart implements AfterViewInit {\n /** The component's specification, once loaded. */\n public Spec: ComponentSpec | null = null;\n\n /** Whether the part names a component. */\n public HasComponent = false;\n\n /** The props the component gets: mapped values, prop defaults, and a callback per declared event. */\n public ComponentProps: Record<string, unknown> = {};\n\n /** True while the part shows a problem with its mappings rather than a load error. */\n private showingInputProblem = false;\n\n constructor(cdr: ChangeDetectorRef) {\n super(cdr);\n }\n\n ngAfterViewInit(): void {\n if (this.Panel) {\n this.loadContent();\n }\n }\n\n public async loadContent(): Promise<void> {\n const config = this.getConfig<PanelConfig>();\n if (!config?.[COMPONENT_NAME_KEY]) {\n this.HasComponent = false;\n this.Spec = null;\n this.cdr.detectChanges();\n return;\n }\n this.setLoading(true);\n try {\n const spec = await LoadComponentSpec(config, this.ProviderToUse);\n this.Spec = spec;\n this.HasComponent = true;\n const resolution = this.UpdateInputs(ComponentPartInterface(spec).Inputs);\n if (!this.showInputs(resolution)) return;\n this.setLoading(false);\n } catch (error) {\n this.showingInputProblem = false;\n this.setError(error instanceof Error ? error.message : 'Failed to load component');\n }\n }\n\n /** New input values: the component re-renders with new props; the component isn't reloaded. */\n protected override ApplyInputs(resolution: PartInputResolution | null): void {\n if (this.ErrorMessage && !this.showingInputProblem) return; // a load error stays until the next load\n if (this.showInputs(resolution)) {\n this.ErrorMessage = null;\n this.cdr.detectChanges();\n }\n }\n\n /** Shows the inputs' problem, or builds the props from them. Returns false when the part stops. */\n private showInputs(resolution: PartInputResolution | null): boolean {\n const problem = PartInputProblemMessage(resolution);\n this.showingInputProblem = problem !== null;\n if (problem) {\n this.setError(problem);\n return false;\n }\n this.ComponentProps = this.buildProps(resolution);\n return true;\n }\n\n /** Each declared prop's mapped value, else its `defaultValue`; and a callback for each declared event. */\n private buildProps(resolution: PartInputResolution | null): Record<string, unknown> {\n const props: Record<string, unknown> = {};\n for (const prop of this.Spec?.properties ?? []) {\n if (resolution && Object.prototype.hasOwnProperty.call(resolution.Values, prop.name)) {\n props[prop.name] = resolution.Values[prop.name];\n } else if (prop.defaultValue !== undefined) {\n props[prop.name] = prop.defaultValue;\n }\n }\n for (const event of this.Spec?.events ?? []) {\n props[event.name] = (...args: unknown[]) => this.raiseDeclaredEvent(event, args);\n }\n return props;\n }\n\n /**\n * Raises a declared event with its parameters by position. An event whose parameters are all\n * empty clears the selection it set.\n */\n private raiseDeclaredEvent(event: ComponentEvent, args: unknown[]): void {\n const parameters = event.parameters ?? [];\n const values: Record<string, unknown> = {};\n parameters.forEach((p, i) => { values[p.name] = args[i]; });\n const cleared = parameters.length > 0 && parameters.every((_, i) => args[i] === null || args[i] === undefined);\n this.EmitPartEvent(event.name, cleared ? null : values);\n }\n\n /** An event the component raised through `callbacks.NotifyEvent`: a declared one is a part event. */\n public OnReactComponentEvent(event: ReactComponentEvent): void {\n const declared = this.Spec?.events?.find(e => e.name === event.type);\n if (!declared) return;\n const payload = (event.payload ?? {}) as Record<string, unknown>;\n this.raiseDeclaredEvent(declared, (declared.parameters ?? []).map(p => payload[p.name]));\n }\n\n /** The component asked to open a record. */\n public OnOpenEntityRecord(event: { entityName: string; key: CompositeKey }): void {\n if (event.entityName && event.key) {\n this.RequestOpenEntityRecord(event.entityName, event.key.ToURLSegment(), 'view', false);\n }\n }\n\n protected override cleanup(): void {\n this.Spec = null;\n this.ComponentProps = {};\n }\n}\n"]}
@@ -3,4 +3,5 @@ export * from './weburl-part.component';
3
3
  export * from './view-part.component';
4
4
  export * from './query-part.component';
5
5
  export * from './artifact-part.component';
6
+ export * from './component-part.component';
6
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/parts/index.ts"],"names":[],"mappings":"AACA,cAAc,uBAAuB,CAAC;AAGtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,2BAA2B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/parts/index.ts"],"names":[],"mappings":"AACA,cAAc,uBAAuB,CAAC;AAGtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,4BAA4B,CAAC"}
@@ -5,4 +5,5 @@ export * from './weburl-part.component';
5
5
  export * from './view-part.component';
6
6
  export * from './query-part.component';
7
7
  export * from './artifact-part.component';
8
+ export * from './component-part.component';
8
9
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/parts/index.ts"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,cAAc,uBAAuB,CAAC;AAEtC,0BAA0B;AAC1B,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,2BAA2B,CAAC","sourcesContent":["// Dashboard Part Renderers - Base Class\nexport * from './base-dashboard-part';\n\n// Runtime Part Components\nexport * from './weburl-part.component';\nexport * from './view-part.component';\nexport * from './query-part.component';\nexport * from './artifact-part.component';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/parts/index.ts"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,cAAc,uBAAuB,CAAC;AAEtC,0BAA0B;AAC1B,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,4BAA4B,CAAC","sourcesContent":["// Dashboard Part Renderers - Base Class\nexport * from './base-dashboard-part';\n\n// Runtime Part Components\nexport * from './weburl-part.component';\nexport * from './view-part.component';\nexport * from './query-part.component';\nexport * from './artifact-part.component';\nexport * from './component-part.component';\n"]}
@@ -1,6 +1,7 @@
1
1
  import { ChangeDetectorRef, AfterViewInit, OnDestroy } from '@angular/core';
2
2
  import { BaseDashboardPart } from './base-dashboard-part';
3
- import { QueryViewerComponent, QueryEntityLinkClickEvent } from '@memberjunction/ng-query-viewer';
3
+ import { QueryViewerComponent, QueryEntityLinkClickEvent, QueryParameterValues, QuerySelectionChangedEvent } from '@memberjunction/ng-query-viewer';
4
+ import { PartInputResolution } from '../models/dashboard-properties';
4
5
  import * as i0 from "@angular/core";
5
6
  /**
6
7
  * Runtime renderer for Query dashboard parts.
@@ -27,11 +28,34 @@ export declare class QueryPartComponent extends BaseDashboardPart implements Aft
27
28
  get showToolbar(): boolean;
28
29
  /** @deprecated Use {@link ShowToolbar}. */
29
30
  set showToolbar(value: boolean);
31
+ /**
32
+ * Parameter values from the part's input mappings. They override the user's saved values, are
33
+ * never saved back into them, and show read-only. Null when the part has no mappings.
34
+ */
35
+ MappedParameters: QueryParameterValues | null;
36
+ /** True while the part shows a problem with its mappings rather than a load error. */
37
+ private showingInputProblem;
30
38
  private queryEntity;
31
39
  private autoRefreshTimer;
32
40
  constructor(cdr: ChangeDetectorRef);
33
41
  ngAfterViewInit(): void;
34
42
  loadContent(): Promise<void>;
43
+ /**
44
+ * Works out the mapped parameter values. A part without mappings loads nothing more and runs as
45
+ * before. Returns false, showing why, when a mapping is broken or a mapped input has no value.
46
+ */
47
+ private applyQueryInputs;
48
+ /** Shows the inputs' problem, or takes their values. Returns false when the part stops. */
49
+ private showInputs;
50
+ /**
51
+ * Every mapped parameter with its value, or null when nothing set it, so the query viewer never
52
+ * falls back to the user's saved value for a parameter the dashboard drives.
53
+ */
54
+ private mappedValues;
55
+ /** New input values: the query viewer reruns the query with them. */
56
+ protected ApplyInputs(resolution: PartInputResolution | null): void;
57
+ /** RowSelected: the selected row's columns; an empty selection clears it. */
58
+ OnSelectionChange(event: QuerySelectionChangedEvent): void;
35
59
  OnEntityLinkClick(event: QueryEntityLinkClickEvent): void;
36
60
  /** @deprecated Use {@link OnEntityLinkClick}. */
37
61
  onEntityLinkClick(event: QueryEntityLinkClickEvent): void;
@@ -1 +1 @@
1
- {"version":3,"file":"query-part.component.d.ts","sourceRoot":"","sources":["../../../src/lib/parts/query-part.component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,iBAAiB,EAAa,aAAa,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAElG,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAG1D,OAAO,EAAE,oBAAoB,EAAE,yBAAyB,EAAE,MAAM,iCAAiC,CAAC;;AAElG;;;GAGG;AACH,qBA8Fa,kBAAmB,SAAQ,iBAAkB,YAAW,aAAa,EAAE,SAAS;IAC/D,WAAW,EAAG,oBAAoB,CAAC;IAE7D,2CAA2C;IAC3C,IAAI,WAAW,IAAI,oBAAoB,CAEtC;IACD,2CAA2C;IAC3C,IAAI,WAAW,CAAC,KAAK,EAAE,oBAAoB,EAE1C;IAEM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IAS5E,6EAA6E;IACtE,iBAAiB,CAAC,KAAK,EAAE,0BAA0B,GAAG,IAAI;IAK1D,iBAAiB,CAAC,KAAK,EAAE,yBAAyB,GAAG,IAAI;IAmBhE,iDAAiD;IAC1C,iBAAiB,CAAC,KAAK,EAAE,yBAAyB,GAAG,IAAI;IAIzD,YAAY,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI;IAIvC,4CAA4C;IACrC,YAAY,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI;IAIhC,YAAY,IAAI,IAAI;IAM3B,4CAA4C;IACrC,YAAY,IAAI,IAAI;IAI3B,OAAO,CAAC,gBAAgB;IASxB,OAAO,CAAC,eAAe;cAOJ,OAAO,IAAI,IAAI;yCAxOzB,kBAAkB;2CAAlB,kBAAkB;CA6O9B"}
@@ -7,6 +7,8 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
7
7
  import { Component, ViewChild } from '@angular/core';
8
8
  import { RegisterClass } from '@memberjunction/global';
9
9
  import { BaseDashboardPart } from './base-dashboard-part';
10
+ import { PartInputProblemMessage, ROW_SELECTED_EVENT } from '../models/dashboard-properties';
11
+ import { LoadPartInterface } from '../models/dashboard-part-interfaces';
10
12
  import * as i0 from "@angular/core";
11
13
  import * as i1 from "@memberjunction/ng-shared-generic";
12
14
  import * as i2 from "@memberjunction/ng-query-viewer";
@@ -14,7 +16,7 @@ import * as i3 from "@memberjunction/ng-ui-components";
14
16
  const _c0 = ["queryViewer"];
15
17
  function QueryPartComponent_Conditional_1_Template(rf, ctx) { if (rf & 1) {
16
18
  i0.ɵɵelementStart(0, "div", 2);
17
- i0.ɵɵelement(1, "mj-loading", 6);
19
+ i0.ɵɵelement(1, "mj-loading", 7);
18
20
  i0.ɵɵelementEnd();
19
21
  } }
20
22
  function QueryPartComponent_Conditional_2_Template(rf, ctx) { if (rf & 1) {
@@ -28,13 +30,21 @@ function QueryPartComponent_Conditional_3_Template(rf, ctx) { if (rf & 1) {
28
30
  } }
29
31
  function QueryPartComponent_Conditional_4_Template(rf, ctx) { if (rf & 1) {
30
32
  const _r2 = i0.ɵɵgetCurrentView();
31
- i0.ɵɵelementStart(0, "div", 5)(1, "mj-query-viewer", 7, 0);
32
- i0.ɵɵlistener("EntityLinkClick", function QueryPartComponent_Conditional_4_Template_mj_query_viewer_EntityLinkClick_1_listener($event) { i0.ɵɵrestoreView(_r2); const ctx_r0 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r0.onEntityLinkClick($event)); })("QueryError", function QueryPartComponent_Conditional_4_Template_mj_query_viewer_QueryError_1_listener($event) { i0.ɵɵrestoreView(_r2); const ctx_r0 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r0.onQueryError($event)); });
33
+ i0.ɵɵelementStart(0, "div", 5)(1, "button", 8);
34
+ i0.ɵɵlistener("click", function QueryPartComponent_Conditional_4_Template_button_click_1_listener() { i0.ɵɵrestoreView(_r2); const ctx_r0 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r0.ClearSelection()); });
35
+ i0.ɵɵelement(2, "i", 9);
36
+ i0.ɵɵtext(3, " Clear selection ");
37
+ i0.ɵɵelementEnd()();
38
+ } }
39
+ function QueryPartComponent_Conditional_5_Template(rf, ctx) { if (rf & 1) {
40
+ const _r3 = i0.ɵɵgetCurrentView();
41
+ i0.ɵɵelementStart(0, "div", 6)(1, "mj-query-viewer", 10, 0);
42
+ i0.ɵɵlistener("EntityLinkClick", function QueryPartComponent_Conditional_5_Template_mj_query_viewer_EntityLinkClick_1_listener($event) { i0.ɵɵrestoreView(_r3); const ctx_r0 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r0.onEntityLinkClick($event)); })("SelectionChange", function QueryPartComponent_Conditional_5_Template_mj_query_viewer_SelectionChange_1_listener($event) { i0.ɵɵrestoreView(_r3); const ctx_r0 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r0.OnSelectionChange($event)); })("QueryError", function QueryPartComponent_Conditional_5_Template_mj_query_viewer_QueryError_1_listener($event) { i0.ɵɵrestoreView(_r3); const ctx_r0 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r0.onQueryError($event)); });
33
43
  i0.ɵɵelementEnd()();
34
44
  } if (rf & 2) {
35
45
  const ctx_r0 = i0.ɵɵnextContext();
36
46
  i0.ɵɵadvance();
37
- i0.ɵɵproperty("QueryId", ctx_r0.queryId)("AutoRun", true)("ShowToolbar", ctx_r0.showToolbar)("PersistState", true)("PersistParameters", true);
47
+ i0.ɵɵproperty("Provider", ctx_r0.Provider)("QueryId", ctx_r0.queryId)("AutoRun", true)("ShowToolbar", ctx_r0.showToolbar)("PersistState", true)("PersistParameters", true)("MappedParameters", ctx_r0.MappedParameters);
38
48
  } }
39
49
  /**
40
50
  * Runtime renderer for Query dashboard parts.
@@ -77,6 +87,13 @@ let QueryPartComponent = class QueryPartComponent extends BaseDashboardPart {
77
87
  set showToolbar(value) {
78
88
  this.ShowToolbar = value;
79
89
  }
90
+ /**
91
+ * Parameter values from the part's input mappings. They override the user's saved values, are
92
+ * never saved back into them, and show read-only. Null when the part has no mappings.
93
+ */
94
+ MappedParameters = null;
95
+ /** True while the part shows a problem with its mappings rather than a load error. */
96
+ showingInputProblem = false;
80
97
  queryEntity = null;
81
98
  autoRefreshTimer = null;
82
99
  constructor(cdr) {
@@ -119,6 +136,8 @@ let QueryPartComponent = class QueryPartComponent extends BaseDashboardPart {
119
136
  throw new Error(`Query "${queryName}" not found`);
120
137
  }
121
138
  }
139
+ if (!(await this.applyQueryInputs(config)))
140
+ return;
122
141
  this.HasQuery = true;
123
142
  this.ShowToolbar = config?.['showParameterControls'] !== false;
124
143
  // Set auto-refresh if configured
@@ -129,9 +148,59 @@ let QueryPartComponent = class QueryPartComponent extends BaseDashboardPart {
129
148
  this.setLoading(false);
130
149
  }
131
150
  catch (error) {
151
+ this.showingInputProblem = false;
132
152
  this.setError(error instanceof Error ? error.message : 'Failed to load query');
133
153
  }
134
154
  }
155
+ /**
156
+ * Works out the mapped parameter values. A part without mappings loads nothing more and runs as
157
+ * before. Returns false, showing why, when a mapping is broken or a mapped input has no value.
158
+ */
159
+ async applyQueryInputs(config) {
160
+ if (this.InputMappings.length === 0) {
161
+ this.MappedParameters = null;
162
+ return true;
163
+ }
164
+ const partInterface = await LoadPartInterface(config, this.ProviderToUse);
165
+ return this.showInputs(this.UpdateInputs(partInterface.Inputs));
166
+ }
167
+ /** Shows the inputs' problem, or takes their values. Returns false when the part stops. */
168
+ showInputs(resolution) {
169
+ const problem = PartInputProblemMessage(resolution);
170
+ this.showingInputProblem = problem !== null;
171
+ if (problem) {
172
+ this.setError(problem);
173
+ return false;
174
+ }
175
+ this.MappedParameters = resolution ? this.mappedValues(resolution) : null;
176
+ return true;
177
+ }
178
+ /**
179
+ * Every mapped parameter with its value, or null when nothing set it, so the query viewer never
180
+ * falls back to the user's saved value for a parameter the dashboard drives.
181
+ */
182
+ mappedValues(resolution) {
183
+ const values = {};
184
+ for (const mapping of this.InputMappings) {
185
+ values[mapping.Input] = resolution.Values[mapping.Input] ?? null;
186
+ }
187
+ return values;
188
+ }
189
+ /** New input values: the query viewer reruns the query with them. */
190
+ ApplyInputs(resolution) {
191
+ if (this.ErrorMessage && !this.showingInputProblem)
192
+ return; // a load error stays until the next load
193
+ if (this.showInputs(resolution)) {
194
+ this.ErrorMessage = null;
195
+ this.HasQuery = !!this.QueryId;
196
+ this.cdr.detectChanges();
197
+ }
198
+ }
199
+ /** RowSelected: the selected row's columns; an empty selection clears it. */
200
+ OnSelectionChange(event) {
201
+ const row = event?.selectedRows?.[0];
202
+ this.EmitPartEvent(ROW_SELECTED_EVENT, row ? { ...row } : null);
203
+ }
135
204
  OnEntityLinkClick(event) {
136
205
  // Emit data change event with clicked entity info (for any listeners that need it)
137
206
  this.emitDataChanged({
@@ -189,12 +258,13 @@ let QueryPartComponent = class QueryPartComponent extends BaseDashboardPart {
189
258
  } if (rf & 2) {
190
259
  let _t;
191
260
  i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.QueryViewer = _t.first);
192
- } }, standalone: false, features: [i0.ɵɵInheritDefinitionFeature], decls: 5, vars: 8, consts: [["queryViewer", ""], [1, "query-part"], [1, "loading-state"], ["Variant", "error", "Icon", "fa-solid fa-triangle-exclamation", "Title", "Couldn't load query", "Size", "compact", 1, "part-placeholder", 3, "Message"], ["Icon", "fa-solid fa-flask", "Title", "No Query Selected", "Message", "Use Edit part to choose a query.", "Size", "compact", 1, "part-placeholder"], [1, "query-content"], ["text", "Loading query..."], [3, "EntityLinkClick", "QueryError", "QueryId", "AutoRun", "ShowToolbar", "PersistState", "PersistParameters"]], template: function QueryPartComponent_Template(rf, ctx) { if (rf & 1) {
261
+ } }, standalone: false, features: [i0.ɵɵInheritDefinitionFeature], decls: 6, vars: 9, consts: [["queryViewer", ""], [1, "query-part"], [1, "loading-state"], ["Variant", "error", "Icon", "fa-solid fa-triangle-exclamation", "Title", "Couldn't load query", "Size", "compact", 1, "part-placeholder", 3, "Message"], ["Icon", "fa-solid fa-flask", "Title", "No Query Selected", "Message", "Use Edit part to choose a query.", "Size", "compact", 1, "part-placeholder"], [1, "part-selection-bar"], [1, "query-content"], ["text", "Loading query..."], ["type", "button", 1, "part-clear-selection", 3, "click"], ["aria-hidden", "true", 1, "fa-solid", "fa-xmark"], [3, "EntityLinkClick", "SelectionChange", "QueryError", "Provider", "QueryId", "AutoRun", "ShowToolbar", "PersistState", "PersistParameters", "MappedParameters"]], template: function QueryPartComponent_Template(rf, ctx) { if (rf & 1) {
193
262
  i0.ɵɵelementStart(0, "div", 1);
194
263
  i0.ɵɵconditionalCreate(1, QueryPartComponent_Conditional_1_Template, 2, 0, "div", 2);
195
264
  i0.ɵɵconditionalCreate(2, QueryPartComponent_Conditional_2_Template, 1, 1, "mj-empty-state", 3);
196
265
  i0.ɵɵconditionalCreate(3, QueryPartComponent_Conditional_3_Template, 1, 0, "mj-empty-state", 4);
197
- i0.ɵɵconditionalCreate(4, QueryPartComponent_Conditional_4_Template, 3, 5, "div", 5);
266
+ i0.ɵɵconditionalCreate(4, QueryPartComponent_Conditional_4_Template, 4, 0, "div", 5);
267
+ i0.ɵɵconditionalCreate(5, QueryPartComponent_Conditional_5_Template, 3, 7, "div", 6);
198
268
  i0.ɵɵelementEnd();
199
269
  } if (rf & 2) {
200
270
  i0.ɵɵclassProp("loading", ctx.IsLoading)("error", ctx.ErrorMessage);
@@ -205,8 +275,10 @@ let QueryPartComponent = class QueryPartComponent extends BaseDashboardPart {
205
275
  i0.ɵɵadvance();
206
276
  i0.ɵɵconditional(!ctx.IsLoading && !ctx.ErrorMessage && !ctx.hasQuery ? 3 : -1);
207
277
  i0.ɵɵadvance();
208
- i0.ɵɵconditional(!ctx.IsLoading && !ctx.ErrorMessage && ctx.hasQuery && ctx.queryId ? 4 : -1);
209
- } }, dependencies: [i1.LoadingComponent, i2.QueryViewerComponent, i3.MJEmptyStateComponent], styles: ["[_nghost-%COMP%] {\n display: block;\n width: 100%;\n height: 100%;\n }\n\n .query-part[_ngcontent-%COMP%] {\n width: 100%;\n height: 100%;\n display: flex;\n flex-direction: column;\n background: var(--mj-bg-surface);\n }\n\n .loading-state[_ngcontent-%COMP%] {\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n height: 100%;\n color: var(--mj-text-secondary);\n text-align: center;\n padding: 24px;\n }\n\n .part-placeholder[_ngcontent-%COMP%] {\n height: 100%;\n }\n\n .query-content[_ngcontent-%COMP%] {\n flex: 1;\n min-height: 0;\n overflow: hidden;\n }\n\n mj-query-viewer[_ngcontent-%COMP%] {\n display: block;\n width: 100%;\n height: 100%;\n }"] });
278
+ i0.ɵɵconditional(ctx.HasActiveSelection && !ctx.IsLoading && !ctx.ErrorMessage ? 4 : -1);
279
+ i0.ɵɵadvance();
280
+ i0.ɵɵconditional(!ctx.IsLoading && !ctx.ErrorMessage && ctx.hasQuery && ctx.queryId ? 5 : -1);
281
+ } }, dependencies: [i1.LoadingComponent, i2.QueryViewerComponent, i3.MJEmptyStateComponent], styles: ["[_nghost-%COMP%] {\n display: block;\n width: 100%;\n height: 100%;\n }\n\n .query-part[_ngcontent-%COMP%] {\n width: 100%;\n height: 100%;\n display: flex;\n flex-direction: column;\n background: var(--mj-bg-surface);\n }\n\n .loading-state[_ngcontent-%COMP%] {\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n height: 100%;\n color: var(--mj-text-secondary);\n text-align: center;\n padding: 24px;\n }\n\n .part-placeholder[_ngcontent-%COMP%] {\n height: 100%;\n }\n\n .query-content[_ngcontent-%COMP%] {\n flex: 1;\n min-height: 0;\n overflow: hidden;\n }\n\n mj-query-viewer[_ngcontent-%COMP%] {\n display: block;\n width: 100%;\n height: 100%;\n }\n\n .part-selection-bar[_ngcontent-%COMP%] {\n display: flex;\n justify-content: flex-end;\n padding: 4px 8px;\n border-bottom: 1px solid var(--mj-border-subtle);\n }\n\n .part-clear-selection[_ngcontent-%COMP%] {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n padding: 2px 10px;\n border: 1px solid var(--mj-border-default);\n border-radius: 12px;\n background: var(--mj-bg-surface);\n color: var(--mj-text-secondary);\n font-size: 12px;\n cursor: pointer;\n }\n\n .part-clear-selection[_ngcontent-%COMP%]:hover {\n background: var(--mj-bg-surface-hover);\n color: var(--mj-text-primary);\n }"] });
210
282
  };
211
283
  QueryPartComponent = __decorate([
212
284
  RegisterClass(BaseDashboardPart, 'QueryPanelRenderer')
@@ -244,26 +316,37 @@ export { QueryPartComponent };
244
316
  Size="compact" />
245
317
  }
246
318
 
319
+ @if (HasActiveSelection && !IsLoading && !ErrorMessage) {
320
+ <div class="part-selection-bar">
321
+ <button type="button" class="part-clear-selection" (click)="ClearSelection()">
322
+ <i class="fa-solid fa-xmark" aria-hidden="true"></i> Clear selection
323
+ </button>
324
+ </div>
325
+ }
326
+
247
327
  <!-- Query Viewer -->
248
328
  @if (!IsLoading && !ErrorMessage && hasQuery && queryId) {
249
329
  <div class="query-content">
250
330
  <mj-query-viewer
251
331
  #queryViewer
332
+ [Provider]="Provider"
252
333
  [QueryId]="queryId"
253
334
  [AutoRun]="true"
254
335
  [ShowToolbar]="showToolbar"
255
336
  [PersistState]="true"
256
337
  [PersistParameters]="true"
338
+ [MappedParameters]="MappedParameters"
257
339
  (EntityLinkClick)="onEntityLinkClick($event)"
340
+ (SelectionChange)="OnSelectionChange($event)"
258
341
  (QueryError)="onQueryError($event)">
259
342
  </mj-query-viewer>
260
343
  </div>
261
344
  }
262
345
  </div>
263
- `, styles: ["\n :host {\n display: block;\n width: 100%;\n height: 100%;\n }\n\n .query-part {\n width: 100%;\n height: 100%;\n display: flex;\n flex-direction: column;\n background: var(--mj-bg-surface);\n }\n\n .loading-state {\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n height: 100%;\n color: var(--mj-text-secondary);\n text-align: center;\n padding: 24px;\n }\n\n .part-placeholder {\n height: 100%;\n }\n\n .query-content {\n flex: 1;\n min-height: 0;\n overflow: hidden;\n }\n\n mj-query-viewer {\n display: block;\n width: 100%;\n height: 100%;\n }\n "] }]
346
+ `, styles: ["\n :host {\n display: block;\n width: 100%;\n height: 100%;\n }\n\n .query-part {\n width: 100%;\n height: 100%;\n display: flex;\n flex-direction: column;\n background: var(--mj-bg-surface);\n }\n\n .loading-state {\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n height: 100%;\n color: var(--mj-text-secondary);\n text-align: center;\n padding: 24px;\n }\n\n .part-placeholder {\n height: 100%;\n }\n\n .query-content {\n flex: 1;\n min-height: 0;\n overflow: hidden;\n }\n\n mj-query-viewer {\n display: block;\n width: 100%;\n height: 100%;\n }\n\n .part-selection-bar {\n display: flex;\n justify-content: flex-end;\n padding: 4px 8px;\n border-bottom: 1px solid var(--mj-border-subtle);\n }\n\n .part-clear-selection {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n padding: 2px 10px;\n border: 1px solid var(--mj-border-default);\n border-radius: 12px;\n background: var(--mj-bg-surface);\n color: var(--mj-text-secondary);\n font-size: 12px;\n cursor: pointer;\n }\n\n .part-clear-selection:hover {\n background: var(--mj-bg-surface-hover);\n color: var(--mj-text-primary);\n }\n "] }]
264
347
  }], () => [{ type: i0.ChangeDetectorRef }], { QueryViewer: [{
265
348
  type: ViewChild,
266
349
  args: ['queryViewer']
267
350
  }] }); })();
268
- (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(QueryPartComponent, { className: "QueryPartComponent", filePath: "src/lib/parts/query-part.component.ts", lineNumber: 106 }); })();
351
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(QueryPartComponent, { className: "QueryPartComponent", filePath: "src/lib/parts/query-part.component.ts", lineNumber: 144 }); })();
269
352
  //# sourceMappingURL=query-part.component.js.map