FIX: delete confirmation for support documents

This commit is contained in:
Frede Hundewadt 2023-06-13 10:40:16 +02:00
parent 3465509d4b
commit c1fb0733b1
4 changed files with 46 additions and 4 deletions

View file

@ -21,9 +21,14 @@
<PageTitle>Support Dokumentation</PageTitle> <PageTitle>Support Dokumentation</PageTitle>
<div class="row"> <div class="row">
<div class="col-sm-8"> <div class="col-sm-6">
<h2>Support Dokumentation</h2> <h2>Support Dokumentation</h2>
</div> </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"> <div class="col-sm-2 text-end">
<a class="btn btn-primary" href="/supervisor" ><i class="bi-chevron-left"></i> Supervisor</a> <a class="btn btn-primary" href="/supervisor" ><i class="bi-chevron-left"></i> Supervisor</a>
</div> </div>
@ -80,3 +85,7 @@ else
{ {
<div>Ingen data</div> <div>Ingen data</div>
} }
<AuthorizeView Roles="Management">
<ConfirmActionModal BodyMessage="@_deleteMessage" OnOkClicked="RemoveDocuments" @ref="_confirmDeleteDocuments"/>
</AuthorizeView>

View file

@ -17,6 +17,7 @@ using System.Text.Json;
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
using Wonky.Client.HttpInterceptors; using Wonky.Client.HttpInterceptors;
using Wonky.Client.HttpRepository; using Wonky.Client.HttpRepository;
using Wonky.Client.Shared;
using Wonky.Entity.DTO; using Wonky.Entity.DTO;
using Wonky.Entity.Views; using Wonky.Entity.Views;
@ -39,7 +40,8 @@ public partial class SupervisorDocumentListPage : IDisposable
private List<SupportDocumentEditView> Documents { get; set; } = new(); private List<SupportDocumentEditView> Documents { get; set; } = new();
private SupportAdvisorView Advisor { get; set; } = new(); private SupportAdvisorView Advisor { get; set; } = new();
private bool Working { get; set; } = true; private bool Working { get; set; } = true;
private ConfirmActionModal _confirmDeleteDocuments = new();
private string _deleteMessage = "";
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
@ -62,6 +64,22 @@ public partial class SupervisorDocumentListPage : IDisposable
} }
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() public void Dispose()
{ {
Interceptor.DisposeEvent(); Interceptor.DisposeEvent();

View file

@ -36,7 +36,7 @@
</div> </div>
<div class="col-sm-2 text-end"> <div class="col-sm-2 text-end">
<AuthorizeView Roles="Management"> <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> </AuthorizeView>
</div> </div>
<div class="col-sm-1 text-end"> <div class="col-sm-1 text-end">
@ -90,3 +90,8 @@
</div> </div>
</div> </div>
</div> </div>
<AuthorizeView Roles="Management">
<ConfirmActionModal BodyMessage="@_deleteMessage" OnOkClicked="RemoveDocument" @ref="_confirmDeleteDocument"/>
</AuthorizeView>

View file

@ -19,6 +19,7 @@ using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Forms; using Microsoft.AspNetCore.Components.Forms;
using Wonky.Client.HttpInterceptors; using Wonky.Client.HttpInterceptors;
using Wonky.Client.HttpRepository; using Wonky.Client.HttpRepository;
using Wonky.Client.Shared;
using Wonky.Entity.DTO; using Wonky.Entity.DTO;
namespace Wonky.Client.Pages; namespace Wonky.Client.Pages;
@ -45,6 +46,9 @@ public partial class SupervisorDocumentViewEditPage : IDisposable
private EditContext FormContext { get; set; } private EditContext FormContext { get; set; }
private SupportDocumentEditView Document { get; set; } = new(); private SupportDocumentEditView Document { get; set; } = new();
private bool Working { get; set; } = true; private bool Working { get; set; } = true;
private ConfirmActionModal _confirmDeleteDocument = new();
private string _deleteMessage = "";
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
@ -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() private async Task RemoveDocument()
{ {
_confirmDeleteDocument.Hide();
Toaster.ShowInfo("Sletter Dokument"); Toaster.ShowInfo("Sletter Dokument");
await DocumentRepo.DeleteDocument(Document.DocumentId); await DocumentRepo.DeleteDocument(Document.DocumentId);
Navigator.NavigateTo($"/supervisor/advisors/{AdvisorId}/documents"); Navigator.NavigateTo($"/supervisor/advisors/{AdvisorId}/documents");