@@ -2,13 +2,9 @@ import {
22 ChangeDetectionStrategy ,
33 ChangeDetectorRef ,
44 Component ,
5- EventEmitter ,
6- Input ,
7- Output ,
8- ViewChild
5+ Input , OnInit ,
96} from '@angular/core' ;
107import { TranslateService } from '@ngx-translate/core' ;
11- import { ModalTemplate , SuiActiveModal , SuiModalService , TemplateModalConfig } from '@richardlt/ng2-semantic-ui' ;
128import { AuthConsumer , AuthConsumerScopeDetail } from 'app/model/authentication.model' ;
139import { Group } from 'app/model/group.model' ;
1410import { AuthentifiedUser } from 'app/model/user.model' ;
@@ -18,6 +14,7 @@ import { UserService } from 'app/service/user/user.service';
1814import { Column , Select } from 'app/shared/table/data-table.component' ;
1915import { ToastService } from 'app/shared/toast/ToastService' ;
2016import { finalize } from 'rxjs/operators' ;
17+ import { NzModalRef } from 'ng-zorro-antd/modal' ;
2118
2219export enum CloseEventType {
2320 CREATED = 'CREATED' ,
@@ -38,13 +35,9 @@ export enum FormStepName {
3835 styleUrls : [ './consumer-create-modal.scss' ] ,
3936 changeDetection : ChangeDetectionStrategy . OnPush
4037} )
41- export class ConsumerCreateModalComponent {
42- @ViewChild ( 'consumerCreateModal' ) consumerDetailsModal : ModalTemplate < boolean , boolean , void > ;
43- modal : SuiActiveModal < boolean , boolean , void > ;
44- open : boolean ;
38+ export class ConsumerCreateModalComponent implements OnInit {
4539
4640 @Input ( ) user : AuthentifiedUser ;
47- @Output ( ) close = new EventEmitter < CloseEventType > ( ) ;
4841
4942 newConsumer : AuthConsumer = new AuthConsumer ( ) ;
5043 signinToken : string ;
@@ -62,7 +55,7 @@ export class ConsumerCreateModalComponent {
6255 maxActivedStep : FormStepName ;
6356
6457 constructor (
65- private _modalService : SuiModalService ,
58+ private _modal : NzModalRef ,
6659 private _userService : UserService ,
6760 private _groupService : GroupService ,
6861 private _authenticationService : AuthenticationService ,
@@ -79,36 +72,15 @@ export class ConsumerCreateModalComponent {
7972 ] ;
8073 }
8174
82- show ( ) {
83- if ( this . open ) {
84- return ;
85- }
86-
87- this . open = true ;
88-
89- const config = new TemplateModalConfig < boolean , boolean , void > ( this . consumerDetailsModal ) ;
90- config . mustScroll = true ;
91- this . modal = this . _modalService . open ( config ) ;
92- this . modal . onApprove ( _ => {
93- this . closeCallback ( ) ;
94- } ) ;
95- this . modal . onDeny ( _ => {
96- this . closeCallback ( ) ;
97- } ) ;
98-
99- this . init ( ) ;
100- }
101-
10275 closeCallback ( ) : void {
103- this . open = false ;
10476 if ( this . newConsumer . id ) {
105- this . close . emit ( CloseEventType . CREATED ) ;
77+ this . _modal . triggerOk ( ) ;
10678 } else {
107- this . close . emit ( CloseEventType . CLOSED ) ;
79+ this . _modal . triggerCancel ( ) ;
10880 }
10981 }
11082
111- init ( ) : void {
83+ ngOnInit ( ) : void {
11284 this . newConsumer = new AuthConsumer ( ) ;
11385 this . signinToken = null ;
11486 this . selectedGroupKeys = null ;
@@ -257,8 +229,4 @@ export class ConsumerCreateModalComponent {
257229 }
258230 this . selectedScopeDetails . push ( detail ) ;
259231 }
260-
261- clickClose ( ) {
262- this . modal . approve ( true ) ;
263- }
264232}
0 commit comments