Added MultiSelect input control for provider settings

Signed-off-by: Robin Dadswell <robin@dadswell.email>
This commit is contained in:
Taloth Saldono
2020-09-22 22:40:33 +02:00
committed by nitsua
parent 33de5d2049
commit 26bf0c0542
10 changed files with 181 additions and 34 deletions
+27 -3
View File
@@ -142,10 +142,34 @@ namespace Readarr.Http.ClientSchema
private static List<SelectOption> GetSelectOptions(Type selectOptions)
{
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();
}
private static Func<object, object> GetValueConverter(Type propertyType)