Add support for deprecated values in field select options

(cherry picked from commit d9786887f3fe30ef60ad9c50b3272bf60dfef309)
pull/8870/head
Bogdan 1 year ago
parent e6b782aa20
commit 97a28fee3b

@ -108,7 +108,7 @@ namespace Radarr.Http.ClientSchema
Placeholder = fieldAttribute.Placeholder
};
if (fieldAttribute.Type == FieldType.Select || fieldAttribute.Type == FieldType.TagSelect)
if (fieldAttribute.Type is FieldType.Select or FieldType.TagSelect)
{
if (fieldAttribute.SelectOptionsProviderAction.IsNotNullOrWhiteSpace())
{
@ -157,11 +157,15 @@ namespace Radarr.Http.ClientSchema
{
if (selectOptions.IsEnum)
{
var options = selectOptions.GetFields().Where(v => v.IsStatic).Select(v =>
var options = selectOptions
.GetFields()
.Where(v => v.IsStatic && !v.GetCustomAttributes(false).OfType<ObsoleteAttribute>().Any())
.Select(v =>
{
var name = v.Name.Replace('_', ' ');
var value = Convert.ToInt32(v.GetRawConstantValue());
var attrib = v.GetCustomAttribute<FieldOptionAttribute>();
if (attrib != null)
{
return new SelectOption
@ -172,15 +176,13 @@ namespace Radarr.Http.ClientSchema
Hint = attrib.Hint ?? $"({value})"
};
}
else
{
return new SelectOption
{
Value = value,
Name = name,
Order = value
};
}
});
return options.OrderBy(o => o.Order).ToList();

Loading…
Cancel
Save