Use handler config.

This commit is contained in:
mikestefanello 2025-04-12 10:20:20 -04:00
parent eaa37a0745
commit 271e252c53
2 changed files with 10 additions and 12 deletions

View file

@ -5,6 +5,7 @@ import (
"net/http"
"strconv"
"strings"
"time"
"entgo.io/ent/entc/gen"
"entgo.io/ent/entc/load"
@ -27,7 +28,6 @@ type Admin struct {
orm *ent.Client
graph *gen.Graph
admin *admin.Handler
itemsPerPage int
}
func init() {
@ -35,10 +35,13 @@ func init() {
}
func (h *Admin) Init(c *services.Container) error {
h.itemsPerPage = 25
h.graph = c.Graph
h.orm = c.ORM
h.admin = admin.NewHandler(h.orm, h.itemsPerPage)
h.admin = admin.NewHandler(h.orm, admin.HandlerConfig{
ItemsPerPage: 25,
PageQueryKey: pager.QueryKey,
TimeFormat: time.DateTime,
})
return nil
}
@ -96,7 +99,7 @@ func (h *Admin) EntityList(n *gen.Type) echo.HandlerFunc {
return pages.AdminEntityList(ctx, pages.AdminEntityListParams{
EntityType: n,
EntityList: list,
Pager: pager.NewPager(ctx, h.itemsPerPage),
Pager: pager.NewPager(ctx, h.admin.Config.ItemsPerPage),
})
}
}

View file

@ -17,9 +17,4 @@ func TestNewContainer(t *testing.T) {
assert.NotNil(t, c.Mail)
assert.NotNil(t, c.Auth)
assert.NotNil(t, c.Tasks)
g := c.Graph
if g == nil {
//c.ORM.User.Create().
}
}