Browse Source

Merge pull request #17254 from abpframework/liangshiwei/settingpage

Order setting tabs
EngincanV/maui-docs
maliming 3 years ago
committed by GitHub
parent
commit
209366593d
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      docs/en/Modules/Setting-Management.md
  2. 6
      docs/zh-Hans/Modules/Setting-Management.md
  3. 2
      modules/setting-management/src/Volo.Abp.SettingManagement.Blazor/Pages/SettingManagement/SettingManagement.razor.cs
  4. 13
      modules/setting-management/src/Volo.Abp.SettingManagement.Blazor/SettingComponentCreationContext.cs
  5. 7
      modules/setting-management/src/Volo.Abp.SettingManagement.Blazor/SettingComponentGroup.cs
  6. 1
      modules/setting-management/src/Volo.Abp.SettingManagement.Web/Pages/SettingManagement/SettingPageContributorManager.cs
  7. 13
      modules/setting-management/src/Volo.Abp.SettingManagement.Web/Pages/SettingManagement/SettingPageCreationContext.cs
  8. 7
      modules/setting-management/src/Volo.Abp.SettingManagement.Web/Pages/SettingManagement/SettingPageGroup.cs

6
docs/en/Modules/Setting-Management.md

@ -177,7 +177,8 @@ public class BookStoreSettingPageContributor : ISettingPageContributor
new SettingPageGroup( new SettingPageGroup(
"Volo.Abp.MySettingGroup", "Volo.Abp.MySettingGroup",
"MySettingGroup", "MySettingGroup",
typeof(MySettingGroupViewComponent) typeof(MySettingGroupViewComponent),
order : 1
) )
); );
@ -240,7 +241,8 @@ public class BookStoreSettingComponentContributor : ISettingComponentContributor
new SettingComponentGroup( new SettingComponentGroup(
"Volo.Abp.MySettingGroup", "Volo.Abp.MySettingGroup",
"MySettingGroup", "MySettingGroup",
typeof(MySettingGroupComponent) typeof(MySettingGroupComponent),
order : 1
) )
); );

6
docs/zh-Hans/Modules/Setting-Management.md

@ -146,7 +146,8 @@ public class BookStoreSettingPageContributor : ISettingPageContributor
new SettingPageGroup( new SettingPageGroup(
"Volo.Abp.MySettingGroup", "Volo.Abp.MySettingGroup",
"MySettingGroup", "MySettingGroup",
typeof(MySettingGroupViewComponent) typeof(MySettingGroupViewComponent),
order : 1
) )
); );
@ -209,7 +210,8 @@ public class BookStoreSettingComponentContributor : ISettingComponentContributor
new SettingComponentGroup( new SettingComponentGroup(
"Volo.Abp.MySettingGroup", "Volo.Abp.MySettingGroup",
"MySettingGroup", "MySettingGroup",
typeof(MySettingGroupComponent) typeof(MySettingGroupComponent),
order : 1
) )
); );

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

@ -39,7 +39,7 @@ public partial class SettingManagement
{ {
await contributor.ConfigureAsync(SettingComponentCreationContext); await contributor.ConfigureAsync(SettingComponentCreationContext);
} }
SettingComponentCreationContext.Normalize();
SettingItemRenders.Clear(); SettingItemRenders.Clear();
SelectedGroup = GetNormalizedString(SettingComponentCreationContext.Groups.First().Id); SelectedGroup = GetNormalizedString(SettingComponentCreationContext.Groups.First().Id);

13
modules/setting-management/src/Volo.Abp.SettingManagement.Blazor/SettingComponentCreationContext.cs

@ -1,5 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using Volo.Abp.DependencyInjection; using Volo.Abp.DependencyInjection;
namespace Volo.Abp.SettingManagement.Blazor; namespace Volo.Abp.SettingManagement.Blazor;
@ -8,7 +9,7 @@ public class SettingComponentCreationContext : IServiceProviderAccessor
{ {
public IServiceProvider ServiceProvider { get; } public IServiceProvider ServiceProvider { get; }
public List<SettingComponentGroup> Groups { get; } public List<SettingComponentGroup> Groups { get; private set; }
public SettingComponentCreationContext(IServiceProvider serviceProvider) public SettingComponentCreationContext(IServiceProvider serviceProvider)
{ {
@ -16,4 +17,14 @@ public class SettingComponentCreationContext : IServiceProviderAccessor
Groups = new List<SettingComponentGroup>(); Groups = new List<SettingComponentGroup>();
} }
public void Normalize()
{
Order();
}
private void Order()
{
Groups = Groups.OrderBy(item => item.Order).ThenBy(item => item.DisplayName).ToList();
}
} }

