From 3e578479fb345263690c0628551e794e7eca67fd Mon Sep 17 00:00:00 2001 From: Enis Necipoglu Date: Thu, 22 Sep 2022 17:38:56 +0300 Subject: [PATCH] Implement conditional editing for PersonalInfo page --- .../PersonalInfo/Default.cshtml | 52 +++++++++++-------- .../IdentityModuleExtensionConsts.cs | 5 ++ 2 files changed, 35 insertions(+), 22 deletions(-) diff --git a/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Components/ProfileManagementGroup/PersonalInfo/Default.cshtml b/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Components/ProfileManagementGroup/PersonalInfo/Default.cshtml index b9b0783ab9..7df1715b2b 100644 --- a/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Components/ProfileManagementGroup/PersonalInfo/Default.cshtml +++ b/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Components/ProfileManagementGroup/PersonalInfo/Default.cshtml @@ -28,28 +28,36 @@ StringComparison.OrdinalIgnoreCase); } -

@L["PersonalSettings"]


+

@L["PersonalSettings"]

+
- + - + - + - + - + - + @foreach (var propertyInfo in ObjectExtensionManager.Instance.GetProperties()) { + var isAllowed = propertyInfo.Configuration.GetOrDefault("AllowUserToEdit"); + + if(isAllowed == null || !isAllowed.Equals(true)) + { + continue; + } + if (!propertyInfo.Name.EndsWith("_Text")) { if (propertyInfo.Type.IsEnum || !propertyInfo.Lookup.Url.IsNullOrEmpty()) @@ -59,28 +67,28 @@ Model.ExtraProperties.ToEnum(propertyInfo.Name, propertyInfo.Type); } + name="ExtraProperties.@propertyInfo.Name" + label="@propertyInfo.GetLocalizedDisplayName(StringLocalizerFactory)" + autocomplete-api-url="@propertyInfo.Lookup.Url" + autocomplete-selected-item-name="@Model.GetProperty(propertyInfo.Name + "_Text")" + autocomplete-selected-item-value="@Model.GetProperty(propertyInfo.Name)" + autocomplete-filter-param-name="@propertyInfo.Lookup.FilterParamName" + autocomplete-items-property-name="@propertyInfo.Lookup.ResultListPropertyName" + autocomplete-display-property-name="@propertyInfo.Lookup.DisplayPropertyName" + autocomplete-value-property-name="@propertyInfo.Lookup.ValuePropertyName"> } else { + asp-for="ExtraProperties[propertyInfo.Name]" + name="ExtraProperties.@propertyInfo.Name" + label="@propertyInfo.GetLocalizedDisplayName(StringLocalizerFactory)" + asp-format="@propertyInfo.GetInputFormatOrNull()" + value="@propertyInfo.GetInputValueOrNull(Model.GetProperty(propertyInfo.Name))" /> } } } - + \ No newline at end of file diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/ObjectExtending/IdentityModuleExtensionConsts.cs b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/ObjectExtending/IdentityModuleExtensionConsts.cs index a9a150aa6d..5135cf22b8 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/ObjectExtending/IdentityModuleExtensionConsts.cs +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/ObjectExtending/IdentityModuleExtensionConsts.cs @@ -14,4 +14,9 @@ public static class IdentityModuleExtensionConsts public const string OrganizationUnit = "OrganizationUnit"; } + + public static class ConfigurationNames + { + public const string AllowUserToEdit = "AllowUserToEdit"; + } }