From ef3af58e23d1e12a1b3cccf547e990550a54fcde Mon Sep 17 00:00:00 2001 From: Chong <47734376+chongqiangchen@users.noreply.github.com> Date: Sat, 13 Feb 2021 21:24:51 +0800 Subject: [PATCH] feat(module:time-picker): support updating OK and Now button text (#6410) --- components/core/config/config.ts | 2 ++ components/time-picker/doc/index.en-US.md | 2 ++ components/time-picker/doc/index.zh-CN.md | 2 ++ components/time-picker/time-picker-panel.component.ts | 6 ++++-- components/time-picker/time-picker.component.ts | 4 ++++ 5 files changed, 14 insertions(+), 2 deletions(-) diff --git a/components/core/config/config.ts b/components/core/config/config.ts index dfe07805ec1..f4e53749b55 100644 --- a/components/core/config/config.ts +++ b/components/core/config/config.ts @@ -257,6 +257,8 @@ export interface TabsConfig { export interface TimePickerConfig { nzAllowEmpty?: boolean; nzClearText?: string; + nzNowText?: string; + nzOkText?: string; nzFormat?: string; nzHourStep?: number; nzMinuteStep?: number; diff --git a/components/time-picker/doc/index.en-US.md b/components/time-picker/doc/index.en-US.md index 1b4dd4190d5..91e36aed71d 100644 --- a/components/time-picker/doc/index.en-US.md +++ b/components/time-picker/doc/index.en-US.md @@ -30,6 +30,8 @@ import { NzTimePickerModule } from 'ng-zorro-antd/time-picker'; | `[nzAllowEmpty]` | allow clearing text | `boolean` | `true` | ✅ | | `[nzAutoFocus]` | get focus when component mounted | `boolean` | `false` | | `[nzClearText]` | clear tooltip of icon | `string` | `'clear'` | ✅ | +| `[nzNowText]` | text of the Now button | `string` | `'Now'` | ✅ | +| `[nzOkText]` | text of the Ok button | `string` | `'Ok'` | ✅ | | `[nzDefaultOpenValue]` | default open panel value if `[ngModel]` is null | `Date` | `new Date()` | | `[nzDisabled]` | determine whether the TimePicker is disabled | `boolean` | `false` | | `[nzDisabledHours]` | to specify the hours that cannot be selected | `() => number[]` | - | diff --git a/components/time-picker/doc/index.zh-CN.md b/components/time-picker/doc/index.zh-CN.md index a293e699356..70e70932f6a 100644 --- a/components/time-picker/doc/index.zh-CN.md +++ b/components/time-picker/doc/index.zh-CN.md @@ -31,6 +31,8 @@ import { NzTimePickerModule } from 'ng-zorro-antd/time-picker'; | `[nzAllowEmpty]` | 是否展示清除按钮 | `boolean` | `true` | ✅ | | `[nzAutoFocus]` | 自动获取焦点 | `boolean` | `false` | | `[nzClearText]` | 清除按钮的提示文案 | `string` | `'clear'` | ✅ | +| `[nzNowText]` | 此刻按钮文本 | `string` | `"此刻"` | ✅ | +| `[nzOkText]` | 确认按钮文本 | `string` | `"确定"` | ✅ | | `[nzDefaultOpenValue]` | 当 `[ngModel]` 不存在时,可以设置面板打开时默认选中的值 | `Date` | `new Date()` | | `[nzDisabled]` | 禁用全部操作 | `boolean` | `false` | | `[nzDisabledHours]` | 禁止选择部分小时选项 | `() => number[]` | - | diff --git a/components/time-picker/time-picker-panel.component.ts b/components/time-picker/time-picker-panel.component.ts index c4d97c2d4dc..69b75561b5a 100644 --- a/components/time-picker/time-picker-panel.component.ts +++ b/components/time-picker/time-picker-panel.component.ts @@ -105,12 +105,12 @@ export type NzTimePickerUnit = 'hour' | 'minute' | 'second' | '12-hour'; @@ -162,6 +162,8 @@ export class NzTimePickerPanelComponent implements ControlValueAccessor, OnInit, @Input() nzAddOn?: TemplateRef; @Input() nzHideDisabledOptions = false; @Input() nzClearText?: string; + @Input() nzNowText?: string; + @Input() nzOkText?: string; @Input() nzPlaceHolder?: string | null; @Input() @InputBoolean() nzUse12Hours = false; @Input() nzDefaultOpenValue?: Date; diff --git a/components/time-picker/time-picker.component.ts b/components/time-picker/time-picker.component.ts index 0f30f529657..44a7c270f97 100644 --- a/components/time-picker/time-picker.component.ts +++ b/components/time-picker/time-picker.component.ts @@ -98,6 +98,8 @@ const NZ_CONFIG_MODULE_NAME: NzConfigKey = 'timePicker'; [nzDefaultOpenValue]="nzDefaultOpenValue" [nzAddOn]="nzAddOn" [nzClearText]="nzClearText" + [nzNowText]="nzNowText" + [nzOkText]="nzOkText" [nzAllowEmpty]="nzAllowEmpty" [(ngModel)]="value" (ngModelChange)="onPanelValueChange($event)" @@ -156,6 +158,8 @@ export class NzTimePickerComponent implements ControlValueAccessor, OnInit, Afte @Input() @WithConfig() nzMinuteStep: number = 1; @Input() @WithConfig() nzSecondStep: number = 1; @Input() @WithConfig() nzClearText: string = 'clear'; + @Input() @WithConfig() nzNowText: string = ''; + @Input() @WithConfig() nzOkText: string = ''; @Input() @WithConfig() nzPopupClassName: string = ''; @Input() nzPlaceHolder = ''; @Input() nzAddOn?: TemplateRef;