Browse Source

Merge pull request #13745 from abpframework/auto-merge/rel-6-0/1291

pull/13753/head
maliming 4 years ago
committed by GitHub
parent
commit
0eb29d9e9e
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      modules/account/src/Volo.Abp.Account.Blazor/AbpAccountBlazorAutoMapperProfile.cs
  2. 19
      modules/account/src/Volo.Abp.Account.Blazor/AbpAccountBlazorModule.cs
  3. 5
      modules/account/src/Volo.Abp.Account.Blazor/Pages/Account/AccountManage.razor
  4. 5
      modules/account/src/Volo.Abp.Account.Blazor/Pages/Account/AccountManage.razor.cs
  5. 3
      modules/account/src/Volo.Abp.Account.Web/AbpAccountWebAutomapperProfile.cs
  6. 19
      modules/account/src/Volo.Abp.Account.Web/AbpAccountWebModule.cs
  7. 8
      modules/account/src/Volo.Abp.Account.Web/Pages/Account/Components/ProfileManagementGroup/PersonalInfo/AccountProfilePersonalInfoManagementGroupViewComponent.cs
  8. 51
      modules/account/src/Volo.Abp.Account.Web/Pages/Account/Components/ProfileManagementGroup/PersonalInfo/Default.cshtml
  9. 2
      modules/account/src/Volo.Abp.Account.Web/Pages/Account/Components/ProfileManagementGroup/PersonalInfo/Default.js

3
modules/account/src/Volo.Abp.Account.Blazor/AbpAccountBlazorAutoMapperProfile.cs

@ -10,10 +10,11 @@ public class AbpAccountBlazorAutoMapperProfile : Profile
public AbpAccountBlazorAutoMapperProfile() public AbpAccountBlazorAutoMapperProfile()
{ {
CreateMap<ProfileDto, PersonalInfoModel>() CreateMap<ProfileDto, PersonalInfoModel>()
.MapExtraProperties()
.Ignore(x => x.PhoneNumberConfirmed) .Ignore(x => x.PhoneNumberConfirmed)
.Ignore(x => x.EmailConfirmed); .Ignore(x => x.EmailConfirmed);
CreateMap<PersonalInfoModel, UpdateProfileDto>() CreateMap<PersonalInfoModel, UpdateProfileDto>()
.Ignore(x => x.ExtraProperties); .MapExtraProperties();
} }
} }

19
modules/account/src/Volo.Abp.Account.Blazor/AbpAccountBlazorModule.cs

@ -1,8 +1,12 @@
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.Account.Blazor.Pages.Account;
using Volo.Abp.AspNetCore.Components.Web.Theming; using Volo.Abp.AspNetCore.Components.Web.Theming;
using Volo.Abp.AspNetCore.Components.Web.Theming.Routing; using Volo.Abp.AspNetCore.Components.Web.Theming.Routing;
using Volo.Abp.AutoMapper; using Volo.Abp.AutoMapper;
using Volo.Abp.Modularity; using Volo.Abp.Modularity;
using Volo.Abp.ObjectExtending;
using Volo.Abp.ObjectExtending.Modularity;
using Volo.Abp.Threading;
using Volo.Abp.UI.Navigation; using Volo.Abp.UI.Navigation;
namespace Volo.Abp.Account.Blazor; namespace Volo.Abp.Account.Blazor;
@ -14,6 +18,8 @@ namespace Volo.Abp.Account.Blazor;
)] )]
public class AbpAccountBlazorModule : AbpModule public class AbpAccountBlazorModule : AbpModule
{ {
private readonly static OneTimeRunner OneTimeRunner = new OneTimeRunner();
public override void ConfigureServices(ServiceConfigurationContext context) public override void ConfigureServices(ServiceConfigurationContext context)
{ {
context.Services.AddAutoMapperObjectMapper<AbpAccountBlazorModule>(); context.Services.AddAutoMapperObjectMapper<AbpAccountBlazorModule>();
@ -33,4 +39,17 @@ public class AbpAccountBlazorModule : AbpModule
options.AdditionalAssemblies.Add(typeof(AbpAccountBlazorModule).Assembly); options.AdditionalAssemblies.Add(typeof(AbpAccountBlazorModule).Assembly);
}); });
} }
public override void PostConfigureServices(ServiceConfigurationContext context)
{
OneTimeRunner.Run(() =>
{
ModuleExtensionConfigurationHelper
.ApplyEntityConfigurationToUi(
IdentityModuleExtensionConsts.ModuleName,
IdentityModuleExtensionConsts.EntityNames.User,
editFormTypes: new[] { typeof(PersonalInfoModel) }
);
});
}
} }

