@genesislcap/pbc-notify-ui 15.14.0 → 15.14.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/custom-elements.json +1332 -1348
- package/dist/dts/components/foundation-notification-dashboard/components/templates/template-dialog/template-condition-builder/template-condition-builder.d.ts +2 -1
- package/dist/dts/components/foundation-notification-dashboard/components/templates/template-dialog/template-condition-builder/template-condition-builder.d.ts.map +1 -1
- package/dist/dts/components/foundation-notification-dashboard/components/templates/template-dialog/template-dialog.d.ts +1 -0
- package/dist/dts/components/foundation-notification-dashboard/components/templates/template-dialog/template-dialog.d.ts.map +1 -1
- package/dist/dts/react.d.ts +28 -28
- package/dist/dts/services/system.service.d.ts.map +1 -1
- package/dist/esm/components/foundation-notification-dashboard/components/templates/template-dialog/template-condition-builder/template-condition-builder.js +4 -4
- package/dist/esm/components/foundation-notification-dashboard/components/templates/template-dialog/template-dialog.js +27 -13
- package/dist/esm/services/system.service.js +37 -12
- package/dist/react.cjs +30 -30
- package/dist/react.mjs +27 -27
- package/package.json +23 -23
- package/src/components/foundation-notification-dashboard/components/templates/template-dialog/template-condition-builder/template-condition-builder.ts +5 -4
- package/src/components/foundation-notification-dashboard/components/templates/template-dialog/template-dialog.ts +27 -14
- package/src/services/system.service.ts +39 -12
|
@@ -64,6 +64,7 @@ export class TemplateDialog extends AlertSoundAttachmentMixin(GenesisElement) {
|
|
|
64
64
|
@observable resources: Array<string> = [];
|
|
65
65
|
@observable fields: Array<Field> = [];
|
|
66
66
|
@observable topics: Array<string> = [];
|
|
67
|
+
private hydrating = false;
|
|
67
68
|
|
|
68
69
|
private requiredFields = () => [this.name, this.description, this.header, this.message];
|
|
69
70
|
|
|
@@ -82,23 +83,31 @@ export class TemplateDialog extends AlertSoundAttachmentMixin(GenesisElement) {
|
|
|
82
83
|
}
|
|
83
84
|
|
|
84
85
|
public async openDialog(params: any) {
|
|
85
|
-
this.topics = await this.notifyService.getNotifyRouteTopics();
|
|
86
|
-
this.resources = await this.systemService.getResources(); // TODO: Tables + Views
|
|
87
86
|
this.templateDialogMode = params.mode;
|
|
87
|
+
this.hydrating = true;
|
|
88
|
+
this.dialog.show();
|
|
88
89
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
90
|
+
try {
|
|
91
|
+
this.topics = await this.notifyService.getNotifyRouteTopics();
|
|
92
|
+
this.resources = await this.systemService.getResources(); // TODO: Tables + Views
|
|
93
|
+
|
|
94
|
+
switch (params.mode) {
|
|
95
|
+
case TemplateDialogMode.CREATE:
|
|
96
|
+
await this.createTemplate();
|
|
97
|
+
break;
|
|
98
|
+
case TemplateDialogMode.EDIT:
|
|
99
|
+
await this.editTemplate(params.data);
|
|
100
|
+
break;
|
|
101
|
+
default:
|
|
102
|
+
logger.error('Error on TemplateDialogMode');
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
105
|
+
} catch (error) {
|
|
106
|
+
logger.error('Failed to initialize template dialog', error);
|
|
107
|
+
this.close();
|
|
108
|
+
} finally {
|
|
109
|
+
this.hydrating = false;
|
|
99
110
|
}
|
|
100
|
-
|
|
101
|
-
this.dialog.show();
|
|
102
111
|
}
|
|
103
112
|
|
|
104
113
|
close() {
|
|
@@ -262,6 +271,10 @@ export class TemplateDialog extends AlertSoundAttachmentMixin(GenesisElement) {
|
|
|
262
271
|
}
|
|
263
272
|
|
|
264
273
|
async resourceChanged() {
|
|
274
|
+
if (this.hydrating) {
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
|
|
265
278
|
this.conditions = [DynamicRuleUtils.createEmptyCondition()];
|
|
266
279
|
this.fields = await this.systemService.getFields(this.resource);
|
|
267
280
|
this.refreshExpressionPreview();
|
|
@@ -12,6 +12,27 @@ export interface SystemService {
|
|
|
12
12
|
getFields(resource: string): Promise<Field[]>;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
+
function schemaDefinitionToField(name: string, def: unknown): Field {
|
|
16
|
+
const raw = def && typeof def === 'object' ? (def as Record<string, unknown>) : {};
|
|
17
|
+
const oneOf = Array.isArray(raw.oneOf) ? raw.oneOf : [];
|
|
18
|
+
const concrete =
|
|
19
|
+
(oneOf.find((option) => {
|
|
20
|
+
if (!option || typeof option !== 'object') {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
return (option as Record<string, unknown>).type !== 'null';
|
|
24
|
+
}) as Record<string, unknown> | undefined) ?? raw;
|
|
25
|
+
const genesisType = typeof concrete.genesisType === 'string' ? concrete.genesisType : undefined;
|
|
26
|
+
const jsonType = typeof concrete.type === 'string' ? concrete.type : undefined;
|
|
27
|
+
const enumValues = Array.isArray(concrete.enum) ? concrete.enum.map(String) : null;
|
|
28
|
+
|
|
29
|
+
return {
|
|
30
|
+
FIELD_NAME: name,
|
|
31
|
+
FIELD_TYPE: (genesisType ?? jsonType ?? 'STRING').toUpperCase(),
|
|
32
|
+
FIELD_VALUES: enumValues,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
15
36
|
class SystemServiceImpl implements SystemService {
|
|
16
37
|
@Connect private connect: Connect;
|
|
17
38
|
|
|
@@ -27,18 +48,24 @@ class SystemServiceImpl implements SystemService {
|
|
|
27
48
|
return [];
|
|
28
49
|
}
|
|
29
50
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
51
|
+
try {
|
|
52
|
+
const schema = await this.connect.getJSONSchema(resource);
|
|
53
|
+
const reply = schema?.OUTBOUND?.properties?.REPLY;
|
|
54
|
+
if (!reply || typeof reply === 'boolean') {
|
|
55
|
+
return [];
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const items = Array.isArray(reply.items) ? reply.items[0] : reply.items;
|
|
59
|
+
if (!items || typeof items === 'boolean' || !items.properties) {
|
|
60
|
+
return [];
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return Object.entries(items.properties)
|
|
64
|
+
.map(([name, def]) => schemaDefinitionToField(name, def))
|
|
65
|
+
.sort((a, b) => a.FIELD_NAME.localeCompare(b.FIELD_NAME));
|
|
66
|
+
} catch {
|
|
67
|
+
return [];
|
|
68
|
+
}
|
|
42
69
|
}
|
|
43
70
|
}
|
|
44
71
|
|