src/app/dialogs/save-graph/save-graph.dialog.ts
Dialog that allows changing name and description of a graph.
styleUrls | ./save-graph.dialog.scss |
templateUrl | ./save-graph.dialog.html |
Properties |
|
Methods |
|
Public
constructor(dialogRef: MatDialogRef<SaveGraphDialog>, graph: FOLGraph)
|
|||||||||
Parameters :
|
Public closeDialog |
closeDialog()
|
Returns :
void
|
Public updatedGraph |
updatedGraph()
|
Returns :
FOLGraph | undefined
|
Public Readonly graph |
Type : FOLGraph
|
Decorators :
@Inject(MAT_DIALOG_DATA)
|
Public Readonly graphDescription |
Type : UntypedFormControl
|
Public Readonly graphName |
Type : UntypedFormControl
|
import { Component, Inject } from '@angular/core';
import { UntypedFormControl, Validators } from '@angular/forms';
import { MAT_LEGACY_DIALOG_DATA as MAT_DIALOG_DATA, MatLegacyDialogRef as MatDialogRef } from '@angular/material/legacy-dialog';
import { FOLGraph } from 'src/app/model/domain/fol.graph';
/**
* Dialog that allows changing name and description of a graph.
*/
@Component({
templateUrl: './save-graph.dialog.html',
styleUrls: ['./save-graph.dialog.scss'],
})
export class SaveGraphDialog {
public readonly graphName: UntypedFormControl;
public readonly graphDescription: UntypedFormControl;
public constructor(
private readonly dialogRef: MatDialogRef<SaveGraphDialog>,
@Inject(MAT_DIALOG_DATA) public readonly graph: FOLGraph,
) {
this.graphName = new UntypedFormControl(graph.name, Validators.required);
this.graphDescription = new UntypedFormControl(graph.description);
}
public updatedGraph(): FOLGraph | undefined {
if (this.graphName.invalid) {
return undefined;
}
return { ...this.graph, name: this.graphName.value, description: this.graphDescription.value, lastEdit: Date.now() };
}
public closeDialog(): void {
this.dialogRef.close();
}
}
<div mat-dialog-content>
<mat-form-field>
<mat-label>{{ 'misc.name' | translate }}</mat-label>
<input matInput [formControl]="graphName" placeholder="{{'misc.name' | translate}}" required />
</mat-form-field>
<mat-form-field>
<mat-label>{{ 'misc.description' | translate }}</mat-label>
<input matInput [formControl]="graphDescription" placeholder="{{'misc.description' | translate}}" />
</mat-form-field>
</div>
<div mat-dialog-actions>
<button mat-raised-button (click)="closeDialog()" color="warn">
<mat-icon>cancel</mat-icon>
{{ 'actions.cancel' | translate }}
</button>
<button mat-raised-button [mat-dialog-close]="updatedGraph()" [disabled]="graphName.invalid" color="primary">
<mat-icon>save</mat-icon>
{{ 'actions.save' | translate }}
</button>
</div>
./save-graph.dialog.scss
mat-form-field {
width: 100%;
}
.mat-dialog-actions {
justify-content: flex-end;
}