5
modules/account/src/Volo.Abp.Account.Blazor/Pages/Account/AccountManage.razor

@ -1,5 +1,9 @@
@page "/account/manage-profile" @page "/account/manage-profile"
@using Microsoft.AspNetCore.Components.Forms @using Microsoft.AspNetCore.Components.Forms
@using Volo.Abp.Account.Localization
@using Volo.Abp.AspNetCore.Components.Web
@using Volo.Abp.BlazoriseUI.Components.ObjectExtending
@inject AbpBlazorMessageLocalizerHelper<AccountResource> LH
@inherits AbpAccountComponentBase @inherits AbpAccountComponentBase
<Row> <Row>
@ -58,6 +62,7 @@
<FieldLabel>@L["DisplayName:PhoneNumber"]</FieldLabel> <FieldLabel>@L["DisplayName:PhoneNumber"]</FieldLabel>
<TextEdit @bind-Text="@PersonalInfoModel.PhoneNumber"/> <TextEdit @bind-Text="@PersonalInfoModel.PhoneNumber"/>
</Field> </Field>
<ExtensionProperties TEntityType="PersonalInfoModel" TResourceType="AccountResource" Entity="@PersonalInfoModel" LH="@LH"/>
<Field> <Field>
<SubmitButton Form="UpdatePersonalInfoForm" Clicked="@UpdatePersonalInfoAsync" /> <SubmitButton Form="UpdatePersonalInfoForm" Clicked="@UpdatePersonalInfoAsync" />
</Field> </Field>

5
modules/account/src/Volo.Abp.Account.Blazor/Pages/Account/AccountManage.razor.cs

@ -2,6 +2,7 @@
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
using Volo.Abp.AspNetCore.Components.Messages; using Volo.Abp.AspNetCore.Components.Messages;
using Volo.Abp.Identity; using Volo.Abp.Identity;
using Volo.Abp.ObjectExtending;
namespace Volo.Abp.Account.Blazor.Pages.Account; namespace Volo.Abp.Account.Blazor.Pages.Account;
@ -58,7 +59,7 @@ public partial class AccountManage
await UiMessageService.Success(L["PasswordChanged"]); await UiMessageService.Success(L["PasswordChanged"]);
} }
protected async Task UpdatePersonalInfoAsync() protected virtual async Task UpdatePersonalInfoAsync()
{ {
await ProfileAppService.UpdateAsync( await ProfileAppService.UpdateAsync(
ObjectMapper.Map<PersonalInfoModel, UpdateProfileDto>(PersonalInfoModel) ObjectMapper.Map<PersonalInfoModel, UpdateProfileDto>(PersonalInfoModel)
@ -86,7 +87,7 @@ public class ChangePasswordModel
} }
} }
public class PersonalInfoModel public class PersonalInfoModel : ExtensibleObject
{ {
public string UserName { get; set; } public string UserName { get; set; }

3
modules/account/src/Volo.Abp.Account.Web/AbpAccountWebAutomapperProfile.cs

@ -9,6 +9,7 @@ public class AbpAccountWebAutoMapperProfile : Profile
{ {
public AbpAccountWebAutoMapperProfile() public AbpAccountWebAutoMapperProfile()
{ {
CreateMap<ProfileDto, AccountProfilePersonalInfoManagementGroupViewComponent.PersonalInfoModel>(); CreateMap<ProfileDto, AccountProfilePersonalInfoManagementGroupViewComponent.PersonalInfoModel>()
.MapExtraProperties();
} }
} }

19
modules/account/src/Volo.Abp.Account.Web/AbpAccountWebModule.cs

@ -2,6 +2,7 @@
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.Account.Localization; using Volo.Abp.Account.Localization;
using Volo.Abp.Account.Web.Pages.Account; using Volo.Abp.Account.Web.Pages.Account;
using Volo.Abp.Account.Web.Pages.Account.Components.ProfileManagementGroup.PersonalInfo;
using Volo.Abp.Account.Web.ProfileManagement; using Volo.Abp.Account.Web.ProfileManagement;
using Volo.Abp.AspNetCore.Mvc.Localization; using Volo.Abp.AspNetCore.Mvc.Localization;
using Volo.Abp.AspNetCore.Mvc.UI.Bundling; using Volo.Abp.AspNetCore.Mvc.UI.Bundling;
@ -12,6 +13,9 @@ using Volo.Abp.ExceptionHandling;
using Volo.Abp.Http.ProxyScripting.Generators.JQuery; using Volo.Abp.Http.ProxyScripting.Generators.JQuery;
using Volo.Abp.Identity.AspNetCore; using Volo.Abp.Identity.AspNetCore;
using Volo.Abp.Modularity; using Volo.Abp.Modularity;
using Volo.Abp.ObjectExtending;
using Volo.Abp.ObjectExtending.Modularity;
using Volo.Abp.Threading;
using Volo.Abp.UI.Navigation; using Volo.Abp.UI.Navigation;
using Volo.Abp.VirtualFileSystem; using Volo.Abp.VirtualFileSystem;
@ -26,6 +30,8 @@ namespace Volo.Abp.Account.Web;
)] )]
public class AbpAccountWebModule : AbpModule public class AbpAccountWebModule : AbpModule
{ {
private readonly static OneTimeRunner OneTimeRunner = new OneTimeRunner();
public override void PreConfigureServices(ServiceConfigurationContext context) public override void PreConfigureServices(ServiceConfigurationContext context)
{ {
context.Services.PreConfigure<AbpMvcDataAnnotationsLocalizationOptions>(options => context.Services.PreConfigure<AbpMvcDataAnnotationsLocalizationOptions>(options =>
@ -95,4 +101,17 @@ public class AbpAccountWebModule : AbpModule
}); });
} }
public override void PostConfigureServices(ServiceConfigurationContext context)
{
OneTimeRunner.Run(() =>
{
ModuleExtensionConfigurationHelper
.ApplyEntityConfigurationToUi(
IdentityModuleExtensionConsts.ModuleName,
IdentityModuleExtensionConsts.EntityNames.User,
editFormTypes: new[] { typeof(AccountProfilePersonalInfoManagementGroupViewComponent.PersonalInfoModel) }
);
});
}
} }

