fix: transfer selectTitle resultTitle not work (#1957)

* fix: transfer selectTitle resultTitle not work

* feat: selectTitle resultTitle use translate
This commit is contained in:
GGICE 2021-05-14 14:35:24 +08:00 committed by GitHub
parent 875a5e48c2
commit bad661528a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 34 additions and 10 deletions

View File

@ -31,8 +31,6 @@ export interface TabsTransferProps
export class TabsTransfer extends React.Component<TabsTransferProps> { export class TabsTransfer extends React.Component<TabsTransferProps> {
static defaultProps = { static defaultProps = {
selectTitle: 'Select.placeholder',
resultTitle: 'Transfer.selectd',
itemRender: (option: Option) => <span>{option.label}</span> itemRender: (option: Option) => <span>{option.label}</span>
}; };

View File

@ -23,7 +23,7 @@ export interface TransferProps
statistics?: boolean; statistics?: boolean;
showArrow?: boolean; showArrow?: boolean;
selectTitle: string; selectTitle?: string;
selectMode?: 'table' | 'list' | 'tree' | 'chained' | 'associated'; selectMode?: 'table' | 'list' | 'tree' | 'chained' | 'associated';
columns?: Array<{ columns?: Array<{
name: string; name: string;
@ -68,7 +68,7 @@ export interface TransferProps
} }
) => JSX.Element; ) => JSX.Element;
resultTitle: string; resultTitle?: string;
sortable?: boolean; sortable?: boolean;
} }
@ -79,8 +79,6 @@ export interface TransferState {
export class Transfer extends React.Component<TransferProps, TransferState> { export class Transfer extends React.Component<TransferProps, TransferState> {
static defaultProps = { static defaultProps = {
selectTitle: 'Select.placeholder',
resultTitle: 'Transfer.selectd',
itemRender: (option: Option) => <span>{option.label}</span> itemRender: (option: Option) => <span>{option.label}</span>
}; };
@ -223,7 +221,7 @@ export class Transfer extends React.Component<TransferProps, TransferState> {
)} )}
> >
<span> <span>
{__(selectTitle)} {__(selectTitle || 'Select.placeholder')}
{statistics !== false ? ( {statistics !== false ? (
<span> <span>
{this.valueArray.length}/{this.availableOptions.length} {this.valueArray.length}/{this.availableOptions.length}
@ -449,7 +447,7 @@ export class Transfer extends React.Component<TransferProps, TransferState> {
<div className={cx('Transfer-result')}> <div className={cx('Transfer-result')}>
<div className={cx('Transfer-title')}> <div className={cx('Transfer-title')}>
<span> <span>
{__(resultTitle)} {__(resultTitle || 'Transfer.selectd')}
{statistics !== false ? ( {statistics !== false ? (
<span> <span>
{this.valueArray.length}/{this.availableOptions.length} {this.valueArray.length}/{this.availableOptions.length}

View File

@ -41,6 +41,16 @@ export interface TabsTransferControlSchema extends FormOptionsControl {
* API * API
*/ */
searchApi?: SchemaApi; searchApi?: SchemaApi;
/**
*
*/
selectTitle?: string;
/**
*
*/
resultTitle?: string;
} }
export interface TabsTransferProps export interface TabsTransferProps
@ -70,7 +80,9 @@ export class TabsTransferRenderer extends BaseTransferRenderer<TabsTransferProps
searchResultMode, searchResultMode,
showArrow, showArrow,
deferLoad, deferLoad,
disabled disabled,
selectTitle,
resultTitle
} = this.props; } = this.props;
return ( return (
@ -86,6 +98,8 @@ export class TabsTransferRenderer extends BaseTransferRenderer<TabsTransferProps
onSearch={searchable ? this.handleSearch : undefined} onSearch={searchable ? this.handleSearch : undefined}
showArrow={showArrow} showArrow={showArrow}
onDeferLoad={deferLoad} onDeferLoad={deferLoad}
selectTitle={selectTitle}
resultTitle={resultTitle}
/> />
<Spinner overlay key="info" show={loading} /> <Spinner overlay key="info" show={loading} />

View File

@ -76,6 +76,16 @@ export interface TransferControlSchema extends FormOptionsControl {
* API * API
*/ */
searchApi?: SchemaApi; searchApi?: SchemaApi;
/**
*
*/
selectTitle?: string;
/**
*
*/
resultTitle?: string;
} }
export interface BaseTransferProps export interface BaseTransferProps
@ -243,7 +253,9 @@ export class BaseTransferRenderer<
leftOptions, leftOptions,
leftMode, leftMode,
rightMode, rightMode,
disabled disabled,
selectTitle,
resultTitle
} = this.props; } = this.props;
return ( return (
@ -265,6 +277,8 @@ export class BaseTransferRenderer<
leftMode={leftMode} leftMode={leftMode}
rightMode={rightMode} rightMode={rightMode}
cellRender={this.renderCell} cellRender={this.renderCell}
selectTitle={selectTitle}
resultTitle={resultTitle}
/> />
<Spinner overlay key="info" show={loading} /> <Spinner overlay key="info" show={loading} />