Added policy validation, ordering and virtual listing properties

This commit is contained in:
2025-01-16 20:23:28 +01:00
parent 4908947217
commit e9f686cf19
17 changed files with 321 additions and 93 deletions

View File

@@ -25,4 +25,6 @@ public class Post {
public TimeOnly At { get; set; }
public ListSortDirection Type { get; set; }
public TypeCode? TypeCode { get; set; }
}

View File

@@ -1,9 +1,7 @@
using HopFrame.Core.Services;
using HopFrame.Testing;
using Microsoft.FluentUI.AspNetCore.Components;
using HopFrame.Testing.Components;
using HopFrame.Testing.Models;
using HopFrame.Testing.Services;
using HopFrame.Web;
using HopFrame.Web.Components.Pages;
using Microsoft.EntityFrameworkCore;
@@ -20,21 +18,29 @@ builder.Services.AddDbContext<DatabaseContext>(options => {
});
builder.Services.AddHopFrame(options => {
options.DisplayUserInfo(false);
options.AddDbContext<DatabaseContext>(context => {
context.Table<User>(table => {
table.Property(u => u.Password)
.ValueParser(pwd => pwd + "-edited");
table.Property(u => u.FirstName)
.SetDisplayName("First Name");
.List(false);
table.Property(u => u.LastName)
.SetDisplayName("Last Name");
.List(false);
table.Property(u => u.Id)
.Sortable(false);
.Sortable(false)
.OrderIndex(3);
table.AddListingProperty("Name", user => $"{user.FirstName} {user.LastName}")
.OrderIndex(2);
table.SetDisplayName("Benutzer");
table.SetDescription("This table is used for user data store and user authentication");
table.SetViewPolicy("policy");
});
context.Table<Post>()
@@ -61,11 +67,12 @@ builder.Services.AddHopFrame(options => {
return errors;
});
context.Table<Post>()
.OrderIndex(-1);
});
});
builder.Services.AddTransient<IHopFrameAuthHandler, AuthService>();
var app = builder.Build();
// Configure the HTTP request pipeline.

View File

@@ -1,12 +0,0 @@
using HopFrame.Core.Services;
namespace HopFrame.Testing.Services;
public class AuthService : IHopFrameAuthHandler {
public Task<bool> IsAuthenticatedAsync(string? policy) {
return Task.FromResult(true);
}
public Task<string> GetCurrentUserDisplayNameAsync() {
return Task.FromResult("Leon Hoppe");
}
}