diff --git a/apps/red-ui/src/app/modules/admin/dialogs/add-edit-user-dialog/reset-password/reset-password.component.html b/apps/red-ui/src/app/modules/admin/dialogs/add-edit-user-dialog/reset-password/reset-password.component.html index 1cfcc107f..f16527517 100644 --- a/apps/red-ui/src/app/modules/admin/dialogs/add-edit-user-dialog/reset-password/reset-password.component.html +++ b/apps/red-ui/src/app/modules/admin/dialogs/add-edit-user-dialog/reset-password/reset-password.component.html @@ -1,4 +1,4 @@ -
+
diff --git a/apps/red-ui/src/app/modules/admin/dialogs/add-edit-user-dialog/reset-password/reset-password.component.ts b/apps/red-ui/src/app/modules/admin/dialogs/add-edit-user-dialog/reset-password/reset-password.component.ts index 34881d642..7dfb3d7b3 100644 --- a/apps/red-ui/src/app/modules/admin/dialogs/add-edit-user-dialog/reset-password/reset-password.component.ts +++ b/apps/red-ui/src/app/modules/admin/dialogs/add-edit-user-dialog/reset-password/reset-password.component.ts @@ -23,10 +23,6 @@ export class ResetPasswordComponent { private readonly _loadingService: LoadingService ) {} - get userName() { - return this._userService.getNameForId(this.user.id); - } - async save() { this._loadingService.start(); await this._userControllerService diff --git a/apps/red-ui/src/app/modules/dossier/components/comments/comments.component.html b/apps/red-ui/src/app/modules/dossier/components/comments/comments.component.html index f41430b73..e284ee1c3 100644 --- a/apps/red-ui/src/app/modules/dossier/components/comments/comments.component.html +++ b/apps/red-ui/src/app/modules/dossier/components/comments/comments.component.html @@ -1,9 +1,10 @@
- {{ getOwnerName(comment) }} + {{ comment.user | name }} {{ comment.date | date: 'sophisticatedDate' }}
+
+
{{ comment.text }}
diff --git a/apps/red-ui/src/app/modules/dossier/components/comments/comments.component.ts b/apps/red-ui/src/app/modules/dossier/components/comments/comments.component.ts index e5fbd8e13..40537f464 100644 --- a/apps/red-ui/src/app/modules/dossier/components/comments/comments.component.ts +++ b/apps/red-ui/src/app/modules/dossier/components/comments/comments.component.ts @@ -52,8 +52,4 @@ export class CommentsComponent { } }); } - - getOwnerName(comment: Comment): string { - return this._userService.getNameForId(comment.user); - } } diff --git a/apps/red-ui/src/app/modules/dossier/components/team-members-manager/team-members-manager.component.html b/apps/red-ui/src/app/modules/dossier/components/team-members-manager/team-members-manager.component.html index 6885e0382..6802347a2 100644 --- a/apps/red-ui/src/app/modules/dossier/components/team-members-manager/team-members-manager.component.html +++ b/apps/red-ui/src/app/modules/dossier/components/team-members-manager/team-members-manager.component.html @@ -4,7 +4,7 @@ {{ 'assign-dossier-owner.dialog.single-user' | translate }} - {{ userService.getNameForId(userId) }} + {{ userId | name }} diff --git a/apps/red-ui/src/app/modules/dossier/dialogs/assign-reviewer-approver-dialog/assign-reviewer-approver-dialog.component.html b/apps/red-ui/src/app/modules/dossier/dialogs/assign-reviewer-approver-dialog/assign-reviewer-approver-dialog.component.html index ad948d812..1dd48e2e6 100644 --- a/apps/red-ui/src/app/modules/dossier/dialogs/assign-reviewer-approver-dialog/assign-reviewer-approver-dialog.component.html +++ b/apps/red-ui/src/app/modules/dossier/dialogs/assign-reviewer-approver-dialog/assign-reviewer-approver-dialog.component.html @@ -14,7 +14,7 @@ {{ 'assign-owner.dialog.label' | translate: { type: data.mode } }} - {{ userService.getNameForId(userId) }} + {{ userId | name }} diff --git a/apps/red-ui/src/app/modules/shared/pipes/name.pipe.ts b/apps/red-ui/src/app/modules/shared/pipes/name.pipe.ts new file mode 100644 index 000000000..b95d4e83c --- /dev/null +++ b/apps/red-ui/src/app/modules/shared/pipes/name.pipe.ts @@ -0,0 +1,17 @@ +import { Pipe, PipeTransform } from '@angular/core'; +import { UserService, UserWrapper } from '@services/user.service'; +import { TranslateService } from '@ngx-translate/core'; + +@Pipe({ + name: 'name' +}) +export class NamePipe implements PipeTransform { + constructor(private readonly _userService: UserService, private readonly _translateService: TranslateService) {} + + transform(value: UserWrapper | string): string { + if (typeof value === 'string') { + return this._userService.getNameForId(value) || this._translateService.instant('unknown'); + } + return value.name; + } +} diff --git a/apps/red-ui/src/app/modules/shared/shared.module.ts b/apps/red-ui/src/app/modules/shared/shared.module.ts index 381b6d0bb..06178f8be 100644 --- a/apps/red-ui/src/app/modules/shared/shared.module.ts +++ b/apps/red-ui/src/app/modules/shared/shared.module.ts @@ -25,6 +25,7 @@ import { AssignUserDropdownComponent } from './components/assign-user-dropdown/a import { PageHeaderComponent } from './components/page-header/page-header.component'; import { DatePipe } from '@shared/pipes/date.pipe'; import { LongPressDirective } from '@shared/directives/long-press.directive'; +import { NamePipe } from '@shared/pipes/name.pipe'; const buttons = [FileDownloadBtnComponent, UserButtonComponent]; @@ -45,7 +46,7 @@ const components = [ ...buttons ]; -const utils = [DatePipe, NavigateLastDossiersScreenDirective, LongPressDirective]; +const utils = [DatePipe, NamePipe, NavigateLastDossiersScreenDirective, LongPressDirective]; const modules = [MatConfigModule, ScrollingModule, IconsModule, FormsModule, ReactiveFormsModule, CommonUiModule]; @@ -68,4 +69,5 @@ const modules = [MatConfigModule, ScrollingModule, IconsModule, FormsModule, Rea } ] }) -export class SharedModule {} +export class SharedModule { +} diff --git a/apps/red-ui/src/app/services/user.service.ts b/apps/red-ui/src/app/services/user.service.ts index f0eeaf28f..a7b86c994 100644 --- a/apps/red-ui/src/app/services/user.service.ts +++ b/apps/red-ui/src/app/services/user.service.ts @@ -106,8 +106,7 @@ export class UserService { } getNameForId(userId: string): string | undefined { - const user = this.getUserById(userId); - return user ? user.name : undefined; + return this.getUserById(userId)?.name; } isManager(user: UserWrapper = this._currentUser): boolean {