Merge branch 'main' into next

This commit is contained in:
Zeke Zhang 2024-09-26 10:28:12 +08:00
commit cdc188c8c8
2 changed files with 14 additions and 7 deletions

View File

@ -13,6 +13,6 @@ export * from './FixedBlockDesignerItem';
export * from './Page'; export * from './Page';
export * from './Page.Settings'; export * from './Page.Settings';
export { PagePopups } from './PagePopups'; export { PagePopups } from './PagePopups';
export { storePopupContext, getStoredPopupContext, withSearchParams, getPopupPathFromParams } from './pagePopupUtils'; export { getPopupPathFromParams, getStoredPopupContext, storePopupContext, withSearchParams } from './pagePopupUtils';
export * from './PageTab.Settings'; export * from './PageTab.Settings';
export { PopupSettingsProvider } from './PopupSettingsProvider'; export { PopupSettingsProvider, usePopupSettings } from './PopupSettingsProvider';

View File

@ -17,12 +17,13 @@ import {
PopupContextProvider, PopupContextProvider,
useCollection, useCollection,
useCollectionRecordData, useCollectionRecordData,
usePopupSettings,
usePopupUtils, usePopupUtils,
VariablePopupRecordProvider, VariablePopupRecordProvider,
} from '@nocobase/client'; } from '@nocobase/client';
import { Schema } from '@nocobase/utils'; import { Schema } from '@nocobase/utils';
import { Card } from 'antd'; import { Card } from 'antd';
import React, { useCallback, useContext, useMemo } from 'react'; import React, { useCallback, useContext, useMemo, useState } from 'react';
import { KanbanCardContext } from './context'; import { KanbanCardContext } from './context';
const cardCss = css` const cardCss = css`
@ -74,14 +75,20 @@ export const KanbanCard: any = observer(
const { openPopup, getPopupSchemaFromSchema } = usePopupUtils(); const { openPopup, getPopupSchemaFromSchema } = usePopupUtils();
const recordData = useCollectionRecordData(); const recordData = useCollectionRecordData();
const popupSchema = getPopupSchemaFromSchema(fieldSchema) || getPopupSchemaFromParent(fieldSchema); const popupSchema = getPopupSchemaFromSchema(fieldSchema) || getPopupSchemaFromParent(fieldSchema);
const [visible, setVisible] = useState(false);
const { isPopupVisibleControlledByURL } = usePopupSettings();
const handleCardClick = useCallback( const handleCardClick = useCallback(
(e: React.MouseEvent) => { (e: React.MouseEvent) => {
const targetElement = e.target as Element; // 将事件目标转换为Element类型 const targetElement = e.target as Element; // 将事件目标转换为Element类型
const currentTargetElement = e.currentTarget as Element; const currentTargetElement = e.currentTarget as Element;
if (currentTargetElement.contains(targetElement)) { if (currentTargetElement.contains(targetElement)) {
openPopup({ if (!isPopupVisibleControlledByURL()) {
popupUidUsedInURL: popupSchema?.['x-uid'], setVisible(true);
}); } else {
openPopup({
popupUidUsedInURL: popupSchema?.['x-uid'],
});
}
e.stopPropagation(); e.stopPropagation();
} else { } else {
e.stopPropagation(); e.stopPropagation();
@ -130,7 +137,7 @@ export const KanbanCard: any = observer(
</FormLayout> </FormLayout>
</DndContext> </DndContext>
</Card> </Card>
<PopupContextProvider> <PopupContextProvider visible={visible} setVisible={setVisible}>
<VariablePopupRecordProvider recordData={recordData} collection={collection}> <VariablePopupRecordProvider recordData={recordData} collection={collection}>
<MemorizedRecursionField schema={wrappedPopupSchema} /> <MemorizedRecursionField schema={wrappedPopupSchema} />
</VariablePopupRecordProvider> </VariablePopupRecordProvider>