8
modules/account/src/Volo.Abp.Account.Web/Pages/Account/Components/ProfileManagementGroup/PersonalInfo/AccountProfilePersonalInfoManagementGroupViewComponent.cs

@ -5,6 +5,7 @@ using Volo.Abp.AspNetCore.Mvc;
using Volo.Abp.AspNetCore.Mvc.UI.Widgets; using Volo.Abp.AspNetCore.Mvc.UI.Widgets;
using Volo.Abp.Domain.Entities; using Volo.Abp.Domain.Entities;
using Volo.Abp.Identity; using Volo.Abp.Identity;
using Volo.Abp.ObjectExtending;
using Volo.Abp.Validation; using Volo.Abp.Validation;
namespace Volo.Abp.Account.Web.Pages.Account.Components.ProfileManagementGroup.PersonalInfo; namespace Volo.Abp.Account.Web.Pages.Account.Components.ProfileManagementGroup.PersonalInfo;
@ -30,7 +31,7 @@ public class AccountProfilePersonalInfoManagementGroupViewComponent : AbpViewCom
return View("~/Pages/Account/Components/ProfileManagementGroup/PersonalInfo/Default.cshtml", model); return View("~/Pages/Account/Components/ProfileManagementGroup/PersonalInfo/Default.cshtml", model);
} }
public class PersonalInfoModel : IHasConcurrencyStamp public class PersonalInfoModel : ExtensibleObject, IHasConcurrencyStamp
{ {
[Required] [Required]
[DynamicStringLength(typeof(IdentityUserConsts), nameof(IdentityUserConsts.MaxUserNameLength))] [DynamicStringLength(typeof(IdentityUserConsts), nameof(IdentityUserConsts.MaxUserNameLength))]
@ -54,7 +55,6 @@ public class AccountProfilePersonalInfoManagementGroupViewComponent : AbpViewCom
[Display(Name = "DisplayName:PhoneNumber")] [Display(Name = "DisplayName:PhoneNumber")]
public string PhoneNumber { get; set; } public string PhoneNumber { get; set; }
[HiddenInput] [HiddenInput] public string ConcurrencyStamp { get; set; }
public string ConcurrencyStamp { get; set; }
} }
} }

51
modules/account/src/Volo.Abp.Account.Web/Pages/Account/Components/ProfileManagementGroup/PersonalInfo/Default.cshtml

