mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 07:38:13 +00:00
Merge branch 'main' into next
Some checks are pending
Build Docker Image / build-and-push (push) Waiting to run
Build Pro Image / build-and-push (push) Waiting to run
E2E / Build (push) Waiting to run
E2E / Core and plugins (push) Blocked by required conditions
E2E / plugin-workflow (push) Blocked by required conditions
E2E / plugin-workflow-approval (push) Blocked by required conditions
E2E / plugin-data-source-main (push) Blocked by required conditions
E2E / Comment on PR (push) Blocked by required conditions
NocoBase Backend Test / sqlite-test (20, false) (push) Waiting to run
NocoBase Backend Test / sqlite-test (20, true) (push) Waiting to run
NocoBase Backend Test / postgres-test (public, 20, nocobase, false) (push) Waiting to run
NocoBase Backend Test / postgres-test (public, 20, nocobase, true) (push) Waiting to run
NocoBase Backend Test / postgres-test (public, 20, public, false) (push) Waiting to run
NocoBase Backend Test / postgres-test (public, 20, public, true) (push) Waiting to run
NocoBase Backend Test / postgres-test (user_schema, 20, nocobase, false) (push) Waiting to run
NocoBase Backend Test / postgres-test (user_schema, 20, nocobase, true) (push) Waiting to run
NocoBase Backend Test / postgres-test (user_schema, 20, public, false) (push) Waiting to run
NocoBase Backend Test / postgres-test (user_schema, 20, public, true) (push) Waiting to run
NocoBase Backend Test / mysql-test (20, false) (push) Waiting to run
NocoBase Backend Test / mysql-test (20, true) (push) Waiting to run
NocoBase Backend Test / mariadb-test (20, false) (push) Waiting to run
NocoBase Backend Test / mariadb-test (20, true) (push) Waiting to run
NocoBase FrontEnd Test / frontend-test (18) (push) Waiting to run
Test on Windows / build (push) Waiting to run
Some checks are pending
Build Docker Image / build-and-push (push) Waiting to run
Build Pro Image / build-and-push (push) Waiting to run
E2E / Build (push) Waiting to run
E2E / Core and plugins (push) Blocked by required conditions
E2E / plugin-workflow (push) Blocked by required conditions
E2E / plugin-workflow-approval (push) Blocked by required conditions
E2E / plugin-data-source-main (push) Blocked by required conditions
E2E / Comment on PR (push) Blocked by required conditions
NocoBase Backend Test / sqlite-test (20, false) (push) Waiting to run
NocoBase Backend Test / sqlite-test (20, true) (push) Waiting to run
NocoBase Backend Test / postgres-test (public, 20, nocobase, false) (push) Waiting to run
NocoBase Backend Test / postgres-test (public, 20, nocobase, true) (push) Waiting to run
NocoBase Backend Test / postgres-test (public, 20, public, false) (push) Waiting to run
NocoBase Backend Test / postgres-test (public, 20, public, true) (push) Waiting to run
NocoBase Backend Test / postgres-test (user_schema, 20, nocobase, false) (push) Waiting to run
NocoBase Backend Test / postgres-test (user_schema, 20, nocobase, true) (push) Waiting to run
NocoBase Backend Test / postgres-test (user_schema, 20, public, false) (push) Waiting to run
NocoBase Backend Test / postgres-test (user_schema, 20, public, true) (push) Waiting to run
NocoBase Backend Test / mysql-test (20, false) (push) Waiting to run
NocoBase Backend Test / mysql-test (20, true) (push) Waiting to run
NocoBase Backend Test / mariadb-test (20, false) (push) Waiting to run
NocoBase Backend Test / mariadb-test (20, true) (push) Waiting to run
NocoBase FrontEnd Test / frontend-test (18) (push) Waiting to run
Test on Windows / build (push) Waiting to run
This commit is contained in:
commit
28753a33de
@ -33,7 +33,6 @@ import {
|
|||||||
useCollectionManager_deprecated,
|
useCollectionManager_deprecated,
|
||||||
useCollection_deprecated,
|
useCollection_deprecated,
|
||||||
} from '../collection-manager';
|
} from '../collection-manager';
|
||||||
import { DataBlockCollector } from '../filter-provider/FilterProvider';
|
|
||||||
import { useSourceId } from '../modules/blocks/useSourceId';
|
import { useSourceId } from '../modules/blocks/useSourceId';
|
||||||
import { RecordProvider, useRecordIndex } from '../record-provider';
|
import { RecordProvider, useRecordIndex } from '../record-provider';
|
||||||
import { useAssociationNames } from './hooks';
|
import { useAssociationNames } from './hooks';
|
||||||
@ -272,9 +271,7 @@ export const BlockProvider = (props: {
|
|||||||
<BlockContext.Provider value={blockValue}>
|
<BlockContext.Provider value={blockValue}>
|
||||||
<DataBlockProvider {...(props as any)} params={params} parentRecord={parentRecord || parentRecordFromHook}>
|
<DataBlockProvider {...(props as any)} params={params} parentRecord={parentRecord || parentRecordFromHook}>
|
||||||
<BlockRequestProvider_deprecated {...props} updateAssociationValues={updateAssociationValues} params={params}>
|
<BlockRequestProvider_deprecated {...props} updateAssociationValues={updateAssociationValues} params={params}>
|
||||||
<DataBlockCollector {...props} params={params}>
|
{props.children}
|
||||||
{props.children}
|
|
||||||
</DataBlockCollector>
|
|
||||||
</BlockRequestProvider_deprecated>
|
</BlockRequestProvider_deprecated>
|
||||||
</DataBlockProvider>
|
</DataBlockProvider>
|
||||||
</BlockContext.Provider>
|
</BlockContext.Provider>
|
||||||
|
@ -11,6 +11,7 @@ import React, { FC, ReactNode, createContext, useContext, useMemo } from 'react'
|
|||||||
|
|
||||||
import { ACLCollectionProvider } from '../../acl/ACLProvider';
|
import { ACLCollectionProvider } from '../../acl/ACLProvider';
|
||||||
import { UseRequestOptions, UseRequestService } from '../../api-client';
|
import { UseRequestOptions, UseRequestService } from '../../api-client';
|
||||||
|
import { DataBlockCollector, FilterParam } from '../../filter-provider/FilterProvider';
|
||||||
import { withDynamicSchemaProps } from '../../hoc/withDynamicSchemaProps';
|
import { withDynamicSchemaProps } from '../../hoc/withDynamicSchemaProps';
|
||||||
import { Designable, useDesignable } from '../../schema-component';
|
import { Designable, useDesignable } from '../../schema-component';
|
||||||
import {
|
import {
|
||||||
@ -33,6 +34,7 @@ export interface AllDataBlockProps {
|
|||||||
action?: 'list' | 'get';
|
action?: 'list' | 'get';
|
||||||
params?: {
|
params?: {
|
||||||
filterByTk?: string | number;
|
filterByTk?: string | number;
|
||||||
|
filter?: FilterParam;
|
||||||
[index: string]: any;
|
[index: string]: any;
|
||||||
};
|
};
|
||||||
parentRecord?: CollectionRecord;
|
parentRecord?: CollectionRecord;
|
||||||
@ -149,7 +151,7 @@ export const AssociationOrCollectionProvider = (props: {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const DataBlockProvider: FC<DataBlockProviderProps & { children?: ReactNode }> = withDynamicSchemaProps(
|
export const DataBlockProvider: FC<Partial<AllDataBlockProps>> = withDynamicSchemaProps(
|
||||||
(props) => {
|
(props) => {
|
||||||
const { collection, association, dataSource, children, hidden, ...resets } = props as Partial<AllDataBlockProps>;
|
const { collection, association, dataSource, children, hidden, ...resets } = props as Partial<AllDataBlockProps>;
|
||||||
const { dn } = useDesignable();
|
const { dn } = useDesignable();
|
||||||
@ -167,7 +169,9 @@ export const DataBlockProvider: FC<DataBlockProviderProps & { children?: ReactNo
|
|||||||
<AssociationOrCollectionProvider collection={collection} association={association}>
|
<AssociationOrCollectionProvider collection={collection} association={association}>
|
||||||
<ACLCollectionProvider>
|
<ACLCollectionProvider>
|
||||||
<DataBlockResourceProvider>
|
<DataBlockResourceProvider>
|
||||||
<BlockRequestProvider>{children}</BlockRequestProvider>
|
<BlockRequestProvider>
|
||||||
|
<DataBlockCollector params={props.params}>{children}</DataBlockCollector>
|
||||||
|
</BlockRequestProvider>
|
||||||
</DataBlockResourceProvider>
|
</DataBlockResourceProvider>
|
||||||
</ACLCollectionProvider>
|
</ACLCollectionProvider>
|
||||||
</AssociationOrCollectionProvider>
|
</AssociationOrCollectionProvider>
|
||||||
|
@ -10,8 +10,10 @@
|
|||||||
import { useField, useFieldSchema } from '@formily/react';
|
import { useField, useFieldSchema } from '@formily/react';
|
||||||
import { uniqBy } from 'lodash';
|
import { uniqBy } from 'lodash';
|
||||||
import React, { createContext, useCallback, useEffect, useRef } from 'react';
|
import React, { createContext, useCallback, useEffect, useRef } from 'react';
|
||||||
import { useBlockRequestContext } from '../block-provider/BlockProvider';
|
import { CollectionFieldOptions_deprecated } from '../collection-manager';
|
||||||
import { CollectionFieldOptions_deprecated, useCollection_deprecated } from '../collection-manager';
|
import { Collection } from '../data-source/collection/Collection';
|
||||||
|
import { useCollection } from '../data-source/collection/CollectionProvider';
|
||||||
|
import { useDataBlockRequest } from '../data-source/data-block/DataBlockRequestProvider';
|
||||||
import { useDataLoadingMode } from '../modules/blocks/data-blocks/details-multi/setDataLoadingModeSettingsItem';
|
import { useDataLoadingMode } from '../modules/blocks/data-blocks/details-multi/setDataLoadingModeSettingsItem';
|
||||||
import { removeNullCondition } from '../schema-component';
|
import { removeNullCondition } from '../schema-component';
|
||||||
import { mergeFilter, useAssociatedFields } from './utils';
|
import { mergeFilter, useAssociatedFields } from './utils';
|
||||||
@ -37,8 +39,6 @@ export interface ForeignKeyField {
|
|||||||
[key: string]: any;
|
[key: string]: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
type Collection = ReturnType<typeof useCollection_deprecated>;
|
|
||||||
|
|
||||||
export interface DataBlock {
|
export interface DataBlock {
|
||||||
/** 唯一标识符,schema 中的 x-uid 值 */
|
/** 唯一标识符,schema 中的 x-uid 值 */
|
||||||
uid: string;
|
uid: string;
|
||||||
@ -97,11 +97,11 @@ export const DataBlockCollector = ({
|
|||||||
params,
|
params,
|
||||||
}: {
|
}: {
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
params?: { filter: FilterParam };
|
params?: { filter?: FilterParam };
|
||||||
}) => {
|
}) => {
|
||||||
const collection = useCollection_deprecated();
|
const collection = useCollection();
|
||||||
const { recordDataBlocks } = useFilterBlock();
|
const { recordDataBlocks } = useFilterBlock();
|
||||||
const { service } = useBlockRequestContext();
|
const service = useDataBlockRequest();
|
||||||
const field = useField();
|
const field = useField();
|
||||||
const fieldSchema = useFieldSchema();
|
const fieldSchema = useFieldSchema();
|
||||||
const associatedFields = useAssociatedFields();
|
const associatedFields = useAssociatedFields();
|
||||||
@ -109,6 +109,7 @@ export const DataBlockCollector = ({
|
|||||||
const dataLoadingMode = useDataLoadingMode();
|
const dataLoadingMode = useDataLoadingMode();
|
||||||
|
|
||||||
const shouldApplyFilter =
|
const shouldApplyFilter =
|
||||||
|
field &&
|
||||||
field.decoratorType !== 'FilterFormBlockProvider' &&
|
field.decoratorType !== 'FilterFormBlockProvider' &&
|
||||||
field.decoratorType !== 'FormBlockProvider' &&
|
field.decoratorType !== 'FormBlockProvider' &&
|
||||||
field.decoratorProps.blockType !== 'filter';
|
field.decoratorProps.blockType !== 'filter';
|
||||||
@ -117,10 +118,10 @@ export const DataBlockCollector = ({
|
|||||||
recordDataBlocks({
|
recordDataBlocks({
|
||||||
uid: fieldSchema['x-uid'],
|
uid: fieldSchema['x-uid'],
|
||||||
title: field.componentProps.title,
|
title: field.componentProps.title,
|
||||||
doFilter: service.runAsync,
|
doFilter: service.runAsync as any,
|
||||||
collection,
|
collection,
|
||||||
associatedFields,
|
associatedFields,
|
||||||
foreignKeyFields: collection.foreignKeyFields as ForeignKeyField[],
|
foreignKeyFields: collection.getFields('isForeignKey') as ForeignKeyField[],
|
||||||
defaultFilter: params?.filter || {},
|
defaultFilter: params?.filter || {},
|
||||||
service,
|
service,
|
||||||
dom: container.current,
|
dom: container.current,
|
||||||
@ -151,7 +152,7 @@ export const DataBlockCollector = ({
|
|||||||
associatedFields,
|
associatedFields,
|
||||||
collection,
|
collection,
|
||||||
dataLoadingMode,
|
dataLoadingMode,
|
||||||
field.componentProps.title,
|
field?.componentProps?.title,
|
||||||
fieldSchema,
|
fieldSchema,
|
||||||
params?.filter,
|
params?.filter,
|
||||||
recordDataBlocks,
|
recordDataBlocks,
|
||||||
|
@ -14,11 +14,12 @@ import { useCallback, useEffect, useState } from 'react';
|
|||||||
import { FilterTarget, findFilterTargets } from '../block-provider/hooks';
|
import { FilterTarget, findFilterTargets } from '../block-provider/hooks';
|
||||||
import {
|
import {
|
||||||
CollectionFieldOptions_deprecated,
|
CollectionFieldOptions_deprecated,
|
||||||
Collection_deprecated,
|
|
||||||
FieldOptions,
|
FieldOptions,
|
||||||
useCollectionManager_deprecated,
|
useCollectionManager_deprecated,
|
||||||
useCollection_deprecated,
|
useCollection_deprecated,
|
||||||
} from '../collection-manager';
|
} from '../collection-manager';
|
||||||
|
import { Collection } from '../data-source/collection/Collection';
|
||||||
|
import { useCollection } from '../data-source/collection/CollectionProvider';
|
||||||
import { removeNullCondition } from '../schema-component';
|
import { removeNullCondition } from '../schema-component';
|
||||||
import { DataBlock, useFilterBlock } from './FilterProvider';
|
import { DataBlock, useFilterBlock } from './FilterProvider';
|
||||||
|
|
||||||
@ -50,10 +51,7 @@ export const getSupportFieldsByAssociation = (inheritCollectionsChain: string[],
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getSupportFieldsByForeignKey = (
|
export const getSupportFieldsByForeignKey = (filterBlockCollection: Collection, block: DataBlock) => {
|
||||||
filterBlockCollection: ReturnType<typeof useCollection_deprecated>,
|
|
||||||
block: DataBlock,
|
|
||||||
) => {
|
|
||||||
return block.foreignKeyFields?.filter((foreignKeyField) => {
|
return block.foreignKeyFields?.filter((foreignKeyField) => {
|
||||||
return filterBlockCollection.fields.some(
|
return filterBlockCollection.fields.some(
|
||||||
(field) => field.type !== 'belongsTo' && field.foreignKey === foreignKeyField.name,
|
(field) => field.type !== 'belongsTo' && field.foreignKey === foreignKeyField.name,
|
||||||
@ -69,7 +67,7 @@ export const getSupportFieldsByForeignKey = (
|
|||||||
export const useSupportedBlocks = (filterBlockType: FilterBlockType) => {
|
export const useSupportedBlocks = (filterBlockType: FilterBlockType) => {
|
||||||
const { getDataBlocks } = useFilterBlock();
|
const { getDataBlocks } = useFilterBlock();
|
||||||
const fieldSchema = useFieldSchema();
|
const fieldSchema = useFieldSchema();
|
||||||
const collection = useCollection_deprecated();
|
const collection = useCollection();
|
||||||
const { getAllCollectionsInheritChain } = useCollectionManager_deprecated();
|
const { getAllCollectionsInheritChain } = useCollectionManager_deprecated();
|
||||||
|
|
||||||
// Form 和 Collapse 仅支持同表的数据区块
|
// Form 和 Collapse 仅支持同表的数据区块
|
||||||
@ -174,7 +172,7 @@ export const isAssocField = (field?: FieldOptions) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const isSameCollection = (c1: Collection_deprecated, c2: Collection_deprecated) => {
|
export const isSameCollection = (c1: Collection, c2: Collection) => {
|
||||||
return c1.name === c2.name && c1.dataSource === c2.dataSource;
|
return c1.name === c2.name && c1.dataSource === c2.dataSource;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ import React from 'react';
|
|||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { findFilterTargets, updateFilterTargets } from '../block-provider/hooks';
|
import { findFilterTargets, updateFilterTargets } from '../block-provider/hooks';
|
||||||
import { useCollectionManager_deprecated } from '../collection-manager/hooks/useCollectionManager_deprecated';
|
import { useCollectionManager_deprecated } from '../collection-manager/hooks/useCollectionManager_deprecated';
|
||||||
import { useCollection_deprecated } from '../collection-manager/hooks/useCollection_deprecated';
|
import { useCollection } from '../data-source/collection/CollectionProvider';
|
||||||
import { useFilterBlock } from '../filter-provider/FilterProvider';
|
import { useFilterBlock } from '../filter-provider/FilterProvider';
|
||||||
import {
|
import {
|
||||||
getSupportFieldsByAssociation,
|
getSupportFieldsByAssociation,
|
||||||
@ -37,7 +37,7 @@ export function SchemaSettingsConnectDataBlocks(props) {
|
|||||||
const fieldSchema = useFieldSchema();
|
const fieldSchema = useFieldSchema();
|
||||||
const { dn } = useDesignable();
|
const { dn } = useDesignable();
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const collection = useCollection_deprecated();
|
const collection = useCollection();
|
||||||
const { inProvider } = useFilterBlock();
|
const { inProvider } = useFilterBlock();
|
||||||
const dataBlocks = useSupportedBlocks(type);
|
const dataBlocks = useSupportedBlocks(type);
|
||||||
// eslint-disable-next-line prefer-const
|
// eslint-disable-next-line prefer-const
|
||||||
|
Loading…
Reference in New Issue
Block a user