From bad661528abd7df9513f4e35b682ae3f39e87053 Mon Sep 17 00:00:00 2001 From: GGICE Date: Fri, 14 May 2021 14:35:24 +0800 Subject: [PATCH] fix: transfer `selectTitle` `resultTitle` not work (#1957) * fix: transfer selectTitle resultTitle not work * feat: selectTitle resultTitle use translate --- src/components/TabsTransfer.tsx | 2 -- src/components/Transfer.tsx | 10 ++++------ src/renderers/Form/TabsTransfer.tsx | 16 +++++++++++++++- src/renderers/Form/Transfer.tsx | 16 +++++++++++++++- 4 files changed, 34 insertions(+), 10 deletions(-) diff --git a/src/components/TabsTransfer.tsx b/src/components/TabsTransfer.tsx index 5bbd625a7..e5c17df68 100644 --- a/src/components/TabsTransfer.tsx +++ b/src/components/TabsTransfer.tsx @@ -31,8 +31,6 @@ export interface TabsTransferProps export class TabsTransfer extends React.Component { static defaultProps = { - selectTitle: 'Select.placeholder', - resultTitle: 'Transfer.selectd', itemRender: (option: Option) => {option.label} }; diff --git a/src/components/Transfer.tsx b/src/components/Transfer.tsx index a573e6b94..ca31ea201 100644 --- a/src/components/Transfer.tsx +++ b/src/components/Transfer.tsx @@ -23,7 +23,7 @@ export interface TransferProps statistics?: boolean; showArrow?: boolean; - selectTitle: string; + selectTitle?: string; selectMode?: 'table' | 'list' | 'tree' | 'chained' | 'associated'; columns?: Array<{ name: string; @@ -68,7 +68,7 @@ export interface TransferProps } ) => JSX.Element; - resultTitle: string; + resultTitle?: string; sortable?: boolean; } @@ -79,8 +79,6 @@ export interface TransferState { export class Transfer extends React.Component { static defaultProps = { - selectTitle: 'Select.placeholder', - resultTitle: 'Transfer.selectd', itemRender: (option: Option) => {option.label} }; @@ -223,7 +221,7 @@ export class Transfer extends React.Component { )} > - {__(selectTitle)} + {__(selectTitle || 'Select.placeholder')} {statistics !== false ? ( ({this.valueArray.length}/{this.availableOptions.length}) @@ -449,7 +447,7 @@ export class Transfer extends React.Component {
- {__(resultTitle)} + {__(resultTitle || 'Transfer.selectd')} {statistics !== false ? ( ({this.valueArray.length}/{this.availableOptions.length}) diff --git a/src/renderers/Form/TabsTransfer.tsx b/src/renderers/Form/TabsTransfer.tsx index d3235e949..1d9cdc155 100644 --- a/src/renderers/Form/TabsTransfer.tsx +++ b/src/renderers/Form/TabsTransfer.tsx @@ -41,6 +41,16 @@ export interface TabsTransferControlSchema extends FormOptionsControl { * 搜索 API */ searchApi?: SchemaApi; + + /** + * 左侧的标题文字 + */ + selectTitle?: string; + + /** + * 右侧结果的标题文字 + */ + resultTitle?: string; } export interface TabsTransferProps @@ -70,7 +80,9 @@ export class TabsTransferRenderer extends BaseTransferRenderer diff --git a/src/renderers/Form/Transfer.tsx b/src/renderers/Form/Transfer.tsx index 5663dc7b8..00031ba3e 100644 --- a/src/renderers/Form/Transfer.tsx +++ b/src/renderers/Form/Transfer.tsx @@ -76,6 +76,16 @@ export interface TransferControlSchema extends FormOptionsControl { * 搜索 API */ searchApi?: SchemaApi; + + /** + * 左侧的标题文字 + */ + selectTitle?: string; + + /** + * 右侧结果的标题文字 + */ + resultTitle?: string; } export interface BaseTransferProps @@ -243,7 +253,9 @@ export class BaseTransferRenderer< leftOptions, leftMode, rightMode, - disabled + disabled, + selectTitle, + resultTitle } = this.props; return ( @@ -265,6 +277,8 @@ export class BaseTransferRenderer< leftMode={leftMode} rightMode={rightMode} cellRender={this.renderCell} + selectTitle={selectTitle} + resultTitle={resultTitle} />