From a7e98d9afb225833361d44d1ceb5b860a2478bbe Mon Sep 17 00:00:00 2001 From: Jack Marshall Date: Wed, 22 Jan 2025 16:06:54 +0000 Subject: [PATCH 1/3] Project status filter - fix and feature flagged WIP --- .../Project/ProjectStatus.cs | 6 +- .../UseCases/Dashboard/GetDashboardService.cs | 6 ++ .../cypress/e2e/homepage.cy.ts | 2 +- .../Pages/Dashboard/DashboardBasePageModel.cs | 17 +++-- .../Pages/Dashboard/_Dashboard.cshtml | 64 +++++++++++-------- 5 files changed, 60 insertions(+), 35 deletions(-) diff --git a/Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects.API.Contracts/Project/ProjectStatus.cs b/Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects.API.Contracts/Project/ProjectStatus.cs index 3684862fb..fb3cb8c86 100644 --- a/Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects.API.Contracts/Project/ProjectStatus.cs +++ b/Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects.API.Contracts/Project/ProjectStatus.cs @@ -15,7 +15,11 @@ public enum ProjectStatus [Description("Cancelled")] Cancelled, - + + //Possible legacy value + [Description("Cancelled during pre-opening")] + CancelledDuringPreOpening, + [Description("Withdrawn in pre-opening")] WithdrawnInPreOpening, diff --git a/Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects.API/UseCases/Dashboard/GetDashboardService.cs b/Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects.API/UseCases/Dashboard/GetDashboardService.cs index ff7c8df92..cf67a9764 100644 --- a/Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects.API/UseCases/Dashboard/GetDashboardService.cs +++ b/Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects.API/UseCases/Dashboard/GetDashboardService.cs @@ -86,6 +86,12 @@ private static IQueryable ApplyFilters(IQueryable query, GetDashboardP { if (projectStatuses.Exists(x => x == ProjectStatus.WithdrawnInPreOpening.ToDescription())) projectStatuses.Add(ProjectStatus.WithdrawnDuringPreOpening.ToDescription()); + + if (projectStatuses.Exists(x => x == ProjectStatus.Preopening.ToDescription())) + projectStatuses.Add(""); + + if (projectStatuses.Exists(x => x == ProjectStatus.Cancelled.ToDescription())) + projectStatuses.Add(ProjectStatus.CancelledDuringPreOpening.ToDescription()); query = query.Where(kpi => projectStatuses.Any(projectStatus => kpi.ProjectStatusProjectStatus == projectStatus)); } diff --git a/Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects.CypressTests/cypress/e2e/homepage.cy.ts b/Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects.CypressTests/cypress/e2e/homepage.cy.ts index a97ed0463..807a148a7 100644 --- a/Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects.CypressTests/cypress/e2e/homepage.cy.ts +++ b/Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects.CypressTests/cypress/e2e/homepage.cy.ts @@ -313,7 +313,7 @@ describe("Testing the home page", () => { }); describe("Filter cache", () => { - it("Should retain filter values after navigating away from the page and back again", () => { + it.only("Should retain filter values after navigating away from the page and back again", () => { homePage .openFilter() diff --git a/Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects/Pages/Dashboard/DashboardBasePageModel.cs b/Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects/Pages/Dashboard/DashboardBasePageModel.cs index 4c628f104..6e14ed44c 100644 --- a/Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects/Pages/Dashboard/DashboardBasePageModel.cs +++ b/Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects/Pages/Dashboard/DashboardBasePageModel.cs @@ -69,7 +69,10 @@ protected async Task LoadDashboard(LoadDashboardParameters loadDashboardParamete var allowCentralRoute = await featureManager.IsEnabledAsync("AllowCentralRoute"); if (!allowCentralRoute) getDashboardServiceParameters.Wave = "FS - Presumption"; - + + var allowProjectStatusFilter = await featureManager.IsEnabledAsync("AllowProjectStatusFilter"); + ProjectStatusSearchTerm = allowProjectStatusFilter ? ProjectStatusSearchTerm : new List(); + var filterCache = dashboardFiltersCache.Get(); if (!string.IsNullOrWhiteSpace(ProjectSearchTerm) @@ -94,7 +97,7 @@ protected async Task LoadDashboard(LoadDashboardParameters loadDashboardParamete var response = await GetDashboardService.Execute(getDashboardServiceParameters); var paginationModel = PaginationMapping.ToModel(response.Paging); - var query = BuildPaginationQuery(); + var query = await BuildPaginationQuery(); paginationModel.Url = $"{loadDashboardParameters.Url}{query}"; Dashboard = new DashboardModel @@ -113,7 +116,7 @@ protected async Task LoadDashboard(LoadDashboardParameters loadDashboardParamete }; } - private string BuildPaginationQuery() + private async Task BuildPaginationQuery() { var query = new QueryString("?handler=movePage"); @@ -121,7 +124,7 @@ private string BuildPaginationQuery() query = query.Add("search-by-project", ProjectSearchTerm); if (RegionSearchTerm.Count != 0) - RegionSearchTerm.ForEach((r => query = query.Add("search-by-region", r))); + RegionSearchTerm.ForEach(r => query = query.Add("search-by-region", r)); if (LocalAuthoritySearchTerm.Count != 0) LocalAuthoritySearchTerm.ForEach(l => query = query.Add("search-by-local-authority", l)); @@ -129,8 +132,10 @@ private string BuildPaginationQuery() if (ProjectManagedBySearchTerm.Count > 0) ProjectManagedBySearchTerm.ForEach(m => query = query.Add("search-by-pmb", m)); - if (ProjectStatusSearchTerm.Count > 0) - ProjectStatusSearchTerm.ForEach((m => query = query.Add("search-by-project-status", m))); + var allowProjectStatusFilter = await featureManager.IsEnabledAsync("AllowProjectStatusFilter"); + + if (ProjectStatusSearchTerm.Count > 0 && allowProjectStatusFilter) + ProjectStatusSearchTerm.ForEach(m => query = query.Add("search-by-project-status", m)); return query.ToString(); } diff --git a/Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects/Pages/Dashboard/_Dashboard.cshtml b/Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects/Pages/Dashboard/_Dashboard.cshtml index e680809cd..1fe51c596 100644 --- a/Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects/Pages/Dashboard/_Dashboard.cshtml +++ b/Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects/Pages/Dashboard/_Dashboard.cshtml @@ -1,13 +1,15 @@ @using Dfe.ManageFreeSchoolProjects.API.Contracts.Project; @using Dfe.ManageFreeSchoolProjects.Constants; +@inject Microsoft.FeatureManagement.IFeatureManager _featureManager; @model Dfe.ManageFreeSchoolProjects.Pages.Dashboard.DashboardModel; @{ - var regions = Enum.GetValues(typeof(ProjectRegion)); + var regions = Enum.GetValues(); var regionLabels = (from object region in regions select region.ToDescription()).ToList(); - var projectStatuses = Enum.GetValues(typeof(ProjectStatus)); + var projectStatuses = Enum.GetValues().Except(new[] { ProjectStatus.CancelledDuringPreOpening, ProjectStatus.WithdrawnDuringPreOpening }); ; var projectStatusLabels = (from ProjectStatus status in projectStatuses select status.ToDescription()).ToList(); + projectStatusLabels.Sort(); var projectManagerLabels = Model.ProjectManagers; @@ -27,6 +29,8 @@ var noResults = (Model.Projects == null || Model.Projects.Count == 0); var noFilteredResults = (isFilterActive && Model.Projects.Count == 0); var projectIds= string.Join(",", Model.TotalProjectIds); + + var allowProjectStatusFilter = await _featureManager.IsEnabledAsync("AllowProjectStatusFilter"); } @@ -176,44 +180,50 @@ } } -
-
+ @{ + if (allowProjectStatusFilter) + { +
+
-
+
-
+
- + - Project status + Project status - + -
- Select all that apply. -
+
+ Select all that apply. +
-
- @foreach (var status in projectStatusLabels) - { - var checkedStatus = Model.ProjectStatusSearchTerm.Contains(status) ? "checked" : ""; +
-
- - + @foreach (var status in projectStatusLabels) + { + var checkedStatus = Model.ProjectStatusSearchTerm.Contains(status) ? "checked" : ""; -
- } +
+ + +
+ } + +
+
- -
-
-
+
+
+ } + }
From 7c36380d896c84f5261cddd15c2ea0176c622247 Mon Sep 17 00:00:00 2001 From: Jack Marshall Date: Thu, 23 Jan 2025 10:10:28 +0000 Subject: [PATCH 2/3] Fixed project filter cache and added feature flag --- .../UseCases/Dashboard/GetDashboardService.cs | 2 +- .../cypress/e2e/homepage.cy.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects.API/UseCases/Dashboard/GetDashboardService.cs b/Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects.API/UseCases/Dashboard/GetDashboardService.cs index cf67a9764..7034e6b96 100644 --- a/Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects.API/UseCases/Dashboard/GetDashboardService.cs +++ b/Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects.API/UseCases/Dashboard/GetDashboardService.cs @@ -88,7 +88,7 @@ private static IQueryable ApplyFilters(IQueryable query, GetDashboardP projectStatuses.Add(ProjectStatus.WithdrawnDuringPreOpening.ToDescription()); if (projectStatuses.Exists(x => x == ProjectStatus.Preopening.ToDescription())) - projectStatuses.Add(""); + projectStatuses.Add(null); if (projectStatuses.Exists(x => x == ProjectStatus.Cancelled.ToDescription())) projectStatuses.Add(ProjectStatus.CancelledDuringPreOpening.ToDescription()); diff --git a/Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects.CypressTests/cypress/e2e/homepage.cy.ts b/Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects.CypressTests/cypress/e2e/homepage.cy.ts index 807a148a7..a97ed0463 100644 --- a/Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects.CypressTests/cypress/e2e/homepage.cy.ts +++ b/Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects.CypressTests/cypress/e2e/homepage.cy.ts @@ -313,7 +313,7 @@ describe("Testing the home page", () => { }); describe("Filter cache", () => { - it.only("Should retain filter values after navigating away from the page and back again", () => { + it("Should retain filter values after navigating away from the page and back again", () => { homePage .openFilter() From a2efc05da49e0da8cfbd1138656b59bb67c0fbd3 Mon Sep 17 00:00:00 2001 From: Jack Marshall Date: Thu, 23 Jan 2025 10:26:05 +0000 Subject: [PATCH 3/3] Removed duplicate ; --- .../Pages/Dashboard/_Dashboard.cshtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects/Pages/Dashboard/_Dashboard.cshtml b/Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects/Pages/Dashboard/_Dashboard.cshtml index 1fe51c596..49f3ba242 100644 --- a/Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects/Pages/Dashboard/_Dashboard.cshtml +++ b/Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects/Pages/Dashboard/_Dashboard.cshtml @@ -7,7 +7,7 @@ var regions = Enum.GetValues(); var regionLabels = (from object region in regions select region.ToDescription()).ToList(); - var projectStatuses = Enum.GetValues().Except(new[] { ProjectStatus.CancelledDuringPreOpening, ProjectStatus.WithdrawnDuringPreOpening }); ; + var projectStatuses = Enum.GetValues().Except(new[] { ProjectStatus.CancelledDuringPreOpening, ProjectStatus.WithdrawnDuringPreOpening }); var projectStatusLabels = (from ProjectStatus status in projectStatuses select status.ToDescription()).ToList(); projectStatusLabels.Sort();