@genesislcap/blank-app-seed 5.2.0-prerelease.9 → 5.2.0
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/.genx/package.json +1 -1
- package/.genx/templates/react/component/component.hbs +9 -90
- package/.genx/templates/react/entityManager.hbs +57 -62
- package/.genx/templates/web-components/component/component.hbs +10 -62
- package/.genx/templates/web-components/component/component.template.hbs +2 -5
- package/.genx/templates/web-components/entityManager.hbs +2 -23
- package/.genx/utils/formatRouteData.js +0 -12
- package/.genx/utils/generateTile.js +0 -13
- package/.genx/versions.json +1 -1
- package/CHANGELOG.md +31 -31
- package/client-tmp/react/src/custom-elements.d.ts +0 -1
- package/client-tmp/react/src/utils/index.ts +1 -2
- package/client-tmp/web-components/src/utils/index.ts +0 -1
- package/package.json +1 -1
- package/.genx/templates/react/component/component.events.config.hbs +0 -32
- package/.genx/templates/web-components/component/component.events.config.hbs +0 -32
- package/client-tmp/react/src/utils/customEvents.ts +0 -174
- package/client-tmp/web-components/src/utils/customEvents.ts +0 -168
package/.genx/package.json
CHANGED
|
@@ -1,27 +1,16 @@
|
|
|
1
1
|
{{#if tile.config.permissions.viewRight~}}
|
|
2
2
|
import { getUser } from '@genesislcap/foundation-user';
|
|
3
|
-
{
|
|
4
|
-
import { customEvent } from '@genesislcap/foundation-events';
|
|
5
|
-
{{/if}}
|
|
6
|
-
import { getViewUpdateRightComponent{{#if tile.config.customEvents}}, submitFailureNotification{{/if}} } from '../../../utils';
|
|
3
|
+
import { getViewUpdateRightComponent } from '../../../utils';
|
|
7
4
|
import ErrorMessage from '../../../components/ErrorMessage/ErrorMessage';
|
|
8
5
|
{{else if tile.config.permissions.updateRight~}}
|
|
9
6
|
import { getUser } from '@genesislcap/foundation-user';
|
|
10
|
-
{
|
|
11
|
-
import { customEvent } from '@genesislcap/foundation-events';
|
|
12
|
-
{{/if}}
|
|
13
|
-
import { getViewUpdateRightComponent{{#if tile.config.customEvents}}, submitFailureNotification{{/if}} } from '../../../utils';
|
|
7
|
+
import { getViewUpdateRightComponent } from '../../../utils';
|
|
14
8
|
import ErrorMessage from '../../../components/ErrorMessage/ErrorMessage';
|
|
15
9
|
{{/if}}
|
|
16
10
|
{{#if tile.config.customEvents}}
|
|
17
|
-
import { useState, useRef, useEffect } from 'react';
|
|
18
|
-
import { createPortal } from 'react-dom';
|
|
19
11
|
import { getConnect } from '@genesislcap/foundation-comms';
|
|
20
12
|
import type { ActionRendererParams } from '@genesislcap/rapid-grid-pro';
|
|
21
13
|
import { RapidAgActionRenderer } from '@genesislcap/rapid-grid-pro';
|
|
22
|
-
import { Modal } from '@genesislcap/rapid-design-system';
|
|
23
|
-
import { customEvents, customEventFormSchemas } from './{{pascalCase tile.title}}EventsConfig';
|
|
24
|
-
import { useCustomEvent, type CustomEventHandler, type CustomEventState } from '../../../utils/customEvents';
|
|
25
14
|
{{/if}}
|
|
26
15
|
{{#if tile.config.createFormUiSchema~}}
|
|
27
16
|
import { createFormSchema as createFormSchemaTile } from './{{pascalCase tile.title}}CreateFormSchema';
|
|
@@ -44,7 +33,7 @@ import './{{pascalCase tile.title}}Component.css';
|
|
|
44
33
|
{{#ifAny tile.metadata.comment tile.metadata.todo}}
|
|
45
34
|
/**
|
|
46
35
|
{{~#if tile.metadata.comment}}{{{ tile.metadata.comment }}}{{/if}}
|
|
47
|
-
{{~#if tile.metadata.todo}}{{#if tile.metadata.comment}}
|
|
36
|
+
{{~#if tile.metadata.todo}}{{#if tile.metadata.comment}}
|
|
48
37
|
*{{/if}}
|
|
49
38
|
* TODO: {{{ tile.metadata.todo }}}{{/if}}
|
|
50
39
|
*/
|
|
@@ -79,24 +68,17 @@ export const {{pascalCase tile.componentName}}: React.FC = () => {
|
|
|
79
68
|
headerName: '',
|
|
80
69
|
minWidth: 50,
|
|
81
70
|
maxWidth: 50,
|
|
82
|
-
headerTooltip: '{{this.tooltip}}',
|
|
83
71
|
pinned: 'right',
|
|
84
72
|
cellRenderer: RapidAgActionRenderer,
|
|
85
73
|
cellRendererParams: {
|
|
86
74
|
actionClick: async (rowData) => {
|
|
87
|
-
const
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
rowData,
|
|
92
|
-
setCustomEventFormData,
|
|
93
|
-
setActiveCustomEvent
|
|
94
|
-
);
|
|
95
|
-
await handleCustomEvent();
|
|
96
|
-
}
|
|
75
|
+
const { ROW_REF, ...DETAILS } = rowData;
|
|
76
|
+
const response = await getConnect().commitEvent("EVENT_{{this}}", {
|
|
77
|
+
DETAILS,
|
|
78
|
+
});
|
|
97
79
|
},
|
|
98
80
|
contentTemplate: `
|
|
99
|
-
<rapid-icon name="
|
|
81
|
+
<rapid-icon name="cog"></rapid-icon>
|
|
100
82
|
`,
|
|
101
83
|
} as ActionRendererParams,
|
|
102
84
|
},
|
|
@@ -132,70 +114,7 @@ export const {{pascalCase tile.componentName}}: React.FC = () => {
|
|
|
132
114
|
};
|
|
133
115
|
{{/if}}
|
|
134
116
|
|
|
135
|
-
{{#if tile.config.customEvents}}
|
|
136
|
-
const customEventModalRef = useRef<Modal>(null);
|
|
137
|
-
const [activeCustomEvent, setActiveCustomEvent] = useState<CustomEventState | null>(null);
|
|
138
|
-
const [customEventFormData, setCustomEventFormData] = useState<Record<string, any>>({});
|
|
139
|
-
|
|
140
|
-
useEffect(() => {
|
|
141
|
-
if (activeCustomEvent) {
|
|
142
|
-
customEventModalRef.current?.show();
|
|
143
|
-
} else {
|
|
144
|
-
customEventModalRef.current?.close();
|
|
145
|
-
}
|
|
146
|
-
}, [activeCustomEvent]);
|
|
147
|
-
|
|
148
|
-
const handleCustomEventSubmit = () => {
|
|
149
|
-
setActiveCustomEvent(null);
|
|
150
|
-
setCustomEventFormData({});
|
|
151
|
-
};
|
|
152
|
-
|
|
153
|
-
const getActiveCustomEvent = () => {
|
|
154
|
-
if (!activeCustomEvent) return null;
|
|
155
|
-
return customEvents.find(e => e.name === activeCustomEvent.name);
|
|
156
|
-
};
|
|
157
|
-
|
|
158
|
-
const getCustomEventModalTitle = () => {
|
|
159
|
-
const customEvent = getActiveCustomEvent();
|
|
160
|
-
return customEvent?.name || 'Custom Event';
|
|
161
|
-
};
|
|
162
|
-
|
|
163
|
-
const getCustomEventResourceName = () => {
|
|
164
|
-
if (!activeCustomEvent) return '';
|
|
165
|
-
return `EVENT_${activeCustomEvent.event}`;
|
|
166
|
-
};
|
|
167
|
-
|
|
168
|
-
const getCustomEventUiSchema = () => {
|
|
169
|
-
const customEvent = getActiveCustomEvent();
|
|
170
|
-
return customEvent && customEvent.name in customEventFormSchemas
|
|
171
|
-
? customEventFormSchemas[customEvent.name as keyof typeof customEventFormSchemas]
|
|
172
|
-
: null;
|
|
173
|
-
};
|
|
174
|
-
|
|
175
|
-
const renderFormModal = () => {
|
|
176
|
-
if (!activeCustomEvent) return null;
|
|
177
|
-
|
|
178
|
-
return createPortal(
|
|
179
|
-
<rapid-modal
|
|
180
|
-
ref={customEventModalRef}
|
|
181
|
-
onCloseCallback={() => setActiveCustomEvent(null)}
|
|
182
|
-
>
|
|
183
|
-
<h4 slot="top">{getCustomEventModalTitle()}</h4>
|
|
184
|
-
<foundation-form
|
|
185
|
-
resourceName={getCustomEventResourceName()}
|
|
186
|
-
uischema={getCustomEventUiSchema()}
|
|
187
|
-
data={customEventFormData}
|
|
188
|
-
onsubmit-success={handleCustomEventSubmit}
|
|
189
|
-
onsubmit={submitFailureNotification}
|
|
190
|
-
onsubmit-failure={submitFailureNotification}
|
|
191
|
-
></foundation-form>
|
|
192
|
-
</rapid-modal>,
|
|
193
|
-
document.querySelector('rapid-design-system-provider')!
|
|
194
|
-
);
|
|
195
|
-
};
|
|
196
|
-
{{/if}}
|
|
197
|
-
|
|
198
117
|
return (
|
|
199
118
|
{{> (lookup tile 'type') tile}}
|
|
200
119
|
);
|
|
201
|
-
};
|
|
120
|
+
};
|
|
@@ -1,68 +1,63 @@
|
|
|
1
1
|
{{#if config.permissions.viewRight~}}
|
|
2
2
|
hasUserPermission('{{config.permissions.viewRight}}') ? (
|
|
3
3
|
{{/if}}
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
></entity-management>
|
|
62
|
-
{{#if config.customEvents}}
|
|
63
|
-
{renderFormModal()}
|
|
64
|
-
{{/if}}
|
|
65
|
-
</>
|
|
4
|
+
<entity-management
|
|
5
|
+
design-system-prefix="rapid"
|
|
6
|
+
enable-row-flashing
|
|
7
|
+
enable-cell-flashing
|
|
8
|
+
{{#if config.title~}}
|
|
9
|
+
title="{{ config.title }}"
|
|
10
|
+
{{/if}}
|
|
11
|
+
resourceName="{{ config.resourceName }}"
|
|
12
|
+
{{#if config.createEvent~}}
|
|
13
|
+
{{#if config.permissions.updateRight~}}
|
|
14
|
+
createEvent={hasUserPermission('{{config.permissions.updateRight}}') ? '{{ config.createEvent }}' : undefined}
|
|
15
|
+
{{else~}}
|
|
16
|
+
createEvent="{{ config.createEvent }}"
|
|
17
|
+
{{/if}}
|
|
18
|
+
{{#if config.createFormUiSchema~}}
|
|
19
|
+
createFormUiSchema={createFormSchema}
|
|
20
|
+
{{/if}}
|
|
21
|
+
{{/if}}
|
|
22
|
+
{{#if config.updateEvent~}}
|
|
23
|
+
{{#if config.permissions.updateRight~}}
|
|
24
|
+
updateEvent={hasUserPermission('{{config.permissions.updateRight}}') ? '{{ config.updateEvent }}' : undefined}
|
|
25
|
+
{{else~}}
|
|
26
|
+
updateEvent="{{ config.updateEvent }}"
|
|
27
|
+
{{/if}}
|
|
28
|
+
{{#if config.updateFormUiSchema~}}
|
|
29
|
+
updateFormUiSchema={updateFormSchema}
|
|
30
|
+
{{/if}}
|
|
31
|
+
{{/if}}
|
|
32
|
+
{{#if config.deleteEvent~}}
|
|
33
|
+
{{#if config.permissions.updateRight~}}
|
|
34
|
+
deleteEvent={hasUserPermission('{{config.permissions.updateRight}}') ? '{{ config.deleteEvent }}' : undefined}
|
|
35
|
+
{{else~}}
|
|
36
|
+
deleteEvent="{{ config.deleteEvent }}"
|
|
37
|
+
{{/if}}
|
|
38
|
+
{{/if}}
|
|
39
|
+
{{#if config.gridOptions~}}
|
|
40
|
+
gridOptions={gridOptions}
|
|
41
|
+
{{/if}}
|
|
42
|
+
{{#if config.snapshot~}}
|
|
43
|
+
datasourceConfig={ isSnapshot: {{ config.snapshot }} }
|
|
44
|
+
{{/if}}
|
|
45
|
+
{{#if config.reqrep~}}
|
|
46
|
+
datasourceConfig={reqrep}
|
|
47
|
+
{{/if}}
|
|
48
|
+
{{#if config.columns~}}
|
|
49
|
+
columns={columnDefs}
|
|
50
|
+
{{/if}}
|
|
51
|
+
{{#if config.modalPosition~}}
|
|
52
|
+
modal-position="{{ config.modalPosition }}"
|
|
53
|
+
{{/if}}
|
|
54
|
+
{{#if config.sizeColumnsToFit~}}
|
|
55
|
+
size-columns-to-fit
|
|
56
|
+
{{/if}}
|
|
57
|
+
{{#if config.enableSearchBar~}}
|
|
58
|
+
enable-search-bar
|
|
59
|
+
{{/if}}
|
|
60
|
+
></entity-management>
|
|
66
61
|
{{#if config.permissions.viewRight~}}
|
|
67
62
|
) : (
|
|
68
63
|
<ErrorMessage elementType="h3" message="You do not have access to view this component." />
|
|
@@ -10,9 +10,6 @@ import { ColDef } from '@ag-grid-community/core';
|
|
|
10
10
|
{{#if tile.config.customEvents}}
|
|
11
11
|
import type { ActionRendererParams } from '@genesislcap/rapid-grid-pro';
|
|
12
12
|
import { RapidAgActionRenderer } from '@genesislcap/rapid-grid-pro';
|
|
13
|
-
import { Modal } from '@genesislcap/rapid-design-system';
|
|
14
|
-
import { customEvents, customEventFormSchemas } from './{{kebabCase tile.title}}.events.config';
|
|
15
|
-
import { handleFormCustomEvent, handleNonFormCustomEvent, showCustomEventConfirmation, type CustomEventHandler, type CustomEventState } from '../../../utils/customEvents';
|
|
16
13
|
{{/if}}
|
|
17
14
|
|
|
18
15
|
{{#ifAny tile.metadata.comment tile.metadata.todo}}
|
|
@@ -33,81 +30,32 @@ export class {{pascalCase tile.componentName}} extends GenesisElement {
|
|
|
33
30
|
@User user: User;
|
|
34
31
|
@Connect connect!: Connect;
|
|
35
32
|
|
|
36
|
-
{{#if tile.config.customEvents}}
|
|
37
|
-
customEventModal: Modal;
|
|
38
|
-
@observable customEvents: CustomEventHandler[] = customEvents;
|
|
39
|
-
@observable activeCustomEvent: CustomEventState | null = null;
|
|
40
|
-
@observable customEventFormData: Record<string, any> = {};
|
|
41
|
-
|
|
42
|
-
async handleCustomEventSubmit() {
|
|
43
|
-
this.activeCustomEvent = null;
|
|
44
|
-
this.customEventFormData = {};
|
|
45
|
-
this.customEventModal.close();
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
async handleCustomEventClick(eventName: string, rowData: any) {
|
|
49
|
-
const customEvent = this.customEvents.find(e => e.name === eventName);
|
|
50
|
-
if (!customEvent) return;
|
|
51
|
-
|
|
52
|
-
if (customEvent.hasForm) {
|
|
53
|
-
handleFormCustomEvent(
|
|
54
|
-
customEvent,
|
|
55
|
-
rowData,
|
|
56
|
-
(data) => this.customEventFormData = data,
|
|
57
|
-
(event) => this.activeCustomEvent = event,
|
|
58
|
-
() => this.customEventModal.show()
|
|
59
|
-
);
|
|
60
|
-
} else {
|
|
61
|
-
await handleNonFormCustomEvent(
|
|
62
|
-
this.connect,
|
|
63
|
-
customEvent,
|
|
64
|
-
rowData,
|
|
65
|
-
(onConfirm) => showCustomEventConfirmation(customEvent, onConfirm)
|
|
66
|
-
);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
getActiveCustomEvent() {
|
|
71
|
-
if (!this.activeCustomEvent) return null;
|
|
72
|
-
return this.customEvents.find(e => e.name === this.activeCustomEvent.name);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
getCustomEventModalTitle() {
|
|
76
|
-
const customEvent = this.getActiveCustomEvent();
|
|
77
|
-
return customEvent?.name || 'Custom Event';
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
getCustomEventResourceName() {
|
|
81
|
-
if (!this.activeCustomEvent) return '';
|
|
82
|
-
return `EVENT_${this.activeCustomEvent.event}`;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
getCustomEventUiSchema() {
|
|
86
|
-
const customEvent = this.getActiveCustomEvent();
|
|
87
|
-
if (!customEvent) return null;
|
|
88
|
-
return customEventFormSchemas[customEvent.name];
|
|
89
|
-
}
|
|
90
|
-
{{/if}}
|
|
91
|
-
|
|
92
33
|
{{#if tile.config.columns}}
|
|
93
34
|
@observable columns: ColDef[] = [
|
|
94
35
|
...columnDefs,
|
|
95
36
|
{{#if tile.config.customEvents}}
|
|
37
|
+
/**
|
|
38
|
+
* TODO: Update the action button's icon under `contentTemplate` below.
|
|
39
|
+
* More information about rapid-icon can be found at: https://docs.genesis.global/docs/develop/client-capabilities/presentation/client-presentation-icon/
|
|
40
|
+
**/
|
|
96
41
|
{{#each tile.config.customEvents}}
|
|
97
42
|
{
|
|
98
43
|
field: '',
|
|
99
44
|
headerName: '',
|
|
100
45
|
minWidth: 50,
|
|
101
46
|
maxWidth: 50,
|
|
102
|
-
headerTooltip: '{{this
|
|
47
|
+
headerTooltip: '{{capitalCase this}}',
|
|
103
48
|
pinned: 'right',
|
|
104
49
|
cellRenderer: RapidAgActionRenderer,
|
|
105
50
|
cellRendererParams: <ActionRendererParams>{
|
|
106
51
|
actionClick: async (rowData) => {
|
|
107
|
-
|
|
52
|
+
const { ROW_REF, ...DETAILS } = rowData;
|
|
53
|
+
const response = await this.connect.commitEvent("EVENT_{{this}}", {
|
|
54
|
+
DETAILS,
|
|
55
|
+
});
|
|
108
56
|
},
|
|
109
57
|
contentTemplate: `
|
|
110
|
-
<rapid-icon name="
|
|
58
|
+
<rapid-icon name="cog"></rapid-icon>
|
|
111
59
|
`,
|
|
112
60
|
},
|
|
113
61
|
},
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import { html,
|
|
2
|
-
{
|
|
3
|
-
import { customEvent } from '@genesislcap/foundation-events';
|
|
4
|
-
{{/if}}
|
|
5
|
-
import { getViewUpdateRightComponent{{#if tile.config.customEvents}}, submitFailureNotification{{/if}} } from '../../../utils';
|
|
1
|
+
import { html, whenElse, repeat } from '@genesislcap/web-core';
|
|
2
|
+
import { getViewUpdateRightComponent } from '../../../utils';
|
|
6
3
|
import type { {{pascalCase tile.componentName}} } from './{{kebabCase tile.title}}';
|
|
7
4
|
{{#if tile.config.createFormUiSchema}}
|
|
8
5
|
import { createFormSchema } from './{{kebabCase tile.title}}.create.form.schema';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
${whenElse(
|
|
2
2
|
(x) => getViewUpdateRightComponent(x.user, '{{config.permissions.viewRight}}'),
|
|
3
|
-
html
|
|
3
|
+
html`
|
|
4
4
|
<entity-management
|
|
5
5
|
design-system-prefix="rapid"
|
|
6
6
|
header-case-type="capitalCase"
|
|
@@ -50,29 +50,8 @@ ${whenElse(
|
|
|
50
50
|
enable-search-bar
|
|
51
51
|
{{/if}}
|
|
52
52
|
></entity-management>
|
|
53
|
-
{{#if config.customEvents}}
|
|
54
|
-
<rapid-modal
|
|
55
|
-
${ref('customEventModal')}
|
|
56
|
-
:onCloseCallback=${(x) => (x.activeCustomEvent = null)}
|
|
57
|
-
>
|
|
58
|
-
<h4 slot="top">${(x) => x.getCustomEventModalTitle()}</h4>
|
|
59
|
-
${when(
|
|
60
|
-
(x) => x.activeCustomEvent,
|
|
61
|
-
html`
|
|
62
|
-
<foundation-form
|
|
63
|
-
resourceName=${(x) => x.getCustomEventResourceName()}
|
|
64
|
-
:uischema=${(x) => x.getCustomEventUiSchema()}
|
|
65
|
-
:data=${(x) => x.customEventFormData}
|
|
66
|
-
@submit-success=${(x) => x.handleCustomEventSubmit()}
|
|
67
|
-
@submit=${(_, c) => submitFailureNotification(customEvent(c))}
|
|
68
|
-
@submit-failure=${(_, c) => submitFailureNotification(customEvent(c))}
|
|
69
|
-
></foundation-form>
|
|
70
|
-
`,
|
|
71
|
-
)}
|
|
72
|
-
</rapid-modal>
|
|
73
|
-
{{/if}}
|
|
74
53
|
`,
|
|
75
54
|
html`
|
|
76
55
|
<not-permitted-component></not-permitted-component>
|
|
77
56
|
`,
|
|
78
|
-
)}
|
|
57
|
+
)}
|
|
@@ -7,16 +7,6 @@ const { getFormattedComment, getFormattedTodo } = require('./getTodosAndComments
|
|
|
7
7
|
const getLayoutType = require('./getLayoutType');
|
|
8
8
|
const { COMPONENT_TYPE, FRAMEWORK_ANGULAR_ALIAS } = require('../static');
|
|
9
9
|
|
|
10
|
-
const formatCustomEvents = (customEvents) => {
|
|
11
|
-
if (!customEvents) return;
|
|
12
|
-
|
|
13
|
-
return customEvents.map(event => ({
|
|
14
|
-
...event,
|
|
15
|
-
uischema: event.hasForm ? formatJSONValue(event.uischema) : undefined,
|
|
16
|
-
defaultValues: event.defaultValues ? formatJSONValue(event.defaultValues) : undefined,
|
|
17
|
-
}));
|
|
18
|
-
};
|
|
19
|
-
|
|
20
10
|
const formatRouteData = (framework, route) => {
|
|
21
11
|
const layoutKey = route?.layoutKey || `${route.name}_${Date.now()}`;
|
|
22
12
|
const layoutType =
|
|
@@ -42,7 +32,6 @@ const formatRouteData = (framework, route) => {
|
|
|
42
32
|
updateFormUiSchema,
|
|
43
33
|
uischema,
|
|
44
34
|
columns,
|
|
45
|
-
customEvents,
|
|
46
35
|
} = config;
|
|
47
36
|
|
|
48
37
|
return {
|
|
@@ -58,7 +47,6 @@ const formatRouteData = (framework, route) => {
|
|
|
58
47
|
updateFormUiSchema: formatJSONValue(updateFormUiSchema),
|
|
59
48
|
uischema: formatJSONValue(uischema),
|
|
60
49
|
columns: gridColumnsSerializer(columns),
|
|
61
|
-
customEvents: formatCustomEvents(customEvents),
|
|
62
50
|
},
|
|
63
51
|
metadata: {
|
|
64
52
|
...metadata,
|
|
@@ -17,8 +17,6 @@ const defaultPathGetters = {
|
|
|
17
17
|
`${componentPath}/${tile.name}.column.defs.ts`,
|
|
18
18
|
gridOptions: (componentPath, tile) =>
|
|
19
19
|
`${componentPath}/${tile.name}.gridOptions.ts`,
|
|
20
|
-
customEventForm: (componentPath, tile) =>
|
|
21
|
-
`${componentPath}/${tile.name}.events.config.ts`,
|
|
22
20
|
};
|
|
23
21
|
|
|
24
22
|
const getPathByFramework = {
|
|
@@ -62,8 +60,6 @@ const getPathByFramework = {
|
|
|
62
60
|
`${componentPath}/${changeCase.pascalCase(tile.name)}ColumnDefs.ts`,
|
|
63
61
|
gridOptions: (componentPath, tile, changeCase) =>
|
|
64
62
|
`${componentPath}/${changeCase.pascalCase(tile.name)}GridOptions.ts`,
|
|
65
|
-
customEventForm: (componentPath, tile, changeCase) =>
|
|
66
|
-
`${componentPath}/${changeCase.pascalCase(tile.name)}EventsConfig.ts`,
|
|
67
63
|
},
|
|
68
64
|
};
|
|
69
65
|
|
|
@@ -85,7 +81,6 @@ const getFilesToWrite = (
|
|
|
85
81
|
updateForm: getUpdateFormTarget,
|
|
86
82
|
columnDefs: getColumnDefsTarget,
|
|
87
83
|
gridOptions: getGridOptionsTarget,
|
|
88
|
-
customEventForm: getCustomEventFormTarget,
|
|
89
84
|
} = path;
|
|
90
85
|
|
|
91
86
|
const routeDir = getRouteDir(clientSrcPath, tileData, routeName, changeCase);
|
|
@@ -125,11 +120,6 @@ const getFilesToWrite = (
|
|
|
125
120
|
target: getGridOptionsTarget(routeDir, tileData, changeCase),
|
|
126
121
|
};
|
|
127
122
|
|
|
128
|
-
const componentCustomEventFormFile = {
|
|
129
|
-
source: `${sourceTemplateDir}/component/component.events.config.hbs`,
|
|
130
|
-
target: getCustomEventFormTarget(routeDir, tileData, changeCase),
|
|
131
|
-
};
|
|
132
|
-
|
|
133
123
|
const filesToWrite = [componentIndexFile, componentFile, componentStylesFile];
|
|
134
124
|
|
|
135
125
|
if (getTemplateTarget) {
|
|
@@ -153,9 +143,6 @@ const getFilesToWrite = (
|
|
|
153
143
|
if (tileData.config?.updateFormUiSchema) {
|
|
154
144
|
filesToWrite.push(componentUpdateFormFile);
|
|
155
145
|
}
|
|
156
|
-
if (tileData.config?.customEvents) {
|
|
157
|
-
filesToWrite.push(componentCustomEventFormFile);
|
|
158
|
-
}
|
|
159
146
|
break;
|
|
160
147
|
case 'grid-pro':
|
|
161
148
|
if (tileData.config?.gridOptions) {
|
package/.genx/versions.json
CHANGED
package/CHANGELOG.md
CHANGED
|
@@ -1,43 +1,43 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
## [5.2.0
|
|
3
|
+
## [5.2.0](https://github.com/genesiscommunitysuccess/blank-app-seed/compare/v5.1.2...v5.2.0) (2025-06-24)
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
###
|
|
7
|
-
|
|
8
|
-
* updating server version information for GSF [PSD-0](https://github.com/genesiscommunitysuccess/blank-app-seed/issues/0) 60b47dc
|
|
9
|
-
|
|
10
|
-
## [5.2.0-prerelease.8](https://github.com/genesiscommunitysuccess/blank-app-seed/compare/v5.2.0-prerelease.7...v5.2.0-prerelease.8) (2025-07-01)
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
### Bug Fixes
|
|
14
|
-
|
|
15
|
-
* show server errors in form GENC-1116 (#479) 3cc189f
|
|
16
|
-
|
|
17
|
-
## [5.2.0-prerelease.7](https://github.com/genesiscommunitysuccess/blank-app-seed/compare/v5.2.0-prerelease.6...v5.2.0-prerelease.7) (2025-07-01)
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
### Bug Fixes
|
|
21
|
-
|
|
22
|
-
* show title in custom events modal GENC-0 6998f64
|
|
23
|
-
* show title in custom events modal GENC-0 d31f9f3
|
|
24
|
-
* show title in custom events modal GENC-0 (#480) f05aa72
|
|
6
|
+
### Features
|
|
25
7
|
|
|
26
|
-
|
|
8
|
+
* advanced custom events - react GENC-1002 13c6bda
|
|
9
|
+
* advanced custom events (react/web-components) GENC-1002 (#472) 2117a89
|
|
10
|
+
* advanced custom events GENC-1002 e31a875
|
|
11
|
+
* bump GSF to 8.12 [PSD-0](https://github.com/genesiscommunitysuccess/blank-app-seed/issues/0) abfa76c
|
|
12
|
+
* bump GSF to 8.12 [PSD-0](https://github.com/genesiscommunitysuccess/blank-app-seed/issues/0) (#474) 33f5d7c
|
|
13
|
+
* bump GSF to 8.12 [PSD-0](https://github.com/genesiscommunitysuccess/blank-app-seed/issues/0) (#476) 1f4849d
|
|
27
14
|
|
|
28
15
|
|
|
29
16
|
### Bug Fixes
|
|
30
17
|
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
*
|
|
40
|
-
*
|
|
18
|
+
* addressed PR feedback GENC-1002 fca014a
|
|
19
|
+
* automated dependency version update [skip-ci] [PSD-9](https://github.com/genesiscommunitysuccess/blank-app-seed/issues/9) 7b0804f
|
|
20
|
+
* automated dependency version update [skip-ci] [PSD-9](https://github.com/genesiscommunitysuccess/blank-app-seed/issues/9) (#470) 4ab2bd3
|
|
21
|
+
* lint errors GENC-1002 08e5d58
|
|
22
|
+
* react bug fixes fd97f2b
|
|
23
|
+
* react bug fixes (#471) b3bafdb
|
|
24
|
+
* react router fixes b6d4754
|
|
25
|
+
* react router fixes (#469) 12e9d1e
|
|
26
|
+
* removed deprecated package inbox 118fb20
|
|
27
|
+
* removed deprecated package inbox (#468) a6f2e42
|
|
28
|
+
* removed deprecated package login 04aa0bc
|
|
29
|
+
* removed deprecated package login 5870b1a
|
|
30
|
+
* revert advanced custom events [PSD-0](https://github.com/genesiscommunitysuccess/blank-app-seed/issues/0) (#473) 892042b
|
|
31
|
+
* updating server version information for Auth [PSD-0](https://github.com/genesiscommunitysuccess/blank-app-seed/issues/0) 278a23a
|
|
32
|
+
* updating server version information for Auth [PSD-0](https://github.com/genesiscommunitysuccess/blank-app-seed/issues/0) 231a029
|
|
33
|
+
* updating server version information for Auth [PSD-0](https://github.com/genesiscommunitysuccess/blank-app-seed/issues/0) 6c2de4b
|
|
34
|
+
* updating server version information for Auth [PSD-0](https://github.com/genesiscommunitysuccess/blank-app-seed/issues/0) 24ff468
|
|
35
|
+
* updating server version information for Auth [PSD-0](https://github.com/genesiscommunitysuccess/blank-app-seed/issues/0) 19f16a4
|
|
36
|
+
* updating server version information for GSF [PSD-0](https://github.com/genesiscommunitysuccess/blank-app-seed/issues/0) 5dc228c
|
|
37
|
+
* updating server version information for GSF [PSD-0](https://github.com/genesiscommunitysuccess/blank-app-seed/issues/0) 0f969da
|
|
38
|
+
* updating server version information for GSF [PSD-0](https://github.com/genesiscommunitysuccess/blank-app-seed/issues/0) 9c6249c
|
|
39
|
+
* updating server version information for GSF [PSD-0](https://github.com/genesiscommunitysuccess/blank-app-seed/issues/0) 8f014d9
|
|
40
|
+
* updating server version information for GSF [PSD-0](https://github.com/genesiscommunitysuccess/blank-app-seed/issues/0) c46e67f
|
|
41
41
|
|
|
42
42
|
## [5.2.0-prerelease.4](https://github.com/genesiscommunitysuccess/blank-app-seed/compare/v5.2.0-prerelease.3...v5.2.0-prerelease.4) (2025-06-24)
|
|
43
43
|
|
|
@@ -14,7 +14,6 @@ declare module "react/jsx-runtime" {
|
|
|
14
14
|
'rapid-g2plot-chart': CustomElement;
|
|
15
15
|
'chart-datasource': CustomElement;
|
|
16
16
|
'client-app-login': CustomElement;
|
|
17
|
-
'rapid-modal': CustomElement;
|
|
18
17
|
'rapid-layout': CustomElement;
|
|
19
18
|
'rapid-layout-region': CustomElement;
|
|
20
19
|
'rapid-layout-item': CustomElement;
|
package/package.json
CHANGED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { CustomEventHandler } from "../../../utils/customEvents";
|
|
2
|
-
|
|
3
|
-
{{#each tile.config.customEvents}}
|
|
4
|
-
{{#if this.hasForm}}
|
|
5
|
-
export const {{camelCase this.name}}FormSchema = {{{this.uischema}}};
|
|
6
|
-
{{/if}}
|
|
7
|
-
{{/each}}
|
|
8
|
-
|
|
9
|
-
export const customEventFormSchemas = {
|
|
10
|
-
{{#each tile.config.customEvents}}
|
|
11
|
-
{{#if this.hasForm}}
|
|
12
|
-
'{{this.name}}': {{camelCase this.name}}FormSchema,
|
|
13
|
-
{{/if}}
|
|
14
|
-
{{/each}}
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export const customEvents: CustomEventHandler[] = [
|
|
18
|
-
{{#each tile.config.customEvents}}
|
|
19
|
-
{
|
|
20
|
-
baseEvent: '{{this.baseEvent}}',
|
|
21
|
-
name: '{{this.name}}',
|
|
22
|
-
hasForm: {{this.hasForm}},
|
|
23
|
-
{{#if this.confirmSubmit}}
|
|
24
|
-
confirmSubmit: {
|
|
25
|
-
state: '{{this.confirmSubmit.state}}',
|
|
26
|
-
message: '{{this.confirmSubmit.message}}'
|
|
27
|
-
},
|
|
28
|
-
{{/if}}
|
|
29
|
-
defaultValues: {{{this.defaultValues}}},
|
|
30
|
-
},
|
|
31
|
-
{{/each}}
|
|
32
|
-
];
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { CustomEventHandler } from "../../../utils/customEvents";
|
|
2
|
-
|
|
3
|
-
{{#each tile.config.customEvents}}
|
|
4
|
-
{{#if this.hasForm}}
|
|
5
|
-
export const {{camelCase this.name}}FormSchema = {{{this.uischema}}};
|
|
6
|
-
{{/if}}
|
|
7
|
-
{{/each}}
|
|
8
|
-
|
|
9
|
-
export const customEventFormSchemas = {
|
|
10
|
-
{{#each tile.config.customEvents}}
|
|
11
|
-
{{#if this.hasForm}}
|
|
12
|
-
'{{this.name}}': {{camelCase this.name}}FormSchema,
|
|
13
|
-
{{/if}}
|
|
14
|
-
{{/each}}
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export const customEvents: CustomEventHandler[] = [
|
|
18
|
-
{{#each tile.config.customEvents}}
|
|
19
|
-
{
|
|
20
|
-
baseEvent: '{{this.baseEvent}}',
|
|
21
|
-
name: '{{this.name}}',
|
|
22
|
-
hasForm: {{this.hasForm}},
|
|
23
|
-
{{#if this.confirmSubmit}}
|
|
24
|
-
confirmSubmit: {
|
|
25
|
-
state: '{{this.confirmSubmit.state}}',
|
|
26
|
-
message: '{{this.confirmSubmit.message}}'
|
|
27
|
-
},
|
|
28
|
-
{{/if}}
|
|
29
|
-
defaultValues: {{{this.defaultValues}}},
|
|
30
|
-
},
|
|
31
|
-
{{/each}}
|
|
32
|
-
];
|
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
import { getConnect } from '@genesislcap/foundation-comms';
|
|
2
|
-
import { showNotification, showNotificationDialog } from '@genesislcap/foundation-notifications';
|
|
3
|
-
|
|
4
|
-
interface ConfirmSubmit {
|
|
5
|
-
state: 'enabled' | 'disabled';
|
|
6
|
-
message: string;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
interface CustomEventError {
|
|
10
|
-
errors: {
|
|
11
|
-
message?: string;
|
|
12
|
-
CODE: string;
|
|
13
|
-
TEXT: string;
|
|
14
|
-
}[];
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export interface CustomEventHandler {
|
|
18
|
-
baseEvent: string;
|
|
19
|
-
name: string;
|
|
20
|
-
hasForm: boolean;
|
|
21
|
-
confirmSubmit?: ConfirmSubmit;
|
|
22
|
-
defaultValues?: Record<string, any>;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export interface CustomEventState {
|
|
26
|
-
name: string;
|
|
27
|
-
event: string;
|
|
28
|
-
rowData: any;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
interface RecordTypeValue {
|
|
32
|
-
type: 'record';
|
|
33
|
-
mapping?: string;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
type DefaultValue = string | number | boolean | null | RecordTypeValue;
|
|
37
|
-
|
|
38
|
-
interface DefaultValues {
|
|
39
|
-
[key: string]: DefaultValue;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export const mapDefaultValues = (
|
|
43
|
-
defaultValues: DefaultValues,
|
|
44
|
-
rowData: any
|
|
45
|
-
): Record<string, any> =>
|
|
46
|
-
Object.entries(defaultValues).reduce(
|
|
47
|
-
(acc, [key, value]) => ({
|
|
48
|
-
...acc,
|
|
49
|
-
[key]:
|
|
50
|
-
typeof value === 'object' &&
|
|
51
|
-
value !== null &&
|
|
52
|
-
'type' in value &&
|
|
53
|
-
value.type === 'record'
|
|
54
|
-
? rowData[(value as RecordTypeValue).mapping || key]
|
|
55
|
-
: value,
|
|
56
|
-
}),
|
|
57
|
-
{}
|
|
58
|
-
);
|
|
59
|
-
|
|
60
|
-
export const executeCustomEvent = async (
|
|
61
|
-
customEventHandler: CustomEventHandler,
|
|
62
|
-
rowData: any
|
|
63
|
-
): Promise<void> => {
|
|
64
|
-
const payload = customEventHandler.defaultValues
|
|
65
|
-
? mapDefaultValues(customEventHandler.defaultValues, rowData)
|
|
66
|
-
: {};
|
|
67
|
-
|
|
68
|
-
const res = await getConnect().commitEvent(
|
|
69
|
-
`EVENT_${customEventHandler.baseEvent}`,
|
|
70
|
-
{ DETAILS: payload }
|
|
71
|
-
);
|
|
72
|
-
|
|
73
|
-
if (res.MESSAGE_TYPE === 'EVENT_NACK') {
|
|
74
|
-
const err: CustomEventError = {
|
|
75
|
-
errors:
|
|
76
|
-
res?.ERROR?.map((e) => ({
|
|
77
|
-
TEXT: e.TEXT,
|
|
78
|
-
CODE: e.STATUS_CODE ?? '0 Unknown Error',
|
|
79
|
-
message:
|
|
80
|
-
'PATH' in e && typeof e.PATH === 'string' && 'FIELD' in e && typeof e.FIELD === 'string'
|
|
81
|
-
? e.TEXT.replace(e.PATH, e.FIELD)
|
|
82
|
-
: undefined,
|
|
83
|
-
})) ?? [],
|
|
84
|
-
};
|
|
85
|
-
submitFailureNotification(new CustomEvent('Error', { detail: err }));
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
export const showCustomEventConfirmation = (
|
|
90
|
-
customEvent: CustomEventHandler,
|
|
91
|
-
onConfirm: () => Promise<void>
|
|
92
|
-
): void => {
|
|
93
|
-
showNotificationDialog(
|
|
94
|
-
{
|
|
95
|
-
title: customEvent.name,
|
|
96
|
-
body: customEvent.confirmSubmit!.message,
|
|
97
|
-
dialog: {
|
|
98
|
-
confirmingActions: [
|
|
99
|
-
{
|
|
100
|
-
label: 'Confirm',
|
|
101
|
-
action: onConfirm,
|
|
102
|
-
},
|
|
103
|
-
],
|
|
104
|
-
dismissingAction: {
|
|
105
|
-
label: 'Cancel',
|
|
106
|
-
action: () => {},
|
|
107
|
-
},
|
|
108
|
-
},
|
|
109
|
-
},
|
|
110
|
-
'rapid',
|
|
111
|
-
);
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
export const submitFailureNotification = (e: CustomEvent<CustomEventError>) => {
|
|
115
|
-
e.detail.errors.forEach((submitFailureError) => {
|
|
116
|
-
if (submitFailureError.CODE === 'OPTIMISTIC_CONCURRENCY_ERROR') {
|
|
117
|
-
showNotification(
|
|
118
|
-
{
|
|
119
|
-
title: 'Warning',
|
|
120
|
-
body: "You're editing an old revision. Please close the form and try editing again",
|
|
121
|
-
config: {
|
|
122
|
-
snackbar: {
|
|
123
|
-
type: 'error',
|
|
124
|
-
},
|
|
125
|
-
},
|
|
126
|
-
},
|
|
127
|
-
'rapid',
|
|
128
|
-
);
|
|
129
|
-
} else {
|
|
130
|
-
showNotification(
|
|
131
|
-
{
|
|
132
|
-
title: 'Error submitting form',
|
|
133
|
-
body:
|
|
134
|
-
submitFailureError.message ??
|
|
135
|
-
(submitFailureError.CODE + ': ' + submitFailureError.TEXT).toString(),
|
|
136
|
-
config: {
|
|
137
|
-
snackbar: {
|
|
138
|
-
type: 'error',
|
|
139
|
-
},
|
|
140
|
-
},
|
|
141
|
-
},
|
|
142
|
-
'rapid',
|
|
143
|
-
);
|
|
144
|
-
}
|
|
145
|
-
});
|
|
146
|
-
};
|
|
147
|
-
|
|
148
|
-
export const useCustomEvent =
|
|
149
|
-
(
|
|
150
|
-
customEvent: CustomEventHandler,
|
|
151
|
-
rowData: any,
|
|
152
|
-
setFormData: (data: Record<string, any>) => void,
|
|
153
|
-
setActiveEvent: (event: CustomEventState | null) => void
|
|
154
|
-
) =>
|
|
155
|
-
async () => {
|
|
156
|
-
if (customEvent.hasForm) {
|
|
157
|
-
const defaultValues = customEvent.defaultValues || {};
|
|
158
|
-
const formData = mapDefaultValues(defaultValues, rowData);
|
|
159
|
-
setFormData(formData);
|
|
160
|
-
setActiveEvent({
|
|
161
|
-
name: customEvent.name,
|
|
162
|
-
event: customEvent.baseEvent,
|
|
163
|
-
rowData,
|
|
164
|
-
});
|
|
165
|
-
} else {
|
|
166
|
-
if (customEvent.confirmSubmit?.state === 'enabled') {
|
|
167
|
-
showCustomEventConfirmation(customEvent, () =>
|
|
168
|
-
executeCustomEvent(customEvent, rowData)
|
|
169
|
-
);
|
|
170
|
-
} else {
|
|
171
|
-
await executeCustomEvent(customEvent, rowData);
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
};
|
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
import { Connect } from '@genesislcap/foundation-comms';
|
|
2
|
-
import { showNotification, showNotificationDialog } from '@genesislcap/foundation-notifications';
|
|
3
|
-
|
|
4
|
-
interface ConfirmSubmit {
|
|
5
|
-
state: 'enabled' | 'disabled';
|
|
6
|
-
message: string;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
interface CustomEventError {
|
|
10
|
-
errors: {
|
|
11
|
-
message?: string;
|
|
12
|
-
CODE: string;
|
|
13
|
-
TEXT: string;
|
|
14
|
-
}[];
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export interface CustomEventHandler {
|
|
18
|
-
baseEvent: string;
|
|
19
|
-
name: string;
|
|
20
|
-
hasForm: boolean;
|
|
21
|
-
confirmSubmit?: ConfirmSubmit;
|
|
22
|
-
defaultValues?: Record<string, any>;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export interface CustomEventState {
|
|
26
|
-
name: string;
|
|
27
|
-
event: string;
|
|
28
|
-
rowData: any;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
interface RecordTypeValue {
|
|
32
|
-
type: 'record';
|
|
33
|
-
mapping?: string;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
type DefaultValue = string | number | boolean | null | RecordTypeValue;
|
|
37
|
-
|
|
38
|
-
interface DefaultValues {
|
|
39
|
-
[key: string]: DefaultValue;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export const mapDefaultValues = (defaultValues: DefaultValues, rowData: any): Record<string, any> =>
|
|
43
|
-
Object.entries(defaultValues).reduce(
|
|
44
|
-
(acc, [key, value]) => ({
|
|
45
|
-
...acc,
|
|
46
|
-
[key]:
|
|
47
|
-
typeof value === 'object' && value !== null && 'type' in value && value.type === 'record'
|
|
48
|
-
? rowData[(value as RecordTypeValue).mapping || key]
|
|
49
|
-
: value,
|
|
50
|
-
}),
|
|
51
|
-
{},
|
|
52
|
-
);
|
|
53
|
-
|
|
54
|
-
export const executeCustomEvent = async (
|
|
55
|
-
connect: Connect,
|
|
56
|
-
customEvent: CustomEventHandler,
|
|
57
|
-
rowData: any,
|
|
58
|
-
): Promise<void> => {
|
|
59
|
-
const payload = customEvent.defaultValues
|
|
60
|
-
? mapDefaultValues(customEvent.defaultValues, rowData)
|
|
61
|
-
: {};
|
|
62
|
-
|
|
63
|
-
const res = await connect.commitEvent(`EVENT_${customEvent.baseEvent}`, {
|
|
64
|
-
DETAILS: payload,
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
if (res.MESSAGE_TYPE === 'EVENT_NACK') {
|
|
68
|
-
const err: CustomEventError = {
|
|
69
|
-
errors:
|
|
70
|
-
res?.ERROR?.map((e) => ({
|
|
71
|
-
TEXT: e.TEXT,
|
|
72
|
-
CODE: e.STATUS_CODE ?? '0 Unknown Error',
|
|
73
|
-
message:
|
|
74
|
-
'PATH' in e && typeof e.PATH === 'string' && 'FIELD' in e && typeof e.FIELD === 'string'
|
|
75
|
-
? e.TEXT.replace(e.PATH, e.FIELD)
|
|
76
|
-
: undefined,
|
|
77
|
-
})) ?? [],
|
|
78
|
-
};
|
|
79
|
-
submitFailureNotification(new CustomEvent('Error', { detail: err }));
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
export const showCustomEventConfirmation = (
|
|
84
|
-
customEvent: CustomEventHandler,
|
|
85
|
-
onConfirm: () => Promise<void>,
|
|
86
|
-
): void => {
|
|
87
|
-
showNotificationDialog(
|
|
88
|
-
{
|
|
89
|
-
title: customEvent.name,
|
|
90
|
-
body: customEvent.confirmSubmit!.message,
|
|
91
|
-
dialog: {
|
|
92
|
-
confirmingActions: [
|
|
93
|
-
{
|
|
94
|
-
label: 'Confirm',
|
|
95
|
-
action: onConfirm,
|
|
96
|
-
},
|
|
97
|
-
],
|
|
98
|
-
dismissingAction: {
|
|
99
|
-
label: 'Cancel',
|
|
100
|
-
action: () => {},
|
|
101
|
-
},
|
|
102
|
-
},
|
|
103
|
-
},
|
|
104
|
-
'rapid',
|
|
105
|
-
);
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
export const submitFailureNotification = (e: CustomEvent<CustomEventError>) => {
|
|
109
|
-
e.detail.errors.forEach((submitFailureError) => {
|
|
110
|
-
if (submitFailureError.CODE === 'OPTIMISTIC_CONCURRENCY_ERROR') {
|
|
111
|
-
showNotification(
|
|
112
|
-
{
|
|
113
|
-
title: 'Warning',
|
|
114
|
-
body: "You're editing an old revision. Please close the form and try editing again",
|
|
115
|
-
config: {
|
|
116
|
-
snackbar: {
|
|
117
|
-
type: 'error',
|
|
118
|
-
},
|
|
119
|
-
},
|
|
120
|
-
},
|
|
121
|
-
'rapid',
|
|
122
|
-
);
|
|
123
|
-
} else {
|
|
124
|
-
showNotification(
|
|
125
|
-
{
|
|
126
|
-
title: 'Error submitting form',
|
|
127
|
-
body:
|
|
128
|
-
submitFailureError.message ??
|
|
129
|
-
(submitFailureError.CODE + ': ' + submitFailureError.TEXT).toString(),
|
|
130
|
-
config: {
|
|
131
|
-
snackbar: {
|
|
132
|
-
type: 'error',
|
|
133
|
-
},
|
|
134
|
-
},
|
|
135
|
-
},
|
|
136
|
-
'rapid',
|
|
137
|
-
);
|
|
138
|
-
}
|
|
139
|
-
});
|
|
140
|
-
};
|
|
141
|
-
|
|
142
|
-
export const handleFormCustomEvent = (
|
|
143
|
-
customEvent: CustomEventHandler,
|
|
144
|
-
rowData: any,
|
|
145
|
-
setFormData: (data: Record<string, any>) => void,
|
|
146
|
-
setActiveEvent: (event: CustomEventState) => void,
|
|
147
|
-
showModal: () => void,
|
|
148
|
-
): void => {
|
|
149
|
-
const defaultValues = customEvent.defaultValues || {};
|
|
150
|
-
const formData = mapDefaultValues(defaultValues, rowData);
|
|
151
|
-
|
|
152
|
-
setFormData(formData);
|
|
153
|
-
setActiveEvent({ name: customEvent.name, event: customEvent.baseEvent, rowData });
|
|
154
|
-
showModal();
|
|
155
|
-
};
|
|
156
|
-
|
|
157
|
-
export const handleNonFormCustomEvent = async (
|
|
158
|
-
connect: Connect,
|
|
159
|
-
customEvent: CustomEventHandler,
|
|
160
|
-
rowData: any,
|
|
161
|
-
showConfirmation: (onConfirm: () => Promise<void>) => void,
|
|
162
|
-
): Promise<void> => {
|
|
163
|
-
if (customEvent.confirmSubmit?.state === 'enabled') {
|
|
164
|
-
showConfirmation(() => executeCustomEvent(connect, customEvent, rowData));
|
|
165
|
-
} else {
|
|
166
|
-
await executeCustomEvent(connect, customEvent, rowData);
|
|
167
|
-
}
|
|
168
|
-
};
|