From 5bf3dfadffd13de14c72b542a8b5c04ae76b493a Mon Sep 17 00:00:00 2001 From: Sean Date: Mon, 23 Mar 2020 14:26:38 +0100 Subject: [PATCH] Fix Shift-Enter to save poll Fixes a bug which caused the event listener not to register in BasePollDialog Also hot fixes a bug in babel --- client/package.json | 1 + .../assignment-poll-dialog.component.spec.ts | 4 ++-- .../motion-poll-dialog.component.spec.ts | 4 ++-- .../motion-poll-dialog/motion-poll-dialog.component.ts | 4 ++-- .../site/polls/components/base-poll-dialog.component.ts | 8 +++----- 5 files changed, 10 insertions(+), 11 deletions(-) diff --git a/client/package.json b/client/package.json index 996c54bda..859e6cc47 100644 --- a/client/package.json +++ b/client/package.json @@ -82,6 +82,7 @@ "@angular/compiler-cli": "^8.2.14", "@angular/language-service": "^8.2.14", "@biesbjerg/ngx-translate-extract": "^3.0.5", + "@babel/compat-data": "~7.8.0", "@compodoc/compodoc": "^1.1.11", "@types/jasmine": "^3.5.0", "@types/jasminewd2": "^2.0.8", diff --git a/client/src/app/site/assignments/components/assignment-poll-dialog/assignment-poll-dialog.component.spec.ts b/client/src/app/site/assignments/components/assignment-poll-dialog/assignment-poll-dialog.component.spec.ts index a13727a88..629636840 100644 --- a/client/src/app/site/assignments/components/assignment-poll-dialog/assignment-poll-dialog.component.spec.ts +++ b/client/src/app/site/assignments/components/assignment-poll-dialog/assignment-poll-dialog.component.spec.ts @@ -13,10 +13,10 @@ describe('AssignmentPollDialogComponent', () => { TestBed.configureTestingModule({ imports: [E2EImportsModule], providers: [ - { provide: MatDialogRef, useValue: {} }, + { provide: MatDialogRef, useValue: null }, { provide: MAT_DIALOG_DATA, - useValue: {} + useValue: null } ] }).compileComponents(); diff --git a/client/src/app/site/motions/modules/motion-poll/motion-poll-dialog/motion-poll-dialog.component.spec.ts b/client/src/app/site/motions/modules/motion-poll/motion-poll-dialog/motion-poll-dialog.component.spec.ts index 773ff4751..0fb3ddb49 100644 --- a/client/src/app/site/motions/modules/motion-poll/motion-poll-dialog/motion-poll-dialog.component.spec.ts +++ b/client/src/app/site/motions/modules/motion-poll/motion-poll-dialog/motion-poll-dialog.component.spec.ts @@ -13,10 +13,10 @@ describe('MotionPollDialogComponent', () => { TestBed.configureTestingModule({ imports: [E2EImportsModule], providers: [ - { provide: MatDialogRef, useValue: {} }, + { provide: MatDialogRef, useValue: null }, { provide: MAT_DIALOG_DATA, - useValue: {} + useValue: null } ] }).compileComponents(); diff --git a/client/src/app/site/motions/modules/motion-poll/motion-poll-dialog/motion-poll-dialog.component.ts b/client/src/app/site/motions/modules/motion-poll/motion-poll-dialog/motion-poll-dialog.component.ts index 73b1f2724..f5eafc444 100644 --- a/client/src/app/site/motions/modules/motion-poll/motion-poll-dialog/motion-poll-dialog.component.ts +++ b/client/src/app/site/motions/modules/motion-poll/motion-poll-dialog/motion-poll-dialog.component.ts @@ -57,7 +57,7 @@ export class MotionPollDialogComponent extends BasePollDialogComponent extends BaseViewComponent - implements OnInit { +export abstract class BasePollDialogComponent extends BaseViewComponent { public publishImmediately: boolean; protected pollForm: PollFormComponent; @@ -31,11 +29,11 @@ export abstract class BasePollDialogComponent> ) { super(title, translate, matSnackbar); + this.addKeyListener(); } - public ngOnInit(): void { + private addKeyListener(): void { if (this.dialogRef) { - // Jasmin/Karma fails here. TODO: this.dialogRef.keydownEvents().subscribe((event: KeyboardEvent) => { if (event.key === 'Enter' && event.shiftKey) { this.submitPoll();