mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-25 23:28:33 -06:00
added delete support for assignments
This commit is contained in:
81
Management.Web/Shared/Components/ConfirmationModal.razor
Normal file
81
Management.Web/Shared/Components/ConfirmationModal.razor
Normal file
@@ -0,0 +1,81 @@
|
||||
@using Management.Web.Shared.Components
|
||||
@namespace Management.Web.Shared.Components
|
||||
|
||||
@code {
|
||||
[Parameter]
|
||||
public Action? OnConfirm { get; init; }
|
||||
[Parameter]
|
||||
public Action? OnDeny { get; init; }
|
||||
[Parameter]
|
||||
public Func<Task>? OnConfirmAsync { get; init; }
|
||||
[Parameter]
|
||||
public Func<Task>? OnDenyAsync { get; init; }
|
||||
[Parameter]
|
||||
[EditorRequired]
|
||||
public string Label { get; set; } = "";
|
||||
[Parameter]
|
||||
[EditorRequired]
|
||||
public string Class { get; set; } = "";
|
||||
|
||||
private Modal? modal { get; set; } = null;
|
||||
|
||||
private bool doingAsyncThings { get; set; } = false;
|
||||
|
||||
private async Task HandleDeny()
|
||||
{
|
||||
if(OnDeny != null)
|
||||
OnDeny();
|
||||
if(OnDenyAsync != null)
|
||||
{
|
||||
doingAsyncThings = true;
|
||||
await OnDenyAsync();
|
||||
doingAsyncThings = false;
|
||||
}
|
||||
modal?.Hide();
|
||||
}
|
||||
private async Task HandleConfirm()
|
||||
{
|
||||
if(OnConfirm != null)
|
||||
OnConfirm();
|
||||
if(OnConfirmAsync != null)
|
||||
{
|
||||
doingAsyncThings = true;
|
||||
await OnConfirmAsync();
|
||||
doingAsyncThings = false;
|
||||
}
|
||||
modal?.Hide();
|
||||
}
|
||||
}
|
||||
|
||||
<button
|
||||
class="btn btn-danger"
|
||||
@onclick="() => modal?.Show()"
|
||||
>
|
||||
@Label
|
||||
</button>
|
||||
|
||||
<Modal @ref="modal">
|
||||
<Title>Are you sure you want to @Label?</Title>
|
||||
<Body>
|
||||
<div class="text-center">
|
||||
<button
|
||||
class="btn btn-secondary"
|
||||
@onclick="HandleDeny"
|
||||
>
|
||||
no
|
||||
</button>
|
||||
<button
|
||||
class="btn btn-primary"
|
||||
@onclick="HandleConfirm"
|
||||
>
|
||||
yes
|
||||
</button>
|
||||
</div>
|
||||
</Body>
|
||||
<Footer>
|
||||
@if(doingAsyncThings)
|
||||
{
|
||||
<Spinnner />
|
||||
}
|
||||
</Footer>
|
||||
</Modal>
|
||||
Reference in New Issue
Block a user