adding "shift-enter"-Submit for TagList
This commit is contained in:
parent
6db5c90180
commit
29188888f8
@ -7,7 +7,8 @@
|
||||
<mat-card class="os-card" *ngIf="blockToCreate">
|
||||
<mat-card-title translate>Create new motion block</mat-card-title>
|
||||
<mat-card-content>
|
||||
<form [formGroup]="createBlockForm">
|
||||
<form [formGroup]="createBlockForm"
|
||||
(keydown)="onKeyDown($event)">
|
||||
<!-- Title -->
|
||||
<p>
|
||||
<mat-form-field>
|
||||
@ -50,7 +51,7 @@
|
||||
<!-- Save and Cancel buttons -->
|
||||
<mat-card-actions>
|
||||
<button mat-button (click)="onSaveNewButton()"><span translate>Save</span></button>
|
||||
<button mat-button (click)="blockToCreate = null"><span translate>Cancel</span></button>
|
||||
<button mat-button (click)="onCancel()"><span translate>Cancel</span></button>
|
||||
</mat-card-actions>
|
||||
</mat-card>
|
||||
|
||||
|
@ -169,4 +169,26 @@ export class MotionBlockListComponent extends ListViewBaseComponent<ViewMotionBl
|
||||
// set a form control as "touched" to trigger potential error messages
|
||||
this.createBlockForm.get('title').markAsTouched();
|
||||
}
|
||||
|
||||
/**
|
||||
* clicking Shift and Enter will save automatically
|
||||
* clicking Escape will cancel the process
|
||||
*
|
||||
* @param event has the code
|
||||
*/
|
||||
public onKeyDown(event: KeyboardEvent): void {
|
||||
if (event.key === 'Enter' && event.shiftKey) {
|
||||
this.onSaveNewButton();
|
||||
}
|
||||
if (event.key === 'Escape') {
|
||||
this.onCancel();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancels the current form action
|
||||
*/
|
||||
public onCancel(): void {
|
||||
this.blockToCreate = null;
|
||||
}
|
||||
}
|
||||
|
@ -73,16 +73,26 @@ export class MotionCommentSectionListComponent extends BaseViewComponent impleme
|
||||
}
|
||||
|
||||
/**
|
||||
* Event on Key Down in update or create form. Do not provide the viewSection for the create form.
|
||||
* Event on Key Down in update or create form.
|
||||
*
|
||||
* @param event the keyboard event
|
||||
* @param the current view in scope
|
||||
*/
|
||||
public keyDownFunction(event: KeyboardEvent, viewSection?: ViewMotionCommentSection): void {
|
||||
if (event.key === "Escape") {
|
||||
if (event.key === 'Enter' && event.shiftKey) {
|
||||
if (viewSection) {
|
||||
this.onSaveButton(viewSection);
|
||||
} else {
|
||||
this.create();
|
||||
}
|
||||
}
|
||||
if (event.key === 'Escape') {
|
||||
if (viewSection) {
|
||||
this.editId = null;
|
||||
} else {
|
||||
this.commentSectionToCreate = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -16,7 +16,8 @@
|
||||
<mat-card *ngIf="statuteParagraphToCreate">
|
||||
<mat-card-title translate>New statute paragraph</mat-card-title>
|
||||
<mat-card-content>
|
||||
<form [formGroup]="createForm">
|
||||
<form [formGroup]="createForm"
|
||||
(keydown)="onKeyDownCreate($event)">
|
||||
<p>
|
||||
<mat-form-field>
|
||||
<input formControlName="title" matInput placeholder="{{'Title' | translate}}" required>
|
||||
@ -39,7 +40,7 @@
|
||||
<button mat-button (click)="create()">
|
||||
<span translate>Save</span>
|
||||
</button>
|
||||
<button mat-button (click)="statuteParagraphToCreate = null">
|
||||
<button mat-button (click)="onCancel()">
|
||||
<span translate>Cancel</span>
|
||||
</button>
|
||||
</mat-card-actions>
|
||||
@ -53,7 +54,9 @@
|
||||
{{ statuteParagraph.title }}
|
||||
</mat-panel-title>
|
||||
</mat-expansion-panel-header>
|
||||
<form [formGroup]="updateForm" *ngIf="editId === statuteParagraph.id">
|
||||
<form [formGroup]="updateForm"
|
||||
*ngIf="editId === statuteParagraph.id"
|
||||
(keydown)="onKeyDownUpdate($event)">
|
||||
<span translate>Edit statute paragraph:</span>
|
||||
<p>
|
||||
<mat-form-field>
|
||||
@ -85,7 +88,7 @@
|
||||
mat-icon-button>
|
||||
<mat-icon>edit</mat-icon>
|
||||
</button>
|
||||
<button *ngIf="editId === statuteParagraph.id" mat-button class="on-transition-fade" (click)="editId = null"
|
||||
<button *ngIf="editId === statuteParagraph.id" mat-button class="on-transition-fade" (click)="onCancelUpdate()"
|
||||
mat-icon-button>
|
||||
<mat-icon>close</mat-icon>
|
||||
</button>
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -138,7 +138,10 @@ export class TagListComponent extends ListViewBaseComponent<ViewTag> 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();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user