Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

增加enableBulkActions属性,批量操作在一定场景下时候可以动态的隐藏多选框和批量操作按钮区 #10971

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 21 additions & 5 deletions packages/amis/src/renderers/CRUD.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,17 @@ export type AutoGenerateFilterObject = {
* 是否显示展开/收起
*/
// showExpand?: boolean;

/**
* 是否默认收起
*
* @default true
*/
defaultCollapsed?: boolean;

/**
* 是否启用多选框
*/
enableBulkActions?: boolean;
};

export type CRUDRendererEvent = TableRendererEvent | CardsRendererEvent;
Expand Down Expand Up @@ -1962,8 +1966,15 @@ export default class CRUD extends React.Component<CRUDProps, any> {
}

hasBulkActionsToolbar() {
const {headerToolbar, footerToolbar} = this.props;

const {headerToolbar, footerToolbar, enableBulkActions} = this.props;

if (enableBulkActions) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

schemaRender.tsx 里面会自动吧 xxxxOn 的运算结果以 xxxx 下发。

所以要不直接文档上说明用 enableBulkActionsOn ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

可以 enableBulkActions: true 或者 enableBulkActionsOn: "${ true }"

const resolvedEnableBulkActions = typeof enableBulkActions === 'string'
? evalExpression(enableBulkActions, this.props.store.data)
: enableBulkActions;

return resolvedEnableBulkActions;
}
const isBulkActions = (item: any) =>
~['bulkActions', 'bulk-actions'].indexOf(item.type || item);
return (
Expand Down Expand Up @@ -2001,10 +2012,15 @@ export default class CRUD extends React.Component<CRUDProps, any> {
store,
render,
classnames: cx,
primaryField
primaryField,
enableBulkActions
} = this.props;

if (!bulkActions || !bulkActions.length) {
const resolvedEnableBulkActions = typeof enableBulkActions === 'string'
? evalExpression(enableBulkActions, this.props.store.data)
: enableBulkActions;

if (!bulkActions || !bulkActions.length || !resolvedEnableBulkActions) {
return null;
}

Expand Down