Merge pull request #4025 from Fadiabb/shift-enter-submit

add shift-enter shortcut
This commit is contained in:
Jochen Saalfeld 2018-11-21 14:52:37 +01:00 committed by GitHub
commit 0a361665c4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 53 additions and 15 deletions

View File

@ -28,3 +28,4 @@ Authors of OpenSlides in chronological order of first contribution:
Andreas Engler <engel.a@web.de> (Russian translation) Andreas Engler <engel.a@web.de> (Russian translation)
Raimund Renkert <raimund@renkert.org> Raimund Renkert <raimund@renkert.org>
Jochen Saalfeld <jochen.saalfeld@intevation.de> Jochen Saalfeld <jochen.saalfeld@intevation.de>
Fadi Abbud <fmfn13@hotmail.com>

View File

@ -6,6 +6,6 @@
"bracketSpacing": true, "bracketSpacing": true,
"htmlWhitespaceSensitivity": "strict", "htmlWhitespaceSensitivity": "strict",
"semi": true, "semi": true,
"trailingComma": "es5", "trailingComma": "none",
"arrowParens": "avoid" "arrowParens": "avoid"
} }

View File

@ -1,5 +1,10 @@
<os-head-bar [nav]="false" [goBack]="true" [editMode]="editTopic" <os-head-bar
(mainEvent)="setEditMode(!editTopic)" (saveEvent)="saveTopic()"> [nav]="false"
[goBack]="true"
[editMode]="editTopic"
(mainEvent)="setEditMode(!editTopic)"
(saveEvent)="saveTopic()"
>
<!-- Title --> <!-- Title -->
<div class="title-slot"> <div class="title-slot">
<h2> <h2>
@ -20,15 +25,13 @@
<div *ngIf="topic" class="topic-container on-transition-fade"> <div *ngIf="topic" class="topic-container on-transition-fade">
<div class="topic-title"> <div class="topic-title">
<h2 *ngIf="!editTopic">{{ topic.title }}</h2> <h2 *ngIf="!editTopic">{{ topic.title }}</h2> <h2 *ngIf="editTopic">{{ topicForm.get('title').value }}</h2>
<h2 *ngIf="editTopic">{{ topicForm.get('title').value }}</h2>
</div> </div>
<mat-card *ngIf="topic || editTopic" class="topic-text"> <mat-card *ngIf="topic || editTopic" class="topic-text">
<div> <div>
<span *ngIf="!editTopic"> <span *ngIf="!editTopic">
{{ topic.text }} {{ topic.text }} <div *ngIf="topic.text === ''" class="missing" translate>No description provided.</div>
<div *ngIf="topic.text === ''" class="missing" translate>No description provided.</div>
</span> </span>
</div> </div>
@ -39,11 +42,17 @@
</h3> </h3>
</div> </div>
<form *ngIf="editTopic" [formGroup]="topicForm" (ngSubmit)="saveTopic()" (keydown)="keyDownFunction($event)"> <form *ngIf="editTopic" [formGroup]="topicForm" (keydown)="onKeyDown($event)" (ngSubmit)="saveTopic()">
<div> <div>
<mat-form-field> <mat-form-field>
<input type="text" matInput osAutofocus required <input
formControlName="title" placeholder="{{ 'Title' | translate}}"/> type="text"
matInput
osAutofocus
required
formControlName="title"
placeholder="{{ 'Title' | translate}}"
/>
<mat-error *ngIf="topicForm.invalid" translate>A name is required</mat-error> <mat-error *ngIf="topicForm.invalid" translate>A name is required</mat-error>
</mat-form-field> </mat-form-field>
</div> </div>

View File

@ -174,11 +174,17 @@ export class TopicDetailComponent {
} }
/** /**
* clicking Shift and Enter will save automatically
* Hitting escape while in topicForm should cancel editing * Hitting escape while in topicForm should cancel editing
*
* @param event has the code * @param event has the code
*/ */
public keyDownFunction(event: KeyboardEvent): void { public onKeyDown(event: KeyboardEvent): void {
if (event.key === "Escape") { if (event.key === 'Enter' && event.shiftKey) {
this.saveTopic();
}
if (event.key === 'Escape') {
this.setEditMode(false); this.setEditMode(false);
} }
} }

View File

@ -137,7 +137,7 @@
</ng-template> </ng-template>
<ng-template #metaInfoTemplate> <ng-template #metaInfoTemplate>
<form [formGroup]='metaInfoForm' (ngSubmit)='saveMotion()'> <form [formGroup]='metaInfoForm' (keydown)="onKeyDown($event)" (ngSubmit)='saveMotion()'>
<!-- Identifier --> <!-- Identifier -->
<div *ngIf="editMotion && !newMotion"> <div *ngIf="editMotion && !newMotion">
@ -256,7 +256,7 @@
</ng-template> </ng-template>
<ng-template #contentTemplate> <ng-template #contentTemplate>
<form class="motion-content" [formGroup]='contentForm' (ngSubmit)='saveMotion()'> <form class="motion-content" [formGroup]='contentForm' (clickdown)="onKeyDown($event)" (keydown)="onKeyDown($event)" (ngSubmit)='saveMotion()'>
<!-- Line Number and Diff buttons--> <!-- Line Number and Diff buttons-->
<div *ngIf="motion && !editMotion && !motion.isStatuteAmendment()" class="motion-text-controls"> <div *ngIf="motion && !editMotion && !motion.isStatuteAmendment()" class="motion-text-controls">

View File

@ -291,6 +291,17 @@ export class MotionDetailComponent extends BaseViewComponent implements OnInit {
}); });
} }
/**
* clicking Shift and Enter will save automatically
*
* @param event has the code
*/
public onKeyDown(event: KeyboardEvent): void {
if (event.key === 'Enter' && event.shiftKey) {
this.saveMotion();
}
}
/** /**
* Save a motion. Calls the "patchValues" function in the MotionObject * Save a motion. Calls the "patchValues" function in the MotionObject
* *

View File

@ -29,7 +29,7 @@
</os-head-bar> </os-head-bar>
<mat-card class="os-card" *osPerms="'users.can_see_name'"> <mat-card class="os-card" *osPerms="'users.can_see_name'">
<form [ngClass]="{'mat-form-field-enabled': editUser}" [formGroup]="personalInfoForm" (ngSubmit)="saveUser()" *ngIf="user"> <form [ngClass]="{'mat-form-field-enabled': editUser}" [formGroup]="personalInfoForm" (ngSubmit)="saveUser()" *ngIf="user" (keydown)="onKeyDown($event)">
<!-- <h3 translate>Personal Data</h3> --> <!-- <h3 translate>Personal Data</h3> -->
<div *ngIf="isAllowed('seeName')"> <div *ngIf="isAllowed('seeName')">
<!-- Title --> <!-- Title -->

View File

@ -274,6 +274,17 @@ export class UserDetailComponent extends BaseViewComponent implements OnInit {
}); });
} }
/**
* clicking Shift and Enter will save automatically
*
* @param event has the code
*/
public onKeyDown(event: KeyboardEvent): void {
if (event.key === 'Enter' && event.shiftKey) {
this.saveUser();
}
}
/** /**
* Save / Submit a user * Save / Submit a user
*/ */