From ef54a6416f5d17a8e34187d76ca96abff4d3624a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Thu, 30 Apr 2020 01:57:58 +0300 Subject: [PATCH] Added UI config for extra properties --- .../CachedObjectExtensionsDtoService.cs | 8 ++++--- ...leObjectExtraPropertyUiFormExtensionDto.cs | 2 +- ...eObjectExtraPropertyUiTableExtensionDto.cs | 2 +- .../Volo/Abp/Reflection/TypeHelper.cs | 4 ++-- ...ityObjectPropertyExtensionConfiguration.cs | 5 ++++ ...yObjectPropertyExtensionUIConfiguration.cs | 23 +++++++++++++++++++ ...ectPropertyExtensionUIFormConfiguration.cs | 10 ++++++++ ...ctPropertyExtensionUITableConfiguration.cs | 10 ++++++++ .../Volo/Abp/Reflection/TypeHelper_Tests.cs | 9 ++++++++ 9 files changed, 66 insertions(+), 7 deletions(-) create mode 100644 framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/ModuleEntityObjectPropertyExtensionUIConfiguration.cs create mode 100644 framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/ModuleEntityObjectPropertyExtensionUIFormConfiguration.cs create mode 100644 framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/ModuleEntityObjectPropertyExtensionUITableConfiguration.cs diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/CachedObjectExtensionsDtoService.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/CachedObjectExtensionsDtoService.cs index 7ff5f034cb..946076b65b 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/CachedObjectExtensionsDtoService.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/CachedObjectExtensionsDtoService.cs @@ -28,6 +28,8 @@ namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ObjectExtending protected virtual ObjectExtensionsDto GenerateCacheValue() { + //TODO: Obviously needs refactoring! + var objectExtensionsDto = new ObjectExtensionsDto { Modules = new Dictionary() @@ -61,15 +63,15 @@ namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ObjectExtending { CreateForm = new ModuleObjectExtraPropertyUiFormExtensionDto { - Visible = true + IsVisible = propertyConfig.UI.CreateForm.IsVisible }, EditForm = new ModuleObjectExtraPropertyUiFormExtensionDto { - Visible = true + IsVisible = propertyConfig.UI.EditForm.IsVisible }, Table = new ModuleObjectExtraPropertyUiTableExtensionDto { - Visible = true + IsVisible = propertyConfig.UI.Table.IsVisible } } }; diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ModuleObjectExtraPropertyUiFormExtensionDto.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ModuleObjectExtraPropertyUiFormExtensionDto.cs index 00411ba0f9..9d7e719f4f 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ModuleObjectExtraPropertyUiFormExtensionDto.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ModuleObjectExtraPropertyUiFormExtensionDto.cs @@ -5,6 +5,6 @@ namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ObjectExtending [Serializable] public class ModuleObjectExtraPropertyUiFormExtensionDto { - public bool Visible { get; set; } + public bool IsVisible { get; set; } } } \ No newline at end of file diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ModuleObjectExtraPropertyUiTableExtensionDto.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ModuleObjectExtraPropertyUiTableExtensionDto.cs index 9c2d202da9..419b9a6430 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ModuleObjectExtraPropertyUiTableExtensionDto.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ModuleObjectExtraPropertyUiTableExtensionDto.cs @@ -5,6 +5,6 @@ namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ObjectExtending [Serializable] public class ModuleObjectExtraPropertyUiTableExtensionDto { - public bool Visible { get; set; } + public bool IsVisible { get; set; } } } \ No newline at end of file diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/Reflection/TypeHelper.cs b/framework/src/Volo.Abp.Core/Volo/Abp/Reflection/TypeHelper.cs index 1a31cc9f34..11f43f852e 100644 --- a/framework/src/Volo.Abp.Core/Volo/Abp/Reflection/TypeHelper.cs +++ b/framework/src/Volo.Abp.Core/Volo/Abp/Reflection/TypeHelper.cs @@ -133,9 +133,9 @@ namespace Volo.Abp.Reflection type == typeof(Guid); } - public static object GetDefaultValue() + public static T GetDefaultValue() { - return GetDefaultValue(typeof(T)); + return default; } public static object GetDefaultValue(Type type) diff --git a/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/ModuleEntityObjectPropertyExtensionConfiguration.cs b/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/ModuleEntityObjectPropertyExtensionConfiguration.cs index 705166e2cc..bdc8d37e1e 100644 --- a/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/ModuleEntityObjectPropertyExtensionConfiguration.cs +++ b/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/ModuleEntityObjectPropertyExtensionConfiguration.cs @@ -36,6 +36,9 @@ namespace Volo.Abp.ObjectExtending [NotNull] public Dictionary Configuration { get; } + + [NotNull] + public ModuleEntityObjectPropertyExtensionUIConfiguration UI { get; } public ModuleEntityObjectPropertyExtensionConfiguration( [NotNull] ModuleEntityObjectExtensionConfiguration entityObjectExtensionConfiguration, @@ -51,6 +54,8 @@ namespace Volo.Abp.ObjectExtending Configuration = new Dictionary(); Attributes = new List(); Validators = new List>(); + + UI = new ModuleEntityObjectPropertyExtensionUIConfiguration(); } } } \ No newline at end of file diff --git a/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/ModuleEntityObjectPropertyExtensionUIConfiguration.cs b/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/ModuleEntityObjectPropertyExtensionUIConfiguration.cs new file mode 100644 index 0000000000..352b714ff0 --- /dev/null +++ b/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/ModuleEntityObjectPropertyExtensionUIConfiguration.cs @@ -0,0 +1,23 @@ +using JetBrains.Annotations; + +namespace Volo.Abp.ObjectExtending +{ + public class ModuleEntityObjectPropertyExtensionUIConfiguration + { + [NotNull] + public ModuleEntityObjectPropertyExtensionUITableConfiguration Table { get; } + + [NotNull] + public ModuleEntityObjectPropertyExtensionUIFormConfiguration CreateForm { get; } + + [NotNull] + public ModuleEntityObjectPropertyExtensionUIFormConfiguration EditForm { get; } + + public ModuleEntityObjectPropertyExtensionUIConfiguration() + { + Table = new ModuleEntityObjectPropertyExtensionUITableConfiguration(); + CreateForm = new ModuleEntityObjectPropertyExtensionUIFormConfiguration(); + EditForm = new ModuleEntityObjectPropertyExtensionUIFormConfiguration(); + } + } +} \ No newline at end of file diff --git a/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/ModuleEntityObjectPropertyExtensionUIFormConfiguration.cs b/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/ModuleEntityObjectPropertyExtensionUIFormConfiguration.cs new file mode 100644 index 0000000000..28ca3d9f79 --- /dev/null +++ b/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/ModuleEntityObjectPropertyExtensionUIFormConfiguration.cs @@ -0,0 +1,10 @@ +namespace Volo.Abp.ObjectExtending +{ + public class ModuleEntityObjectPropertyExtensionUIFormConfiguration + { + /// + /// Default: true. + /// + public bool IsVisible { get; set; } = true; + } +} \ No newline at end of file diff --git a/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/ModuleEntityObjectPropertyExtensionUITableConfiguration.cs b/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/ModuleEntityObjectPropertyExtensionUITableConfiguration.cs new file mode 100644 index 0000000000..36ae59e47d --- /dev/null +++ b/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/ModuleEntityObjectPropertyExtensionUITableConfiguration.cs @@ -0,0 +1,10 @@ +namespace Volo.Abp.ObjectExtending +{ + public class ModuleEntityObjectPropertyExtensionUITableConfiguration + { + /// + /// Default: true. + /// + public bool IsVisible { get; set; } = true; + } +} \ No newline at end of file diff --git a/framework/test/Volo.Abp.Core.Tests/Volo/Abp/Reflection/TypeHelper_Tests.cs b/framework/test/Volo.Abp.Core.Tests/Volo/Abp/Reflection/TypeHelper_Tests.cs index e289779d2c..23eba093a6 100644 --- a/framework/test/Volo.Abp.Core.Tests/Volo/Abp/Reflection/TypeHelper_Tests.cs +++ b/framework/test/Volo.Abp.Core.Tests/Volo/Abp/Reflection/TypeHelper_Tests.cs @@ -66,6 +66,15 @@ namespace Volo.Abp.Reflection ).ShouldBeFalse(); } + [Fact] + public void GetDefaultValue() + { + TypeHelper.GetDefaultValue(typeof(bool)).ShouldBe(false); + TypeHelper.GetDefaultValue(typeof(byte)).ShouldBe(0); + TypeHelper.GetDefaultValue(typeof(int)).ShouldBe(0); + TypeHelper.GetDefaultValue(typeof(string)).ShouldBeNull(); + } + public class MyDictionary : Dictionary {