diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 4d258b9c3dd5b1979823b1027fc39a53b86c51a4..3937566e8a94a1ffdd708874024d2e2bff766dcb 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -90,6 +90,7 @@ import { TranslateHttpLoader } from '@ngx-translate/http-loader'; import { MarkdownModule } from 'ngx-markdown'; import { MarkdownToolbarComponent } from './components/fragments/markdown-toolbar/markdown-toolbar.component'; import { MarkdownHelpDialogComponent } from './components/dialogs/markdown-help-dialog/markdown-help-dialog.component'; +import { GenericDataDialogComponent } from './components/dialogs/generic-data-dialog/generic-data-dialog.component'; @NgModule({ declarations: [ @@ -129,7 +130,8 @@ import { MarkdownHelpDialogComponent } from './components/dialogs/markdown-help- ContentDeleteComponent, FeedbackBarometerPageComponent, MarkdownToolbarComponent, - MarkdownHelpDialogComponent + MarkdownHelpDialogComponent, + GenericDataDialogComponent ], entryComponents: [ RegisterComponent, @@ -143,7 +145,8 @@ import { MarkdownHelpDialogComponent } from './components/dialogs/markdown-help- ContentTextCreatorComponent, ContentYesNoCreatorComponent, ContentDeleteComponent, - MarkdownHelpDialogComponent + MarkdownHelpDialogComponent, + GenericDataDialogComponent ], imports: [ AppRoutingModule, diff --git a/src/app/components/dialogs/generic-data-dialog/generic-data-dialog.component.html b/src/app/components/dialogs/generic-data-dialog/generic-data-dialog.component.html new file mode 100644 index 0000000000000000000000000000000000000000..d3266006431a4366608e956eb50606db9151c123 --- /dev/null +++ b/src/app/components/dialogs/generic-data-dialog/generic-data-dialog.component.html @@ -0,0 +1,7 @@ +<form (ngSubmit)="submit()"> + <mat-form-field class="input-block" *ngFor="let input of data"> + <input matInput name="{{input.id}}" [(ngModel)]="input.value" placeholder="{{input.label}}" /> + </mat-form-field> + + <button mat-raised-button color="primary" type="submit">Submit</button> +</form> diff --git a/src/app/components/dialogs/generic-data-dialog/generic-data-dialog.component.scss b/src/app/components/dialogs/generic-data-dialog/generic-data-dialog.component.scss new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/src/app/components/dialogs/generic-data-dialog/generic-data-dialog.component.spec.ts b/src/app/components/dialogs/generic-data-dialog/generic-data-dialog.component.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..0b36dd0c611be58f8eb83968436765f8cc93d736 --- /dev/null +++ b/src/app/components/dialogs/generic-data-dialog/generic-data-dialog.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { GenericDataDialogComponent } from './generic-data-dialog.component'; + +describe('GenericDataDialogComponent', () => { + let component: GenericDataDialogComponent; + let fixture: ComponentFixture<GenericDataDialogComponent>; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ GenericDataDialogComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(GenericDataDialogComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/components/dialogs/generic-data-dialog/generic-data-dialog.component.ts b/src/app/components/dialogs/generic-data-dialog/generic-data-dialog.component.ts new file mode 100644 index 0000000000000000000000000000000000000000..8355c2d5ae9850452be224a3b44badb23f51b5f3 --- /dev/null +++ b/src/app/components/dialogs/generic-data-dialog/generic-data-dialog.component.ts @@ -0,0 +1,31 @@ +import { Component, Inject } from '@angular/core'; +import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material'; + +@Component({ + selector: 'app-generic-data-dialog', + templateUrl: './generic-data-dialog.component.html', + styleUrls: ['./generic-data-dialog.component.scss'] +}) +export class GenericDataDialogComponent { + + constructor(public dialogRef: MatDialogRef<GenericDataDialogComponent>, + @Inject(MAT_DIALOG_DATA) public data: Data[]) { + } + + submit(): void { + this.dialogRef.close(this.data); + } +} + +export class Data { + id: string; + label: string; + value: string; + + // TODO: constructor needed? + constructor(id: string, label: string, value?: string) { + this.id = id; + this.label = label; + this.value = value; + } +}