Browse Source

introduce new components for other data types

pull/7686/head
Ilkay Ilknur 6 years ago
parent
commit
17b4bac99c
  1. 26
      framework/src/Volo.Abp.BlazoriseUI/BlazoriseUiObjectExtensionPropertyInfoExtensions.cs
  2. 2
      framework/src/Volo.Abp.BlazoriseUI/Components/AbpExtensibleDataGrid.razor
  3. 11
      framework/src/Volo.Abp.BlazoriseUI/Components/ObjectExtending/CheckExtensionProperty.razor
  4. 32
      framework/src/Volo.Abp.BlazoriseUI/Components/ObjectExtending/CheckExtensionProperty.razor.cs
  5. 20
      framework/src/Volo.Abp.BlazoriseUI/Components/ObjectExtending/DateTimeExtensionProperty.razor
  6. 37
      framework/src/Volo.Abp.BlazoriseUI/Components/ObjectExtending/DateTimeExtensionProperty.razor.cs
  7. 41
      framework/src/Volo.Abp.BlazoriseUI/Components/ObjectExtending/ExtensionProperties.razor
  8. 20
      framework/src/Volo.Abp.BlazoriseUI/Components/ObjectExtending/ExtensionProperties.razor.cs
  9. 13
      framework/src/Volo.Abp.BlazoriseUI/Components/ObjectExtending/TimeExtensionProperty.razor
  10. 37
      framework/src/Volo.Abp.BlazoriseUI/Components/ObjectExtending/TimeExtensionProperty.razor.cs

26
framework/src/Volo.Abp.BlazoriseUI/BlazoriseUiObjectExtensionPropertyInfoExtensions.cs

