mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 13:06:31 +00:00
refactor: useFieldModeOptions (#2612)
* refactor: useFieldModeOptions * refactor: code improve * refactor: code improve
This commit is contained in:
parent
f82b466aaa
commit
0d465f4d71
@ -1,4 +1,4 @@
|
|||||||
import { useField, useFieldSchema } from '@formily/react';
|
import { useField, useFieldSchema, useForm } from '@formily/react';
|
||||||
import { useMemo } from 'react';
|
import { useMemo } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { useCollection, useCollectionManager } from '../../collection-manager';
|
import { useCollection, useCollectionManager } from '../../collection-manager';
|
||||||
@ -8,7 +8,8 @@ export const useFieldModeOptions = (props?) => {
|
|||||||
const currentFieldSchema = useFieldSchema();
|
const currentFieldSchema = useFieldSchema();
|
||||||
const fieldSchema = props?.fieldSchema || currentFieldSchema;
|
const fieldSchema = props?.fieldSchema || currentFieldSchema;
|
||||||
const field = useField();
|
const field = useField();
|
||||||
const isReadPretty = field.readPretty;
|
const form = useForm();
|
||||||
|
const isReadPretty = field.readPretty && form.readPretty;
|
||||||
const isSubTableField = props?.fieldSchema;
|
const isSubTableField = props?.fieldSchema;
|
||||||
const { getField } = useCollection();
|
const { getField } = useCollection();
|
||||||
const collectionField = getField(fieldSchema['name']) || getCollectionJoinField(fieldSchema['x-collection-field']);
|
const collectionField = getField(fieldSchema['name']) || getCollectionJoinField(fieldSchema['x-collection-field']);
|
||||||
|
@ -47,6 +47,7 @@ import {
|
|||||||
getInheritCollections,
|
getInheritCollections,
|
||||||
getPopupContainer,
|
getPopupContainer,
|
||||||
useGCMTranslation,
|
useGCMTranslation,
|
||||||
|
cleanGraphContainer,
|
||||||
} from './utils';
|
} from './utils';
|
||||||
const { drop, groupBy, last, maxBy, minBy, take, uniq } = lodash;
|
const { drop, groupBy, last, maxBy, minBy, take, uniq } = lodash;
|
||||||
|
|
||||||
@ -628,7 +629,6 @@ export const GraphDrawPage = React.memo(() => {
|
|||||||
targetGraph.selectedCollections = queryString;
|
targetGraph.selectedCollections = queryString;
|
||||||
};
|
};
|
||||||
const handleConnectionParents = (collections) => {
|
const handleConnectionParents = (collections) => {
|
||||||
console.log(collections);
|
|
||||||
let data = targetGraph.selectedCollections.split(',') || [];
|
let data = targetGraph.selectedCollections.split(',') || [];
|
||||||
data = data.concat(collections);
|
data = data.concat(collections);
|
||||||
const queryString = uniq(data).toString();
|
const queryString = uniq(data).toString();
|
||||||
@ -1079,6 +1079,9 @@ export const GraphDrawPage = React.memo(() => {
|
|||||||
} else {
|
} else {
|
||||||
!selectedCollections && renderInitGraphCollection(collections);
|
!selectedCollections && renderInitGraphCollection(collections);
|
||||||
}
|
}
|
||||||
|
return () => {
|
||||||
|
cleanGraphContainer();
|
||||||
|
};
|
||||||
}, [searchParams, collectionList]);
|
}, [searchParams, collectionList]);
|
||||||
|
|
||||||
const loadCollections = async () => {
|
const loadCollections = async () => {
|
||||||
|
@ -30,9 +30,6 @@ export const SelectCollectionsAction = (props) => {
|
|||||||
getPopupContainer={getPopupContainer}
|
getPopupContainer={getPopupContainer}
|
||||||
mode="multiple"
|
mode="multiple"
|
||||||
allowClear
|
allowClear
|
||||||
onSearch={(value) => {
|
|
||||||
console.log(value);
|
|
||||||
}}
|
|
||||||
options={collectionOptions}
|
options={collectionOptions}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
style={{ minWidth: 200, position: 'fixed', margin: '24px', zIndex: 1000, maxWidth: '60%' }}
|
style={{ minWidth: 200, position: 'fixed', margin: '24px', zIndex: 1000, maxWidth: '60%' }}
|
||||||
|
@ -552,3 +552,7 @@ export const getPopupContainer = () => {
|
|||||||
}
|
}
|
||||||
return (graphContainer = document.getElementById('graph_container'));
|
return (graphContainer = document.getElementById('graph_container'));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const cleanGraphContainer = () => {
|
||||||
|
graphContainer = null;
|
||||||
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user