根据 itemDraggableOn 控制拖拽按钮是否显示 (#2255)

Co-authored-by: cy <chenyi08@kuaishou.com>
This commit is contained in:
cyboning 2021-07-09 20:33:26 +08:00 committed by GitHub
parent 3589f0bfe0
commit 02bfa4bc6f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,7 +3,7 @@ import {findDOMNode} from 'react-dom';
import {Renderer, RendererProps} from '../../factory';
import {SchemaNode, Action, Schema} from '../../types';
import forEach from 'lodash/forEach';
import {filter} from '../../utils/tpl';
import {evalExpression, filter} from '../../utils/tpl';
import DropDownButton from '../DropDownButton';
import Checkbox from '../../components/Checkbox';
import Button from '../../components/Button';
@ -2048,7 +2048,14 @@ export default class Table extends React.Component<TableProps, object> {
}
renderActions(region: string) {
let {actions, render, store, classnames: cx, data} = this.props;
let {
actions,
render,
store,
classnames: cx,
data,
itemDraggableOn
} = this.props;
actions = Array.isArray(actions) ? actions.concat() : [];
@ -2068,7 +2075,8 @@ export default class Table extends React.Component<TableProps, object> {
!store.isNested &&
region === 'header' &&
store.rows.length > 1 &&
!~this.renderedToolbars.indexOf('drag-toggler')
!~this.renderedToolbars.indexOf('drag-toggler') &&
(!itemDraggableOn || evalExpression(itemDraggableOn, data))
) {
actions.push({
type: 'button',