mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 05:36:05 +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,
|
||||
useCollection_deprecated,
|
||||
} from '../collection-manager';
|
||||
import { DataBlockCollector } from '../filter-provider/FilterProvider';
|
||||
import { useSourceId } from '../modules/blocks/useSourceId';
|
||||
import { RecordProvider, useRecordIndex } from '../record-provider';
|
||||
import { useAssociationNames } from './hooks';
|
||||
@ -272,9 +271,7 @@ export const BlockProvider = (props: {
|
||||
<BlockContext.Provider value={blockValue}>
|
||||
<DataBlockProvider {...(props as any)} params={params} parentRecord={parentRecord || parentRecordFromHook}>
|
||||
<BlockRequestProvider_deprecated {...props} updateAssociationValues={updateAssociationValues} params={params}>
|
||||
<DataBlockCollector {...props} params={params}>
|
||||
{props.children}
|
||||
</DataBlockCollector>
|
||||
{props.children}
|
||||
</BlockRequestProvider_deprecated>
|
||||
</DataBlockProvider>
|
||||
</BlockContext.Provider>
|
||||
|
@ -11,6 +11,7 @@ import React, { FC, ReactNode, createContext, useContext, useMemo } from 'react'
|
||||
|
||||
import { ACLCollectionProvider } from '../../acl/ACLProvider';
|
||||
import { UseRequestOptions, UseRequestService } from '../../api-client';
|
||||
import { DataBlockCollector, FilterParam } from '../../filter-provider/FilterProvider';
|
||||
import { withDynamicSchemaProps } from '../../hoc/withDynamicSchemaProps';
|
||||
import { Designable, useDesignable } from '../../schema-component';
|
||||
import {
|
||||
@ -33,6 +34,7 @@ export interface AllDataBlockProps {
|
||||
action?: 'list' | 'get';
|
||||
params?: {
|
||||
filterByTk?: string | number;
|
||||
filter?: FilterParam;
|
||||
[index: string]: any;
|
||||
};
|
||||
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) => {
|
||||
const { collection, association, dataSource, children, hidden, ...resets } = props as Partial<AllDataBlockProps>;
|
||||
const { dn } = useDesignable();
|
||||
@ -167,7 +169,9 @@ export const DataBlockProvider: FC<DataBlockProviderProps & { children?: ReactNo
|
||||
<AssociationOrCollectionProvider collection={collection} association={association}>
|
||||
<ACLCollectionProvider>
|
||||
<DataBlockResourceProvider>
|
||||
<BlockRequestProvider>{children}</BlockRequestProvider>
|
||||
<BlockRequestProvider>
|
||||
<DataBlockCollector params={props.params}>{children}</DataBlockCollector>
|
||||
</BlockRequestProvider>
|
||||
</DataBlockResourceProvider>
|
||||
</ACLCollectionProvider>
|
||||
</AssociationOrCollectionProvider>
|
||||
|
@ -10,8 +10,10 @@
|
||||
import { useField, useFieldSchema } from '@formily/react';
|
||||
import { uniqBy } from 'lodash';
|
||||
import React, { createContext, useCallback, useEffect, useRef } from 'react';
|
||||
import { useBlockRequestContext } from '../block-provider/BlockProvider';
|
||||
import { CollectionFieldOptions_deprecated, useCollection_deprecated } from '../collection-manager';
|
||||
import { CollectionFieldOptions_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 { removeNullCondition } from '../schema-component';
|
||||
import { mergeFilter, useAssociatedFields } from './utils';
|
||||
@ -37,8 +39,6 @@ export interface ForeignKeyField {
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
type Collection = ReturnType<typeof useCollection_deprecated>;
|
||||
|
||||
export interface DataBlock {
|
||||
/** 唯一标识符,schema 中的 x-uid 值 */
|
||||
uid: string;
|
||||
@ -97,11 +97,11 @@ export const DataBlockCollector = ({
|
||||
params,
|
||||
}: {
|
||||
children: React.ReactNode;
|
||||
params?: { filter: FilterParam };
|
||||
params?: { filter?: FilterParam };
|
||||
}) => {
|
||||
const collection = useCollection_deprecated();
|
||||
const collection = useCollection();
|
||||
const { recordDataBlocks } = useFilterBlock();
|
||||
const { service } = useBlockRequestContext();
|
||||
const service = useDataBlockRequest();
|
||||
const field = useField();
|
||||
const fieldSchema = useFieldSchema();
|
||||
const associatedFields = useAssociatedFields();
|
||||
@ -109,6 +109,7 @@ export const DataBlockCollector = ({
|
||||
const dataLoadingMode = useDataLoadingMode();
|
||||
|
||||
const shouldApplyFilter =
|
||||
field &&
|
||||
field.decoratorType !== 'FilterFormBlockProvider' &&
|
||||
field.decoratorType !== 'FormBlockProvider' &&
|
||||
field.decoratorProps.blockType !== 'filter';
|
||||
@ -117,10 +118,10 @@ export const DataBlockCollector = ({
|
||||
recordDataBlocks({
|
||||
uid: fieldSchema['x-uid'],
|
||||
title: field.componentProps.title,
|
||||
doFilter: service.runAsync,
|
||||
doFilter: service.runAsync as any,
|
||||
collection,
|
||||
associatedFields,
|
||||
foreignKeyFields: collection.foreignKeyFields as ForeignKeyField[],
|
||||
foreignKeyFields: collection.getFields('isForeignKey') as ForeignKeyField[],
|
||||
defaultFilter: params?.filter || {},
|
||||
service,
|
||||
dom: container.current,
|
||||
@ -151,7 +152,7 @@ export const DataBlockCollector = ({
|
||||
associatedFields,
|
||||
collection,
|
||||
dataLoadingMode,
|
||||
field.componentProps.title,
|
||||
field?.componentProps?.title,
|
||||
fieldSchema,
|
||||
params?.filter,
|
||||
recordDataBlocks,
|
||||
|
@ -14,11 +14,12 @@ import { useCallback, useEffect, useState } from 'react';
|
||||
import { FilterTarget, findFilterTargets } from '../block-provider/hooks';
|
||||
import {
|
||||
CollectionFieldOptions_deprecated,
|
||||
Collection_deprecated,
|
||||
FieldOptions,
|
||||
useCollectionManager_deprecated,
|
||||
useCollection_deprecated,
|
||||
} from '../collection-manager';
|
||||
import { Collection } from '../data-source/collection/Collection';
|
||||
import { useCollection } from '../data-source/collection/CollectionProvider';
|
||||
import { removeNullCondition } from '../schema-component';
|
||||
import { DataBlock, useFilterBlock } from './FilterProvider';
|
||||
|
||||
@ -50,10 +51,7 @@ export const getSupportFieldsByAssociation = (inheritCollectionsChain: string[],
|
||||
);
|
||||
};
|
||||
|
||||
export const getSupportFieldsByForeignKey = (
|
||||
filterBlockCollection: ReturnType<typeof useCollection_deprecated>,
|
||||
block: DataBlock,
|
||||
) => {
|
||||
export const getSupportFieldsByForeignKey = (filterBlockCollection: Collection, block: DataBlock) => {
|
||||
return block.foreignKeyFields?.filter((foreignKeyField) => {
|
||||
return filterBlockCollection.fields.some(
|
||||
(field) => field.type !== 'belongsTo' && field.foreignKey === foreignKeyField.name,
|
||||
@ -69,7 +67,7 @@ export const getSupportFieldsByForeignKey = (
|
||||
export const useSupportedBlocks = (filterBlockType: FilterBlockType) => {
|
||||
const { getDataBlocks } = useFilterBlock();
|
||||
const fieldSchema = useFieldSchema();
|
||||
const collection = useCollection_deprecated();
|
||||
const collection = useCollection();
|
||||
const { getAllCollectionsInheritChain } = useCollectionManager_deprecated();
|
||||
|
||||
// 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;
|
||||
};
|
||||
|
||||
|
@ -14,7 +14,7 @@ import React from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { findFilterTargets, updateFilterTargets } from '../block-provider/hooks';
|
||||
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 {
|
||||
getSupportFieldsByAssociation,
|
||||
@ -37,7 +37,7 @@ export function SchemaSettingsConnectDataBlocks(props) {
|
||||
const fieldSchema = useFieldSchema();
|
||||
const { dn } = useDesignable();
|
||||
const { t } = useTranslation();
|
||||
const collection = useCollection_deprecated();
|
||||
const collection = useCollection();
|
||||
const { inProvider } = useFilterBlock();
|
||||
const dataBlocks = useSupportedBlocks(type);
|
||||
// eslint-disable-next-line prefer-const
|
||||
|
Loading…
Reference in New Issue
Block a user