@evoke-platform/ui-components 1.10.0-testing.21 → 1.10.0-testing.23

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.
@@ -104,11 +104,14 @@ function FormRendererContainer(props) {
104
104
  }
105
105
  }, []);
106
106
  useEffect(() => {
107
+ const needsInstance = action?.type !== 'create' && !!instanceId;
108
+ // Instance and Action are loaded in the side effect above; wait for them to complete.
109
+ const loading = (actionId && !action) || (needsInstance && !instance);
107
110
  if (dataType === 'documents' || form)
108
111
  return;
109
- if (actionId && !action)
110
- return; // Action is loaded in the side effect above; wait for it to complete
111
- if (formId || action?.defaultFormId) {
112
+ if (loading)
113
+ return;
114
+ if ((formId || action?.defaultFormId) && formId !== '_auto_') {
112
115
  apiServices
113
116
  .get(getPrefixedUrl(`/forms/${formId || action?.defaultFormId}`))
114
117
  .then((evokeForm) => {
@@ -125,14 +128,14 @@ function FormRendererContainer(props) {
125
128
  onError(error);
126
129
  });
127
130
  }
128
- else if (action?.type === 'delete' && instance) {
131
+ else if (action?.type === 'delete' && formId === '_auto_') {
129
132
  setForm({
130
133
  id: '',
131
134
  name: '',
132
135
  entries: [
133
136
  {
134
137
  type: 'content',
135
- html: `<p>You are about to delete <strong>${instance.name}</strong>. Deleted records can't be restored. Are you sure you want to continue?</p>`,
138
+ html: `<p>You are about to delete <strong>${instance?.name}</strong>. Deleted records can't be restored. Are you sure you want to continue?</p>`,
136
139
  },
137
140
  ],
138
141
  objectId: objectId,
@@ -66,6 +66,8 @@ const RepeatableField = (props) => {
66
66
  const updateAction = relatedObject?.actions?.find((item) => item.id === entry.display?.updateActionId);
67
67
  const deleteAction = relatedObject?.actions?.find((item) => item.id === entry.display?.deleteActionId);
68
68
  function getForm(setForm, action, formId) {
69
+ if (formId === '_auto_')
70
+ return;
69
71
  if (formId || action?.defaultFormId) {
70
72
  apiServices
71
73
  .get(getPrefixedUrl(`/forms/${formId || action?.defaultFormId}`))
@@ -554,7 +556,9 @@ const RepeatableField = (props) => {
554
556
  : dialogType === 'update'
555
557
  ? updateForm?.id
556
558
  : dialogType === 'delete'
557
- ? deleteForm?.id
559
+ ? entry.display?.deleteFormId === '_auto_'
560
+ ? '_auto_'
561
+ : deleteForm?.id
558
562
  : undefined, instanceId: selectedInstanceId, relatedParameter: fieldDefinition, associatedObject: instance?.id && fieldDefinition.relatedPropertyId
559
563
  ? { instanceId: instance.id, propertyId: fieldDefinition.relatedPropertyId }
560
564
  : undefined })),
@@ -729,4 +729,24 @@ describe('FormRendererContainer', () => {
729
729
  expect(scrollIntoViewMock).not.toHaveBeenCalled();
730
730
  });
731
731
  });
732
+ it('renders the auto-generated delete confirmation form when formId is "_auto_"', async () => {
733
+ server.use(http.get('/api/data/objects/specialty/instances/test-instance', () => {
734
+ return HttpResponse.json({
735
+ id: 'test-instance',
736
+ name: 'Persons Name',
737
+ specialtyType: null,
738
+ license: null,
739
+ });
740
+ }), http.get('/api/data/objects/specialty/instances/test-instance/object', () => {
741
+ return HttpResponse.json(specialtyObject);
742
+ }));
743
+ render(React.createElement(FormRendererContainer, { objectId: 'specialty', formId: '_auto_', dataType: 'objectInstances', actionId: '_delete', instanceId: 'test-instance' }));
744
+ // Wait for the delete confirmation message to appear
745
+ const confirmation = await screen.findByText(/you are about to delete/i);
746
+ expect(confirmation).toBeInTheDocument();
747
+ // Validate that the message includes the instance name
748
+ expect(confirmation).toHaveTextContent(/Persons Name/);
749
+ // Ensure the "Delete" button is rendered
750
+ await screen.findByRole('button', { name: /delete/i });
751
+ });
732
752
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evoke-platform/ui-components",
3
- "version": "1.10.0-testing.21",
3
+ "version": "1.10.0-testing.23",
4
4
  "description": "",
5
5
  "main": "dist/published/index.js",
6
6
  "module": "dist/published/index.js",