diff --git a/modules/tenant-management/src/Volo.Abp.TenantManagement.Blazor/AbpTenantManagementBlazorModule.cs b/modules/tenant-management/src/Volo.Abp.TenantManagement.Blazor/AbpTenantManagementBlazorModule.cs index c5a4970e79..201bcd4d0f 100644 --- a/modules/tenant-management/src/Volo.Abp.TenantManagement.Blazor/AbpTenantManagementBlazorModule.cs +++ b/modules/tenant-management/src/Volo.Abp.TenantManagement.Blazor/AbpTenantManagementBlazorModule.cs @@ -3,7 +3,10 @@ using Volo.Abp.AspNetCore.Components.WebAssembly.Theming.Routing; using Volo.Abp.AutoMapper; using Volo.Abp.FeatureManagement.Blazor; using Volo.Abp.Modularity; +using Volo.Abp.ObjectExtending; +using Volo.Abp.ObjectExtending.Modularity; using Volo.Abp.TenantManagement.Blazor.Navigation; +using Volo.Abp.Threading; using Volo.Abp.UI.Navigation; namespace Volo.Abp.TenantManagement.Blazor @@ -15,6 +18,8 @@ namespace Volo.Abp.TenantManagement.Blazor )] public class AbpTenantManagementBlazorModule : AbpModule { + private static readonly OneTimeRunner OneTimeRunner = new(); + public override void ConfigureServices(ServiceConfigurationContext context) { context.Services.AddAutoMapperObjectMapper(); @@ -34,5 +39,19 @@ namespace Volo.Abp.TenantManagement.Blazor options.AdditionalAssemblies.Add(typeof(AbpTenantManagementBlazorModule).Assembly); }); } + + public override void PostConfigureServices(ServiceConfigurationContext context) + { + OneTimeRunner.Run(() => + { + ModuleExtensionConfigurationHelper + .ApplyEntityConfigurationToUi( + TenantManagementModuleExtensionConsts.ModuleName, + TenantManagementModuleExtensionConsts.EntityNames.Tenant, + createFormTypes: new[] { typeof(TenantCreateDto) }, + editFormTypes: new[] { typeof(TenantUpdateDto) } + ); + }); + } } } 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 47fac0a124..9570c4b8f3 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 @@ -1,64 +1,32 @@ @page "/tenant-management/tenants" -@attribute [Authorize( TenantManagementPermissions.Tenants.Default )] +@attribute [Authorize(TenantManagementPermissions.Tenants.Default)] @using Microsoft.AspNetCore.Authorization @using Volo.Abp.FeatureManagement.Blazor.Components @using Microsoft.AspNetCore.Components.Forms @using Volo.Abp.TenantManagement.Localization +@using Volo.Abp.AspNetCore.Components.WebAssembly.Theming.Layout +@using Volo.Abp.BlazoriseUI.Components.ObjectExtending @inject AbpBlazorMessageLocalizerHelper LH @inherits AbpCrudPageBase @* ************************* PAGE HEADER ************************* *@ - - - @L["Tenants"] - - - @if (HasCreatePermission) - { - - } - - + + @* ************************* DATA GRID ************************* *@ - - - - - - - - - - - - - - @(context.Name) - - - - + + @@ -66,12 +34,12 @@ @if (HasCreatePermission) { - +
@L["NewTenant"] - + @@ -80,7 +48,7 @@ @L["TenantName"] - + @@ -90,7 +58,7 @@ @L["DisplayName:AdminEmailAddress"] - + @@ -100,16 +68,17 @@ @L["DisplayName:AdminPassword"] - + + - +
@@ -120,12 +89,12 @@ @if (HasUpdatePermission) { - +
@L["Edit"] - + @@ -134,16 +103,17 @@ @L["TenantName"] - + + - +
@@ -152,5 +122,5 @@ @if (HasManageFeaturesPermission) { - -} + +} \ No newline at end of file diff --git a/modules/tenant-management/src/Volo.Abp.TenantManagement.Blazor/Pages/TenantManagement/TenantManagement.razor.cs b/modules/tenant-management/src/Volo.Abp.TenantManagement.Blazor/Pages/TenantManagement/TenantManagement.razor.cs index 72c5d4e589..cd10d4ac3f 100644 --- a/modules/tenant-management/src/Volo.Abp.TenantManagement.Blazor/Pages/TenantManagement/TenantManagement.razor.cs +++ b/modules/tenant-management/src/Volo.Abp.TenantManagement.Blazor/Pages/TenantManagement/TenantManagement.razor.cs @@ -1,10 +1,15 @@ using System; +using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Threading.Tasks; using Blazorise; using Microsoft.AspNetCore.Authorization; +using Volo.Abp.AspNetCore.Components.Extensibility.EntityActions; +using Volo.Abp.AspNetCore.Components.Extensibility.TableColumns; +using Volo.Abp.AspNetCore.Components.WebAssembly.Theming.PageToolbars; using Volo.Abp.BlazoriseUI; using Volo.Abp.FeatureManagement.Blazor.Components; +using Volo.Abp.ObjectExtending; using Volo.Abp.TenantManagement.Localization; namespace Volo.Abp.TenantManagement.Blazor.Pages.TenantManagement @@ -20,6 +25,10 @@ namespace Volo.Abp.TenantManagement.Blazor.Pages.TenantManagement protected TenantInfoModel TenantInfo; + protected PageToolbar Toolbar { get; } = new(); + + protected List TenantManagementTableColumns => TableColumns.Get(); + public TenantManagement() { LocalizationResource = typeof(AbpTenantManagementResource); @@ -45,10 +54,78 @@ namespace Volo.Abp.TenantManagement.Blazor.Pages.TenantManagement { return string.Format(L["TenantDeletionConfirmationMessage"], entity.Name); } + + protected override ValueTask SetToolbarItemsAsync() + { + Toolbar.AddButton(L["NewTenant"], + OpenCreateModalAsync, + IconName.Add, + requiredPolicyName: CreatePolicyName); + + return base.SetToolbarItemsAsync(); + } + + protected override ValueTask SetEntityActionsAsync() + { + EntityActions + .Get() + .AddRange(new EntityAction[] + { + new EntityAction + { + Text = L["Edit"], + RequiredPolicy = UpdatePolicyName, + Clicked = async (data) => { await OpenEditModalAsync(data.As()); } + }, + new EntityAction + { + Text = L["Features"], + RequiredPolicy = ManageFeaturesPolicyName, + Clicked = async (data) => + { + var tenant = data.As(); + await FeatureManagementModal.OpenAsync(FeatureProviderName, tenant.Id.ToString()); + } + }, + new EntityAction + { + Text = L["Delete"], + RequiredPolicy = DeletePolicyName, + Clicked = async (data) => await DeleteEntityAsync(data.As()), + ConfirmationMessage = (data) => GetDeleteConfirmationMessage(data.As()) + } + }); + + return base.SetEntityActionsAsync(); + } + + protected override ValueTask SetTableColumnsAsync() + { + TenantManagementTableColumns + .AddRange(new TableColumn[] + { + new TableColumn + { + Title = L["Actions"], + Actions = EntityActions.Get() + }, + new TableColumn + { + Title = L["TenantName"], + Data = nameof(TenantDto.Name), + }, + }); + + TenantManagementTableColumns.AddRange(GetExtensionTableColumns( + TenantManagementModuleExtensionConsts.ModuleName, + TenantManagementModuleExtensionConsts.EntityNames.Tenant)); + + return base.SetTableColumnsAsync(); + } } public class TenantInfoModel { public Guid Id { get; set; } } -} +} \ No newline at end of file