diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index f48dc2a1b8..ee85b030fb 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -419,6 +419,8 @@ jobs: - plugin-workflow - plugin-workflow-approval - plugin-data-source-main + permissions: + pull-requests: write if: ${{ !cancelled() && github.event.pull_request.number }} steps: - uses: actions/checkout@v4 diff --git a/packages/core/client/src/collection-manager/templates/components/PreviewFields.tsx b/packages/core/client/src/collection-manager/templates/components/PreviewFields.tsx index fa77da458f..e1098151e0 100644 --- a/packages/core/client/src/collection-manager/templates/components/PreviewFields.tsx +++ b/packages/core/client/src/collection-manager/templates/components/PreviewFields.tsx @@ -69,7 +69,7 @@ const PreviewCom = (props) => { }; }); const children = collection.fields - .filter((v) => !['hasOne', 'hasMany', 'belongsToMany'].includes(v?.type)) + .filter((v) => !['obo', 'oho', 'm2m', 'o2m'].includes(v?.interface)) ?.map((v) => { return { value: v.name, key: v.name, label: t(v.uiSchema?.title || v.name) }; }) diff --git a/packages/core/client/src/collection-manager/templates/components/sql-collection/FieldsConfigure.tsx b/packages/core/client/src/collection-manager/templates/components/sql-collection/FieldsConfigure.tsx index 0935adfdf1..541dbcb89f 100644 --- a/packages/core/client/src/collection-manager/templates/components/sql-collection/FieldsConfigure.tsx +++ b/packages/core/client/src/collection-manager/templates/components/sql-collection/FieldsConfigure.tsx @@ -68,11 +68,12 @@ const useSourceFieldsOptions = () => { return; } const children = (collection.fields as FieldOptions[]) - .filter((v) => !['hasOne', 'hasMany', 'belongsToMany'].includes(v?.type)) + .filter((v) => { + return !['hasOne', 'hasMany', 'belongsToMany', 'belongsTo'].includes(v?.type); + }) ?.map((v) => { return { value: v.name, label: t(v.uiSchema?.title) }; }); - data.push({ value: item, label: t(collection.title), @@ -110,7 +111,6 @@ export const FieldsConfigure = observer( [compile], ); const sourceFieldsOptions = useSourceFieldsOptions(); - const refGetInterface = useRef(getInterface); useEffect(() => { const fieldsMp = new Map(); diff --git a/packages/core/client/src/modules/blocks/data-blocks/table/hooks/useTableBlockProps.tsx b/packages/core/client/src/modules/blocks/data-blocks/table/hooks/useTableBlockProps.tsx index 7c54943b45..747a4066e2 100644 --- a/packages/core/client/src/modules/blocks/data-blocks/table/hooks/useTableBlockProps.tsx +++ b/packages/core/client/src/modules/blocks/data-blocks/table/hooks/useTableBlockProps.tsx @@ -13,7 +13,7 @@ import { isEqual } from 'lodash'; import { useCallback, useEffect, useMemo } from 'react'; import { useTableBlockContext } from '../../../../../block-provider/TableBlockProvider'; import { findFilterTargets } from '../../../../../block-provider/hooks'; -import { useFilterBlock } from '../../../../../filter-provider/FilterProvider'; +import { DataBlock, useFilterBlock } from '../../../../../filter-provider/FilterProvider'; import { mergeFilter } from '../../../../../filter-provider/utils'; import { removeNullCondition } from '../../../../../schema-component'; @@ -103,12 +103,17 @@ export const useTableBlockProps = () => { return; } - const value = [record[ctx.rowKey]]; + const currentBlock = dataBlocks.find((block) => block.uid === fieldSchema.parent['x-uid']); dataBlocks.forEach((block) => { const target = targets.find((target) => target.uid === block.uid); if (!target) return; + const isForeignKey = block.foreignKeyFields?.some((field) => field.name === target.field); + const sourceKey = getSourceKey(currentBlock, target.field); + const recordKey = isForeignKey ? sourceKey : ctx.rowKey; + const value = [record[recordKey]]; + const param = block.service.params?.[0] || {}; // 保留原有的 filter const storedFilter = block.service.params?.[1]?.filters || {}; @@ -146,7 +151,7 @@ export const useTableBlockProps = () => { }); // 更新表格的选中状态 - setSelectedRow((prev) => (prev?.includes(record[ctx.rowKey]) ? [] : [...value])); + setSelectedRow((prev) => (prev?.includes(record[ctx.rowKey]) ? [] : [record[ctx.rowKey]])); }, [ctx.rowKey, fieldSchema, getDataBlocks], ), @@ -155,3 +160,8 @@ export const useTableBlockProps = () => { }, []), }; }; + +function getSourceKey(currentBlock: DataBlock, field: string) { + const associationField = currentBlock?.associatedFields?.find((item) => item.foreignKey === field); + return associationField?.sourceKey || 'id'; +} diff --git a/packages/core/client/src/modules/fields/component/Select/selectComponentFieldSettings.tsx b/packages/core/client/src/modules/fields/component/Select/selectComponentFieldSettings.tsx index 2701d6762b..a346d6d293 100644 --- a/packages/core/client/src/modules/fields/component/Select/selectComponentFieldSettings.tsx +++ b/packages/core/client/src/modules/fields/component/Select/selectComponentFieldSettings.tsx @@ -362,9 +362,10 @@ export const selectComponentFieldSettings = new SchemaSettings({ { ...allowMultiple, useVisible() { + const isFieldReadPretty = useIsFieldReadPretty(); const isAssociationField = useIsAssociationField(); const IsShowMultipleSwitch = useIsShowMultipleSwitch(); - return isAssociationField && IsShowMultipleSwitch(); + return !isFieldReadPretty && isAssociationField && IsShowMultipleSwitch(); }, }, { diff --git a/packages/core/client/src/schema-component/antd/association-field/AssociationSelect.tsx b/packages/core/client/src/schema-component/antd/association-field/AssociationSelect.tsx index 71a6124c80..dee73be25d 100644 --- a/packages/core/client/src/schema-component/antd/association-field/AssociationSelect.tsx +++ b/packages/core/client/src/schema-component/antd/association-field/AssociationSelect.tsx @@ -127,7 +127,7 @@ const InternalAssociationSelect = observer( }; return (