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