Skip to content

Commit

Permalink
#931: use AlertDialogComponent instead of CancelDialogComponent
Browse files Browse the repository at this point in the history
  • Loading branch information
clean-coder committed Jul 29, 2024
1 parent 30c378b commit e2dbb27
Showing 1 changed file with 10 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { MatDialog, MatDialogConfig } from '@angular/material/dialog';
import { CancelDialogComponent, CancelDialogData } from '../../shared/dialog/cancel-dialog/cancel-dialog.component';
import { OKR_DIALOG_CONFIG } from '../../shared/constantLibary';
import { filter, mergeMap } from 'rxjs';
import { AlertDialogComponent, AlertDialogData } from '../../shared/dialog/alert-dialog/alert-dialog.component';

@Component({
selector: 'app-delete-user',
Expand Down Expand Up @@ -42,27 +43,23 @@ export class DeleteUserComponent implements OnInit {
});
}

// https://blog.angular-university.io/angular-material-dialog/
// https://stackblitz.com/edit/angular-ivy-b3fqjj?file=src%2Fapp%2FAlertDialogComponent%2Falert-dialog.component.ts
deleteUser() {
if (this.isUserMemberOfTeams) {
this.showUnableToDeleteDialog(
this.user,
`${getFullNameFromUser(this.user)} ist in Team(s) und kann nicht gelöscht werden!`,
);
this.showUnableToDeleteDialog(`${this.userInfo()} ist in Team(s) und kann nicht gelöscht werden!`);
return;
}
if (this.isUserOwnerOfKeyResults) {
this.showUnableToDeleteDialog(
this.user,
`${getFullNameFromUser(this.user)} ist Owner von KeyResults kann nicht gelöscht werden!`,
);
this.showUnableToDeleteDialog(`${this.userInfo()} ist Owner von KeyResults und kann nicht gelöscht werden!`);
return;
}

this.showDeleteUserDialog(this.user);
}

private userInfo() {
return getFullNameFromUser(this.user);
}

showDeleteUserDialog(user: User) {
const dialogConfig: MatDialogConfig<CancelDialogData> = OKR_DIALOG_CONFIG;
dialogConfig.data = {
Expand All @@ -81,11 +78,11 @@ export class DeleteUserComponent implements OnInit {
});
}

showUnableToDeleteDialog(user: User, title: string) {
const dialogConfig: MatDialogConfig<CancelDialogData> = OKR_DIALOG_CONFIG;
showUnableToDeleteDialog(title: string) {
const dialogConfig: MatDialogConfig<AlertDialogData> = OKR_DIALOG_CONFIG;
dialogConfig.data = {
dialogTitle: title,
};
this.dialog.open(CancelDialogComponent, dialogConfig);
this.dialog.open(AlertDialogComponent, dialogConfig);
}
}

0 comments on commit e2dbb27

Please sign in to comment.