1
0
mirror of https://github.com/Radarr/Radarr.git synced 2026-04-18 21:35:51 -04:00

New: MultiSelect input control for provider settings

Co-Authored-By: Taloth <Taloth@users.noreply.github.com>
This commit is contained in:
Qstick
2020-10-06 23:03:29 -04:00
parent 00022fd206
commit a826c1dc25
10 changed files with 210 additions and 25 deletions

View File

@@ -146,10 +146,34 @@ namespace Radarr.Http.ClientSchema
{
if (selectOptions.IsEnum)
{
var options = from Enum e in Enum.GetValues(selectOptions)
select new SelectOption { Value = Convert.ToInt32(e), Name = e.ToString() };
var options = selectOptions.GetFields().Where(v => v.IsStatic).Select(v =>
{
var name = v.Name.Replace('_', ' ');
var value = Convert.ToInt32(v.GetRawConstantValue());
var attrib = v.GetCustomAttribute<FieldOptionAttribute>();
if (attrib != null)
{
return new SelectOption
{
Value = value,
Name = attrib.Label ?? name,
Order = attrib.Order,
Hint = attrib.Hint ?? $"({value})"
};
}
else
{
return new SelectOption
{
Value = value,
Name = name,
Order = value,
Hint = $"({value})"
};
}
});
return options.OrderBy(o => o.Value).ToList();
return options.OrderBy(o => o.Order).ToList();
}
if (typeof(ISelectOptionsConverter).IsAssignableFrom(selectOptions))