Merge pull request #308 from GNS3/Adding-new-project-on-enter

Adding new project on enter
This commit is contained in:
ziajka 2019-02-28 10:11:56 +01:00 committed by GitHub
commit 3cf7492452
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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',