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..7034e6b96 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(null); + + 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/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..49f3ba242 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" : ""; -
- } +
+ + +
+ } + +
+
- -
-
-
+
+
+ } + }