@ -3,7 +3,7 @@ using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using Volo.Abp.Data;
using Volo.Abp.BlazoriseUI.Components.ObjectExtending;
using Volo.Abp.ObjectExtending;
using Volo.Abp.Reflection;
@ -210,7 +210,7 @@ namespace Volo.Abp.BlazoriseUI
}
}
return GetInputTypeFromTypeOrNull(propertyInfo.Type)
?? typeof(TextEdit); //default
?? typeof(TextExtensionProperty<,>); //default
}
private static Type GetInputTypeFromAttributeOrNull(Attribute attribute)
@ -219,7 +219,7 @@ namespace Volo.Abp.BlazoriseUI
if (hasTextEditSupport)
{
return typeof(TextEdit);
return typeof(TextExtensionProperty<,>);
}
//if (attribute is EmailAddressAttribute)
@ -247,19 +247,19 @@ namespace Volo.Abp.BlazoriseUI
switch (dataTypeAttribute.DataType)
{
case DataType.Password:
return typeof(TextEdit);
return typeof(TextExtensionProperty<,>);
case DataType.Date:
return typeof(DateEdit<>);
return typeof(DateTimeExtensionProperty<,>);
case DataType.Time:
return typeof(TimeEdit<>);
return typeof(TimeExtensionProperty<,>);
case DataType.EmailAddress:
return typeof(TextEdit);
return typeof(TextExtensionProperty<,>);
case DataType.Url:
return typeof(TextEdit);
return typeof(TextExtensionProperty<,>);
case DataType.PhoneNumber:
return typeof(TextEdit);
return typeof(TextExtensionProperty<,>);
case DataType.DateTime:
return typeof(DateEdit<>);
return typeof(DateTimeExtensionProperty<,>);
}
}
@ -270,17 +270,17 @@ namespace Volo.Abp.BlazoriseUI
{
if (type == typeof(bool))
{
return typeof(Check<>);
return typeof(CheckExtensionProperty<,>);
}
if (type == typeof(DateTime))
{
return typeof(DateEdit<>);
return typeof(DateTimeExtensionProperty<,>);
}
if (NumberTypes.Contains(type))
{
return typeof(TextEdit);
return typeof(TextExtensionProperty<,>);
}
return null;

2
framework/src/Volo.Abp.BlazoriseUI/Components/AbpExtensibleDataGrid.razor

@ -67,7 +67,7 @@
var entity = context as IHasExtraProperties;
var propertyName = ExtensionPropertiesRegex.Match(column.Data).Groups[1].Value;
var propertyValue = entity.GetProperty(propertyName);
if (propertyValue.GetType() == typeof(bool))
if (propertyValue!=null && propertyValue.GetType() == typeof(bool))
{
if ((bool)propertyValue)
{

11
framework/src/Volo.Abp.BlazoriseUI/Components/ObjectExtending/CheckExtensionProperty.razor

@ -0,0 +1,11 @@
@typeparam TEntity
@typeparam TResourceType
@using Volo.Abp.BlazoriseUI
@using Volo.Abp.Localization
@if (PropertyInfo != null && Entity != null)
{
<Field>
<Check TValue="bool" @bind-Checked="@Value">@PropertyInfo.GetLocalizedDisplayName(StringLocalizerFactory)</Check>
</Field>
}

32
framework/src/Volo.Abp.BlazoriseUI/Components/ObjectExtending/CheckExtensionProperty.razor.cs

@ -0,0 +1,32 @@
using Microsoft.AspNetCore.Components;
using Microsoft.Extensions.Localization;
using Volo.Abp.Data;
using Volo.Abp.ObjectExtending;
namespace Volo.Abp.BlazoriseUI.Components.ObjectExtending
{
public partial class CheckExtensionProperty<TEntity, TResourceType> : ComponentBase
where TEntity : IHasExtraProperties
{
[Inject]
public IStringLocalizerFactory StringLocalizerFactory { get; set; }
[Parameter]
public TEntity Entity { get; set; }
[Parameter]
public ObjectExtensionPropertyInfo PropertyInfo { get; set; }
protected bool Value
{
get
{
return PropertyInfo.GetInputValueOrDefault<bool>(Entity.GetProperty(PropertyInfo.Name));
}
set
{
Entity.SetProperty(PropertyInfo.Name, value, false);
}
}
}
}

20
framework/src/Volo.Abp.BlazoriseUI/Components/ObjectExtending/DateTimeExtensionProperty.razor

@ -0,0 +1,20 @@
@typeparam TEntity
@typeparam TResourceType
@using Volo.Abp.BlazoriseUI
@using Volo.Abp.Localization
@if (PropertyInfo != null && Entity != null)
{
<Field>
<FieldLabel>@PropertyInfo.GetLocalizedDisplayName(StringLocalizerFactory)</FieldLabel>
<DateEdit TValue="DateTime?"
Pattern="@PropertyInfo.GetDateEditInputFormatOrNull()"
@bind-Date="@Value">
</DateEdit>
@*<input @bind=CurrentValue
@bind-
@bind:format="@propertyInfo.GetDateEditInputFormatOrNull()"
type="datetime-local" />*@
</Field>
}

37
framework/src/Volo.Abp.BlazoriseUI/Components/ObjectExtending/DateTimeExtensionProperty.razor.cs

@ -0,0 +1,37 @@
using Microsoft.AspNetCore.Components;
using Microsoft.Extensions.Localization;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Data;
using Volo.Abp.ObjectExtending;
namespace Volo.Abp.BlazoriseUI.Components.ObjectExtending
{
public partial class DateTimeExtensionProperty<TEntity, TResourceType> : ComponentBase
where TEntity : IHasExtraProperties
{
[Inject]
public IStringLocalizerFactory StringLocalizerFactory { get; set; }
[Parameter]
public TEntity Entity { get; set; }
[Parameter]
public ObjectExtensionPropertyInfo PropertyInfo { get; set; }
protected DateTime? Value
{
get
{
return PropertyInfo.GetInputValueOrDefault<DateTime?>(Entity.GetProperty(PropertyInfo.Name));
}
set
{
Entity.SetProperty(PropertyInfo.Name, value, false);
}
}
}
}

41
framework/src/Volo.Abp.BlazoriseUI/Components/ObjectExtending/ExtensionProperties.razor

@ -15,48 +15,15 @@
else if (!propertyInfo.Lookup.Url.IsNullOrEmpty())
{
<LookupExtensionProperty PropertyInfo="@propertyInfo" Entity="@Entity" TEntity="TEntityType" TResourceType="TResourceType" />
}
else
{
var inputType = propertyInfo.GetInputType();
if (inputType == typeof(TextEdit))
{
<TextExtensionProperty TEntity="TEntityType" TResourceType="TResourceType" PropertyInfo="@propertyInfo" Entity="@Entity">
</TextExtensionProperty>
}
else if (inputType == typeof(Check<>))
{
<Field>
<Check TValue="bool" CheckedChanged="(val) => CheckedChanged(val, propertyInfo.Name)" Checked="@(propertyInfo.GetInputValueOrDefault<bool>(Entity.GetProperty(propertyInfo.Name)))">@propertyInfo.GetLocalizedDisplayName(StringLocalizerFactory)</Check>
</Field>
}
else if (inputType == typeof(TimeEdit<>))
{
<Field>
<FieldLabel>@propertyInfo.GetLocalizedDisplayName(StringLocalizerFactory)</FieldLabel>-->
<TimeEdit TValue="TimeSpan?" Time="@(propertyInfo.GetInputValueOrDefault<TimeSpan?>(Entity.GetProperty(propertyInfo.Name)))" TimeChanged="(val) => TimeChanged(val, propertyInfo.Name)">
<Feedback>
<ValidationError />
</Feedback>
</TimeEdit>
</Field>
}
else if (inputType == typeof(DateEdit<>))
{
<Field>
<FieldLabel>@propertyInfo.GetLocalizedDisplayName(StringLocalizerFactory)</FieldLabel>
<DateEdit TValue="DateTime?"
Pattern="@propertyInfo.GetDateEditInputFormatOrNull()"
Date="@(propertyInfo.GetInputValueOrDefault<DateTime?>(Entity.GetProperty(propertyInfo.Name)))"
DateChanged="(val) => DateTimeChanged(val, propertyInfo.Name)">
<Feedback>
<ValidationError />
</Feedback>
</DateEdit>
</Field>
}
__builder.OpenComponent(0, inputType.MakeGenericType(new[] { typeof(TEntityType), typeof(TResourceType) }));
__builder.AddAttribute(1, "PropertyInfo", propertyInfo);
__builder.AddAttribute(2, "Entity", Entity);
__builder.CloseComponent();
}
}
}

20
framework/src/Volo.Abp.BlazoriseUI/Components/ObjectExtending/ExtensionProperties.razor.cs

@ -17,25 +17,5 @@ namespace Volo.Abp.BlazoriseUI.Components.ObjectExtending
[Parameter]
public TEntityType Entity { get; set; }
protected void TextChanged(string value, string propertyName)
{
Entity.SetProperty(propertyName, value);
}
protected void CheckedChanged(bool value, string propertyName)
{
Entity.SetProperty(propertyName, value);
}
protected void TimeChanged(TimeSpan? value, string propertyName)
{
Entity.SetProperty(propertyName, value);
}
protected void DateTimeChanged(DateTime? value, string propertyName)
{
Entity.SetProperty(propertyName, value);
}
}
}

