From 139f45de14d91d44c1db0815a1c818a0ce951106 Mon Sep 17 00:00:00 2001 From: Engincan VESKE <43685404+EngincanV@users.noreply.github.com> Date: Fri, 9 Jun 2023 13:40:23 +0300 Subject: [PATCH 1/4] Allow Setting Extended Property as ReadOnly for Blazor UI --- .../CheckExtensionProperty.razor | 2 +- .../DateTimeExtensionProperty.razor | 1 + .../ObjectExtending/ExtensionProperties.razor | 1 + .../ExtensionProperties.razor.cs | 4 ++++ .../ExtensionPropertyComponentBase.cs | 5 +++++ .../LookupExtensionProperty.razor | 3 ++- .../SelectExtensionProperty.razor | 2 +- .../TextExtensionProperty.razor | 2 +- .../TimeExtensionProperty.razor | 2 +- .../ObjectExtensionPropertyInfo.cs | 18 ++++++++++++++++++ 10 files changed, 35 insertions(+), 5 deletions(-) diff --git a/framework/src/Volo.Abp.BlazoriseUI/Components/ObjectExtending/CheckExtensionProperty.razor b/framework/src/Volo.Abp.BlazoriseUI/Components/ObjectExtending/CheckExtensionProperty.razor index eebff3970d..b9ef1e0f8e 100644 --- a/framework/src/Volo.Abp.BlazoriseUI/Components/ObjectExtending/CheckExtensionProperty.razor +++ b/framework/src/Volo.Abp.BlazoriseUI/Components/ObjectExtending/CheckExtensionProperty.razor @@ -8,7 +8,7 @@ { - + @PropertyInfo.GetLocalizedDisplayName(StringLocalizerFactory) diff --git a/framework/src/Volo.Abp.BlazoriseUI/Components/ObjectExtending/DateTimeExtensionProperty.razor b/framework/src/Volo.Abp.BlazoriseUI/Components/ObjectExtending/DateTimeExtensionProperty.razor index 8fa7f0d777..0500d29c32 100644 --- a/framework/src/Volo.Abp.BlazoriseUI/Components/ObjectExtending/DateTimeExtensionProperty.razor +++ b/framework/src/Volo.Abp.BlazoriseUI/Components/ObjectExtending/DateTimeExtensionProperty.razor @@ -13,6 +13,7 @@ diff --git a/framework/src/Volo.Abp.BlazoriseUI/Components/ObjectExtending/ExtensionProperties.razor b/framework/src/Volo.Abp.BlazoriseUI/Components/ObjectExtending/ExtensionProperties.razor index 9fe96c7a20..64e31560b2 100644 --- a/framework/src/Volo.Abp.BlazoriseUI/Components/ObjectExtending/ExtensionProperties.razor +++ b/framework/src/Volo.Abp.BlazoriseUI/Components/ObjectExtending/ExtensionProperties.razor @@ -25,6 +25,7 @@ __builder.AddAttribute(1, "PropertyInfo", propertyInfo); __builder.AddAttribute(2, "Entity", Entity); __builder.AddAttribute(3, "LH", LH); + __builder.AddAttribute(4, "EditForm", EditForm); __builder.CloseComponent(); } } diff --git a/framework/src/Volo.Abp.BlazoriseUI/Components/ObjectExtending/ExtensionProperties.razor.cs b/framework/src/Volo.Abp.BlazoriseUI/Components/ObjectExtending/ExtensionProperties.razor.cs index 947069a7ee..848aa0e66e 100644 --- a/framework/src/Volo.Abp.BlazoriseUI/Components/ObjectExtending/ExtensionProperties.razor.cs +++ b/framework/src/Volo.Abp.BlazoriseUI/Components/ObjectExtending/ExtensionProperties.razor.cs @@ -2,6 +2,7 @@ using Microsoft.Extensions.Localization; using Volo.Abp.AspNetCore.Components.Web; using Volo.Abp.Data; +using Volo.Abp.ObjectExtending; namespace Volo.Abp.BlazoriseUI.Components.ObjectExtending; @@ -16,4 +17,7 @@ public partial class ExtensionProperties : Component [Parameter] public TEntityType Entity { get; set; } + + [Parameter] + public bool? EditForm { get; set; } } diff --git a/framework/src/Volo.Abp.BlazoriseUI/Components/ObjectExtending/ExtensionPropertyComponentBase.cs b/framework/src/Volo.Abp.BlazoriseUI/Components/ObjectExtending/ExtensionPropertyComponentBase.cs index b2a5c1e48d..fce83d34c1 100644 --- a/framework/src/Volo.Abp.BlazoriseUI/Components/ObjectExtending/ExtensionPropertyComponentBase.cs +++ b/framework/src/Volo.Abp.BlazoriseUI/Components/ObjectExtending/ExtensionPropertyComponentBase.cs @@ -33,6 +33,9 @@ public abstract class ExtensionPropertyComponentBase : O [Parameter] public AbpBlazorMessageLocalizerHelper LH { get; set; } + [Parameter] + public bool? EditForm { get; set; } + protected virtual void Validate(ValidatorEventArgs e) { e.Status = ValidationStatus.Success; @@ -71,6 +74,8 @@ public abstract class ExtensionPropertyComponentBase : O } } + protected bool IsReadonlyField => EditForm.HasValue && EditForm.Value && PropertyInfo.UI.EditModal.IsReadOnly; + private static string GetDefaultErrorMessage(ValidationAttribute validationAttribute) { if (validationAttribute is StringLengthAttribute stringLengthAttribute && stringLengthAttribute.MinimumLength != 0) diff --git a/framework/src/Volo.Abp.BlazoriseUI/Components/ObjectExtending/LookupExtensionProperty.razor b/framework/src/Volo.Abp.BlazoriseUI/Components/ObjectExtending/LookupExtensionProperty.razor index 2ea468f1f4..7c32549d51 100644 --- a/framework/src/Volo.Abp.BlazoriseUI/Components/ObjectExtending/LookupExtensionProperty.razor +++ b/framework/src/Volo.Abp.BlazoriseUI/Components/ObjectExtending/LookupExtensionProperty.razor @@ -15,6 +15,7 @@ SelectedValueChanged="@SelectedValueChanged" SearchChanged="@SearchFilterChangedAsync" Validator="@Validate" - MinLength="0"> + MinLength="0" + Disabled="IsReadonlyField"> diff --git a/framework/src/Volo.Abp.BlazoriseUI/Components/ObjectExtending/SelectExtensionProperty.razor b/framework/src/Volo.Abp.BlazoriseUI/Components/ObjectExtending/SelectExtensionProperty.razor index cc1735c26a..605158aec0 100644 --- a/framework/src/Volo.Abp.BlazoriseUI/Components/ObjectExtending/SelectExtensionProperty.razor +++ b/framework/src/Volo.Abp.BlazoriseUI/Components/ObjectExtending/SelectExtensionProperty.razor @@ -10,7 +10,7 @@ @foreach (var item in SelectItems) { - @item.Text + @item.Text } diff --git a/framework/src/Volo.Abp.BlazoriseUI/Components/ObjectExtending/TextExtensionProperty.razor b/framework/src/Volo.Abp.BlazoriseUI/Components/ObjectExtending/TextExtensionProperty.razor index fc8b7b5398..e9d3d7031e 100644 --- a/framework/src/Volo.Abp.BlazoriseUI/Components/ObjectExtending/TextExtensionProperty.razor +++ b/framework/src/Volo.Abp.BlazoriseUI/Components/ObjectExtending/TextExtensionProperty.razor @@ -9,7 +9,7 @@ @PropertyInfo.GetLocalizedDisplayName(StringLocalizerFactory) - + diff --git a/framework/src/Volo.Abp.BlazoriseUI/Components/ObjectExtending/TimeExtensionProperty.razor b/framework/src/Volo.Abp.BlazoriseUI/Components/ObjectExtending/TimeExtensionProperty.razor index 6ad15b2cb5..5d3f1f26af 100644 --- a/framework/src/Volo.Abp.BlazoriseUI/Components/ObjectExtending/TimeExtensionProperty.razor +++ b/framework/src/Volo.Abp.BlazoriseUI/Components/ObjectExtending/TimeExtensionProperty.razor @@ -9,7 +9,7 @@ @PropertyInfo.GetLocalizedDisplayName(StringLocalizerFactory)--> - + diff --git a/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/ObjectExtensionPropertyInfo.cs b/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/ObjectExtensionPropertyInfo.cs index f89035d733..a7006b24b1 100644 --- a/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/ObjectExtensionPropertyInfo.cs +++ b/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/ObjectExtensionPropertyInfo.cs @@ -60,6 +60,8 @@ public class ObjectExtensionPropertyInfo : IHasNameWithLocalizableDisplayName, I [NotNull] public ExtensionPropertyLookupConfiguration Lookup { get; set; } + public ExtensionPropertyUI UI { get; set; } + public ObjectExtensionPropertyInfo( [NotNull] ObjectExtensionInfo objectExtension, [NotNull] Type type, @@ -76,10 +78,26 @@ public class ObjectExtensionPropertyInfo : IHasNameWithLocalizableDisplayName, I Attributes.AddRange(ExtensionPropertyHelper.GetDefaultAttributes(Type)); DefaultValue = TypeHelper.GetDefaultValue(Type); Lookup = new ExtensionPropertyLookupConfiguration(); + UI = new ExtensionPropertyUI(); } public object GetDefaultValue() { return ExtensionPropertyHelper.GetDefaultValue(Type, DefaultValueFactory, DefaultValue); } + + public class ExtensionPropertyUI + { + public ExtensionPropertyUIEditModal EditModal { get; set; } + + public ExtensionPropertyUI() + { + EditModal = new ExtensionPropertyUIEditModal(); + } + } + + public class ExtensionPropertyUIEditModal + { + public bool IsReadOnly { get; set; } + } } From fb2a02f4a7e03c548f717504c1a6eff750480ff6 Mon Sep 17 00:00:00 2001 From: Engincan VESKE <43685404+EngincanV@users.noreply.github.com> Date: Mon, 12 Jun 2023 20:36:52 +0300 Subject: [PATCH 2/4] Add modal type to extension properties component --- .../Components/ObjectExtending/ExtensionProperties.razor | 2 +- .../ObjectExtending/ExtensionProperties.razor.cs | 2 +- .../ObjectExtending/ExtensionPropertyComponentBase.cs | 6 +++--- .../ObjectExtending/ExtensionPropertyModalType.cs | 7 +++++++ 4 files changed, 12 insertions(+), 5 deletions(-) create mode 100644 framework/src/Volo.Abp.BlazoriseUI/Components/ObjectExtending/ExtensionPropertyModalType.cs diff --git a/framework/src/Volo.Abp.BlazoriseUI/Components/ObjectExtending/ExtensionProperties.razor b/framework/src/Volo.Abp.BlazoriseUI/Components/ObjectExtending/ExtensionProperties.razor index 64e31560b2..aa546793b9 100644 --- a/framework/src/Volo.Abp.BlazoriseUI/Components/ObjectExtending/ExtensionProperties.razor +++ b/framework/src/Volo.Abp.BlazoriseUI/Components/ObjectExtending/ExtensionProperties.razor @@ -25,7 +25,7 @@ __builder.AddAttribute(1, "PropertyInfo", propertyInfo); __builder.AddAttribute(2, "Entity", Entity); __builder.AddAttribute(3, "LH", LH); - __builder.AddAttribute(4, "EditForm", EditForm); + __builder.AddAttribute(4, "ModalType", ModalType); __builder.CloseComponent(); } } diff --git a/framework/src/Volo.Abp.BlazoriseUI/Components/ObjectExtending/ExtensionProperties.razor.cs b/framework/src/Volo.Abp.BlazoriseUI/Components/ObjectExtending/ExtensionProperties.razor.cs index 848aa0e66e..d9a1a42d85 100644 --- a/framework/src/Volo.Abp.BlazoriseUI/Components/ObjectExtending/ExtensionProperties.razor.cs +++ b/framework/src/Volo.Abp.BlazoriseUI/Components/ObjectExtending/ExtensionProperties.razor.cs @@ -19,5 +19,5 @@ public partial class ExtensionProperties : Component public TEntityType Entity { get; set; } [Parameter] - public bool? EditForm { get; set; } + public ExtensionPropertyModalType? ModalType { get; set; } } diff --git a/framework/src/Volo.Abp.BlazoriseUI/Components/ObjectExtending/ExtensionPropertyComponentBase.cs b/framework/src/Volo.Abp.BlazoriseUI/Components/ObjectExtending/ExtensionPropertyComponentBase.cs index fce83d34c1..46f4bd7f51 100644 --- a/framework/src/Volo.Abp.BlazoriseUI/Components/ObjectExtending/ExtensionPropertyComponentBase.cs +++ b/framework/src/Volo.Abp.BlazoriseUI/Components/ObjectExtending/ExtensionPropertyComponentBase.cs @@ -34,7 +34,7 @@ public abstract class ExtensionPropertyComponentBase : O public AbpBlazorMessageLocalizerHelper LH { get; set; } [Parameter] - public bool? EditForm { get; set; } + public ExtensionPropertyModalType? ModalType { get; set; } protected virtual void Validate(ValidatorEventArgs e) { @@ -68,13 +68,13 @@ public abstract class ExtensionPropertyComponentBase : O } e.MemberNames = result.MemberNames; - e.Status = ValidationStatus.Error; + e.Status = ValidationStatus.Error; e.ErrorText = errorMessage; break; } } - protected bool IsReadonlyField => EditForm.HasValue && EditForm.Value && PropertyInfo.UI.EditModal.IsReadOnly; + protected bool IsReadonlyField => ModalType is ExtensionPropertyModalType.EditModal && PropertyInfo.UI.EditModal.IsReadOnly; private static string GetDefaultErrorMessage(ValidationAttribute validationAttribute) { diff --git a/framework/src/Volo.Abp.BlazoriseUI/Components/ObjectExtending/ExtensionPropertyModalType.cs b/framework/src/Volo.Abp.BlazoriseUI/Components/ObjectExtending/ExtensionPropertyModalType.cs new file mode 100644 index 0000000000..67cf8d5bb8 --- /dev/null +++ b/framework/src/Volo.Abp.BlazoriseUI/Components/ObjectExtending/ExtensionPropertyModalType.cs @@ -0,0 +1,7 @@ +namespace Volo.Abp.BlazoriseUI.Components.ObjectExtending; + +public enum ExtensionPropertyModalType : byte +{ + CreateModal = 0, + EditModal = 1 +} \ No newline at end of file From cdbf19b0bdc8d7769623cfd14a977c10dc8cee80 Mon Sep 17 00:00:00 2001 From: Engincan VESKE <43685404+EngincanV@users.noreply.github.com> Date: Tue, 13 Jun 2023 16:53:57 +0300 Subject: [PATCH 3/4] Update ExtensionProperties component for identity and tenant-management modules --- .../Pages/Identity/RoleManagement.razor | 4 ++-- .../Pages/Identity/UserManagement.razor | 4 ++-- .../Pages/TenantManagement/TenantManagement.razor | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/RoleManagement.razor b/modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/RoleManagement.razor index ab9107118e..bf0c485647 100644 --- a/modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/RoleManagement.razor +++ b/modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/RoleManagement.razor @@ -54,7 +54,7 @@ - + @L["DisplayName:IsDefault"] @@ -92,7 +92,7 @@ - + @L["DisplayName:IsDefault"] diff --git a/modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/UserManagement.razor b/modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/UserManagement.razor index afa3fd3897..f858f99f68 100644 --- a/modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/UserManagement.razor +++ b/modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/UserManagement.razor @@ -132,7 +132,7 @@ @L["DisplayName:LockoutEnabled"] - + @if (NewUserRoles != null) @@ -253,7 +253,7 @@ @L["DisplayName:LockoutEnabled"] - + @if (EditUserRoles != null) diff --git a/modules/tenant-management/src/Volo.Abp.TenantManagement.Blazor/Pages/TenantManagement/TenantManagement.razor b/modules/tenant-management/src/Volo.Abp.TenantManagement.Blazor/Pages/TenantManagement/TenantManagement.razor index 0c03d5cbd2..04251a5003 100644 --- a/modules/tenant-management/src/Volo.Abp.TenantManagement.Blazor/Pages/TenantManagement/TenantManagement.razor +++ b/modules/tenant-management/src/Volo.Abp.TenantManagement.Blazor/Pages/TenantManagement/TenantManagement.razor @@ -81,7 +81,7 @@ - + @@ -116,7 +116,7 @@ - + From 4795f471a7869012e48a0bde726bb06358e8e161 Mon Sep 17 00:00:00 2001 From: Engincan VESKE Date: Tue, 13 Jun 2023 17:01:43 +0300 Subject: [PATCH 4/4] Update RoleManagement.razor --- .../Pages/Identity/RoleManagement.razor | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/RoleManagement.razor b/modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/RoleManagement.razor index bf0c485647..b5b8b15d47 100644 --- a/modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/RoleManagement.razor +++ b/modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/RoleManagement.razor @@ -92,7 +92,7 @@ - + @L["DisplayName:IsDefault"] @@ -112,4 +112,4 @@ @if (HasManagePermissionsPermission) { -} \ No newline at end of file +}