mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-08 06:59:26 +08:00
Merge branch 'main' into next
This commit is contained in:
commit
be28e6325d
@ -281,13 +281,14 @@ export const useBlockAssociationContext = () => {
|
|||||||
return useContext(BlockAssociationContext) || association;
|
return useContext(BlockAssociationContext) || association;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const useFilterByTk = () => {
|
export const useFilterByTk = (blockProps?: any) => {
|
||||||
const { resource, __parent } = useBlockRequestContext();
|
const { resource, __parent } = useBlockRequestContext();
|
||||||
const recordIndex = useRecordIndex();
|
const recordIndex = useRecordIndex();
|
||||||
const recordData = useCollectionRecordData();
|
const recordData = useCollectionRecordData();
|
||||||
const collection = useCollection_deprecated();
|
const collection = useCollection_deprecated();
|
||||||
const { getCollectionField } = useCollectionManager_deprecated();
|
const { getCollectionField } = useCollectionManager_deprecated();
|
||||||
const assoc = useBlockAssociationContext();
|
const association = useBlockAssociationContext();
|
||||||
|
const assoc = blockProps?.association || association;
|
||||||
const withoutTableFieldResource = useContext(WithoutTableFieldResource);
|
const withoutTableFieldResource = useContext(WithoutTableFieldResource);
|
||||||
|
|
||||||
if (!withoutTableFieldResource) {
|
if (!withoutTableFieldResource) {
|
||||||
@ -336,8 +337,8 @@ export const useSourceIdFromParentRecord = () => {
|
|||||||
* @internal
|
* @internal
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
export const useParamsFromRecord = () => {
|
export const useParamsFromRecord = (props?: any) => {
|
||||||
const filterByTk = useFilterByTk();
|
const filterByTk = useFilterByTk(props);
|
||||||
const record = useRecord();
|
const record = useRecord();
|
||||||
const { fields } = useCollection_deprecated();
|
const { fields } = useCollection_deprecated();
|
||||||
const fieldSchema = useFieldSchema();
|
const fieldSchema = useFieldSchema();
|
||||||
|
@ -20,7 +20,7 @@ import {
|
|||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
export function useDetailsDecoratorProps(props) {
|
export function useDetailsDecoratorProps(props) {
|
||||||
const params = useParamsFromRecord();
|
const params = useParamsFromRecord(props);
|
||||||
let parentRecord;
|
let parentRecord;
|
||||||
|
|
||||||
// association 的值是固定不变的,所以可以在条件中使用 hooks
|
// association 的值是固定不变的,所以可以在条件中使用 hooks
|
||||||
|
@ -11,7 +11,7 @@ import { observer, useField, useFieldSchema } from '@formily/react';
|
|||||||
import { toArr } from '@formily/shared';
|
import { toArr } from '@formily/shared';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import React, { FC, Fragment, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
import React, { FC, Fragment, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
||||||
import { useDesignable } from '../../';
|
import { useDesignable, usePopupSettings } from '../../';
|
||||||
import { WithoutTableFieldResource } from '../../../block-provider';
|
import { WithoutTableFieldResource } from '../../../block-provider';
|
||||||
import { CollectionRecordProvider, useCollectionManager, useCollectionRecordData } from '../../../data-source';
|
import { CollectionRecordProvider, useCollectionManager, useCollectionRecordData } from '../../../data-source';
|
||||||
import { NocoBaseRecursionField } from '../../../formily/NocoBaseRecursionField';
|
import { NocoBaseRecursionField } from '../../../formily/NocoBaseRecursionField';
|
||||||
@ -48,6 +48,7 @@ export interface ButtonListProps {
|
|||||||
label: string;
|
label: string;
|
||||||
value: string;
|
value: string;
|
||||||
};
|
};
|
||||||
|
onClick?: (props: { recordData: any }) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const RenderRecord = React.memo(
|
const RenderRecord = React.memo(
|
||||||
@ -67,6 +68,7 @@ const RenderRecord = React.memo(
|
|||||||
ellipsisWithTooltipRef,
|
ellipsisWithTooltipRef,
|
||||||
value,
|
value,
|
||||||
setBtnHover,
|
setBtnHover,
|
||||||
|
onClick,
|
||||||
}: {
|
}: {
|
||||||
fieldNames: any;
|
fieldNames: any;
|
||||||
isTreeCollection: boolean;
|
isTreeCollection: boolean;
|
||||||
@ -83,6 +85,7 @@ const RenderRecord = React.memo(
|
|||||||
ellipsisWithTooltipRef: React.MutableRefObject<IEllipsisWithTooltipRef>;
|
ellipsisWithTooltipRef: React.MutableRefObject<IEllipsisWithTooltipRef>;
|
||||||
value: any;
|
value: any;
|
||||||
setBtnHover: any;
|
setBtnHover: any;
|
||||||
|
onClick?: (props: { recordData: any }) => void;
|
||||||
}) => {
|
}) => {
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
const [result, setResult] = useState<React.ReactNode[]>([]);
|
const [result, setResult] = useState<React.ReactNode[]>([]);
|
||||||
@ -138,6 +141,7 @@ const RenderRecord = React.memo(
|
|||||||
// When first inserting, the fieldSchema instance will be updated to a new instance.
|
// When first inserting, the fieldSchema instance will be updated to a new instance.
|
||||||
// We need to wait for the instance update before opening the popup to prevent configuration loss.
|
// We need to wait for the instance update before opening the popup to prevent configuration loss.
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
onClick?.({ recordData: record });
|
||||||
openPopup({
|
openPopup({
|
||||||
recordData: record,
|
recordData: record,
|
||||||
parentRecordData: recordData,
|
parentRecordData: recordData,
|
||||||
@ -146,6 +150,7 @@ const RenderRecord = React.memo(
|
|||||||
});
|
});
|
||||||
needWaitForFieldSchemaUpdatedRef.current = false;
|
needWaitForFieldSchemaUpdatedRef.current = false;
|
||||||
} else if (fieldSchema.properties) {
|
} else if (fieldSchema.properties) {
|
||||||
|
onClick?.({ recordData: record });
|
||||||
openPopup({
|
openPopup({
|
||||||
recordData: record,
|
recordData: record,
|
||||||
parentRecordData: recordData,
|
parentRecordData: recordData,
|
||||||
@ -230,6 +235,7 @@ const ButtonLinkList: FC<ButtonListProps> = observer((props) => {
|
|||||||
ellipsisWithTooltipRef={ellipsisWithTooltipRef}
|
ellipsisWithTooltipRef={ellipsisWithTooltipRef}
|
||||||
value={props.value}
|
value={props.value}
|
||||||
setBtnHover={props.setBtnHover}
|
setBtnHover={props.setBtnHover}
|
||||||
|
onClick={props.onClick}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@ -275,12 +281,18 @@ export const ReadPrettyInternalViewer: React.FC<ReadPrettyInternalViewerProps> =
|
|||||||
const { visibleWithURL, setVisibleWithURL } = usePopupUtils();
|
const { visibleWithURL, setVisibleWithURL } = usePopupUtils();
|
||||||
const [btnHover, setBtnHover] = useState(!!visibleWithURL);
|
const [btnHover, setBtnHover] = useState(!!visibleWithURL);
|
||||||
const { defaultOpenMode } = useOpenModeContext();
|
const { defaultOpenMode } = useOpenModeContext();
|
||||||
const recordData = useCollectionRecordData();
|
const parentRecordData = useCollectionRecordData();
|
||||||
|
const [recordData, setRecordData] = useState(null);
|
||||||
|
const { isPopupVisibleControlledByURL } = usePopupSettings();
|
||||||
|
|
||||||
|
const onClickItem = useCallback((props: { recordData: any }) => {
|
||||||
|
setRecordData(props.recordData);
|
||||||
|
}, []);
|
||||||
|
|
||||||
const btnElement = (
|
const btnElement = (
|
||||||
<EllipsisWithTooltip ellipsis={true}>
|
<EllipsisWithTooltip ellipsis={true}>
|
||||||
<CollectionRecordProvider isNew={false} record={getSourceData(recordData, fieldSchema)}>
|
<CollectionRecordProvider isNew={false} record={getSourceData(parentRecordData, fieldSchema)}>
|
||||||
<ButtonList setBtnHover={setBtnHover} value={value} fieldNames={props.fieldNames} />
|
<ButtonList setBtnHover={setBtnHover} value={value} fieldNames={props.fieldNames} onClick={onClickItem} />
|
||||||
</CollectionRecordProvider>
|
</CollectionRecordProvider>
|
||||||
</EllipsisWithTooltip>
|
</EllipsisWithTooltip>
|
||||||
);
|
);
|
||||||
@ -304,14 +316,29 @@ export const ReadPrettyInternalViewer: React.FC<ReadPrettyInternalViewerProps> =
|
|||||||
return btnElement;
|
return btnElement;
|
||||||
}
|
}
|
||||||
|
|
||||||
const renderWithoutTableFieldResourceProvider = () => (
|
const renderWithoutTableFieldResourceProvider = () => {
|
||||||
// The recordData here is only provided when the popup is opened, not the current row record
|
if (isPopupVisibleControlledByURL()) {
|
||||||
<VariablePopupRecordProvider>
|
return (
|
||||||
<WithoutTableFieldResource.Provider value={true}>
|
// The recordData here is only provided when the popup is opened, not the current row record
|
||||||
<NocoBaseRecursionField schema={fieldSchema} onlyRenderProperties basePath={field.address} />
|
<VariablePopupRecordProvider>
|
||||||
</WithoutTableFieldResource.Provider>
|
<WithoutTableFieldResource.Provider value={true}>
|
||||||
</VariablePopupRecordProvider>
|
<NocoBaseRecursionField schema={fieldSchema} onlyRenderProperties basePath={field.address} />
|
||||||
);
|
</WithoutTableFieldResource.Provider>
|
||||||
|
</VariablePopupRecordProvider>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<CollectionRecordProvider isNew={false} record={recordData} parentRecord={parentRecordData}>
|
||||||
|
{/* The recordData here is only provided when the popup is opened, not the current row record */}
|
||||||
|
<VariablePopupRecordProvider>
|
||||||
|
<WithoutTableFieldResource.Provider value={true}>
|
||||||
|
<NocoBaseRecursionField schema={fieldSchema} onlyRenderProperties basePath={field.address} />
|
||||||
|
</WithoutTableFieldResource.Provider>
|
||||||
|
</VariablePopupRecordProvider>
|
||||||
|
</CollectionRecordProvider>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<PopupVisibleProvider visible={false}>
|
<PopupVisibleProvider visible={false}>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user