diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 59feb204b600ad085c9d1fc58afb9373a8e0a112..49e159b3bbb5df3d910abc37303019b8e625e3b4 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -17,7 +17,7 @@ import { IqbComponentsModule } from 'iqb-components'; import {MatButtonModule} from "@angular/material/button"; import {MatCardModule} from "@angular/material/card"; import {MatCheckboxModule} from "@angular/material/checkbox"; -import { MatDialogModule } from '@angular/material/dialog'; +import {MatDialog, MatDialogModule} from '@angular/material/dialog'; import {MatFormFieldModule} from "@angular/material/form-field"; import {MatIconModule} from "@angular/material/icon"; import {MatInputModule} from "@angular/material/input"; @@ -66,6 +66,7 @@ import {RouterModule} from "@angular/router"; ], providers: [ BackendService, + MatDialog, { provide: HTTP_INTERCEPTORS, useClass: AuthInterceptor, diff --git a/src/app/superadmin/users/newpassword/newpassword.component.html b/src/app/superadmin/users/newpassword/newpassword.component.html index 8685c172a39662b40f6a6734944552a13b17d09f..49bc44b867202f95f12e7f250e548ca7b1882548 100644 --- a/src/app/superadmin/users/newpassword/newpassword.component.html +++ b/src/app/superadmin/users/newpassword/newpassword.component.html @@ -3,7 +3,7 @@ <mat-dialog-content> <div class="infobox"> - <p>Ändern des Kennwortes für Nutzer/in "{{ data.name }}".</p> + <p>Ändern des Kennwortes für Nutzer/in "{{ data }}".</p> </div> <p> <mat-form-field class="full-width"> diff --git a/src/app/superadmin/users/newpassword/newpassword.component.spec.ts b/src/app/superadmin/users/newpassword/newpassword.component.spec.ts index c9d927fa6f9d1b83edd952857cee749180eee7f2..9e7ddf443e512b929c57abfce9e45b156147bef6 100644 --- a/src/app/superadmin/users/newpassword/newpassword.component.spec.ts +++ b/src/app/superadmin/users/newpassword/newpassword.component.spec.ts @@ -2,7 +2,10 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { NewpasswordComponent } from './newpassword.component'; import {ReactiveFormsModule} from "@angular/forms"; -import {MatDialogModule} from "@angular/material/dialog"; +import {MAT_DIALOG_DATA, MatDialog, MatDialogModule} from "@angular/material/dialog"; +import {MatInputModule} from "@angular/material/input"; +import {MatFormFieldModule} from "@angular/material/form-field"; +import {NoopAnimationsModule} from "@angular/platform-browser/animations"; describe('NewpasswordComponent', () => { let component: NewpasswordComponent; @@ -11,7 +14,17 @@ describe('NewpasswordComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ declarations: [ NewpasswordComponent ], - imports: [ReactiveFormsModule, MatDialogModule] + imports: [ + MatDialogModule, + ReactiveFormsModule, + MatInputModule, + MatFormFieldModule, + NoopAnimationsModule + ], + providers: [ + MatDialog, + { provide: MAT_DIALOG_DATA, useValue: 'Harry Sack' } + ] }) .compileComponents(); })); diff --git a/src/app/superadmin/users/newpassword/newpassword.component.ts b/src/app/superadmin/users/newpassword/newpassword.component.ts index 3a001265d18cae4a65cf5de623c1ebfddff7f91d..c4b785f42eee61923e6308f50668d567495dfbc9 100644 --- a/src/app/superadmin/users/newpassword/newpassword.component.ts +++ b/src/app/superadmin/users/newpassword/newpassword.component.ts @@ -1,21 +1,17 @@ import { MAT_DIALOG_DATA } from '@angular/material/dialog'; -import { Component, OnInit, Inject } from '@angular/core'; -import { FormGroup, FormBuilder, Validators } from '@angular/forms'; +import { Component, Inject } from '@angular/core'; +import {FormGroup, Validators, FormControl} from '@angular/forms'; @Component({ templateUrl: './newpassword.component.html', styleUrls: ['./newpassword.component.css'] }) -export class NewpasswordComponent implements OnInit { - newpasswordform: FormGroup; +export class NewpasswordComponent { + newpasswordform = new FormGroup({ + pw: new FormControl('', [Validators.required, Validators.minLength(3)]) + }); - constructor(private fb: FormBuilder, - @Inject(MAT_DIALOG_DATA) public data: any) { } - - ngOnInit() { - this.newpasswordform = this.fb.group({ - pw: this.fb.control('', [Validators.required, Validators.minLength(3)]) - }); - } + constructor( + @Inject(MAT_DIALOG_DATA) public data: string) { } } diff --git a/src/app/superadmin/users/newuser/newuser.component.html b/src/app/superadmin/users/newuser/newuser.component.html index 4a4d5c11f20c5873192f60bf454c5193b1785ece..32b548ef737a6b8db12dbe6c82eed553afcc8b7e 100644 --- a/src/app/superadmin/users/newuser/newuser.component.html +++ b/src/app/superadmin/users/newuser/newuser.component.html @@ -4,7 +4,7 @@ <mat-dialog-content> <p> <mat-form-field class="full-width"> - <input matInput formControlName="name" placeholder="Name" [value]="data.name"> + <input matInput formControlName="name" placeholder="Name"> </mat-form-field> </p> <p> diff --git a/src/app/superadmin/users/newuser/newuser.component.spec.ts b/src/app/superadmin/users/newuser/newuser.component.spec.ts index f58f6764bfc7dcef639cecfc0df98f714d34c4b1..75c49da6a6323a759819d5bf932c793c5ebe8e9a 100644 --- a/src/app/superadmin/users/newuser/newuser.component.spec.ts +++ b/src/app/superadmin/users/newuser/newuser.component.spec.ts @@ -2,7 +2,11 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { NewuserComponent } from './newuser.component'; import {ReactiveFormsModule} from "@angular/forms"; -import {MatDialogModule} from "@angular/material/dialog"; +import {MatDialog, MatDialogModule} from "@angular/material/dialog"; +import {MatInputModule} from "@angular/material/input"; +import {MatFormFieldModule} from "@angular/material/form-field"; +import {MatIconModule} from "@angular/material/icon"; +import {NoopAnimationsModule} from "@angular/platform-browser/animations"; describe('NewuserComponent', () => { let component: NewuserComponent; @@ -11,7 +15,17 @@ describe('NewuserComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ declarations: [ NewuserComponent ], - imports: [ReactiveFormsModule, MatDialogModule] + imports: [ + MatDialogModule, + ReactiveFormsModule, + MatInputModule, + MatFormFieldModule, + MatIconModule, + NoopAnimationsModule + ], + providers: [ + MatDialog + ] }) .compileComponents(); })); diff --git a/src/app/superadmin/users/newuser/newuser.component.ts b/src/app/superadmin/users/newuser/newuser.component.ts index 75ea8e3bfb23faf5dd77b480a98af7dde78c8b7a..615a84f02f6078d92c9de1783d02cc77d9b2cefe 100644 --- a/src/app/superadmin/users/newuser/newuser.component.ts +++ b/src/app/superadmin/users/newuser/newuser.component.ts @@ -1,21 +1,14 @@ -import { MAT_DIALOG_DATA } from '@angular/material/dialog'; -import { Component, OnInit, Inject } from '@angular/core'; -import { FormGroup, FormBuilder, Validators } from '@angular/forms'; +import { Component } from '@angular/core'; +import {FormControl, FormGroup, Validators} from '@angular/forms'; @Component({ templateUrl: './newuser.component.html', styleUrls: ['./newuser.component.css'] }) -export class NewuserComponent implements OnInit { - newuserform: FormGroup; - constructor(private fb: FormBuilder, - @Inject(MAT_DIALOG_DATA) public data: any) { } - - ngOnInit() { - this.newuserform = this.fb.group({ - name: this.fb.control('', [Validators.required, Validators.minLength(3)]), - pw: this.fb.control('', [Validators.required, Validators.minLength(3)]) - }); - } +export class NewuserComponent { + newuserform = new FormGroup({ + name: new FormControl('', [Validators.required, Validators.minLength(3)]), + pw: new FormControl('', [Validators.required, Validators.minLength(3)]) + }); } diff --git a/src/app/superadmin/users/users.component.ts b/src/app/superadmin/users/users.component.ts index f7b652890398feef7259faf1393d5c196ee5a768..c12db9a6877a8621a6097e861195600e5e9ede6f 100644 --- a/src/app/superadmin/users/users.component.ts +++ b/src/app/superadmin/users/users.component.ts @@ -71,10 +71,7 @@ export class UsersComponent implements OnInit, OnDestroy { // *********************************************************************************** addObject() { const dialogRef = this.newuserDialog.open(NewuserComponent, { - width: '600px', - data: { - name: '' - } + width: '600px' }); dialogRef.afterClosed().subscribe(result => { @@ -112,9 +109,7 @@ export class UsersComponent implements OnInit, OnDestroy { } else { const dialogRef = this.newpasswordDialog.open(NewpasswordComponent, { width: '600px', - data: { - name: selectedRows[0]['name'] - } + data: selectedRows[0]['name'] }); dialogRef.afterClosed().subscribe(result => { diff --git a/src/app/superadmin/workspaces/editworkspace/editworkspace.component.html b/src/app/superadmin/workspaces/editworkspace/editworkspace.component.html index ea8a177147f15f24e8abc97b062d00d6f756d950..4d5d55c7bb77168ba3697bd3b07416c479da1e73 100644 --- a/src/app/superadmin/workspaces/editworkspace/editworkspace.component.html +++ b/src/app/superadmin/workspaces/editworkspace/editworkspace.component.html @@ -1,10 +1,10 @@ <form [formGroup]="editworkspaceform"> - <h1 mat-dialog-title>Arbeitsbereich "{{data.oldname}}" ändern</h1> + <h1 mat-dialog-title>Arbeitsbereich "{{data}}" ändern</h1> <mat-dialog-content> <p> <mat-form-field class="full-width"> - <input matInput formControlName="name" placeholder="Name" [value]="data.name"> + <input matInput formControlName="name" placeholder="Name" [value]="data"> </mat-form-field> </p> </mat-dialog-content> diff --git a/src/app/superadmin/workspaces/editworkspace/editworkspace.component.spec.ts b/src/app/superadmin/workspaces/editworkspace/editworkspace.component.spec.ts index e8338731ac2c5e7e0177f7bb09f87ef3caa53a2a..e3ac6df1235284ff7634fc7884ac3cad7d79e7fe 100644 --- a/src/app/superadmin/workspaces/editworkspace/editworkspace.component.spec.ts +++ b/src/app/superadmin/workspaces/editworkspace/editworkspace.component.spec.ts @@ -2,7 +2,10 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { EditworkspaceComponent } from './editworkspace.component'; import {ReactiveFormsModule} from "@angular/forms"; -import {MatDialogModule} from "@angular/material/dialog"; +import {MAT_DIALOG_DATA, MatDialog, MatDialogModule} from "@angular/material/dialog"; +import {MatInputModule} from "@angular/material/input"; +import {MatFormFieldModule} from "@angular/material/form-field"; +import {NoopAnimationsModule} from "@angular/platform-browser/animations"; describe('EditworkspaceComponent', () => { let component: EditworkspaceComponent; @@ -11,7 +14,17 @@ describe('EditworkspaceComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ declarations: [ EditworkspaceComponent ], - imports: [ReactiveFormsModule, MatDialogModule] + imports: [ + MatDialogModule, + ReactiveFormsModule, + MatInputModule, + MatFormFieldModule, + NoopAnimationsModule + ], + providers: [ + MatDialog, + { provide: MAT_DIALOG_DATA, useValue: 'VERA 2020' } + ] }) .compileComponents(); })); diff --git a/src/app/superadmin/workspaces/editworkspace/editworkspace.component.ts b/src/app/superadmin/workspaces/editworkspace/editworkspace.component.ts index 55013ca244f4916715a8f6c2baa906dc17fe08ed..819f1299c21c5d63872bc61973b2c64098899938 100644 --- a/src/app/superadmin/workspaces/editworkspace/editworkspace.component.ts +++ b/src/app/superadmin/workspaces/editworkspace/editworkspace.component.ts @@ -1,20 +1,16 @@ import { MAT_DIALOG_DATA } from '@angular/material/dialog'; -import { Component, OnInit, Inject } from '@angular/core'; -import { FormGroup, FormBuilder, Validators } from '@angular/forms'; +import { Component, Inject } from '@angular/core'; +import {FormGroup, Validators, FormControl} from '@angular/forms'; @Component({ templateUrl: './editworkspace.component.html', styleUrls: ['./editworkspace.component.css'] }) -export class EditworkspaceComponent implements OnInit { - editworkspaceform: FormGroup; +export class EditworkspaceComponent { + editworkspaceform = new FormGroup({ + name: new FormControl('', [Validators.required, Validators.minLength(3)]) + }); - constructor(private fb: FormBuilder, - @Inject(MAT_DIALOG_DATA) public data: any) { } - - ngOnInit() { - this.editworkspaceform = this.fb.group({ - name: this.fb.control('', [Validators.required, Validators.minLength(3)]) - }); - } + constructor( + @Inject(MAT_DIALOG_DATA) public data: string) { } } diff --git a/src/app/superadmin/workspaces/newworkspace/newworkspace.component.html b/src/app/superadmin/workspaces/newworkspace/newworkspace.component.html index 5f6e7c282656460604295e5c11967e1cdc23b421..00ad5848b717f75aba486ae82cb202cfe00d6294 100644 --- a/src/app/superadmin/workspaces/newworkspace/newworkspace.component.html +++ b/src/app/superadmin/workspaces/newworkspace/newworkspace.component.html @@ -4,7 +4,7 @@ <mat-dialog-content> <p> <mat-form-field class="full-width"> - <input matInput formControlName="name" placeholder="Name" [value]="data.name"> + <input matInput formControlName="name" placeholder="Name"> </mat-form-field> </p> <div class="infobox"> diff --git a/src/app/superadmin/workspaces/newworkspace/newworkspace.component.spec.ts b/src/app/superadmin/workspaces/newworkspace/newworkspace.component.spec.ts index 919ebd2ed369617b9dd2b21c0e6fa06e686425b3..0bf0a5c92355d84dcb866199a929a1cbde3b938d 100644 --- a/src/app/superadmin/workspaces/newworkspace/newworkspace.component.spec.ts +++ b/src/app/superadmin/workspaces/newworkspace/newworkspace.component.spec.ts @@ -2,16 +2,28 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { NewworkspaceComponent } from './newworkspace.component'; import {ReactiveFormsModule} from "@angular/forms"; -import {MatDialogModule} from "@angular/material/dialog"; +import {MatDialog, MatDialogModule} from "@angular/material/dialog"; +import {MatInputModule} from "@angular/material/input"; +import {MatFormFieldModule} from "@angular/material/form-field"; +import {NoopAnimationsModule} from "@angular/platform-browser/animations"; -describe('NewworkspaceComponent', () => { +describe('NewWorkspaceComponent', () => { let component: NewworkspaceComponent; let fixture: ComponentFixture<NewworkspaceComponent>; beforeEach(async(() => { TestBed.configureTestingModule({ declarations: [ NewworkspaceComponent ], - imports: [ReactiveFormsModule, MatDialogModule] + imports: [ + MatDialogModule, + ReactiveFormsModule, + MatInputModule, + MatFormFieldModule, + NoopAnimationsModule + ], + providers: [ + MatDialog + ] }) .compileComponents(); })); diff --git a/src/app/superadmin/workspaces/newworkspace/newworkspace.component.ts b/src/app/superadmin/workspaces/newworkspace/newworkspace.component.ts index 02cf6f563b7dd474d94a3fd2546591baf9aaef28..6fd83574628b7214ad4c8f9447dcb25ba5520428 100644 --- a/src/app/superadmin/workspaces/newworkspace/newworkspace.component.ts +++ b/src/app/superadmin/workspaces/newworkspace/newworkspace.component.ts @@ -1,20 +1,12 @@ -import { MAT_DIALOG_DATA } from '@angular/material/dialog'; -import { Component, OnInit, Inject } from '@angular/core'; -import { FormGroup, FormBuilder, Validators } from '@angular/forms'; +import { Component } from '@angular/core'; +import {FormGroup, Validators, FormControl} from '@angular/forms'; @Component({ templateUrl: './newworkspace.component.html', styleUrls: ['./newworkspace.component.css'] }) -export class NewworkspaceComponent implements OnInit { - newworkspaceform: FormGroup; - - constructor(private fb: FormBuilder, - @Inject(MAT_DIALOG_DATA) public data: any) { } - - ngOnInit() { - this.newworkspaceform = this.fb.group({ - name: this.fb.control('', [Validators.required, Validators.minLength(3)]) - }); - } +export class NewworkspaceComponent { + newworkspaceform = new FormGroup({ + name: new FormControl('', [Validators.required, Validators.minLength(3)]) + }) } diff --git a/src/app/superadmin/workspaces/workspaces.component.ts b/src/app/superadmin/workspaces/workspaces.component.ts index e7ff8f3f283ee9a7e390d97667a6a38e30a8e71f..72ffe0ab78750b0de8a052e83ab5886947b45e02 100644 --- a/src/app/superadmin/workspaces/workspaces.component.ts +++ b/src/app/superadmin/workspaces/workspaces.component.ts @@ -112,10 +112,7 @@ export class WorkspacesComponent implements OnInit, OnDestroy { } else { const dialogRef = this.editworkspaceDialog.open(EditworkspaceComponent, { width: '600px', - data: { - name: selectedRows[0].name, - oldname: selectedRows[0].name - } + data: selectedRows[0].name }); dialogRef.afterClosed().subscribe(result => { diff --git a/src/app/sys-check/environment-check/environment-check.component.spec.ts b/src/app/sys-check/environment-check/environment-check.component.spec.ts index bd2f643af7dd6a00cc24289814b4fdc278375663..c1b1ed9951f6bff845beb5b87b09e93fa3224a54 100644 --- a/src/app/sys-check/environment-check/environment-check.component.spec.ts +++ b/src/app/sys-check/environment-check/environment-check.component.spec.ts @@ -1,6 +1,7 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { EnvironmentCheckComponent } from './environment-check.component'; +import {MatCardModule} from "@angular/material/card"; describe('EnvironmentCheckComponent', () => { let component: EnvironmentCheckComponent; @@ -8,7 +9,8 @@ describe('EnvironmentCheckComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ EnvironmentCheckComponent ] + declarations: [ EnvironmentCheckComponent ], + imports: [MatCardModule] }) .compileComponents(); })); diff --git a/src/app/sys-check/report/report.component.ts b/src/app/sys-check/report/report.component.ts index 9a4d111f7dda2d8a6d56db5f9b3902ec895d7d43..8e419413f659c5ed415eb42e55fd6170bada1bf7 100644 --- a/src/app/sys-check/report/report.component.ts +++ b/src/app/sys-check/report/report.component.ts @@ -54,33 +54,34 @@ export class ReportComponent { const dialogRef = this.saveDialog.open(SaveReportComponent, { width: '500px', - height: '600px', - data: 'jojo' + height: '600px' }); dialogRef.afterClosed().subscribe(result => { - if (result !== false) { - const reportKey = result.get('key').value as string; - const reportTitle = result.get('title').value as string; - const cd = this.ds.checkConfig$.getValue(); - console.log('result', result); - this.bs.saveReport( - cd.workspaceId, - cd.name, - { - keyPhrase: reportKey, - title: reportTitle, - environment: this.ds.environmentData$.getValue(), - network: this.ds.networkData$.getValue(), - questionnaire: this.ds.questionnaireData$.getValue(), - unit: this.ds.unitData$.getValue() + if (typeof result !== 'undefined') { + if (result !== false) { + const reportKey = result.get('key').value as string; + const reportTitle = result.get('title').value as string; + const cd = this.ds.checkConfig$.getValue(); + console.log('result', result); + this.bs.saveReport( + cd.workspaceId, + cd.name, + { + keyPhrase: reportKey, + title: reportTitle, + environment: this.ds.environmentData$.getValue(), + network: this.ds.networkData$.getValue(), + questionnaire: this.ds.questionnaireData$.getValue(), + unit: this.ds.unitData$.getValue() + } + ).subscribe((result: boolean|ServerError) => { + if (result instanceof ServerError) { + this.snackBar.open('Konnte Bericht nicht speichern.', '', {duration: 3000}); + } else { + this.snackBar.open('Bericht gespeichert.', '', {duration: 3000}); } - ).subscribe((result: boolean|ServerError) => { - if (result instanceof ServerError) { - this.snackBar.open('Konnte Bericht nicht speichern.', '', {duration: 3000}); - } else { - this.snackBar.open('Bericht gespeichert.', '', {duration: 3000}); - } - }); + }); + } } }); } diff --git a/src/app/sys-check/report/save-report/save-report.component.spec.ts b/src/app/sys-check/report/save-report/save-report.component.spec.ts index c6331a856e54dec2e0925a124c58a58ae272e6d8..e996a0b2f01cbb15f470a65ace527cd12d45dbea 100644 --- a/src/app/sys-check/report/save-report/save-report.component.spec.ts +++ b/src/app/sys-check/report/save-report/save-report.component.spec.ts @@ -1,7 +1,10 @@ import { SaveReportComponent } from './save-report.component'; import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import {ReactiveFormsModule} from "@angular/forms"; -import {MatDialogModule} from "@angular/material/dialog"; +import {MatDialog, MatDialogModule} from "@angular/material/dialog"; +import {MatInputModule} from "@angular/material/input"; +import {MatFormFieldModule} from "@angular/material/form-field"; +import {NoopAnimationsModule} from "@angular/platform-browser/animations"; describe('SaveReportComponent', () => { let component: SaveReportComponent; @@ -10,7 +13,16 @@ describe('SaveReportComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ declarations: [ SaveReportComponent ], - imports: [ReactiveFormsModule, MatDialogModule] + imports: [ + MatDialogModule, + ReactiveFormsModule, + MatInputModule, + MatFormFieldModule, + NoopAnimationsModule + ], + providers: [ + MatDialog, + ] }) .compileComponents(); })); diff --git a/src/app/sys-check/report/save-report/save-report.component.ts b/src/app/sys-check/report/save-report/save-report.component.ts index 3c92665eed03b582ba1ffc09f0946b63f73d168d..f5c5f7ed5ef7224ef8de832ed432b1f001a80ff8 100644 --- a/src/app/sys-check/report/save-report/save-report.component.ts +++ b/src/app/sys-check/report/save-report/save-report.component.ts @@ -1,22 +1,15 @@ -import { FormBuilder, FormGroup, Validators } from '@angular/forms'; -import { Component, OnInit, Inject } from '@angular/core'; -import {MAT_DIALOG_DATA} from "@angular/material/dialog"; +import { FormControl, FormGroup, Validators} from '@angular/forms'; +import { Component } from '@angular/core'; @Component({ selector: 'app-save-report', templateUrl: './save-report.component.html', styleUrls: ['./save-report.component.css'] }) -export class SaveReportComponent implements OnInit { - savereportform: FormGroup; - constructor(private fb: FormBuilder, - @Inject(MAT_DIALOG_DATA) public data: string) { } - - ngOnInit() { - this.savereportform = this.fb.group({ - title: this.fb.control('', [Validators.required, Validators.minLength(3)]), - key: this.fb.control('', [Validators.required, Validators.minLength(3)]) - }); - } +export class SaveReportComponent { + savereportform = new FormGroup({ + title: new FormControl('', [Validators.required, Validators.minLength(3)]), + key: new FormControl('', [Validators.required, Validators.minLength(3)]) + }); } diff --git a/src/app/test-controller/review-dialog/review-dialog.component.spec.ts b/src/app/test-controller/review-dialog/review-dialog.component.spec.ts index ced09f8527297eed8b15452cb3b4fe1c2227b8d3..6946039c52f5eddeacf513b92575838147cc88eb 100644 --- a/src/app/test-controller/review-dialog/review-dialog.component.spec.ts +++ b/src/app/test-controller/review-dialog/review-dialog.component.spec.ts @@ -2,16 +2,43 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { ReviewDialogComponent } from './review-dialog.component'; import {ReactiveFormsModule} from "@angular/forms"; -import {MatDialogModule} from "@angular/material/dialog"; +import {MAT_DIALOG_DATA, MatDialog, MatDialogModule} from "@angular/material/dialog"; +import {MatRadioModule} from "@angular/material/radio"; +import {MatCheckboxModule} from "@angular/material/checkbox"; +import {MatInputModule} from "@angular/material/input"; +import {MatFormFieldModule} from "@angular/material/form-field"; +import {ReviewDialogData} from "../test-controller.interfaces"; +import {MatIconModule} from "@angular/material/icon"; +import {NoopAnimationsModule} from "@angular/platform-browser/animations"; describe('ReviewDialogComponent', () => { let component: ReviewDialogComponent; let fixture: ComponentFixture<ReviewDialogComponent>; + const matDialogDataStub = <ReviewDialogData> { + loginname: 'loginname', + bookletname: 'bookletname', + unitDbKey: 'unitDbKey', + unitTitle: 'unitTitle' + }; + beforeEach(async(() => { TestBed.configureTestingModule({ declarations: [ ReviewDialogComponent ], - imports: [ReactiveFormsModule, MatDialogModule] + imports: [ + MatDialogModule, + ReactiveFormsModule, + MatRadioModule, + MatInputModule, + MatFormFieldModule, + MatIconModule, + MatCheckboxModule, + NoopAnimationsModule + ], + providers: [ + MatDialog, + { provide: MAT_DIALOG_DATA, useValue: matDialogDataStub } + ] }) .compileComponents(); })); diff --git a/src/app/test-controller/review-dialog/review-dialog.component.ts b/src/app/test-controller/review-dialog/review-dialog.component.ts index 11ab351a46de3bbb4cd1567b4019b8f4697c267b..721ac80416477b2858b8f6527b41d109447aeea5 100644 --- a/src/app/test-controller/review-dialog/review-dialog.component.ts +++ b/src/app/test-controller/review-dialog/review-dialog.component.ts @@ -1,27 +1,23 @@ -import { FormGroup, FormBuilder, Validators } from '@angular/forms'; +import {FormGroup, Validators, FormControl} from '@angular/forms'; import { MAT_DIALOG_DATA } from '@angular/material/dialog'; -import { Component, OnInit, Inject } from '@angular/core'; +import { Component, Inject } from '@angular/core'; +import {ReviewDialogData} from "../test-controller.interfaces"; @Component({ templateUrl: './review-dialog.component.html' }) -export class ReviewDialogComponent implements OnInit { - reviewform: FormGroup; +export class ReviewDialogComponent { + reviewform = new FormGroup({ + target: new FormControl ('b', Validators.required), + priority: new FormControl('', Validators.required), + tech: new FormControl(''), + content: new FormControl(''), + design: new FormControl(''), + entry: new FormControl('', Validators.required) + }); constructor( - private fb: FormBuilder, - @Inject(MAT_DIALOG_DATA) public data: any) { } - - ngOnInit() { - this.reviewform = this.fb.group({ - target: this.fb.control('b', Validators.required), - priority: this.fb.control('', Validators.required), - tech: this.fb.control(''), - content: this.fb.control(''), - design: this.fb.control(''), - entry: this.fb.control('', Validators.required) - }); - } + @Inject(MAT_DIALOG_DATA) public data: ReviewDialogData) { } getCategories(): string { let myreturn = ''; diff --git a/src/app/test-controller/start-lock-input/start-lock-input.component.html b/src/app/test-controller/start-lock-input/start-lock-input.component.html index f2b53dca8f993d86052842409839849e698079dc..f9d8b6d92355c45ab1d249650eafabe54c0a9bba 100644 --- a/src/app/test-controller/start-lock-input/start-lock-input.component.html +++ b/src/app/test-controller/start-lock-input/start-lock-input.component.html @@ -1,18 +1,19 @@ -<form [formGroup]="startkeyform" fxLayout="column"> +<form #matform [formGroup]="startkeyform" fxLayout="column"> <h1 mat-dialog-title>{{ data.title }}</h1> <mat-dialog-content> <p>{{ data.prompt }}</p> <mat-form-field *ngFor="let c of data.codes" fxLayout="column"> <p>{{ c.prompt }}</p> - <input matInput [formControlName]="c.testletId" [(ngModel)]="c.value" (keyup.enter)="close()"> + <input matInput [formControlName]="c.testletId" (keyup.enter)="matform.submit()"> </mat-form-field> </mat-dialog-content> <mat-dialog-actions> - <button mat-raised-button #okButton color="primary" - [disabled]="startkeyform.invalid" - type="submit" [mat-dialog-close]="data.codes">Weiter</button> + <button mat-raised-button color="primary" + [disabled]="!startkeyform.valid" + type="submit" + [mat-dialog-close]="startkeyform">Weiter</button> <button mat-raised-button [mat-dialog-close]="false">Abbrechen</button> </mat-dialog-actions> </form> diff --git a/src/app/test-controller/start-lock-input/start-lock-input.component.spec.ts b/src/app/test-controller/start-lock-input/start-lock-input.component.spec.ts index b53a1a085e2e900952a9e07b7ff61ca1667619bc..af6a17e5e687dae7fea85c7c3812316de6def0ee 100644 --- a/src/app/test-controller/start-lock-input/start-lock-input.component.spec.ts +++ b/src/app/test-controller/start-lock-input/start-lock-input.component.spec.ts @@ -2,16 +2,52 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { StartLockInputComponent } from './start-lock-input.component'; import {ReactiveFormsModule} from "@angular/forms"; -import {MAT_DIALOG_DATA, MatDialogModule, MatDialogRef} from "@angular/material/dialog"; +import {MAT_DIALOG_DATA, MatDialog, MatDialogModule, MatDialogRef} from "@angular/material/dialog"; +import {StartLockData} from "../test-controller.interfaces"; +import {MatInputModule} from "@angular/material/input"; +import {MatFormFieldModule} from "@angular/material/form-field"; +import {MatIconModule} from "@angular/material/icon"; +import {NoopAnimationsModule} from "@angular/platform-browser/animations"; describe('StartLockInputComponent', () => { let component: StartLockInputComponent; let fixture: ComponentFixture<StartLockInputComponent>; beforeEach(async(() => { + const matDialogRefStub = {}; + const matDialogDataStub = <StartLockData>{ + title: 'title', + prompt: 'prompt', + codes: [ + { + testletId: 'testletA', + prompt: 'promptA', + code: 'codeA', + value: 'valueA' + }, + { + testletId: 'testletB', + prompt: 'promptB', + code: 'codeB', + value: 'valueB' + } + ] + }; TestBed.configureTestingModule({ - imports: [ReactiveFormsModule, MatDialogModule], - declarations: [ StartLockInputComponent, MatDialogRef, MAT_DIALOG_DATA ] + declarations: [ StartLockInputComponent ], + imports: [ + MatDialogModule, + ReactiveFormsModule, + MatInputModule, + MatFormFieldModule, + MatIconModule, + NoopAnimationsModule + ], + providers: [ + MatDialog, + { provide: MatDialogRef, useValue: matDialogRefStub }, + { provide: MAT_DIALOG_DATA, useValue: matDialogDataStub } + ] }) .compileComponents(); })); diff --git a/src/app/test-controller/start-lock-input/start-lock-input.component.ts b/src/app/test-controller/start-lock-input/start-lock-input.component.ts index 122019620e0d53c985f4bbfc8916b0b76a07b69b..6de789c7a904ab7e097964ed07a8455877ab580b 100644 --- a/src/app/test-controller/start-lock-input/start-lock-input.component.ts +++ b/src/app/test-controller/start-lock-input/start-lock-input.component.ts @@ -1,29 +1,22 @@ -import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; -import { FormBuilder, FormGroup, Validators } from '@angular/forms'; -import { Component, OnInit, Inject } from '@angular/core'; -import { StartLockData } from '../test-controller.interfaces'; - +import {Component, Inject} from '@angular/core'; +import {MAT_DIALOG_DATA} from '@angular/material/dialog'; +import {FormControl, FormGroup, Validators} from "@angular/forms"; +import {StartLockData} from "../test-controller.interfaces"; @Component({ templateUrl: './start-lock-input.component.html', styleUrls: ['./start-lock-input.component.css'] }) -export class StartLockInputComponent implements OnInit { +export class StartLockInputComponent { startkeyform: FormGroup; - constructor(private fb: FormBuilder, - private dialogRef: MatDialogRef<StartLockInputComponent>, - @Inject(MAT_DIALOG_DATA) public data: StartLockData) { } + constructor( + @Inject(MAT_DIALOG_DATA) public data: StartLockData) { - ngOnInit() { - const controlsConfig = {}; + const myFormControls = {}; this.data.codes.forEach(c => { - controlsConfig[c.testletId] = this.fb.control('', [Validators.required, Validators.minLength(3)]); + myFormControls[c.testletId] = new FormControl('', [Validators.required, Validators.minLength(3)]); }); - this.startkeyform = this.fb.group(controlsConfig); - } - - close() { - this.dialogRef.close(this.data.codes); + this.startkeyform = new FormGroup(myFormControls); } } diff --git a/src/app/test-controller/test-controller.component.ts b/src/app/test-controller/test-controller.component.ts index 3dde9f9616e9319eef5d0fef6bb352d7abfce65d..0e2c096e415e0fd692187f3b0f0f50ed71fdf9da 100644 --- a/src/app/test-controller/test-controller.component.ts +++ b/src/app/test-controller/test-controller.component.ts @@ -7,7 +7,15 @@ import { BackendService } from './backend.service'; import { TestControllerService } from './test-controller.service'; import { Component, OnInit, OnDestroy, Inject } from '@angular/core'; import { UnitDef, Testlet, EnvironmentData, MaxTimerData } from './test-controller.classes'; -import { LastStateKey, LogEntryKey, BookletData, UnitData, MaxTimerDataType, TaggedString } from './test-controller.interfaces'; +import { + LastStateKey, + LogEntryKey, + BookletData, + UnitData, + MaxTimerDataType, + TaggedString, + ReviewDialogData +} from './test-controller.interfaces'; import { Subscription, Observable, of, from } from 'rxjs'; import { switchMap, concatMap } from 'rxjs/operators'; import { CustomtextService, ServerError } from 'iqb-components'; @@ -603,7 +611,7 @@ export class TestControllerComponent implements OnInit, OnDestroy { } else { const dialogRef = this.reviewDialog.open(ReviewDialogComponent, { width: '700px', - data: { + data: <ReviewDialogData>{ loginname: this.tcs.loginname, bookletname: this.tcs.rootTestlet.title, unitTitle: this.tcs.currentUnitTitle, diff --git a/src/app/test-controller/test-controller.interfaces.ts b/src/app/test-controller/test-controller.interfaces.ts index 18809f46f56c6490d3d8bb9c7795bf6850f84233..c3cf6e1e52c444e8368cc861b88984b7ad3af7da 100644 --- a/src/app/test-controller/test-controller.interfaces.ts +++ b/src/app/test-controller/test-controller.interfaces.ts @@ -105,3 +105,10 @@ export interface PageData { type: '#next' | '#previous' | '#goto'; disabled: boolean; } + +export interface ReviewDialogData { + loginname: string; + bookletname: string; + unitDbKey: string; + unitTitle: string; +} diff --git a/src/app/test-controller/unithost/unit-routing-guards.ts b/src/app/test-controller/unithost/unit-routing-guards.ts index 1e753b594577f71d7d00c3ebb20d2b8bd4b1920c..0a70ba93475ee022711047697a11e8545e7f9d1d 100644 --- a/src/app/test-controller/unithost/unit-routing-guards.ts +++ b/src/app/test-controller/unithost/unit-routing-guards.ts @@ -131,10 +131,15 @@ export class UnitActivateGuard implements CanActivate { if ((typeof result === 'undefined') || (result === false)) { return of(false); } else { - const codeData = result as CodeInputData[]; let codesOk = true; - for (const c of codeData) { - if (c.value.toUpperCase().trim() !== c.code) { + for (const c of myCodes) { + const testeeInput = result[c.testletId]; + if (testeeInput) { + if (c.value.toUpperCase().trim() !== testeeInput.toUpperCase().trim()) { + codesOk = false; + break; + } + } else { codesOk = false; break; }