@genesislcap/blank-app-seed 5.4.0 → 5.6.0-prerelease.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/.genx/package.json +1 -1
- package/.genx/templates/angular/component/component.events.config.hbs +40 -0
- package/.genx/templates/angular/component/component.hbs +3 -32
- package/.genx/templates/angular/entityManager.hbs +3 -0
- package/.genx/templates/react/component/component.events.config.hbs +21 -14
- package/.genx/templates/react/component/component.hbs +3 -92
- package/.genx/templates/react/entityManager.hbs +3 -3
- package/.genx/templates/web-components/component/component.events.config.hbs +23 -15
- package/.genx/templates/web-components/component/component.hbs +0 -67
- package/.genx/templates/web-components/component/component.template.hbs +3 -0
- package/.genx/templates/web-components/entityManager.hbs +3 -12
- package/.genx/versions.json +3 -3
- package/CHANGELOG.md +98 -67
- package/client-tmp/react/src/utils/index.ts +0 -1
- package/client-tmp/web-components/src/utils/index.ts +0 -1
- package/package.json +1 -1
- package/server/gradle.properties +1 -1
- package/client-tmp/react/src/utils/customEvents.ts +0 -187
- package/client-tmp/web-components/src/index.federated.ts +0 -1
- package/client-tmp/web-components/src/utils/customEvents.ts +0 -166
package/.genx/package.json
CHANGED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { type CustomAction, CrudMenuPosition, UiSchema } from '@genesislcap/foundation-entity-management';
|
|
2
|
+
|
|
3
|
+
{{#each tile.config.customEvents}}
|
|
4
|
+
{{#if this.hasForm}}
|
|
5
|
+
export const {{camelCase this.name}}FormSchema: UiSchema = {{{this.uischema}}};
|
|
6
|
+
{{/if}}
|
|
7
|
+
{{/each}}
|
|
8
|
+
|
|
9
|
+
export const customActions: CustomAction[] = [
|
|
10
|
+
{{#each tile.config.customEvents}}
|
|
11
|
+
{
|
|
12
|
+
name: '{{this.name}}',
|
|
13
|
+
action: {
|
|
14
|
+
type: 'event',
|
|
15
|
+
event: 'EVENT_{{this.baseEvent}}',
|
|
16
|
+
hasForm: {{this.hasForm}},
|
|
17
|
+
{{#if this.hasForm}}
|
|
18
|
+
uiSchema: {{camelCase this.name}}FormSchema,
|
|
19
|
+
{{/if}}
|
|
20
|
+
defaultValues: {{{this.defaultValues}}},
|
|
21
|
+
},
|
|
22
|
+
{{#if this.position}}
|
|
23
|
+
position: CrudMenuPosition.{{{pascalCase this.position}}},
|
|
24
|
+
{{/if}}
|
|
25
|
+
{{#if this.icon}}
|
|
26
|
+
icon: '{{this.icon}}',
|
|
27
|
+
{{/if}}
|
|
28
|
+
{{#if this.tooltip}}
|
|
29
|
+
tooltip: '{{this.tooltip}}',
|
|
30
|
+
{{/if}}
|
|
31
|
+
{{#if this.confirmSubmit}}
|
|
32
|
+
confirmSubmit: {
|
|
33
|
+
state: '{{this.confirmSubmit.state}}',
|
|
34
|
+
message: '{{this.confirmSubmit.message}}'
|
|
35
|
+
},
|
|
36
|
+
{{/if}}
|
|
37
|
+
requiresSelection: true,
|
|
38
|
+
},
|
|
39
|
+
{{/each}}
|
|
40
|
+
];
|
|
@@ -4,9 +4,7 @@ import { getUser } from '@genesislcap/foundation-user';
|
|
|
4
4
|
import { ErrorMessageComponent } from '../../../components/error-message/error-message.component';
|
|
5
5
|
import { getViewUpdateRightComponent } from '../../../utils';
|
|
6
6
|
{{#if tile.config.customEvents}}
|
|
7
|
-
import {
|
|
8
|
-
import type { ActionRendererParams } from '@genesislcap/rapid-grid-pro';
|
|
9
|
-
import { RapidAgActionRenderer } from '@genesislcap/rapid-grid-pro';
|
|
7
|
+
import { customActions as emCustomActions } from './{{kebabCase tile.title}}.events.config';
|
|
10
8
|
{{/if}}
|
|
11
9
|
{{#if tile.config.gridOptions}}
|
|
12
10
|
import { GridOptionsConfig } from "@genesislcap/rapid-grid-pro";
|
|
@@ -56,33 +54,6 @@ export class {{pascalCase tile.componentName}} {
|
|
|
56
54
|
reqrep = { pollingInterval: 5000, requestAutoSetup: false };{{/if}}{{#if tile.config.columns}}
|
|
57
55
|
columnDefs = [
|
|
58
56
|
...columnDefs,
|
|
59
|
-
{{#if tile.config.customEvents}}
|
|
60
|
-
/**
|
|
61
|
-
* TODO: Update the action button's icon under `contentTemplate` below.
|
|
62
|
-
* More information about rapid-icon can be found at: https://docs.genesis.global/docs/develop/client-capabilities/presentation/client-presentation-icon/
|
|
63
|
-
**/
|
|
64
|
-
{{#each tile.config.customEvents}}
|
|
65
|
-
{
|
|
66
|
-
field: '',
|
|
67
|
-
headerName: '',
|
|
68
|
-
minWidth: 50,
|
|
69
|
-
maxWidth: 50,
|
|
70
|
-
pinned: 'right',
|
|
71
|
-
cellRenderer: RapidAgActionRenderer,
|
|
72
|
-
cellRendererParams: <ActionRendererParams>{
|
|
73
|
-
actionClick: async (rowData) => {
|
|
74
|
-
const { ROW_REF, ...DETAILS } = rowData;
|
|
75
|
-
const response = await getConnect().commitEvent("EVENT_{{this}}", {
|
|
76
|
-
DETAILS,
|
|
77
|
-
});
|
|
78
|
-
},
|
|
79
|
-
contentTemplate: `
|
|
80
|
-
<rapid-icon name="cog"></rapid-icon>
|
|
81
|
-
`,
|
|
82
|
-
},
|
|
83
|
-
},
|
|
84
|
-
{{/each}}
|
|
85
|
-
{{/if}}
|
|
86
57
|
];{{/if}}{{#if tile.config.type}}
|
|
87
58
|
chartConfig = { {{#ifEquals tile.config.type 'pie'}}
|
|
88
59
|
"radius": 0.75,
|
|
@@ -90,6 +61,6 @@ export class {{pascalCase tile.componentName}} {
|
|
|
90
61
|
"colorField": "groupBy",{{else}}
|
|
91
62
|
"xField": "groupBy",
|
|
92
63
|
"yField": "value",{{/ifEquals}}
|
|
93
|
-
};{{/if}}
|
|
94
|
-
|
|
64
|
+
};{{/if}}{{#if tile.config.customEvents}}
|
|
65
|
+
customActions = emCustomActions;{{/if}}
|
|
95
66
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { UiSchema } from '@genesislcap/foundation-forms';
|
|
1
|
+
import { type CustomAction, CrudMenuPosition, UiSchema } from '@genesislcap/foundation-entity-management';
|
|
3
2
|
|
|
4
3
|
{{#each tile.config.customEvents}}
|
|
5
4
|
{{#if this.hasForm}}
|
|
@@ -7,27 +6,35 @@ export const {{camelCase this.name}}FormSchema: UiSchema = {{{this.uischema}}};
|
|
|
7
6
|
{{/if}}
|
|
8
7
|
{{/each}}
|
|
9
8
|
|
|
10
|
-
export const
|
|
11
|
-
{{#each tile.config.customEvents}}
|
|
12
|
-
{{#if this.hasForm}}
|
|
13
|
-
'{{this.name}}': {{camelCase this.name}}FormSchema,
|
|
14
|
-
{{/if}}
|
|
15
|
-
{{/each}}
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export const customEvents: CustomEventHandler[] = [
|
|
9
|
+
export const customActions: CustomAction[] = [
|
|
19
10
|
{{#each tile.config.customEvents}}
|
|
20
11
|
{
|
|
21
|
-
baseEvent: '{{this.baseEvent}}',
|
|
22
12
|
name: '{{this.name}}',
|
|
23
|
-
|
|
13
|
+
action: {
|
|
14
|
+
type: 'event',
|
|
15
|
+
event: 'EVENT_{{this.baseEvent}}',
|
|
16
|
+
hasForm: {{this.hasForm}},
|
|
17
|
+
{{#if this.hasForm}}
|
|
18
|
+
uiSchema: {{camelCase this.name}}FormSchema,
|
|
19
|
+
{{/if}}
|
|
20
|
+
defaultValues: {{{this.defaultValues}}},
|
|
21
|
+
},
|
|
22
|
+
{{#if this.position}}
|
|
23
|
+
position: CrudMenuPosition.{{{pascalCase this.position}}},
|
|
24
|
+
{{/if}}
|
|
25
|
+
{{#if this.icon}}
|
|
26
|
+
icon: '{{this.icon}}',
|
|
27
|
+
{{/if}}
|
|
28
|
+
{{#if this.tooltip}}
|
|
29
|
+
tooltip: '{{this.tooltip}}',
|
|
30
|
+
{{/if}}
|
|
24
31
|
{{#if this.confirmSubmit}}
|
|
25
32
|
confirmSubmit: {
|
|
26
33
|
state: '{{this.confirmSubmit.state}}',
|
|
27
34
|
message: '{{this.confirmSubmit.message}}'
|
|
28
35
|
},
|
|
29
36
|
{{/if}}
|
|
30
|
-
|
|
37
|
+
requiresSelection: true,
|
|
31
38
|
},
|
|
32
39
|
{{/each}}
|
|
33
40
|
];
|
|
@@ -1,9 +1,6 @@
|
|
|
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';
|
|
@@ -14,14 +11,7 @@ import { getViewUpdateRightComponent{{#if tile.config.customEvents}}, submitFail
|
|
|
14
11
|
import ErrorMessage from '../../../components/ErrorMessage/ErrorMessage';
|
|
15
12
|
{{/if}}
|
|
16
13
|
{{#if tile.config.customEvents}}
|
|
17
|
-
import {
|
|
18
|
-
import { createPortal } from 'react-dom';
|
|
19
|
-
import { getConnect } from '@genesislcap/foundation-comms';
|
|
20
|
-
import type { ActionRendererParams } from '@genesislcap/rapid-grid-pro';
|
|
21
|
-
import { RapidAgActionRenderer } from '@genesislcap/rapid-grid-pro';
|
|
22
|
-
import { UiSchema } from '@genesislcap/foundation-forms';
|
|
23
|
-
import { customEvents, customEventFormSchemas } from './{{pascalCase tile.title}}EventsConfig';
|
|
24
|
-
import { useCustomEvent, type CustomEventState } from '../../../utils/customEvents';
|
|
14
|
+
import { customActions } from './{{pascalCase tile.title}}EventsConfig';
|
|
25
15
|
{{/if}}
|
|
26
16
|
{{#if tile.config.createFormUiSchema~}}
|
|
27
17
|
import { createFormSchema as createFormSchemaTile } from './{{pascalCase tile.title}}CreateFormSchema';
|
|
@@ -66,48 +56,7 @@ export const {{pascalCase tile.componentName}}: React.FC = () => {
|
|
|
66
56
|
const updateFormSchema: typeof updateFormSchemaTile = updateFormSchemaTile;
|
|
67
57
|
{{/if}}
|
|
68
58
|
{{#if tile.config.columns~}}
|
|
69
|
-
const columnDefs: typeof columnDefsTile = [
|
|
70
|
-
...columnDefsTile,
|
|
71
|
-
{{#if tile.config.customEvents}}
|
|
72
|
-
/**
|
|
73
|
-
* TODO: Update the action button's icon under `contentTemplate` below.
|
|
74
|
-
* More information about rapid-icon can be found at: https://docs.genesis.global/docs/develop/client-capabilities/presentation/client-presentation-icon/
|
|
75
|
-
**/
|
|
76
|
-
{{#each tile.config.customEvents}}
|
|
77
|
-
{
|
|
78
|
-
headerName: '',
|
|
79
|
-
minWidth: 50,
|
|
80
|
-
maxWidth: 50,
|
|
81
|
-
headerTooltip: '{{this.tooltip}}',
|
|
82
|
-
pinned: 'right',
|
|
83
|
-
suppressCellFlash: true,
|
|
84
|
-
cellRenderer: RapidAgActionRenderer,
|
|
85
|
-
cellRendererParams: {
|
|
86
|
-
actionClick: async (rowData) => {
|
|
87
|
-
setIsModalVisible(false);
|
|
88
|
-
|
|
89
|
-
const customEvent = customEvents.find(e => e.name === '{{this.name}}');
|
|
90
|
-
if (customEvent) {
|
|
91
|
-
const handleCustomEvent = useCustomEvent(
|
|
92
|
-
customEvent,
|
|
93
|
-
rowData,
|
|
94
|
-
setCustomEventFormData,
|
|
95
|
-
setActiveCustomEvent,
|
|
96
|
-
setResourceName,
|
|
97
|
-
setUiSchema,
|
|
98
|
-
customEventFormSchemas
|
|
99
|
-
);
|
|
100
|
-
await handleCustomEvent();
|
|
101
|
-
}
|
|
102
|
-
},
|
|
103
|
-
contentTemplate: `
|
|
104
|
-
<rapid-icon name="{{this.icon}}" title="{{this.name}}"></rapid-icon>
|
|
105
|
-
`,
|
|
106
|
-
} as ActionRendererParams,
|
|
107
|
-
},
|
|
108
|
-
{{/each}}
|
|
109
|
-
{{/if}}
|
|
110
|
-
];
|
|
59
|
+
const columnDefs: typeof columnDefsTile = [...columnDefsTile];
|
|
111
60
|
{{/if}}
|
|
112
61
|
{{#if tile.config.gridOptions~}}
|
|
113
62
|
const deferredGridOptions: { onRowClicked: GridOptionsConfig.onRowClicked } = { onRowClicked: gridOptionsTile?.onRowClicked }
|
|
@@ -137,44 +86,6 @@ export const {{pascalCase tile.componentName}}: React.FC = () => {
|
|
|
137
86
|
};
|
|
138
87
|
{{/if}}
|
|
139
88
|
|
|
140
|
-
{{#if tile.config.customEvents}}
|
|
141
|
-
const [activeCustomEvent, setActiveCustomEvent] = useState<CustomEventState | null>(null);
|
|
142
|
-
const [customEventFormData, setCustomEventFormData] = useState<Record<string, any>>({});
|
|
143
|
-
const [resourceName, setResourceName] = useState<string>('');
|
|
144
|
-
const [uiSchema, setUiSchema] = useState<UiSchema | null>(null);
|
|
145
|
-
const [isModalVisible, setIsModalVisible] = useState<boolean>(false);
|
|
146
|
-
|
|
147
|
-
function confirmationMessage() {
|
|
148
|
-
if (!activeCustomEvent) return null;
|
|
149
|
-
const event = customEvents.find(e => e.name === activeCustomEvent.name);
|
|
150
|
-
return event?.confirmSubmit?.state === 'enabled' ? event.confirmSubmit.message : null;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
useEffect(() => {
|
|
154
|
-
if (activeCustomEvent) {
|
|
155
|
-
setIsModalVisible(true);
|
|
156
|
-
}
|
|
157
|
-
}, [activeCustomEvent]);
|
|
158
|
-
|
|
159
|
-
const renderFormModal = () => {
|
|
160
|
-
if (!activeCustomEvent) return null;
|
|
161
|
-
|
|
162
|
-
return createPortal(
|
|
163
|
-
<smart-form-modal
|
|
164
|
-
entityLabel="{{ tile.config.entityName }}"
|
|
165
|
-
modal-position="{{ tile.config.modalPosition }}"
|
|
166
|
-
modalFormType={isModalVisible && 'update'}
|
|
167
|
-
editModalVisible={isModalVisible}
|
|
168
|
-
formResourceName={resourceName}
|
|
169
|
-
formUiSchema={uiSchema}
|
|
170
|
-
editedEntity={customEventFormData}
|
|
171
|
-
confirmationMessage={confirmationMessage()}
|
|
172
|
-
></smart-form-modal>,
|
|
173
|
-
document.querySelector('rapid-design-system-provider')!
|
|
174
|
-
);
|
|
175
|
-
};
|
|
176
|
-
{{/if}}
|
|
177
|
-
|
|
178
89
|
return (
|
|
179
90
|
{{> (lookup tile 'type') tile}}
|
|
180
91
|
);
|
|
@@ -61,10 +61,10 @@ hasUserPermission('{{config.permissions.viewRight}}') ? (
|
|
|
61
61
|
{{#if config.enableSearchBar~}}
|
|
62
62
|
enable-search-bar
|
|
63
63
|
{{/if}}
|
|
64
|
+
{{#if config.customEvents}}
|
|
65
|
+
customActions={customActions}
|
|
66
|
+
{{/if}}
|
|
64
67
|
></entity-management>
|
|
65
|
-
{{#if config.customEvents}}
|
|
66
|
-
{renderFormModal()}
|
|
67
|
-
{{/if}}
|
|
68
68
|
</>
|
|
69
69
|
{{#if config.permissions.viewRight~}}
|
|
70
70
|
) : (
|
|
@@ -1,32 +1,40 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { type CustomAction, CrudMenuPosition, UiSchema } from '@genesislcap/foundation-entity-management';
|
|
2
2
|
|
|
3
3
|
{{#each tile.config.customEvents}}
|
|
4
4
|
{{#if this.hasForm}}
|
|
5
|
-
export const {{camelCase this.name}}FormSchema = {{{this.uischema}}};
|
|
5
|
+
export const {{camelCase this.name}}FormSchema: UiSchema = {{{this.uischema}}};
|
|
6
6
|
{{/if}}
|
|
7
7
|
{{/each}}
|
|
8
8
|
|
|
9
|
-
export const
|
|
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[] = [
|
|
9
|
+
export const customActions: CustomAction[] = [
|
|
18
10
|
{{#each tile.config.customEvents}}
|
|
19
11
|
{
|
|
20
|
-
baseEvent: '{{this.baseEvent}}',
|
|
21
12
|
name: '{{this.name}}',
|
|
22
|
-
|
|
13
|
+
action: {
|
|
14
|
+
type: 'event',
|
|
15
|
+
event: 'EVENT_{{this.baseEvent}}',
|
|
16
|
+
hasForm: {{this.hasForm}},
|
|
17
|
+
{{#if this.hasForm}}
|
|
18
|
+
uiSchema: {{camelCase this.name}}FormSchema,
|
|
19
|
+
{{/if}}
|
|
20
|
+
defaultValues: {{{this.defaultValues}}},
|
|
21
|
+
},
|
|
22
|
+
{{#if this.position}}
|
|
23
|
+
position: CrudMenuPosition.{{{pascalCase this.position}}},
|
|
24
|
+
{{/if}}
|
|
25
|
+
{{#if this.icon}}
|
|
26
|
+
icon: '{{this.icon}}',
|
|
27
|
+
{{/if}}
|
|
28
|
+
{{#if this.tooltip}}
|
|
29
|
+
tooltip: '{{this.tooltip}}',
|
|
30
|
+
{{/if}}
|
|
23
31
|
{{#if this.confirmSubmit}}
|
|
24
32
|
confirmSubmit: {
|
|
25
33
|
state: '{{this.confirmSubmit.state}}',
|
|
26
34
|
message: '{{this.confirmSubmit.message}}'
|
|
27
35
|
},
|
|
28
36
|
{{/if}}
|
|
29
|
-
|
|
37
|
+
requiresSelection: true,
|
|
30
38
|
},
|
|
31
39
|
{{/each}}
|
|
32
|
-
];
|
|
40
|
+
];
|
|
@@ -7,12 +7,6 @@ import { {{pascalCase tile.title}}Template as template } from './{{kebabCase til
|
|
|
7
7
|
import { columnDefs } from './{{kebabCase tile.title}}.column.defs';
|
|
8
8
|
import { ColDef } from '@ag-grid-community/core';
|
|
9
9
|
{{/if}}
|
|
10
|
-
{{#if tile.config.customEvents}}
|
|
11
|
-
import type { ActionRendererParams } from '@genesislcap/rapid-grid-pro';
|
|
12
|
-
import { RapidAgActionRenderer } from '@genesislcap/rapid-grid-pro';
|
|
13
|
-
import { customEvents, customEventFormSchemas } from './{{kebabCase tile.title}}.events.config';
|
|
14
|
-
import { handleFormCustomEvent, handleNonFormCustomEvent, showCustomEventConfirmation, type CustomEventHandler, type CustomEventState } from '../../../utils/customEvents';
|
|
15
|
-
{{/if}}
|
|
16
10
|
|
|
17
11
|
{{#ifAny tile.metadata.comment tile.metadata.todo}}
|
|
18
12
|
/**
|
|
@@ -32,70 +26,9 @@ export class {{pascalCase tile.componentName}} extends GenesisElement {
|
|
|
32
26
|
@User user: User;
|
|
33
27
|
@Connect connect!: Connect;
|
|
34
28
|
|
|
35
|
-
{{#if tile.config.customEvents}}
|
|
36
|
-
@observable customEvents: CustomEventHandler[] = customEvents;
|
|
37
|
-
@observable activeCustomEvent: CustomEventState | null = null;
|
|
38
|
-
@observable customEventFormData: Record<string, any> = {};
|
|
39
|
-
|
|
40
|
-
async handleCustomEventClick(eventName: string, rowData: any) {
|
|
41
|
-
const customEvent = this.customEvents.find((e) => e.name === eventName);
|
|
42
|
-
if (!customEvent) return;
|
|
43
|
-
|
|
44
|
-
if (customEvent.hasForm) {
|
|
45
|
-
handleFormCustomEvent(
|
|
46
|
-
customEvent,
|
|
47
|
-
rowData,
|
|
48
|
-
(data) => (this.customEventFormData = data),
|
|
49
|
-
(event) => (this.activeCustomEvent = event),
|
|
50
|
-
);
|
|
51
|
-
} else {
|
|
52
|
-
await handleNonFormCustomEvent(this.connect, customEvent, rowData, (onConfirm) =>
|
|
53
|
-
showCustomEventConfirmation(customEvent, onConfirm),
|
|
54
|
-
);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
getActiveCustomEvent() {
|
|
59
|
-
if (!this.activeCustomEvent) return null;
|
|
60
|
-
return this.customEvents.find(e => e.name === this.activeCustomEvent.name);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
getCustomEventResourceName() {
|
|
64
|
-
if (!this.activeCustomEvent) return '';
|
|
65
|
-
return `EVENT_${this.activeCustomEvent.event}`;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
getCustomEventUiSchema() {
|
|
69
|
-
const customEvent = this.getActiveCustomEvent();
|
|
70
|
-
if (!customEvent) return null;
|
|
71
|
-
return customEventFormSchemas[customEvent.name];
|
|
72
|
-
}
|
|
73
|
-
{{/if}}
|
|
74
|
-
|
|
75
29
|
{{#if tile.config.columns}}
|
|
76
30
|
@observable columns: ColDef[] = [
|
|
77
31
|
...columnDefs,
|
|
78
|
-
{{#if tile.config.customEvents}}
|
|
79
|
-
{{#each tile.config.customEvents}}
|
|
80
|
-
{
|
|
81
|
-
headerName: '',
|
|
82
|
-
minWidth: 50,
|
|
83
|
-
maxWidth: 50,
|
|
84
|
-
headerTooltip: '{{this.tooltip}}',
|
|
85
|
-
pinned: 'right',
|
|
86
|
-
suppressCellFlash: true,
|
|
87
|
-
cellRenderer: RapidAgActionRenderer,
|
|
88
|
-
cellRendererParams: <ActionRendererParams>{
|
|
89
|
-
actionClick: async (rowData) => {
|
|
90
|
-
await this.handleCustomEventClick('{{this.name}}', rowData);
|
|
91
|
-
},
|
|
92
|
-
contentTemplate: `
|
|
93
|
-
<rapid-icon name="{{this.icon}}" title="{{this.name}}"></rapid-icon>
|
|
94
|
-
`,
|
|
95
|
-
},
|
|
96
|
-
},
|
|
97
|
-
{{/each}}
|
|
98
|
-
{{/if}}
|
|
99
32
|
];
|
|
100
33
|
{{/if}}
|
|
101
34
|
}
|
|
@@ -10,6 +10,9 @@ import { createFormSchema } from './{{kebabCase tile.title}}.create.form.schema'
|
|
|
10
10
|
{{#if tile.config.updateFormUiSchema}}
|
|
11
11
|
import { updateFormSchema } from './{{kebabCase tile.title}}.update.form.schema';
|
|
12
12
|
{{/if}}
|
|
13
|
+
{{#if tile.config.customEvents}}
|
|
14
|
+
import { customActions } from './{{kebabCase tile.title}}.events.config';
|
|
15
|
+
{{/if}}
|
|
13
16
|
{{#if tile.config.gridOptions}}
|
|
14
17
|
import { gridOptions } from './{{kebabCase tile.title}}.gridOptions';
|
|
15
18
|
{{/if}}
|
|
@@ -49,19 +49,10 @@ ${whenElse(
|
|
|
49
49
|
{{#if config.enableSearchBar}}
|
|
50
50
|
enable-search-bar
|
|
51
51
|
{{/if}}
|
|
52
|
+
{{#if config.customEvents}}
|
|
53
|
+
:customActions=${() => customActions}
|
|
54
|
+
{{/if}}
|
|
52
55
|
></entity-management>
|
|
53
|
-
{{#if config.customEvents}}
|
|
54
|
-
<smart-form-modal
|
|
55
|
-
entityLabel="{{ config.entityName }}"
|
|
56
|
-
modal-position="{{ config.modalPosition }}"
|
|
57
|
-
:modalFormType=${(x) => !!x.activeCustomEvent && 'update'}
|
|
58
|
-
:editModalVisible=${(x) => !!x.activeCustomEvent}
|
|
59
|
-
:formResourceName=${(x) => x.getCustomEventResourceName()}
|
|
60
|
-
:formUiSchema=${(x) => x.getCustomEventUiSchema()}
|
|
61
|
-
:editedEntity=${(x) => x.customEventFormData}
|
|
62
|
-
confirmation-message="${(x) => x.getActiveCustomEvent()?.confirmSubmit?.state === 'enabled' ? x.getActiveCustomEvent().confirmSubmit.message : null}"
|
|
63
|
-
></smart-form-modal>
|
|
64
|
-
{{/if}}
|
|
65
56
|
`,
|
|
66
57
|
html`
|
|
67
58
|
<not-permitted-component></not-permitted-component>
|
package/.genx/versions.json
CHANGED
package/CHANGELOG.md
CHANGED
|
@@ -1,80 +1,111 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
## [5.
|
|
3
|
+
## [5.6.0-prerelease.1](https://github.com/genesiscommunitysuccess/blank-app-seed/compare/v5.5.0...v5.6.0-prerelease.1) (2025-10-07)
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
### Features
|
|
7
7
|
|
|
8
|
-
* add
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* backport main 8.13 (#492) 76884d4
|
|
12
|
-
* BDD framework + GSF change GENC-1208 (#514) ee185b4
|
|
13
|
-
* smart-form-modal react GENC-1162 d82bf2b
|
|
14
|
-
* support confirmation message for event on entity manager GENC-1185 ea27d49
|
|
15
|
-
* support confirmation message for event on entity manager GENC-1185 (#503) d2b4448
|
|
16
|
-
* support cucumber tags in bdd tests cc918ff
|
|
17
|
-
* support cucumber tags in bdd tests (#512) 652dcf1
|
|
18
|
-
* use smart-form-modal GENC-1162 (#485) 744ad5b
|
|
8
|
+
* add position + customEvents in angular GENC-1213 38ddcf4
|
|
9
|
+
* handle custom actions by entity-management GENC-1213 b78bf5d
|
|
10
|
+
* handle custom actions by entity-management GENC-1213 (#519) e96b445
|
|
19
11
|
|
|
20
12
|
|
|
21
13
|
### Bug Fixes
|
|
22
14
|
|
|
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
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
*
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
* updating server version information for
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
15
|
+
* backport main to prerelease GENC-0 (#520) 59c1ac5
|
|
16
|
+
* remove index-federated.ts file 769b154
|
|
17
|
+
* remove index-federated.ts file (#515) 7f4b431
|
|
18
|
+
* update genesisStart version GENC-0 f483e15
|
|
19
|
+
* update genesisStart version GENC-0 (#517) cb37824
|
|
20
|
+
* updating server version information for Auth [PSD-0](https://github.com/genesiscommunitysuccess/blank-app-seed/issues/0) 0a1f905
|
|
21
|
+
* updating server version information for Auth [PSD-0](https://github.com/genesiscommunitysuccess/blank-app-seed/issues/0) 3a3fc53
|
|
22
|
+
* updating server version information for Auth [PSD-0](https://github.com/genesiscommunitysuccess/blank-app-seed/issues/0) f2cf4ba
|
|
23
|
+
* updating server version information for Auth [PSD-0](https://github.com/genesiscommunitysuccess/blank-app-seed/issues/0) ae21109
|
|
24
|
+
* updating server version information for GSF [PSD-0](https://github.com/genesiscommunitysuccess/blank-app-seed/issues/0) 56405a7
|
|
25
|
+
* updating server version information for GSF [PSD-0](https://github.com/genesiscommunitysuccess/blank-app-seed/issues/0) 96831c7
|
|
26
|
+
* updating server version information for GSF [PSD-0](https://github.com/genesiscommunitysuccess/blank-app-seed/issues/0) 7b6670e
|
|
27
|
+
* updating server version information for GSF [PSD-0](https://github.com/genesiscommunitysuccess/blank-app-seed/issues/0) 0d5e2bc
|
|
28
|
+
|
|
29
|
+
## [5.4.0-prerelease.27](https://github.com/genesiscommunitysuccess/blank-app-seed/compare/v5.4.0-prerelease.26...v5.4.0-prerelease.27) (2025-10-06)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
### Bug Fixes
|
|
33
|
+
|
|
34
|
+
* updating server version information for Auth [PSD-0](https://github.com/genesiscommunitysuccess/blank-app-seed/issues/0) 0a1f905
|
|
35
|
+
|
|
36
|
+
## [5.4.0-prerelease.26](https://github.com/genesiscommunitysuccess/blank-app-seed/compare/v5.4.0-prerelease.25...v5.4.0-prerelease.26) (2025-10-06)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
### Bug Fixes
|
|
40
|
+
|
|
41
|
+
* updating server version information for GSF [PSD-0](https://github.com/genesiscommunitysuccess/blank-app-seed/issues/0) 56405a7
|
|
42
|
+
|
|
43
|
+
## [5.4.0-prerelease.25](https://github.com/genesiscommunitysuccess/blank-app-seed/compare/v5.4.0-prerelease.24...v5.4.0-prerelease.25) (2025-10-06)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
### Features
|
|
47
|
+
|
|
48
|
+
* add position + customEvents in angular GENC-1213 38ddcf4
|
|
49
|
+
* handle custom actions by entity-management GENC-1213 b78bf5d
|
|
50
|
+
* handle custom actions by entity-management GENC-1213 (#519) e96b445
|
|
51
|
+
|
|
52
|
+
## [5.4.0-prerelease.24](https://github.com/genesiscommunitysuccess/blank-app-seed/compare/v5.4.0-prerelease.23...v5.4.0-prerelease.24) (2025-10-02)
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
### Bug Fixes
|
|
56
|
+
|
|
57
|
+
* updating server version information for Auth [PSD-0](https://github.com/genesiscommunitysuccess/blank-app-seed/issues/0) 3a3fc53
|
|
58
|
+
|
|
59
|
+
## [5.4.0-prerelease.23](https://github.com/genesiscommunitysuccess/blank-app-seed/compare/v5.4.0-prerelease.22...v5.4.0-prerelease.23) (2025-10-02)
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
### Bug Fixes
|
|
63
|
+
|
|
64
|
+
* updating server version information for GSF [PSD-0](https://github.com/genesiscommunitysuccess/blank-app-seed/issues/0) 96831c7
|
|
65
|
+
|
|
66
|
+
## [5.4.0-prerelease.22](https://github.com/genesiscommunitysuccess/blank-app-seed/compare/v5.4.0-prerelease.21...v5.4.0-prerelease.22) (2025-09-30)
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
### Bug Fixes
|
|
70
|
+
|
|
71
|
+
* updating server version information for Auth [PSD-0](https://github.com/genesiscommunitysuccess/blank-app-seed/issues/0) f2cf4ba
|
|
72
|
+
|
|
73
|
+
## [5.4.0-prerelease.21](https://github.com/genesiscommunitysuccess/blank-app-seed/compare/v5.4.0-prerelease.20...v5.4.0-prerelease.21) (2025-09-30)
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
### Bug Fixes
|
|
77
|
+
|
|
78
|
+
* updating server version information for GSF [PSD-0](https://github.com/genesiscommunitysuccess/blank-app-seed/issues/0) 7b6670e
|
|
79
|
+
|
|
80
|
+
## [5.4.0-prerelease.20](https://github.com/genesiscommunitysuccess/blank-app-seed/compare/v5.4.0-prerelease.19...v5.4.0-prerelease.20) (2025-09-26)
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
### Bug Fixes
|
|
84
|
+
|
|
85
|
+
* remove index-federated.ts file 769b154
|
|
86
|
+
* remove index-federated.ts file (#515) 7f4b431
|
|
87
|
+
|
|
88
|
+
## [5.4.0-prerelease.19](https://github.com/genesiscommunitysuccess/blank-app-seed/compare/v5.4.0-prerelease.18...v5.4.0-prerelease.19) (2025-09-22)
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
### Bug Fixes
|
|
92
|
+
|
|
93
|
+
* update genesisStart version GENC-0 f483e15
|
|
94
|
+
* update genesisStart version GENC-0 (#517) cb37824
|
|
95
|
+
|
|
96
|
+
## [5.4.0-prerelease.18](https://github.com/genesiscommunitysuccess/blank-app-seed/compare/v5.4.0-prerelease.17...v5.4.0-prerelease.18) (2025-09-19)
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
### Bug Fixes
|
|
100
|
+
|
|
101
|
+
* updating server version information for Auth [PSD-0](https://github.com/genesiscommunitysuccess/blank-app-seed/issues/0) ae21109
|
|
102
|
+
|
|
103
|
+
## [5.4.0-prerelease.17](https://github.com/genesiscommunitysuccess/blank-app-seed/compare/v5.4.0-prerelease.16...v5.4.0-prerelease.17) (2025-09-19)
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
### Bug Fixes
|
|
107
|
+
|
|
108
|
+
* updating server version information for GSF [PSD-0](https://github.com/genesiscommunitysuccess/blank-app-seed/issues/0) 0d5e2bc
|
|
78
109
|
|
|
79
110
|
## [5.4.0-prerelease.16](https://github.com/genesiscommunitysuccess/blank-app-seed/compare/v5.4.0-prerelease.15...v5.4.0-prerelease.16) (2025-09-17)
|
|
80
111
|
|
package/package.json
CHANGED
package/server/gradle.properties
CHANGED
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
import { getConnect } from '@genesislcap/foundation-comms';
|
|
2
|
-
import { UiSchema } from '@genesislcap/foundation-forms';
|
|
3
|
-
import { showNotification, showNotificationDialog } from '@genesislcap/foundation-notifications';
|
|
4
|
-
|
|
5
|
-
interface ConfirmSubmit {
|
|
6
|
-
state: 'enabled' | 'disabled';
|
|
7
|
-
message: string;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
interface CustomEventError {
|
|
11
|
-
errors: {
|
|
12
|
-
message?: string;
|
|
13
|
-
CODE: string;
|
|
14
|
-
TEXT: string;
|
|
15
|
-
}[];
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export interface CustomEventHandler {
|
|
19
|
-
baseEvent: string;
|
|
20
|
-
name: string;
|
|
21
|
-
hasForm: boolean;
|
|
22
|
-
confirmSubmit?: ConfirmSubmit;
|
|
23
|
-
defaultValues?: Record<string, any>;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export interface CustomEventState {
|
|
27
|
-
name: string;
|
|
28
|
-
event: string;
|
|
29
|
-
rowData: any;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
interface RecordTypeValue {
|
|
33
|
-
type: 'record';
|
|
34
|
-
mapping?: string;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
type DefaultValue = string | number | boolean | null | RecordTypeValue;
|
|
38
|
-
|
|
39
|
-
interface DefaultValues {
|
|
40
|
-
[key: string]: DefaultValue;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export const mapDefaultValues = (
|
|
44
|
-
defaultValues: DefaultValues,
|
|
45
|
-
rowData: any
|
|
46
|
-
): Record<string, any> =>
|
|
47
|
-
Object.entries(defaultValues).reduce(
|
|
48
|
-
(acc, [key, value]) => ({
|
|
49
|
-
...acc,
|
|
50
|
-
[key]:
|
|
51
|
-
typeof value === 'object' &&
|
|
52
|
-
value !== null &&
|
|
53
|
-
'type' in value &&
|
|
54
|
-
value.type === 'record'
|
|
55
|
-
? rowData[(value as RecordTypeValue).mapping || key]
|
|
56
|
-
: value,
|
|
57
|
-
}),
|
|
58
|
-
{}
|
|
59
|
-
);
|
|
60
|
-
|
|
61
|
-
export const executeCustomEvent = async (
|
|
62
|
-
customEventHandler: CustomEventHandler,
|
|
63
|
-
rowData: any
|
|
64
|
-
): Promise<void> => {
|
|
65
|
-
const payload = customEventHandler.defaultValues
|
|
66
|
-
? mapDefaultValues(customEventHandler.defaultValues, rowData)
|
|
67
|
-
: {};
|
|
68
|
-
|
|
69
|
-
const res = await getConnect().commitEvent(
|
|
70
|
-
`EVENT_${customEventHandler.baseEvent}`,
|
|
71
|
-
{ DETAILS: payload }
|
|
72
|
-
);
|
|
73
|
-
|
|
74
|
-
if (res.MESSAGE_TYPE === 'EVENT_NACK') {
|
|
75
|
-
const err: CustomEventError = {
|
|
76
|
-
errors:
|
|
77
|
-
res?.ERROR?.map((e) => ({
|
|
78
|
-
TEXT: e.TEXT,
|
|
79
|
-
CODE: e.STATUS_CODE ?? '0 Unknown Error',
|
|
80
|
-
message:
|
|
81
|
-
'PATH' in e && typeof e.PATH === 'string' && 'FIELD' in e && typeof e.FIELD === 'string'
|
|
82
|
-
? e.TEXT.replace(e.PATH, e.FIELD)
|
|
83
|
-
: undefined,
|
|
84
|
-
})) ?? [],
|
|
85
|
-
};
|
|
86
|
-
submitFailureNotification(new CustomEvent('Error', { detail: err }));
|
|
87
|
-
}
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
export const showCustomEventConfirmation = (
|
|
91
|
-
customEvent: CustomEventHandler,
|
|
92
|
-
onConfirm: () => Promise<void>
|
|
93
|
-
): void => {
|
|
94
|
-
showNotificationDialog(
|
|
95
|
-
{
|
|
96
|
-
title: customEvent.name,
|
|
97
|
-
body: customEvent.confirmSubmit!.message,
|
|
98
|
-
dialog: {
|
|
99
|
-
confirmingActions: [
|
|
100
|
-
{
|
|
101
|
-
label: 'Confirm',
|
|
102
|
-
action: onConfirm,
|
|
103
|
-
},
|
|
104
|
-
],
|
|
105
|
-
dismissingAction: {
|
|
106
|
-
label: 'Cancel',
|
|
107
|
-
action: () => {},
|
|
108
|
-
},
|
|
109
|
-
},
|
|
110
|
-
},
|
|
111
|
-
'rapid',
|
|
112
|
-
);
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
export const submitFailureNotification = (e: CustomEvent<CustomEventError>) => {
|
|
116
|
-
e.detail.errors.forEach((submitFailureError) => {
|
|
117
|
-
if (submitFailureError.CODE === 'OPTIMISTIC_CONCURRENCY_ERROR') {
|
|
118
|
-
showNotification(
|
|
119
|
-
{
|
|
120
|
-
title: 'Warning',
|
|
121
|
-
body: "You're editing an old revision. Please close the form and try editing again",
|
|
122
|
-
config: {
|
|
123
|
-
snackbar: {
|
|
124
|
-
type: 'error',
|
|
125
|
-
},
|
|
126
|
-
},
|
|
127
|
-
},
|
|
128
|
-
'rapid',
|
|
129
|
-
);
|
|
130
|
-
} else {
|
|
131
|
-
showNotification(
|
|
132
|
-
{
|
|
133
|
-
title: 'Error submitting form',
|
|
134
|
-
body:
|
|
135
|
-
submitFailureError.message ??
|
|
136
|
-
(submitFailureError.CODE + ': ' + submitFailureError.TEXT).toString(),
|
|
137
|
-
config: {
|
|
138
|
-
snackbar: {
|
|
139
|
-
type: 'error',
|
|
140
|
-
},
|
|
141
|
-
},
|
|
142
|
-
},
|
|
143
|
-
'rapid',
|
|
144
|
-
);
|
|
145
|
-
}
|
|
146
|
-
});
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
export const useCustomEvent =
|
|
150
|
-
(
|
|
151
|
-
customEvent: CustomEventHandler,
|
|
152
|
-
rowData: any,
|
|
153
|
-
setFormData: (data: Record<string, any>) => void,
|
|
154
|
-
setActiveEvent: (event: CustomEventState | null) => void,
|
|
155
|
-
setResourceName?: (name: string) => void,
|
|
156
|
-
setUiSchema?: (schema: UiSchema) => void,
|
|
157
|
-
customEventFormSchemas?: Record<string, UiSchema>
|
|
158
|
-
) =>
|
|
159
|
-
async () => {
|
|
160
|
-
if (customEvent.hasForm) {
|
|
161
|
-
const defaultValues = customEvent.defaultValues || {};
|
|
162
|
-
const formData = mapDefaultValues(defaultValues, rowData);
|
|
163
|
-
setFormData(formData);
|
|
164
|
-
setActiveEvent({
|
|
165
|
-
name: customEvent.name,
|
|
166
|
-
event: customEvent.baseEvent,
|
|
167
|
-
rowData,
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
if (setResourceName) {
|
|
171
|
-
setResourceName(`EVENT_${customEvent.baseEvent}`);
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
if (setUiSchema && customEventFormSchemas) {
|
|
175
|
-
const uiSchema = customEventFormSchemas[customEvent.name];
|
|
176
|
-
setUiSchema(uiSchema || null);
|
|
177
|
-
}
|
|
178
|
-
} else {
|
|
179
|
-
if (customEvent.confirmSubmit?.state === 'enabled') {
|
|
180
|
-
showCustomEventConfirmation(customEvent, () =>
|
|
181
|
-
executeCustomEvent(customEvent, rowData)
|
|
182
|
-
);
|
|
183
|
-
} else {
|
|
184
|
-
await executeCustomEvent(customEvent, rowData);
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import('./index');
|
|
@@ -1,166 +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
|
-
): void => {
|
|
148
|
-
const defaultValues = customEvent.defaultValues || {};
|
|
149
|
-
const formData = mapDefaultValues(defaultValues, rowData);
|
|
150
|
-
|
|
151
|
-
setFormData(formData);
|
|
152
|
-
setActiveEvent({ name: customEvent.name, event: customEvent.baseEvent, rowData });
|
|
153
|
-
};
|
|
154
|
-
|
|
155
|
-
export const handleNonFormCustomEvent = async (
|
|
156
|
-
connect: Connect,
|
|
157
|
-
customEvent: CustomEventHandler,
|
|
158
|
-
rowData: any,
|
|
159
|
-
showConfirmation: (onConfirm: () => Promise<void>) => void,
|
|
160
|
-
): Promise<void> => {
|
|
161
|
-
if (customEvent.confirmSubmit?.state === 'enabled') {
|
|
162
|
-
showConfirmation(() => executeCustomEvent(connect, customEvent, rowData));
|
|
163
|
-
} else {
|
|
164
|
-
await executeCustomEvent(connect, customEvent, rowData);
|
|
165
|
-
}
|
|
166
|
-
};
|