--- /dev/null
+/**
+ * Assign access keys to <a> tags.
+ *
+ * Access key action is peformed via .click(). hrefs, routerLinks,
+ * and (click) actions are all supported.
+ *
+ * <a
+ * routerLink="/staff/splash"
+ * egAccessKey
+ * keySpec="alt+h" i18n-keySpec
+ * keyDesc="My Description" 18n-keyDesc
+ * >
+ */
+import { Component, ElementRef, Input, OnInit, ViewChild } from '@angular/core';
+import { ConfirmDialogComponent } from '@eg/share/dialog/confirm.component';
+import { AccessKeyService } from '@eg/share/accesskey/accesskey.service';
+
+@Component({
+ selector: '[egAccessKey]',
+ template: '<eg-confirm-dialog #confirmDialog dialogBody="{{confirm}}" i18n-dialogBody></eg-confirm-dialog>'
+})
+export class AccessKeyComponent implements OnInit {
+
+ // Space-separated list of key combinations
+ // E.g. "ctrl+h", "alt+h ctrl+y"
+ @Input() keySpec: string;
+
+ // Description to display in the accesskey info dialog
+ @Input() keyDesc: string;
+
+ // Context info to display in the accesskey info dialog
+ // E.g. "navbar"
+ @Input() keyCtx: string;
+
+ // Optional; if set, a confirmation dialog will be shown
+ // and the click() action will be performed on confirmation
+ @Input() confirm?: string;
+
+ @ViewChild('confirmDialog', { static: true }) confirmDialog: ConfirmDialogComponent;
+
+ constructor(
+ private elm: ElementRef,
+ private keyService: AccessKeyService
+ ) { }
+
+ ngOnInit() {
+
+ if (!this.keySpec) {
+ console.warn('AccessKey no keySpec provided');
+ return;
+ }
+
+ this.keySpec.split(/ /).forEach(keySpec => {
+ this.keyService.assign({
+ key: keySpec,
+ desc: this.keyDesc,
+ ctx: this.keyCtx,
+ action: () => {
+ // if a confirmation message was specified, show the dialog
+ if (this.confirm && this.confirm.length > 0) {
+ this.confirmDialog.open().subscribe(confirmed => {
+ if (!confirmed) { return; }
+
+ // confirmed? now we do the click()
+ this.elm.nativeElement.click();
+ });
+ }
+ // if no confirmation message was given, just do the click()
+ else
+ this.elm.nativeElement.click();
+ }
+ });
+ });
+ }
+}
+
+
+++ /dev/null
-/**
- * Assign access keys to <a> tags.
- *
- * Access key action is peformed via .click(). hrefs, routerLinks,
- * and (click) actions are all supported.
- *
- * <a
- * routerLink="/staff/splash"
- * egAccessKey
- * keySpec="alt+h" i18n-keySpec
- * keyDesc="My Description" 18n-keyDesc
- * >
- */
-import {Directive, ElementRef, Input, OnInit} from '@angular/core';
-import {AccessKeyService} from '@eg/share/accesskey/accesskey.service';
-
-@Directive({
- selector: '[egAccessKey]'
-})
-export class AccessKeyDirective implements OnInit {
-
- // Space-separated list of key combinations
- // E.g. "ctrl+h", "alt+h ctrl+y"
- @Input() keySpec: string;
-
- // Description to display in the accesskey info dialog
- @Input() keyDesc: string;
-
- // Context info to display in the accesskey info dialog
- // E.g. "navbar"
- @Input() keyCtx: string;
-
- constructor(
- private elm: ElementRef,
- private keyService: AccessKeyService
- ) { }
-
- ngOnInit() {
-
- if (!this.keySpec) {
- console.warn('AccessKey no keySpec provided');
- return;
- }
-
- this.keySpec.split(/ /).forEach(keySpec => {
- this.keyService.assign({
- key: keySpec,
- desc: this.keyDesc,
- ctx: this.keyCtx,
- action: () => this.elm.nativeElement.click()
- });
- });
- }
-}
-
-
import {GridModule} from '@eg/share/grid/grid.module';
import {CatalogCommonModule} from '@eg/share/catalog/catalog-common.module';
import {StaffBannerComponent} from './share/staff-banner.component';
-import {AccessKeyDirective} from '@eg/share/accesskey/accesskey.directive';
+import {AccessKeyComponent} from '@eg/share/accesskey/accesskey.component';
import {AccessKeyService} from '@eg/share/accesskey/accesskey.service';
import {AccessKeyInfoComponent} from '@eg/share/accesskey/accesskey-info.component';
import {OpChangeComponent} from '@eg/staff/share/op-change/op-change.component';
@NgModule({
declarations: [
StaffBannerComponent,
- AccessKeyDirective,
+ AccessKeyComponent,
AccessKeyInfoComponent,
TitleComponent,
OpChangeComponent,
GridModule,
CatalogCommonModule,
StaffBannerComponent,
- AccessKeyDirective,
+ AccessKeyComponent,
AccessKeyInfoComponent,
TitleComponent,
OpChangeComponent,