fix(client): sub table does not work

This commit is contained in:
chenos 2022-03-06 19:04:02 +08:00
parent 5164f85484
commit 4ce41cf7b2
9 changed files with 49 additions and 26 deletions

View File

@ -35,7 +35,7 @@ export const RemoteCollectionManagerProvider = (props: any) => {
paginate: false,
appends: ['fields', 'fields.uiSchema'],
filter: {
inherit: false,
// inherit: false,
},
},
};

View File

@ -7,7 +7,7 @@ import { CollectionFieldOptions } from '../types';
export const useCollection = () => {
const collection = useContext(CollectionContext);
const api = useAPIClient();
const resource = api?.resource(collection.name);
const resource = api?.resource(collection?.name);
return {
...collection,
resource,

View File

@ -255,7 +255,7 @@ export const DataSourceProvider = observer((props: any) => {
},
);
return (
<CollectionProvider name={collection}>
<CollectionProvider collection={coll}>
<DataSourceContext.Provider
value={{
rowKey,

View File

@ -0,0 +1,15 @@
import React from 'react';
import { GeneralSchemaDesigner, SchemaSettings } from '../../../schema-settings';
export const TableArrayDesigner = () => {
return (
<GeneralSchemaDesigner>
<SchemaSettings.Remove
removeParentsIfNoChildren
breakRemoveOn={{
'x-component': 'Grid',
}}
/>
</GeneralSchemaDesigner>
);
};

View File

@ -1,4 +1,5 @@
import { TableArray } from './Table.Array';
import { TableArrayDesigner } from './Table.Array.Designer';
import { TableColumn } from './Table.Column';
import { TableColumnActionBar } from './Table.Column.ActionBar';
import { TableColumnDecorator } from './Table.Column.Decorator';
@ -23,3 +24,4 @@ Table.Column.Deigner = TableColumnDeigner;
Table.RowActionDesigner = TableRowActionDesigner;
Table.Designer = TableDesigner;
Table.Array.Designer = TableArrayDesigner;

View File

@ -167,13 +167,15 @@ export const CalendarBlockInitializer = (props) => {
{
type: 'itemGroup',
title: t('Select data source'),
children: collections?.map((item) => {
return {
type: 'item',
name: item.name,
title: item.title,
};
}),
children: collections
?.filter((item) => !item.inherit)
?.map((item) => {
return {
type: 'item',
name: item.name,
title: item.title,
};
}),
},
]}
/>

View File

@ -66,13 +66,15 @@ export const FormBlockInitializer = (props) => {
{
type: 'itemGroup',
title: t('Select data source'),
children: collections?.map((item) => {
return {
type: 'item',
name: item.name,
title: item.title,
};
}),
children: collections
?.filter((item) => !item.inherit)
?.map((item) => {
return {
type: 'item',
name: item.name,
title: item.title,
};
}),
},
]}
/>

View File

@ -91,13 +91,15 @@ export const TableBlockInitializer = (props) => {
{
type: 'itemGroup',
title: t('Select data source'),
children: collections?.map((item) => {
return {
type: 'item',
name: item.name,
title: item.title,
};
}),
children: collections
?.filter((item) => !item.inherit)
?.map((item) => {
return {
type: 'item',
name: item.name,
title: item.title,
};
}),
},
]}
/>

View File

@ -57,7 +57,7 @@ const findTableColumn = (schema: Schema, key: string, action: string, deepth: nu
};
export const useTableColumnInitializerFields = () => {
const { name, fields } = useCollection();
const { name, fields = [] } = useCollection();
return fields
.filter((field) => field?.interface && field?.interface !== 'subTable')
.map((field) => {
@ -113,7 +113,7 @@ export const useFormItemInitializerFields = () => {
schema: {
type: 'void',
name: field.name,
'x-designer': 'FormItem.Designer',
'x-designer': 'Table.Array.Designer',
'x-component': 'div',
'x-decorator': 'FormItem',
'x-collection-field': `${name}.${field.name}`,