mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-19 07:53:02 +00:00
81901: Enable spacebar toggling for admin sidebar items
This commit is contained in:
@@ -36,7 +36,9 @@
|
|||||||
<div class="sidebar-section" id="sidebar-collapse-toggle">
|
<div class="sidebar-section" id="sidebar-collapse-toggle">
|
||||||
<a class="nav-item nav-link sidebar-section d-flex flex-row flex-nowrap"
|
<a class="nav-item nav-link sidebar-section d-flex flex-row flex-nowrap"
|
||||||
href="javascript:void(0);"
|
href="javascript:void(0);"
|
||||||
(click)="toggle($event)">
|
(click)="toggle($event)"
|
||||||
|
(keyup.space)="$event.stopPropagation(); toggle($event)"
|
||||||
|
>
|
||||||
<div class="shortcut-icon">
|
<div class="shortcut-icon">
|
||||||
<i *ngIf="(menuCollapsed | async)" class="fas fa-fw fa-angle-double-right"
|
<i *ngIf="(menuCollapsed | async)" class="fas fa-fw fa-angle-double-right"
|
||||||
[title]="'menu.section.icon.pin' | translate"></i>
|
[title]="'menu.section.icon.pin' | translate"></i>
|
||||||
|
@@ -3,9 +3,10 @@
|
|||||||
value: ((expanded | async) ? 'endBackground' : 'startBackground'),
|
value: ((expanded | async) ? 'endBackground' : 'startBackground'),
|
||||||
params: {endColor: (sidebarActiveBg | async)}}">
|
params: {endColor: (sidebarActiveBg | async)}}">
|
||||||
<a class="nav-item nav-link d-flex flex-row flex-nowrap"
|
<a class="nav-item nav-link d-flex flex-row flex-nowrap"
|
||||||
attr.aria.labelledby="sidebarName-{{section.id}}"
|
attr.aria-labelledby="sidebarName-{{section.id}}"
|
||||||
[title]="('menu.section.icon.' + section.id) | translate"
|
[title]="('menu.section.icon.' + section.id) | translate"
|
||||||
(click)="toggleSection($event)"
|
(click)="toggleSection($event)"
|
||||||
|
(keyup.space)="$event.stopPropagation(); toggleSection($event)"
|
||||||
href="javascript:void(0);"
|
href="javascript:void(0);"
|
||||||
>
|
>
|
||||||
<div class="shortcut-icon">
|
<div class="shortcut-icon">
|
||||||
|
@@ -2,5 +2,6 @@
|
|||||||
[ngClass]="{ 'disabled': !hasLink }"
|
[ngClass]="{ 'disabled': !hasLink }"
|
||||||
[attr.aria-disabled]="!hasLink"
|
[attr.aria-disabled]="!hasLink"
|
||||||
[routerLink]="getRouterLink()"
|
[routerLink]="getRouterLink()"
|
||||||
|
(keyup.space)="navigate($event)"
|
||||||
href="javascript:void(0);"
|
href="javascript:void(0);"
|
||||||
>{{item.text | translate}}</a>
|
>{{item.text | translate}}</a>
|
||||||
|
@@ -5,6 +5,8 @@ import { By } from '@angular/platform-browser';
|
|||||||
import { LinkMenuItemComponent } from './link-menu-item.component';
|
import { LinkMenuItemComponent } from './link-menu-item.component';
|
||||||
import { RouterLinkDirectiveStub } from '../../testing/router-link-directive.stub';
|
import { RouterLinkDirectiveStub } from '../../testing/router-link-directive.stub';
|
||||||
import { environment } from '../../../../environments/environment';
|
import { environment } from '../../../../environments/environment';
|
||||||
|
import { RouterStub } from '../../testing/router.stub';
|
||||||
|
import { Router } from '@angular/router';
|
||||||
|
|
||||||
describe('LinkMenuItemComponent', () => {
|
describe('LinkMenuItemComponent', () => {
|
||||||
let component: LinkMenuItemComponent;
|
let component: LinkMenuItemComponent;
|
||||||
@@ -25,6 +27,7 @@ describe('LinkMenuItemComponent', () => {
|
|||||||
declarations: [LinkMenuItemComponent, RouterLinkDirectiveStub],
|
declarations: [LinkMenuItemComponent, RouterLinkDirectiveStub],
|
||||||
providers: [
|
providers: [
|
||||||
{ provide: 'itemModelProvider', useValue: { text: text, link: link } },
|
{ provide: 'itemModelProvider', useValue: { text: text, link: link } },
|
||||||
|
{ provide: Router, useValue: RouterStub },
|
||||||
],
|
],
|
||||||
schemas: [NO_ERRORS_SCHEMA]
|
schemas: [NO_ERRORS_SCHEMA]
|
||||||
})
|
})
|
||||||
|
@@ -4,6 +4,7 @@ import { MenuItemType } from '../initial-menus-state';
|
|||||||
import { rendersMenuItemForType } from '../menu-item.decorator';
|
import { rendersMenuItemForType } from '../menu-item.decorator';
|
||||||
import { isNotEmpty } from '../../empty.util';
|
import { isNotEmpty } from '../../empty.util';
|
||||||
import { environment } from '../../../../environments/environment';
|
import { environment } from '../../../../environments/environment';
|
||||||
|
import { Router } from '@angular/router';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Component that renders a menu section of type LINK
|
* Component that renders a menu section of type LINK
|
||||||
@@ -16,7 +17,10 @@ import { environment } from '../../../../environments/environment';
|
|||||||
export class LinkMenuItemComponent implements OnInit {
|
export class LinkMenuItemComponent implements OnInit {
|
||||||
item: LinkMenuItemModel;
|
item: LinkMenuItemModel;
|
||||||
hasLink: boolean;
|
hasLink: boolean;
|
||||||
constructor(@Inject('itemModelProvider') item: LinkMenuItemModel) {
|
constructor(
|
||||||
|
@Inject('itemModelProvider') item: LinkMenuItemModel,
|
||||||
|
private router: Router,
|
||||||
|
) {
|
||||||
this.item = item;
|
this.item = item;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -31,4 +35,11 @@ export class LinkMenuItemComponent implements OnInit {
|
|||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
navigate(event: any) {
|
||||||
|
event.stopPropagation();
|
||||||
|
if (this.getRouterLink()) {
|
||||||
|
this.router.navigate([this.getRouterLink()]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -1 +1,6 @@
|
|||||||
<a href="javascript:void(0);" class="nav-item nav-link" role="button" (click)="item.function()">{{item.text | translate}}</a>
|
<a href="javascript:void(0);"
|
||||||
|
class="nav-item nav-link"
|
||||||
|
role="button"
|
||||||
|
(click)="item.function()"
|
||||||
|
(keyup.space)="$event.stopPropagation(); item.function()"
|
||||||
|
>{{item.text | translate}}</a>
|
||||||
|
Reference in New Issue
Block a user