@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.
- package/README.md +17 -3
- package/dist/lib/config-panels/artifact-config-panel.component.js +2 -2
- package/dist/lib/config-panels/component-config-panel.component.d.ts +51 -0
- package/dist/lib/config-panels/component-config-panel.component.d.ts.map +1 -0
- package/dist/lib/config-panels/component-config-panel.component.js +246 -0
- package/dist/lib/config-panels/component-config-panel.component.js.map +1 -0
- package/dist/lib/config-panels/index.d.ts +1 -0
- package/dist/lib/config-panels/index.d.ts.map +1 -1
- package/dist/lib/config-panels/index.js +1 -0
- package/dist/lib/config-panels/index.js.map +1 -1
- package/dist/lib/config-panels/query-config-panel.component.js +2 -2
- package/dist/lib/config-panels/view-config-panel.component.js +2 -2
- package/dist/lib/config-panels/weburl-config-panel.component.js +2 -2
- package/dist/lib/dashboard-viewer/dashboard-viewer.component.d.ts +58 -1
- package/dist/lib/dashboard-viewer/dashboard-viewer.component.d.ts.map +1 -1
- package/dist/lib/dashboard-viewer/dashboard-viewer.component.js +186 -4
- package/dist/lib/dashboard-viewer/dashboard-viewer.component.js.map +1 -1
- package/dist/lib/dashboard-viewer.module.d.ts +22 -17
- package/dist/lib/dashboard-viewer.module.d.ts.map +1 -1
- package/dist/lib/dashboard-viewer.module.js +29 -4
- package/dist/lib/dashboard-viewer.module.js.map +1 -1
- package/dist/lib/dialogs/part-dialog/dashboard-part-dialog.component.d.ts +35 -1
- package/dist/lib/dialogs/part-dialog/dashboard-part-dialog.component.d.ts.map +1 -1
- package/dist/lib/dialogs/part-dialog/dashboard-part-dialog.component.js +307 -34
- package/dist/lib/dialogs/part-dialog/dashboard-part-dialog.component.js.map +1 -1
- package/dist/lib/dialogs/properties-dialog/dashboard-properties-dialog.component.d.ts +79 -0
- package/dist/lib/dialogs/properties-dialog/dashboard-properties-dialog.component.d.ts.map +1 -0
- package/dist/lib/dialogs/properties-dialog/dashboard-properties-dialog.component.js +461 -0
- package/dist/lib/dialogs/properties-dialog/dashboard-properties-dialog.component.js.map +1 -0
- package/dist/lib/dialogs/property-default-editor/property-default-editor.component.d.ts +41 -0
- package/dist/lib/dialogs/property-default-editor/property-default-editor.component.d.ts.map +1 -0
- package/dist/lib/dialogs/property-default-editor/property-default-editor.component.js +248 -0
- package/dist/lib/dialogs/property-default-editor/property-default-editor.component.js.map +1 -0
- package/dist/lib/models/dashboard-config-validator.d.ts +30 -0
- package/dist/lib/models/dashboard-config-validator.d.ts.map +1 -0
- package/dist/lib/models/dashboard-config-validator.js +107 -0
- package/dist/lib/models/dashboard-config-validator.js.map +1 -0
- package/dist/lib/models/dashboard-part-interfaces.d.ts +42 -0
- package/dist/lib/models/dashboard-part-interfaces.d.ts.map +1 -0
- package/dist/lib/models/dashboard-part-interfaces.js +180 -0
- package/dist/lib/models/dashboard-part-interfaces.js.map +1 -0
- package/dist/lib/models/dashboard-properties.d.ts +182 -0
- package/dist/lib/models/dashboard-properties.d.ts.map +1 -0
- package/dist/lib/models/dashboard-properties.js +263 -0
- package/dist/lib/models/dashboard-properties.js.map +1 -0
- package/dist/lib/models/dashboard-types.d.ts +8 -0
- package/dist/lib/models/dashboard-types.d.ts.map +1 -1
- package/dist/lib/models/dashboard-types.js.map +1 -1
- package/dist/lib/models/part-inputs-editor.d.ts +36 -0
- package/dist/lib/models/part-inputs-editor.d.ts.map +1 -0
- package/dist/lib/models/part-inputs-editor.js +53 -0
- package/dist/lib/models/part-inputs-editor.js.map +1 -0
- package/dist/lib/parts/artifact-part.component.d.ts.map +1 -1
- package/dist/lib/parts/artifact-part.component.js +5 -4
- package/dist/lib/parts/artifact-part.component.js.map +1 -1
- package/dist/lib/parts/base-dashboard-part.d.ts +50 -1
- package/dist/lib/parts/base-dashboard-part.d.ts.map +1 -1
- package/dist/lib/parts/base-dashboard-part.js +108 -1
- package/dist/lib/parts/base-dashboard-part.js.map +1 -1
- package/dist/lib/parts/component-part.component.d.ts +54 -0
- package/dist/lib/parts/component-part.component.d.ts.map +1 -0
- package/dist/lib/parts/component-part.component.js +221 -0
- package/dist/lib/parts/component-part.component.js.map +1 -0
- package/dist/lib/parts/index.d.ts +1 -0
- package/dist/lib/parts/index.d.ts.map +1 -1
- package/dist/lib/parts/index.js +1 -0
- package/dist/lib/parts/index.js.map +1 -1
- package/dist/lib/parts/query-part.component.d.ts +25 -1
- package/dist/lib/parts/query-part.component.d.ts.map +1 -1
- package/dist/lib/parts/query-part.component.js +93 -10
- package/dist/lib/parts/query-part.component.js.map +1 -1
- package/dist/lib/parts/view-part.component.d.ts +18 -1
- package/dist/lib/parts/view-part.component.d.ts.map +1 -1
- package/dist/lib/parts/view-part.component.js +74 -10
- package/dist/lib/parts/view-part.component.js.map +1 -1
- package/dist/lib/parts/weburl-part.component.d.ts +14 -0
- package/dist/lib/parts/weburl-part.component.d.ts.map +1 -1
- package/dist/lib/parts/weburl-part.component.js +62 -5
- package/dist/lib/parts/weburl-part.component.js.map +1 -1
- package/dist/public-api.d.ts +8 -0
- package/dist/public-api.d.ts.map +1 -1
- package/dist/public-api.js +8 -0
- package/dist/public-api.js.map +1 -1
- package/package.json +15 -13
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
import { Component, EventEmitter, Input, Output } from '@angular/core';
|
|
2
|
+
import { CONTEXT_TOKENS, PROPERTY_OFFSET_UNITS, } from '@memberjunction/core';
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
import * as i1 from "@angular/forms";
|
|
5
|
+
function PropertyDefaultEditorComponent_Conditional_8_Conditional_0_Template(rf, ctx) { if (rf & 1) {
|
|
6
|
+
const _r1 = i0.ɵɵgetCurrentView();
|
|
7
|
+
i0.ɵɵelementStart(0, "select", 7);
|
|
8
|
+
i0.ɵɵlistener("ngModelChange", function PropertyDefaultEditorComponent_Conditional_8_Conditional_0_Template_select_ngModelChange_0_listener($event) { i0.ɵɵrestoreView(_r1); const ctx_r1 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r1.SetValue($event)); });
|
|
9
|
+
i0.ɵɵelementStart(1, "option", 8);
|
|
10
|
+
i0.ɵɵtext(2, "(none)");
|
|
11
|
+
i0.ɵɵelementEnd();
|
|
12
|
+
i0.ɵɵelementStart(3, "option", 9);
|
|
13
|
+
i0.ɵɵtext(4, "true");
|
|
14
|
+
i0.ɵɵelementEnd();
|
|
15
|
+
i0.ɵɵelementStart(5, "option", 10);
|
|
16
|
+
i0.ɵɵtext(6, "false");
|
|
17
|
+
i0.ɵɵelementEnd()();
|
|
18
|
+
} if (rf & 2) {
|
|
19
|
+
const ctx_r1 = i0.ɵɵnextContext(2);
|
|
20
|
+
i0.ɵɵproperty("ngModel", ctx_r1.ValueText)("disabled", ctx_r1.Disabled);
|
|
21
|
+
i0.ɵɵattribute("aria-label", ctx_r1.Label);
|
|
22
|
+
} }
|
|
23
|
+
function PropertyDefaultEditorComponent_Conditional_8_Conditional_1_Template(rf, ctx) { if (rf & 1) {
|
|
24
|
+
const _r3 = i0.ɵɵgetCurrentView();
|
|
25
|
+
i0.ɵɵelementStart(0, "input", 11);
|
|
26
|
+
i0.ɵɵlistener("ngModelChange", function PropertyDefaultEditorComponent_Conditional_8_Conditional_1_Template_input_ngModelChange_0_listener($event) { i0.ɵɵrestoreView(_r3); const ctx_r1 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r1.SetValue($event ?? "")); });
|
|
27
|
+
i0.ɵɵelementEnd();
|
|
28
|
+
} if (rf & 2) {
|
|
29
|
+
const ctx_r1 = i0.ɵɵnextContext(2);
|
|
30
|
+
i0.ɵɵproperty("type", ctx_r1.Type === "number" ? "number" : ctx_r1.Type === "date" ? "date" : "text")("ngModel", ctx_r1.ValueText)("disabled", ctx_r1.Disabled);
|
|
31
|
+
i0.ɵɵattribute("aria-label", ctx_r1.Label);
|
|
32
|
+
} }
|
|
33
|
+
function PropertyDefaultEditorComponent_Conditional_8_Template(rf, ctx) { if (rf & 1) {
|
|
34
|
+
i0.ɵɵconditionalCreate(0, PropertyDefaultEditorComponent_Conditional_8_Conditional_0_Template, 7, 3, "select", 5)(1, PropertyDefaultEditorComponent_Conditional_8_Conditional_1_Template, 1, 4, "input", 6);
|
|
35
|
+
} if (rf & 2) {
|
|
36
|
+
const ctx_r1 = i0.ɵɵnextContext();
|
|
37
|
+
i0.ɵɵconditional(ctx_r1.Type === "boolean" ? 0 : 1);
|
|
38
|
+
} }
|
|
39
|
+
function PropertyDefaultEditorComponent_Conditional_9_For_2_Template(rf, ctx) { if (rf & 1) {
|
|
40
|
+
i0.ɵɵelementStart(0, "option", 12);
|
|
41
|
+
i0.ɵɵtext(1);
|
|
42
|
+
i0.ɵɵelementEnd();
|
|
43
|
+
} if (rf & 2) {
|
|
44
|
+
const token_r5 = ctx.$implicit;
|
|
45
|
+
i0.ɵɵproperty("value", token_r5);
|
|
46
|
+
i0.ɵɵadvance();
|
|
47
|
+
i0.ɵɵtextInterpolate(token_r5);
|
|
48
|
+
} }
|
|
49
|
+
function PropertyDefaultEditorComponent_Conditional_9_Conditional_3_For_3_Template(rf, ctx) { if (rf & 1) {
|
|
50
|
+
i0.ɵɵelementStart(0, "option", 12);
|
|
51
|
+
i0.ɵɵtext(1);
|
|
52
|
+
i0.ɵɵelementEnd();
|
|
53
|
+
} if (rf & 2) {
|
|
54
|
+
const unit_r7 = ctx.$implicit;
|
|
55
|
+
i0.ɵɵproperty("value", unit_r7);
|
|
56
|
+
i0.ɵɵadvance();
|
|
57
|
+
i0.ɵɵtextInterpolate(unit_r7);
|
|
58
|
+
} }
|
|
59
|
+
function PropertyDefaultEditorComponent_Conditional_9_Conditional_3_Template(rf, ctx) { if (rf & 1) {
|
|
60
|
+
const _r6 = i0.ɵɵgetCurrentView();
|
|
61
|
+
i0.ɵɵelementStart(0, "input", 13);
|
|
62
|
+
i0.ɵɵlistener("ngModelChange", function PropertyDefaultEditorComponent_Conditional_9_Conditional_3_Template_input_ngModelChange_0_listener($event) { i0.ɵɵrestoreView(_r6); const ctx_r1 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r1.SetOffset($event, (ctx_r1.Default == null ? null : ctx_r1.Default.Offset == null ? null : ctx_r1.Default.Offset.Unit) ?? "day")); });
|
|
63
|
+
i0.ɵɵelementEnd();
|
|
64
|
+
i0.ɵɵelementStart(1, "select", 14);
|
|
65
|
+
i0.ɵɵlistener("ngModelChange", function PropertyDefaultEditorComponent_Conditional_9_Conditional_3_Template_select_ngModelChange_1_listener($event) { i0.ɵɵrestoreView(_r6); const ctx_r1 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r1.SetOffset((ctx_r1.Default == null ? null : ctx_r1.Default.Offset == null ? null : ctx_r1.Default.Offset.Amount) ?? null, $event)); });
|
|
66
|
+
i0.ɵɵrepeaterCreate(2, PropertyDefaultEditorComponent_Conditional_9_Conditional_3_For_3_Template, 2, 2, "option", 12, i0.ɵɵrepeaterTrackByIdentity);
|
|
67
|
+
i0.ɵɵelementEnd();
|
|
68
|
+
} if (rf & 2) {
|
|
69
|
+
const ctx_r1 = i0.ɵɵnextContext(2);
|
|
70
|
+
i0.ɵɵproperty("ngModel", (ctx_r1.Default == null ? null : ctx_r1.Default.Offset == null ? null : ctx_r1.Default.Offset.Amount) ?? null)("disabled", ctx_r1.Disabled);
|
|
71
|
+
i0.ɵɵattribute("aria-label", ctx_r1.Label + " offset");
|
|
72
|
+
i0.ɵɵadvance();
|
|
73
|
+
i0.ɵɵproperty("ngModel", (ctx_r1.Default == null ? null : ctx_r1.Default.Offset == null ? null : ctx_r1.Default.Offset.Unit) ?? "day")("disabled", ctx_r1.Disabled || !(ctx_r1.Default == null ? null : ctx_r1.Default.Offset));
|
|
74
|
+
i0.ɵɵattribute("aria-label", ctx_r1.Label + " offset unit");
|
|
75
|
+
i0.ɵɵadvance();
|
|
76
|
+
i0.ɵɵrepeater(ctx_r1.OffsetUnits);
|
|
77
|
+
} }
|
|
78
|
+
function PropertyDefaultEditorComponent_Conditional_9_Template(rf, ctx) { if (rf & 1) {
|
|
79
|
+
const _r4 = i0.ɵɵgetCurrentView();
|
|
80
|
+
i0.ɵɵelementStart(0, "select", 7);
|
|
81
|
+
i0.ɵɵlistener("ngModelChange", function PropertyDefaultEditorComponent_Conditional_9_Template_select_ngModelChange_0_listener($event) { i0.ɵɵrestoreView(_r4); const ctx_r1 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r1.SetToken($event)); });
|
|
82
|
+
i0.ɵɵrepeaterCreate(1, PropertyDefaultEditorComponent_Conditional_9_For_2_Template, 2, 2, "option", 12, i0.ɵɵrepeaterTrackByIdentity);
|
|
83
|
+
i0.ɵɵelementEnd();
|
|
84
|
+
i0.ɵɵconditionalCreate(3, PropertyDefaultEditorComponent_Conditional_9_Conditional_3_Template, 4, 6);
|
|
85
|
+
} if (rf & 2) {
|
|
86
|
+
const ctx_r1 = i0.ɵɵnextContext();
|
|
87
|
+
i0.ɵɵproperty("ngModel", ctx_r1.Default == null ? null : ctx_r1.Default.Token)("disabled", ctx_r1.Disabled);
|
|
88
|
+
i0.ɵɵattribute("aria-label", ctx_r1.Label + " token");
|
|
89
|
+
i0.ɵɵadvance();
|
|
90
|
+
i0.ɵɵrepeater(ctx_r1.Tokens);
|
|
91
|
+
i0.ɵɵadvance(2);
|
|
92
|
+
i0.ɵɵconditional(ctx_r1.TakesOffset ? 3 : -1);
|
|
93
|
+
} }
|
|
94
|
+
const USER_TOKENS = ['Context.UserID', 'Context.UserEmail', 'Context.UserName'];
|
|
95
|
+
/** A fixed value from what the user typed: a number for a number type, true/false for a boolean, blank for none. */
|
|
96
|
+
export function ParseDefaultValueText(text, type) {
|
|
97
|
+
const trimmed = text.trim();
|
|
98
|
+
if (trimmed.length === 0)
|
|
99
|
+
return null;
|
|
100
|
+
if (type === 'number')
|
|
101
|
+
return Number(trimmed);
|
|
102
|
+
if (type === 'boolean')
|
|
103
|
+
return trimmed === 'true';
|
|
104
|
+
return text;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Edits one default (a dashboard property's, or a part input mapping's): none, a fixed value of the
|
|
108
|
+
* given type, or a context token with an optional offset for date tokens. Every change emits a new
|
|
109
|
+
* default (undefined for none) through `DefaultChange`, so `[(Default)]` works.
|
|
110
|
+
*/
|
|
111
|
+
export class PropertyDefaultEditorComponent {
|
|
112
|
+
/** The default being edited; undefined for none. */
|
|
113
|
+
Default = undefined;
|
|
114
|
+
/** The type a fixed value takes. */
|
|
115
|
+
Type = 'string';
|
|
116
|
+
/** The accessible name of the controls. */
|
|
117
|
+
Label = 'Default';
|
|
118
|
+
/** The text of the "no default" choice. */
|
|
119
|
+
NoneLabel = 'No default';
|
|
120
|
+
Disabled = false;
|
|
121
|
+
DefaultChange = new EventEmitter();
|
|
122
|
+
Tokens = CONTEXT_TOKENS;
|
|
123
|
+
OffsetUnits = PROPERTY_OFFSET_UNITS;
|
|
124
|
+
get Mode() {
|
|
125
|
+
if (!this.Default)
|
|
126
|
+
return 'none';
|
|
127
|
+
return this.Default.Token !== undefined ? 'token' : 'value';
|
|
128
|
+
}
|
|
129
|
+
/** The fixed value as the text an input shows. */
|
|
130
|
+
get ValueText() {
|
|
131
|
+
const value = this.Default?.Value;
|
|
132
|
+
return value === null || value === undefined ? '' : String(value);
|
|
133
|
+
}
|
|
134
|
+
/** True when the default is a date token, which can take an offset. */
|
|
135
|
+
get TakesOffset() {
|
|
136
|
+
return !!this.Default?.Token && !USER_TOKENS.includes(this.Default.Token);
|
|
137
|
+
}
|
|
138
|
+
SetMode(mode) {
|
|
139
|
+
const defaults = {
|
|
140
|
+
none: undefined,
|
|
141
|
+
value: { Value: null },
|
|
142
|
+
token: { Token: this.Type === 'uuid' ? 'Context.UserID' : 'Context.Today' },
|
|
143
|
+
};
|
|
144
|
+
this.emit(defaults[mode]);
|
|
145
|
+
}
|
|
146
|
+
SetValue(text) {
|
|
147
|
+
this.emit({ Value: ParseDefaultValueText(text, this.Type) });
|
|
148
|
+
}
|
|
149
|
+
/** A user token takes no offset, so choosing one drops it. */
|
|
150
|
+
SetToken(token) {
|
|
151
|
+
const offset = USER_TOKENS.includes(token) ? undefined : this.Default?.Offset;
|
|
152
|
+
this.emit(offset ? { Token: token, Offset: offset } : { Token: token });
|
|
153
|
+
}
|
|
154
|
+
/** An offset of 0 (or blank) removes it. */
|
|
155
|
+
SetOffset(amount, unit) {
|
|
156
|
+
const token = this.Default?.Token;
|
|
157
|
+
if (!token)
|
|
158
|
+
return;
|
|
159
|
+
this.emit(amount ? { Token: token, Offset: { Amount: Math.trunc(amount), Unit: unit } } : { Token: token });
|
|
160
|
+
}
|
|
161
|
+
emit(value) {
|
|
162
|
+
this.Default = value;
|
|
163
|
+
this.DefaultChange.emit(value);
|
|
164
|
+
}
|
|
165
|
+
static ɵfac = function PropertyDefaultEditorComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || PropertyDefaultEditorComponent)(); };
|
|
166
|
+
static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: PropertyDefaultEditorComponent, selectors: [["mj-property-default-editor"]], inputs: { Default: "Default", Type: "Type", Label: "Label", NoneLabel: "NoneLabel", Disabled: "Disabled" }, outputs: { DefaultChange: "DefaultChange" }, standalone: false, decls: 10, vars: 6, consts: [[1, "pde"], [1, "mj-input", "pde-mode", 3, "ngModelChange", "ngModel", "disabled"], ["value", "none"], ["value", "value"], ["value", "token"], [1, "mj-input", "pde-value", 3, "ngModel", "disabled"], [1, "mj-input", "pde-value", 3, "type", "ngModel", "disabled"], [1, "mj-input", "pde-value", 3, "ngModelChange", "ngModel", "disabled"], ["value", ""], ["value", "true"], ["value", "false"], [1, "mj-input", "pde-value", 3, "ngModelChange", "type", "ngModel", "disabled"], [3, "value"], ["type", "number", "step", "1", "placeholder", "Offset", 1, "mj-input", "pde-offset", 3, "ngModelChange", "ngModel", "disabled"], [1, "mj-input", "pde-unit", 3, "ngModelChange", "ngModel", "disabled"]], template: function PropertyDefaultEditorComponent_Template(rf, ctx) { if (rf & 1) {
|
|
167
|
+
i0.ɵɵelementStart(0, "div", 0)(1, "select", 1);
|
|
168
|
+
i0.ɵɵlistener("ngModelChange", function PropertyDefaultEditorComponent_Template_select_ngModelChange_1_listener($event) { return ctx.SetMode($event); });
|
|
169
|
+
i0.ɵɵelementStart(2, "option", 2);
|
|
170
|
+
i0.ɵɵtext(3);
|
|
171
|
+
i0.ɵɵelementEnd();
|
|
172
|
+
i0.ɵɵelementStart(4, "option", 3);
|
|
173
|
+
i0.ɵɵtext(5, "Fixed value");
|
|
174
|
+
i0.ɵɵelementEnd();
|
|
175
|
+
i0.ɵɵelementStart(6, "option", 4);
|
|
176
|
+
i0.ɵɵtext(7, "Context token");
|
|
177
|
+
i0.ɵɵelementEnd()();
|
|
178
|
+
i0.ɵɵconditionalCreate(8, PropertyDefaultEditorComponent_Conditional_8_Template, 2, 1);
|
|
179
|
+
i0.ɵɵconditionalCreate(9, PropertyDefaultEditorComponent_Conditional_9_Template, 4, 4);
|
|
180
|
+
i0.ɵɵelementEnd();
|
|
181
|
+
} if (rf & 2) {
|
|
182
|
+
i0.ɵɵadvance();
|
|
183
|
+
i0.ɵɵproperty("ngModel", ctx.Mode)("disabled", ctx.Disabled);
|
|
184
|
+
i0.ɵɵattribute("aria-label", ctx.Label + " kind");
|
|
185
|
+
i0.ɵɵadvance(2);
|
|
186
|
+
i0.ɵɵtextInterpolate(ctx.NoneLabel);
|
|
187
|
+
i0.ɵɵadvance(5);
|
|
188
|
+
i0.ɵɵconditional(ctx.Mode === "value" ? 8 : -1);
|
|
189
|
+
i0.ɵɵadvance();
|
|
190
|
+
i0.ɵɵconditional(ctx.Mode === "token" ? 9 : -1);
|
|
191
|
+
} }, dependencies: [i1.NgSelectOption, i1.ɵNgSelectMultipleOption, i1.DefaultValueAccessor, i1.NumberValueAccessor, i1.SelectControlValueAccessor, i1.NgControlStatus, i1.NgModel], styles: [".pde[_ngcontent-%COMP%] { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }\n .pde-mode[_ngcontent-%COMP%] { flex: 0 0 140px; }\n .pde-value[_ngcontent-%COMP%] { flex: 1 1 140px; min-width: 120px; }\n .pde-offset[_ngcontent-%COMP%] { flex: 0 0 90px; }\n .pde-unit[_ngcontent-%COMP%] { flex: 0 0 100px; }"] });
|
|
192
|
+
}
|
|
193
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(PropertyDefaultEditorComponent, [{
|
|
194
|
+
type: Component,
|
|
195
|
+
args: [{ standalone: false, selector: 'mj-property-default-editor', template: `
|
|
196
|
+
<div class="pde">
|
|
197
|
+
<select class="mj-input pde-mode" [attr.aria-label]="Label + ' kind'" [ngModel]="Mode" (ngModelChange)="SetMode($event)" [disabled]="Disabled">
|
|
198
|
+
<option value="none">{{ NoneLabel }}</option>
|
|
199
|
+
<option value="value">Fixed value</option>
|
|
200
|
+
<option value="token">Context token</option>
|
|
201
|
+
</select>
|
|
202
|
+
@if (Mode === 'value') {
|
|
203
|
+
@if (Type === 'boolean') {
|
|
204
|
+
<select class="mj-input pde-value" [attr.aria-label]="Label" [ngModel]="ValueText" (ngModelChange)="SetValue($event)" [disabled]="Disabled">
|
|
205
|
+
<option value="">(none)</option>
|
|
206
|
+
<option value="true">true</option>
|
|
207
|
+
<option value="false">false</option>
|
|
208
|
+
</select>
|
|
209
|
+
} @else {
|
|
210
|
+
<input class="mj-input pde-value" [attr.aria-label]="Label"
|
|
211
|
+
[type]="Type === 'number' ? 'number' : Type === 'date' ? 'date' : 'text'"
|
|
212
|
+
[ngModel]="ValueText" (ngModelChange)="SetValue($event ?? '')" [disabled]="Disabled" />
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
@if (Mode === 'token') {
|
|
216
|
+
<select class="mj-input pde-value" [attr.aria-label]="Label + ' token'" [ngModel]="Default?.Token" (ngModelChange)="SetToken($event)" [disabled]="Disabled">
|
|
217
|
+
@for (token of Tokens; track token) {
|
|
218
|
+
<option [value]="token">{{ token }}</option>
|
|
219
|
+
}
|
|
220
|
+
</select>
|
|
221
|
+
@if (TakesOffset) {
|
|
222
|
+
<input class="mj-input pde-offset" type="number" step="1" [attr.aria-label]="Label + ' offset'" placeholder="Offset"
|
|
223
|
+
[ngModel]="Default?.Offset?.Amount ?? null" (ngModelChange)="SetOffset($event, Default?.Offset?.Unit ?? 'day')" [disabled]="Disabled" />
|
|
224
|
+
<select class="mj-input pde-unit" [attr.aria-label]="Label + ' offset unit'" [ngModel]="Default?.Offset?.Unit ?? 'day'"
|
|
225
|
+
(ngModelChange)="SetOffset(Default?.Offset?.Amount ?? null, $event)" [disabled]="Disabled || !Default?.Offset">
|
|
226
|
+
@for (unit of OffsetUnits; track unit) {
|
|
227
|
+
<option [value]="unit">{{ unit }}</option>
|
|
228
|
+
}
|
|
229
|
+
</select>
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
</div>
|
|
233
|
+
`, styles: ["\n .pde { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }\n .pde-mode { flex: 0 0 140px; }\n .pde-value { flex: 1 1 140px; min-width: 120px; }\n .pde-offset { flex: 0 0 90px; }\n .pde-unit { flex: 0 0 100px; }\n "] }]
|
|
234
|
+
}], null, { Default: [{
|
|
235
|
+
type: Input
|
|
236
|
+
}], Type: [{
|
|
237
|
+
type: Input
|
|
238
|
+
}], Label: [{
|
|
239
|
+
type: Input
|
|
240
|
+
}], NoneLabel: [{
|
|
241
|
+
type: Input
|
|
242
|
+
}], Disabled: [{
|
|
243
|
+
type: Input
|
|
244
|
+
}], DefaultChange: [{
|
|
245
|
+
type: Output
|
|
246
|
+
}] }); })();
|
|
247
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(PropertyDefaultEditorComponent, { className: "PropertyDefaultEditorComponent", filePath: "src/lib/dialogs/property-default-editor/property-default-editor.component.ts", lineNumber: 81 }); })();
|
|
248
|
+
//# sourceMappingURL=property-default-editor.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"property-default-editor.component.js","sourceRoot":"","sources":["../../../../src/lib/dialogs/property-default-editor/property-default-editor.component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvE,OAAO,EACH,cAAc,EAEd,qBAAqB,GAKxB,MAAM,sBAAsB,CAAC;;;;;IAiClB,iCAA4I;IAAzD,uOAAiB,uBAAgB,KAAC;IACnH,iCAAiB;IAAA,sBAAM;IAAA,iBAAS;IAChC,iCAAqB;IAAA,oBAAI;IAAA,iBAAS;IAClC,kCAAsB;IAAA,qBAAK;IAC7B,AAD6B,iBAAS,EAC7B;;;IAJ6G,AAAzD,0CAAqB,6BAAyD;;;;;IAM3I,iCAEyF;IAAjE,sOAAiB,0BAAmB,EAAE,CAAC,KAAC;IAFhE,iBAEyF;;;IAAxB,AAA/D,AADA,qGAAyE,6BACpD,6BAA+D;;;;IAHtF,AANF,iHAA0B,0FAMjB;;;IANT,mDAUC;;;IAKG,kCAAwB;IAAA,YAAW;IAAA,iBAAS;;;IAApC,gCAAe;IAAC,cAAW;IAAX,8BAAW;;;IASjC,kCAAuB;IAAA,YAAU;IAAA,iBAAS;;;IAAlC,+BAAc;IAAC,cAAU;IAAV,6BAAU;;;;IALrC,iCAC0I;IAA5F,sOAAiB,gIAA2C,KAAK,CAAC,KAAC;IADjH,iBAC0I;IAC1I,kCACiH;IAA/G,uOAAiB,0HAAqC,IAAI,SAAS,KAAC;IACpE,mJAEC;IACH,iBAAS;;;IANyG,AAAhH,uIAA2C,6BAA0F;;IAC1D,cAA0C;IAChD,AADM,sIAA0C,yFACP;;IAC9G,cAEC;IAFD,iCAEC;;;;IAZL,iCAA4J;IAAzD,wNAAiB,uBAAgB,KAAC;IACnI,qIAEC;IACH,iBAAS;IACT,oGAAmB;;;IALmH,AAA9D,8EAA0B,6BAAyD;;IACzJ,cAEC;IAFD,4BAEC;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AC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;IAChH,CAAC;IAEO,IAAI,CAAC,KAAkC;QAC3C,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;QACrB,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACnC,CAAC;wHA5DQ,8BAA8B;6DAA9B,8BAA8B;YA7CnC,AADF,8BAAiB,gBACgI;YAAxD,iIAAiB,mBAAe,IAAC;YACtH,iCAAqB;YAAA,YAAe;YAAA,iBAAS;YAC7C,iCAAsB;YAAA,2BAAW;YAAA,iBAAS;YAC1C,iCAAsB;YAAA,6BAAa;YACrC,AADqC,iBAAS,EACrC;YACT,sFAAwB;YAaxB,sFAAwB;YAiB1B,iBAAM;;YAnCkE,cAAgB;YAAmC,AAAnD,kCAAgB,0BAAwD;;YACvH,eAAe;YAAf,mCAAe;YAItC,eAYC;YAZD,+CAYC;YACD,cAgBC;YAhBD,+CAgBC;;;iFAWI,8BAA8B;cAlD1C,SAAS;6BACM,KAAK,YACP,4BAA4B,YAC5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAsCT;;kBAWA,KAAK;;kBAEL,KAAK;;kBAEL,KAAK;;kBAEL,KAAK;;kBACL,KAAK;;kBACL,MAAM;;kFAVE,8BAA8B","sourcesContent":["import { Component, EventEmitter, Input, Output } from '@angular/core';\nimport {\n CONTEXT_TOKENS,\n ContextToken,\n PROPERTY_OFFSET_UNITS,\n PropertyDefault,\n PropertyOffsetUnit,\n PropertyValue,\n PropertyValueType,\n} from '@memberjunction/core';\n\n/** How a default is given: none, a fixed value, or a context token. */\nexport type PropertyDefaultMode = 'none' | 'value' | 'token';\n\nconst USER_TOKENS: readonly ContextToken[] = ['Context.UserID', 'Context.UserEmail', 'Context.UserName'];\n\n/** A fixed value from what the user typed: a number for a number type, true/false for a boolean, blank for none. */\nexport function ParseDefaultValueText(text: string, type: PropertyValueType): PropertyValue {\n const trimmed = text.trim();\n if (trimmed.length === 0) return null;\n if (type === 'number') return Number(trimmed);\n if (type === 'boolean') return trimmed === 'true';\n return text;\n}\n\n/**\n * Edits one default (a dashboard property's, or a part input mapping's): none, a fixed value of the\n * given type, or a context token with an optional offset for date tokens. Every change emits a new\n * default (undefined for none) through `DefaultChange`, so `[(Default)]` works.\n */\n@Component({\n standalone: false,\n selector: 'mj-property-default-editor',\n template: `\n <div class=\"pde\">\n <select class=\"mj-input pde-mode\" [attr.aria-label]=\"Label + ' kind'\" [ngModel]=\"Mode\" (ngModelChange)=\"SetMode($event)\" [disabled]=\"Disabled\">\n <option value=\"none\">{{ NoneLabel }}</option>\n <option value=\"value\">Fixed value</option>\n <option value=\"token\">Context token</option>\n </select>\n @if (Mode === 'value') {\n @if (Type === 'boolean') {\n <select class=\"mj-input pde-value\" [attr.aria-label]=\"Label\" [ngModel]=\"ValueText\" (ngModelChange)=\"SetValue($event)\" [disabled]=\"Disabled\">\n <option value=\"\">(none)</option>\n <option value=\"true\">true</option>\n <option value=\"false\">false</option>\n </select>\n } @else {\n <input class=\"mj-input pde-value\" [attr.aria-label]=\"Label\"\n [type]=\"Type === 'number' ? 'number' : Type === 'date' ? 'date' : 'text'\"\n [ngModel]=\"ValueText\" (ngModelChange)=\"SetValue($event ?? '')\" [disabled]=\"Disabled\" />\n }\n }\n @if (Mode === 'token') {\n <select class=\"mj-input pde-value\" [attr.aria-label]=\"Label + ' token'\" [ngModel]=\"Default?.Token\" (ngModelChange)=\"SetToken($event)\" [disabled]=\"Disabled\">\n @for (token of Tokens; track token) {\n <option [value]=\"token\">{{ token }}</option>\n }\n </select>\n @if (TakesOffset) {\n <input class=\"mj-input pde-offset\" type=\"number\" step=\"1\" [attr.aria-label]=\"Label + ' offset'\" placeholder=\"Offset\"\n [ngModel]=\"Default?.Offset?.Amount ?? null\" (ngModelChange)=\"SetOffset($event, Default?.Offset?.Unit ?? 'day')\" [disabled]=\"Disabled\" />\n <select class=\"mj-input pde-unit\" [attr.aria-label]=\"Label + ' offset unit'\" [ngModel]=\"Default?.Offset?.Unit ?? 'day'\"\n (ngModelChange)=\"SetOffset(Default?.Offset?.Amount ?? null, $event)\" [disabled]=\"Disabled || !Default?.Offset\">\n @for (unit of OffsetUnits; track unit) {\n <option [value]=\"unit\">{{ unit }}</option>\n }\n </select>\n }\n }\n </div>\n `,\n styles: [`\n .pde { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }\n .pde-mode { flex: 0 0 140px; }\n .pde-value { flex: 1 1 140px; min-width: 120px; }\n .pde-offset { flex: 0 0 90px; }\n .pde-unit { flex: 0 0 100px; }\n `]\n})\nexport class PropertyDefaultEditorComponent {\n /** The default being edited; undefined for none. */\n @Input() Default: PropertyDefault | undefined = undefined;\n /** The type a fixed value takes. */\n @Input() Type: PropertyValueType = 'string';\n /** The accessible name of the controls. */\n @Input() Label = 'Default';\n /** The text of the \"no default\" choice. */\n @Input() NoneLabel = 'No default';\n @Input() Disabled = false;\n @Output() DefaultChange = new EventEmitter<PropertyDefault | undefined>();\n\n public readonly Tokens = CONTEXT_TOKENS;\n public readonly OffsetUnits = PROPERTY_OFFSET_UNITS;\n\n public get Mode(): PropertyDefaultMode {\n if (!this.Default) return 'none';\n return this.Default.Token !== undefined ? 'token' : 'value';\n }\n\n /** The fixed value as the text an input shows. */\n public get ValueText(): string {\n const value = this.Default?.Value;\n return value === null || value === undefined ? '' : String(value);\n }\n\n /** True when the default is a date token, which can take an offset. */\n public get TakesOffset(): boolean {\n return !!this.Default?.Token && !USER_TOKENS.includes(this.Default.Token);\n }\n\n public SetMode(mode: PropertyDefaultMode): void {\n const defaults: Record<PropertyDefaultMode, PropertyDefault | undefined> = {\n none: undefined,\n value: { Value: null },\n token: { Token: this.Type === 'uuid' ? 'Context.UserID' : 'Context.Today' },\n };\n this.emit(defaults[mode]);\n }\n\n public SetValue(text: string): void {\n this.emit({ Value: ParseDefaultValueText(text, this.Type) });\n }\n\n /** A user token takes no offset, so choosing one drops it. */\n public SetToken(token: ContextToken): void {\n const offset = USER_TOKENS.includes(token) ? undefined : this.Default?.Offset;\n this.emit(offset ? { Token: token, Offset: offset } : { Token: token });\n }\n\n /** An offset of 0 (or blank) removes it. */\n public SetOffset(amount: number | null, unit: PropertyOffsetUnit): void {\n const token = this.Default?.Token;\n if (!token) return;\n this.emit(amount ? { Token: token, Offset: { Amount: Math.trunc(amount), Unit: unit } } : { Token: token });\n }\n\n private emit(value: PropertyDefault | undefined): void {\n this.Default = value;\n this.DefaultChange.emit(value);\n }\n}\n"]}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { DashboardPanel } from './dashboard-types';
|
|
2
|
+
import { DashboardPartInputMapping, DashboardPartInterface, DashboardProperty, DashboardWire } from './dashboard-properties';
|
|
3
|
+
/**
|
|
4
|
+
* Problems with a dashboard's properties: a blank or repeated name, an unknown type, or a default
|
|
5
|
+
* that doesn't fit the type (a bad token, a bad offset unit, an offset on a user token).
|
|
6
|
+
*/
|
|
7
|
+
export declare function ValidateDashboardProperties(properties: DashboardProperty[]): string[];
|
|
8
|
+
/**
|
|
9
|
+
* Problems with one part's mappings: an input the part doesn't declare or only the server sets, a
|
|
10
|
+
* property the dashboard doesn't have, mismatched types, a default that doesn't fit the input, or
|
|
11
|
+
* two mappings for one input.
|
|
12
|
+
*/
|
|
13
|
+
export declare function ValidatePartMappings(partTitle: string, mappings: DashboardPartInputMapping[], partInterface: DashboardPartInterface, properties: DashboardProperty[]): string[];
|
|
14
|
+
/**
|
|
15
|
+
* Problems with the wires: a panel not on the dashboard, an event the part doesn't declare, a value
|
|
16
|
+
* the event doesn't carry, a property the dashboard doesn't have, or a value whose type doesn't fit
|
|
17
|
+
* the property. A part whose interface couldn't load is not checked (it shows its own error).
|
|
18
|
+
*/
|
|
19
|
+
export declare function ValidateDashboardWires(wires: DashboardWire[], panels: DashboardPanel[], interfaces: Map<string, DashboardPartInterface | null>, properties: DashboardProperty[]): string[];
|
|
20
|
+
/** What a dashboard's save checks. */
|
|
21
|
+
export interface DashboardBindingsToValidate {
|
|
22
|
+
Properties: DashboardProperty[];
|
|
23
|
+
Wires: DashboardWire[];
|
|
24
|
+
Panels: DashboardPanel[];
|
|
25
|
+
/** Each panel's interface, by panel ID; null when it couldn't load. */
|
|
26
|
+
Interfaces: Map<string, DashboardPartInterface | null>;
|
|
27
|
+
}
|
|
28
|
+
/** Every problem a save refuses: the properties, each part's mappings, and the wires. Empty: save. */
|
|
29
|
+
export declare function ValidateDashboardBindings(bindings: DashboardBindingsToValidate): string[];
|
|
30
|
+
//# sourceMappingURL=dashboard-config-validator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dashboard-config-validator.d.ts","sourceRoot":"","sources":["../../../src/lib/models/dashboard-config-validator.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EACH,yBAAyB,EACzB,sBAAsB,EACtB,iBAAiB,EACjB,aAAa,EAIhB,MAAM,wBAAwB,CAAC;AAEhC;;;GAGG;AACH,wBAAgB,2BAA2B,CAAC,UAAU,EAAE,iBAAiB,EAAE,GAAG,MAAM,EAAE,CAgBrF;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAChC,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,yBAAyB,EAAE,EACrC,aAAa,EAAE,sBAAsB,EACrC,UAAU,EAAE,iBAAiB,EAAE,GAChC,MAAM,EAAE,CAUV;AAWD;;;;GAIG;AACH,wBAAgB,sBAAsB,CAClC,KAAK,EAAE,aAAa,EAAE,EACtB,MAAM,EAAE,cAAc,EAAE,EACxB,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,sBAAsB,GAAG,IAAI,CAAC,EACtD,UAAU,EAAE,iBAAiB,EAAE,GAChC,MAAM,EAAE,CAOV;AAwBD,sCAAsC;AACtC,MAAM,WAAW,2BAA2B;IACxC,UAAU,EAAE,iBAAiB,EAAE,CAAC;IAChC,KAAK,EAAE,aAAa,EAAE,CAAC;IACvB,MAAM,EAAE,cAAc,EAAE,CAAC;IACzB,uEAAuE;IACvE,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,sBAAsB,GAAG,IAAI,CAAC,CAAC;CAC1D;AAED,sGAAsG;AACtG,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,2BAA2B,GAAG,MAAM,EAAE,CAWzF"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Save-time checks for a dashboard's properties, part input mappings and wires (plan § 4 and § 4.1).
|
|
3
|
+
* Plain TypeScript: the part interfaces are loaded first (see dashboard-part-interfaces.ts) and
|
|
4
|
+
* handed in, so these checks run without Angular or a provider.
|
|
5
|
+
*/
|
|
6
|
+
import { PROPERTY_VALUE_TYPES, ValidatePropertyDefault } from '@memberjunction/core';
|
|
7
|
+
import { GetInputMappings, IsTypeCompatible, MappingProblem, } from './dashboard-properties';
|
|
8
|
+
/**
|
|
9
|
+
* Problems with a dashboard's properties: a blank or repeated name, an unknown type, or a default
|
|
10
|
+
* that doesn't fit the type (a bad token, a bad offset unit, an offset on a user token).
|
|
11
|
+
*/
|
|
12
|
+
export function ValidateDashboardProperties(properties) {
|
|
13
|
+
const errors = [];
|
|
14
|
+
const seen = new Set();
|
|
15
|
+
properties.forEach((property, index) => {
|
|
16
|
+
const name = (property.Name ?? '').trim();
|
|
17
|
+
const label = name ? `Property "${name}"` : `Property ${index + 1}`;
|
|
18
|
+
if (!name)
|
|
19
|
+
errors.push(`${label}: Name is required.`);
|
|
20
|
+
if (name && seen.has(name.toLowerCase()))
|
|
21
|
+
errors.push(`${label}: another property has the same name.`);
|
|
22
|
+
seen.add(name.toLowerCase());
|
|
23
|
+
if (!PROPERTY_VALUE_TYPES.includes(property.Type)) {
|
|
24
|
+
errors.push(`${label}: Type must be one of ${PROPERTY_VALUE_TYPES.join(', ')}.`);
|
|
25
|
+
}
|
|
26
|
+
else if (property.Default) {
|
|
27
|
+
errors.push(...ValidatePropertyDefault(property.Default, property.Type).map(e => `${label}: ${e}`));
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
return errors;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Problems with one part's mappings: an input the part doesn't declare or only the server sets, a
|
|
34
|
+
* property the dashboard doesn't have, mismatched types, a default that doesn't fit the input, or
|
|
35
|
+
* two mappings for one input.
|
|
36
|
+
*/
|
|
37
|
+
export function ValidatePartMappings(partTitle, mappings, partInterface, properties) {
|
|
38
|
+
const errors = [];
|
|
39
|
+
const seen = new Set();
|
|
40
|
+
for (const mapping of mappings) {
|
|
41
|
+
if (seen.has(mapping.Input))
|
|
42
|
+
errors.push(`Part "${partTitle}": input "${mapping.Input}" is mapped twice.`);
|
|
43
|
+
seen.add(mapping.Input);
|
|
44
|
+
const problem = MappingProblem(mapping, partInterface.Inputs, properties) ?? defaultProblem(mapping, partInterface);
|
|
45
|
+
if (problem)
|
|
46
|
+
errors.push(`Part "${partTitle}": ${problem}`);
|
|
47
|
+
}
|
|
48
|
+
return errors;
|
|
49
|
+
}
|
|
50
|
+
/** Why a mapping's own default doesn't fit its input, or null. An input typed `any` takes any default. */
|
|
51
|
+
function defaultProblem(mapping, partInterface) {
|
|
52
|
+
const input = partInterface.Inputs.find(i => i.Name === mapping.Input);
|
|
53
|
+
if (!mapping.Default || !input)
|
|
54
|
+
return null;
|
|
55
|
+
const type = input.Type === 'any' || input.Type === 'unsupported' ? 'string' : input.Type;
|
|
56
|
+
const errors = ValidatePropertyDefault(mapping.Default, type);
|
|
57
|
+
return errors.length > 0 ? `the default of input "${mapping.Input}" is invalid: ${errors.join(' ')}` : null;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Problems with the wires: a panel not on the dashboard, an event the part doesn't declare, a value
|
|
61
|
+
* the event doesn't carry, a property the dashboard doesn't have, or a value whose type doesn't fit
|
|
62
|
+
* the property. A part whose interface couldn't load is not checked (it shows its own error).
|
|
63
|
+
*/
|
|
64
|
+
export function ValidateDashboardWires(wires, panels, interfaces, properties) {
|
|
65
|
+
const errors = [];
|
|
66
|
+
wires.forEach((wire, index) => {
|
|
67
|
+
const problem = wireProblem(wire, panels, interfaces, properties);
|
|
68
|
+
if (problem)
|
|
69
|
+
errors.push(`Wire ${index + 1}: ${problem}`);
|
|
70
|
+
});
|
|
71
|
+
return errors;
|
|
72
|
+
}
|
|
73
|
+
function wireProblem(wire, panels, interfaces, properties) {
|
|
74
|
+
const panel = panels.find(p => p.id === wire.Panel);
|
|
75
|
+
if (!panel)
|
|
76
|
+
return `the part it starts from is not on the dashboard.`;
|
|
77
|
+
const property = properties.find(p => p.Name === wire.Property);
|
|
78
|
+
if (!property)
|
|
79
|
+
return `it sets "${wire.Property}", which the dashboard doesn't have.`;
|
|
80
|
+
const partInterface = interfaces.get(panel.id);
|
|
81
|
+
if (!partInterface)
|
|
82
|
+
return null;
|
|
83
|
+
const event = partInterface.Events.find(e => e.Name === wire.Event);
|
|
84
|
+
if (!event)
|
|
85
|
+
return `part "${panel.title}" doesn't raise "${wire.Event}".`;
|
|
86
|
+
const value = event.Values.find(v => v.Name === wire.Value);
|
|
87
|
+
if (!value)
|
|
88
|
+
return `"${wire.Event}" of part "${panel.title}" carries no value "${wire.Value}".`;
|
|
89
|
+
if (!IsTypeCompatible(value.Type, property.Type)) {
|
|
90
|
+
return `"${wire.Value}" (${value.Type}) can't set "${wire.Property}" (${property.Type}).`;
|
|
91
|
+
}
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
/** Every problem a save refuses: the properties, each part's mappings, and the wires. Empty: save. */
|
|
95
|
+
export function ValidateDashboardBindings(bindings) {
|
|
96
|
+
const errors = ValidateDashboardProperties(bindings.Properties);
|
|
97
|
+
for (const panel of bindings.Panels) {
|
|
98
|
+
const mappings = GetInputMappings(panel.config);
|
|
99
|
+
const partInterface = bindings.Interfaces.get(panel.id);
|
|
100
|
+
if (mappings.length > 0 && partInterface) {
|
|
101
|
+
errors.push(...ValidatePartMappings(panel.title, mappings, partInterface, bindings.Properties));
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
errors.push(...ValidateDashboardWires(bindings.Wires, bindings.Panels, bindings.Interfaces, bindings.Properties));
|
|
105
|
+
return errors;
|
|
106
|
+
}
|
|
107
|
+
//# sourceMappingURL=dashboard-config-validator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dashboard-config-validator.js","sourceRoot":"","sources":["../../../src/lib/models/dashboard-config-validator.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAErF,OAAO,EAKH,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,GACjB,MAAM,wBAAwB,CAAC;AAEhC;;;GAGG;AACH,MAAM,UAAU,2BAA2B,CAAC,UAA+B;IACvE,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAC/B,UAAU,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,KAAK,EAAE,EAAE;QACnC,MAAM,IAAI,GAAG,CAAC,QAAQ,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;QAC1C,MAAM,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC,aAAa,IAAI,GAAG,CAAC,CAAC,CAAC,YAAY,KAAK,GAAG,CAAC,EAAE,CAAC;QACpE,IAAI,CAAC,IAAI;YAAE,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,qBAAqB,CAAC,CAAC;QACtD,IAAI,IAAI,IAAI,IAAI,CAAC,GAAG,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EAAE,CAAC;QAC/C,OAAO,IAAI,IAAI,CAAC,KAAK,MAAM,KAAK,CAAC,IAAI,gBAAgB,IAAI,CAAC,QAAQ,MAAM,QAAQ,CAAC,IAAI,IAAI,CAAC;IAC9F,CAAC;IACD,OAAO,IAAI,CAAC;AAChB,CAAC;AAWD,sGAAsG;AACtG,MAAM,UAAU,yBAAyB,CAAC,QAAqC;IAC3E,MAAM,MAAM,GAAG,2BAA2B,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;IAChE,KAAK,MAAM,KAAK,IAAI,QAAQ,CAAC,MAAM,EAAE,CAAC;QAClC,MAAM,QAAQ,GAAG,gBAAgB,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QAChD,MAAM,aAAa,GAAG,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QACxD,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,IAAI,aAAa,EAAE,CAAC;YACvC,MAAM,CAAC,IAAI,CAAC,GAAG,oBAAoB,CAAC,KAAK,CAAC,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC;QACpG,CAAC;IACL,CAAC;IACD,MAAM,CAAC,IAAI,CAAC,GAAG,sBAAsB,CAAC,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,UAAU,EAAE,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC;IAClH,OAAO,MAAM,CAAC;AAClB,CAAC","sourcesContent":["/**\n * Save-time checks for a dashboard's properties, part input mappings and wires (plan § 4 and § 4.1).\n * Plain TypeScript: the part interfaces are loaded first (see dashboard-part-interfaces.ts) and\n * handed in, so these checks run without Angular or a provider.\n */\nimport { PROPERTY_VALUE_TYPES, ValidatePropertyDefault } from '@memberjunction/core';\nimport type { DashboardPanel } from './dashboard-types';\nimport {\n DashboardPartInputMapping,\n DashboardPartInterface,\n DashboardProperty,\n DashboardWire,\n GetInputMappings,\n IsTypeCompatible,\n MappingProblem,\n} from './dashboard-properties';\n\n/**\n * Problems with a dashboard's properties: a blank or repeated name, an unknown type, or a default\n * that doesn't fit the type (a bad token, a bad offset unit, an offset on a user token).\n */\nexport function ValidateDashboardProperties(properties: DashboardProperty[]): string[] {\n const errors: string[] = [];\n const seen = new Set<string>();\n properties.forEach((property, index) => {\n const name = (property.Name ?? '').trim();\n const label = name ? `Property \"${name}\"` : `Property ${index + 1}`;\n if (!name) errors.push(`${label}: Name is required.`);\n if (name && seen.has(name.toLowerCase())) errors.push(`${label}: another property has the same name.`);\n seen.add(name.toLowerCase());\n if (!(PROPERTY_VALUE_TYPES as readonly string[]).includes(property.Type)) {\n errors.push(`${label}: Type must be one of ${PROPERTY_VALUE_TYPES.join(', ')}.`);\n } else if (property.Default) {\n errors.push(...ValidatePropertyDefault(property.Default, property.Type).map(e => `${label}: ${e}`));\n }\n });\n return errors;\n}\n\n/**\n * Problems with one part's mappings: an input the part doesn't declare or only the server sets, a\n * property the dashboard doesn't have, mismatched types, a default that doesn't fit the input, or\n * two mappings for one input.\n */\nexport function ValidatePartMappings(\n partTitle: string,\n mappings: DashboardPartInputMapping[],\n partInterface: DashboardPartInterface,\n properties: DashboardProperty[],\n): string[] {\n const errors: string[] = [];\n const seen = new Set<string>();\n for (const mapping of mappings) {\n if (seen.has(mapping.Input)) errors.push(`Part \"${partTitle}\": input \"${mapping.Input}\" is mapped twice.`);\n seen.add(mapping.Input);\n const problem = MappingProblem(mapping, partInterface.Inputs, properties) ?? defaultProblem(mapping, partInterface);\n if (problem) errors.push(`Part \"${partTitle}\": ${problem}`);\n }\n return errors;\n}\n\n/** Why a mapping's own default doesn't fit its input, or null. An input typed `any` takes any default. */\nfunction defaultProblem(mapping: DashboardPartInputMapping, partInterface: DashboardPartInterface): string | null {\n const input = partInterface.Inputs.find(i => i.Name === mapping.Input);\n if (!mapping.Default || !input) return null;\n const type = input.Type === 'any' || input.Type === 'unsupported' ? 'string' : input.Type;\n const errors = ValidatePropertyDefault(mapping.Default, type);\n return errors.length > 0 ? `the default of input \"${mapping.Input}\" is invalid: ${errors.join(' ')}` : null;\n}\n\n/**\n * Problems with the wires: a panel not on the dashboard, an event the part doesn't declare, a value\n * the event doesn't carry, a property the dashboard doesn't have, or a value whose type doesn't fit\n * the property. A part whose interface couldn't load is not checked (it shows its own error).\n */\nexport function ValidateDashboardWires(\n wires: DashboardWire[],\n panels: DashboardPanel[],\n interfaces: Map<string, DashboardPartInterface | null>,\n properties: DashboardProperty[],\n): string[] {\n const errors: string[] = [];\n wires.forEach((wire, index) => {\n const problem = wireProblem(wire, panels, interfaces, properties);\n if (problem) errors.push(`Wire ${index + 1}: ${problem}`);\n });\n return errors;\n}\n\nfunction wireProblem(\n wire: DashboardWire,\n panels: DashboardPanel[],\n interfaces: Map<string, DashboardPartInterface | null>,\n properties: DashboardProperty[],\n): string | null {\n const panel = panels.find(p => p.id === wire.Panel);\n if (!panel) return `the part it starts from is not on the dashboard.`;\n const property = properties.find(p => p.Name === wire.Property);\n if (!property) return `it sets \"${wire.Property}\", which the dashboard doesn't have.`;\n const partInterface = interfaces.get(panel.id);\n if (!partInterface) return null;\n const event = partInterface.Events.find(e => e.Name === wire.Event);\n if (!event) return `part \"${panel.title}\" doesn't raise \"${wire.Event}\".`;\n const value = event.Values.find(v => v.Name === wire.Value);\n if (!value) return `\"${wire.Event}\" of part \"${panel.title}\" carries no value \"${wire.Value}\".`;\n if (!IsTypeCompatible(value.Type, property.Type)) {\n return `\"${wire.Value}\" (${value.Type}) can't set \"${wire.Property}\" (${property.Type}).`;\n }\n return null;\n}\n\n/** What a dashboard's save checks. */\nexport interface DashboardBindingsToValidate {\n Properties: DashboardProperty[];\n Wires: DashboardWire[];\n Panels: DashboardPanel[];\n /** Each panel's interface, by panel ID; null when it couldn't load. */\n Interfaces: Map<string, DashboardPartInterface | null>;\n}\n\n/** Every problem a save refuses: the properties, each part's mappings, and the wires. Empty: save. */\nexport function ValidateDashboardBindings(bindings: DashboardBindingsToValidate): string[] {\n const errors = ValidateDashboardProperties(bindings.Properties);\n for (const panel of bindings.Panels) {\n const mappings = GetInputMappings(panel.config);\n const partInterface = bindings.Interfaces.get(panel.id);\n if (mappings.length > 0 && partInterface) {\n errors.push(...ValidatePartMappings(panel.title, mappings, partInterface, bindings.Properties));\n }\n }\n errors.push(...ValidateDashboardWires(bindings.Wires, bindings.Panels, bindings.Interfaces, bindings.Properties));\n return errors;\n}\n"]}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What each part type declares (plan § 4 and § 4.1): its inputs and its events.
|
|
3
|
+
*
|
|
4
|
+
* - View: its view's properties (`MJ: User Views.Properties`); `RecordSelected`, carrying the
|
|
5
|
+
* record's fields.
|
|
6
|
+
* - Query: its query's parameters (`MJ: Query Parameters`); `RowSelected`, carrying the row's columns.
|
|
7
|
+
* - Component: its component's declared props and events (`ComponentSpec.properties` / `.events`).
|
|
8
|
+
* - Web URL: the `{Name}` placeholders in its URL; no events.
|
|
9
|
+
* - Artifact (and any other type): nothing.
|
|
10
|
+
*
|
|
11
|
+
* The `...PartInterface` functions are pure; `LoadPartInterface` loads what they need through a provider.
|
|
12
|
+
*/
|
|
13
|
+
import { EntityInfo, IMetadataProvider } from '@memberjunction/core';
|
|
14
|
+
import { MJQueryFieldEntity, MJQueryParameterEntity, MJUserViewEntityExtended } from '@memberjunction/core-entities';
|
|
15
|
+
import type { ComponentSpec } from '@memberjunction/interactive-component-types';
|
|
16
|
+
import type { PanelConfig } from './dashboard-types';
|
|
17
|
+
import { DashboardPartInterface } from './dashboard-properties';
|
|
18
|
+
/** A View part's interface: the view's properties, and `RecordSelected` with the entity's fields. */
|
|
19
|
+
export declare function ViewPartInterface(view: Pick<MJUserViewEntityExtended, 'PropertiesObject'> | null, entity: EntityInfo | null): DashboardPartInterface;
|
|
20
|
+
/** A Query part's interface: the query's parameters, and `RowSelected` with its columns. */
|
|
21
|
+
export declare function QueryPartInterface(parameters: readonly Pick<MJQueryParameterEntity, 'Name' | 'Type' | 'Description' | 'IsRequired' | 'DefaultValue' | 'IsServerSet'>[], fields: readonly Pick<MJQueryFieldEntity, 'Name' | 'SQLBaseType'>[]): DashboardPartInterface;
|
|
22
|
+
/** A Component part's interface: the component's declared props and events. */
|
|
23
|
+
export declare function ComponentPartInterface(spec: Pick<ComponentSpec, 'properties' | 'events'> | null): DashboardPartInterface;
|
|
24
|
+
/** A Web URL part's interface: one required input per `{Name}` placeholder; any value, URL-encoded. */
|
|
25
|
+
export declare function WebUrlPartInterface(url: string | null | undefined): DashboardPartInterface;
|
|
26
|
+
/** The part config keys a Component part keeps. */
|
|
27
|
+
export declare const COMPONENT_NAME_KEY = "componentName";
|
|
28
|
+
export declare const COMPONENT_NAMESPACE_KEY = "componentNamespace";
|
|
29
|
+
export declare const COMPONENT_VERSION_KEY = "componentVersion";
|
|
30
|
+
/**
|
|
31
|
+
* Loads the registered component a Component part names (`MJ: Components` by name, and namespace and
|
|
32
|
+
* version when given; the highest version otherwise) and parses its specification.
|
|
33
|
+
* @throws when the part names no component, none matches, or its specification isn't valid JSON
|
|
34
|
+
*/
|
|
35
|
+
export declare function LoadComponentSpec(config: PanelConfig, provider: IMetadataProvider): Promise<ComponentSpec>;
|
|
36
|
+
/**
|
|
37
|
+
* Loads what a part declares, from its config: through the provider for a View, Query or Component
|
|
38
|
+
* part; from the URL for a Web URL part; nothing for any other type.
|
|
39
|
+
* @throws when the part's view or component can't be loaded
|
|
40
|
+
*/
|
|
41
|
+
export declare function LoadPartInterface(config: PanelConfig | null | undefined, provider: IMetadataProvider): Promise<DashboardPartInterface>;
|
|
42
|
+
//# sourceMappingURL=dashboard-part-interfaces.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dashboard-part-interfaces.d.ts","sourceRoot":"","sources":["../../../src/lib/models/dashboard-part-interfaces.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAC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