Skip to content

Commit bc7a5d4

Browse files
Adopted isEnabled property
1 parent ee80c30 commit bc7a5d4

File tree

2 files changed

+6
-29
lines changed

2 files changed

+6
-29
lines changed

frontend/src/app/common/services/user-data.service.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export class UserDataService {
3838
userIdentityId: number,
3939
representedByOrganizationId: string,
4040
roleCds: Array<string>,
41+
isEnabled: boolean,
4142
updDtm: string
4243
}): Observable<any> {
4344
return this.httpClient.put<UserDetails>(`${environment.API_HOST}/users/${data.userIdentityId}`, data)

frontend/src/app/features/components/user-management/user-details/user-details.component.ts

Lines changed: 5 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,12 @@ export class UserDetailsComponent implements OnInit {
5959

6060
ngOnInit(): void {
6161
this.id = Number(this.route.snapshot.params['id']);
62-
console.log(this.id);
6362

6463
if (isNaN(this.id)) {
6564
this.errorService.showError('Invalid User ID: User ID must consist of numbers only.');
6665
this.router.navigate(['/user-management']);
6766
}
6867

69-
this.loaderService.loadingStart();
70-
7168
this.init();
7269
}
7370

@@ -85,41 +82,18 @@ export class UserDetailsComponent implements OnInit {
8582
}
8683

8784
onSave(): void {
88-
// TODO: this part needs to be reconsidered. Either use concatMap or do everything in one API call (backend involvement required);
8985
this.userService.updateUser({
9086
roleCds: this.user.roleCds,
9187
updDtm: this.user.updDtm,
9288
userIdentityId: this.user.userIdentityId,
89+
isEnabled: this.state === 'Active',
9390
representedByOrganizationId: this.selectedOrg
9491
}).subscribe({
9592
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;
12095
},
12196
complete: () => {
122-
12397
this.loaderService.loadingEnd();
12498
this.cd.detectChanges();
12599
}
@@ -139,6 +113,8 @@ export class UserDetailsComponent implements OnInit {
139113
}
140114

141115
private init(): void {
116+
this.loaderService.loadingStart();
117+
142118
forkJoin([
143119
this.userService.getUserById(this.id),
144120
this.rolesService.getRoles(),

0 commit comments

Comments
 (0)