Skip to content
Snippets Groups Projects
Commit 25fbd956 authored by OZGCloud's avatar OZGCloud
Browse files

OZG-6376 OZG-6696 Add editor info to button label

parent a6764926
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
......@@ -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();
});
});
});
......@@ -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)}`;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment