improve sort order of user profile options using settings

This commit is contained in:
sbwalker
2025-09-10 17:17:47 -04:00
parent d871bffdd5
commit fba4f23f71
3 changed files with 6 additions and 7 deletions

View File

@ -124,7 +124,6 @@
@if (!string.IsNullOrEmpty(p.Autocomplete)) @if (!string.IsNullOrEmpty(p.Autocomplete))
{ {
<select id="@p.Name" class="form-select" @onchange="@(e => ProfileChanged(e, p.Name))" autocomplete="@p.Autocomplete"> <select id="@p.Name" class="form-select" @onchange="@(e => ProfileChanged(e, p.Name))" autocomplete="@p.Autocomplete">
<option value="">&lt;@SharedLocalizer["Not Specified"]&gt;</option>
@foreach (var option in p.Options.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)) @foreach (var option in p.Options.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
{ {
var values = option.Split(':'); var values = option.Split(':');
@ -144,7 +143,6 @@
else else
{ {
<select id="@p.Name" class="form-select" @onchange="@(e => ProfileChanged(e, p.Name))"> <select id="@p.Name" class="form-select" @onchange="@(e => ProfileChanged(e, p.Name))">
<option value="">&lt;@SharedLocalizer["Not Specified"]&gt;</option>
@foreach (var option in p.Options.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)) @foreach (var option in p.Options.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
{ {
var values = option.Split(':'); var values = option.Split(':');
@ -417,7 +415,8 @@
if (profile.Options.ToLower().StartsWith("entityname:")) if (profile.Options.ToLower().StartsWith("entityname:"))
{ {
var options = await SettingService.GetSettingsAsync(profile.Options.Substring(11), -1); var options = await SettingService.GetSettingsAsync(profile.Options.Substring(11), -1);
profile.Options = string.Join(",", options.Select(kvp => $"{kvp.Key}:{kvp.Value}")); options.Add("", $"<{SharedLocalizer["Not Specified"]}>");
profile.Options = string.Join(",", options.OrderBy(item => item.Value).Select(kvp => $"{kvp.Key}:{kvp.Value}"));
} }
} }
_timezones = TimeZoneService.GetTimeZones(); _timezones = TimeZoneService.GetTimeZones();

View File

@ -86,7 +86,6 @@
@if (!string.IsNullOrEmpty(p.Options)) @if (!string.IsNullOrEmpty(p.Options))
{ {
<select id="@p.Name" class="form-select" @onchange="@(e => ProfileChanged(e, p.Name))"> <select id="@p.Name" class="form-select" @onchange="@(e => ProfileChanged(e, p.Name))">
<option value="">&lt;@SharedLocalizer["Not Specified"]&gt;</option>
@foreach (var option in p.Options.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)) @foreach (var option in p.Options.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
{ {
var values = option.Split(':'); var values = option.Split(':');
@ -154,7 +153,8 @@
if (profile.Options.ToLower().StartsWith("entityname:")) if (profile.Options.ToLower().StartsWith("entityname:"))
{ {
var options = await SettingService.GetSettingsAsync(profile.Options.Substring(11), -1); var options = await SettingService.GetSettingsAsync(profile.Options.Substring(11), -1);
profile.Options = string.Join(",", options.Select(kvp => $"{kvp.Key}:{kvp.Value}")); options.Add("", $"<{SharedLocalizer["Not Specified"]}>");
profile.Options = string.Join(",", options.OrderBy(item => item.Value).Select(kvp => $"{kvp.Key}:{kvp.Value}"));
} }
} }
_settings = new Dictionary<string, string>(); _settings = new Dictionary<string, string>();

View File

@ -119,7 +119,6 @@
@if (!string.IsNullOrEmpty(p.Options)) @if (!string.IsNullOrEmpty(p.Options))
{ {
<select id="@p.Name" class="form-select" @onchange="@(e => ProfileChanged(e, p.Name))"> <select id="@p.Name" class="form-select" @onchange="@(e => ProfileChanged(e, p.Name))">
<option value="">&lt;@SharedLocalizer["Not Specified"]&gt;</option>
@foreach (var option in p.Options.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)) @foreach (var option in p.Options.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
{ {
var values = option.Split(':'); var values = option.Split(':');
@ -213,7 +212,8 @@
if (profile.Options.ToLower().StartsWith("entityname:")) if (profile.Options.ToLower().StartsWith("entityname:"))
{ {
var options = await SettingService.GetSettingsAsync(profile.Options.Substring(11), -1); var options = await SettingService.GetSettingsAsync(profile.Options.Substring(11), -1);
profile.Options = string.Join(",", options.Select(kvp => $"{kvp.Key}:{kvp.Value}")); options.Add("", $"<{SharedLocalizer["Not Specified"]}>");
profile.Options = string.Join(",", options.OrderBy(item => item.Value).Select(kvp => $"{kvp.Key}:{kvp.Value}"));
} }
} }
_timezones = TimeZoneService.GetTimeZones(); _timezones = TimeZoneService.GetTimeZones();