mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-07-01 18:52:20 +08:00
fix: add action and field not working
This commit is contained in:
parent
5c19dc754a
commit
f51a0474ff
@ -49,11 +49,6 @@ interface AddActionButtonProps {
|
|||||||
items?: SubModelItemsType;
|
items?: SubModelItemsType;
|
||||||
}
|
}
|
||||||
|
|
||||||
const DefaultBtn = () => {
|
|
||||||
const { t } = useTranslation();
|
|
||||||
return <FlowSettingsButton icon={<SettingOutlined />}>{t('Configure actions')}</FlowSettingsButton>;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 专门用于添加动作模型的按钮组件
|
* 专门用于添加动作模型的按钮组件
|
||||||
*
|
*
|
||||||
@ -69,13 +64,17 @@ const AddActionButtonCore: React.FC<AddActionButtonProps> = ({
|
|||||||
model,
|
model,
|
||||||
subModelBaseClass = 'ActionFlowModel',
|
subModelBaseClass = 'ActionFlowModel',
|
||||||
subModelKey = 'actions',
|
subModelKey = 'actions',
|
||||||
children = <DefaultBtn />,
|
children,
|
||||||
subModelType = 'array',
|
subModelType = 'array',
|
||||||
items,
|
items,
|
||||||
filter,
|
filter,
|
||||||
onModelCreated,
|
onModelCreated,
|
||||||
onSubModelAdded,
|
onSubModelAdded,
|
||||||
}) => {
|
}) => {
|
||||||
|
const defaultChildren = useMemo(() => {
|
||||||
|
return <FlowSettingsButton icon={<SettingOutlined />}>{model.translate('Configure fields')}</FlowSettingsButton>;
|
||||||
|
}, [model]);
|
||||||
|
|
||||||
const allActionsItems = useMemo(() => {
|
const allActionsItems = useMemo(() => {
|
||||||
const actionClasses = model.flowEngine.filterModelClassByParent(subModelBaseClass);
|
const actionClasses = model.flowEngine.filterModelClassByParent(subModelBaseClass);
|
||||||
const registeredBlocks = [];
|
const registeredBlocks = [];
|
||||||
@ -109,7 +108,7 @@ const AddActionButtonCore: React.FC<AddActionButtonProps> = ({
|
|||||||
onModelCreated={onModelCreated}
|
onModelCreated={onModelCreated}
|
||||||
onSubModelAdded={onSubModelAdded}
|
onSubModelAdded={onSubModelAdded}
|
||||||
>
|
>
|
||||||
{children}
|
{children || defaultChildren}
|
||||||
</AddSubModelButton>
|
</AddSubModelButton>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -15,7 +15,6 @@ import { FlowModelOptions, ModelConstructor } from '../../types';
|
|||||||
import { FlowSettingsButton } from '../common/FlowSettingsButton';
|
import { FlowSettingsButton } from '../common/FlowSettingsButton';
|
||||||
import { withFlowDesignMode } from '../common/withFlowDesignMode';
|
import { withFlowDesignMode } from '../common/withFlowDesignMode';
|
||||||
import { AddSubModelButton, SubModelItemsType, mergeSubModelItems } from './AddSubModelButton';
|
import { AddSubModelButton, SubModelItemsType, mergeSubModelItems } from './AddSubModelButton';
|
||||||
import { useTranslation } from 'react-i18next';
|
|
||||||
|
|
||||||
export type BuildCreateModelOptionsType = {
|
export type BuildCreateModelOptionsType = {
|
||||||
defaultOptions: FlowModelOptions;
|
defaultOptions: FlowModelOptions;
|
||||||
@ -66,11 +65,6 @@ function defaultBuildCreateModelOptions({ defaultOptions }: BuildCreateModelOpti
|
|||||||
return defaultOptions;
|
return defaultOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
const DefaultBtn = () => {
|
|
||||||
const { t } = useTranslation();
|
|
||||||
return <FlowSettingsButton icon={<SettingOutlined />}>{t('Configure fields')}</FlowSettingsButton>;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 专门用于添加字段模型的按钮组件
|
* 专门用于添加字段模型的按钮组件
|
||||||
*
|
*
|
||||||
@ -86,7 +80,7 @@ const AddFieldButtonCore: React.FC<AddFieldButtonProps> = ({
|
|||||||
model,
|
model,
|
||||||
subModelBaseClass = 'FieldFlowModel',
|
subModelBaseClass = 'FieldFlowModel',
|
||||||
subModelKey = 'fields',
|
subModelKey = 'fields',
|
||||||
children = <DefaultBtn />,
|
children,
|
||||||
subModelType = 'array',
|
subModelType = 'array',
|
||||||
collection,
|
collection,
|
||||||
buildCreateModelOptions = defaultBuildCreateModelOptions,
|
buildCreateModelOptions = defaultBuildCreateModelOptions,
|
||||||
@ -96,6 +90,9 @@ const AddFieldButtonCore: React.FC<AddFieldButtonProps> = ({
|
|||||||
onSubModelAdded,
|
onSubModelAdded,
|
||||||
}) => {
|
}) => {
|
||||||
const fields = collection.getFields();
|
const fields = collection.getFields();
|
||||||
|
const defaultChildren = useMemo(() => {
|
||||||
|
return <FlowSettingsButton icon={<SettingOutlined />}>{model.translate('Configure fields')}</FlowSettingsButton>;
|
||||||
|
}, [model]);
|
||||||
|
|
||||||
// 构建字段 items 的函数
|
// 构建字段 items 的函数
|
||||||
const buildFieldItems = useMemo<SubModelItemsType>(() => {
|
const buildFieldItems = useMemo<SubModelItemsType>(() => {
|
||||||
@ -169,7 +166,7 @@ const AddFieldButtonCore: React.FC<AddFieldButtonProps> = ({
|
|||||||
onModelCreated={onModelCreated}
|
onModelCreated={onModelCreated}
|
||||||
onSubModelAdded={onSubModelAdded}
|
onSubModelAdded={onSubModelAdded}
|
||||||
>
|
>
|
||||||
{children}
|
{children || defaultChildren}
|
||||||
</AddSubModelButton>
|
</AddSubModelButton>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user