Enhanced `CreateEnvelopeWizardPopup.razor` with PDF preview functionality using `SenderPdfImageEditor` and `PdfRenderService`. Added `_documentPagePreviews` to store rendered pages and `DocumentPdfDataUrl` for base64-encoded PDF data. Updated document upload logic to render pages and handle errors gracefully. Cleared `_documentPagePreviews` on reset. Modified `PdfFileDropZone.razor` to include a spacer for better layout when no document is present. Updated `sender-page.css` to improve layout responsiveness, add dynamic resizing, and refine styles for document preview and drop zone. Removed unused `sender-create-wizard__document-meta` class. These changes improve the user experience by providing PDF previews, enhancing layout consistency, and ensuring robust error handling during document uploads.
136 lines
3.4 KiB
Plaintext
136 lines
3.4 KiB
Plaintext
@using Microsoft.AspNetCore.Components.Forms
|
|
|
|
<div class="sender-pdf-dropzone @DropZoneClass">
|
|
<div class="sender-pdf-dropzone__content">
|
|
@if (HasDocument)
|
|
{
|
|
@if (!string.IsNullOrWhiteSpace(DocumentName))
|
|
{
|
|
<div class="sender-pdf-dropzone__doc-name">@DocumentName</div>
|
|
}
|
|
@if (!string.IsNullOrWhiteSpace(DocumentSizeText))
|
|
{
|
|
<div class="sender-pdf-dropzone__doc-size">@DocumentSizeText</div>
|
|
}
|
|
@if (!string.IsNullOrWhiteSpace(UploadedHintText))
|
|
{
|
|
<div class="sender-pdf-dropzone__hint">@UploadedHintText</div>
|
|
}
|
|
}
|
|
else if (!string.IsNullOrWhiteSpace(CurrentActionText))
|
|
{
|
|
<div class="sender-pdf-dropzone__hint">@CurrentActionText</div>
|
|
}
|
|
|
|
@if (!HasDocument)
|
|
{
|
|
<div class="sender-pdf-dropzone__initial-spacer" aria-hidden="true"></div>
|
|
}
|
|
</div>
|
|
|
|
<InputFile OnChange="OnFileSelectedAsync"
|
|
accept="@Accept"
|
|
disabled="@Disabled"
|
|
@ondragenter="OnDragEnter"
|
|
@ondragleave="OnDragLeave"
|
|
@ondragover="OnDragOver"
|
|
@ondrop="OnDrop"
|
|
class="sender-pdf-dropzone__input" />
|
|
</div>
|
|
|
|
@code {
|
|
[Parameter]
|
|
public bool Disabled { get; set; }
|
|
|
|
[Parameter]
|
|
public bool HasDocument { get; set; }
|
|
|
|
[Parameter]
|
|
public string Accept { get; set; } = ".pdf";
|
|
|
|
[Parameter]
|
|
public string UploadText { get; set; } = "PDF hochladen";
|
|
|
|
[Parameter]
|
|
public string ReplaceText { get; set; } = "PDF ersetzen";
|
|
|
|
[Parameter]
|
|
public string DragDropHintText { get; set; } = "Datei hierhin ziehen oder klicken";
|
|
|
|
[Parameter]
|
|
public string? DocumentName { get; set; }
|
|
|
|
[Parameter]
|
|
public string? DocumentSizeText { get; set; }
|
|
|
|
[Parameter]
|
|
public string UploadedHintText { get; set; } = "Zum Ersetzen klicken oder eine Datei hierher ziehen.";
|
|
|
|
[Parameter]
|
|
public EventCallback<InputFileChangeEventArgs> FileSelected { get; set; }
|
|
|
|
private int _dragDepth;
|
|
private bool _isDragActive;
|
|
|
|
private string CurrentActionText => HasDocument ? ReplaceText : UploadText;
|
|
|
|
private string DropZoneClass
|
|
{
|
|
get
|
|
{
|
|
if (Disabled)
|
|
return "sender-pdf-dropzone--disabled";
|
|
|
|
if (HasDocument)
|
|
return "sender-pdf-dropzone--has-document";
|
|
|
|
return _isDragActive ? "sender-pdf-dropzone--drag-active" : string.Empty;
|
|
}
|
|
}
|
|
|
|
private void OnDragEnter(DragEventArgs _)
|
|
{
|
|
if (Disabled)
|
|
return;
|
|
|
|
_dragDepth++;
|
|
_isDragActive = true;
|
|
}
|
|
|
|
private void OnDragLeave(DragEventArgs _)
|
|
{
|
|
if (Disabled)
|
|
return;
|
|
|
|
_dragDepth = Math.Max(0, _dragDepth - 1);
|
|
if (_dragDepth == 0)
|
|
_isDragActive = false;
|
|
}
|
|
|
|
private void OnDragOver(DragEventArgs _)
|
|
{
|
|
if (Disabled)
|
|
return;
|
|
|
|
_isDragActive = true;
|
|
}
|
|
|
|
private void OnDrop(DragEventArgs _)
|
|
{
|
|
_dragDepth = 0;
|
|
_isDragActive = false;
|
|
}
|
|
|
|
private async Task OnFileSelectedAsync(InputFileChangeEventArgs args)
|
|
{
|
|
_dragDepth = 0;
|
|
_isDragActive = false;
|
|
|
|
if (Disabled)
|
|
return;
|
|
|
|
if (FileSelected.HasDelegate)
|
|
await FileSelected.InvokeAsync(args);
|
|
}
|
|
}
|