chenos 3e3cb416b6
feat: improve collection hooks/fields/actions/views... (#30)
* feat: add onFinish callback

* fix: update json attribute unsaved after query

* refactor: collection hooks

* feat: add migrate options
2020-12-04 21:09:39 +08:00

41 lines
988 B
TypeScript

import React, { useRef } from 'react';
import { Button } from 'antd';
import ViewFactory from '@/components/views';
export function Create(props) {
console.log(props);
const { title, viewName, collection_name } = props.schema;
const { activeTab = {}, item = {}, associatedName, associatedKey } = props;
const { association } = activeTab;
const params = {};
if (association) {
params['resourceName'] = association;
params['associatedName'] = associatedName;
params['associatedKey'] = associatedKey;
} else {
params['resourceName'] = collection_name;
params['resourceKey'] = item.itemId;
}
console.log(params);
const drawerRef = useRef<any>();
return (
<>
<ViewFactory
{...props}
reference={drawerRef}
viewName={viewName}
{...params}
/>
<Button type={'primary'} onClick={() => {
drawerRef.current.setVisible(true);
}}>{title}</Button>
</>
)
}
export default Create;