fix(view-collection): field name cannot be edited when there with field source (#1642)
* fix: field name cannot be edited when there with field source * fix: did not bring the uiSchema when selecting interface
This commit is contained in:
parent
ffcf1d9cf1
commit
c38dbd1675
@ -30,7 +30,7 @@ const PreviewCom = (props) => {
|
||||
const [sourceFields, setSourceFields] = useState([]);
|
||||
const field: any = useField();
|
||||
const form = useForm();
|
||||
const { getCollection } = useCollectionManager();
|
||||
const { getCollection, getInterface } = useCollectionManager();
|
||||
const compile = useCompile();
|
||||
const initOptions = getOptions().filter((v) => !['relation', 'systemInfo'].includes(v.key));
|
||||
useEffect(() => {
|
||||
@ -148,7 +148,10 @@ const PreviewCom = (props) => {
|
||||
<Select
|
||||
defaultValue={text}
|
||||
style={{ width: '100%' }}
|
||||
onChange={(value) => handleFieldChange({ ...item, interface: value }, index)}
|
||||
onChange={(value) => {
|
||||
const interfaceConfig = getInterface(value);
|
||||
handleFieldChange({ ...item, interface: value, uiSchema: interfaceConfig?.default?.uiSchema }, index);
|
||||
}}
|
||||
>
|
||||
{data.map((group) => (
|
||||
<Select.OptGroup key={group.key} label={compile(group.label)}>
|
||||
@ -170,12 +173,12 @@ const PreviewCom = (props) => {
|
||||
width: 180,
|
||||
render: (text, record, index) => {
|
||||
const item = dataSource[index];
|
||||
return item.source ? (
|
||||
record?.uiSchema?.title
|
||||
) : (
|
||||
return (
|
||||
<Input
|
||||
defaultValue={record?.uiSchema?.title}
|
||||
onChange={(e) => handleFieldChange({ ...item, uiSchema: { title: e.target.value } }, index)}
|
||||
onChange={(e) =>
|
||||
handleFieldChange({ ...item, uiSchema: { ...item?.uiSchema, title: e.target.value } }, index)
|
||||
}
|
||||
/>
|
||||
);
|
||||
},
|
||||
|
@ -47,7 +47,7 @@ export const PreviewTable = (props) => {
|
||||
const fieldSource = typeof item?.source === 'string' ? item?.source?.split('.') : item?.source;
|
||||
const sourceField = getCollection(fieldSource?.[0])?.fields.find((v) => v.name === fieldSource?.[1])?.uiSchema
|
||||
?.title;
|
||||
const target = sourceField || item?.uiSchema?.title || item.name;
|
||||
const target = item?.uiSchema?.title || sourceField || item.name;
|
||||
const schema: any = item.source
|
||||
? getCollectionField(typeof item.source === 'string' ? item.source : item.source.join('.'))?.uiSchema
|
||||
: getInterface(item.interface)?.default?.uiSchema;
|
||||
|
Loading…
Reference in New Issue
Block a user