diff --git a/alfa-client/libs/user-profile/src/lib/user-profile-in-vorgang-container/user-profile-in-vorgang/user-profile-button-container/user-profile-button-container.component.html b/alfa-client/libs/user-profile/src/lib/user-profile-in-vorgang-container/user-profile-in-vorgang/user-profile-button-container/user-profile-button-container.component.html index 5fa5cdf3ab2ef420c6aba8fdafb9fe6b64f8dd17..f455cb99443c2e6a9be7146de5e4ed7e15022704 100644 --- a/alfa-client/libs/user-profile/src/lib/user-profile-in-vorgang-container/user-profile-in-vorgang/user-profile-button-container/user-profile-button-container.component.html +++ b/alfa-client/libs/user-profile/src/lib/user-profile-in-vorgang-container/user-profile-in-vorgang/user-profile-button-container/user-profile-button-container.component.html @@ -28,7 +28,7 @@ [matMenuTriggerFor]="menu.matMenu" (menuOpened)="showUserProfileSearch()" (menuClosed)="hideUserProfileSearch()" - aria-label="Bearbeiter ändern" + [attr.aria-label]="userButtonLabel" class="user-profile-button" > <alfa-user-icon diff --git a/alfa-client/libs/user-profile/src/lib/user-profile-in-vorgang-container/user-profile-in-vorgang/user-profile-button-container/user-profile-button-container.component.spec.ts b/alfa-client/libs/user-profile/src/lib/user-profile-in-vorgang-container/user-profile-in-vorgang/user-profile-button-container/user-profile-button-container.component.spec.ts index 4464f2f109503b0424b404266a04c7bd80bee70b..6c12e1395e939a926ad075df0c40159f9ae04cb4 100644 --- a/alfa-client/libs/user-profile/src/lib/user-profile-in-vorgang-container/user-profile-in-vorgang/user-profile-button-container/user-profile-button-container.component.spec.ts +++ b/alfa-client/libs/user-profile/src/lib/user-profile-in-vorgang-container/user-profile-in-vorgang/user-profile-button-container/user-profile-button-container.component.spec.ts @@ -21,10 +21,11 @@ * Die sprachspezifischen Genehmigungen und Beschränkungen * unter der Lizenz sind dem Lizenztext zu entnehmen. */ -import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { createEmptyStateResource, StateResource } from '@alfa-client/tech-shared'; import { mock } from '@alfa-client/test-utils'; import { OzgcloudMenuComponent, UiModule } from '@alfa-client/ui'; -import { UserProfileService } from '@alfa-client/user-profile-shared'; +import { UserProfileResource, UserProfileService } from '@alfa-client/user-profile-shared'; +import { ComponentFixture, TestBed } from '@angular/core/testing'; import { MockComponent } from 'ng-mocks'; import { BehaviorSubject } from 'rxjs'; import { UserIconComponent } from '../../../user-icon/user-icon.component'; @@ -114,4 +115,31 @@ describe('UserProfileButtonContainerComponent', () => { expect(userProfileService.hideUserProfileSearch).toHaveBeenCalled(); }); }); + + describe('getUserButtonLabel', () => { + it('should return label', () => { + component.userProfile = createEmptyStateResource(); + + const result = component.getUserButtonLabel(); + + expect(result).toBe('Bearbeiter ändern. Aktueller Bearbeiter: Unbekannter Benutzer'); + }); + }); + + describe('set userProfile', () => { + const userProfileStateResource: StateResource<UserProfileResource> = createEmptyStateResource(); + it('should set userProfile', () => { + component.userProfile = userProfileStateResource; + + expect(component.userProfile).toBe(userProfileStateResource); + }); + + it('should get label for user button', () => { + component.getUserButtonLabel = jest.fn(); + + component.userProfile = userProfileStateResource; + + expect(component.getUserButtonLabel).toHaveBeenCalled(); + }); + }); }); diff --git a/alfa-client/libs/user-profile/src/lib/user-profile-in-vorgang-container/user-profile-in-vorgang/user-profile-button-container/user-profile-button-container.component.ts b/alfa-client/libs/user-profile/src/lib/user-profile-in-vorgang-container/user-profile-in-vorgang/user-profile-button-container/user-profile-button-container.component.ts index 1c7451882382e8bdd72e1b6a66b44c48a3b1dc01..e559f74639d522733a7506a840c689091f6460fe 100644 --- a/alfa-client/libs/user-profile/src/lib/user-profile-in-vorgang-container/user-profile-in-vorgang/user-profile-button-container/user-profile-button-container.component.ts +++ b/alfa-client/libs/user-profile/src/lib/user-profile-in-vorgang-container/user-profile-in-vorgang/user-profile-button-container/user-profile-button-container.component.ts @@ -21,10 +21,14 @@ * Die sprachspezifischen Genehmigungen und Beschränkungen * unter der Lizenz sind dem Lizenztext zu entnehmen. */ +import { StateResource } from '@alfa-client/tech-shared'; +import { + getUserName, + UserProfileResource, + UserProfileService, +} from '@alfa-client/user-profile-shared'; import { Component, Input, OnInit, ViewChild } from '@angular/core'; import { MatMenuTrigger } from '@angular/material/menu'; -import { StateResource } from '@alfa-client/tech-shared'; -import { UserProfileResource, UserProfileService } from '@alfa-client/user-profile-shared'; import { Observable, tap } from 'rxjs'; @Component({ @@ -33,11 +37,21 @@ import { Observable, tap } from 'rxjs'; styleUrls: ['./user-profile-button-container.component.scss'], }) export class UserProfileButtonContainerComponent implements OnInit { - @Input() userProfile: StateResource<UserProfileResource>; + @Input() + set userProfile(value: StateResource<UserProfileResource>) { + this._userProfile = value; + this.userButtonLabel = this.getUserButtonLabel(); + } + + get userProfile() { + return this._userProfile; + } @ViewChild(MatMenuTrigger) menuTrigger: MatMenuTrigger; showUserProfileSearch$: Observable<boolean>; + private _userProfile: StateResource<UserProfileResource>; + userButtonLabel: string; constructor(public userProfileService: UserProfileService) {} @@ -64,4 +78,8 @@ export class UserProfileButtonContainerComponent implements OnInit { public hideUserProfileSearch(): void { this.userProfileService.hideUserProfileSearch(); } + + public getUserButtonLabel(): string { + return `Bearbeiter ändern. Aktueller Bearbeiter: ${getUserName(this.userProfile.resource)}`; + } }