-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a pop up to confirm to the user if they want to cancel the acti…
…on and a confirmation message when successfully canceled
- Loading branch information
1 parent
c60b34c
commit eb45ebe
Showing
5 changed files
with
94 additions
and
11 deletions.
There are no files selected for viewing
57 changes: 57 additions & 0 deletions
57
apps/web-mzima-client/src/app/settings/general/ confirm-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,57 @@ | ||
import { Component, Inject } from '@angular/core'; | ||
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; | ||
|
||
@Component({ | ||
selector: 'app-confirm-dialog', | ||
template: ` | ||
<h2 mat-dialog-title style="font-size: 24px; font-weight: bold;"> | ||
The data has not been saved | ||
</h2> | ||
<div class="dialog-content" style="margin-bottom: 20px; font-size: 16px;"> | ||
This action cannot be undone. Please proceed with caution. | ||
</div> | ||
<div class="dialog-actions" style="display: flex; justify-content: flex-end;"> | ||
<button | ||
class="dialog-button cancel-button" | ||
style="color: #333; padding: 12px 24px; width:20%; margin-right: 10px; border: 1px solid gray; border-radius: 3px; font-size: 14px; font-weight: semi-bold;" | ||
(click)="onCancel()" | ||
> | ||
Cancel | ||
</button> | ||
<button | ||
class="dialog-button confirm-button" | ||
style="background-color: orange; color: #333; width:20%; padding: 12px 24px; margin-left: 10px; border: none; border-radius: 3px; font-size: 14px; font-weight: semi-bold;" | ||
(click)="onConfirm()" | ||
> | ||
OK | ||
</button> | ||
</div> | ||
`, | ||
}) | ||
export class ConfirmDialogComponent { | ||
constructor( | ||
public dialogRef: MatDialogRef<ConfirmDialogComponent>, | ||
@Inject(MAT_DIALOG_DATA) public data: ConfirmDialogData, | ||
) {} | ||
|
||
get title(): string { | ||
return this.data.title || 'Confirmation'; | ||
} | ||
|
||
get message(): string { | ||
return this.data.message || 'Are you sure you want to discard the changes?'; | ||
} | ||
|
||
onCancel(): void { | ||
this.dialogRef.close(false); | ||
} | ||
|
||
onConfirm(): void { | ||
this.dialogRef.close(true); | ||
} | ||
} | ||
|
||
export interface ConfirmDialogData { | ||
title?: string; | ||
message?: string; | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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