7
modules/setting-management/src/Volo.Abp.SettingManagement.Blazor/SettingComponentGroup.cs

@ -5,6 +5,8 @@ namespace Volo.Abp.SettingManagement.Blazor;
public class SettingComponentGroup public class SettingComponentGroup
{ {
public const int DefaultOrder = 1000;
public string Id { public string Id {
get => _id; get => _id;
set => _id = Check.NotNullOrWhiteSpace(value, nameof(Id)); set => _id = Check.NotNullOrWhiteSpace(value, nameof(Id));
@ -24,12 +26,15 @@ public class SettingComponentGroup
private Type _componentType; private Type _componentType;
public object Parameter { get; set; } public object Parameter { get; set; }
public int Order { get; set; }
public SettingComponentGroup([NotNull] string id, [NotNull] string displayName, [NotNull] Type componentType, object parameter = null) public SettingComponentGroup([NotNull] string id, [NotNull] string displayName, [NotNull] Type componentType, object parameter = null, int order = DefaultOrder)
{ {
Id = id; Id = id;
DisplayName = displayName; DisplayName = displayName;
ComponentType = componentType; ComponentType = componentType;
Parameter = parameter; Parameter = parameter;
Order = order;
} }
} }

1
modules/setting-management/src/Volo.Abp.SettingManagement.Web/Pages/SettingManagement/SettingPageContributorManager.cs

@ -37,6 +37,7 @@ public class SettingPageContributorManager : IScopedDependency
{ {
await contributor.ConfigureAsync(context); await contributor.ConfigureAsync(context);
} }
context.Normalize();
return context; return context;
} }

13
modules/setting-management/src/Volo.Abp.SettingManagement.Web/Pages/SettingManagement/SettingPageCreationContext.cs

@ -1,5 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using Volo.Abp.DependencyInjection; using Volo.Abp.DependencyInjection;
namespace Volo.Abp.SettingManagement.Web.Pages.SettingManagement; namespace Volo.Abp.SettingManagement.Web.Pages.SettingManagement;
@ -8,7 +9,7 @@ public class SettingPageCreationContext : IServiceProviderAccessor
{ {
public IServiceProvider ServiceProvider { get; } public IServiceProvider ServiceProvider { get; }
public List<SettingPageGroup> Groups { get; } public List<SettingPageGroup> Groups { get; private set; }
public SettingPageCreationContext(IServiceProvider serviceProvider) public SettingPageCreationContext(IServiceProvider serviceProvider)
{ {
@ -16,4 +17,14 @@ public class SettingPageCreationContext : IServiceProviderAccessor
Groups = new List<SettingPageGroup>(); Groups = new List<SettingPageGroup>();
} }
public void Normalize()
{
Order();
}
private void Order()
{
Groups = Groups.OrderBy(item => item.Order).ThenBy(item => item.DisplayName).ToList();
}
} }

7
modules/setting-management/src/Volo.Abp.SettingManagement.Web/Pages/SettingManagement/SettingPageGroup.cs

@ -5,6 +5,8 @@ namespace Volo.Abp.SettingManagement.Web.Pages.SettingManagement;
public class SettingPageGroup public class SettingPageGroup
{ {
public const int DefaultOrder = 1000;
public string Id { public string Id {
get => _id; get => _id;
set => _id = Check.NotNullOrWhiteSpace(value, nameof(Id)); set => _id = Check.NotNullOrWhiteSpace(value, nameof(Id));
@ -24,12 +26,15 @@ public class SettingPageGroup
private Type _componentType; private Type _componentType;
public object Parameter { get; set; } public object Parameter { get; set; }
public int Order { get; set; }
public SettingPageGroup([NotNull] string id, [NotNull] string displayName, [NotNull] Type componentType, object parameter = null) public SettingPageGroup([NotNull] string id, [NotNull] string displayName, [NotNull] Type componentType, object parameter = null, int order = DefaultOrder)
{ {
Id = id; Id = id;
DisplayName = displayName; DisplayName = displayName;
ComponentType = componentType; ComponentType = componentType;
Parameter = parameter; Parameter = parameter;
Order = order;
} }
} }

Loading…
Cancel
Save