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
This commit is contained in:
Sean 2020-03-23 14:26:38 +01:00
parent 5617b02804
commit 5bf3dfadff
5 changed files with 10 additions and 11 deletions

View File

@ -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",

View File

@ -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();

View File

@ -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();

View File

@ -57,7 +57,7 @@ export class MotionPollDialogComponent extends BasePollDialogComponent<ViewMotio
}
/**
* Pre-executed method to initialize the dialog-form depending on the poll-method.
* Initialize the dialog-form depending on the poll-method.
*/
private createDialog(): void {
this.dialogVoteForm = this.formBuilder.group({
@ -69,7 +69,7 @@ export class MotionPollDialogComponent extends BasePollDialogComponent<ViewMotio
votescast: ['', [Validators.min(LOWEST_VOTE_VALUE)]]
});
if (this.pollData.poll) {
if (this.pollData && this.pollData.poll) {
this.updateDialogVoteForm(this.pollData);
}
}

View File

@ -1,4 +1,3 @@
import { OnInit } from '@angular/core';
import { FormGroup } from '@angular/forms';
import { MatSnackBar } from '@angular/material';
import { MatDialogRef } from '@angular/material/dialog';
@ -16,8 +15,7 @@ import { ViewBasePoll } from '../models/view-base-poll';
/**
* A dialog for updating the values of a poll.
*/
export abstract class BasePollDialogComponent<T extends ViewBasePoll, S extends PollService> extends BaseViewComponent
implements OnInit {
export abstract class BasePollDialogComponent<T extends ViewBasePoll, S extends PollService> extends BaseViewComponent {
public publishImmediately: boolean;
protected pollForm: PollFormComponent<T, S>;
@ -31,11 +29,11 @@ export abstract class BasePollDialogComponent<T extends ViewBasePoll, S extends
public dialogRef: MatDialogRef<BasePollDialogComponent<T, S>>
) {
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();