Skip to content

Commit

Permalink
fix: add child action should omit children data (nocobase#2969)
Browse files Browse the repository at this point in the history
* refactor: expand action locale

* fix: add child action should omit children data
  • Loading branch information
katherinehhh authored Nov 5, 2023
1 parent 2c58d51 commit b109a57
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions packages/core/client/src/block-provider/hooks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ export const useCreateActionProps = () => {
// const values = omitBy(formValues, (value) => isEqual(JSON.stringify(value), '[{}]'));
if (addChild) {
const treeParentField = getTreeParentField();
values[treeParentField?.name ?? 'parent'] = currentRecord?.__parent;
values[treeParentField?.name ?? 'parent'] = omit(currentRecord?.__parent, ['children']);
values[treeParentField?.foreignKey ?? 'parentId'] = currentRecord?.__parent?.id;
}
actionField.data = field.data || {};
Expand All @@ -182,10 +182,10 @@ export const useCreateActionProps = () => {
? triggerWorkflows.map((row) => [row.workflowKey, row.context].filter(Boolean).join('!')).join(',')
: undefined,
});
setVisible?.(false);
actionField.data.loading = false;
actionField.data.data = data;
__parent?.service?.refresh?.();
setVisible?.(false);
if (!onSuccess?.successMessage) {
message.success(t('Saved successfully'));
await form.reset();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { css } from '@emotion/css';
import { useFieldSchema } from '@formily/react';
import { Button } from 'antd';
import React from 'react';
import { useCompile } from '../../hooks';
import { useTableBlockContext, useTableSelectorContext } from '../../../block-provider';
import { Icon } from '../../../icon';

Expand Down Expand Up @@ -52,6 +53,7 @@ export const ExpandAction = (props) => {
const isTableSelector = schema.parent?.parent?.['x-decorator'] === 'TableSelectorProvider';
const ctx = isTableSelector ? ctxSelector : ctxBlock;
const { titleExpand, titleCollapse, iconExpand, iconCollapse } = schema['x-component-props'] || {};
const compile = useCompile();
return (
<div className={actionDesignerCss}>
{ctx?.params['tree'] && (
Expand All @@ -62,8 +64,8 @@ export const ExpandAction = (props) => {
icon={<Icon type={ctx?.expandFlag ? iconCollapse : iconExpand} />}
type={props.type}
>
{props.children[1]}
<span style={{ marginLeft: 10 }}>{ctx?.expandFlag ? titleCollapse : titleExpand}</span>
{props.children?.[1]}
<span style={{ marginLeft: 10 }}>{ctx?.expandFlag ? compile(titleCollapse) : compile(titleExpand)}</span>
</Button>
)}
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import React from 'react';
import { useTranslation } from 'react-i18next';
import { ActionInitializer } from './ActionInitializer';

export const ExpandActionInitializer = (props) => {
const { t } = useTranslation();
const schema = {
'x-action': 'expandAll',
'x-component': 'Action',
'x-designer': 'Expand.Action.Design',
'x-component-props': {
titleExpand: t('Expand all'),
titleCollapse: t('Collapse all'),
titleExpand: "{{t('Expand all')}}",
titleCollapse: "{{t('Collapse all')}}",
iconExpand: 'nodeexpandoutlined',
iconCollapse: 'nodecollapseoutlined',
component: 'Expand.Action',
Expand Down

0 comments on commit b109a57

Please sign in to comment.