13
framework/src/Volo.Abp.BlazoriseUI/Components/ObjectExtending/TimeExtensionProperty.razor

@ -0,0 +1,13 @@
@typeparam TEntity
@typeparam TResourceType
@using Volo.Abp.BlazoriseUI
@using Volo.Abp.Localization
@if (PropertyInfo != null && Entity != null)
{
<Field>
<FieldLabel>@PropertyInfo.GetLocalizedDisplayName(StringLocalizerFactory)</FieldLabel>-->
<TimeEdit TValue="TimeSpan?" @bind-Time="@Value">
</TimeEdit>
</Field>
}

37
framework/src/Volo.Abp.BlazoriseUI/Components/ObjectExtending/TimeExtensionProperty.razor.cs

@ -0,0 +1,37 @@
using Microsoft.AspNetCore.Components;
using Microsoft.Extensions.Localization;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Data;
using Volo.Abp.ObjectExtending;
namespace Volo.Abp.BlazoriseUI.Components.ObjectExtending
{
public partial class TimeExtensionProperty<TEntity, TResourceType> : ComponentBase
where TEntity : IHasExtraProperties
{
[Inject]
public IStringLocalizerFactory StringLocalizerFactory { get; set; }
[Parameter]
public TEntity Entity { get; set; }
[Parameter]
public ObjectExtensionPropertyInfo PropertyInfo { get; set; }
protected TimeSpan? Value
{
get
{
return PropertyInfo.GetInputValueOrDefault<TimeSpan?>(Entity.GetProperty(PropertyInfo.Name));
}
set
{
Entity.SetProperty(PropertyInfo.Name, value, false);
}
}
}
}
Loading…
Cancel
Save