adjusted confirmation dialog component for reusability
This commit is contained in:
@@ -37,11 +37,12 @@
|
||||
</div>
|
||||
|
||||
<div class="account-card">
|
||||
<div class="avatar">M</div>
|
||||
<div class="avatar">{{ (credentialService.login | async)?.charAt(0) }}</div>
|
||||
<div>
|
||||
<strong>{{
|
||||
(credentialService.login | async) || 'Max Mustermann'
|
||||
}}</strong>
|
||||
<strong>{{ credentialService.organizationName | async }}</strong>
|
||||
<span>Startup Coach</span>
|
||||
</div>
|
||||
<mat-icon>expand_more</mat-icon>
|
||||
@@ -51,7 +52,7 @@
|
||||
<button
|
||||
class="utility-link"
|
||||
type="button"
|
||||
(click)="credentialService.logoutAcount()">
|
||||
(click)="onLogout()">
|
||||
<mat-icon>logout</mat-icon>
|
||||
<span>Abmelden</span>
|
||||
</button>
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
import { Component, computed } from '@angular/core';
|
||||
import { Component, computed ,inject} from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { Router, RouterLink, RouterLinkActive } from '@angular/router';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatListModule } from '@angular/material/list';
|
||||
import { CredentialService } from '../../services/credential.service';
|
||||
import { MatProgressBarModule } from '@angular/material/progress-bar';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { ConfirmationDialogComponent } from '../confirmation-dialog/confirmation-dialog.component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-menu',
|
||||
@@ -32,7 +34,7 @@ export class AppMenuComponent {
|
||||
label: 'Personen',
|
||||
icon: 'groups',
|
||||
route: '/persons',
|
||||
queryParams: { institutionName: 'University of Duisburg-Essen' },
|
||||
queryParams: { institutionName: this.credentialService.organizationName.value },
|
||||
disabled: false,
|
||||
},
|
||||
];
|
||||
@@ -43,4 +45,21 @@ export class AppMenuComponent {
|
||||
) {}
|
||||
|
||||
isNavigating = computed(() => !!this.router.currentNavigation());
|
||||
private readonly dialog = inject(MatDialog);
|
||||
|
||||
onLogout() {
|
||||
const dialogRef = this.dialog.open(ConfirmationDialogComponent, {
|
||||
data: {
|
||||
title: 'Abmelden',
|
||||
message: 'Möchtest Du Dich wirklich abmelden?',
|
||||
confirmText: 'Abmelden',
|
||||
cancelText: 'Abbrechen',
|
||||
},
|
||||
});
|
||||
|
||||
dialogRef.componentInstance.confirmDelete.subscribe(() => {
|
||||
this.credentialService.logoutAcount();
|
||||
this.router.navigate(['/login']);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
<h3 mat-dialog-title>Daten löschen</h3>
|
||||
<mat-dialog-content
|
||||
>Bist Du sicher, dass Du die Daten löschen möchtest? Diesen Vorgang kannst Du
|
||||
nicht mehr rückgängig machen.</mat-dialog-content
|
||||
>
|
||||
<h3 mat-dialog-title>{{ data.title }}</h3>
|
||||
<mat-dialog-content>{{ data.message }}</mat-dialog-content>
|
||||
|
||||
<mat-dialog-actions class="action">
|
||||
<button mat-flat-button class="secondary-button" (click)="onCancelClick()">
|
||||
Abbrechen
|
||||
{{ data.cancelText }}
|
||||
</button>
|
||||
<button mat-flat-button class="primary-button" (click)="onConfirmClick()">
|
||||
Löschen
|
||||
{{ data.confirmText }}
|
||||
</button>
|
||||
</mat-dialog-actions>
|
||||
|
||||
@@ -1,18 +1,25 @@
|
||||
import { Component, EventEmitter } from '@angular/core';
|
||||
import { Component, EventEmitter, inject, Inject, Optional } from '@angular/core';
|
||||
import {
|
||||
MatDialogRef,
|
||||
MatDialogActions,
|
||||
MatDialogClose,
|
||||
MatDialogTitle,
|
||||
MatDialogContent,
|
||||
MAT_DIALOG_DATA,
|
||||
} from '@angular/material/dialog';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
|
||||
export interface ConfirmationData {
|
||||
title: string;
|
||||
message: string;
|
||||
confirmText: string;
|
||||
cancelText: string;
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'app-confirmation-dialog',
|
||||
imports: [
|
||||
MatDialogActions,
|
||||
MatDialogClose,
|
||||
MatDialogContent,
|
||||
MatDialogTitle,
|
||||
MatButtonModule,
|
||||
@@ -22,9 +29,20 @@ import { MatButtonModule } from '@angular/material/button';
|
||||
standalone: true,
|
||||
})
|
||||
export class ConfirmationDialogComponent {
|
||||
confirmDelete = new EventEmitter<void>();
|
||||
|
||||
constructor(public dialogRef: MatDialogRef<ConfirmationDialogComponent>) {}
|
||||
confirmDelete = new EventEmitter<void>();
|
||||
|
||||
constructor(
|
||||
public dialogRef: MatDialogRef<ConfirmationDialogComponent>,
|
||||
@Optional() @Inject(MAT_DIALOG_DATA) public data: ConfirmationData
|
||||
) {
|
||||
this.data = data || {
|
||||
title: 'Daten löschen',
|
||||
message: 'Bist Du sicher, dass Du die Daten löschen möchtest? Diesen Vorgang kannst Du nicht mehr rückgängig machen.',
|
||||
confirmText: 'Löschen',
|
||||
cancelText: 'Abbrechen'
|
||||
};
|
||||
}
|
||||
|
||||
onCancelClick(): void {
|
||||
this.dialogRef.close();
|
||||
|
||||
Reference in New Issue
Block a user