From 8b1d285ff4c87abf8295c345f1bde885a4309bc5 Mon Sep 17 00:00:00 2001 From: George Kalampokis Date: Wed, 29 Jan 2020 18:28:46 +0200 Subject: [PATCH] Replace the DMP creator with the user roles on the User's profile (ref #224) --- .../src/app/ui/user-profile/user-profile.component.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/dmp-frontend/src/app/ui/user-profile/user-profile.component.ts b/dmp-frontend/src/app/ui/user-profile/user-profile.component.ts index 00fd630a8..de33e2857 100644 --- a/dmp-frontend/src/app/ui/user-profile/user-profile.component.ts +++ b/dmp-frontend/src/app/ui/user-profile/user-profile.component.ts @@ -77,7 +77,13 @@ export class UserProfileComponent extends BaseComponent implements OnInit, OnDes } getUserRole(dmp: DmpModel) { - if (dmp.creator.id === this.currentUserId) { return this.language.instant('USER-PROFILE.DMPS.CREATOR'); } else if (dmp.associatedUsers.map(x => x.id).indexOf(this.currentUserId) !== -1) { return this.language.instant('USER-PROFILE.DMPS.MEMBER'); } + let role = -1; + dmp.users.forEach(user => { + if (user.id === this.currentUserId) { + role = user.role; + } + }); + if (role === 0) { return this.language.instant('USER-PROFILE.DMPS.CREATOR'); } else if (role === 1) { return this.language.instant('USER-PROFILE.DMPS.MEMBER'); } return ''; }