Skip to content

Commit

Permalink
Merge pull request #39 from DFE-Digital/bugfix/195845-project-list
Browse files Browse the repository at this point in the history
Paging fix
  • Loading branch information
paullocknimble authored Jan 15, 2025
2 parents a3d4808 + 205e384 commit dc571fc
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class PaginationViewModel
{
public int PageSize { get; set; } = 10;

public PagingResponse Paging { get; set; } = null;
public PagingResponse Paging { get; set; } = new();

[BindProperty(SupportsGet = true)]
public int CurrentPage { get; set; } = 1;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
@page "/schools-requiring-improvement"
@using Microsoft.Extensions.Configuration
@model IndexModel
@inject IConfiguration Configuration

@{
Layout = "_Layout";
}
<div class="govuk-grid-row">
<div class="govuk-grid-column-full">
<h1 class="govuk-heading-xl" data-cy="select-heading">
Schools requiring improvement
</h1>
<a asp-page="/WhichSchoolNeedsHelp" role="button" draggable="false" class="govuk-button" data-module="govuk-button" data-cy="create_new_conversion_btn">
Add a school
</a>
</div>
<div class="govuk-grid-column-one-third">
<partial name="Shared/_ProjectListFilters" model="Model.Filters" />
</div>
<div class="govuk-grid-column-two-thirds">

<h2 class="govuk-heading-l" test-id="projectCount" data-cy="select-projectlist-filter-count">@Model.TotalProjects schools found</h2>
<table class="govuk-table">
<caption class="govuk-table__caption govuk-table__caption--m govuk-visually-hidden">Schools @Model.SupportProjects.Count() </caption>
<thead class="govuk-table__head">
<tr class="govuk-table__row">
<th class="govuk-table__header app-!-width-three-fifths">School information</th>
</tr>
</thead>
<tbody class="govuk-table__body">
@{
<partial name="Shared/_ProjectListRows" model="Model.SupportProjects" />
}
</tbody>
</table><partial name="Shared/_Pagination" model="Model.Pagination" />
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;

namespace Dfe.RegionalImprovementForStandardsAndExcellence.Frontend.Pages;
namespace Dfe.RegionalImprovementForStandardsAndExcellence.Frontend.Pages.SchoolList;

public class IndexModel : PageModel
{
Expand All @@ -17,29 +17,29 @@ public IndexModel(ISupportProjectQueryService supportProjectQueryService)
}

public IEnumerable<SupportProjectViewModel> SupportProjects = new List<SupportProjectViewModel>();

[BindProperty]
public ProjectListFilters Filters { get; set; } = new();

[BindProperty(SupportsGet = true)]
public PaginationViewModel Pagination { get; set; } = new();
public int ProjectCount => SupportProjects.Count();


[BindProperty(SupportsGet = true)]
public int TotalProjects { get; set; }
public async Task<IActionResult> OnGetAsync(CancellationToken cancellationToken)
{
Filters.PersistUsing(TempData).PopulateFrom(Request.Query);

Pagination.PagePath = "/schools-requiring-improvement";
Pagination.PagePath = "/SchoolList/Index";

var result =
await _supportProjectQueryService.SearchForSupportProjects(
Filters.Title, Filters.SelectedStatuses, Filters.SelectedOfficers, Filters.SelectedRegions,
Filters.SelectedLocalAuthorities, Pagination.PagePath, Pagination.CurrentPage, Pagination.PageSize,
cancellationToken);

if(result.IsSuccess && result.Value != null) {
if (result.IsSuccess && result.Value != null)
{
Pagination.Paging = result.Value.Paging;
TotalProjects = result.Value?.Paging?.RecordCount ?? 0;
SupportProjects = result.Value?.Data.Select(SupportProjectViewModel.Create);
Expand Down

0 comments on commit dc571fc

Please sign in to comment.