Improve bootstrap handling in SenderEditorPage
Added a `DxLoadingPanel` to display a loading indicator during the bootstrap process. Introduced the `IsBootstrapLoading` property to track bootstrap progress. Refactored `OnParametersSetAsync` to handle bootstrap tokens more effectively, including redirecting to `/sender` if no token is provided. Updated `TryApplyBootstrapAsync` to adjust navigation behavior when the bootstrap payload is `null`. Enhanced `OnAfterRenderAsync` to process `_pendingBootstrapToken` more cleanly and removed redundant logic. Simplified navigation and improved code readability and maintainability.
This commit is contained in:
@@ -31,6 +31,11 @@
|
||||
<link href="@AppVersion.GetVersionedUrl("css/envelope-viewer.css")" rel="stylesheet" />
|
||||
<script src="@AppVersion.GetVersionedUrl("js/envelope-editor.js")"></script>
|
||||
|
||||
<DxLoadingPanel Visible="@IsBootstrapLoading"
|
||||
IsContentBlocked="true"
|
||||
ApplyBackgroundShading="true"
|
||||
IndicatorAreaVisible="true"
|
||||
Text='@L("SenderEditor_BootstrapLoadingHint", "Der Umschlag wird vorbereitet und die Daten werden uebernommen.")'>
|
||||
<div class="envelope-viewer-layout">
|
||||
|
||||
@* ── Action Bar ── *@
|
||||
@@ -426,6 +431,7 @@
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</DxLoadingPanel>
|
||||
|
||||
<DxPopup @bind-Visible="_receiverPopupVisible"
|
||||
HeaderText='@L("AddReceiver", "Empfänger hinzufügen")'
|
||||
@@ -670,6 +676,7 @@
|
||||
static readonly System.ComponentModel.DataAnnotations.EmailAddressAttribute ReceiverEmailValidator = new();
|
||||
|
||||
bool IsEditMode => EnvelopeId.HasValue && EnvelopeId.Value > 0;
|
||||
bool IsBootstrapLoading => !IsEditMode && !_bootstrapApplied;
|
||||
|
||||
// ── Lifecycle ──
|
||||
|
||||
@@ -704,17 +711,22 @@
|
||||
if (EnvelopeId.HasValue && EnvelopeId.Value > 0)
|
||||
_editingEnvelopeId = EnvelopeId.Value;
|
||||
|
||||
if (!IsEditMode && !_bootstrapApplied && !string.IsNullOrWhiteSpace(BootstrapToken))
|
||||
_pendingBootstrapToken = BootstrapToken;
|
||||
|
||||
if (IsEditMode && _loadedEnvelopeId != EnvelopeId)
|
||||
{
|
||||
await LoadEnvelopeForEditAsync(EnvelopeId!.Value);
|
||||
return;
|
||||
}
|
||||
|
||||
if (IsEditMode)
|
||||
if (IsEditMode || _bootstrapApplied)
|
||||
return;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(BootstrapToken))
|
||||
{
|
||||
NavigationManager.NavigateTo("/sender", replace: true);
|
||||
return;
|
||||
}
|
||||
|
||||
_pendingBootstrapToken = BootstrapToken;
|
||||
}
|
||||
|
||||
async Task TryApplyBootstrapAsync(string token)
|
||||
@@ -724,7 +736,7 @@
|
||||
|
||||
if (payload is null)
|
||||
{
|
||||
NavigationManager.NavigateTo("/sender/editor", replace: true);
|
||||
NavigationManager.NavigateTo("/sender", replace: true);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -785,8 +797,6 @@
|
||||
_pagePreviews = [];
|
||||
_pageCount = 0;
|
||||
}
|
||||
|
||||
NavigationManager.NavigateTo("/sender/editor", replace: true);
|
||||
}
|
||||
|
||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||
@@ -800,6 +810,15 @@
|
||||
if (!OperatingSystem.IsBrowser())
|
||||
return;
|
||||
|
||||
if (!IsEditMode && !_bootstrapApplied && !string.IsNullOrWhiteSpace(_pendingBootstrapToken))
|
||||
{
|
||||
var token = _pendingBootstrapToken;
|
||||
_pendingBootstrapToken = null;
|
||||
await TryApplyBootstrapAsync(token);
|
||||
await InvokeAsync(StateHasChanged);
|
||||
return;
|
||||
}
|
||||
|
||||
if (_saveDraftAfterBootstrap && !_isSaving)
|
||||
{
|
||||
_saveDraftAfterBootstrap = false;
|
||||
@@ -807,12 +826,6 @@
|
||||
return;
|
||||
}
|
||||
|
||||
if (!IsEditMode && !_bootstrapApplied && !string.IsNullOrWhiteSpace(_pendingBootstrapToken))
|
||||
{
|
||||
var token = _pendingBootstrapToken;
|
||||
_pendingBootstrapToken = null;
|
||||
await TryApplyBootstrapAsync(token);
|
||||
}
|
||||
}
|
||||
|
||||
async Task LoadEnvelopeForEditAsync(int envelopeId)
|
||||
|
||||
Reference in New Issue
Block a user