feat(data-vi): allows to add charts for mobile client (#3922)

* feat(data-vi): allows to add charts for mobile client

* fix: remove foreign keys
This commit is contained in:
YANG QIA 2024-04-04 00:06:30 +08:00 committed by GitHub
parent 231f4c7cd4
commit b111f827ed
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 23 additions and 80 deletions

View File

@ -7,7 +7,7 @@ export const getAntChart = (Component: React.FC<any>) => (props: any) => {
const [height, setHeight] = React.useState<number>(0);
useEffect(() => {
const el = chartRef.current;
if (!el || service.loading === true) {
if (!el || service.loading === true || props.height) {
return;
}
const observer = new ResizeObserver((entries) => {
@ -17,10 +17,10 @@ export const getAntChart = (Component: React.FC<any>) => (props: any) => {
});
observer.observe(el);
return () => observer.disconnect();
}, [service.loading]);
}, [service.loading, props.height]);
return (
<div ref={chartRef} style={height ? { height: `${height}px` } : {}}>
<Component {...props} {...(height ? { height } : {})} />
<div ref={chartRef} style={height ? { height: `${props.height || height}px` } : {}}>
<Component {...props} {...(height ? { height: props.height || height } : {})} />
</div>
);
};

View File

@ -230,7 +230,7 @@ export const useCollectionFieldsOptions = (dataSource: string, collectionName: s
const fields = collectionFields.filter((v) => !excludes.includes(v.interface));
const field2option = (field, depth, prefix?) => {
if (!field.interface) {
if (!field.interface || field.isForeignKey) {
return;
}
const fieldInterface = fim.getFieldInterface(field.interface);
@ -287,7 +287,7 @@ export const useCollectionFilterOptions = (dataSource: string, collection: strin
return useMemo(() => {
const fields = cm.getCollectionFields(collection || _collection);
const field2option = (field, depth) => {
if (!field.interface) {
if (!field.interface || field.isForeignKey) {
return;
}
const fieldInterface = fim.getFieldInterface(field.interface);

View File

@ -1,12 +1,8 @@
import { CompatibleSchemaInitializer, gridRowColWrap } from '@nocobase/client';
import { generateNTemplate } from '../../../locale';
/**
* @deprecated
* use `mBlockInitializers` instead
*/
export const mBlockInitializers_deprecated = new CompatibleSchemaInitializer({
name: 'MBlockInitializers',
const mBlockInitializersOptions = {
name: 'mobilePage:addBlock',
title: '{{t("Add block")}}',
icon: 'PlusOutlined',
wrap: gridRowColWrap,
@ -47,6 +43,11 @@ export const mBlockInitializers_deprecated = new CompatibleSchemaInitializer({
title: generateNTemplate('Map'),
Component: 'MapBlockInitializer',
},
{
name: 'charts',
title: '{{t("Charts")}}',
Component: 'ChartV2BlockInitializer',
},
],
},
{
@ -72,76 +73,18 @@ export const mBlockInitializers_deprecated = new CompatibleSchemaInitializer({
],
},
],
};
/**
* @deprecated
* use `mBlockInitializers` instead
*/
export const mBlockInitializers_deprecated = new CompatibleSchemaInitializer({
...mBlockInitializersOptions,
name: 'MBlockInitializers',
});
export const mBlockInitializers = new CompatibleSchemaInitializer(
{
name: 'mobilePage:addBlock',
title: '{{t("Add block")}}',
icon: 'PlusOutlined',
wrap: gridRowColWrap,
items: [
{
name: 'dataBlocks',
type: 'itemGroup',
title: '{{t("Data blocks")}}',
children: [
{
name: 'gridCard',
type: 'item',
title: '{{t("Grid Card")}}',
Component: 'GridCardBlockInitializer',
},
{
name: 'table',
title: '{{t("Table")}}',
Component: 'TableBlockInitializer',
},
{
name: 'form',
title: '{{t("Form")}}',
Component: 'FormBlockInitializer',
},
{
name: 'details',
title: '{{t("Details")}}',
Component: 'DetailsBlockInitializer',
},
{
name: 'calendar',
title: '{{t("Calendar")}}',
Component: 'CalendarBlockInitializer',
},
{
name: 'mapBlock',
title: generateNTemplate('Map'),
Component: 'MapBlockInitializer',
},
],
},
{
name: 'otherBlocks',
type: 'itemGroup',
title: '{{t("Other blocks")}}',
children: [
{
name: 'menu',
title: generateNTemplate('Menu'),
Component: 'MMenuBlockInitializer',
},
{
name: 'markdown',
title: '{{t("Markdown")}}',
Component: 'MarkdownBlockInitializer',
},
{
name: 'settings',
title: generateNTemplate('Settings'),
Component: 'MSettingsBlockInitializer',
},
],
},
],
},
mBlockInitializersOptions,
mBlockInitializers_deprecated,
);