Browse Source

Created a new GfPromptDialogComponent to extend existing notifcation service with an input dialog #3955

pull/4117/head
Brandon Wortman 9 months ago
parent
commit
a3097917e2
No known key found for this signature in database GPG Key ID: C63DB7DA05AEC086
  1. 46
      apps/client/src/app/core/notification/prompt-dialog/prompt-dialog.component.ts
  2. 21
      apps/client/src/app/core/notification/prompt-dialog/prompt-dialog.html

46
apps/client/src/app/core/notification/prompt-dialog/prompt-dialog.component.ts

@ -0,0 +1,46 @@
import { CommonModule } from '@angular/common';
import { Component } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { MatButtonModule } from '@angular/material/button';
import { MatDialogModule, MatDialogRef } from '@angular/material/dialog';
import { MatFormFieldModule } from '@angular/material/form-field';
import { MatInputModule } from '@angular/material/input';
@Component({
imports: [
CommonModule,
FormsModule,
MatButtonModule,
MatDialogModule,
MatFormFieldModule,
MatInputModule
],
selector: 'gf-prompt-dialog',
standalone: true,
templateUrl: './prompt-dialog.html'
})
export class GfPromptDialogComponent {
public confirmLabel: string;
public defaultValue: string;
public discardLabel: string;
public title: string;
public value: string;
public valueLabel: string;
public constructor(public dialogRef: MatDialogRef<GfPromptDialogComponent>) {}
public initialize(aParams: {
confirmLabel?: string;
defaultValue?: string;
discardLabel?: string;
title: string;
valueLabel?: string;
}) {
this.confirmLabel = aParams.confirmLabel;
this.defaultValue = aParams.defaultValue;
this.discardLabel = aParams.discardLabel;
this.title = aParams.title;
this.valueLabel = aParams.valueLabel;
this.value = this.defaultValue;
}
}

21
apps/client/src/app/core/notification/prompt-dialog/prompt-dialog.html

@ -0,0 +1,21 @@
@if (title) {
<div mat-dialog-title [innerHTML]="title"></div>
}
<div mat-dialog-content style="padding: 20px">
<mat-form-field appearance="outline" class="w-100">
@if (valueLabel) {
<mat-label>{{ valueLabel }}</mat-label>
}
<input matInput [(ngModel)]="value" />
</mat-form-field>
</div>
<div align="end" mat-dialog-actions>
<button mat-button (click)="dialogRef.close('discard')">
{{ discardLabel }}
</button>
<button color="primary" mat-flat-button (click)="dialogRef.close(value)">
{{ confirmLabel }}
</button>
</div>
Loading…
Cancel
Save