|
11 | 11 |
|
12 | 12 | @{ |
13 | 13 | ViewData["Title"] = Configuration["Layout:ServiceName"]; |
| 14 | + var showFiltersPanel = Model.FiltersEnabled && (Model.ShowFiltersPanel || !ViewData.ModelState.IsValid); |
| 15 | +} |
| 16 | + |
| 17 | +@if (Model.FiltersEnabled) |
| 18 | +{ |
| 19 | + <link rel="stylesheet" href="~/css/application-listing.css" asp-append-version="true" /> |
14 | 20 | } |
15 | 21 |
|
16 | 22 | <div class="govuk-grid-row"> |
|
32 | 38 | </div> |
33 | 39 | </div> |
34 | 40 | } |
| 41 | + else if (!ViewData.ModelState.IsValid) |
| 42 | + { |
| 43 | + <div class="govuk-error-summary" aria-labelledby="error-summary-title" role="alert" data-module="govuk-error-summary"> |
| 44 | + <h2 class="govuk-error-summary__title" id="error-summary-title"> |
| 45 | + There is a problem |
| 46 | + </h2> |
| 47 | + <div class="govuk-error-summary__body"> |
| 48 | + <ul class="govuk-list govuk-error-summary__list"> |
| 49 | + @foreach (var error in ViewData.ModelState.Values.SelectMany(v => v.Errors)) |
| 50 | + { |
| 51 | + <li>@error.ErrorMessage</li> |
| 52 | + } |
| 53 | + </ul> |
| 54 | + </div> |
| 55 | + </div> |
| 56 | + } |
35 | 57 |
|
36 | 58 | <h2 class="govuk-heading-l govuk-!-margin-bottom-3"> |
37 | 59 | @AppTerminology.PluralCapitalised in progress |
38 | 60 | </h2> |
39 | 61 |
|
| 62 | + @if (Model.FiltersEnabled) |
| 63 | + { |
| 64 | + <details class="govuk-details application-listing__filters-container" data-module="govuk-details" @(showFiltersPanel ? "open" : null)> |
| 65 | + <summary class="govuk-details__summary application-listing__filters-summary"> |
| 66 | + <span class="govuk-details__summary-text govuk-button govuk-button--secondary application-listing__filters-button" data-testid="filter-applications-button"> |
| 67 | + Filter @AppTerminology.Plural |
| 68 | + </span> |
| 69 | + </summary> |
| 70 | + <div class="govuk-details__text application-listing__filters-details"> |
| 71 | + <form method="get" action="/applications/dashboard"> |
| 72 | + <div class="govuk-grid-row"> |
| 73 | + <div class="govuk-grid-column-one-quarter"> |
| 74 | + <div class="govuk-form-group"> |
| 75 | + <h2 class="govuk-label-wrapper"> |
| 76 | + <label class="govuk-label govuk-label--m" for="search-reference"> |
| 77 | + Reference number |
| 78 | + </label> |
| 79 | + </h2> |
| 80 | + <div id="search-reference-hint" class="govuk-hint"> |
| 81 | + Enter all or part of a reference number |
| 82 | + </div> |
| 83 | + <input class="govuk-input" id="search-reference" name="searchReference" |
| 84 | + type="search" value="@Model.SearchReference" autocomplete="off" |
| 85 | + aria-describedby="search-reference-hint" data-testid="search-reference"> |
| 86 | + </div> |
| 87 | + </div> |
| 88 | + |
| 89 | + <div class="govuk-grid-column-one-quarter"> |
| 90 | + <div class="govuk-form-group"> |
| 91 | + <label class="govuk-label govuk-label--m" for="search-status"> |
| 92 | + Status |
| 93 | + </label> |
| 94 | + <select class="govuk-select" id="search-status" name="status" data-testid="search-status"> |
| 95 | + @if (Model.Status is null) |
| 96 | + { |
| 97 | + <option value="" selected>All statuses</option> |
| 98 | + } |
| 99 | + else |
| 100 | + { |
| 101 | + <option value="">All statuses</option> |
| 102 | + } |
| 103 | + @if (Model.Status == ApplicationStatus.InProgress) |
| 104 | + { |
| 105 | + <option value="@((int)ApplicationStatus.InProgress)" selected>In progress</option> |
| 106 | + } |
| 107 | + else |
| 108 | + { |
| 109 | + <option value="@((int)ApplicationStatus.InProgress)">In progress</option> |
| 110 | + } |
| 111 | + @if (Model.Status == ApplicationStatus.Submitted) |
| 112 | + { |
| 113 | + <option value="@((int)ApplicationStatus.Submitted)" selected>Submitted</option> |
| 114 | + } |
| 115 | + else |
| 116 | + { |
| 117 | + <option value="@((int)ApplicationStatus.Submitted)">Submitted</option> |
| 118 | + } |
| 119 | + </select> |
| 120 | + </div> |
| 121 | + </div> |
| 122 | + |
| 123 | + <div class="govuk-grid-column-one-quarter"> |
| 124 | + <div class="govuk-form-group @(ViewData.ModelState[nameof(Model.DateStartedTo)]?.Errors.Count > 0 ? "govuk-form-group--error" : null)"> |
| 125 | + <fieldset class="govuk-fieldset" aria-describedby="date-started-hint"> |
| 126 | + <legend class="govuk-fieldset__legend govuk-fieldset__legend--m"> |
| 127 | + Date started |
| 128 | + </legend> |
| 129 | + <div id="date-started-hint" class="govuk-hint">For example, 01 03 2024</div> |
| 130 | + @if (ViewData.ModelState[nameof(Model.DateStartedTo)]?.Errors.Count > 0) |
| 131 | + { |
| 132 | + <span class="govuk-error-message"> |
| 133 | + <span class="govuk-visually-hidden">Error:</span> |
| 134 | + @ViewData.ModelState[nameof(Model.DateStartedTo)]!.Errors[0].ErrorMessage |
| 135 | + </span> |
| 136 | + } |
| 137 | + <label class="govuk-label" for="date-started-from">From</label> |
| 138 | + <input class="govuk-input govuk-!-margin-bottom-2 @(ViewData.ModelState[nameof(Model.DateStartedTo)]?.Errors.Count > 0 ? "govuk-input--error" : null)" |
| 139 | + id="date-started-from" name="dateStartedFrom" type="date" |
| 140 | + value="@Model.DateStartedFrom" data-testid="date-started-from"> |
| 141 | + <label class="govuk-label" for="date-started-to">To</label> |
| 142 | + <input class="govuk-input @(ViewData.ModelState[nameof(Model.DateStartedTo)]?.Errors.Count > 0 ? "govuk-input--error" : null)" |
| 143 | + id="date-started-to" name="dateStartedTo" type="date" |
| 144 | + value="@Model.DateStartedTo" data-testid="date-started-to"> |
| 145 | + </fieldset> |
| 146 | + </div> |
| 147 | + </div> |
| 148 | + |
| 149 | + <div class="govuk-grid-column-one-quarter"> |
| 150 | + <div class="govuk-form-group @(ViewData.ModelState[nameof(Model.DateSubmittedTo)]?.Errors.Count > 0 ? "govuk-form-group--error" : null)"> |
| 151 | + <fieldset class="govuk-fieldset" aria-describedby="date-submitted-hint"> |
| 152 | + <legend class="govuk-fieldset__legend govuk-fieldset__legend--m"> |
| 153 | + Date submitted |
| 154 | + </legend> |
| 155 | + <div id="date-submitted-hint" class="govuk-hint">For example, 01 03 2024</div> |
| 156 | + @if (ViewData.ModelState[nameof(Model.DateSubmittedTo)]?.Errors.Count > 0) |
| 157 | + { |
| 158 | + <span class="govuk-error-message"> |
| 159 | + <span class="govuk-visually-hidden">Error:</span> |
| 160 | + @ViewData.ModelState[nameof(Model.DateSubmittedTo)]!.Errors[0].ErrorMessage |
| 161 | + </span> |
| 162 | + } |
| 163 | + <label class="govuk-label" for="date-submitted-from">From</label> |
| 164 | + <input class="govuk-input govuk-!-margin-bottom-2 @(ViewData.ModelState[nameof(Model.DateSubmittedTo)]?.Errors.Count > 0 ? "govuk-input--error" : null)" |
| 165 | + id="date-submitted-from" name="dateSubmittedFrom" type="date" |
| 166 | + value="@Model.DateSubmittedFrom" data-testid="date-submitted-from"> |
| 167 | + <label class="govuk-label" for="date-submitted-to">To</label> |
| 168 | + <input class="govuk-input @(ViewData.ModelState[nameof(Model.DateSubmittedTo)]?.Errors.Count > 0 ? "govuk-input--error" : null)" |
| 169 | + id="date-submitted-to" name="dateSubmittedTo" type="date" |
| 170 | + value="@Model.DateSubmittedTo" data-testid="date-submitted-to"> |
| 171 | + </fieldset> |
| 172 | + </div> |
| 173 | + </div> |
| 174 | + </div> |
| 175 | + |
| 176 | + <div class="govuk-grid-row"> |
| 177 | + <div class="govuk-grid-column-full"> |
| 178 | + <div class="govuk-button-group"> |
| 179 | + <button class="govuk-button govuk-button--secondary" type="submit" data-module="govuk-button" data-testid="apply-filters"> |
| 180 | + Apply filters |
| 181 | + </button> |
| 182 | + @if (Model.IsSearchActive) |
| 183 | + { |
| 184 | + <a class="govuk-link" href="/applications/dashboard" data-testid="clear-filters">Clear filters</a> |
| 185 | + } |
| 186 | + </div> |
| 187 | + </div> |
| 188 | + </div> |
| 189 | + </form> |
| 190 | + </div> |
| 191 | + </details> |
| 192 | + } |
| 193 | + |
| 194 | + <div class="govuk-!-margin-bottom-6"></div> |
| 195 | + |
40 | 196 | @if (!Model.HasError && !Model.Applications.Any()) |
41 | 197 | { |
42 | | - <p class="govuk-body">You have no @AppTerminology.Plural in progress.</p> |
| 198 | + <p class="govuk-body"> |
| 199 | + @if (Model.IsSearchActive) |
| 200 | + { |
| 201 | + <span>No @AppTerminology.Plural found matching your filters.</span> |
| 202 | + } |
| 203 | + else |
| 204 | + { |
| 205 | + <span>You have no @AppTerminology.Plural in progress.</span> |
| 206 | + } |
| 207 | + </p> |
43 | 208 | } |
44 | 209 | else if (!Model.HasError) |
45 | 210 | { |
|
93 | 258 | @if (Model.CurrentPage > 1) |
94 | 259 | { |
95 | 260 | <div class="govuk-pagination__prev"> |
96 | | - <a class="govuk-link govuk-pagination__link" href="?currentPage=@(Model.CurrentPage - 1)" rel="prev"> |
| 261 | + <a class="govuk-link govuk-pagination__link" href="@Model.BuildPaginationHref(Model.CurrentPage - 1)" rel="prev"> |
97 | 262 | <svg class="govuk-pagination__icon govuk-pagination__icon--prev" xmlns="http://www.w3.org/2000/svg" height="13" width="15" focusable="false" aria-hidden="true" viewBox="0 0 15 13"> |
98 | 263 | <path d="m6.5938-0.0078125-6.7266 6.7266 6.7441 6.4062 1.377-1.449-4.1856-3.9768h12.896v-2h-12.984l4.2931-4.293-1.414-1.414z" /> |
99 | 264 | </svg> |
|
107 | 272 | if (i == Model.CurrentPage) |
108 | 273 | { |
109 | 274 | <li class="govuk-pagination__item govuk-pagination__item--current"> |
110 | | - <a class="govuk-link govuk-pagination__link" href="?currentPage=@i" aria-label="Page @i" aria-current="page">@i</a> |
| 275 | + <a class="govuk-link govuk-pagination__link" href="@Model.BuildPaginationHref(i)" aria-label="Page @i" aria-current="page">@i</a> |
111 | 276 | </li> |
112 | 277 | } |
113 | 278 | else if (i == 1 || i == Model.TotalPages || Math.Abs(i - Model.CurrentPage) <= 1) |
114 | 279 | { |
115 | 280 | <li class="govuk-pagination__item"> |
116 | | - <a class="govuk-link govuk-pagination__link" href="?currentPage=@i" aria-label="Page @i">@i</a> |
| 281 | + <a class="govuk-link govuk-pagination__link" href="@Model.BuildPaginationHref(i)" aria-label="Page @i">@i</a> |
117 | 282 | </li> |
118 | 283 | } |
119 | 284 | else if (Math.Abs(i - Model.CurrentPage) == 2) |
|
125 | 290 | @if (Model.CurrentPage < Model.TotalPages) |
126 | 291 | { |
127 | 292 | <div class="govuk-pagination__next"> |
128 | | - <a class="govuk-link govuk-pagination__link" href="?currentPage=@(Model.CurrentPage + 1)" rel="next"> |
| 293 | + <a class="govuk-link govuk-pagination__link" href="@Model.BuildPaginationHref(Model.CurrentPage + 1)" rel="next"> |
129 | 294 | <span class="govuk-pagination__link-title">Next<span class="govuk-visually-hidden"> page</span></span> |
130 | 295 | <svg class="govuk-pagination__icon govuk-pagination__icon--next" xmlns="http://www.w3.org/2000/svg" height="13" width="15" focusable="false" aria-hidden="true" viewBox="0 0 15 13"> |
131 | 296 | <path d="m8.107-0.0078125-1.4136 1.414 4.2926 4.293h-12.986v2h12.896l-4.1855 3.9766 1.377 1.4492 6.7441-6.4062-6.7246-6.7246z" /> |
|
0 commit comments