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" />
|
<link href="@AppVersion.GetVersionedUrl("css/envelope-viewer.css")" rel="stylesheet" />
|
||||||
<script src="@AppVersion.GetVersionedUrl("js/envelope-editor.js")"></script>
|
<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">
|
<div class="envelope-viewer-layout">
|
||||||
|
|
||||||
@* ── Action Bar ── *@
|
@* ── Action Bar ── *@
|
||||||
@@ -426,6 +431,7 @@
|
|||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</DxLoadingPanel>
|
||||||
|
|
||||||
<DxPopup @bind-Visible="_receiverPopupVisible"
|
<DxPopup @bind-Visible="_receiverPopupVisible"
|
||||||
HeaderText='@L("AddReceiver", "Empfänger hinzufügen")'
|
HeaderText='@L("AddReceiver", "Empfänger hinzufügen")'
|
||||||
@@ -670,6 +676,7 @@
|
|||||||
static readonly System.ComponentModel.DataAnnotations.EmailAddressAttribute ReceiverEmailValidator = new();
|
static readonly System.ComponentModel.DataAnnotations.EmailAddressAttribute ReceiverEmailValidator = new();
|
||||||
|
|
||||||
bool IsEditMode => EnvelopeId.HasValue && EnvelopeId.Value > 0;
|
bool IsEditMode => EnvelopeId.HasValue && EnvelopeId.Value > 0;
|
||||||
|
bool IsBootstrapLoading => !IsEditMode && !_bootstrapApplied;
|
||||||
|
|
||||||
// ── Lifecycle ──
|
// ── Lifecycle ──
|
||||||
|
|
||||||
@@ -704,17 +711,22 @@
|
|||||||
if (EnvelopeId.HasValue && EnvelopeId.Value > 0)
|
if (EnvelopeId.HasValue && EnvelopeId.Value > 0)
|
||||||
_editingEnvelopeId = EnvelopeId.Value;
|
_editingEnvelopeId = EnvelopeId.Value;
|
||||||
|
|
||||||
if (!IsEditMode && !_bootstrapApplied && !string.IsNullOrWhiteSpace(BootstrapToken))
|
|
||||||
_pendingBootstrapToken = BootstrapToken;
|
|
||||||
|
|
||||||
if (IsEditMode && _loadedEnvelopeId != EnvelopeId)
|
if (IsEditMode && _loadedEnvelopeId != EnvelopeId)
|
||||||
{
|
{
|
||||||
await LoadEnvelopeForEditAsync(EnvelopeId!.Value);
|
await LoadEnvelopeForEditAsync(EnvelopeId!.Value);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsEditMode)
|
if (IsEditMode || _bootstrapApplied)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace(BootstrapToken))
|
||||||
|
{
|
||||||
|
NavigationManager.NavigateTo("/sender", replace: true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_pendingBootstrapToken = BootstrapToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
async Task TryApplyBootstrapAsync(string token)
|
async Task TryApplyBootstrapAsync(string token)
|
||||||
@@ -724,7 +736,7 @@
|
|||||||
|
|
||||||
if (payload is null)
|
if (payload is null)
|
||||||
{
|
{
|
||||||
NavigationManager.NavigateTo("/sender/editor", replace: true);
|
NavigationManager.NavigateTo("/sender", replace: true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -785,8 +797,6 @@
|
|||||||
_pagePreviews = [];
|
_pagePreviews = [];
|
||||||
_pageCount = 0;
|
_pageCount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
NavigationManager.NavigateTo("/sender/editor", replace: true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||||
@@ -800,6 +810,15 @@
|
|||||||
if (!OperatingSystem.IsBrowser())
|
if (!OperatingSystem.IsBrowser())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (!IsEditMode && !_bootstrapApplied && !string.IsNullOrWhiteSpace(_pendingBootstrapToken))
|
||||||
|
{
|
||||||
|
var token = _pendingBootstrapToken;
|
||||||
|
_pendingBootstrapToken = null;
|
||||||
|
await TryApplyBootstrapAsync(token);
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (_saveDraftAfterBootstrap && !_isSaving)
|
if (_saveDraftAfterBootstrap && !_isSaving)
|
||||||
{
|
{
|
||||||
_saveDraftAfterBootstrap = false;
|
_saveDraftAfterBootstrap = false;
|
||||||
@@ -807,12 +826,6 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!IsEditMode && !_bootstrapApplied && !string.IsNullOrWhiteSpace(_pendingBootstrapToken))
|
|
||||||
{
|
|
||||||
var token = _pendingBootstrapToken;
|
|
||||||
_pendingBootstrapToken = null;
|
|
||||||
await TryApplyBootstrapAsync(token);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async Task LoadEnvelopeForEditAsync(int envelopeId)
|
async Task LoadEnvelopeForEditAsync(int envelopeId)
|
||||||
|
|||||||
Reference in New Issue
Block a user