@ -1,13 +1,24 @@
@using Volo.Abp.Account.Localization @using Volo.Abp.Account.Localization
@using Volo.Abp.Users @using Volo.Abp.Users
@using Microsoft.AspNetCore.Mvc.Localization @using Microsoft.AspNetCore.Mvc.Localization
@using Microsoft.AspNetCore.Mvc.TagHelpers
@using Microsoft.Extensions.Localization
@using Volo.Abp.Account.Web.Pages.Account.Components.ProfileManagementGroup.PersonalInfo
@using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Alert
@using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Button
@using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form
@using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Grid
@using Volo.Abp.AspNetCore.Mvc.UI.Theming @using Volo.Abp.AspNetCore.Mvc.UI.Theming
@using Volo.Abp.Data
@using Volo.Abp.Identity.Settings @using Volo.Abp.Identity.Settings
@using Volo.Abp.Localization
@using Volo.Abp.ObjectExtending
@using Volo.Abp.Settings @using Volo.Abp.Settings
@inject IHtmlLocalizer<AccountResource> L @inject IHtmlLocalizer<AccountResource> L
@inject ICurrentUser CurrentUser @inject ICurrentUser CurrentUser
@inject ISettingProvider SettingManager @inject ISettingProvider SettingManager
@inject IThemeManager ThemeManager @inject IThemeManager ThemeManager
@inject IStringLocalizerFactory StringLocalizerFactory
@model Volo.Abp.Account.Web.Pages.Account.Components.ProfileManagementGroup.PersonalInfo.AccountProfilePersonalInfoManagementGroupViewComponent.PersonalInfoModel @model Volo.Abp.Account.Web.Pages.Account.Components.ProfileManagementGroup.PersonalInfo.AccountProfilePersonalInfoManagementGroupViewComponent.PersonalInfoModel
@{ @{
var isUserNameUpdateEnabled = string.Equals(await SettingManager.GetOrNullAsync(IdentitySettingNames.User.IsUserNameUpdateEnabled), "true", var isUserNameUpdateEnabled = string.Equals(await SettingManager.GetOrNullAsync(IdentitySettingNames.User.IsUserNameUpdateEnabled), "true",
@ -19,8 +30,8 @@
<h4>@L["PersonalSettings"]</h4><hr/> <h4>@L["PersonalSettings"]</h4><hr/>
<form method="post" id="PersonalSettingsForm"> <form method="post" id="PersonalSettingsForm">
<input asp-for="ConcurrencyStamp" /> <input asp-for="ConcurrencyStamp"/>
<abp-input asp-for="UserName" readonly="!isUserNameUpdateEnabled"/> <abp-input asp-for="UserName" readonly="!isUserNameUpdateEnabled"/>
@ -37,5 +48,39 @@
<abp-input asp-for="PhoneNumber"/> <abp-input asp-for="PhoneNumber"/>
@foreach (var propertyInfo in ObjectExtensionManager.Instance.GetProperties<AccountProfilePersonalInfoManagementGroupViewComponent.PersonalInfoModel>())
{
if (!propertyInfo.Name.EndsWith("_Text"))
{
if (propertyInfo.Type.IsEnum || !propertyInfo.Lookup.Url.IsNullOrEmpty())
{
if (propertyInfo.Type.IsEnum)
{
Model.ExtraProperties.ToEnum(propertyInfo.Name, propertyInfo.Type);
}
<abp-select asp-for="ExtraProperties[propertyInfo.Name]"
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">
</abp-select>
}
else
{
<abp-input type="@propertyInfo.GetInputType()"
asp-for="ExtraProperties[propertyInfo.Name]"
name="ExtraProperties.@propertyInfo.Name"
label="@propertyInfo.GetLocalizedDisplayName(StringLocalizerFactory)"
asp-format="@propertyInfo.GetInputFormatOrNull()"
value="@propertyInfo.GetInputValueOrNull(Model.GetProperty(propertyInfo.Name))"/>
}
}
}
<abp-button type="submit" button-type="Primary" text="@L["Submit"].Value"/> <abp-button type="submit" button-type="Primary" text="@L["Submit"].Value"/>
</form> </form>

2
modules/account/src/Volo.Abp.Account.Web/Pages/Account/Components/ProfileManagementGroup/PersonalInfo/Default.js

@ -9,7 +9,7 @@
return false; return false;
} }
var input = $('#PersonalSettingsForm').serializeFormToObject(); var input = $('#PersonalSettingsForm').serializeFormToObject(false);
volo.abp.account.profile.update(input).then(function (result) { volo.abp.account.profile.update(input).then(function (result) {
abp.notify.success(l('PersonalSettingsSaved')); abp.notify.success(l('PersonalSettingsSaved'));

Loading…
Cancel
Save