Skip to content

Commit

Permalink
Added delete confirmation dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
j4asper committed Dec 3, 2024
1 parent 1bb3d40 commit f561963
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 3 deletions.
19 changes: 19 additions & 0 deletions NotamManagement.UI/Pages/Dialogs/DeleteConfirmationDialog.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<MudDialog>
<DialogContent>
<MudText>@ContentText</MudText>
</DialogContent>
<DialogActions>
<MudButton OnClick="Cancel">Cancel</MudButton>
<MudButton Color="Color.Error" Variant="Variant.Filled" OnClick="Submit">Delete</MudButton>
</DialogActions>
</MudDialog>

@code {
[CascadingParameter] private MudDialogInstance MudDialog { get; set; }

[Parameter] [EditorRequired] public string ContentText { get; set; }

private void Submit() => MudDialog.Close(DialogResult.Ok(true));

private void Cancel() => MudDialog.Cancel();
}
21 changes: 18 additions & 3 deletions NotamManagement.UI/Pages/HandledNotams.razor
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
[Inject] public Blazored.LocalStorage.ILocalStorageService LocalStorage { get; set; } = null!;
[Inject] public ApiAuthenticationStateProvider ApiAuthenticationStateProvider { get; set; } = null!;
[Inject] public NavigationManager NavigationManager { get; set; } = null!;
[Inject] public IDialogService DialogService { get; set; } = null!;

private List<NotamAction> NotamActions = [];

Expand All @@ -48,11 +49,25 @@
}
}

private void RemoveItemCallback(NotamAction notamAction)
private async Task RemoveItemCallback(NotamAction notamAction)
{
NotamActions.Remove(notamAction);
var parameters = new DialogParameters<DeleteConfirmationDialog>
{
{ x => x.ContentText, "Are you sure you want to delete this handled notam?" }
};

var options = new DialogOptions { CloseButton = true, MaxWidth = MaxWidth.ExtraSmall };

var dialog = await DialogService.ShowAsync<DeleteConfirmationDialog>("Delete", parameters, options);

var result = await dialog.Result;

Snackbar.Add("Notam Action Deleted!", Severity.Success);
if (!result.Canceled)
{
NotamActions.Remove(notamAction);

Snackbar.Add("Notam Action Deleted!", Severity.Success);
}
}

private void UpdateItemCallback(NotamAction notamAction)
Expand Down
1 change: 1 addition & 0 deletions NotamManagement.UI/_Imports.razor
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
@using NotamManagement.UI.Pages.Components
@using NotamManagement.UI.Layout
@using NotamManagement.Core.Models
@using NotamManagement.UI.Pages.Dialogs
@using NotamManagement.Core.Services
@using MudBlazor
@using System.Net.Http.Headers

0 comments on commit f561963

Please sign in to comment.