From bc0bc467ef64552856ee1fe3a49069f94dbd7c5a Mon Sep 17 00:00:00 2001 From: kekehaoz Date: Mon, 4 Mar 2019 19:53:36 +0800 Subject: [PATCH 01/10] feat(module: Modal): support `nzMask` and `nzMaskCloseable` global config (#1594) --- components/modal/nz-modal-config.ts | 16 ++------ components/modal/nz-modal.component.ts | 54 +++++++++++++++++++++----- 2 files changed, 47 insertions(+), 23 deletions(-) diff --git a/components/modal/nz-modal-config.ts b/components/modal/nz-modal-config.ts index db66f7f1751..205e99358da 100644 --- a/components/modal/nz-modal-config.ts +++ b/components/modal/nz-modal-config.ts @@ -1,17 +1,7 @@ import { InjectionToken } from '@angular/core'; -export const NZ_MODAL_DEFAULT_CONFIG: NzModalConfig = { - autoBodyPadding: true -}; - -export const NZ_MODAL_CONFIG = new InjectionToken('NzModalConfig', { - providedIn: 'root', - factory: () => NZ_MODAL_DEFAULT_CONFIG // Default config -}); - export interface NzModalConfig { - /** - * @deprecated used {@link BlockScrollStrategy} instead. - */ - autoBodyPadding?: boolean; // Whether add the padding-right and overflow to body automatically to play smoothly + nzMask?: boolean; + nzMaskClosable?: boolean; } +export const NZ_MODAL_CONFIG = new InjectionToken('NZ_MODAL_CONFIG'); diff --git a/components/modal/nz-modal.component.ts b/components/modal/nz-modal.component.ts index d01c2c1a8ed..835f62874e7 100644 --- a/components/modal/nz-modal.component.ts +++ b/components/modal/nz-modal.component.ts @@ -18,6 +18,7 @@ import { OnChanges, OnDestroy, OnInit, + Optional, Output, SimpleChanges, TemplateRef, @@ -33,7 +34,7 @@ import { InputBoolean } from '../core/util/convert'; import { isPromise } from '../core/util/is-promise'; import { NzI18nService } from '../i18n/nz-i18n.service'; import ModalUtil from './modal-util'; -import { NzModalConfig, NZ_MODAL_CONFIG, NZ_MODAL_DEFAULT_CONFIG } from './nz-modal-config'; +import { NzModalConfig, NZ_MODAL_CONFIG } from './nz-modal-config'; import { NzModalControlService } from './nz-modal-control.service'; import { NzModalRef } from './nz-modal-ref.class'; import { ModalButtonOptions, ModalOptions, ModalType, OnClickCallback } from './nz-modal.type'; @@ -54,8 +55,6 @@ export class NzModalComponent extends NzModalRef impleme @Input() @InputBoolean() nzVisible: boolean = false; @Input() @InputBoolean() nzClosable: boolean = true; - @Input() @InputBoolean() nzMask: boolean = true; - @Input() @InputBoolean() nzMaskClosable: boolean = true; @Input() @InputBoolean() nzOkLoading: boolean = false; @Input() @InputBoolean() nzOkDisabled: boolean = false; @Input() @InputBoolean() nzCancelDisabled: boolean = false; @@ -80,6 +79,38 @@ export class NzModalComponent extends NzModalRef impleme @Input() nzIconType: string = 'question-circle'; // Confirm Modal ONLY @Input() nzModalType: ModalType = 'default'; + @Input() @InputBoolean() + get nzMask(): boolean { + if (this.nzMaskDetect.dirty) { + return this.nzMaskDetect.value; + } else if (this.globalConfig) { + return this.globalConfig.nzMask; + } else { + return true; + } + } + + set nzMask(value: boolean) { + this.nzMaskDetect.value = value; + this.nzMaskDetect.dirty = true; + } + + @Input() @InputBoolean() + get nzMaskClosable(): boolean { + if (this.nzMaskCloseableDetect.dirty) { + return this.nzMaskCloseableDetect.value; + } else if (this.globalConfig) { + return this.globalConfig.nzMaskClosable; + } else { + return true; + } + } + + set nzMaskClosable(value: boolean) { + this.nzMaskCloseableDetect.value = value; + this.nzMaskCloseableDetect.dirty = true; + } + @Input() @Output() readonly nzOnOk: EventEmitter | OnClickCallback = new EventEmitter(); @Input() @Output() readonly nzOnCancel: EventEmitter | OnClickCallback = new EventEmitter(); @@ -123,6 +154,14 @@ export class NzModalComponent extends NzModalRef impleme private previouslyFocusedElement: HTMLElement; private focusTrap: FocusTrap; private scrollStrategy: BlockScrollStrategy; + private globalConfig: NzModalConfig; + private nzMaskDetect: { dirty: boolean, value?: boolean } = { + dirty: false + }; + + private nzMaskCloseableDetect: { dirty: boolean, value?: boolean } = { + dirty: false + }; constructor( private overlay: Overlay, @@ -133,12 +172,11 @@ export class NzModalComponent extends NzModalRef impleme private modalControl: NzModalControlService, private focusTrapFactory: FocusTrapFactory, private cdr: ChangeDetectorRef, - @Inject(NZ_MODAL_CONFIG) private config: NzModalConfig, + @Optional() @Inject(NZ_MODAL_CONFIG) globalConfig: NzModalConfig, @Inject(DOCUMENT) private document: any) { // tslint:disable-line:no-any super(); - - this.config = this.mergeDefaultConfig(this.config); + this.globalConfig = globalConfig; this.scrollStrategy = this.overlay.scrollStrategies.block(); } @@ -428,10 +466,6 @@ export class NzModalComponent extends NzModalRef impleme } } - private mergeDefaultConfig(config: NzModalConfig): NzModalConfig { - return { ...NZ_MODAL_DEFAULT_CONFIG, ...config }; - } - private savePreviouslyFocusedElement(): void { if (this.document) { this.previouslyFocusedElement = this.document.activeElement as HTMLElement; From b2382ad886093d4e914f6601703fae39aac254e9 Mon Sep 17 00:00:00 2001 From: kekehaoz Date: Mon, 4 Mar 2019 21:42:30 +0800 Subject: [PATCH 02/10] feat(module: Modal): support global config `nzMask` and `nzMaskClosable` --- components/modal/nz-modal.component.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/components/modal/nz-modal.component.ts b/components/modal/nz-modal.component.ts index 835f62874e7..bb1fc1bdd61 100644 --- a/components/modal/nz-modal.component.ts +++ b/components/modal/nz-modal.component.ts @@ -97,8 +97,8 @@ export class NzModalComponent extends NzModalRef impleme @Input() @InputBoolean() get nzMaskClosable(): boolean { - if (this.nzMaskCloseableDetect.dirty) { - return this.nzMaskCloseableDetect.value; + if (this.nzMaskClosableDetect.dirty) { + return this.nzMaskClosableDetect.value; } else if (this.globalConfig) { return this.globalConfig.nzMaskClosable; } else { @@ -107,8 +107,8 @@ export class NzModalComponent extends NzModalRef impleme } set nzMaskClosable(value: boolean) { - this.nzMaskCloseableDetect.value = value; - this.nzMaskCloseableDetect.dirty = true; + this.nzMaskClosableDetect.value = value; + this.nzMaskClosableDetect.dirty = true; } @Input() @Output() readonly nzOnOk: EventEmitter | OnClickCallback = new EventEmitter(); @@ -159,7 +159,7 @@ export class NzModalComponent extends NzModalRef impleme dirty: false }; - private nzMaskCloseableDetect: { dirty: boolean, value?: boolean } = { + private nzMaskClosableDetect: { dirty: boolean, value?: boolean } = { dirty: false }; From 813ea18d2c1d8ca89cfeb7a4e8225daed4595f8a Mon Sep 17 00:00:00 2001 From: kekehaoz Date: Tue, 5 Mar 2019 21:14:12 +0800 Subject: [PATCH 03/10] feat(module: Modal): support global config (#1594) support global config `nzMask` and `nzMaskClosable` --- components/modal/nz-modal.component.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/components/modal/nz-modal.component.ts b/components/modal/nz-modal.component.ts index bb1fc1bdd61..e6b18d1f871 100644 --- a/components/modal/nz-modal.component.ts +++ b/components/modal/nz-modal.component.ts @@ -30,6 +30,7 @@ import { import { fromEvent, Observable, Subject } from 'rxjs'; import { takeUntil } from 'rxjs/operators'; +import { isNotNil } from '../core/util'; import { InputBoolean } from '../core/util/convert'; import { isPromise } from '../core/util/is-promise'; import { NzI18nService } from '../i18n/nz-i18n.service'; @@ -83,7 +84,7 @@ export class NzModalComponent extends NzModalRef impleme get nzMask(): boolean { if (this.nzMaskDetect.dirty) { return this.nzMaskDetect.value; - } else if (this.globalConfig) { + } else if (isNotNil(this.globalConfig) && isNotNil(this.globalConfig.nzMask)) { return this.globalConfig.nzMask; } else { return true; @@ -99,7 +100,7 @@ export class NzModalComponent extends NzModalRef impleme get nzMaskClosable(): boolean { if (this.nzMaskClosableDetect.dirty) { return this.nzMaskClosableDetect.value; - } else if (this.globalConfig) { + } else if (isNotNil(this.globalConfig) && isNotNil(this.globalConfig.nzMaskClosable)) { return this.globalConfig.nzMaskClosable; } else { return true; From 9a3d9a255d8c9cc8e1d9d9ba1eb54442d96c608e Mon Sep 17 00:00:00 2001 From: kekehaoz Date: Tue, 5 Mar 2019 21:15:00 +0800 Subject: [PATCH 04/10] test(module: Modal): support global config (#1594) support global config `nzMask` and `nzMaskClosable` --- components/modal/nz-modal.spec.ts | 62 +++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/components/modal/nz-modal.spec.ts b/components/modal/nz-modal.spec.ts index 984a3e5b711..906b0729145 100644 --- a/components/modal/nz-modal.spec.ts +++ b/components/modal/nz-modal.spec.ts @@ -17,6 +17,7 @@ import en_US from '../i18n/languages/en_US'; import { NzI18nService } from '../i18n/nz-i18n.service'; import { NzIconTestModule } from '../icon/nz-icon-test.module'; import { CssUnitPipe } from './css-unit.pipe'; +import { NZ_MODAL_CONFIG } from './nz-modal-config'; import { NzModalControlService } from './nz-modal-control.service'; import { NzModalRef } from './nz-modal-ref.class'; import { NzModalComponent } from './nz-modal.component'; @@ -349,6 +350,55 @@ describe('modal testing (legacy)', () => { }); }); +describe('global config', () => { + let basicFixture: ComponentFixture; + let inputFixture: ComponentFixture; + let nativeElement: HTMLElement; + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [ NoopAnimationsModule, NzModalModule ], + providers: [{ + provide: NZ_MODAL_CONFIG, + useValue: { + nzMask: false, + nzMaskClosable: false + } + }], + declarations: [ + NzDemoModalBasicComponent, + NzDemoModalWithInputComponent + ] + }).compileComponents(); + basicFixture = TestBed.createComponent(NzDemoModalBasicComponent); + inputFixture = TestBed.createComponent(NzDemoModalWithInputComponent); + }); + + it('nzMask be global config value', fakeAsync(() => { + const debugElement = basicFixture.debugElement.query(By.css('.ant-modal-mask')); + basicFixture.detectChanges(); + expect(debugElement).toBe(null); + })); + + it('nzMask should be input value', fakeAsync(() => { + inputFixture.componentInstance.nzMask = true; + inputFixture.detectChanges(); + nativeElement = inputFixture.debugElement.query(By.css('.ant-modal-mask')).nativeElement; + inputFixture.detectChanges(); + expect(nativeElement).not.toBe(null); + })); + + it('nzMaskClosable should be global config value', fakeAsync(() => { + inputFixture.componentInstance.nzMask = true; + inputFixture.detectChanges(); + nativeElement = inputFixture.debugElement.query(By.css('.ant-modal-wrap')).nativeElement; + inputFixture.detectChanges(); + nativeElement.click(); + inputFixture.detectChanges(); + console.log(inputFixture.debugElement.nativeElement); + expectModalHidden(inputFixture.debugElement.query(By.css('nz-modal')).nativeElement, true); + })); +}); + describe('NzModal', () => { let modalService: NzModalService; let overlayContainer: OverlayContainer; @@ -578,6 +628,18 @@ class NzDemoModalBasicComponent { modalAvailable = true; } +@Component({ + template: ` + +

content

+
+ ` +}) +class NzDemoModalWithInputComponent { + modalAvailable = true; + nzMask = true; +} + @Component({ selector: 'nz-demo-modal-async', template: ` From 754385b6b7cd76bdbfc533dfbdfe8e331a430d2b Mon Sep 17 00:00:00 2001 From: kekehaoz Date: Wed, 6 Mar 2019 19:59:10 +0800 Subject: [PATCH 05/10] docs(module: Modal): support global configuration Modal support `nzMask` and `nzMaskClosable` global configuration --- components/modal/doc/index.en-US.md | 24 ++++++++++++++++++++++++ components/modal/doc/index.zh-CN.md | 23 +++++++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/components/modal/doc/index.en-US.md b/components/modal/doc/index.en-US.md index 909afd5ad06..5e7904dae44 100644 --- a/components/modal/doc/index.en-US.md +++ b/components/modal/doc/index.en-US.md @@ -120,6 +120,30 @@ The dialog created by the service method `NzModalService.xxx()` will return a `N | triggerOk() | Manually trigger nzOnOk | | triggerCancel() | Manually trigger nzOnCancel | + +### Global Configuration + +Global Configuration(NZ_MODAL_CONFIG) + +if your want to set global configuration, you can use the value of provide `NZ_MODAL_CONFIG` to accomplish it. +(eg, add `{ provide: NZ_MODAL_CONFIG, useValue: { nzMask: false }}` to `providers` of your module, you can import `NZ_MODAL_CONFIG` from `ng-zorro-antd`) + +The weight of global configuration, component default value, component input value: + +component input value > global configuration > component default value + +supported global configuration item +```ts +{ + provide: NZ_MODAL_CONFIG, + useValue: { + nzMask?: boolean; // Whether show mask or not. + nzMaskClosable?: boolean; // Whether to close the modal dialog when the mask (area outside the modal) is clicked + } +} +``` +> Note: global configuration does not have default value which component has it. + #### ModalButtonOptions (used to customize the bottom button) An array of `ModalButtonOptions` type can be passed to `nzFooter` for custom bottom buttons. diff --git a/components/modal/doc/index.zh-CN.md b/components/modal/doc/index.zh-CN.md index d16cde4f425..26581b12272 100644 --- a/components/modal/doc/index.zh-CN.md +++ b/components/modal/doc/index.zh-CN.md @@ -120,6 +120,29 @@ constructor(modal: NzModalService) { | triggerOk() | 手动触发nzOnOk | | triggerCancel() | 手动触发nzOnCancel | + +### 全局配置 + +全局配置(NZ_MODAL_CONFIG) +如果要进行全局默认配置,你可以设置提供商 `NZ_MODAL_CONFIG` 的值来实现。 +(如:在你的模块的`providers`中加入 `{ provide: NZ_MODAL_CONFIG, useValue: { nzMask: false }}`,`NZ_MODAL_CONFIG` 可以从 `ng-zorro-antd` 中导入) + +全局配置,组件默认值,组件层级配置之间的权重如下: + +组件层级配置 > 全局配置 > 组件默认值 + +当前支持的全局配置 +```ts +{ + provide: NZ_MODAL_CONFIG, + useValue: { + nzMask?: boolean; // 是否展示遮罩 + nzMaskClosable?: boolean; // 点击蒙层是否允许关闭 + } +} +``` +注:全局配置并无默认值,因为nzMask和nzMaskClosable默认值存在于组件中 + #### ModalButtonOptions(用于自定义底部按钮) 可将此类型数组传入 `nzFooter`,用于自定义底部按钮。 From f8a0b0b7f997c10d80ab5f0071512a8bd2fdab44 Mon Sep 17 00:00:00 2001 From: kekehaoz Date: Wed, 27 Mar 2019 09:52:15 +0800 Subject: [PATCH 06/10] feat(module: modal): support global config --- components/modal/nz-modal.component.html | 2 +- components/modal/nz-modal.component.ts | 80 ++++++++++++++---------- components/modal/nz-modal.spec.ts | 29 +++++---- 3 files changed, 61 insertions(+), 50 deletions(-) diff --git a/components/modal/nz-modal.component.html b/components/modal/nz-modal.component.html index 2d12d419661..8f85e3e2616 100644 --- a/components/modal/nz-modal.component.html +++ b/components/modal/nz-modal.component.html @@ -1,7 +1,7 @@
-
extends NzModalRef @Input() nzIconType: string = 'question-circle'; // Confirm Modal ONLY @Input() nzModalType: ModalType = 'default'; - @Input() @InputBoolean() + @Input() + @InputBoolean() get nzMask(): boolean { - if (this.nzMaskDetect.dirty) { - return this.nzMaskDetect.value; - } else if (isNotNil(this.globalConfig) && isNotNil(this.globalConfig.nzMask)) { - return this.globalConfig.nzMask; - } else { - return true; - } + return this._nzMask; } set nzMask(value: boolean) { - this.nzMaskDetect.value = value; - this.nzMaskDetect.dirty = true; + this._nzMask = value; } - @Input() @InputBoolean() + @Input() + @InputBoolean() get nzMaskClosable(): boolean { - if (this.nzMaskClosableDetect.dirty) { - return this.nzMaskClosableDetect.value; - } else if (isNotNil(this.globalConfig) && isNotNil(this.globalConfig.nzMaskClosable)) { - return this.globalConfig.nzMaskClosable; - } else { - return true; - } + return this._nzMaskClosable; } set nzMaskClosable(value: boolean) { - this.nzMaskClosableDetect.value = value; - this.nzMaskClosableDetect.dirty = true; + this._nzMaskClosable = value; } @Input() @Output() readonly nzOnOk: EventEmitter | OnClickCallback = new EventEmitter(); @@ -145,6 +132,34 @@ export class NzModalComponent extends NzModalRef return !this.nzVisible && !this.animationState; } // Indicate whether this dialog should hidden + /** the calculated highest weight of mask value + * weight of mask: + * component default value < global configuration < component input value + */ + get mask(): boolean { + if (this.nzMask != null) { + return this.nzMask; + } else if (this.nzModalGlobalConfig && this.nzModalGlobalConfig.nzMask != null) { + return this.nzModalGlobalConfig.nzMask; + } else { + return true; + } + } + + /** the calculated highest weight of maskClosable value + * weight of maskClosable: + * component default value < global configuration < component input value + */ + get maskClosable(): boolean { + if (this.nzMaskClosable != null) { + return this.nzMaskClosable; + } else if (this.nzModalGlobalConfig && this.nzModalGlobalConfig.nzMaskClosable != null) { + return this.nzModalGlobalConfig.nzMaskClosable; + } else { + return true; + } + } + locale: { okText?: string; cancelText?: string } = {}; maskAnimationClassMap: object | null; modalAnimationClassMap: object | null; @@ -157,14 +172,9 @@ export class NzModalComponent extends NzModalRef private previouslyFocusedElement: HTMLElement; private focusTrap: FocusTrap; private scrollStrategy: BlockScrollStrategy; - private globalConfig: NzModalConfig; - private nzMaskDetect: { dirty: boolean, value?: boolean } = { - dirty: false - }; - - private nzMaskClosableDetect: { dirty: boolean, value?: boolean } = { - dirty: false - }; + private nzModalGlobalConfig: NzModalConfig; + private _nzMask: boolean; + private _nzMaskClosable: boolean; [key: string]: any; // tslint:disable-line:no-any @@ -177,11 +187,13 @@ export class NzModalComponent extends NzModalRef private modalControl: NzModalControlService, private focusTrapFactory: FocusTrapFactory, private cdr: ChangeDetectorRef, - @Optional() @Inject(NZ_MODAL_CONFIG) globalConfig: NzModalConfig, - @Inject(DOCUMENT) private document: any) { // tslint:disable-line:no-any + @Optional() @Inject(NZ_MODAL_CONFIG) nzModalGlobalConfig: NzModalConfig, + @Inject(DOCUMENT) private document: any + ) { + // tslint:disable-line:no-any super(); - this.globalConfig = globalConfig; + this.nzModalGlobalConfig = nzModalGlobalConfig; this.scrollStrategy = this.overlay.scrollStrategies.block(); } @@ -296,8 +308,8 @@ export class NzModalComponent extends NzModalRef onClickMask($event: MouseEvent): void { if ( - this.nzMask && - this.nzMaskClosable && + this.mask && + this.maskClosable && ($event.target as HTMLElement).classList.contains('ant-modal-wrap') && this.nzVisible ) { diff --git a/components/modal/nz-modal.spec.ts b/components/modal/nz-modal.spec.ts index 7165dbb85e5..e42d30d6634 100644 --- a/components/modal/nz-modal.spec.ts +++ b/components/modal/nz-modal.spec.ts @@ -377,27 +377,26 @@ describe('global config', () => { let nativeElement: HTMLElement; beforeEach(() => { TestBed.configureTestingModule({ - imports: [ NoopAnimationsModule, NzModalModule ], - providers: [{ - provide: NZ_MODAL_CONFIG, - useValue: { - nzMask: false, - nzMaskClosable: false + imports: [NoopAnimationsModule, NzModalModule], + providers: [ + { + provide: NZ_MODAL_CONFIG, + useValue: { + nzMask: false, + nzMaskClosable: false + } } - }], - declarations: [ - NzDemoModalBasicComponent, - NzDemoModalWithInputComponent - ] + ], + declarations: [NzDemoModalBasicComponent, NzDemoModalWithInputComponent] }).compileComponents(); basicFixture = TestBed.createComponent(NzDemoModalBasicComponent); inputFixture = TestBed.createComponent(NzDemoModalWithInputComponent); }); - it('nzMask be global config value', fakeAsync(() => { + it('nzMask should be global config value', fakeAsync(() => { const debugElement = basicFixture.debugElement.query(By.css('.ant-modal-mask')); basicFixture.detectChanges(); - expect(debugElement).toBe(null); + expect(debugElement).toBeNull(); })); it('nzMask should be input value', fakeAsync(() => { @@ -405,7 +404,7 @@ describe('global config', () => { inputFixture.detectChanges(); nativeElement = inputFixture.debugElement.query(By.css('.ant-modal-mask')).nativeElement; inputFixture.detectChanges(); - expect(nativeElement).not.toBe(null); + expect(nativeElement).not.toBeNull(); })); it('nzMaskClosable should be global config value', fakeAsync(() => { @@ -413,7 +412,7 @@ describe('global config', () => { inputFixture.detectChanges(); nativeElement = inputFixture.debugElement.query(By.css('.ant-modal-wrap')).nativeElement; inputFixture.detectChanges(); - nativeElement.click(); + nativeElement!.click(); inputFixture.detectChanges(); console.log(inputFixture.debugElement.nativeElement); expectModalHidden(inputFixture.debugElement.query(By.css('nz-modal')).nativeElement, true); From 533c1d7b8c026b575d62edbb1256d4c90e71472c Mon Sep 17 00:00:00 2001 From: kekehaoz Date: Wed, 27 Mar 2019 10:27:33 +0800 Subject: [PATCH 07/10] fix(module:modal): modify comment and tslint error --- components/modal/nz-modal.component.ts | 42 +++++++++----------------- 1 file changed, 14 insertions(+), 28 deletions(-) diff --git a/components/modal/nz-modal.component.ts b/components/modal/nz-modal.component.ts index d09502ac140..da45f563e55 100644 --- a/components/modal/nz-modal.component.ts +++ b/components/modal/nz-modal.component.ts @@ -61,6 +61,8 @@ export class NzModalComponent extends NzModalRef @Input() @InputBoolean() nzCancelLoading: boolean = false; @Input() @InputBoolean() nzKeyboard: boolean = true; @Input() @InputBoolean() nzNoAnimation = false; + @Input() @InputBoolean() nzMask: boolean; + @Input() @InputBoolean() nzMaskClosable: boolean; @Input() nzContent: string | TemplateRef<{}> | Type; // [STATIC] If not specified, will use @Input() nzComponentParams: T; // [STATIC] ONLY avaliable when nzContent is a component @Input() nzFooter: string | TemplateRef<{}> | Array>; // [STATIC] Default Modal ONLY @@ -79,26 +81,6 @@ export class NzModalComponent extends NzModalRef @Input() nzIconType: string = 'question-circle'; // Confirm Modal ONLY @Input() nzModalType: ModalType = 'default'; - @Input() - @InputBoolean() - get nzMask(): boolean { - return this._nzMask; - } - - set nzMask(value: boolean) { - this._nzMask = value; - } - - @Input() - @InputBoolean() - get nzMaskClosable(): boolean { - return this._nzMaskClosable; - } - - set nzMaskClosable(value: boolean) { - this._nzMaskClosable = value; - } - @Input() @Output() readonly nzOnOk: EventEmitter | OnClickCallback = new EventEmitter(); @Input() @Output() readonly nzOnCancel: EventEmitter | OnClickCallback = new EventEmitter(); @@ -132,9 +114,12 @@ export class NzModalComponent extends NzModalRef return !this.nzVisible && !this.animationState; } // Indicate whether this dialog should hidden - /** the calculated highest weight of mask value - * weight of mask: - * component default value < global configuration < component input value + /** + * @description + * The calculated highest weight of mask value + * + * Weight of different mask input: + * component default value < global configuration < component input value */ get mask(): boolean { if (this.nzMask != null) { @@ -146,8 +131,11 @@ export class NzModalComponent extends NzModalRef } } - /** the calculated highest weight of maskClosable value - * weight of maskClosable: + /** + * @description + * The calculated highest weight of maskClosable value + * + * Weight of different maskClosable input: * component default value < global configuration < component input value */ get maskClosable(): boolean { @@ -173,8 +161,6 @@ export class NzModalComponent extends NzModalRef private focusTrap: FocusTrap; private scrollStrategy: BlockScrollStrategy; private nzModalGlobalConfig: NzModalConfig; - private _nzMask: boolean; - private _nzMaskClosable: boolean; [key: string]: any; // tslint:disable-line:no-any @@ -188,7 +174,7 @@ export class NzModalComponent extends NzModalRef private focusTrapFactory: FocusTrapFactory, private cdr: ChangeDetectorRef, @Optional() @Inject(NZ_MODAL_CONFIG) nzModalGlobalConfig: NzModalConfig, - @Inject(DOCUMENT) private document: any + @Inject(DOCUMENT) private document: Document ) { // tslint:disable-line:no-any From 36910ac941b4e41c16153c3c25878808612ffe3c Mon Sep 17 00:00:00 2001 From: kekehaoz Date: Thu, 28 Mar 2019 20:27:24 +0800 Subject: [PATCH 08/10] fix(module:modal): fix build error --- components/modal/nz-modal.component.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/components/modal/nz-modal.component.ts b/components/modal/nz-modal.component.ts index bc6c64e2314..54ad1289d5d 100644 --- a/components/modal/nz-modal.component.ts +++ b/components/modal/nz-modal.component.ts @@ -174,10 +174,8 @@ export class NzModalComponent extends NzModalRef private focusTrapFactory: FocusTrapFactory, private cdr: ChangeDetectorRef, @Optional() @Inject(NZ_MODAL_CONFIG) nzModalGlobalConfig: NzModalConfig, - @Inject(DOCUMENT) private document: Document + @Inject(DOCUMENT) private document: any // tslint:disable-line:no-any ) { - // tslint:disable-line:no-any - super(); this.nzModalGlobalConfig = nzModalGlobalConfig; this.scrollStrategy = this.overlay.scrollStrategies.block(); From a17a2449ba8d1d16ebb1e2e9f67e4b4d0c59c7ab Mon Sep 17 00:00:00 2001 From: kekehaoz Date: Tue, 2 Apr 2019 18:50:32 +0800 Subject: [PATCH 09/10] fix(module:modal): format comment --- components/modal/nz-modal.component.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/components/modal/nz-modal.component.ts b/components/modal/nz-modal.component.ts index 54ad1289d5d..de98fb6a196 100644 --- a/components/modal/nz-modal.component.ts +++ b/components/modal/nz-modal.component.ts @@ -118,8 +118,8 @@ export class NzModalComponent extends NzModalRef * @description * The calculated highest weight of mask value * - * Weight of different mask input: - * component default value < global configuration < component input value + * Weight of different mask input: + * component default value < global configuration < component input value */ get mask(): boolean { if (this.nzMask != null) { @@ -135,8 +135,8 @@ export class NzModalComponent extends NzModalRef * @description * The calculated highest weight of maskClosable value * - * Weight of different maskClosable input: - * component default value < global configuration < component input value + * Weight of different maskClosable input: + * component default value < global configuration < component input value */ get maskClosable(): boolean { if (this.nzMaskClosable != null) { From 86858f1326fa4fd8d2c50292689bb3405ec9a159 Mon Sep 17 00:00:00 2001 From: kekehaoz Date: Wed, 3 Apr 2019 12:02:36 +0800 Subject: [PATCH 10/10] refactor(module:modal): delete extra private property --- components/modal/nz-modal.component.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/components/modal/nz-modal.component.ts b/components/modal/nz-modal.component.ts index de98fb6a196..b8f63e40a66 100644 --- a/components/modal/nz-modal.component.ts +++ b/components/modal/nz-modal.component.ts @@ -160,7 +160,6 @@ export class NzModalComponent extends NzModalRef private previouslyFocusedElement: HTMLElement; private focusTrap: FocusTrap; private scrollStrategy: BlockScrollStrategy; - private nzModalGlobalConfig: NzModalConfig; [key: string]: any; // tslint:disable-line:no-any @@ -173,11 +172,10 @@ export class NzModalComponent extends NzModalRef private modalControl: NzModalControlService, private focusTrapFactory: FocusTrapFactory, private cdr: ChangeDetectorRef, - @Optional() @Inject(NZ_MODAL_CONFIG) nzModalGlobalConfig: NzModalConfig, + @Optional() @Inject(NZ_MODAL_CONFIG) private nzModalGlobalConfig: NzModalConfig, @Inject(DOCUMENT) private document: any // tslint:disable-line:no-any ) { super(); - this.nzModalGlobalConfig = nzModalGlobalConfig; this.scrollStrategy = this.overlay.scrollStrategies.block(); }