Adding new project on enter

This commit is contained in:
Piotr Pekala 2019-02-27 02:06:52 -08:00
parent 66c87bd50c
commit bc7eda33b3
3 changed files with 16 additions and 0 deletions

View File

@ -3,6 +3,7 @@
<mat-form-field class="file-name-form-field">
<input
matInput
(keydown)="onKeyDown($event)"
type="text"
formControlName="projectName"
[ngClass]="{ 'is-invalid': form.projectName?.errors }"

View File

@ -141,4 +141,13 @@ describe('AddBlankProjectDialogComponent', () => {
expect(toaster.success).toHaveBeenCalled();
expect(router.navigate).toHaveBeenCalled();
});
it('should call adding on enter', () => {
component.projectNameForm.controls['projectName'].setValue('validName');
spyOn(component, 'onAddClick');
component.onKeyDown({key: 'Enter'});
expect(component.onAddClick).toHaveBeenCalled();
});
});

View File

@ -71,6 +71,12 @@ export class AddBlankProjectDialogComponent implements OnInit {
});
}
onKeyDown(event) {
if (event.key === "Enter") {
this.onAddClick();
}
}
openConfirmationDialog(existingProject: Project) {
const dialogRef = this.dialog.open(ConfirmationDialogComponent, {
width: '300px',