From 21eb85646ccfca5a9d6ec3fc051192a53481e471 Mon Sep 17 00:00:00 2001 From: plockwood Date: Wed, 13 Dec 2023 15:41:56 +0000 Subject: [PATCH 1/7] changes for filter --- .../Pages/ProjectList/Index.cshtml | 389 +++++++++++++++--- .../Dfe.PrepareConversions/libman.json | 5 + .../wwwroot/package-lock.json | 48 +-- .../wwwroot/package.json | 4 +- 4 files changed, 350 insertions(+), 96 deletions(-) create mode 100644 Dfe.PrepareConversions/Dfe.PrepareConversions/libman.json diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/ProjectList/Index.cshtml b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/ProjectList/Index.cshtml index 4a70c624c..5bf61c7ae 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/ProjectList/Index.cshtml +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/ProjectList/Index.cshtml @@ -3,77 +3,336 @@ @using Microsoft.FeatureManagement.Mvc.TagHelpers @model Dfe.PrepareConversions.Pages.ProjectList.IndexModel @{ - ViewData["Title"] = "Project list"; + ViewData["Title"] = "Project list"; }
-
-

Manage an academy conversion

-

Use this service to start a new conversion project

- +
+

Manage an academy conversion

+

Use this service to start a new conversion project

+
Start a new conversion - -

@(Model.TotalProjects) projects found

- - - -
-
There are no matching results.
-

Improve your results by:

-
    -
  • double-checking your spelling
  • -
  • searching again with another school
  • -
  • removing some filters
  • -
-
- -
-
- -
- - - - - - - - - - - - - @{ - var index = 0; - foreach (ProjectListViewModel project in Model.Projects) - { - - - - - index++; - } - } - -
Projects (@Model.ProjectCount)
Application informationProject status and dates
- - -
-
+ +
+
+
+ +
+ +
+

Filter

+
+ +
+
+ +
+ +
+ +@*
+ +
+ +
+

Selected filters

+
+ + + +
+ +

Type

+ + + +

Status

+ + + +
*@ + +
+ + + +
+ + You can search by school name, academy name, trust name, URN and UKPRN + + +
+
+ +
+
+
+
+

+ + Assigned to + +

+
+
+
+
+ + + +
+
+ + + +
+
+ + + +
+
+
+
+
+
+

+ + Region + +

+
+
+
+
+ + + +
+
+ + + +
+
+ + + +
+
+
+
+
+
+

+ + Local Authority + +

+
+
+
+
+ + + +
+
+ + + +
+
+ + + +
+
+
+
+ +
+
+

+ + Project status + +

+
+
+
+
+ + + +
+
+ + + +
+
+ + + +
+
+
+
+ + +
+
+

+ + Advisory board date + +

+
+
+
+
+ + + +
+
+ + + +
+
+ + + +
+
+
+
+ +
+ + +
+ +
+ +
+ +
+ +
+ +
+
+ +

@(Model.TotalProjects) projects found

+ + @* + +
+
There are no matching results.
+

Improve your results by:

+
    +
  • double-checking your spelling
  • +
  • searching again with another school
  • +
  • removing some filters
  • +
