Added paging.
This commit is contained in:
parent
36bc20b90f
commit
13ae07ae60
1 changed files with 28 additions and 1 deletions
|
|
@ -17,6 +17,7 @@ import (
|
||||||
. "github.com/mikestefanello/pagoda/pkg/ui/components"
|
. "github.com/mikestefanello/pagoda/pkg/ui/components"
|
||||||
"github.com/mikestefanello/pagoda/pkg/ui/layouts"
|
"github.com/mikestefanello/pagoda/pkg/ui/layouts"
|
||||||
. "maragu.dev/gomponents"
|
. "maragu.dev/gomponents"
|
||||||
|
. "maragu.dev/gomponents/components"
|
||||||
. "maragu.dev/gomponents/html"
|
. "maragu.dev/gomponents/html"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -198,7 +199,14 @@ func AdminEntityList(ctx echo.Context, params AdminEntityListParams) error {
|
||||||
return g
|
return g
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO pager
|
pagedHref := func(page int) string {
|
||||||
|
return fmt.Sprintf("%s?%s=%d",
|
||||||
|
r.Path(routenames.AdminEntityList(params.EntityType.Name)),
|
||||||
|
pager.QueryKey,
|
||||||
|
page,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
return r.Render(layouts.Admin, Group{
|
return r.Render(layouts.Admin, Group{
|
||||||
ButtonLink(
|
ButtonLink(
|
||||||
r.Path(routenames.AdminEntityAdd(params.EntityType.Name)),
|
r.Path(routenames.AdminEntityAdd(params.EntityType.Name)),
|
||||||
|
|
@ -212,5 +220,24 @@ func AdminEntityList(ctx echo.Context, params AdminEntityListParams) error {
|
||||||
),
|
),
|
||||||
TBody(genRows()),
|
TBody(genRows()),
|
||||||
),
|
),
|
||||||
|
Nav(
|
||||||
|
Class("pagination"),
|
||||||
|
A(
|
||||||
|
Classes{
|
||||||
|
"pagination-previous": true,
|
||||||
|
"is-disabled": params.EntityList.Page == 1,
|
||||||
|
},
|
||||||
|
If(params.EntityList.Page != 1, Href(pagedHref(params.EntityList.Page-1))),
|
||||||
|
Text("Previous page"),
|
||||||
|
),
|
||||||
|
A(
|
||||||
|
Classes{
|
||||||
|
"pagination-previous": true,
|
||||||
|
"is-disabled": !params.EntityList.HasNextPage,
|
||||||
|
},
|
||||||
|
If(params.EntityList.HasNextPage, Href(pagedHref(params.EntityList.Page+1))),
|
||||||
|
Text("Next page"),
|
||||||
|
),
|
||||||
|
),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue