Improve signature UI and refactor ReportViewer.razor

Updated the signature button text and SVG icon for clarity.
Enhanced the `DxPopup` component with better interaction
properties (`CloseOnEscape` and `CloseOnOutsideClick`).
Disabled the "Close" button in the popup when no signature
is captured.

Reformatted and restructured constants and fields in the
`@code` block for readability. Reintroduced previously
removed fields, constants, and methods to ensure
functionality. Added a conditional block in `LogoutAsync`
to open the signature popup when the user has access.

Performed general cleanup and code reorganization to
improve maintainability.
This commit is contained in:
2026-06-01 02:42:32 +02:00
parent d8781a4b41
commit 164dfacab3

View File

@@ -54,7 +54,7 @@
</svg>
<span>Unterschrift gespeichert</span>
} else {
<span>Unterschrift erstellen</span>
<span>Unterschrift &auml;ndern</span>
}
</button>
@if (_annotations.Count > 0) {
@@ -91,11 +91,11 @@
</div>
<DxPopup @bind-Visible="SignaturePopupVisible"
HeaderText="Unterschrift erfassen"
Width="620px"
ShowFooter="true"
HeaderText="Unterschrift erfassen"
Width="620px"
ShowFooter="true"
CloseOnEscape="true"
CloseOnOutsideClick="false">
CloseOnOutsideClick="false">
<BodyContentTemplate>
<ul class="nav nav-tabs mb-3">
<li class="nav-item">
@@ -160,7 +160,7 @@
<div class="d-flex gap-2 flex-wrap justify-content-end w-100">
<button class="btn btn-outline-secondary" @onclick="RenewSignatureAsync">Unterschrift erneuern</button>
<button class="btn btn-primary" @onclick="SaveSignatureAsync">Speichern</button>
<button class="btn btn-secondary" @onclick="CloseSignaturePopup">Schliessen</button>
<button class="btn btn-secondary" @onclick="CloseSignaturePopup" disabled="@(_capturedSignature is null)">Schliessen</button>
</div>
</FooterContentTemplate>
</DxPopup>
@@ -175,15 +175,15 @@
@code {
const string SignatureTabDraw = "draw";
const string SignatureTabText = "text";
const string SignatureTabImage = "image";
const string DrawCanvasId = "receiver-signature-pad";
const string TypedCanvasId = "receiver-typed-signature-pad";
const string ImageInputId = "receiver-signature-image-input";
const string ImageCanvasId = "receiver-image-signature-pad";
const string SignatureTabDraw = "draw";
const string SignatureTabText = "text";
const string SignatureTabImage = "image";
const string DrawCanvasId = "receiver-signature-pad";
const string TypedCanvasId = "receiver-typed-signature-pad";
const string ImageInputId = "receiver-signature-image-input";
const string ImageCanvasId = "receiver-image-signature-pad";
readonly (string Text, string Value)[] TypedSignatureFonts = {
readonly (string Text, string Value)[] TypedSignatureFonts = {
("Brush Script", "'Brush Script MT', cursive"),
("Segoe Script", "'Segoe Script', cursive"),
("Lucida Handwriting", "'Lucida Handwriting', cursive"),
@@ -191,31 +191,31 @@ readonly (string Text, string Value)[] TypedSignatureFonts = {
("Cursive", "cursive")
};
[Parameter] public string? EnvelopeKey { get; set; }
[Parameter] public string? EnvelopeKey { get; set; }
DxReportViewer? reportViewer;
XtraReport? Report;
bool SignatureApplied;
bool SignaturePopupVisible;
string? SignatureValidationMessage;
string? PopupValidationMessage;
string ActiveSignatureTab = SignatureTabDraw;
string TypedSignatureText = string.Empty;
string TypedSignatureFont = "'Brush Script MT', cursive";
string SignerFullName = string.Empty;
string SignerPosition = string.Empty;
string SignaturePlace = string.Empty;
int ViewerKey;
bool IsLoggingOut;
DxReportViewer? reportViewer;
XtraReport? Report;
bool SignatureApplied;
bool SignaturePopupVisible;
string? SignatureValidationMessage;
string? PopupValidationMessage;
string ActiveSignatureTab = SignatureTabDraw;
string TypedSignatureText = string.Empty;
string TypedSignatureFont = "'Brush Script MT', cursive";
string SignerFullName = string.Empty;
string SignerPosition = string.Empty;
string SignaturePlace = string.Empty;
int ViewerKey;
bool IsLoggingOut;
IReadOnlyList<AnnotationDto> _annotations = [];
record SignatureCapture(string DataUrl, string FullName, string Position, string Place);
SignatureCapture? _capturedSignature;
byte[]? _basePdfBytes;
// annotation IDs the user has checked via overlay checkboxes
readonly HashSet<long> _checkedAnnotations = [];
DotNetObjectReference<ReportViewer>? _dotNetRef;
int _lastOverlayViewerKey = -1;
IReadOnlyList<AnnotationDto> _annotations = [];
record SignatureCapture(string DataUrl, string FullName, string Position, string Place);
SignatureCapture? _capturedSignature;
byte[]? _basePdfBytes;
// annotation IDs the user has checked via overlay checkboxes
readonly HashSet<long> _checkedAnnotations = [];
DotNetObjectReference<ReportViewer>? _dotNetRef;
int _lastOverlayViewerKey = -1;
async Task LogoutAsync() {
if (string.IsNullOrWhiteSpace(EnvelopeKey) || IsLoggingOut) return;
@@ -233,6 +233,10 @@ int _lastOverlayViewerKey = -1;
Navigation.NavigateTo($"/login/{Uri.EscapeDataString(EnvelopeKey)}");
return;
}
else
{
await OpenSignaturePopupAsync();
}
}
_annotations = await AnnotationService.GetAnnotationsAsync(EnvelopeKey ?? "fake");