File tree Expand file tree Collapse file tree 1 file changed +22
-8
lines changed Expand file tree Collapse file tree 1 file changed +22
-8
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ import {
14
14
CreateRoleDto
15
15
} from '@shared/service-proxies/service-proxies' ;
16
16
import { AppComponentBase } from '@shared/app-component-base' ;
17
+ import { finalize } from 'rxjs/operators' ;
17
18
18
19
@Component ( {
19
20
templateUrl : 'create-or-edit-role-dialog.component.html' ,
@@ -36,6 +37,7 @@ export class CreateOrEditRoleDialogComponent extends AppComponentBase
36
37
checkedPermissionsMap : { [ key : string ] : boolean } = { } ;
37
38
defaultPermissionCheckedStatus = true ;
38
39
permissionName = '' ;
40
+ saving = false ;
39
41
40
42
constructor (
41
43
injector : Injector ,
@@ -105,22 +107,34 @@ export class CreateOrEditRoleDialogComponent extends AppComponentBase
105
107
}
106
108
107
109
save ( ) : void {
110
+ this . saving = true ;
111
+
108
112
const role = new RoleDto ( ) ;
109
113
role . permissions = this . getCheckedPermissions ( ) ;
110
114
role . init ( this . role ) ;
111
115
112
116
if ( this . isCreateDialog ( ) ) {
113
117
const createRole = new CreateRoleDto ( ) ;
114
118
createRole . init ( role ) ;
115
- this . _roleService . create ( createRole ) . subscribe ( ( ) => {
116
- this . notify . info ( this . l ( 'SavedSuccessfully' ) ) ;
117
- this . close ( true ) ;
118
- } ) ;
119
+ this . _roleService . create ( createRole )
120
+ . pipe (
121
+ finalize ( ( ) => {
122
+ this . saving = false ;
123
+ } )
124
+ ) . subscribe ( ( ) => {
125
+ this . notify . info ( this . l ( 'SavedSuccessfully' ) ) ;
126
+ this . close ( true ) ;
127
+ } ) ;
119
128
} else {
120
- this . _roleService . update ( role ) . subscribe ( ( ) => {
121
- this . notify . info ( this . l ( 'SavedSuccessfully' ) ) ;
122
- this . close ( true ) ;
123
- } ) ;
129
+ this . _roleService . update ( role )
130
+ . pipe (
131
+ finalize ( ( ) => {
132
+ this . saving = false ;
133
+ } )
134
+ ) . subscribe ( ( ) => {
135
+ this . notify . info ( this . l ( 'SavedSuccessfully' ) ) ;
136
+ this . close ( true ) ;
137
+ } ) ;
124
138
}
125
139
}
126
140
You can’t perform that action at this time.
0 commit comments