-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1127 from DSD-DBS/feat-add-custom-input-dialog
feat: Add custom input dialog
- Loading branch information
Showing
12 changed files
with
294 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
frontend/src/app/helpers/input-dialog/input-dialog.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<!-- | ||
~ SPDX-FileCopyrightText: Copyright DB Netz AG and the capella-collab-manager contributors | ||
~ SPDX-License-Identifier: Apache-2.0 | ||
--> | ||
|
||
<div class="dialog"> | ||
<form [formGroup]="form" (submit)="onSubmit()"> | ||
<h2>{{ data.title }}</h2> | ||
<p>{{ data.text }}</p> | ||
|
||
<mat-form-field class="w-full" appearance="fill"> | ||
<mat-label>Reason</mat-label> | ||
<textarea rows="6" matInput formControlName="result"></textarea> | ||
<mat-error *ngIf="form.controls.result.errors?.required"> | ||
Please enter something or click on cancel! | ||
</mat-error> | ||
</mat-form-field> | ||
<div class="flex justify-between"> | ||
<button | ||
mat-flat-button | ||
color="primary" | ||
type="button" | ||
(click)="onCancel()" | ||
> | ||
Cancel | ||
</button> | ||
<button | ||
mat-flat-button | ||
color="primary" | ||
type="submit" | ||
[disabled]="!form.valid" | ||
> | ||
Confirm | ||
</button> | ||
</div> | ||
</form> | ||
</div> |
49 changes: 49 additions & 0 deletions
49
frontend/src/app/helpers/input-dialog/input-dialog.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* SPDX-FileCopyrightText: Copyright DB Netz AG and the capella-collab-manager contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { Component, Inject, OnInit } from '@angular/core'; | ||
import { FormControl, FormGroup, Validators } from '@angular/forms'; | ||
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; | ||
|
||
export interface InputDialogData { | ||
title: string; | ||
text: string; | ||
} | ||
|
||
export interface InputDialogResult { | ||
text?: string; | ||
success: boolean; | ||
} | ||
|
||
@Component({ | ||
selector: 'app-input-dialog', | ||
templateUrl: './input-dialog.component.html', | ||
}) | ||
export class InputDialogComponent implements OnInit { | ||
form = new FormGroup({ | ||
result: new FormControl<string | undefined>(undefined, [ | ||
Validators.required, | ||
]), | ||
}); | ||
|
||
constructor( | ||
public dialogRef: MatDialogRef<InputDialogComponent, InputDialogResult>, | ||
@Inject(MAT_DIALOG_DATA) public data: InputDialogData, | ||
) {} | ||
|
||
ngOnInit(): void { | ||
this.dialogRef.updateSize('500px'); | ||
} | ||
|
||
onSubmit(): void { | ||
if (this.form.valid) { | ||
this.dialogRef.close({ text: this.form.value.result!, success: true }); | ||
} | ||
} | ||
|
||
onCancel(): void { | ||
this.dialogRef.close({ text: undefined, success: false }); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.