From 29188888f8a4f1a8260512c27f69537d2d45ac3a Mon Sep 17 00:00:00 2001 From: Jochen Saalfeld Date: Mon, 7 Jan 2019 14:44:42 +0100 Subject: [PATCH] adding "shift-enter"-Submit for TagList --- .../motion-block-list.component.html | 5 ++- .../motion-block-list.component.ts | 22 +++++++++ .../motion-comment-section-list.component.ts | 14 +++++- .../statute-paragraph-list.component.html | 11 +++-- .../statute-paragraph-list.component.ts | 45 +++++++++++++++++++ .../components/tag-list/tag-list.component.ts | 5 ++- 6 files changed, 93 insertions(+), 9 deletions(-) diff --git a/client/src/app/site/motions/components/motion-block-list/motion-block-list.component.html b/client/src/app/site/motions/components/motion-block-list/motion-block-list.component.html index 85c5a78b0..7dc9540f6 100644 --- a/client/src/app/site/motions/components/motion-block-list/motion-block-list.component.html +++ b/client/src/app/site/motions/components/motion-block-list/motion-block-list.component.html @@ -7,7 +7,8 @@ Create new motion block -
+

@@ -50,7 +51,7 @@ - + diff --git a/client/src/app/site/motions/components/motion-block-list/motion-block-list.component.ts b/client/src/app/site/motions/components/motion-block-list/motion-block-list.component.ts index 2c661cdd9..e466f3690 100644 --- a/client/src/app/site/motions/components/motion-block-list/motion-block-list.component.ts +++ b/client/src/app/site/motions/components/motion-block-list/motion-block-list.component.ts @@ -169,4 +169,26 @@ export class MotionBlockListComponent extends ListViewBaseComponent New statute paragraph - +

@@ -39,7 +40,7 @@ - @@ -53,7 +54,9 @@ {{ statuteParagraph.title }} - + Edit statute paragraph:

@@ -85,7 +88,7 @@ mat-icon-button> edit - diff --git a/client/src/app/site/motions/components/statute-paragraph-list/statute-paragraph-list.component.ts b/client/src/app/site/motions/components/statute-paragraph-list/statute-paragraph-list.component.ts index 1b63ecc25..04aefada6 100644 --- a/client/src/app/site/motions/components/statute-paragraph-list/statute-paragraph-list.component.ts +++ b/client/src/app/site/motions/components/statute-paragraph-list/statute-paragraph-list.component.ts @@ -155,4 +155,49 @@ export class StatuteParagraphListComponent extends BaseViewComponent implements public sortStatuteParagraphs(): void { console.log('Not yet implemented. Depends on other Features'); } + + /** + * clicking Shift and Enter will save automatically + * clicking Escape will cancel the process + * + * @param event has the code + */ + public onKeyDownCreate(event: KeyboardEvent): void { + if (event.key === 'Enter' && event.shiftKey) { + this.create(); + } + if (event.key === 'Escape') { + this.onCancelCreate(); + } + } + + /** + * Cancels the current form action + */ + public onCancelCreate(): void { + this.statuteParagraphToCreate = null; + } + + /** + * clicking Shift and Enter will save automatically + * clicking Escape will cancel the process + * + * @param event has the code + */ + public onKeyDownUpdate(event: KeyboardEvent): void { + if (event.key === 'Enter' && event.shiftKey) { + const myParagraph = this.statuteParagraphs.find(x => x.id === this.editId); + this.onSaveButton(myParagraph); + } + if (event.key === 'Escape') { + this.onCancelUpdate(); + } + } + + /** + * Cancels the current form action + */ + public onCancelUpdate(): void { + this.editId = null; + } } diff --git a/client/src/app/site/tags/components/tag-list/tag-list.component.ts b/client/src/app/site/tags/components/tag-list/tag-list.component.ts index 4465c7aab..8e4fb91fe 100644 --- a/client/src/app/site/tags/components/tag-list/tag-list.component.ts +++ b/client/src/app/site/tags/components/tag-list/tag-list.component.ts @@ -138,7 +138,10 @@ export class TagListComponent extends ListViewBaseComponent implements * @param event */ public keyDownFunction(event: KeyboardEvent): void { - if (event.key === "Enter") { + if (event.key === 'Enter' && event.shiftKey) { + this.submitNewTag(); + } + if (event.key === "Escape") { this.cancelEditing(); } }