refactor: code improve

This commit is contained in:
katherinehhh 2023-05-11 17:12:03 +08:00
parent 18ccd6e7e2
commit 86b2046a68
2 changed files with 2 additions and 4 deletions

View File

@ -20,9 +20,8 @@ const InternalAssociationSelect = observer((props: AssociationSelectProps) => {
const field: any = useField();
const fieldSchema = useFieldSchema();
const [visibleAddNewer, setVisibleAddNewer] = useState(false);
const { getField } = useCollection();
const { getCollectionJoinField } = useCollectionManager();
const collectionField = getField(field.props.name) || getCollectionJoinField(fieldSchema?.['x-collection-field']);
const collectionField = getCollectionJoinField(fieldSchema?.['x-collection-field']);
const service = useServiceOptions(props);
const isFilterForm = fieldSchema['x-designer'] === 'FormItem.FilterFormDesigner';
const isAllowAddNew = fieldSchema['x-add-new'];

View File

@ -32,8 +32,7 @@ export const ReadPrettyInternalViewer: React.FC = observer((props: any) => {
const fieldNames = useFieldNames(props);
const [visible, setVisible] = useState(false);
const insertViewer = useInsertSchema('Viewer');
const { getField } = useCollection();
const collectionField = getField(fieldSchema.name) || getCollectionJoinField(fieldSchema?.['x-collection-field']);
const collectionField = getCollectionJoinField(fieldSchema?.['x-collection-field']);
const [record, setRecord] = useState({});
const compile = useCompile();
const labelUiSchema = useLabelUiSchema(collectionField, fieldNames?.label || 'label');