Refactor envelope type selection logic

Removed the placeholder option from the envelope type dropdown to simplify the UI. Introduced a new `GetDefaultEnvelopeTypeId()` method to centralize and enhance the logic for determining the default envelope type. This method prioritizes envelope types with titles containing "Handwritten Signature" if available, improving alignment with user preferences. Updated `_selectedEnvelopeTypeId` initialization to use the new method for better maintainability.
This commit is contained in:
2026-10-05 15:04:09 +02:00
parent a535e20b0e
commit 5db2f6f1e3

View File

@@ -64,7 +64,6 @@
<select value="@(_selectedEnvelopeTypeId?.ToString() ?? string.Empty)"
@onchange="OnEnvelopeTypeChanged"
class="sender-create-wizard__select">
<option value="">@L("SenderEditor_SelectTemplate", "Vorlage auswählen")</option>
@foreach (var type in EnvelopeTypes)
{
<option value="@type.Id">@type.Title</option>
@@ -634,7 +633,7 @@
_validationMessage = null;
_title = string.Empty;
_selectedEnvelopeTypeId = EnvelopeTypes.Count > 0 ? EnvelopeTypes[0].Id : null;
_selectedEnvelopeTypeId = GetDefaultEnvelopeTypeId();
_message = string.Empty;
_language = "de-DE";
@@ -647,6 +646,18 @@
_documentSizeText = string.Empty;
}
private int? GetDefaultEnvelopeTypeId()
{
if (EnvelopeTypes.Count == 0)
return null;
var handwrittenType = EnvelopeTypes.FirstOrDefault(x =>
!string.IsNullOrWhiteSpace(x.Title)
&& x.Title.Contains("Handschriftliche Unterschrift", StringComparison.OrdinalIgnoreCase));
return handwrittenType?.Id ?? EnvelopeTypes[0].Id;
}
private string L(string key, string fallback)
{
var modelValue = ModelLocalizer[key];