mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-07-01 18:52:20 +08:00
Merge branch 'main' into next
This commit is contained in:
commit
982936963b
@ -191,6 +191,9 @@ const quickCreate: any = {
|
||||
title: "{{t('Add new')}}",
|
||||
// 'x-designer': 'Action.Designer',
|
||||
'x-toolbar': 'ActionSchemaToolbar',
|
||||
'x-toolbar-props': {
|
||||
draggable: false,
|
||||
},
|
||||
'x-settings': 'actionSettings:addNew',
|
||||
'x-component': 'Action',
|
||||
'x-decorator': 'ACLActionProvider',
|
||||
|
@ -14,7 +14,7 @@ import { uid } from '@formily/shared';
|
||||
import { Space, message } from 'antd';
|
||||
import { isEqual } from 'lodash';
|
||||
import { isFunction } from 'mathjs';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import React, { useEffect, useState, useContext } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import {
|
||||
ClearCollectionFieldContext,
|
||||
@ -22,6 +22,7 @@ import {
|
||||
RecordProvider,
|
||||
useAPIClient,
|
||||
useCollectionRecordData,
|
||||
SchemaComponentContext,
|
||||
} from '../../../';
|
||||
import { isVariable } from '../../../variables/utils/isVariable';
|
||||
import { getInnermostKeyAndValue } from '../../common/utils/uitls';
|
||||
@ -75,6 +76,8 @@ const InternalAssociationSelect = observer(
|
||||
const api = useAPIClient();
|
||||
const resource = api.resource(collectionField.target);
|
||||
const recordData = useCollectionRecordData();
|
||||
const schemaComponentCtxValue = useContext(SchemaComponentContext);
|
||||
|
||||
useEffect(() => {
|
||||
const initValue = isVariable(field.value) ? undefined : field.value;
|
||||
const value = Array.isArray(initValue) ? initValue.filter(Boolean) : initValue;
|
||||
@ -155,19 +158,21 @@ const InternalAssociationSelect = observer(
|
||||
></RemoteSelect>
|
||||
|
||||
{addMode === 'modalAdd' && (
|
||||
<RecordProvider isNew={true} record={null} parent={recordData}>
|
||||
{/* 快捷添加按钮添加的添加的是一个普通的 form 区块(非关系区块),不应该与任何字段有关联,所以在这里把字段相关的上下文给清除掉 */}
|
||||
<ClearCollectionFieldContext>
|
||||
<NocoBaseRecursionField
|
||||
onlyRenderProperties
|
||||
basePath={field.address}
|
||||
schema={fieldSchema}
|
||||
filterProperties={(s) => {
|
||||
return s['x-component'] === 'Action';
|
||||
}}
|
||||
/>
|
||||
</ClearCollectionFieldContext>
|
||||
</RecordProvider>
|
||||
<SchemaComponentContext.Provider value={{ ...schemaComponentCtxValue, draggable: false }}>
|
||||
<RecordProvider isNew={true} record={null} parent={recordData}>
|
||||
{/* 快捷添加按钮添加的添加的是一个普通的 form 区块(非关系区块),不应该与任何字段有关联,所以在这里把字段相关的上下文给清除掉 */}
|
||||
<ClearCollectionFieldContext>
|
||||
<NocoBaseRecursionField
|
||||
onlyRenderProperties
|
||||
basePath={field.address}
|
||||
schema={fieldSchema}
|
||||
filterProperties={(s) => {
|
||||
return s['x-component'] === 'Action';
|
||||
}}
|
||||
/>
|
||||
</ClearCollectionFieldContext>
|
||||
</RecordProvider>
|
||||
</SchemaComponentContext.Provider>
|
||||
)}
|
||||
</Space.Compact>
|
||||
</div>
|
||||
|
@ -13,7 +13,17 @@ import { useField, useFieldSchema } from '@formily/react';
|
||||
import { Space } from 'antd';
|
||||
import classNames from 'classnames';
|
||||
// @ts-ignore
|
||||
import React, { createContext, FC, startTransition, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
||||
import React, {
|
||||
createContext,
|
||||
FC,
|
||||
startTransition,
|
||||
useCallback,
|
||||
useEffect,
|
||||
useMemo,
|
||||
useRef,
|
||||
useState,
|
||||
useContext,
|
||||
} from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { SchemaInitializer, SchemaSettings, SchemaToolbarProvider, useSchemaInitializerRender } from '../application';
|
||||
import { useSchemaSettingsRender } from '../application/schema-settings/hooks/useSchemaSettingsRender';
|
||||
@ -24,6 +34,7 @@ import { DragHandler, useCompile, useDesignable, useGridContext, useGridRowConte
|
||||
import { gridRowColWrap } from '../schema-initializer/utils';
|
||||
import { SchemaSettingsDropdown } from './SchemaSettings';
|
||||
import { useGetAriaLabelOfDesigner } from './hooks/useGetAriaLabelOfDesigner';
|
||||
import { SchemaComponentContext } from '../';
|
||||
import { useStyles } from './styles';
|
||||
|
||||
const titleCss = css`
|
||||
@ -221,6 +232,7 @@ const InternalSchemaToolbar: FC<SchemaToolbarProps> = React.memo((props) => {
|
||||
...(fieldSchema?.['x-toolbar-props'] || {}),
|
||||
} as SchemaToolbarProps;
|
||||
const compile = useCompile();
|
||||
const { draggable: draggableCtx } = useContext(SchemaComponentContext);
|
||||
const { componentCls, hashId } = useStyles();
|
||||
const { t } = useTranslation();
|
||||
const { getAriaLabel } = useGetAriaLabelOfDesigner();
|
||||
@ -266,13 +278,13 @@ const InternalSchemaToolbar: FC<SchemaToolbarProps> = React.memo((props) => {
|
||||
}, [getAriaLabel, rowCtx?.cols?.length]);
|
||||
|
||||
const dragElement = useMemo(() => {
|
||||
if (draggable === false) return null;
|
||||
if (draggable === false || draggableCtx === false) return null;
|
||||
return (
|
||||
<DragHandler>
|
||||
<DragOutlined role="button" aria-label={getAriaLabel('drag-handler')} />
|
||||
</DragHandler>
|
||||
);
|
||||
}, [draggable, getAriaLabel]);
|
||||
}, [draggable, getAriaLabel, draggableCtx]);
|
||||
|
||||
const initializerElement = useMemo(() => {
|
||||
if (initializer === false) return null;
|
||||
|
Loading…
x
Reference in New Issue
Block a user