mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-07-01 18:52:20 +08:00
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:
parent
231f4c7cd4
commit
b111f827ed
@ -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>
|
||||
);
|
||||
};
|
||||
|
@ -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);
|
||||
|
@ -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,
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user