i18n cleanup/ accesskey
authorBill Erickson <berickxx@gmail.com>
Sat, 14 Apr 2018 19:45:01 +0000 (19:45 +0000)
committerBill Erickson <berickxx@gmail.com>
Sat, 14 Apr 2018 19:45:01 +0000 (19:45 +0000)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/src/eg2/src/app/share/accesskey/accesskey.directive.ts [new file with mode: 0644]
Open-ILS/src/eg2/src/app/share/accesskey/accesskey.service.ts [new file with mode: 0644]
Open-ILS/src/eg2/src/app/staff/admin/workstation/workstations/workstations.component.html
Open-ILS/src/eg2/src/app/staff/catalog/record/copies.component.html
Open-ILS/src/eg2/src/app/staff/common.module.ts
Open-ILS/src/eg2/src/app/staff/nav.component.html
Open-ILS/src/eg2/src/app/staff/staff.component.html
Open-ILS/src/eg2/src/app/staff/staff.component.ts

diff --git a/Open-ILS/src/eg2/src/app/share/accesskey/accesskey.directive.ts b/Open-ILS/src/eg2/src/app/share/accesskey/accesskey.directive.ts
new file mode 100644 (file)
index 0000000..440b312
--- /dev/null
@@ -0,0 +1,29 @@
+/**
+ * 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}`);
+    }
+
+}
+
diff --git a/Open-ILS/src/eg2/src/app/share/accesskey/accesskey.service.ts b/Open-ILS/src/eg2/src/app/share/accesskey/accesskey.service.ts
new file mode 100644 (file)
index 0000000..82f7395
--- /dev/null
@@ -0,0 +1,19 @@
+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 {
+    }
+
+}
+
index 490f9a6..d900723 100644 (file)
@@ -27,7 +27,6 @@
           (onChange)="orgOnChange($event)"
           [hideOrgs]="hideOrgs"
           [disableOrgs]="disableOrgs"
-          [initialOrg]="initialOrg"
           [placeholder]="'Owner'" >
         </eg-org-select>
       </div>
@@ -81,7 +80,7 @@
         </button>
         <button i18n class="btn btn-danger"
           (click)="removeSelected()"
-          [disabled]="!selected || isRemoving || !canDeleteSelected()">
+          [disabled]="!selected || !canDeleteSelected()">
           Remove
         </button>
       </div>
index 84e9d8e..8c7a4f3 100644 (file)
@@ -45,7 +45,7 @@
               {{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>
               | 
index f44f97d..cddd063 100644 (file)
@@ -5,6 +5,8 @@ import {EgOrgSelectComponent} from '@eg/share/org-select.component';
 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.
@@ -16,7 +18,8 @@ import {EgPromptDialogComponent} from '@eg/share/dialog/prompt.component';
     EgOrgSelectComponent,
     EgDialogComponent,
     EgConfirmDialogComponent,
-    EgPromptDialogComponent
+    EgPromptDialogComponent,
+    EgAccessKeyDirective
   ],
   imports: [
     EgCommonModule
@@ -27,7 +30,8 @@ import {EgPromptDialogComponent} from '@eg/share/dialog/prompt.component';
     EgOrgSelectComponent,
     EgDialogComponent,
     EgConfirmDialogComponent,
-    EgPromptDialogComponent
+    EgPromptDialogComponent,
+    EgAccessKeyDirective
   ]
 })
 
@@ -36,6 +40,7 @@ export class EgStaffCommonModule {
         return {
             ngModule: EgStaffCommonModule,
             providers: [
+                EgAccessKeyService
                 /* placeholder for exporting staff-wide services */
             ]
         };
index f85a6e1..803e173 100644 (file)
           <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>
index 7bd463a..5f92ef0 100644 (file)
@@ -1,8 +1,15 @@
 <!-- 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>
+
index 0084952..505b21d 100644 (file)
@@ -1,7 +1,8 @@
-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/';
@@ -14,13 +15,13 @@ const WS_MANAGE_PATH = '/staff/admin/workstation/workstations/manage';
 
 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() {
@@ -87,6 +88,15 @@ export class EgStaffComponent implements OnInit {
         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);
+    }
+
 }