fix: add child action should omit children data (#2969)
* refactor: expand action locale * fix: add child action should omit children data
This commit is contained in:
parent
2c58d515da
commit
b109a5751b
@ -164,7 +164,7 @@ export const useCreateActionProps = () => {
|
|||||||
// const values = omitBy(formValues, (value) => isEqual(JSON.stringify(value), '[{}]'));
|
// const values = omitBy(formValues, (value) => isEqual(JSON.stringify(value), '[{}]'));
|
||||||
if (addChild) {
|
if (addChild) {
|
||||||
const treeParentField = getTreeParentField();
|
const treeParentField = getTreeParentField();
|
||||||
values[treeParentField?.name ?? 'parent'] = currentRecord?.__parent;
|
values[treeParentField?.name ?? 'parent'] = omit(currentRecord?.__parent, ['children']);
|
||||||
values[treeParentField?.foreignKey ?? 'parentId'] = currentRecord?.__parent?.id;
|
values[treeParentField?.foreignKey ?? 'parentId'] = currentRecord?.__parent?.id;
|
||||||
}
|
}
|
||||||
actionField.data = field.data || {};
|
actionField.data = field.data || {};
|
||||||
@ -182,10 +182,10 @@ export const useCreateActionProps = () => {
|
|||||||
? triggerWorkflows.map((row) => [row.workflowKey, row.context].filter(Boolean).join('!')).join(',')
|
? triggerWorkflows.map((row) => [row.workflowKey, row.context].filter(Boolean).join('!')).join(',')
|
||||||
: undefined,
|
: undefined,
|
||||||
});
|
});
|
||||||
|
setVisible?.(false);
|
||||||
actionField.data.loading = false;
|
actionField.data.loading = false;
|
||||||
actionField.data.data = data;
|
actionField.data.data = data;
|
||||||
__parent?.service?.refresh?.();
|
__parent?.service?.refresh?.();
|
||||||
setVisible?.(false);
|
|
||||||
if (!onSuccess?.successMessage) {
|
if (!onSuccess?.successMessage) {
|
||||||
message.success(t('Saved successfully'));
|
message.success(t('Saved successfully'));
|
||||||
await form.reset();
|
await form.reset();
|
||||||
|
@ -2,6 +2,7 @@ import { css } from '@emotion/css';
|
|||||||
import { useFieldSchema } from '@formily/react';
|
import { useFieldSchema } from '@formily/react';
|
||||||
import { Button } from 'antd';
|
import { Button } from 'antd';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import { useCompile } from '../../hooks';
|
||||||
import { useTableBlockContext, useTableSelectorContext } from '../../../block-provider';
|
import { useTableBlockContext, useTableSelectorContext } from '../../../block-provider';
|
||||||
import { Icon } from '../../../icon';
|
import { Icon } from '../../../icon';
|
||||||
|
|
||||||
@ -52,6 +53,7 @@ export const ExpandAction = (props) => {
|
|||||||
const isTableSelector = schema.parent?.parent?.['x-decorator'] === 'TableSelectorProvider';
|
const isTableSelector = schema.parent?.parent?.['x-decorator'] === 'TableSelectorProvider';
|
||||||
const ctx = isTableSelector ? ctxSelector : ctxBlock;
|
const ctx = isTableSelector ? ctxSelector : ctxBlock;
|
||||||
const { titleExpand, titleCollapse, iconExpand, iconCollapse } = schema['x-component-props'] || {};
|
const { titleExpand, titleCollapse, iconExpand, iconCollapse } = schema['x-component-props'] || {};
|
||||||
|
const compile = useCompile();
|
||||||
return (
|
return (
|
||||||
<div className={actionDesignerCss}>
|
<div className={actionDesignerCss}>
|
||||||
{ctx?.params['tree'] && (
|
{ctx?.params['tree'] && (
|
||||||
@ -62,8 +64,8 @@ export const ExpandAction = (props) => {
|
|||||||
icon={<Icon type={ctx?.expandFlag ? iconCollapse : iconExpand} />}
|
icon={<Icon type={ctx?.expandFlag ? iconCollapse : iconExpand} />}
|
||||||
type={props.type}
|
type={props.type}
|
||||||
>
|
>
|
||||||
{props.children[1]}
|
{props.children?.[1]}
|
||||||
<span style={{ marginLeft: 10 }}>{ctx?.expandFlag ? titleCollapse : titleExpand}</span>
|
<span style={{ marginLeft: 10 }}>{ctx?.expandFlag ? compile(titleCollapse) : compile(titleExpand)}</span>
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,16 +1,14 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
|
||||||
import { ActionInitializer } from './ActionInitializer';
|
import { ActionInitializer } from './ActionInitializer';
|
||||||
|
|
||||||
export const ExpandActionInitializer = (props) => {
|
export const ExpandActionInitializer = (props) => {
|
||||||
const { t } = useTranslation();
|
|
||||||
const schema = {
|
const schema = {
|
||||||
'x-action': 'expandAll',
|
'x-action': 'expandAll',
|
||||||
'x-component': 'Action',
|
'x-component': 'Action',
|
||||||
'x-designer': 'Expand.Action.Design',
|
'x-designer': 'Expand.Action.Design',
|
||||||
'x-component-props': {
|
'x-component-props': {
|
||||||
titleExpand: t('Expand all'),
|
titleExpand: "{{t('Expand all')}}",
|
||||||
titleCollapse: t('Collapse all'),
|
titleCollapse: "{{t('Collapse all')}}",
|
||||||
iconExpand: 'nodeexpandoutlined',
|
iconExpand: 'nodeexpandoutlined',
|
||||||
iconCollapse: 'nodecollapseoutlined',
|
iconCollapse: 'nodecollapseoutlined',
|
||||||
component: 'Expand.Action',
|
component: 'Expand.Action',
|
||||||
|
Loading…
Reference in New Issue
Block a user