Enhance ConfirmDialog with customizable button styles and add PDF opening functionality in AccountDetail
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
<p>@Message</p>
|
||||
<div class="d-flex justify-content-end gap-2">
|
||||
<button class="btn btn-outline-secondary" @onclick="Cancel"><i class="bi bi-x-lg"></i> @CancelText</button>
|
||||
<button class="btn btn-danger" @onclick="Confirm"><i class="bi bi-trash"></i> @ConfirmText</button>
|
||||
<button class="@ConfirmButtonClass" @onclick="Confirm"><i class="@ConfirmIconClass"></i> @ConfirmText</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -14,6 +14,8 @@
|
||||
[Parameter] public string Message { get; set; } = "Sind Sie sicher?";
|
||||
[Parameter] public string ConfirmText { get; set; } = "Ja, bestätigen";
|
||||
[Parameter] public string CancelText { get; set; } = "Nein, abbrechen";
|
||||
[Parameter] public string ConfirmButtonClass { get; set; } = "btn btn-danger";
|
||||
[Parameter] public string ConfirmIconClass { get; set; } = "bi bi-trash";
|
||||
[Parameter] public EventCallback OnConfirm { get; set; }
|
||||
[Parameter] public EventCallback OnCancel { get; set; }
|
||||
|
||||
|
||||
@@ -144,6 +144,18 @@
|
||||
OnCancel="CancelRestoreConfirm" />
|
||||
}
|
||||
|
||||
@if (!string.IsNullOrWhiteSpace(savedPdfPath))
|
||||
{
|
||||
<ConfirmDialog Title="PDF öffnen"
|
||||
Message="Die PDF wurde gespeichert. Möchten Sie sie jetzt öffnen?"
|
||||
ConfirmText="Ja, öffnen"
|
||||
CancelText="Nein"
|
||||
ConfirmButtonClass="btn btn-primary"
|
||||
ConfirmIconClass="bi bi-box-arrow-up-right"
|
||||
OnConfirm="HandleOpenSavedPdf"
|
||||
OnCancel="CancelOpenSavedPdf" />
|
||||
}
|
||||
|
||||
@if (editingEntry != null)
|
||||
{
|
||||
<AddEntryDialog AccountId="AccountId"
|
||||
@@ -176,6 +188,8 @@
|
||||
private int? confirmRestoreEntryId;
|
||||
private string? confirmRestoreEntryTitle;
|
||||
|
||||
private string? savedPdfPath;
|
||||
|
||||
private EntryDto? editingEntry;
|
||||
private EntryDto? editingTransferEntry;
|
||||
|
||||
@@ -291,7 +305,22 @@
|
||||
{
|
||||
var pdf = await PdfStatementService.GenerateStatementAsync(AccountId, showCurrentYearOnly);
|
||||
var suffix = showCurrentYearOnly ? $"_{DateTime.Now.Year}" : "_Gesamt";
|
||||
await FileSaveService.SaveFileAsync(pdf, $"{account?.Name}{suffix}.pdf");
|
||||
savedPdfPath = await FileSaveService.SaveFileAsync(pdf, $"{account?.Name}{suffix}.pdf");
|
||||
}
|
||||
|
||||
private async Task HandleOpenSavedPdf()
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(savedPdfPath))
|
||||
{
|
||||
await FileSaveService.OpenFileAsync(savedPdfPath);
|
||||
}
|
||||
|
||||
savedPdfPath = null;
|
||||
}
|
||||
|
||||
private void CancelOpenSavedPdf()
|
||||
{
|
||||
savedPdfPath = null;
|
||||
}
|
||||
|
||||
private static string FormatAmount(decimal amount) => $"{amount:N2} €";
|
||||
|
||||
@@ -3,4 +3,5 @@ namespace Duempelkas.App.Services;
|
||||
public interface IFileSaveService
|
||||
{
|
||||
Task<string?> SaveFileAsync(byte[] content, string suggestedFileName);
|
||||
Task OpenFileAsync(string filePath);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user