mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2025-06-19 15:23:51 +00:00
Adding new project on enter
This commit is contained in:
@ -3,6 +3,7 @@
|
|||||||
<mat-form-field class="file-name-form-field">
|
<mat-form-field class="file-name-form-field">
|
||||||
<input
|
<input
|
||||||
matInput
|
matInput
|
||||||
|
(keydown)="onKeyDown($event)"
|
||||||
type="text"
|
type="text"
|
||||||
formControlName="projectName"
|
formControlName="projectName"
|
||||||
[ngClass]="{ 'is-invalid': form.projectName?.errors }"
|
[ngClass]="{ 'is-invalid': form.projectName?.errors }"
|
||||||
|
@ -141,4 +141,13 @@ describe('AddBlankProjectDialogComponent', () => {
|
|||||||
expect(toaster.success).toHaveBeenCalled();
|
expect(toaster.success).toHaveBeenCalled();
|
||||||
expect(router.navigate).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();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -71,6 +71,12 @@ export class AddBlankProjectDialogComponent implements OnInit {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onKeyDown(event) {
|
||||||
|
if (event.key === "Enter") {
|
||||||
|
this.onAddClick();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
openConfirmationDialog(existingProject: Project) {
|
openConfirmationDialog(existingProject: Project) {
|
||||||
const dialogRef = this.dialog.open(ConfirmationDialogComponent, {
|
const dialogRef = this.dialog.open(ConfirmationDialogComponent, {
|
||||||
width: '300px',
|
width: '300px',
|
||||||
|
Reference in New Issue
Block a user