修复transfer配置disabled无效的问题

This commit is contained in:
rickcole 2020-09-21 11:06:30 +08:00
parent 2dcc51d0b8
commit 856b4b651d
8 changed files with 51 additions and 8 deletions

View File

@ -105,6 +105,7 @@ export class AssociatedCheckboxes extends BaseCheckboxes<
onChange,
columns,
value,
disabled,
leftMode,
cellRender
} = this.props;
@ -124,6 +125,7 @@ export class AssociatedCheckboxes extends BaseCheckboxes<
option2value={this.leftOption2Value}
options={leftOptions}
value={this.state.leftValue}
disabled={disabled}
onChange={this.handleLeftSelect}
showRadio={false}
/>
@ -132,6 +134,7 @@ export class AssociatedCheckboxes extends BaseCheckboxes<
option2value={this.leftOption2Value}
options={leftOptions}
value={this.state.leftValue}
disabled={disabled}
onChange={this.handleLeftSelect}
showRadio={false}
/>
@ -166,6 +169,7 @@ export class AssociatedCheckboxes extends BaseCheckboxes<
<TableCheckboxes
columns={columns!}
value={value}
disabled={disabled}
options={selectdOption.children || []}
onChange={onChange}
option2value={option2value}
@ -174,6 +178,7 @@ export class AssociatedCheckboxes extends BaseCheckboxes<
) : rightMode === 'tree' ? (
<TreeCheckboxes
value={value}
disabled={disabled}
options={selectdOption.children || []}
onChange={onChange}
option2value={option2value}
@ -181,6 +186,7 @@ export class AssociatedCheckboxes extends BaseCheckboxes<
) : rightMode === 'chained' ? (
<ChainedCheckboxes
value={value}
disabled={disabled}
options={selectdOption.children || []}
onChange={onChange}
option2value={option2value}
@ -188,6 +194,7 @@ export class AssociatedCheckboxes extends BaseCheckboxes<
) : (
<ListCheckboxes
value={value}
disabled={disabled}
options={selectdOption.children || []}
onChange={onChange}
option2value={option2value}

View File

@ -63,9 +63,9 @@ export class BaseCheckboxes<
}
toggleOption(option: Option) {
const {value, onChange, option2value, options} = this.props;
const {value, onChange, option2value, options, disabled} = this.props;
if (option.disabled) {
if (disabled || option.disabled) {
return;
}

View File

@ -50,7 +50,7 @@ export class TableCheckboxes extends BaseCheckboxes<TableCheckboxesProps> {
}
renderTHead() {
const {options, classnames: cx, value, option2value} = this.props;
const {options, classnames: cx, value, disabled, option2value} = this.props;
let columns = this.getColumns();
let valueArray = BaseCheckboxes.value2array(value, options, option2value);
const availableOptions = options.filter(option => !option.disabled);
@ -74,6 +74,7 @@ export class TableCheckboxes extends BaseCheckboxes<TableCheckboxesProps> {
<th className={cx('Table-checkCell')}>
<Checkbox
size="sm"
disabled={disabled}
onChange={this.toggleAll}
checked={partialChecked}
partial={partialChecked && !allChecked}
@ -95,6 +96,7 @@ export class TableCheckboxes extends BaseCheckboxes<TableCheckboxesProps> {
classnames: cx,
cellRender,
value,
disabled,
option2value,
translate: __
} = this.props;
@ -113,7 +115,7 @@ export class TableCheckboxes extends BaseCheckboxes<TableCheckboxesProps> {
onClick={e => e.defaultPrevented || this.toggleOption(option)}
>
<td className={cx('Table-checkCell')}>
<Checkbox size="sm" checked={checked} />
<Checkbox size="sm" checked={checked} disabled={disabled} />
</td>
{columns.map((column, colIndex) => (
<td key={colIndex}>

View File

@ -43,6 +43,7 @@ export class TabsTransfer extends React.Component<TabsTransferProps> {
searchResultColumns,
classnames: cx,
value,
disabled,
onChange,
option2value,
cellRender
@ -57,6 +58,7 @@ export class TabsTransfer extends React.Component<TabsTransferProps> {
columns={searchResultColumns!}
options={options}
value={value}
disabled={disabled}
onChange={onChange}
option2value={option2value}
cellRender={cellRender}
@ -67,6 +69,7 @@ export class TabsTransfer extends React.Component<TabsTransferProps> {
className={cx('Transfer-checkboxes')}
options={options}
value={value}
disabled={disabled}
onChange={onChange}
option2value={option2value}
/>
@ -76,6 +79,7 @@ export class TabsTransfer extends React.Component<TabsTransferProps> {
className={cx('Transfer-checkboxes')}
options={options}
value={value}
disabled={disabled}
onChange={onChange}
option2value={option2value}
/>
@ -85,6 +89,7 @@ export class TabsTransfer extends React.Component<TabsTransferProps> {
className={cx('Transfer-checkboxes')}
options={options}
value={value}
disabled={disabled}
onChange={onChange}
option2value={option2value}
/>
@ -98,6 +103,7 @@ export class TabsTransfer extends React.Component<TabsTransferProps> {
placeholder,
classnames: cx,
value,
disabled,
onChange,
onSearch: searchable,
option2value,
@ -146,6 +152,7 @@ export class TabsTransfer extends React.Component<TabsTransferProps> {
columns={option.columns as any}
options={option.children || []}
value={value}
disabled={disabled}
onChange={onChange}
option2value={option2value}
onDeferLoad={onDeferLoad}
@ -156,6 +163,7 @@ export class TabsTransfer extends React.Component<TabsTransferProps> {
className={cx('Transfer-checkboxes')}
options={option.children || []}
value={value}
disabled={disabled}
onChange={onChange}
option2value={option2value}
onDeferLoad={onDeferLoad}
@ -165,6 +173,7 @@ export class TabsTransfer extends React.Component<TabsTransferProps> {
className={cx('Transfer-checkboxes')}
options={option.children || []}
value={value}
disabled={disabled}
onChange={onChange}
option2value={option2value}
onDeferLoad={onDeferLoad}
@ -175,6 +184,7 @@ export class TabsTransfer extends React.Component<TabsTransferProps> {
className={cx('Transfer-checkboxes')}
options={option.children || []}
value={value}
disabled={disabled}
onChange={onChange}
option2value={option2value}
onDeferLoad={onDeferLoad}
@ -187,6 +197,7 @@ export class TabsTransfer extends React.Component<TabsTransferProps> {
className={cx('Transfer-checkboxes')}
options={option.children || []}
value={value}
disabled={disabled}
onChange={onChange}
option2value={option2value}
onDeferLoad={onDeferLoad}

View File

@ -270,6 +270,7 @@ export class Transfer extends React.Component<TransferProps, TransferState> {
searchResultColumns,
classnames: cx,
value,
disabled,
onChange,
option2value,
cellRender
@ -284,6 +285,7 @@ export class Transfer extends React.Component<TransferProps, TransferState> {
columns={searchResultColumns!}
options={options}
value={value}
disabled={disabled}
onChange={onChange}
option2value={option2value}
cellRender={cellRender}
@ -294,6 +296,7 @@ export class Transfer extends React.Component<TransferProps, TransferState> {
className={cx('Transfer-checkboxes')}
options={options}
value={value}
disabled={disabled}
onChange={onChange}
option2value={option2value}
/>
@ -303,6 +306,7 @@ export class Transfer extends React.Component<TransferProps, TransferState> {
className={cx('Transfer-checkboxes')}
options={options}
value={value}
disabled={disabled}
onChange={onChange}
option2value={option2value}
/>
@ -312,6 +316,7 @@ export class Transfer extends React.Component<TransferProps, TransferState> {
className={cx('Transfer-checkboxes')}
options={options}
value={value}
disabled={disabled}
onChange={onChange}
option2value={option2value}
/>
@ -324,6 +329,7 @@ export class Transfer extends React.Component<TransferProps, TransferState> {
columns,
options,
value,
disabled,
onChange,
option2value,
classnames: cx,
@ -341,6 +347,7 @@ export class Transfer extends React.Component<TransferProps, TransferState> {
columns={columns!}
options={options || []}
value={value}
disabled={disabled}
onChange={onChange}
option2value={option2value}
onDeferLoad={onDeferLoad}
@ -351,6 +358,7 @@ export class Transfer extends React.Component<TransferProps, TransferState> {
className={cx('Transfer-checkboxes')}
options={options || []}
value={value}
disabled={disabled}
onChange={onChange}
option2value={option2value}
onDeferLoad={onDeferLoad}
@ -360,6 +368,7 @@ export class Transfer extends React.Component<TransferProps, TransferState> {
className={cx('Transfer-checkboxes')}
options={options || []}
value={value}
disabled={disabled}
onChange={onChange}
option2value={option2value}
onDeferLoad={onDeferLoad}
@ -369,6 +378,7 @@ export class Transfer extends React.Component<TransferProps, TransferState> {
className={cx('Transfer-checkboxes')}
options={options || []}
value={value}
disabled={disabled}
onChange={onChange}
option2value={option2value}
onDeferLoad={onDeferLoad}
@ -383,6 +393,7 @@ export class Transfer extends React.Component<TransferProps, TransferState> {
className={cx('Transfer-checkboxes')}
options={options || []}
value={value}
disabled={disabled}
onChange={onChange}
option2value={option2value}
onDeferLoad={onDeferLoad}
@ -450,6 +461,7 @@ export class Transfer extends React.Component<TransferProps, TransferState> {
<ResultList
className={cx('Transfer-selections')}
sortable={sortable}
disabled={disabled}
value={value}
onChange={onChange}
placeholder={__('请先选择左侧数据')}

View File

@ -76,9 +76,16 @@ export class TreeCheckboxes extends BaseCheckboxes<
}
toggleOption(option: Option) {
const {value, onChange, option2value, options, onDeferLoad} = this.props;
const {
value,
onChange,
option2value,
options,
onDeferLoad,
disabled
} = this.props;
if (option.disabled) {
if (disabled || option.disabled) {
return;
} else if (option.defer && !option.loaded) {
onDeferLoad?.(option);

View File

@ -64,13 +64,15 @@ export class TabsTransferRenderer extends BaseTransferRenderer<
searchable,
searchResultMode,
showArrow,
deferLoad
deferLoad,
disabled
} = this.props;
return (
<div className={cx('TabsTransferControl', className)}>
<TabsTransfer
value={selectedOptions}
disabled={disabled}
options={options}
onChange={this.handleChange}
option2value={this.option2value}

View File

@ -235,7 +235,8 @@ export class BaseTransferRenderer<
deferLoad,
leftOptions,
leftMode,
rightMode
rightMode,
disabled
} = this.props;
return (
@ -243,6 +244,7 @@ export class BaseTransferRenderer<
<Transfer
value={selectedOptions}
options={options}
disabled={disabled}
onChange={this.handleChange}
option2value={this.option2value}
sortable={sortable}