+
*@ + +
+
+ +
+ + + + + + + + + + + + + @{ + var index = 0; + foreach (ProjectListViewModel project in Model.Projects) + { + + + + + index++; + } + } + +
Projects (@Model.ProjectCount)
Application informationProject status and dates
+ + +
+
\ No newline at end of file diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/libman.json b/Dfe.PrepareConversions/Dfe.PrepareConversions/libman.json new file mode 100644 index 000000000..ceee2710f --- /dev/null +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/libman.json @@ -0,0 +1,5 @@ +{ + "version": "1.0", + "defaultProvider": "cdnjs", + "libraries": [] +} \ No newline at end of file diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/wwwroot/package-lock.json b/Dfe.PrepareConversions/Dfe.PrepareConversions/wwwroot/package-lock.json index cb7a442da..a34dd1f54 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/wwwroot/package-lock.json +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/wwwroot/package-lock.json @@ -5,10 +5,10 @@ "packages": { "": { "dependencies": { - "@ministryofjustice/frontend": "^0.2.6", + "@ministryofjustice/frontend": "^1.8.1", "accessible-autocomplete": "^2.0.4", "dfe-frontend-alpha": "^1.0.1", - "govuk-frontend": "^3.14.0", + "govuk-frontend": "^4.7.0", "jquery": "^3.6.1" }, "devDependencies": { @@ -2356,14 +2356,18 @@ } }, "node_modules/@ministryofjustice/frontend": { - "version": "0.2.6", - "resolved": "https://registry.npmjs.org/@ministryofjustice/frontend/-/frontend-0.2.6.tgz", - "integrity": "sha512-Q7VxqmOm/uFUpD2/EZjVgaAJ2EgKjNWZPFQN74HkSQ24ZK+tQERGfWkw5DM8molmtnwNns9XBL3E0lVJ/moJnA==", + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/@ministryofjustice/frontend/-/frontend-1.8.1.tgz", + "integrity": "sha512-HNl8XXbNje/NtQRlGM57CTLlAGBTW+ziGTBkxXHDn7VauKNz418PnErDlKRWeaHIyc6V9twI5EbOj4lFCsvasw==", "dependencies": { + "govuk-frontend": "^3.0.0 || ^4.0.0", "moment": "^2.27.0" }, "engines": { "node": ">= 4.2.0" + }, + "peerDependencies": { + "jquery": "^3.6.0" } }, "node_modules/@nodelib/fs.scandir": { @@ -5010,14 +5014,6 @@ "node": "18.x" } }, - "node_modules/dfe-frontend-alpha/node_modules/govuk-frontend": { - "version": "4.7.0", - "resolved": "https://registry.npmjs.org/govuk-frontend/-/govuk-frontend-4.7.0.tgz", - "integrity": "sha512-0OsdCusF5qvLWwKziU8zqxiC0nq6WP0ZQuw51ymZ/1V0tO71oIKMlSLN2S9bm8RcEGSoidPt2A34gKxePrLjvg==", - "engines": { - "node": ">= 4.2.0" - } - }, "node_modules/diff-sequences": { "version": "26.6.2", "resolved": "https://registry.npmjs.org/diff-sequences/-/diff-sequences-26.6.2.tgz", @@ -6597,9 +6593,9 @@ } }, "node_modules/govuk-frontend": { - "version": "3.14.0", - "resolved": "https://registry.npmjs.org/govuk-frontend/-/govuk-frontend-3.14.0.tgz", - "integrity": "sha512-y7FTuihCSA8Hty+e9h0uPhCoNanCAN+CLioNFlPmlbeHXpbi09VMyxTcH+XfnMPY4Cp++7096v0rLwwdapTXnA==", + "version": "4.7.0", + "resolved": "https://registry.npmjs.org/govuk-frontend/-/govuk-frontend-4.7.0.tgz", + "integrity": "sha512-0OsdCusF5qvLWwKziU8zqxiC0nq6WP0ZQuw51ymZ/1V0tO71oIKMlSLN2S9bm8RcEGSoidPt2A34gKxePrLjvg==", "engines": { "node": ">= 4.2.0" } @@ -17714,10 +17710,11 @@ } }, "@ministryofjustice/frontend": { - "version": "0.2.6", - "resolved": "https://registry.npmjs.org/@ministryofjustice/frontend/-/frontend-0.2.6.tgz", - "integrity": "sha512-Q7VxqmOm/uFUpD2/EZjVgaAJ2EgKjNWZPFQN74HkSQ24ZK+tQERGfWkw5DM8molmtnwNns9XBL3E0lVJ/moJnA==", + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/@ministryofjustice/frontend/-/frontend-1.8.1.tgz", + "integrity": "sha512-HNl8XXbNje/NtQRlGM57CTLlAGBTW+ziGTBkxXHDn7VauKNz418PnErDlKRWeaHIyc6V9twI5EbOj4lFCsvasw==", "requires": { + "govuk-frontend": "^3.0.0 || ^4.0.0", "moment": "^2.27.0" } }, @@ -19867,13 +19864,6 @@ "wait-on": "^6.0.0", "webpack": "^5.74.0", "webpack-stream": "^5.2.1" - }, - "dependencies": { - "govuk-frontend": { - "version": "4.7.0", - "resolved": "https://registry.npmjs.org/govuk-frontend/-/govuk-frontend-4.7.0.tgz", - "integrity": "sha512-0OsdCusF5qvLWwKziU8zqxiC0nq6WP0ZQuw51ymZ/1V0tO71oIKMlSLN2S9bm8RcEGSoidPt2A34gKxePrLjvg==" - } } }, "diff-sequences": { @@ -21110,9 +21100,9 @@ } }, "govuk-frontend": { - "version": "3.14.0", - "resolved": "https://registry.npmjs.org/govuk-frontend/-/govuk-frontend-3.14.0.tgz", - "integrity": "sha512-y7FTuihCSA8Hty+e9h0uPhCoNanCAN+CLioNFlPmlbeHXpbi09VMyxTcH+XfnMPY4Cp++7096v0rLwwdapTXnA==" + "version": "4.7.0", + "resolved": "https://registry.npmjs.org/govuk-frontend/-/govuk-frontend-4.7.0.tgz", + "integrity": "sha512-0OsdCusF5qvLWwKziU8zqxiC0nq6WP0ZQuw51ymZ/1V0tO71oIKMlSLN2S9bm8RcEGSoidPt2A34gKxePrLjvg==" }, "graceful-fs": { "version": "4.2.10", diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/wwwroot/package.json b/Dfe.PrepareConversions/Dfe.PrepareConversions/wwwroot/package.json index b654ea78d..ada6dc7a5 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/wwwroot/package.json +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/wwwroot/package.json @@ -17,10 +17,10 @@ "webpack-cli": "^4.10.0" }, "dependencies": { - "@ministryofjustice/frontend": "^0.2.6", + "@ministryofjustice/frontend": "^1.8.1", "accessible-autocomplete": "^2.0.4", "dfe-frontend-alpha": "^1.0.1", - "govuk-frontend": "^3.14.0", + "govuk-frontend": "^4.7.0", "jquery": "^3.6.1" } } From 6f6fd0a9110254e92625248d1ee287215559e86a Mon Sep 17 00:00:00 2001 From: plockwood Date: Thu, 14 Dec 2023 13:40:56 +0000 Subject: [PATCH 2/7] progress on filters --- .../Pages/ProjectList/Index.cshtml | 258 +----------------- .../Pages/Shared/_ProjectListFilters.cshtml | 246 ++++++++++++++++- 2 files changed, 243 insertions(+), 261 deletions(-) diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/ProjectList/Index.cshtml b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/ProjectList/Index.cshtml index 5bf61c7ae..0e78f6b28 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/ProjectList/Index.cshtml +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/ProjectList/Index.cshtml @@ -29,267 +29,13 @@
-
- -
- -
-

Filter

-
- -
-
- -
- -
- -@*
- -
- -
-

Selected filters

-
- - - -
- -

Type

- - - -

Status

- - - -
*@ - -
- - - -
- - You can search by school name, academy name, trust name, URN and UKPRN - - -
-
- -
-
-
-
-

- - Assigned to - -

-
-
-
-
- - - -
-
- - - -
-
- - - -
-
-
-
-
-
-

- - Region - -

-
-
-
-
- - - -
-
- - - -
-
- - - -
-
-
-
-
-
-

- - Local Authority - -

-
-
-
-
- - - -
-
- - - -
-
- - - -
-
-
-
- -
-
-

- - Project status - -

-
-
-
-
- - - -
-
- - - -
-
- - - -
-
-
-
- - -
-
-

- - Advisory board date - -

-
-
-
-
- - - -
-
- - - -
-
- - - -
-
-
-
- -
- - -
- -
- -
- -
- -
+

@(Model.TotalProjects) projects found

- @* -
There are no matching results.

Improve your results by:

@@ -298,7 +44,7 @@
  • searching again with another school
  • removing some filters
  • -
    *@ +
    diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Shared/_ProjectListFilters.cshtml b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Shared/_ProjectListFilters.cshtml index 057728afa..a37b3f84e 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Shared/_ProjectListFilters.cshtml +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Shared/_ProjectListFilters.cshtml @@ -1,7 +1,243 @@ @using Dfe.PrepareConversions.Utils @model Dfe.PrepareConversions.Models.ProjectList.ProjectListFilters +
    -
    +
    + +
    +

    Filter

    +
    + +
    +
    + +
    + +
    + + @*
    + +
    + +
    +

    Selected filters

    +
    + + + +
    + +

    Type

    + + + +

    Status

    + + + +
    *@ + +
    +
    + + +
    + + You can search by school name, academy name, trust name, URN and UKPRN + + +
    + +
    + +
    +
    +
    +
    +

    + + Assigned to + +

    +
    +
    + @{ +
    + + +
    + foreach (var officer in Model.AvailableDeliveryOfficers) + { +
    + + +
    + } + } +
    +
    +
    +
    +

    + + Region + +

    +
    +
    +
    + @{ + foreach (var region in Model.AvailableRegions) + { +
    + + +
    + } + } +
    +
    +
    +
    +
    +

    + + Local Authority + +

    +
    +
    +
    +
    + + + +
    +
    + + + +
    +
    + + + +
    +
    +
    +
    + +
    +
    +

    + + Project status + +

    +
    +
    +
    + @{ + foreach (var status in Model.AvailableStatuses) + { +
    + + +
    + } + } +
    +
    +
    + + +
    +
    +

    + + Advisory board date + +

    +
    +
    +
    +
    + + + +
    +
    + + + +
    +
    + + + +
    +
    +
    +
    + +
    + + +
    + +
    +
    +
    + +
    + +
    +@*
    Filter projects @@ -26,7 +262,7 @@ data-cy="select-projectlist-filter-title">
    - @*REGIONS*@ +
    @@ -58,7 +294,7 @@
    - @*STATUS*@ +
    @@ -90,7 +326,7 @@
    - @*DELIVERY OFFICERS*@ +
    @@ -145,4 +381,4 @@
    - \ No newline at end of file + *@ \ No newline at end of file From 6864cb1ba34a794414e60a616593abe125214e96 Mon Sep 17 00:00:00 2001 From: plockwood Date: Thu, 14 Dec 2023 15:13:22 +0000 Subject: [PATCH 3/7] Project filter wired up to display correct values --- .../Models/ProjectFilterParameters.cs | 2 + .../Models/ProjectList/ProjectListFilters.cs | 25 +- .../Pages/ProjectList/Index.cshtml.cs | 2 + .../Pages/Shared/_ProjectListFilters.cshtml | 215 +++--------------- 4 files changed, 54 insertions(+), 190 deletions(-) diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Models/ProjectFilterParameters.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Models/ProjectFilterParameters.cs index a7629ccc0..d5fea9d6a 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Models/ProjectFilterParameters.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Models/ProjectFilterParameters.cs @@ -7,4 +7,6 @@ public class ProjectFilterParameters public List Statuses { get; set; } = new(); public List AssignedUsers { get; set; } = new(); public List Regions { get; set; } = new(); + public List LocalAuthorities { get; set; } = new(); + public List AdvisoryBoardDates { get; set; } = new(); } diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Models/ProjectList/ProjectListFilters.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/Models/ProjectList/ProjectListFilters.cs index dc31a16fa..785bbf95c 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/Models/ProjectList/ProjectListFilters.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Models/ProjectList/ProjectListFilters.cs @@ -14,6 +14,8 @@ public class ProjectListFilters public const string FilterStatuses = nameof(FilterStatuses); public const string FilterOfficers = nameof(FilterOfficers); public const string FilterRegions = nameof(FilterRegions); + public const string FilterLocalAuthorities = nameof(FilterLocalAuthorities); + public const string FilterAdvisoryBoardDates = nameof(FilterAdvisoryBoardDates); private IDictionary _store = null!; @@ -21,6 +23,9 @@ public class ProjectListFilters public List AvailableDeliveryOfficers { get; set; } = new(); public List AvailableRegions { get; set; } = new(); + public List AvailableLocalAuthorities { get; set; } = new(); + public List AvailableAdvisoryBoardDates { get; set; } = new(); + [BindProperty] public string? Title { get; set; } @@ -33,6 +38,12 @@ public class ProjectListFilters [BindProperty] public string[] SelectedRegions { get; set; } = Array.Empty(); + [BindProperty] + public string[] SelectedLocalAuthorities { get; set; } = Array.Empty(); + + [BindProperty] + public string[] SelectedAdvisoryBoardDates { get; set; } = Array.Empty(); + public bool IsVisible => string.IsNullOrWhiteSpace(Title) is false || SelectedStatuses.Length > 0 || SelectedOfficers.Length > 0 || @@ -46,6 +57,8 @@ public ProjectListFilters PersistUsing(IDictionary store) SelectedStatuses = Get(FilterStatuses); SelectedOfficers = Get(FilterOfficers); SelectedRegions = Get(FilterRegions); + SelectedLocalAuthorities = Get(FilterLocalAuthorities); + SelectedAdvisoryBoardDates = Get(FilterAdvisoryBoardDates); return this; } @@ -62,6 +75,8 @@ public void PopulateFrom(IEnumerable> request SelectedStatuses = Array.Empty(); SelectedOfficers = Array.Empty(); SelectedRegions = Array.Empty(); + SelectedLocalAuthorities = Array.Empty(); + SelectedAdvisoryBoardDates = Array.Empty(); return; } @@ -69,7 +84,9 @@ public void PopulateFrom(IEnumerable> request bool activeFilterChanges = query.ContainsKey(nameof(Title)) || query.ContainsKey(nameof(SelectedStatuses)) || query.ContainsKey(nameof(SelectedOfficers)) || - query.ContainsKey(nameof(SelectedRegions)); + query.ContainsKey(nameof(SelectedRegions)) || + query.ContainsKey(nameof(SelectedLocalAuthorities)) || + query.ContainsKey(nameof(SelectedAdvisoryBoardDates)); if (activeFilterChanges) { @@ -77,6 +94,8 @@ public void PopulateFrom(IEnumerable> request SelectedStatuses = Cache(FilterStatuses, GetFromQuery(nameof(SelectedStatuses))); SelectedOfficers = Cache(FilterOfficers, GetFromQuery(nameof(SelectedOfficers))); SelectedRegions = Cache(FilterRegions, GetFromQuery(nameof(SelectedRegions))); + SelectedLocalAuthorities = Cache(FilterLocalAuthorities, GetFromQuery(nameof(SelectedLocalAuthorities))); + SelectedAdvisoryBoardDates = Cache(FilterAdvisoryBoardDates, GetFromQuery(nameof(SelectedAdvisoryBoardDates))); } else { @@ -84,6 +103,8 @@ public void PopulateFrom(IEnumerable> request SelectedStatuses = Get(FilterStatuses, true); SelectedOfficers = Get(FilterOfficers, true); SelectedRegions = Get(FilterRegions, true); + SelectedLocalAuthorities = Get(FilterLocalAuthorities, true); + SelectedAdvisoryBoardDates = Get(FilterAdvisoryBoardDates, true); } string[] GetFromQuery(string key) @@ -118,6 +139,8 @@ private void ClearFilters() Cache(FilterStatuses, default); Cache(FilterOfficers, default); Cache(FilterRegions, default); + Cache(FilterLocalAuthorities, default); + Cache(FilterAdvisoryBoardDates, default); } /// diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/ProjectList/Index.cshtml.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/ProjectList/Index.cshtml.cs index aa22e465b..1cca310b7 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/ProjectList/Index.cshtml.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/ProjectList/Index.cshtml.cs @@ -49,6 +49,8 @@ public async Task OnGetAsync() Filters.AvailableStatuses = filterParametersResponse.Body.Statuses.ConvertAll(r => r.ToSentenceCase()); Filters.AvailableDeliveryOfficers = filterParametersResponse.Body.AssignedUsers; Filters.AvailableRegions = filterParametersResponse.Body.Regions; + Filters.AvailableLocalAuthorities = filterParametersResponse.Body.LocalAuthorities; + Filters.AvailableAdvisoryBoardDates = filterParametersResponse.Body.AdvisoryBoardDates; } } } diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Shared/_ProjectListFilters.cshtml b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Shared/_ProjectListFilters.cshtml index a37b3f84e..60d17fc69 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Shared/_ProjectListFilters.cshtml +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Shared/_ProjectListFilters.cshtml @@ -137,27 +137,19 @@
    -
    - - - -
    -
    - - - -
    -
    - - - -
    + @{ + foreach (var localAuthority in Model.AvailableLocalAuthorities) + { +
    + + +
    + } + }
    @@ -199,29 +191,19 @@
    -
    -
    - - - -
    -
    - - - -
    -
    - - - -
    -
    + @{ + foreach (var boardDates in Model.AvailableAdvisoryBoardDates) + { +
    + + +
    + } + }
    @@ -237,148 +219,3 @@ -@*
    - - - Filter projects - - -
    -
    -
    -
    -
    -

    - -

    - -
    - For example, Bolton Spa Primary -
    - - -
    -
    - -
    -
    -
    - - - Project Region - - - -
    - Select all that apply. -
    - -
    - @{ - foreach (var region in Model.AvailableRegions) - { -
    - - -
    - } - } -
    -
    -
    -
    - -
    -
    -
    - - - Project status - - - -
    - Select all that apply. -
    - -
    - @{ - foreach (var status in Model.AvailableStatuses) - { -
    - - -
    - } - } -
    -
    -
    -
    - -
    -
    -
    - - - Delivery officers - - - -
    - Select all that apply. -
    - -
    - @{ -
    - - -
    - foreach (var officer in Model.AvailableDeliveryOfficers) - { -
    - - -
    - } - } -
    -
    -
    -
    -
    - -
    -
    -
    - - - Clear filters -
    -
    -
    -
    -
    -
    *@ \ No newline at end of file From fc004c72a71c3968839f99a2c738115c64a6f174 Mon Sep 17 00:00:00 2001 From: plockwood Date: Thu, 14 Dec 2023 17:31:00 +0000 Subject: [PATCH 4/7] advisory board dates filter and local authority --- .../Features/ApiClient.cs | 5 ++ .../Features/IApiClient.cs | 1 + .../Features/PathFor.cs | 2 + .../Models/AcademyConversionSearchModelV2.cs | 15 ++++++ .../AcademyConversionProjectRepository.cs | 53 +++++++++++++++++++ .../IAcademyConversionProjectRepository.cs | 11 ++++ .../Pages/ProjectList/Index.cshtml.cs | 2 +- .../Pages/Shared/_ProjectListFilters.cshtml | 16 +++--- ...emyConversionProjectItemsCacheDecorator.cs | 5 ++ 9 files changed, 101 insertions(+), 9 deletions(-) create mode 100644 Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Models/AcademyConversionSearchModelV2.cs diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Features/ApiClient.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Features/ApiClient.cs index b180371ab..48689510e 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Features/ApiClient.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Features/ApiClient.cs @@ -67,4 +67,9 @@ public async Task SetProjectExternalApplicationForm(int id, return await AcademisationClient.PutAsync(string.Format(PathFor.SetExternalApplicationForm, id), JsonContent.Create(payload)); } + + public async Task GetAllProjectsV2Async(AcademyConversionSearchModelV2 searchModel) + { + return await AcademisationClient.PostAsync(PathFor.GetAllProjectsV2, JsonContent.Create(searchModel)); + } } diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Features/IApiClient.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Features/IApiClient.cs index d3f8d422c..8ac7eb6d1 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Features/IApiClient.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Features/IApiClient.cs @@ -7,6 +7,7 @@ namespace Dfe.PrepareConversions.Data.Features; public interface IApiClient { Task GetAllProjectsAsync(AcademyConversionSearchModel searchModel); + Task GetAllProjectsV2Async(AcademyConversionSearchModelV2 searchModel); Task GetProjectByIdAsync(int id); Task UpdateProjectAsync(int id, UpdateAcademyConversionProject updateProject); Task GetFilterParametersAsync(); diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Features/PathFor.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Features/PathFor.cs index 574aa8dd2..0fd23ab69 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Features/PathFor.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Features/PathFor.cs @@ -17,4 +17,6 @@ public PathFor(IFeatureManager features) public static string GetFilterParameters => "/legacy/projects/status"; public static string AddProjectNote => "/legacy/project/{0}/notes"; public static string SetExternalApplicationForm => "/conversion-project/{0}/setExternalApplicationForm"; + + public static string GetAllProjectsV2 => "/conversion-project/projects"; } diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Models/AcademyConversionSearchModelV2.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Models/AcademyConversionSearchModelV2.cs new file mode 100644 index 000000000..ec7f5d8fb --- /dev/null +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Models/AcademyConversionSearchModelV2.cs @@ -0,0 +1,15 @@ +using System.Collections.Generic; + +namespace Dfe.PrepareConversions.Data.Models; + +public class AcademyConversionSearchModelV2 +{ + public int Page { get; set; } + public int Count { get; set; } + public string TitleFilter { get; set; } + public IEnumerable DeliveryOfficerQueryString { get; set; } + public IEnumerable RegionQueryString { get; set; } + public IEnumerable StatusQueryString { get; set; } + public IEnumerable LocalAuthoritiesQueryString { get; set; } + public IEnumerable AdvisoryBoardDatesQueryString { get; set; } +} diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Services/AcademyConversionProjectRepository.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Services/AcademyConversionProjectRepository.cs index 23c72be82..cb9b79574 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Services/AcademyConversionProjectRepository.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Services/AcademyConversionProjectRepository.cs @@ -162,6 +162,41 @@ private void ProcessFilters(IEnumerable statusFilters, } } + private void ProcessFiltersV2(IEnumerable statusFilters, + IEnumerable deliveryOfficerFilter, + AcademyConversionSearchModelV2 searchModel, + IEnumerable regionsFilter = default, + IEnumerable localAuthoritiesFilter = default, + IEnumerable advisoryBoardDateFilter = default + ) + { + if (deliveryOfficerFilter != default) + { + searchModel.DeliveryOfficerQueryString = deliveryOfficerFilter; + } + if (statusFilters != null) + { + IEnumerable projectedStatuses = statusFilters.SelectMany(x => + _invertedAliasedStatuses.ContainsKey(x.ToLowerInvariant()) + ? new[] { x, _invertedAliasedStatuses[x.ToLowerInvariant()] } + : new[] { x }); + + searchModel.StatusQueryString = projectedStatuses.ToArray(); + } + if (regionsFilter != default) + { + searchModel.RegionQueryString = regionsFilter.Select(x => x.ToLower()).ToList(); + } + if (localAuthoritiesFilter != default) + { + searchModel.LocalAuthoritiesQueryString = localAuthoritiesFilter.Select(x => x.ToLower()).ToList(); + } + if (advisoryBoardDateFilter != default) + { + searchModel.AdvisoryBoardDatesQueryString = advisoryBoardDateFilter.Select(x => x.ToLower()).ToList(); + } + } + private async Task ReadFromJsonAndThrowIfNull(HttpContent content) { T responseObj = await content.ReadFromJsonAsync(); @@ -177,4 +212,22 @@ public async Task SetProjectExternalApplicationForm(int id, bool externalApplica HttpResponseMessage result = await _apiClient.SetProjectExternalApplicationForm(id, externalApplicationFormSaved, externalApplicationFormUrl); if (result.IsSuccessStatusCode is false) throw new ApiResponseException($"Request to Api failed | StatusCode - {result.StatusCode}"); } + + public async Task>>> GetAllProjectsV2(int page, int count, string titleFilter = "", IEnumerable statusFilters = null, IEnumerable deliveryOfficerFilter = null, IEnumerable regionsFilter = null, IEnumerable localAuthoritiesFilter = null, IEnumerable advisoryBoardDatesFilter = null) + { + AcademyConversionSearchModelV2 searchModel = new() { TitleFilter = titleFilter, Page = page, Count = count }; + + ProcessFiltersV2(statusFilters, deliveryOfficerFilter, searchModel, regionsFilter, localAuthoritiesFilter, advisoryBoardDatesFilter); + + HttpResponseMessage response = await _apiClient.GetAllProjectsV2Async(searchModel); + if (!response.IsSuccessStatusCode) + { + return new ApiResponse>>(response.StatusCode, + new ApiV2Wrapper> { Data = Enumerable.Empty() }); + } + + ApiV2Wrapper> outerResponse = await response.Content.ReadFromJsonAsync>>(); + + return new ApiResponse>>(response.StatusCode, outerResponse); + } } diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Services/IAcademyConversionProjectRepository.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Services/IAcademyConversionProjectRepository.cs index c40a18ae7..d3e50a3e9 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Services/IAcademyConversionProjectRepository.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Services/IAcademyConversionProjectRepository.cs @@ -17,6 +17,17 @@ Task>>> GetAllPro IEnumerable applicationReferences = default ); + Task>>> GetAllProjectsV2( + int page, + int count, + string titleFilter = "", + IEnumerable statusFilters = default, + IEnumerable deliveryOfficerFilter = default, + IEnumerable regionsFilter = default, + IEnumerable localAuthoritiesFilter = default, + IEnumerable advisoryBoardDatesFilter = default +); + Task> GetProjectById(int id); Task> UpdateProject(int id, UpdateAcademyConversionProject updateProject); Task CreateProject(CreateNewProject newProject); diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/ProjectList/Index.cshtml.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/ProjectList/Index.cshtml.cs index 1cca310b7..890099dfb 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/ProjectList/Index.cshtml.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/ProjectList/Index.cshtml.cs @@ -36,7 +36,7 @@ public async Task OnGetAsync() Filters.PersistUsing(TempData).PopulateFrom(Request.Query); ApiResponse>> response = - await _repository.GetAllProjects(CurrentPage, PageSize, Filters.Title, Filters.SelectedStatuses, Filters.SelectedOfficers, Filters.SelectedRegions); + await _repository.GetAllProjectsV2(CurrentPage, PageSize, Filters.Title, Filters.SelectedStatuses, Filters.SelectedOfficers, Filters.SelectedRegions, Filters.SelectedLocalAuthorities, Filters.SelectedAdvisoryBoardDates); Paging = response.Body?.Paging; Projects = response.Body?.Data.Select(ProjectListHelper.Build).ToList(); diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Shared/_ProjectListFilters.cshtml b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Shared/_ProjectListFilters.cshtml index 60d17fc69..05b672d7a 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Shared/_ProjectListFilters.cshtml +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Shared/_ProjectListFilters.cshtml @@ -141,10 +141,10 @@ foreach (var localAuthority in Model.AvailableLocalAuthorities) {
    - -
    @@ -195,10 +195,10 @@ foreach (var boardDates in Model.AvailableAdvisoryBoardDates) {
    - -
    diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Services/AcademyConversionProjectItemsCacheDecorator.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/Services/AcademyConversionProjectItemsCacheDecorator.cs index e16bd171d..e4d9ef2ee 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/Services/AcademyConversionProjectItemsCacheDecorator.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Services/AcademyConversionProjectItemsCacheDecorator.cs @@ -74,4 +74,9 @@ public async Task SetProjectExternalApplicationForm(int id, bool externalApplica { await _innerRepository.SetProjectExternalApplicationForm(id, externalApplicationFormSaved, externalApplicationFormUrl); } + + public async Task>>> GetAllProjectsV2(int page, int count, string titleFilter = "", IEnumerable statusFilters = null, IEnumerable deliveryOfficerFilter = null, IEnumerable regionsFilter = null, IEnumerable localAuthoritiesFilter = null, IEnumerable advisoryBoardDatesFilter = null) + { + return await _innerRepository.GetAllProjectsV2(page, count, titleFilter, statusFilters, deliveryOfficerFilter, regionsFilter, localAuthoritiesFilter, advisoryBoardDatesFilter); + } } From 27dcd7141a90be47f983e1942606b7eaf9e688e3 Mon Sep 17 00:00:00 2001 From: plockwood Date: Mon, 18 Dec 2023 17:30:47 +0000 Subject: [PATCH 5/7] Selected filters and clear filters --- .../Models/ProjectList/ProjectListFilters.cs | 4 +- .../Pages/Shared/_ProjectListFilters.cshtml | 110 +++++++++++++----- 2 files changed, 83 insertions(+), 31 deletions(-) diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Models/ProjectList/ProjectListFilters.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/Models/ProjectList/ProjectListFilters.cs index 785bbf95c..591355567 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/Models/ProjectList/ProjectListFilters.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Models/ProjectList/ProjectListFilters.cs @@ -47,7 +47,9 @@ public class ProjectListFilters public bool IsVisible => string.IsNullOrWhiteSpace(Title) is false || SelectedStatuses.Length > 0 || SelectedOfficers.Length > 0 || - SelectedRegions.Length > 0; + SelectedRegions.Length > 0 || + SelectedLocalAuthorities.Length > 0 || + SelectedAdvisoryBoardDates.Length > 0; public ProjectListFilters PersistUsing(IDictionary store) { diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Shared/_ProjectListFilters.cshtml b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Shared/_ProjectListFilters.cshtml index 05b672d7a..8ef9457ba 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Shared/_ProjectListFilters.cshtml +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Shared/_ProjectListFilters.cshtml @@ -14,41 +14,91 @@
    +
    - @*
    +
    -
    - -
    -

    Selected filters

    -
    +
    +

    Selected filters

    +
    - + +
    + @if (Model.SelectedOfficers.Length > 0) + { +

    Assigned to

    + + + } + @if (Model.SelectedOfficers.Length > 0) + { +

    Region

    + + + } + @if (Model.SelectedLocalAuthorities.Length > 0) + { +

    Local Authority

    + + + } + @if (Model.SelectedStatuses.Length > 0) + { +

    Project status

    + + + } + @if (Model.SelectedAdvisoryBoardDates.Length > 0) + { +

    Advisory board date

    + + + }
    -

    Type

    - - - -

    Status

    - - - -
    *@ -
    + Download as a spreadsheet