fix(plugin-workflow): fix CollectionFieldSelect component (#598)
This commit is contained in:
parent
740e50bfe4
commit
f951ba1745
@ -1,12 +1,45 @@
|
||||
import React from "react";
|
||||
import { Cascader } from 'antd';
|
||||
import { Select, Cascader } from 'antd';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { useCollectionFilterOptions, useCompile } from "@nocobase/client";
|
||||
import { useCollectionManager, useCollectionFilterOptions, useCompile } from "@nocobase/client";
|
||||
|
||||
|
||||
|
||||
export default function (props) {
|
||||
const { collection, value, onChange } = props;
|
||||
const { t } = useTranslation();
|
||||
const compile = useCompile();
|
||||
const { getCollectionFields } = useCollectionManager();
|
||||
const fields = getCollectionFields(collection)
|
||||
.filter(field => field.interface && (!field.target || field.type === 'belongsTo'))
|
||||
.map(field => field.type === 'belongsTo'
|
||||
? {
|
||||
title: `${compile(field.uiSchema?.title || field.name)} ID`,
|
||||
name: field.foreignKey
|
||||
}
|
||||
: {
|
||||
title: compile(field.uiSchema?.title || field.name),
|
||||
name: field.name
|
||||
});
|
||||
|
||||
return (
|
||||
<Select
|
||||
placeholder={t('Fields')}
|
||||
value={value}
|
||||
onChange={onChange}
|
||||
>
|
||||
{fields
|
||||
.map(field => (
|
||||
<Select.Option key={field.name} value={field.name}>{field.title}</Select.Option>
|
||||
))
|
||||
}
|
||||
</Select>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
function SelectWithAssociations(props) {
|
||||
const { collection, value, onChange } = props;
|
||||
const { t } = useTranslation();
|
||||
const compile = useCompile();
|
||||
|
Loading…
Reference in New Issue
Block a user