mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-07-02 11:12:20 +08:00
Merge branch 'next' into develop
This commit is contained in:
commit
c3f99d7efb
@ -62,6 +62,7 @@ interface Props {
|
|||||||
children?: any;
|
children?: any;
|
||||||
expandFlag?: boolean;
|
expandFlag?: boolean;
|
||||||
dragSortBy?: string;
|
dragSortBy?: string;
|
||||||
|
enableIndexÏColumn?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const InternalTableBlockProvider = (props: Props) => {
|
const InternalTableBlockProvider = (props: Props) => {
|
||||||
@ -74,6 +75,7 @@ const InternalTableBlockProvider = (props: Props) => {
|
|||||||
expandFlag: propsExpandFlag = false,
|
expandFlag: propsExpandFlag = false,
|
||||||
fieldNames,
|
fieldNames,
|
||||||
collection,
|
collection,
|
||||||
|
enableIndexÏColumn,
|
||||||
} = props;
|
} = props;
|
||||||
const field: any = useField();
|
const field: any = useField();
|
||||||
const { resource, service } = useBlockRequestContext();
|
const { resource, service } = useBlockRequestContext();
|
||||||
@ -131,6 +133,7 @@ const InternalTableBlockProvider = (props: Props) => {
|
|||||||
allIncludesChildren,
|
allIncludesChildren,
|
||||||
setExpandFlag: setExpandFlagValue,
|
setExpandFlag: setExpandFlagValue,
|
||||||
heightProps,
|
heightProps,
|
||||||
|
enableIndexÏColumn,
|
||||||
}),
|
}),
|
||||||
[
|
[
|
||||||
allIncludesChildren,
|
allIncludesChildren,
|
||||||
@ -146,6 +149,7 @@ const InternalTableBlockProvider = (props: Props) => {
|
|||||||
service,
|
service,
|
||||||
setExpandFlagValue,
|
setExpandFlagValue,
|
||||||
showIndex,
|
showIndex,
|
||||||
|
enableIndexÏColumn,
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -1085,5 +1085,6 @@
|
|||||||
"Date scope":"日期范围",
|
"Date scope":"日期范围",
|
||||||
"Deprecated": "已弃用",
|
"Deprecated": "已弃用",
|
||||||
"The following old template features have been deprecated and will be removed in next version.": "以下旧的模板功能已弃用,将在下个版本移除。",
|
"The following old template features have been deprecated and will be removed in next version.": "以下旧的模板功能已弃用,将在下个版本移除。",
|
||||||
"Full permissions": "全部权限"
|
"Full permissions": "全部权限",
|
||||||
|
"Enable index column": "启用序号列"
|
||||||
}
|
}
|
@ -25,6 +25,33 @@ import { setDefaultSortingRulesSchemaSettingsItem } from '../../../../schema-set
|
|||||||
import { setTheDataScopeSchemaSettingsItem } from '../../../../schema-settings/setTheDataScopeSchemaSettingsItem';
|
import { setTheDataScopeSchemaSettingsItem } from '../../../../schema-settings/setTheDataScopeSchemaSettingsItem';
|
||||||
import { useBlockTemplateContext } from '../../../../schema-templates/BlockTemplateProvider';
|
import { useBlockTemplateContext } from '../../../../schema-templates/BlockTemplateProvider';
|
||||||
import { setDataLoadingModeSettingsItem } from '../details-multi/setDataLoadingModeSettingsItem';
|
import { setDataLoadingModeSettingsItem } from '../details-multi/setDataLoadingModeSettingsItem';
|
||||||
|
import { SchemaSettingsItemType } from '../../../../application';
|
||||||
|
|
||||||
|
const enabledIndexColumn: SchemaSettingsItemType = {
|
||||||
|
name: 'enableIndexColumn',
|
||||||
|
type: 'switch',
|
||||||
|
useComponentProps: () => {
|
||||||
|
const field = useField();
|
||||||
|
const fieldSchema = useFieldSchema();
|
||||||
|
const { t } = useTranslation();
|
||||||
|
const { dn } = useDesignable();
|
||||||
|
return {
|
||||||
|
title: t('Enable index column'),
|
||||||
|
checked: field.decoratorProps.enableSelectColumn !== false,
|
||||||
|
onChange: async (enableIndexÏColumn) => {
|
||||||
|
field.decoratorProps = field.decoratorProps || {};
|
||||||
|
field.decoratorProps.enableIndexÏColumn = enableIndexÏColumn;
|
||||||
|
fieldSchema['x-decorator-props'].enableIndexÏColumn = enableIndexÏColumn;
|
||||||
|
dn.emit('patch', {
|
||||||
|
schema: {
|
||||||
|
['x-uid']: fieldSchema['x-uid'],
|
||||||
|
'x-decorator-props': fieldSchema['x-decorator-props'],
|
||||||
|
},
|
||||||
|
});
|
||||||
|
},
|
||||||
|
};
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
export const tableBlockSettings = new SchemaSettings({
|
export const tableBlockSettings = new SchemaSettings({
|
||||||
name: 'blockSettings:table',
|
name: 'blockSettings:table',
|
||||||
@ -139,6 +166,7 @@ export const tableBlockSettings = new SchemaSettings({
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
enabledIndexColumn,
|
||||||
{
|
{
|
||||||
name: 'SortField',
|
name: 'SortField',
|
||||||
Component: SchemaSettingsSortField,
|
Component: SchemaSettingsSortField,
|
||||||
|
@ -28,7 +28,33 @@ import { isSubMode } from '../../../../schema-component/antd/association-field/u
|
|||||||
import { useIsAssociationField } from '../../../../schema-component/antd/form-item';
|
import { useIsAssociationField } from '../../../../schema-component/antd/form-item';
|
||||||
import { FormLinkageRules } from '../../../../schema-settings/LinkageRules';
|
import { FormLinkageRules } from '../../../../schema-settings/LinkageRules';
|
||||||
import { SchemaSettingsLinkageRules } from '../../../../schema-settings/SchemaSettings';
|
import { SchemaSettingsLinkageRules } from '../../../../schema-settings/SchemaSettings';
|
||||||
|
import { SchemaSettingsItemType } from '../../../../application';
|
||||||
|
|
||||||
|
const enabledIndexColumn: SchemaSettingsItemType = {
|
||||||
|
name: 'enableIndexColumn',
|
||||||
|
type: 'switch',
|
||||||
|
useComponentProps: () => {
|
||||||
|
const field = useField();
|
||||||
|
const fieldSchema = useFieldSchema();
|
||||||
|
const { t } = useTranslation();
|
||||||
|
const { dn } = useDesignable();
|
||||||
|
return {
|
||||||
|
title: t('Enable index column'),
|
||||||
|
checked: field.componentProps.enableIndexÏColumn !== false,
|
||||||
|
onChange: async (enableIndexÏColumn) => {
|
||||||
|
field.componentProps = field.componentProps || {};
|
||||||
|
field.componentProps.enableIndexÏColumn = enableIndexÏColumn;
|
||||||
|
fieldSchema['x-component-props'].enableIndexÏColumn = enableIndexÏColumn;
|
||||||
|
dn.emit('patch', {
|
||||||
|
schema: {
|
||||||
|
['x-uid']: fieldSchema['x-uid'],
|
||||||
|
'x-component-props': fieldSchema['x-component-props'],
|
||||||
|
},
|
||||||
|
});
|
||||||
|
},
|
||||||
|
};
|
||||||
|
},
|
||||||
|
};
|
||||||
const fieldComponent: any = {
|
const fieldComponent: any = {
|
||||||
name: 'fieldComponent',
|
name: 'fieldComponent',
|
||||||
type: 'select',
|
type: 'select',
|
||||||
@ -365,6 +391,7 @@ export const subTablePopoverComponentFieldSettings = new SchemaSettings({
|
|||||||
allowSelectExistingRecord,
|
allowSelectExistingRecord,
|
||||||
allowDisassociation,
|
allowDisassociation,
|
||||||
setDefaultSortingRules,
|
setDefaultSortingRules,
|
||||||
|
enabledIndexColumn,
|
||||||
linkageRules,
|
linkageRules,
|
||||||
recordPerPage,
|
recordPerPage,
|
||||||
],
|
],
|
||||||
|
@ -97,7 +97,7 @@ export const SubTable: any = observer(
|
|||||||
const labelUiSchema = useLabelUiSchema(collectionField, fieldNames?.label || 'label');
|
const labelUiSchema = useLabelUiSchema(collectionField, fieldNames?.label || 'label');
|
||||||
const recordV2 = useCollectionRecord();
|
const recordV2 = useCollectionRecord();
|
||||||
const collection = useCollection();
|
const collection = useCollection();
|
||||||
const { allowSelectExistingRecord, allowAddnew, allowDisassociation } = field.componentProps;
|
const { allowSelectExistingRecord, allowAddnew, allowDisassociation, enableIndexÏColumn } = field.componentProps;
|
||||||
|
|
||||||
useSubTableSpecialCase({ rootField: field, rootSchema: schema });
|
useSubTableSpecialCase({ rootField: field, rootSchema: schema });
|
||||||
|
|
||||||
@ -218,7 +218,7 @@ export const SubTable: any = observer(
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
console.log(props);
|
||||||
return (
|
return (
|
||||||
<div className={subTableContainer}>
|
<div className={subTableContainer}>
|
||||||
<FlagProvider isInSubTable>
|
<FlagProvider isInSubTable>
|
||||||
@ -252,6 +252,7 @@ export const SubTable: any = observer(
|
|||||||
locale={{
|
locale={{
|
||||||
emptyText: <span> {field.editable ? t('Please add or select record') : t('No data')}</span>,
|
emptyText: <span> {field.editable ? t('Please add or select record') : t('No data')}</span>,
|
||||||
}}
|
}}
|
||||||
|
enableIndexÏColumn={enableIndexÏColumn !== false}
|
||||||
/>
|
/>
|
||||||
{field.editable && (
|
{field.editable && (
|
||||||
<Space
|
<Space
|
||||||
|
@ -679,6 +679,7 @@ export const Table: any = withDynamicSchemaProps(
|
|||||||
onExpand,
|
onExpand,
|
||||||
loading,
|
loading,
|
||||||
onClickRow,
|
onClickRow,
|
||||||
|
enableIndexÏColumn,
|
||||||
...others
|
...others
|
||||||
} = { ...others1, ...others2 } as any;
|
} = { ...others1, ...others2 } as any;
|
||||||
const field = useArrayField(others);
|
const field = useArrayField(others);
|
||||||
@ -831,7 +832,8 @@ export const Table: any = withDynamicSchemaProps(
|
|||||||
|
|
||||||
const restProps = useMemo(
|
const restProps = useMemo(
|
||||||
() => ({
|
() => ({
|
||||||
rowSelection: memoizedRowSelection
|
rowSelection: enableIndexÏColumn
|
||||||
|
? memoizedRowSelection
|
||||||
? {
|
? {
|
||||||
type: 'checkbox',
|
type: 'checkbox',
|
||||||
selectedRowKeys: selectedRowKeys,
|
selectedRowKeys: selectedRowKeys,
|
||||||
@ -890,6 +892,7 @@ export const Table: any = withDynamicSchemaProps(
|
|||||||
},
|
},
|
||||||
...memoizedRowSelection,
|
...memoizedRowSelection,
|
||||||
}
|
}
|
||||||
|
: undefined
|
||||||
: undefined,
|
: undefined,
|
||||||
}),
|
}),
|
||||||
[
|
[
|
||||||
@ -903,6 +906,7 @@ export const Table: any = withDynamicSchemaProps(
|
|||||||
isRowSelect,
|
isRowSelect,
|
||||||
memoizedRowSelection,
|
memoizedRowSelection,
|
||||||
paginationProps,
|
paginationProps,
|
||||||
|
enableIndexÏColumn,
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -851,7 +851,7 @@ export const Table: any = withDynamicSchemaProps(
|
|||||||
const collection = useCollection();
|
const collection = useCollection();
|
||||||
const isTableSelector = schema?.parent?.['x-decorator'] === 'TableSelectorProvider';
|
const isTableSelector = schema?.parent?.['x-decorator'] === 'TableSelectorProvider';
|
||||||
const ctx = isTableSelector ? useTableSelectorContext() : useTableBlockContext();
|
const ctx = isTableSelector ? useTableSelectorContext() : useTableBlockContext();
|
||||||
const { expandFlag, allIncludesChildren } = ctx;
|
const { expandFlag, allIncludesChildren, enableIndexÏColumn } = ctx;
|
||||||
const onRowDragEnd = useMemoizedFn(others.onRowDragEnd || (() => {}));
|
const onRowDragEnd = useMemoizedFn(others.onRowDragEnd || (() => {}));
|
||||||
const paginationProps = usePaginationProps(pagination1, pagination2, props);
|
const paginationProps = usePaginationProps(pagination1, pagination2, props);
|
||||||
const columns = useTableColumns(others, paginationProps);
|
const columns = useTableColumns(others, paginationProps);
|
||||||
@ -1016,7 +1016,9 @@ export const Table: any = withDynamicSchemaProps(
|
|||||||
|
|
||||||
const restProps = useMemo(
|
const restProps = useMemo(
|
||||||
() => ({
|
() => ({
|
||||||
rowSelection: memoizedRowSelection
|
rowSelection:
|
||||||
|
enableIndexÏColumn !== false
|
||||||
|
? memoizedRowSelection
|
||||||
? {
|
? {
|
||||||
type: 'checkbox',
|
type: 'checkbox',
|
||||||
selectedRowKeys: selectedRowKeys,
|
selectedRowKeys: selectedRowKeys,
|
||||||
@ -1082,6 +1084,7 @@ export const Table: any = withDynamicSchemaProps(
|
|||||||
},
|
},
|
||||||
...memoizedRowSelection,
|
...memoizedRowSelection,
|
||||||
}
|
}
|
||||||
|
: undefined
|
||||||
: undefined,
|
: undefined,
|
||||||
}),
|
}),
|
||||||
[
|
[
|
||||||
@ -1096,6 +1099,7 @@ export const Table: any = withDynamicSchemaProps(
|
|||||||
memoizedRowSelection,
|
memoizedRowSelection,
|
||||||
paginationProps,
|
paginationProps,
|
||||||
tableBlockContextBasicValue,
|
tableBlockContextBasicValue,
|
||||||
|
enableIndexÏColumn,
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -176,6 +176,21 @@ export const TableBlockDesigner = () => {
|
|||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
<SchemaSettingsSwitchItem
|
||||||
|
title={t('Enable index column')}
|
||||||
|
checked={field.decoratorProps?.enableSelectColumn !== false}
|
||||||
|
onChange={async (enableIndexÏColumn) => {
|
||||||
|
field.decoratorProps = field.decoratorProps || {};
|
||||||
|
field.decoratorProps.enableIndexÏColumn = enableIndexÏColumn;
|
||||||
|
fieldSchema['x-decorator-props'].enableIndexÏColumn = enableIndexÏColumn;
|
||||||
|
dn.emit('patch', {
|
||||||
|
schema: {
|
||||||
|
['x-uid']: fieldSchema['x-uid'],
|
||||||
|
'x-decorator-props': fieldSchema['x-decorator-props'],
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
/>
|
||||||
{field.decoratorProps.dragSort && <EditSortField />}
|
{field.decoratorProps.dragSort && <EditSortField />}
|
||||||
<SchemaSettingsDataScope
|
<SchemaSettingsDataScope
|
||||||
collectionName={name}
|
collectionName={name}
|
||||||
|
@ -72,6 +72,10 @@ describe('Table.settings', () => {
|
|||||||
expect(screen.queryByText('Drag and drop sorting field')).not.toBeInTheDocument();
|
expect(screen.queryByText('Drag and drop sorting field')).not.toBeInTheDocument();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
title: 'Enable index column',
|
||||||
|
type: 'switch',
|
||||||
|
},
|
||||||
// {
|
// {
|
||||||
// title: 'Fix block',
|
// title: 'Fix block',
|
||||||
// type: 'switch',
|
// type: 'switch',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user