Skip to content

Commit

Permalink
Fix works of EntityReference component inside SubForm
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexStepantsov committed Jun 21, 2023
1 parent dabcfd6 commit 05de2ef
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
33 changes: 18 additions & 15 deletions shesha-reactjs/src/components/quickView/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Button, Form, Popover, PopoverProps, Spin, notification } from 'antd';
import { entitiesGet } from 'apis/entities';
import React, { FC, PropsWithChildren, useEffect, useState } from 'react';
import React, { FC, PropsWithChildren, useEffect, useMemo, useState } from 'react';
import { ConfigurableForm } from '../';
import { FormMarkupWithSettings, useSheshaApplication, useUi } from '../../providers';
import { FormItemProvider, FormMarkupWithSettings, useSheshaApplication, useUi } from '../../providers';
import { useConfigurationItemsLoader } from '../../providers/configurationItemsLoader';
import { useFormConfiguration } from '../../providers/form/api';
import { FormIdentifier } from '../../providers/form/models';
Expand Down Expand Up @@ -99,19 +99,22 @@ const QuickView: FC<Omit<IQuickViewProps, 'formType'>> = ({
}
}, [entityId, getEntityUrl, formSettings]);

const formContent =
formSettings && formData ? (
<ConfigurableForm
mode="readonly"
{...formItemLayout}
markup={formSettings}
form={form}
initialValues={formData}
skipFetchData={true}
/>
) : (
<></>
);
const formContent = useMemo(() => {
return formSettings && formData ? (
<FormItemProvider namePrefix={undefined}>
<ConfigurableForm
mode="readonly"
{...formItemLayout}
markup={formSettings}
form={form}
initialValues={formData}
skipFetchData={true}
/>
</FormItemProvider>
) : (
<></>
);
}, [formSettings, formData]);

const render = () => {
if (children) {
Expand Down
2 changes: 2 additions & 0 deletions shesha-reactjs/src/pages/dynamic/index.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export const OrganisationEdit = addStory(Template, {
module: 'Test Module',
version: 1,
},
id: '5BC9A277-63ED-4A71-919F-0B4064363BBC'
});

export const PersonEdit = addStory(Template, {
Expand All @@ -51,6 +52,7 @@ export const PersonEdit = addStory(Template, {
module: 'Test Module',
version: 7,
},
id: '32E2B3DD-4D99-4542-AF71-134EC7C0E2CE'
});

export const PersonDetails = addStory(Template, {
Expand Down

0 comments on commit 05de2ef

Please sign in to comment.