@@ -59,15 +59,12 @@ export class UserDetailsComponent implements OnInit {
59
59
60
60
ngOnInit ( ) : void {
61
61
this . id = Number ( this . route . snapshot . params [ 'id' ] ) ;
62
- console . log ( this . id ) ;
63
62
64
63
if ( isNaN ( this . id ) ) {
65
64
this . errorService . showError ( 'Invalid User ID: User ID must consist of numbers only.' ) ;
66
65
this . router . navigate ( [ '/user-management' ] ) ;
67
66
}
68
67
69
- this . loaderService . loadingStart ( ) ;
70
-
71
68
this . init ( ) ;
72
69
}
73
70
@@ -85,41 +82,18 @@ export class UserDetailsComponent implements OnInit {
85
82
}
86
83
87
84
onSave ( ) : void {
88
- // TODO: this part needs to be reconsidered. Either use concatMap or do everything in one API call (backend involvement required);
89
85
this . userService . updateUser ( {
90
86
roleCds : this . user . roleCds ,
91
87
updDtm : this . user . updDtm ,
92
88
userIdentityId : this . user . userIdentityId ,
89
+ isEnabled : this . state === 'Active' ,
93
90
representedByOrganizationId : this . selectedOrg
94
91
} ) . subscribe ( {
95
92
next : ( _ ) => {
96
-
97
- if ( ( this . user . isEnabled && this . state === 'Disabled' ) || ( ! this . user . isEnabled && this . state === 'Active' ) ) {
98
- this . loaderService . loadingStart ( ) ;
99
-
100
- this . userService . getUserById ( this . id ) . subscribe ( {
101
- next : ( user ) => {
102
- this . loaderService . loadingStart ( ) ;
103
-
104
- this . userService . updateIsEnabled ( this . user . userIdentityId , this . state === 'Active' , user . updDtm ) . subscribe ( {
105
- next : ( ) => {
106
- this . init ( ) ;
107
- } , complete : ( ) => {
108
- this . loaderService . loadingEnd ( ) ;
109
- }
110
- } ) ;
111
-
112
- } , complete : ( ) => {
113
- this . loaderService . loadingEnd ( ) ;
114
- }
115
- } ) ;
116
- }
117
-
118
- this . onCancel ( ) ;
119
- this . errorService . showSuccess ( 'User has been successfully updated' ) ;
93
+ this . init ( ) ;
94
+ this . isEdit = false ;
120
95
} ,
121
96
complete : ( ) => {
122
-
123
97
this . loaderService . loadingEnd ( ) ;
124
98
this . cd . detectChanges ( ) ;
125
99
}
@@ -139,6 +113,8 @@ export class UserDetailsComponent implements OnInit {
139
113
}
140
114
141
115
private init ( ) : void {
116
+ this . loaderService . loadingStart ( ) ;
117
+
142
118
forkJoin ( [
143
119
this . userService . getUserById ( this . id ) ,
144
120
this . rolesService . getRoles ( ) ,
0 commit comments