Add PDF preview and improve document upload UX
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.
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
@inject IStringLocalizer<Model> ModelLocalizer
|
||||
@inject IStringLocalizer<Resource> UiLocalizer
|
||||
@inject ReceiverService ReceiverService
|
||||
@inject PdfRenderService PdfRenderService
|
||||
|
||||
<DxPopup Visible="@_isVisible"
|
||||
VisibleChanged="OnPopupVisibleChangedAsync"
|
||||
@@ -396,6 +397,22 @@
|
||||
ReplaceText='@L("SenderWizard_DocumentUploadSimpleHint", "Dokument hinzufuegen: klicken oder per Drag-and-Drop ablegen")'
|
||||
UploadedHintText='@L("SenderWizard_DocumentReplaceHint", "Zum Ersetzen klicken oder eine Datei auf diese Fläche ziehen.")'
|
||||
FileSelected="OnDocumentSelectedAsync" />
|
||||
|
||||
@if (_documentBytes is { Length: > 0 })
|
||||
{
|
||||
<div class="sender-create-wizard__document-preview-card">
|
||||
<div class="sender-create-wizard__document-preview-wrap">
|
||||
<SenderPdfImageEditor IsPlacementMode="false"
|
||||
PageCount="@_documentPagePreviews.Count"
|
||||
Pages="@_documentPagePreviews"
|
||||
PdfDataUrl="@DocumentPdfDataUrl"
|
||||
PdfFileName="@_documentFileName"
|
||||
Fields="Array.Empty<SenderPdfFieldOverlay>()"
|
||||
SignatureOverlays="Array.Empty<SenderPdfSignatureOverlay>()"
|
||||
ShowFieldRemoveButton="false" />
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</aside>
|
||||
</div>
|
||||
|
||||
@@ -509,6 +526,7 @@
|
||||
private byte[]? _documentBytes;
|
||||
private string? _documentFileName;
|
||||
private string _documentSizeText = string.Empty;
|
||||
private List<PdfPageImageDto> _documentPagePreviews = [];
|
||||
private bool _isDocumentUploading;
|
||||
private bool _isStepActionRunning;
|
||||
private bool _isFinishing;
|
||||
@@ -523,6 +541,9 @@
|
||||
private string? _validationMessage;
|
||||
|
||||
private bool IsActionLocked => _isDocumentUploading || _isStepActionRunning || _isFinishing;
|
||||
private string? DocumentPdfDataUrl => _documentBytes is { Length: > 0 }
|
||||
? $"data:application/pdf;base64,{Convert.ToBase64String(_documentBytes)}"
|
||||
: null;
|
||||
|
||||
private bool IsFirstStep => _currentStep <= 0;
|
||||
private bool IsLastStep => _currentStep >= TotalSteps - 1;
|
||||
@@ -742,6 +763,17 @@
|
||||
_documentFileName = file.Name;
|
||||
_documentSizeText = FormatSize(_documentBytes.Length);
|
||||
|
||||
try
|
||||
{
|
||||
_documentPagePreviews = (await PdfRenderService.RenderPagesAsync(_documentBytes))
|
||||
.OrderBy(p => p.PageNumber)
|
||||
.ToList();
|
||||
}
|
||||
catch
|
||||
{
|
||||
_documentPagePreviews = [];
|
||||
}
|
||||
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -1257,6 +1289,7 @@
|
||||
_documentBytes = null;
|
||||
_documentFileName = null;
|
||||
_documentSizeText = string.Empty;
|
||||
_documentPagePreviews.Clear();
|
||||
|
||||
ApplyDefaultEnvelopeType();
|
||||
NormalizeSettings();
|
||||
|
||||
@@ -21,6 +21,11 @@
|
||||
{
|
||||
<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"
|
||||
|
||||
@@ -1323,6 +1323,8 @@
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: stretch;
|
||||
min-height: 0;
|
||||
overflow: hidden;
|
||||
opacity: 1;
|
||||
transition: opacity 220ms ease 0.2s, transform 220ms ease 0.2s;
|
||||
}
|
||||
@@ -1352,6 +1354,13 @@
|
||||
height: 100%;
|
||||
min-height: 100%;
|
||||
margin-left: 0.75rem;
|
||||
flex: 1 1 auto;
|
||||
}
|
||||
|
||||
.sender-create-wizard__wizard-side .sender-pdf-dropzone--has-document {
|
||||
height: auto;
|
||||
min-height: 92px;
|
||||
flex: 0 0 auto;
|
||||
}
|
||||
|
||||
.sender-create-wizard__meta {
|
||||
@@ -1809,6 +1818,9 @@
|
||||
display: grid;
|
||||
gap: 0.2rem;
|
||||
padding: 0.75rem 0.9rem;
|
||||
width: 100%;
|
||||
min-height: 100%;
|
||||
align-content: center;
|
||||
}
|
||||
|
||||
.sender-pdf-dropzone__title {
|
||||
@@ -1821,6 +1833,10 @@
|
||||
color: #64748b;
|
||||
}
|
||||
|
||||
.sender-pdf-dropzone__initial-spacer {
|
||||
min-height: 56px;
|
||||
}
|
||||
|
||||
.sender-pdf-dropzone__doc-name {
|
||||
font-size: 0.82rem;
|
||||
font-weight: 700;
|
||||
@@ -1846,33 +1862,40 @@
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.sender-create-wizard__document-meta {
|
||||
border: 1px solid rgba(16, 185, 129, 0.3);
|
||||
border-radius: 8px;
|
||||
background: rgba(16, 185, 129, 0.08);
|
||||
padding: 0.55rem 0.7rem;
|
||||
}
|
||||
|
||||
.sender-create-wizard__document-preview-card {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.65rem;
|
||||
flex: 1 1 auto;
|
||||
min-height: 0;
|
||||
overflow: hidden;
|
||||
margin: 0.65rem 0 0 0.75rem;
|
||||
}
|
||||
|
||||
.sender-create-wizard__document-preview-wrap {
|
||||
border: 1px solid rgba(148, 163, 184, 0.38);
|
||||
border-radius: 10px;
|
||||
background: rgba(248, 250, 252, 0.96);
|
||||
height: 320px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-height: 0;
|
||||
height: 0;
|
||||
flex: 1 1 auto;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.sender-create-wizard__document-preview-wrap .sender-image-editor-shell {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-height: 0;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.sender-create-wizard__document-preview-wrap .sender-image-editor {
|
||||
flex: 1 1 auto;
|
||||
min-height: 0;
|
||||
height: 100%;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.sender-create-wizard__document-name {
|
||||
|
||||
Reference in New Issue
Block a user