FIX: delete confirmation for support documents
This commit is contained in:
parent
3465509d4b
commit
c1fb0733b1
4 changed files with 46 additions and 4 deletions
|
@ -21,9 +21,14 @@
|
|||
<PageTitle>Support Dokumentation</PageTitle>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-sm-8">
|
||||
<div class="col-sm-6">
|
||||
<h2>Support Dokumentation</h2>
|
||||
</div>
|
||||
<div class="col-sm-2">
|
||||
<AuthorizeView Roles="Management">
|
||||
<button type="button" class="btn btn-danger" @onclick="@ShowConfirmAction"><i class="bi-trash"></i> GDPR Slet</button>
|
||||
</AuthorizeView>
|
||||
</div>
|
||||
<div class="col-sm-2 text-end">
|
||||
<a class="btn btn-primary" href="/supervisor" ><i class="bi-chevron-left"></i> Supervisor</a>
|
||||
</div>
|
||||
|
@ -80,3 +85,7 @@ else
|
|||
{
|
||||
<div>Ingen data</div>
|
||||
}
|
||||
|
||||
<AuthorizeView Roles="Management">
|
||||
<ConfirmActionModal BodyMessage="@_deleteMessage" OnOkClicked="RemoveDocuments" @ref="_confirmDeleteDocuments"/>
|
||||
</AuthorizeView>
|
||||
|
|
|
@ -17,6 +17,7 @@ using System.Text.Json;
|
|||
using Microsoft.AspNetCore.Components;
|
||||
using Wonky.Client.HttpInterceptors;
|
||||
using Wonky.Client.HttpRepository;
|
||||
using Wonky.Client.Shared;
|
||||
using Wonky.Entity.DTO;
|
||||
using Wonky.Entity.Views;
|
||||
|
||||
|
@ -39,7 +40,8 @@ public partial class SupervisorDocumentListPage : IDisposable
|
|||
private List<SupportDocumentEditView> Documents { get; set; } = new();
|
||||
private SupportAdvisorView Advisor { get; set; } = new();
|
||||
private bool Working { get; set; } = true;
|
||||
|
||||
private ConfirmActionModal _confirmDeleteDocuments = new();
|
||||
private string _deleteMessage = "";
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
|
@ -60,7 +62,23 @@ public partial class SupervisorDocumentListPage : IDisposable
|
|||
Working = false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void ShowConfirmAction()
|
||||
{
|
||||
_deleteMessage = $"Bekræft sletning af dokumenter for {Advisor.FullName}. Handlinger kan ikke fortryders.";
|
||||
_confirmDeleteDocuments.Show();
|
||||
}
|
||||
|
||||
|
||||
private async Task RemoveDocuments()
|
||||
{
|
||||
foreach (var document in Documents)
|
||||
{
|
||||
await DocumentRepo.DeleteDocument(document.DocumentId);
|
||||
}
|
||||
Documents.Clear();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
</div>
|
||||
<div class="col-sm-2 text-end">
|
||||
<AuthorizeView Roles="Management">
|
||||
<button type="button" class="btn btn-warning" @onclick="@RemoveDocument"><i class="bi-trash"></i> Slet</button>
|
||||
<button type="button" class="btn btn-warning" @onclick="@ShowConfirmAction"><i class="bi-trash"></i> Slet</button>
|
||||
</AuthorizeView>
|
||||
</div>
|
||||
<div class="col-sm-1 text-end">
|
||||
|
@ -89,4 +89,9 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<AuthorizeView Roles="Management">
|
||||
<ConfirmActionModal BodyMessage="@_deleteMessage" OnOkClicked="RemoveDocument" @ref="_confirmDeleteDocument"/>
|
||||
</AuthorizeView>
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@ using Microsoft.AspNetCore.Components;
|
|||
using Microsoft.AspNetCore.Components.Forms;
|
||||
using Wonky.Client.HttpInterceptors;
|
||||
using Wonky.Client.HttpRepository;
|
||||
using Wonky.Client.Shared;
|
||||
using Wonky.Entity.DTO;
|
||||
|
||||
namespace Wonky.Client.Pages;
|
||||
|
@ -45,7 +46,10 @@ public partial class SupervisorDocumentViewEditPage : IDisposable
|
|||
private EditContext FormContext { get; set; }
|
||||
private SupportDocumentEditView Document { get; set; } = new();
|
||||
private bool Working { get; set; } = true;
|
||||
private ConfirmActionModal _confirmDeleteDocument = new();
|
||||
|
||||
private string _deleteMessage = "";
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
Interceptor.RegisterEvent();
|
||||
|
@ -64,9 +68,15 @@ public partial class SupervisorDocumentViewEditPage : IDisposable
|
|||
|
||||
}
|
||||
|
||||
private void ShowConfirmAction()
|
||||
{
|
||||
_deleteMessage = $"Bekræft sletning af dokument {Document.Description}. Handlingen kan ikke fortrydes.";
|
||||
_confirmDeleteDocument.Show();
|
||||
}
|
||||
|
||||
private async Task RemoveDocument()
|
||||
{
|
||||
_confirmDeleteDocument.Hide();
|
||||
Toaster.ShowInfo("Sletter Dokument");
|
||||
await DocumentRepo.DeleteDocument(Document.DocumentId);
|
||||
Navigator.NavigateTo($"/supervisor/advisors/{AdvisorId}/documents");
|
||||
|
|
Loading…
Reference in a new issue