Worked on admin page listing
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using HopFrame.Web.Admin.Models;
|
||||
using HopFrame.Web.Admin.Providers;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace HopFrame.Web.Admin.Generators.Implementation;
|
||||
|
||||
@@ -58,7 +59,7 @@ internal class AdminContextGenerator : IAdminContextGenerator {
|
||||
|
||||
|
||||
|
||||
public static void RegisterPages(AdminPagesContext context, IAdminPagesProvider provider) {
|
||||
public static void RegisterPages(AdminPagesContext context, IAdminPagesProvider provider, IServiceCollection services) {
|
||||
var properties = context.GetType().GetProperties();
|
||||
|
||||
foreach (var property in properties) {
|
||||
@@ -66,6 +67,9 @@ internal class AdminContextGenerator : IAdminContextGenerator {
|
||||
if (page is null) continue;
|
||||
|
||||
provider.RegisterAdminPage(page.Title.ToLower(), page);
|
||||
|
||||
if (page.RepositoryProvider is not null)
|
||||
services.AddScoped(page.RepositoryProvider);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -94,7 +94,7 @@ internal sealed class AdminPageGenerator<TModel> : IAdminPageGenerator<TModel>,
|
||||
return this;
|
||||
}
|
||||
|
||||
public IAdminPageGenerator<TModel> ConfigureRepository<TRepository>() where TRepository : IModelRepository<TModel> {
|
||||
public IAdminPageGenerator<TModel> ConfigureRepository<TRepository>() where TRepository : ModelRepository<TModel> {
|
||||
Page.RepositoryProvider = typeof(TRepository);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -45,6 +45,11 @@ internal sealed class AdminPropertyGenerator(string name, Type type) : IAdminPro
|
||||
return this;
|
||||
}
|
||||
|
||||
public IAdminPropertyGenerator Bold(bool bold = true) {
|
||||
_property.Bold = bold;
|
||||
return this;
|
||||
}
|
||||
|
||||
public IAdminPropertyGenerator DisplayName(string displayName) {
|
||||
_property.DisplayName = displayName;
|
||||
return this;
|
||||
@@ -69,6 +74,7 @@ internal sealed class AdminPropertyGenerator(string name, Type type) : IAdminPro
|
||||
if (attributes.Any(a => a is KeyAttribute)) {
|
||||
pageGenerator.Page.DefaultSortPropertyName = property.Name;
|
||||
Editable(false);
|
||||
Bold();
|
||||
}
|
||||
|
||||
if (attributes.Any(a => a is AdminUnsortableAttribute))
|
||||
@@ -99,6 +105,11 @@ internal sealed class AdminPropertyGenerator(string name, Type type) : IAdminPro
|
||||
var attribute = attributes.Single(a => a is AdminDescriptionAttribute) as AdminDescriptionAttribute;
|
||||
Description(attribute?.Description);
|
||||
}
|
||||
|
||||
if (attributes.Any(a => a is AdminBoldAttribute)) {
|
||||
var attribute = attributes.Single(a => a is AdminBoldAttribute) as AdminBoldAttribute;
|
||||
Bold(attribute?.Bold == true);
|
||||
}
|
||||
|
||||
if (attributes.Any(a => a is AdminPrefixAttribute)) {
|
||||
var attribute = attributes.Single(a => a is AdminPrefixAttribute) as AdminPrefixAttribute;
|
||||
|
||||
Reference in New Issue
Block a user