mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-05 21:49:25 +08:00
Merge branch 'next' into develop
This commit is contained in:
commit
1978d0edd5
@ -61,14 +61,11 @@ export const TableBlockInitializer = ({
|
|||||||
|
|
||||||
export const useCreateTableBlock = () => {
|
export const useCreateTableBlock = () => {
|
||||||
const { insert } = useSchemaInitializer();
|
const { insert } = useSchemaInitializer();
|
||||||
const { getCollection } = useCollectionManager_deprecated();
|
|
||||||
|
|
||||||
const createTableBlock = ({ item }) => {
|
const createTableBlock = ({ item }) => {
|
||||||
const collection = getCollection(item.name, item.dataSource);
|
|
||||||
const schema = createTableBlockUISchema({
|
const schema = createTableBlockUISchema({
|
||||||
collectionName: item.name,
|
collectionName: item.name,
|
||||||
dataSource: item.dataSource,
|
dataSource: item.dataSource,
|
||||||
rowKey: collection.filterTargetKey || 'id',
|
|
||||||
});
|
});
|
||||||
insert(schema);
|
insert(schema);
|
||||||
};
|
};
|
||||||
|
@ -17,7 +17,7 @@ vi.mock('@formily/shared', () => {
|
|||||||
|
|
||||||
describe('createTableBLockSchemaV2', () => {
|
describe('createTableBLockSchemaV2', () => {
|
||||||
it('should create a default table block schema with minimum options', () => {
|
it('should create a default table block schema with minimum options', () => {
|
||||||
const options = { dataSource: 'abc', collectionName: 'users', association: 'users.roles', rowKey: 'rowKey' };
|
const options = { dataSource: 'abc', collectionName: 'users', association: 'users.roles' };
|
||||||
const schema = createTableBlockUISchema(options);
|
const schema = createTableBlockUISchema(options);
|
||||||
|
|
||||||
expect(schema).toMatchInlineSnapshot(`
|
expect(schema).toMatchInlineSnapshot(`
|
||||||
@ -85,7 +85,6 @@ describe('createTableBLockSchemaV2', () => {
|
|||||||
"params": {
|
"params": {
|
||||||
"pageSize": 20,
|
"pageSize": 20,
|
||||||
},
|
},
|
||||||
"rowKey": "rowKey",
|
|
||||||
"showIndex": true,
|
"showIndex": true,
|
||||||
},
|
},
|
||||||
"x-filter-targets": [],
|
"x-filter-targets": [],
|
||||||
|
@ -13,10 +13,9 @@ import { uid } from '@formily/shared';
|
|||||||
export const createTableBlockUISchema = (options: {
|
export const createTableBlockUISchema = (options: {
|
||||||
dataSource: string;
|
dataSource: string;
|
||||||
collectionName?: string;
|
collectionName?: string;
|
||||||
rowKey?: string;
|
|
||||||
association?: string;
|
association?: string;
|
||||||
}): ISchema => {
|
}): ISchema => {
|
||||||
const { collectionName, dataSource, rowKey, association } = options;
|
const { collectionName, dataSource, association } = options;
|
||||||
|
|
||||||
if (!dataSource) {
|
if (!dataSource) {
|
||||||
throw new Error('dataSource is required');
|
throw new Error('dataSource is required');
|
||||||
@ -35,7 +34,6 @@ export const createTableBlockUISchema = (options: {
|
|||||||
params: {
|
params: {
|
||||||
pageSize: 20,
|
pageSize: 20,
|
||||||
},
|
},
|
||||||
rowKey,
|
|
||||||
showIndex: true,
|
showIndex: true,
|
||||||
dragSort: false,
|
dragSort: false,
|
||||||
},
|
},
|
||||||
|
@ -11,15 +11,19 @@ import { useFieldSchema } from '@formily/react';
|
|||||||
import { useMemo } from 'react';
|
import { useMemo } from 'react';
|
||||||
import { useParsedFilter } from '../../../../../block-provider/hooks/useParsedFilter';
|
import { useParsedFilter } from '../../../../../block-provider/hooks/useParsedFilter';
|
||||||
import { useParentRecordCommon } from '../../../useParentRecordCommon';
|
import { useParentRecordCommon } from '../../../useParentRecordCommon';
|
||||||
|
import { useDataSourceManager } from '../../../../../data-source';
|
||||||
|
|
||||||
export const useTableBlockDecoratorProps = (props) => {
|
export const useTableBlockDecoratorProps = (props) => {
|
||||||
const { params, parseVariableLoading } = useTableBlockParams(props);
|
const { params, parseVariableLoading } = useTableBlockParams(props);
|
||||||
const parentRecord = useParentRecordCommon(props.association);
|
const parentRecord = useParentRecordCommon(props.association);
|
||||||
|
const dm = useDataSourceManager();
|
||||||
|
const collection = dm.getDataSource(props.dataSource)?.collectionManager.getCollection(props.collection);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
params,
|
params,
|
||||||
parentRecord,
|
parentRecord,
|
||||||
parseVariableLoading,
|
parseVariableLoading,
|
||||||
|
rowKey: collection?.filterTargetKey || 'id',
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -10,25 +10,9 @@
|
|||||||
import { observer } from '@formily/react';
|
import { observer } from '@formily/react';
|
||||||
import classnames from 'classnames';
|
import classnames from 'classnames';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Space, Tooltip } from 'antd';
|
|
||||||
import { withDynamicSchemaProps } from '../../../hoc/withDynamicSchemaProps';
|
import { withDynamicSchemaProps } from '../../../hoc/withDynamicSchemaProps';
|
||||||
import Action from './Action';
|
import Action from './Action';
|
||||||
import { ComposedAction } from './types';
|
import { ComposedAction } from './types';
|
||||||
import { Icon } from '../../../icon';
|
|
||||||
|
|
||||||
const WrapperComponent = React.forwardRef(
|
|
||||||
({ component: Component = 'a', icon, onlyIcon, children, ...restProps }: any, ref) => {
|
|
||||||
return (
|
|
||||||
<Component ref={ref} {...restProps}>
|
|
||||||
<Tooltip title={restProps.title}>
|
|
||||||
<span style={{ marginRight: 3 }}>{icon && typeof icon === 'string' ? <Icon type={icon} /> : icon}</span>
|
|
||||||
</Tooltip>
|
|
||||||
{onlyIcon ? children[1] : children}
|
|
||||||
</Component>
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
WrapperComponent.displayName = 'WrapperComponentLink';
|
|
||||||
|
|
||||||
export const ActionLink: ComposedAction = withDynamicSchemaProps(
|
export const ActionLink: ComposedAction = withDynamicSchemaProps(
|
||||||
observer((props: any) => {
|
observer((props: any) => {
|
||||||
|
@ -357,7 +357,7 @@ function FinallyButton({
|
|||||||
}}
|
}}
|
||||||
style={{
|
style={{
|
||||||
...props?.style,
|
...props?.style,
|
||||||
display: !designable && field?.data?.hidden && 'none',
|
display: !designable && field?.data?.hidden ? 'none' : 'inline-block',
|
||||||
opacity: designable && field?.data?.hidden && 0.1,
|
opacity: designable && field?.data?.hidden && 0.1,
|
||||||
...buttonStyle,
|
...buttonStyle,
|
||||||
}}
|
}}
|
||||||
|
@ -39,7 +39,6 @@ export const RecordAssociationBlockInitializer = () => {
|
|||||||
} else {
|
} else {
|
||||||
insert(
|
insert(
|
||||||
createTableBlockUISchema({
|
createTableBlockUISchema({
|
||||||
rowKey: collection.filterTargetKey,
|
|
||||||
dataSource: collection.dataSource,
|
dataSource: collection.dataSource,
|
||||||
association: association,
|
association: association,
|
||||||
}),
|
}),
|
||||||
@ -62,7 +61,6 @@ export function useCreateAssociationTableBlock() {
|
|||||||
|
|
||||||
insert(
|
insert(
|
||||||
createTableBlockUISchema({
|
createTableBlockUISchema({
|
||||||
rowKey: collection.filterTargetKey,
|
|
||||||
dataSource: collection.dataSource,
|
dataSource: collection.dataSource,
|
||||||
association: `${field.collectionName}.${field.name}`,
|
association: `${field.collectionName}.${field.name}`,
|
||||||
}),
|
}),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user