mirror of https://github.com/abpframework/abp.git
5 changed files with 129 additions and 18 deletions
@ -0,0 +1,24 @@ |
|||
@typeparam TEntity |
|||
@typeparam TResourceType |
|||
@using Volo.Abp.BlazoriseUI |
|||
@using Volo.Abp.Localization |
|||
@using Volo.Abp.ObjectExtending |
|||
@inherits ExtensionPropertyComponentBase<TEntity, TResourceType> |
|||
|
|||
@if (PropertyInfo != null && Entity != null) |
|||
{ |
|||
<Validation Validator="@Validate" MessageLocalizer="@LH.Localize"> |
|||
<Field> |
|||
<FieldLabel>@PropertyInfo.GetLocalizedDisplayName(StringLocalizerFactory)</FieldLabel> |
|||
<DateInput TValue="DateTimeOffset?" |
|||
InputMode="@(PropertyInfo.IsDate() ? DateInputMode.Date : DateInputMode.DateTime)" |
|||
Pattern="@PropertyInfo.GetDateEditInputFormatOrNull()" |
|||
Disabled="IsReadonlyField" |
|||
@bind-Value="@Value"> |
|||
<Feedback> |
|||
<ValidationError/> |
|||
</Feedback> |
|||
</DateInput> |
|||
</Field> |
|||
</Validation> |
|||
} |
|||
@ -0,0 +1,29 @@ |
|||
using System; |
|||
using Volo.Abp.Data; |
|||
|
|||
namespace Volo.Abp.BlazoriseUI.Components.ObjectExtending; |
|||
|
|||
public partial class DateTimeOffsetExtensionProperty<TEntity, TResourceType> |
|||
where TEntity : IHasExtraProperties |
|||
{ |
|||
protected DateTimeOffset? Value { |
|||
get { |
|||
var raw = Entity.GetProperty(PropertyInfo.Name); |
|||
return raw switch |
|||
{ |
|||
null => null, |
|||
DateTimeOffset dto => dto, |
|||
DateTime dt => dt.Kind switch |
|||
{ |
|||
DateTimeKind.Utc => new DateTimeOffset(dt, TimeSpan.Zero), |
|||
DateTimeKind.Local => new DateTimeOffset(dt), |
|||
_ => new DateTimeOffset(DateTime.SpecifyKind(dt, DateTimeKind.Utc), TimeSpan.Zero) |
|||
}, |
|||
_ => null |
|||
}; |
|||
} |
|||
set { |
|||
Entity.SetProperty(PropertyInfo.Name, value, false); |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue