Browse Source

Merge pull request #6008 from abpframework/cotur/component-base

Remove abstract component bases and more for blazor components
pull/6030/head
Halil İbrahim Kalkan 6 years ago
committed by GitHub
parent
commit
30b7e6d510
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 14
      modules/account/src/Volo.Abp.Account.Blazor/AbpAccountComponentBase.cs
  2. 20
      modules/account/src/Volo.Abp.Account.Blazor/Pages/Account/AccountManage.razor
  3. 17
      modules/account/src/Volo.Abp.Account.Blazor/Pages/Account/AccountManage.razor.cs
  4. 6
      modules/account/src/Volo.Abp.Account.Blazor/Volo.Abp.Account.Blazor.csproj
  5. 13
      modules/feature-management/src/Volo.Abp.FeatureManagement.Blazor/AbpFeatureManagementComponentBase.cs
  6. 140
      modules/feature-management/src/Volo.Abp.FeatureManagement.Blazor/Components/FeatureManagementModal.razor
  7. 2
      modules/feature-management/src/Volo.Abp.FeatureManagement.Blazor/Components/FeatureManagementModal.razor.cs
  8. 8
      modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/RoleManagement.razor
  9. 9
      modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/RoleManagement.razor.cs
  10. 8
      modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/UserManagement.razor
  11. 5
      modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/UserManagement.razor.cs
  12. 2
      modules/setting-management/src/Volo.Abp.SettingManagement.Blazor/Pages/SettingManagement/SettingManagement.razor
  13. 4
      modules/setting-management/src/Volo.Abp.SettingManagement.Blazor/Pages/SettingManagement/SettingManagement.razor.cs
  14. 8
      modules/tenant-management/src/Volo.Abp.TenantManagement.Blazor/Pages/TenantManagement/TenantManagement.razor
  15. 9
      modules/tenant-management/src/Volo.Abp.TenantManagement.Blazor/Pages/TenantManagement/TenantManagement.razor.cs

14
modules/account/src/Volo.Abp.Account.Blazor/AbpAccountComponentBase.cs

@ -0,0 +1,14 @@
using Volo.Abp.Account.Localization;
using Volo.Abp.AspNetCore.Components;
namespace Volo.Abp.Account.Blazor
{
public abstract class AbpAccountComponentBase : AbpComponentBase
{
protected AbpAccountComponentBase()
{
LocalizationResource = typeof(AccountResource);
ObjectMapperContext = typeof(AbpAccountBlazorModule);
}
}
}

20
modules/account/src/Volo.Abp.Account.Blazor/Pages/Account/Manage.razor → modules/account/src/Volo.Abp.Account.Blazor/Pages/Account/AccountManage.razor

@ -1,5 +1,7 @@
@page "/account/manage-profile"
@inherits AccountManageBase
@using Microsoft.AspNetCore.Components.Forms
@inherits AbpAccountComponentBase
<Row>
<Column ColumnSize="ColumnSize.Is12">
<Tabs @bind-SelectedTab="@SelectedTab" TabPosition="TabPosition.Left" Pills="true">
@ -14,15 +16,15 @@
<EditForm id="ChangePasswordForm" Model="@ChangePasswordModel" OnValidSubmit="ChangePasswordAsync">
<Field>
<FieldLabel>@L["DisplayName:CurrentPassword"]</FieldLabel>
<TextEdit Role="TextRole.Password" @bind-text="@ChangePasswordModel.CurrentPassword"/>
<TextEdit Role="@TextRole.Password" @bind-Text="@ChangePasswordModel.CurrentPassword"/>
</Field>
<Field>
<FieldLabel>@L["DisplayName:NewPassword"]</FieldLabel>
<TextEdit Role="TextRole.Password" @bind-text="@ChangePasswordModel.NewPassword"/>
<TextEdit Role="@TextRole.Password" @bind-Text="@ChangePasswordModel.NewPassword"/>
</Field>
<Field>
<FieldLabel>@L["DisplayName:NewPasswordConfirm"]</FieldLabel>
<TextEdit Role="TextRole.Password" @bind-text="@ChangePasswordModel.NewPasswordConfirm"/>
<TextEdit Role="@TextRole.Password" @bind-Text="@ChangePasswordModel.NewPasswordConfirm"/>
</Field>
<Field>
<Button form="ChangePasswordForm" Color="Color.Primary" Clicked="@ChangePasswordAsync">@L["Save"]</Button>
@ -36,25 +38,25 @@
<EditForm id="UpdatePersonalInfoForm" Model="@PersonalInfoModel" OnValidSubmit="UpdatePersonalInfoAsync">
<Field>
<FieldLabel>@L["DisplayName:UserName"]</FieldLabel>
<TextEdit @bind-text="@PersonalInfoModel.UserName"/>
<TextEdit @bind-Text="@PersonalInfoModel.UserName"/>
</Field>
<Fields>
<Field ColumnSize="ColumnSize.Is6">
<FieldLabel>@L["DisplayName:Name"]</FieldLabel>
<TextEdit @bind-text="@PersonalInfoModel.Name"/>
<TextEdit @bind-Text="@PersonalInfoModel.Name"/>
</Field>
<Field ColumnSize="ColumnSize.Is6">
<FieldLabel>@L["DisplayName:Surname"]</FieldLabel>
<TextEdit @bind-text="@PersonalInfoModel.Surname"/>
<TextEdit @bind-Text="@PersonalInfoModel.Surname"/>
</Field>
</Fields>
<Field>
<FieldLabel>@L["DisplayName:Email"]</FieldLabel>
<TextEdit @bind-text="@PersonalInfoModel.Email"/>
<TextEdit @bind-Text="@PersonalInfoModel.Email"/>
</Field>
<Field>
<FieldLabel>@L["DisplayName:PhoneNumber"]</FieldLabel>
<TextEdit @bind-text="@PersonalInfoModel.PhoneNumber"/>
<TextEdit @bind-Text="@PersonalInfoModel.PhoneNumber"/>
</Field>
<Field>
<Button form="UpdatePersonalInfoForm" Color="Color.Primary" Clicked="@UpdatePersonalInfoAsync">@L["Save"]</Button>

17
modules/account/src/Volo.Abp.Account.Blazor/Pages/Account/Manage.razor.cs → modules/account/src/Volo.Abp.Account.Blazor/Pages/Account/AccountManage.razor.cs

@ -1,33 +1,22 @@
using System.Threading.Tasks;
using Localization.Resources.AbpUi;
using Microsoft.AspNetCore.Components;
using Microsoft.Extensions.Localization;
using Volo.Abp.Account.Localization;
using Volo.Abp.AspNetCore.Components.WebAssembly;
using Volo.Abp.Identity;
using Volo.Abp.ObjectMapping;
namespace Volo.Abp.Account.Blazor.Pages.Account
{
public abstract class AccountManageBase : OwningComponentBase
public partial class AccountManage
{
[Inject] protected IAccountAppService AccountAppService { get; set; }
[Inject] protected IProfileAppService ProfileAppService { get; set; }
[Inject] protected IObjectMapper<AbpAccountBlazorModule> ObjectMapper { get; set; }
[Inject] protected IUiMessageService UiMessageService { get; set; }
[Inject] protected IStringLocalizer<AbpUiResource> UiLocalizer { get; set; }
[Inject] protected IStringLocalizer<AccountResource> L { get; set; }
protected string SelectedTab = "Password";
protected ChangePasswordModel ChangePasswordModel;
protected PersonalInfoModel PersonalInfoModel;
protected async override Task OnInitializedAsync()
{
await GetUserInformations();

6
modules/account/src/Volo.Abp.Account.Blazor/Volo.Abp.Account.Blazor.csproj

@ -17,10 +17,4 @@
<ProjectReference Include="..\Volo.Abp.Account.HttpApi.Client\Volo.Abp.Account.HttpApi.Client.csproj" />
</ItemGroup>
<ItemGroup>
<Content Update="Pages\Account\Manage.razor">
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
</Content>
</ItemGroup>
</Project>

13
modules/feature-management/src/Volo.Abp.FeatureManagement.Blazor/AbpFeatureManagementComponentBase.cs

@ -0,0 +1,13 @@
using Volo.Abp.AspNetCore.Components;
using Volo.Abp.FeatureManagement.Localization;
namespace Volo.Abp.FeatureManagement.Blazor
{
public abstract class AbpFeatureManagementComponentBase : AbpComponentBase
{
protected AbpFeatureManagementComponentBase()
{
LocalizationResource = typeof(AbpFeatureManagementResource);
}
}
}

140
modules/feature-management/src/Volo.Abp.FeatureManagement.Blazor/Components/FeatureManagementModal.razor

@ -1,6 +1,8 @@
@using Volo.Abp.Validation.StringValues
@using Microsoft.Extensions.Localization
@inherits AbpFeatureManagementComponentBase
<Modal @ref="Modal">
<ModalBackdrop />
<ModalContent Size="ModalSize.Large" IsCentered="true">
@ -9,84 +11,80 @@
<CloseButton Clicked="CloseModal" />
</ModalHeader>
<ModalBody MaxHeight="50">
<EditForm id="UpdateFeaturesForm" OnValidSubmit="SaveAsync">
@if (Groups == null)
{
<span>@L["NoFeatureFoundMessage"]</span>
}
else
{
<Tabs TabPosition="TabPosition.Left" Pills="true" @bind-SelectedTab="@SelectedTabName">
<Items>
@foreach (var group in Groups)
{
<Tab Name="@GetNormalizedGroupName(group.Name)">
<span>@group.DisplayName</span>
</Tab>
}
</Items>
<Content>
@foreach (var group in Groups)
{
<TabPanel Name="@GetNormalizedGroupName(group.Name)">
<h4>@group.DisplayName</h4>
@foreach (var feature in group.Features)
@if (Groups == null)
{
<span>@L["NoFeatureFoundMessage"]</span>
}
else
{
<Tabs TabPosition="TabPosition.Left" Pills="true" @bind-SelectedTab="@SelectedTabName">
<Items>
@foreach (var group in Groups)
{
<Tab Name="@GetNormalizedGroupName(group.Name)">
<span>@group.DisplayName</span>
</Tab>
}
</Items>
<Content>
@foreach (var group in Groups)
{
<TabPanel Name="@GetNormalizedGroupName(group.Name)">
<h4>@group.DisplayName</h4>
@foreach (var feature in group.Features)
{
var disabled = IsDisabled(feature.Provider.Name);
if (feature.ValueType is FreeTextStringValueType)
{
var disabled = IsDisabled(feature.Provider.Name);
if (feature.ValueType is FreeTextStringValueType)
{
<Field>
<FieldLabel>@feature.DisplayName</FieldLabel>
<TextEdit
Disabled="@disabled"
Text="@feature.Value"
TextChanged="@(async(v) => await OnFeatureValueChangedAsync(v, feature))" />
@if (feature.Description != null)
<Field>
<FieldLabel>@feature.DisplayName</FieldLabel>
<TextEdit Disabled="@disabled"
Text="@feature.Value"
TextChanged="@(async(v) => await OnFeatureValueChangedAsync(v, feature))" />
@if (feature.Description != null)
{
<span>@feature.Description</span>
}
</Field>
}
if (feature.ValueType is SelectionStringValueType)
{
var items = ((SelectionStringValueType)feature.ValueType).ItemSource.Items;
<Field>
<FieldLabel>@feature.DisplayName</FieldLabel>
<Select TValue="string"
@bind-SelectedValue="@SelectionStringValues[feature.Name]">
@foreach (var item in items)
{
<span>@feature.Description</span>
<SelectItem Value="@item.Value">
@CreateStringLocalizer(item.DisplayText.ResourceName).GetString(item.DisplayText.Name)
</SelectItem>
}
</Field>
}
if (feature.ValueType is SelectionStringValueType)
{
var items = ((SelectionStringValueType) feature.ValueType).ItemSource.Items;
<Field>
<FieldLabel>@feature.DisplayName</FieldLabel>
<Select
TValue="string"
@bind-SelectedValue="@SelectionStringValues[feature.Name]">
@foreach (var item in items)
{
<SelectItem Value="@item.Value">
@CreateStringLocalizer(item.DisplayText.ResourceName).GetString(item.DisplayText.Name)
</SelectItem>
}
</Select>
</Field>
}
if (feature.ValueType is ToggleStringValueType)
{
<Field>
<Check TValue="bool" @bind-checked="@ToggleValues[feature.Name]">@feature.DisplayName</Check>
</Field>
}
</Select>
</Field>
}
if (feature.ValueType is ToggleStringValueType)
{
<Field>
<Check TValue="bool" @bind-checked="@ToggleValues[feature.Name]">@feature.DisplayName</Check>
</Field>
}
</TabPanel>
}
</Content>
</Tabs>
}
</EditForm>
}
</TabPanel>
}
</Content>
</Tabs>
}
</ModalBody>
<ModalFooter>
<Button Color="Color.Secondary" Clicked="CloseModal">@L["Cancel"]</Button>
<Button form="UpdateFeaturesForm" Color="Color.Primary" Clicked="SaveAsync">@L["Save"]</Button>
<Button Color="Color.Primary" Clicked="SaveAsync">@L["Save"]</Button>
</ModalFooter>
</ModalContent>
</Modal>

2
modules/feature-management/src/Volo.Abp.FeatureManagement.Blazor/Components/FeatureManagementModal.razor.cs

@ -20,8 +20,6 @@ namespace Volo.Abp.FeatureManagement.Blazor.Components
[Inject] protected IUiMessageService UiMessageService { get; set; }
[Inject] protected IStringLocalizer<AbpFeatureManagementResource> L { get; set; }
[Inject] protected IStringLocalizerFactory HtmlLocalizerFactory { get; set; }
[Inject] protected IOptions<AbpLocalizationOptions> LocalizationOptions { get; set; }

8
modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/RoleManagement.razor

@ -2,12 +2,14 @@
@attribute [Authorize(IdentityPermissions.Roles.Default)]
@using Volo.Abp.Identity
@using Microsoft.AspNetCore.Authorization
@using Microsoft.AspNetCore.Components.Forms
@using Volo.Abp.PermissionManagement.Blazor.Components
@using Microsoft.Extensions.Localization
@using Volo.Abp.Identity.Localization
@using Volo.Abp.PermissionManagement.Blazor.Components
@inherits RoleManagementBase
@inject IStringLocalizer<IdentityResource> L
@inject AbpIdentityBlazorMessageLocalizerHelper<IdentityResource> LH
@inherits AbpCrudPageBase<IIdentityRoleAppService, IdentityRoleDto, Guid, GetIdentityRolesInput, IdentityRoleCreateDto, IdentityRoleUpdateDto>
@* ************************* PAGE HEADER ************************* *@
<Row>
<Column ColumnSize="ColumnSize.Is6">

9
modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/RoleManagement.razor.cs

@ -1,14 +1,13 @@
using System;
using System;
using System.Threading.Tasks;
using Blazorise;
using Microsoft.AspNetCore.Authorization;
using Volo.Abp.BlazoriseUI;
using Volo.Abp.Identity.Localization;
using Volo.Abp.PermissionManagement.Blazor.Components;
namespace Volo.Abp.Identity.Blazor.Pages.Identity
{
public abstract class RoleManagementBase : AbpCrudPageBase<IIdentityRoleAppService, IdentityRoleDto, Guid, GetIdentityRolesInput, IdentityRoleCreateDto, IdentityRoleUpdateDto>
public partial class RoleManagement
{
protected const string PermissionProviderName = "R";
@ -17,7 +16,9 @@ namespace Volo.Abp.Identity.Blazor.Pages.Identity
protected bool HasManagePermissionsPermission { get; set; }
public RoleManagementBase()
protected bool ShouldShowEntityActions { get; set; }
public RoleManagement()
{
ObjectMapperContext = typeof(AbpIdentityBlazorModule);
LocalizationResource = typeof(IdentityResource);

8
modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/UserManagement.razor

@ -1,11 +1,13 @@
@page "/identity/users"
@attribute [Authorize(IdentityPermissions.Users.Default)]
@using Microsoft.AspNetCore.Authorization
@using Microsoft.AspNetCore.Components.Forms
@using Volo.Abp.PermissionManagement.Blazor.Components
@using Microsoft.Extensions.Localization
@using Volo.Abp.Identity.Localization
@using Volo.Abp.PermissionManagement.Blazor.Components
@inherits UserManagementBase
@inject IStringLocalizer<IdentityResource> L
@inherits AbpCrudPageBase<IIdentityUserAppService, IdentityUserDto, Guid, GetIdentityUsersInput, IdentityUserCreateDto, IdentityUserUpdateDto>
@inject AbpIdentityBlazorMessageLocalizerHelper<IdentityResource> LH
@* ************************* PAGE HEADER ************************* *@
<Row>

5
modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/UserManagement.razor.cs

@ -4,13 +4,12 @@ using System.Linq;
using System.Threading.Tasks;
using Blazorise;
using Microsoft.AspNetCore.Authorization;
using Volo.Abp.BlazoriseUI;
using Volo.Abp.Identity.Localization;
using Volo.Abp.PermissionManagement.Blazor.Components;
namespace Volo.Abp.Identity.Blazor.Pages.Identity
{
public abstract class UserManagementBase : AbpCrudPageBase<IIdentityUserAppService, IdentityUserDto, Guid, GetIdentityUsersInput, IdentityUserCreateDto, IdentityUserUpdateDto>
public partial class UserManagement
{
protected const string PermissionProviderName = "U";
@ -30,7 +29,7 @@ namespace Volo.Abp.Identity.Blazor.Pages.Identity
protected string EditModalSelectedTab = DefaultSelectedTab;
public UserManagementBase()
public UserManagement()
{
ObjectMapperContext = typeof(AbpIdentityBlazorModule);
LocalizationResource = typeof(IdentityResource);

2
modules/setting-management/src/Volo.Abp.SettingManagement.Blazor/Pages/SettingManagement/SettingManagement.razor

@ -1,5 +1,5 @@
@page "/setting-management"
@inherits SettingManagementBase
@* ************************* PAGE HEADER ************************* *@
<PageHeader Title="@L["Settings"]" BreadcrumbItems="@BreadcrumbItems">

4
modules/setting-management/src/Volo.Abp.SettingManagement.Blazor/Pages/SettingManagement/SettingManagement.razor.cs

@ -10,7 +10,7 @@ using Volo.Abp.SettingManagement.Localization;
namespace Volo.Abp.SettingManagement.Blazor.Pages.SettingManagement
{
public abstract class SettingManagementBase : OwningComponentBase
public partial class SettingManagement
{
[Inject]
protected IServiceProvider ServiceProvider { get; set; }
@ -44,7 +44,7 @@ namespace Volo.Abp.SettingManagement.Blazor.Pages.SettingManagement
BreadcrumbItems.Add(new BreadcrumbItem(L["Settings"]));
}
protected string GetNormalizedString(string value)
protected virtual string GetNormalizedString(string value)
{
return value.Replace('.', '_');
}

8
modules/tenant-management/src/Volo.Abp.TenantManagement.Blazor/Pages/TenantManagement/TenantManagement.razor

@ -1,11 +1,11 @@
@page "/tenant-management/tenants"
@attribute [Authorize(TenantManagementPermissions.Tenants.Default)]
@using Microsoft.AspNetCore.Authorization
@using Microsoft.Extensions.Localization
@using Volo.Abp.TenantManagement.Localization
@using Volo.Abp.FeatureManagement.Blazor.Components
@inherits TenantManagementBase
@inject IStringLocalizer<AbpTenantManagementResource> L
@using Microsoft.AspNetCore.Components.Forms
@inherits AbpCrudPageBase<ITenantAppService, TenantDto, Guid, GetTenantsInput, TenantCreateDto, TenantUpdateDto>
@* ************************* PAGE HEADER ************************* *@
<Row>
<Column ColumnSize="ColumnSize.Is6">

9
modules/tenant-management/src/Volo.Abp.TenantManagement.Blazor/Pages/TenantManagement/TenantManagement.razor.cs

@ -4,11 +4,11 @@ using Blazorise;
using Microsoft.AspNetCore.Authorization;
using Volo.Abp.BlazoriseUI;
using Volo.Abp.FeatureManagement.Blazor.Components;
using Volo.Abp.TenantManagement.Localization;
namespace Volo.Abp.TenantManagement.Blazor.Pages.TenantManagement
{
public abstract class TenantManagementBase
: AbpCrudPageBase<ITenantAppService, TenantDto, Guid, GetTenantsInput, TenantCreateDto, TenantUpdateDto>
public partial class TenantManagement
{
protected const string FeatureProviderName = "T";
@ -22,9 +22,10 @@ namespace Volo.Abp.TenantManagement.Blazor.Pages.TenantManagement
protected Modal ManageConnectionStringModal;
protected TenantInfoModel TenantInfo;
public TenantManagementBase()
public TenantManagement()
{
LocalizationResource = typeof(AbpTenantManagementResource);
ObjectMapperContext = typeof(AbpTenantManagementBlazorModule);
CreatePolicyName = TenantManagementPermissions.Tenants.Create;

Loading…
Cancel
Save