Skip to content

Commit 426633c

Browse files
committed
#273 - ViewComponent de paginação /sp8 - feature/sp8/#273
1 parent eed808f commit 426633c

File tree

5 files changed

+41
-0
lines changed

5 files changed

+41
-0
lines changed

src/web/JSE.WebApp.MVC/Controllers/CatalogoController.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public async Task<IActionResult> Index([FromQuery] int ps = 8, [FromQuery] int p
2222
{
2323
var produtos = await _catalogoService.ObterTodos(ps, page, q);
2424
ViewBag.Pesquisa = q;
25+
produtos.ReferenceAction = "Index";
2526

2627
return View(produtos);
2728
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using JSE.WebApp.MVC.Models;
2+
using Microsoft.AspNetCore.Mvc;
3+
4+
namespace JSE.WebApp.MVC.Extensions
5+
{
6+
public class PaginacaoViewComponent : ViewComponent
7+
{
8+
public IViewComponentResult Invoke(IPagedList modelopaginado)
9+
{
10+
return View(modelopaginado);
11+
}
12+
}
13+
}

src/web/JSE.WebApp.MVC/Views/Catalogo/Index.cshtml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@
4444

4545
</div>
4646

47+
48+
@* //TODO - ViewComponent de paginação *@
4749
<nav aria-label="...">
4850
<ul class="pagination">
4951
@{
@@ -65,5 +67,6 @@
6567
}
6668
</ul>
6769
</nav>
70+
6871
</div>
6972
</div>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
@model IPagedList
2+
3+
<nav aria-label="...">
4+
<ul class="pagination">
5+
@{
6+
for (var i = 1; i < Model.TotalPages + 1; i++)
7+
{
8+
if (i == Model.PageIndex)
9+
{
10+
<li class="page-item active">
11+
<a class="page-link" asp-action="@Model.ReferenceAction" asp-route-ps="@Model.PageSize" asp-route-page="@i" asp-route-q="@Model.Query">@i</a>
12+
</li>
13+
}
14+
else
15+
{
16+
<li class="page-item">
17+
<a class="page-link" asp-action="@Model.ReferenceAction" asp-route-ps="@Model.PageSize" asp-route-page="@i" asp-route-q="@Model.Query">@i</a>
18+
</li>
19+
}
20+
}
21+
}
22+
</ul>
23+
</nav>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+


0 commit comments

Comments
 (0)