mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 07:06:06 +00:00
fix: useValuesFromRecord with cloneDeep (#2902)
* fix: useValuesFromRecord with cloneDeep * fix: omit uiSchema.rawTitle * fix: disabled
This commit is contained in:
parent
e2a420afcd
commit
d492471ed5
@ -38,7 +38,7 @@ const useEditCategry = () => {
|
||||
|
||||
const useValuesFromRecord = (options) => {
|
||||
const record = useRecord();
|
||||
const result = useRequest(() => Promise.resolve({ data: { ...record } }), {
|
||||
const result = useRequest(() => Promise.resolve({ data: cloneDeep(record) }), {
|
||||
...options,
|
||||
manual: true,
|
||||
});
|
||||
|
@ -81,7 +81,10 @@ export const useValuesFromRecord = (options) => {
|
||||
const result = useRequest(
|
||||
() =>
|
||||
Promise.resolve({
|
||||
data: { ...omit(record, ['__parent', '__collectionName']), category: record?.category.map((v) => v.id) },
|
||||
data: {
|
||||
...omit(cloneDeep(record), ['__parent', '__collectionName']),
|
||||
category: record?.category.map((v) => v.id),
|
||||
},
|
||||
}),
|
||||
{
|
||||
...options,
|
||||
|
@ -2,17 +2,18 @@ import { ArrayTable } from '@formily/antd-v5';
|
||||
import { ISchema, useForm } from '@formily/react';
|
||||
import { uid } from '@formily/shared';
|
||||
import cloneDeep from 'lodash/cloneDeep';
|
||||
import omit from 'lodash/omit';
|
||||
import set from 'lodash/set';
|
||||
import React, { useMemo, useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useAPIClient, useRequest } from '../../api-client';
|
||||
import { RecordProvider, useRecord } from '../../record-provider';
|
||||
import { ActionContextProvider, SchemaComponent, useActionContext, useCompile } from '../../schema-component';
|
||||
import { useResourceActionContext, useResourceContext } from '../ResourceActionProvider';
|
||||
import { useCancelAction, useUpdateAction } from '../action-hooks';
|
||||
import { useCollectionManager } from '../hooks';
|
||||
import useDialect from '../hooks/useDialect';
|
||||
import { IField } from '../interfaces/types';
|
||||
import { useResourceActionContext, useResourceContext } from '../ResourceActionProvider';
|
||||
import * as components from './components';
|
||||
|
||||
const getSchema = (schema: IField, record: any, compile, getContainer): ISchema => {
|
||||
@ -64,7 +65,7 @@ const getSchema = (schema: IField, record: any, compile, getContainer): ISchema
|
||||
return useRequest(
|
||||
() =>
|
||||
Promise.resolve({
|
||||
data: cloneDeep(schema.default),
|
||||
data: cloneDeep(omit(schema.default, ['uiSchema.rawTitle'])),
|
||||
}),
|
||||
options,
|
||||
);
|
||||
|
@ -1,5 +1,6 @@
|
||||
import { useField, useForm } from '@formily/react';
|
||||
import { message } from 'antd';
|
||||
import cloneDeep from 'lodash/cloneDeep';
|
||||
import omit from 'lodash/omit';
|
||||
import { useEffect, useMemo } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
@ -23,10 +24,13 @@ export const useCancelAction = () => {
|
||||
|
||||
export const useValuesFromRecord = (options) => {
|
||||
const record = useRecord();
|
||||
const result = useRequest(() => Promise.resolve({ data: omit(record, ['__parent', '__collectionName']) }), {
|
||||
...options,
|
||||
manual: true,
|
||||
});
|
||||
const result = useRequest(
|
||||
() => Promise.resolve({ data: omit(cloneDeep(record), ['__parent', '__collectionName']) }),
|
||||
{
|
||||
...options,
|
||||
manual: true,
|
||||
},
|
||||
);
|
||||
const ctx = useActionContext();
|
||||
useEffect(() => {
|
||||
if (ctx.visible) {
|
||||
|
@ -10,12 +10,13 @@ import {
|
||||
} from '@nocobase/client';
|
||||
import { error, lodash } from '@nocobase/utils/client';
|
||||
import { Select, message } from 'antd';
|
||||
import cloneDeep from 'lodash/cloneDeep';
|
||||
import React, { useContext, useEffect } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { GraphCollectionContext } from './components/CollectionNodeProvder';
|
||||
|
||||
export const useValuesFromRecord = (options, data) => {
|
||||
const result = useRequest(() => Promise.resolve({ data }), {
|
||||
const result = useRequest(() => Promise.resolve({ data: cloneDeep(data) }), {
|
||||
...options,
|
||||
manual: true,
|
||||
});
|
||||
|
@ -110,7 +110,7 @@ export const formSchema: ISchema = {
|
||||
name: {
|
||||
'x-component': 'CollectionField',
|
||||
'x-decorator': 'FormItem',
|
||||
'x-visible': '{{ !!createOnly }}',
|
||||
'x-disabled': '{{ !createOnly }}',
|
||||
},
|
||||
pinned: {
|
||||
'x-component': 'CollectionField',
|
||||
|
Loading…
Reference in New Issue
Block a user