--- /dev/null
+/**
+ * Allows for in-template hotkey configuration. Reads hotkey maps and
+ * passes them off to the hotkey service.
+ *
+ * Listens and responds to global keyboard events.
+ */
+import {Directive, ElementRef, Input, OnInit} from '@angular/core';
+import {EgAccessKeyService} from '@eg/share/accesskey/accesskey.service';
+
+@Directive({
+ selector: '[egAccessKey]'
+})
+export class EgAccessKeyDirective implements OnInit {
+
+ constructor(
+ private elm: ElementRef,
+ private keyService: EgAccessKeyService
+ ) { }
+
+ @Input() keySpec: string;
+ @Input() keyDesc: string;
+
+ ngOnInit() {
+
+ console.debug(`Assigning access key '${this.keySpec}' => ${this.keyDesc}`);
+ }
+
+}
+
--- /dev/null
+import {Injectable, EventEmitter, HostListener} from '@angular/core';
+
+export interface EgAccessKeyAssignment {
+ key: string,
+ action: () => void
+};
+
+@Injectable()
+export class EgAccessKeyService {
+
+ handlers: {[key: string] : Function} = {};
+
+ constructor() {}
+
+ fire(evt: KeyboardEvent): void {
+ }
+
+}
+
(onChange)="orgOnChange($event)"
[hideOrgs]="hideOrgs"
[disableOrgs]="disableOrgs"
- [initialOrg]="initialOrg"
[placeholder]="'Owner'" >
</eg-org-select>
</div>
</button>
<button i18n class="btn btn-danger"
(click)="removeSelected()"
- [disabled]="!selected || isRemoving || !canDeleteSelected()">
+ [disabled]="!selected || !canDeleteSelected()">
Remove
</button>
</div>
{{copy.call_number_label}}
{{copy.call_number_suffix_label}}
</div>
- <div class="flex-1 pl-1" i18n>
+ <div class="flex-1 pl-1">
{{copy.barcode}}
<a class="pl-1" href="/eg/staff/cat/item/{{copy.id}}" i18n>View</a>
|
import {EgDialogComponent} from '@eg/share/dialog/dialog.component';
import {EgConfirmDialogComponent} from '@eg/share/dialog/confirm.component';
import {EgPromptDialogComponent} from '@eg/share/dialog/prompt.component';
+import {EgAccessKeyDirective} from '@eg/share/accesskey/accesskey.directive';
+import {EgAccessKeyService} from '@eg/share/accesskey/accesskey.service';
/**
* Imports the EG common modules and adds modules common to all staff UI's.
EgOrgSelectComponent,
EgDialogComponent,
EgConfirmDialogComponent,
- EgPromptDialogComponent
+ EgPromptDialogComponent,
+ EgAccessKeyDirective
],
imports: [
EgCommonModule
EgOrgSelectComponent,
EgDialogComponent,
EgConfirmDialogComponent,
- EgPromptDialogComponent
+ EgPromptDialogComponent,
+ EgAccessKeyDirective
]
})
return {
ngModule: EgStaffCommonModule,
providers: [
+ EgAccessKeyService
/* placeholder for exporting staff-wide services */
]
};
<i class="material-icons">more_vert</i>
</a>
<div class="dropdown-menu" ngbDropdownMenu>
- <a i18n class="dropdown-item" (click)="logout()">
+ <a class="dropdown-item" (click)="logout()">
<span class="material-icons">lock_outline</span>
<span i18n>Logout</span>
</a>
- <a i18n class="dropdown-item" href="/eg/staff/about">
+ <a class="dropdown-item" href="/eg/staff/about">
<span class="material-icons">info_outline</span>
<span i18n>About</span>
</a>
<!-- top navigation bar -->
<eg-staff-nav-bar></eg-staff-nav-bar>
+
<div id='staff-content-container'>
<!-- page content -->
<router-outlet></router-outlet>
</div>
+<div>
+ <b>testing</b>
+ <div egAccessKey keySpec="alt+s" keyDesc="My Description" i18n-keySpec i18n-keyDesc></div>
+ <div egAccessKey keySpec="alt+t" keyDesc="My Description 2"></div>
+</div>
+
-import {Component, OnInit, NgZone} from '@angular/core';
+import {Component, OnInit, NgZone, HostListener} from '@angular/core';
import {Router, ActivatedRoute, NavigationEnd} from '@angular/router';
import {EgAuthService, EgAuthWsState} from '@eg/core/auth.service';
import {EgNetService} from '@eg/core/net.service';
+import {EgAccessKeyService} from '@eg/share/accesskey/accesskey.service';
const LOGIN_PATH = '/staff/login';
const WS_BASE_PATH = '/staff/admin/workstation/workstations/';
export class EgStaffComponent implements OnInit {
-
constructor(
private router: Router,
private route: ActivatedRoute,
private zone: NgZone,
private net: EgNetService,
- private auth: EgAuthService
+ private auth: EgAuthService,
+ private keys: EgAccessKeyService
) {}
ngOnInit() {
if (this.auth.workstationState != EgAuthWsState.VALID)
this.router.navigate([WS_MANAGE_PATH]);
}
+
+ /**
+ * Listen for keyboard events here -- the root directive -- and pass
+ * events down to the key service for processing.
+ */
+ @HostListener('window:keydown', ['$event']) onKeyDown(evt: KeyboardEvent) {
+ this.keys.fire(evt);
+ }
+
}