mirror of https://github.com/abpframework/abp.git
14 changed files with 135 additions and 107 deletions
@ -0,0 +1,39 @@ |
|||
using System.Linq; |
|||
using Blazorise; |
|||
using Microsoft.AspNetCore.Components; |
|||
using Microsoft.Extensions.Localization; |
|||
using Volo.Abp.AspNetCore.Components.Web; |
|||
using Volo.Abp.Data; |
|||
using Volo.Abp.ObjectExtending; |
|||
|
|||
namespace Volo.Abp.BlazoriseUI.Components.ObjectExtending; |
|||
|
|||
public abstract class ExtensionPropertyComponentBase<TEntity, TResourceType> : OwningComponentBase |
|||
where TEntity : IHasExtraProperties |
|||
{ |
|||
[Inject] |
|||
public IStringLocalizerFactory StringLocalizerFactory { get; set; } |
|||
|
|||
[Parameter] |
|||
public TEntity Entity { get; set; } |
|||
|
|||
[Parameter] |
|||
public ObjectExtensionPropertyInfo PropertyInfo { get; set; } |
|||
|
|||
[Parameter] |
|||
public AbpBlazorMessageLocalizerHelper<TResourceType> LH { get; set; } |
|||
|
|||
protected virtual void Validate(ValidatorEventArgs e) |
|||
{ |
|||
e.Status = ValidationStatus.Success; |
|||
|
|||
var result = ExtensibleObjectValidator.GetValidationErrors(Entity, PropertyInfo.Name, e.Value); |
|||
if (!result.Any()) |
|||
{ |
|||
return; |
|||
} |
|||
|
|||
e.Status = ValidationStatus.Error; |
|||
e.ErrorText = result.First().ErrorMessage; |
|||
} |
|||
} |
|||
@ -1,13 +1,21 @@ |
|||
@typeparam TEntity |
|||
@typeparam TResourceType |
|||
@using Abp.Localization |
|||
@inherits ExtensionPropertyComponentBase<TEntity, TResourceType> |
|||
|
|||
<Field> |
|||
<FieldLabel>@PropertyInfo.GetLocalizedDisplayName(StringLocalizerFactory)</FieldLabel> |
|||
<Select @bind-SelectedValue="@SelectedValue" > |
|||
@foreach (var item in SelectItems) |
|||
{ |
|||
<SelectItem Value="@item.Value">@item.Text</SelectItem> |
|||
} |
|||
</Select> |
|||
</Field> |
|||
<Validation Validator="@Validate" MessageLocalizer="@LH.Localize"> |
|||
<Field> |
|||
<FieldLabel>@PropertyInfo.GetLocalizedDisplayName(StringLocalizerFactory)</FieldLabel> |
|||
<Select @bind-SelectedValue="@SelectedValue"> |
|||
<ChildContent> |
|||
@foreach (var item in SelectItems) |
|||
{ |
|||
<SelectItem Value="@item.Value">@item.Text</SelectItem> |
|||
} |
|||
</ChildContent> |
|||
<Feedback> |
|||
<ValidationError/> |
|||
</Feedback> |
|||
</Select> |
|||
</Field> |
|||
</Validation> |
|||
|
|||
Loading…
Reference in new issue