|
|
|
|
@ -11,27 +11,18 @@ namespace Volo.Abp.BlazoriseUI.Components.ObjectExtending
|
|
|
|
|
public partial class SelectExtensionProperty<TEntity, TResourceType> : ComponentBase
|
|
|
|
|
where TEntity : IHasExtraProperties
|
|
|
|
|
{
|
|
|
|
|
[Inject]
|
|
|
|
|
public IStringLocalizerFactory StringLocalizerFactory { get; set; }
|
|
|
|
|
[Inject] public IStringLocalizerFactory StringLocalizerFactory { get; set; }
|
|
|
|
|
|
|
|
|
|
[Parameter]
|
|
|
|
|
public TEntity Entity { get; set; }
|
|
|
|
|
[Parameter] public TEntity Entity { get; set; }
|
|
|
|
|
|
|
|
|
|
[Parameter]
|
|
|
|
|
public ObjectExtensionPropertyInfo PropertyInfo { get; set; }
|
|
|
|
|
[Parameter] public ObjectExtensionPropertyInfo PropertyInfo { get; set; }
|
|
|
|
|
|
|
|
|
|
public int SelectedValue
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return Entity.GetProperty<int>(PropertyInfo.Name);
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
Entity.SetProperty(PropertyInfo.Name, value);
|
|
|
|
|
}
|
|
|
|
|
get { return Entity.GetProperty<int>(PropertyInfo.Name); }
|
|
|
|
|
set { Entity.SetProperty(PropertyInfo.Name, value); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected virtual IEnumerable<SelectItem<int>> GetSelectItemsFromEnum()
|
|
|
|
|
{
|
|
|
|
|
var isNullableType = Nullable.GetUnderlyingType(PropertyInfo.Type) != null;
|
|
|
|
|
@ -45,37 +36,21 @@ namespace Volo.Abp.BlazoriseUI.Components.ObjectExtending
|
|
|
|
|
|
|
|
|
|
foreach (var enumValue in enumType.GetEnumValues())
|
|
|
|
|
{
|
|
|
|
|
var memberName = enumType.GetEnumName(enumValue);
|
|
|
|
|
var localizedMemberName = AbpInternalLocalizationHelper.LocalizeWithFallback(
|
|
|
|
|
new[]
|
|
|
|
|
{
|
|
|
|
|
// containerLocalizer,
|
|
|
|
|
StringLocalizerFactory.CreateDefaultOrNull()
|
|
|
|
|
},
|
|
|
|
|
new[]
|
|
|
|
|
{
|
|
|
|
|
$"Enum:{enumType.Name}.{memberName}",
|
|
|
|
|
$"{enumType.Name}.{memberName}",
|
|
|
|
|
memberName
|
|
|
|
|
},
|
|
|
|
|
memberName
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
yield return new SelectItem<int>
|
|
|
|
|
{
|
|
|
|
|
Value = (int)enumValue,
|
|
|
|
|
Text = localizedMemberName
|
|
|
|
|
Value = (int) enumValue,
|
|
|
|
|
Text = EnumHelper.GetLocalizedMemberName(enumType, enumValue, StringLocalizerFactory)
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected virtual void SelectedValueChanged(int value)
|
|
|
|
|
protected override void OnInitialized()
|
|
|
|
|
{
|
|
|
|
|
SelectedValue = value;
|
|
|
|
|
SelectedValue = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class SelectItem<TValue>
|
|
|
|
|
{
|
|
|
|
|
public string Text { get; set; }
|
|
|
|
|
|