mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
[CST-15590] Close user profile menu after menu entry is selected (#3760)
(cherry picked from commit fa0ec0bf0c
)
Co-authored-by: Alisa Ismailati <alisa.ismailati@4science.com>
This commit is contained in:
@@ -19,7 +19,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div *ngIf="(isAuthenticated | async) && (showAuth | async)" class="nav-item">
|
<div *ngIf="(isAuthenticated | async) && (showAuth | async)" class="nav-item">
|
||||||
<div ngbDropdown display="dynamic" placement="bottom-right" class="d-inline-block" @fadeInOut>
|
<div ngbDropdown #loggedInDrop="ngbDropdown" display="dynamic" placement="bottom-right" class="d-inline-block" @fadeInOut>
|
||||||
<a href="javascript:void(0);"
|
<a href="javascript:void(0);"
|
||||||
role="menuitem"
|
role="menuitem"
|
||||||
[attr.aria-label]="'nav.user-profile-menu-and-logout' | translate"
|
[attr.aria-label]="'nav.user-profile-menu-and-logout' | translate"
|
||||||
@@ -30,7 +30,7 @@
|
|||||||
ngbDropdownToggle>
|
ngbDropdownToggle>
|
||||||
<i class="fas fa-user-circle fa-lg fa-fw"></i></a>
|
<i class="fas fa-user-circle fa-lg fa-fw"></i></a>
|
||||||
<div id="logoutDropdownMenu" ngbDropdownMenu>
|
<div id="logoutDropdownMenu" ngbDropdownMenu>
|
||||||
<ds-user-menu [inExpandableNavbar]="false"></ds-user-menu>
|
<ds-user-menu [inExpandableNavbar]="false" (changedRoute)="loggedInDrop.close()"></ds-user-menu>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -1,6 +1,8 @@
|
|||||||
import {
|
import {
|
||||||
Component,
|
Component,
|
||||||
|
EventEmitter,
|
||||||
Input,
|
Input,
|
||||||
|
Output,
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
|
|
||||||
import { ThemedComponent } from '../../theme-support/themed.component';
|
import { ThemedComponent } from '../../theme-support/themed.component';
|
||||||
@@ -23,7 +25,12 @@ export class ThemedUserMenuComponent extends ThemedComponent<UserMenuComponent>{
|
|||||||
*/
|
*/
|
||||||
@Input() inExpandableNavbar: boolean;
|
@Input() inExpandableNavbar: boolean;
|
||||||
|
|
||||||
protected inAndOutputNames: (keyof UserMenuComponent & keyof this)[] = ['inExpandableNavbar'];
|
/**
|
||||||
|
* Emits an event when the route changes
|
||||||
|
*/
|
||||||
|
@Output() changedRoute: EventEmitter<any> = new EventEmitter<any>();
|
||||||
|
|
||||||
|
protected inAndOutputNames: (keyof UserMenuComponent & keyof this)[] = ['inExpandableNavbar', 'changedRoute'];
|
||||||
|
|
||||||
protected getComponentName(): string {
|
protected getComponentName(): string {
|
||||||
return 'UserMenuComponent';
|
return 'UserMenuComponent';
|
||||||
|
@@ -6,17 +6,17 @@
|
|||||||
{{dsoNameService.getName(user$ | async)}}<br>
|
{{dsoNameService.getName(user$ | async)}}<br>
|
||||||
<span class="text-muted">{{(user$ | async)?.email}}</span>
|
<span class="text-muted">{{(user$ | async)?.email}}</span>
|
||||||
</li>
|
</li>
|
||||||
<li class="ds-menu-item-wrapper" role="presentation">
|
<li class="ds-menu-item-wrapper" role="presentation" (click)="onMenuItemClick()">
|
||||||
<a class="ds-menu-item" role="menuitem"
|
<a class="ds-menu-item" role="menuitem"
|
||||||
[routerLink]="[profileRoute]"
|
[routerLink]="[profileRoute]"
|
||||||
routerLinkActive="active">{{'nav.profile' | translate}}</a>
|
routerLinkActive="active">{{'nav.profile' | translate}}</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="ds-menu-item-wrapper" role="presentation">
|
<li class="ds-menu-item-wrapper" role="presentation" (click)="onMenuItemClick()">
|
||||||
<a class="ds-menu-item" role="menuitem"
|
<a class="ds-menu-item" role="menuitem"
|
||||||
[routerLink]="[mydspaceRoute]"
|
[routerLink]="[mydspaceRoute]"
|
||||||
routerLinkActive="active">{{'nav.mydspace' | translate}}</a>
|
routerLinkActive="active">{{'nav.mydspace' | translate}}</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="ds-menu-item-wrapper" role="presentation">
|
<li class="ds-menu-item-wrapper" role="presentation" (click)="onMenuItemClick()">
|
||||||
<a class="ds-menu-item" role="menuitem"
|
<a class="ds-menu-item" role="menuitem"
|
||||||
[routerLink]="[subscriptionsRoute]"
|
[routerLink]="[subscriptionsRoute]"
|
||||||
routerLinkActive="active">{{'nav.subscriptions' | translate}}</a>
|
routerLinkActive="active">{{'nav.subscriptions' | translate}}</a>
|
||||||
|
@@ -203,6 +203,17 @@ describe('UserMenuComponent', () => {
|
|||||||
expect(components).toBeFalsy();
|
expect(components).toBeFalsy();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should call onMenuItemClick when li is clicked', () => {
|
||||||
|
spyOn(component, 'onMenuItemClick');
|
||||||
|
const lis = fixture.debugElement.queryAll(By.css('.ds-menu-item-wrapper'));
|
||||||
|
const secondLi = lis[1];
|
||||||
|
secondLi.triggerEventHandler('click', {
|
||||||
|
preventDefault: () => {/**/
|
||||||
|
},
|
||||||
|
});
|
||||||
|
expect(component.onMenuItemClick).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@@ -5,8 +5,10 @@ import {
|
|||||||
} from '@angular/common';
|
} from '@angular/common';
|
||||||
import {
|
import {
|
||||||
Component,
|
Component,
|
||||||
|
EventEmitter,
|
||||||
Input,
|
Input,
|
||||||
OnInit,
|
OnInit,
|
||||||
|
Output,
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
import {
|
import {
|
||||||
RouterLink,
|
RouterLink,
|
||||||
@@ -49,6 +51,11 @@ export class UserMenuComponent implements OnInit {
|
|||||||
*/
|
*/
|
||||||
@Input() inExpandableNavbar = false;
|
@Input() inExpandableNavbar = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Emits an event when the route changes
|
||||||
|
*/
|
||||||
|
@Output() changedRoute: EventEmitter<any> = new EventEmitter<any>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* True if the authentication is loading.
|
* True if the authentication is loading.
|
||||||
* @type {Observable<boolean>}
|
* @type {Observable<boolean>}
|
||||||
@@ -96,4 +103,11 @@ export class UserMenuComponent implements OnInit {
|
|||||||
this.user$ = this.authService.getAuthenticatedUserFromStore();
|
this.user$ = this.authService.getAuthenticatedUserFromStore();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Emits an event when the menu item is clicked
|
||||||
|
*/
|
||||||
|
onMenuItemClick() {
|
||||||
|
this.changedRoute.emit();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user