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 TEntity |
||||
@typeparam TResourceType |
@typeparam TResourceType |
||||
@using Abp.Localization |
@using Abp.Localization |
||||
|
@inherits ExtensionPropertyComponentBase<TEntity, TResourceType> |
||||
|
|
||||
<Field> |
<Validation Validator="@Validate" MessageLocalizer="@LH.Localize"> |
||||
<FieldLabel>@PropertyInfo.GetLocalizedDisplayName(StringLocalizerFactory)</FieldLabel> |
<Field> |
||||
<Select @bind-SelectedValue="@SelectedValue" > |
<FieldLabel>@PropertyInfo.GetLocalizedDisplayName(StringLocalizerFactory)</FieldLabel> |
||||
@foreach (var item in SelectItems) |
<Select @bind-SelectedValue="@SelectedValue"> |
||||
{ |
<ChildContent> |
||||
<SelectItem Value="@item.Value">@item.Text</SelectItem> |
@foreach (var item in SelectItems) |
||||
} |
{ |
||||
</Select> |
<SelectItem Value="@item.Value">@item.Text</SelectItem> |
||||
</Field> |
} |
||||
|
</ChildContent> |
||||
|
<Feedback> |
||||
|
<ValidationError/> |
||||
|
</Feedback> |
||||
|
</Select> |
||||
|
</Field> |
||||
|
</Validation> |
||||
|
|||||
Loading…
Reference in new issue