From 0462a00f5b1dd916610a565f4c098cfa8b39cb2a Mon Sep 17 00:00:00 2001 From: ppaidi Date: Thu, 10 Sep 2020 16:05:06 +0530 Subject: [PATCH 01/10] feat: create directive to act on escape key, use directive to close task and stage configurator modals on escape part of #1333 --- .../common/src/lib/client-shared.module.ts | 2 ++ .../common/src/lib/directives/action-on-escape.ts | 13 +++++++++++++ libs/lib-client/common/src/lib/directives/index.ts | 1 + .../task-configurator.component.html | 2 +- .../task-configurator.component.ts | 2 +- .../stage-configurator.component.html | 2 +- .../stage-configurator.component.ts | 2 +- 7 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 libs/lib-client/common/src/lib/directives/action-on-escape.ts diff --git a/libs/lib-client/common/src/lib/client-shared.module.ts b/libs/lib-client/common/src/lib/client-shared.module.ts index d4f6c0d7a..27abb4988 100644 --- a/libs/lib-client/common/src/lib/client-shared.module.ts +++ b/libs/lib-client/common/src/lib/client-shared.module.ts @@ -12,6 +12,7 @@ import { EditableInputDirective, JsonDownloaderDirective, ClickOutsideDirective, + ActionOnEscapeDirective, } from './directives'; import { LoadingIndicatorComponent, FlogoDeletePopupComponent } from './components'; @@ -25,6 +26,7 @@ const ALL_MODULE_DECLARABLES = [ EditableInputDirective, TimeFromNowPipe, ClickOutsideDirective, + ActionOnEscapeDirective, FlogoDeletePopupComponent, ObjectPropertiesPipe, ]; diff --git a/libs/lib-client/common/src/lib/directives/action-on-escape.ts b/libs/lib-client/common/src/lib/directives/action-on-escape.ts new file mode 100644 index 000000000..a4bc8b80c --- /dev/null +++ b/libs/lib-client/common/src/lib/directives/action-on-escape.ts @@ -0,0 +1,13 @@ +import { Directive, HostListener, EventEmitter, Output } from '@angular/core'; + +@Directive({ + selector: '[fgOnEscape]', +}) +export class ActionOnEscapeDirective { + @Output() fgOnEscape = new EventEmitter(); + + @HostListener('document:keydown.escape') + onEscape() { + this.fgOnEscape.emit(); + } +} diff --git a/libs/lib-client/common/src/lib/directives/index.ts b/libs/lib-client/common/src/lib/directives/index.ts index 8da7f2701..b5465f41d 100644 --- a/libs/lib-client/common/src/lib/directives/index.ts +++ b/libs/lib-client/common/src/lib/directives/index.ts @@ -4,3 +4,4 @@ export { ContenteditableDirective } from './contenteditable.directive'; export { DraggableDirective } from './draggable.directive'; export { EditableInputDirective } from './editable-input.directive'; export { JsonDownloaderDirective } from './json-downloader.directive'; +export { ActionOnEscapeDirective } from './action-on-escape'; diff --git a/libs/plugins/flow-client/src/lib/task-configurator/task-configurator.component.html b/libs/plugins/flow-client/src/lib/task-configurator/task-configurator.component.html index 70a361f7a..61025246b 100644 --- a/libs/plugins/flow-client/src/lib/task-configurator/task-configurator.component.html +++ b/libs/plugins/flow-client/src/lib/task-configurator/task-configurator.component.html @@ -1,4 +1,4 @@ -