fix: restore useValuesFromRecord
This commit is contained in:
parent
dea9655573
commit
6799c9615d
@ -1,13 +1,12 @@
|
|||||||
import { message } from 'antd';
|
|
||||||
import omit from 'lodash/omit';
|
|
||||||
import { useEffect } from 'react';
|
|
||||||
import { useForm } from '@formily/react';
|
import { useForm } from '@formily/react';
|
||||||
|
import { message } from 'antd';
|
||||||
|
import { useEffect } from 'react';
|
||||||
import { useCollection, useCollectionManager } from '.';
|
import { useCollection, useCollectionManager } from '.';
|
||||||
import { useRequest } from '../api-client';
|
import { useRequest } from '../api-client';
|
||||||
import { useRecord } from '../record-provider';
|
import { useRecord } from '../record-provider';
|
||||||
import { useActionContext } from '../schema-component';
|
import { useActionContext } from '../schema-component';
|
||||||
|
import { useFilterFieldOptions, useFilterFieldProps } from '../schema-component/antd/filter/useFilterActionProps';
|
||||||
import { useResourceActionContext, useResourceContext } from './ResourceActionProvider';
|
import { useResourceActionContext, useResourceContext } from './ResourceActionProvider';
|
||||||
import { useFilterFieldProps, useFilterFieldOptions } from '../schema-component/antd/filter/useFilterActionProps';
|
|
||||||
|
|
||||||
export const useCancelAction = () => {
|
export const useCancelAction = () => {
|
||||||
const form = useForm();
|
const form = useForm();
|
||||||
@ -20,6 +19,21 @@ export const useCancelAction = () => {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const useValuesFromRecord = (options) => {
|
||||||
|
const record = useRecord();
|
||||||
|
const result = useRequest(() => Promise.resolve({ data: record }), {
|
||||||
|
...options,
|
||||||
|
manual: true,
|
||||||
|
});
|
||||||
|
const ctx = useActionContext();
|
||||||
|
useEffect(() => {
|
||||||
|
if (ctx.visible) {
|
||||||
|
result.run();
|
||||||
|
}
|
||||||
|
}, [ctx.visible]);
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
|
||||||
export const useResetFilterAction = () => {
|
export const useResetFilterAction = () => {
|
||||||
const { run } = useResourceActionContext();
|
const { run } = useResourceActionContext();
|
||||||
const form = useForm();
|
const form = useForm();
|
||||||
@ -166,7 +180,7 @@ export const useCreateAction = () => {
|
|||||||
return {
|
return {
|
||||||
async run() {
|
async run() {
|
||||||
await form.submit();
|
await form.submit();
|
||||||
await resource.create({ values: form.values});
|
await resource.create({ values: form.values });
|
||||||
ctx.setVisible(false);
|
ctx.setVisible(false);
|
||||||
await form.reset();
|
await form.reset();
|
||||||
refresh();
|
refresh();
|
||||||
@ -259,7 +273,6 @@ export const useBulkDestroyAction = () => {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export const useValuesFromRA = (options) => {
|
export const useValuesFromRA = (options) => {
|
||||||
const ctx = useResourceActionContext();
|
const ctx = useResourceActionContext();
|
||||||
return useRequest(() => Promise.resolve(ctx.data), {
|
return useRequest(() => Promise.resolve(ctx.data), {
|
||||||
|
Loading…
Reference in New Issue
Block a user