-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(module: popconfirm): support async close (#7533)
Co-authored-by: luolei <luolei@kuaishou.com>
- Loading branch information
Showing
8 changed files
with
219 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
--- | ||
order: 6 | ||
title: | ||
zh-CN: 异步关闭 | ||
en-US: Asynchronously close | ||
--- | ||
|
||
## zh-CN | ||
|
||
点击确定后异步关闭 Popconfirm,例如提交表单。 | ||
|
||
## en-US | ||
|
||
Asynchronously close a popconfirm when a the OK button is pressed. For example, you can use this pattern when you submit a form. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { Component } from '@angular/core'; | ||
import { Observable } from 'rxjs'; | ||
|
||
import { NzMessageService } from 'ng-zorro-antd/message'; | ||
|
||
@Component({ | ||
selector: 'nz-demo-popconfirm-async', | ||
template: ` | ||
<button | ||
nz-popconfirm | ||
nzPopconfirmTitle="Title" | ||
[nzBeforeConfirm]="beforeConfirm" | ||
(nzOnConfirm)="confirm()" | ||
(nzOnCancel)="cancel()" | ||
nz-button | ||
nzType="primary" | ||
> | ||
Open Popconfirm with async logic | ||
</button> | ||
` | ||
}) | ||
export class NzDemoPopconfirmAsyncComponent { | ||
cancel(): void { | ||
this.nzMessageService.info('click cancel'); | ||
} | ||
|
||
confirm(): void { | ||
this.nzMessageService.info('click confirm'); | ||
} | ||
|
||
beforeConfirm(): Observable<boolean> { | ||
return new Observable(observer => { | ||
setTimeout(() => { | ||
observer.next(true); | ||
observer.complete(); | ||
}, 3000); | ||
}); | ||
} | ||
|
||
constructor(private nzMessageService: NzMessageService) {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
--- | ||
order: 7 | ||
title: | ||
zh-CN: 基于 Promise 的异步关闭 | ||
en-US: Asynchronously close on Promise | ||
--- | ||
|
||
## zh-CN | ||
|
||
点击确定后异步关闭 Popconfirm,例如提交表单。 | ||
|
||
## en-US | ||
|
||
Asynchronously close a popconfirm when the OK button is pressed. For example, you can use this pattern when you submit a form. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { Component } from '@angular/core'; | ||
|
||
import { NzMessageService } from 'ng-zorro-antd/message'; | ||
|
||
@Component({ | ||
selector: 'nz-demo-popconfirm-promise', | ||
template: ` | ||
<button | ||
nz-popconfirm | ||
nzPopconfirmTitle="Title" | ||
[nzBeforeConfirm]="beforeConfirm" | ||
(nzOnConfirm)="confirm()" | ||
(nzOnCancel)="cancel()" | ||
nz-button | ||
nzType="primary" | ||
> | ||
Open Popconfirm with Promise | ||
</button> | ||
` | ||
}) | ||
export class NzDemoPopconfirmPromiseComponent { | ||
cancel(): void { | ||
this.nzMessageService.info('click cancel'); | ||
} | ||
|
||
confirm(): void { | ||
this.nzMessageService.info('click confirm'); | ||
} | ||
|
||
beforeConfirm(): Promise<boolean> { | ||
return new Promise(resolve => { | ||
setTimeout(() => { | ||
resolve(true); | ||
}, 3000); | ||
}); | ||
} | ||
|
||
constructor(private nzMessageService: NzMessageService) {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters