Skip to content

Commit

Permalink
fix(module:popconfirm): add nzOkType support (#1492)
Browse files Browse the repository at this point in the history
close #1312
  • Loading branch information
wilsoncook authored and vthinkxie committed May 22, 2018
1 parent 1b8c0fe commit 6f394a4
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion components/popconfirm/nz-popconfirm.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<ng-container *ngIf="nzCancelText">{{ nzCancelText }}</ng-container>
<ng-container *ngIf="!nzCancelText">{{ 'Modal.cancelText' | nzI18n }}</ng-container>
</button>
<button nz-button [nzSize]="'small'" [nzType]="'primary'" (click)="onConfirm()">
<button nz-button [nzSize]="'small'" [nzType]="nzOkType" (click)="onConfirm()">
<ng-container *ngIf="nzOkText">{{ nzOkText }}</ng-container>
<ng-container *ngIf="!nzOkText">{{ 'Modal.okText' | nzI18n }}</ng-container>
</button>
Expand Down
1 change: 1 addition & 0 deletions components/popconfirm/nz-popconfirm.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export class NzPopconfirmComponent extends NzToolTipComponent {
_hasBackdrop = true;
@Input() nzContent;
@Input() nzOkText: string;
@Input() nzOkType: string = 'primary';
@Input() nzCancelText: string;

@Input()
Expand Down
16 changes: 15 additions & 1 deletion components/popconfirm/nz-popconfirm.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,18 @@ describe('NzPopconfirm', () => {
expect(overlayContainerElement.textContent).not.toContain(featureKey);
}));

it('should support nzOkType', fakeAsync(() => {
demoAppComponent.nzOkType = 'danger';
const triggerElement = demoAppComponent.normalTrigger.nativeElement;

dispatchMouseEvent(triggerElement, 'mouseenter');
demoAppFixture.detectChanges();
tick(150); // wait for the default 100ms delay
demoAppFixture.detectChanges();
tick();
expect(!!overlayContainerElement.querySelector('button.ant-btn-danger')).toBeTruthy();
}));

it('should show tooltip with custom template', fakeAsync(() => {
const triggerElement = demoAppComponent.templateTrigger.nativeElement;

Expand Down Expand Up @@ -144,7 +156,7 @@ describe('NzPopconfirm', () => {
@Component({
selector: 'nz-demo-app',
template: `
<nz-popconfirm [nzTitle]="'NORMAL'" [nzTrigger]="'hover'"><span #normalTrigger nz-popconfirm>Show</span></nz-popconfirm>
<nz-popconfirm [nzOkType]="nzOkType" [nzTitle]="'NORMAL'" [nzTrigger]="'hover'"><span #normalTrigger nz-popconfirm>Show</span></nz-popconfirm>
<nz-popconfirm [nzTrigger]="'hover'">
<button #templateTrigger nz-popconfirm>Show</button>
Expand All @@ -163,6 +175,8 @@ describe('NzPopconfirm', () => {
`
})
export class DemoAppComponent {
nzOkType = 'primary';

@ViewChild('normalTrigger') normalTrigger: ElementRef;

@ViewChild('templateTrigger') templateTrigger: ElementRef;
Expand Down

0 comments on commit 6f394a4

Please sign in to comment.