Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 45 additions & 28 deletions LearningHub.Nhs.WebUI/Controllers/ReportsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,14 @@ await this.multiPageFormService.SetMultiPageFormData(
/// CreateReportCourseSelection.
/// </summary>
/// <param name="searchText">searchText.</param>
/// <param name="returnUrl">returnUrl.</param>
/// <returns>A <see cref="Task{TResult}"/> representing the result of the asynchronous operation.</returns>
[Route("CreateReportCourseSelection")]
[ResponseCache(CacheProfileName = "Never")]
[TypeFilter(typeof(RedirectMissingMultiPageFormData), Arguments = new object[] { "ReportWizardCWF" })]
public async Task<IActionResult> CreateReportCourseSelection(string searchText = "")
public async Task<IActionResult> CreateReportCourseSelection(string searchText = "", string returnUrl = "")
{
this.ViewBag.ReturnUrl = returnUrl;
var reportCreation = await this.multiPageFormService.GetMultiPageFormData<DatabricksRequestModel>(MultiPageFormDataFeature.AddCustomWebForm("ReportWizardCWF"), this.TempData);
var coursevm = new ReportCreationCourseSelection { SearchText = searchText, Courses = reportCreation.Courses != null ? reportCreation.Courses : new List<string>() };
var getCourses = await this.GetCoursesAsync();
Expand All @@ -143,12 +145,13 @@ public async Task<IActionResult> CreateReportCourseSelection(string searchText =
/// CreateReportCourseSelection.
/// </summary>
/// <param name="courseSelection">courseSelection.</param>
/// <param name="returnUrl">returnurl.</param>
/// <returns>A <see cref="Task{TResult}"/> representing the result of the asynchronous operation.</returns>
[HttpPost]
[Route("CreateReportCourseSelection")]
[ResponseCache(CacheProfileName = "Never")]
[TypeFilter(typeof(RedirectMissingMultiPageFormData), Arguments = new object[] { "ReportWizardCWF" })]
public async Task<IActionResult> CreateReportCourseSelection(ReportCreationCourseSelection courseSelection)
public async Task<IActionResult> CreateReportCourseSelection(ReportCreationCourseSelection courseSelection, string returnUrl = "")
{
var reportCreation = await this.multiPageFormService.GetMultiPageFormData<DatabricksRequestModel>(MultiPageFormDataFeature.AddCustomWebForm("ReportWizardCWF"), this.TempData);

Expand All @@ -158,56 +161,69 @@ public async Task<IActionResult> CreateReportCourseSelection(ReportCreationCours
{
reportCreation.Courses = courseSelection.Courses.Contains("all") ? new List<string>() : courseSelection.Courses;
await this.multiPageFormService.SetMultiPageFormData(reportCreation, MultiPageFormDataFeature.AddCustomWebForm("ReportWizardCWF"), this.TempData);
if (!string.IsNullOrEmpty(returnUrl))
{
return this.Redirect(returnUrl);
}

return this.RedirectToAction("CreateReportDateSelection");
}
}

this.ModelState.AddModelError("Courses", CommonValidationErrorMessages.CourseRequired);
reportCreation.Courses = null;
await this.multiPageFormService.SetMultiPageFormData(reportCreation, MultiPageFormDataFeature.AddCustomWebForm("ReportWizardCWF"), this.TempData);
courseSelection.BuildCourses(await this.GetCoursesAsync());
courseSelection.Courses = reportCreation.Courses;
this.ViewBag.ReturnUrl = returnUrl;
return this.View("CreateReportCourseSelection", courseSelection);
}

/// <summary>
/// CreateReportDateSelection.
/// </summary>
/// <param name="returnUrl">returnUrl.</param>
/// <returns>A <see cref="Task{TResult}"/> representing the result of the asynchronous operation.</returns>
[Route("CreateReportDateSelection")]
[ResponseCache(CacheProfileName = "Never")]
[TypeFilter(typeof(RedirectMissingMultiPageFormData), Arguments = new object[] { "ReportWizardCWF" })]
public async Task<IActionResult> CreateReportDateSelection()
public async Task<IActionResult> CreateReportDateSelection(string returnUrl = "")
{
var reportCreation = await this.multiPageFormService.GetMultiPageFormData<DatabricksRequestModel>(MultiPageFormDataFeature.AddCustomWebForm("ReportWizardCWF"), this.TempData);
var dateVM = new ReportCreationDateSelection();
dateVM.TimePeriod = reportCreation.TimePeriod;
if (reportCreation.StartDate.HasValue && reportCreation.TimePeriod == "Custom")
this.ViewBag.ReturnUrl = returnUrl;
{
dateVM.StartDay = reportCreation.StartDate.HasValue ? reportCreation.StartDate.GetValueOrDefault().Day : 0;
dateVM.StartMonth = reportCreation.StartDate.HasValue ? reportCreation.StartDate.GetValueOrDefault().Month : 0;
dateVM.StartYear = reportCreation.StartDate.HasValue ? reportCreation.StartDate.GetValueOrDefault().Year : 0;
dateVM.EndDay = reportCreation.EndDate.HasValue ? reportCreation.EndDate.GetValueOrDefault().Day : 0;
dateVM.EndMonth = reportCreation.EndDate.HasValue ? reportCreation.EndDate.GetValueOrDefault().Month : 0;
dateVM.EndYear = reportCreation.EndDate.HasValue ? reportCreation.EndDate.GetValueOrDefault().Year : 0;
}
var reportCreation = await this.multiPageFormService.GetMultiPageFormData<DatabricksRequestModel>(MultiPageFormDataFeature.AddCustomWebForm("ReportWizardCWF"), this.TempData);
var dateVM = new ReportCreationDateSelection();
dateVM.TimePeriod = reportCreation.TimePeriod;
if (reportCreation.StartDate.HasValue && reportCreation.TimePeriod == "Custom")
{
dateVM.StartDay = reportCreation.StartDate.HasValue ? reportCreation.StartDate.GetValueOrDefault().Day : 0;
dateVM.StartMonth = reportCreation.StartDate.HasValue ? reportCreation.StartDate.GetValueOrDefault().Month : 0;
dateVM.StartYear = reportCreation.StartDate.HasValue ? reportCreation.StartDate.GetValueOrDefault().Year : 0;
dateVM.EndDay = reportCreation.EndDate.HasValue ? reportCreation.EndDate.GetValueOrDefault().Day : 0;
dateVM.EndMonth = reportCreation.EndDate.HasValue ? reportCreation.EndDate.GetValueOrDefault().Month : 0;
dateVM.EndYear = reportCreation.EndDate.HasValue ? reportCreation.EndDate.GetValueOrDefault().Year : 0;
}

var minDate = await this.GetMinDate();
var minDate = await this.GetMinDate();

dateVM.DataStart = minDate.DataStart;
dateVM.HintText = minDate.HintText;
dateVM.DataStart = minDate.DataStart;
dateVM.HintText = minDate.HintText;

return this.View(dateVM);
return this.View(dateVM);
}
}

/// <summary>
/// CreateReportDateSelection.
/// </summary>
/// <param name="reportCreationDate">reportCreationDate.</param>
/// <param name="returnUrl">returnurl.</param>
/// <returns>A <see cref="Task{TResult}"/> representing the result of the asynchronous operation.</returns>
[Route("CreateReportSummary")]
[HttpPost]
[ResponseCache(CacheProfileName = "Never")]
[TypeFilter(typeof(RedirectMissingMultiPageFormData), Arguments = new object[] { "ReportWizardCWF" })]
public async Task<IActionResult> CreateReportSummary(ReportCreationDateSelection reportCreationDate)
public async Task<IActionResult> CreateReportSummary(ReportCreationDateSelection reportCreationDate, string returnUrl = "")
{
// validate date
var reportCreation = await this.multiPageFormService.GetMultiPageFormData<DatabricksRequestModel>(MultiPageFormDataFeature.AddCustomWebForm("ReportWizardCWF"), this.TempData);
Expand All @@ -219,6 +235,7 @@ public async Task<IActionResult> CreateReportSummary(ReportCreationDateSelection
reportCreationDate.DataStart = minDate.DataStart;
reportCreationDate.HintText = minDate.HintText;
this.ModelState.AddModelError("TimePeriod", CommonValidationErrorMessages.ReportingPeriodRequired);
this.ViewBag.ReturnUrl = returnUrl;
return this.View("CreateReportDateSelection", reportCreationDate);
}

Expand All @@ -227,13 +244,14 @@ public async Task<IActionResult> CreateReportSummary(ReportCreationDateSelection
var minDate = await this.GetMinDate();
reportCreationDate.DataStart = minDate.DataStart;
reportCreationDate.HintText = minDate.HintText;
this.ViewBag.ReturnUrl = returnUrl;
return this.View("CreateReportDateSelection", reportCreationDate);
}

reportCreation.StartDate = reportCreationDate.GetStartDate();
reportCreation.EndDate = reportCreationDate.GetEndDate();
await this.multiPageFormService.SetMultiPageFormData(reportCreation, MultiPageFormDataFeature.AddCustomWebForm("ReportWizardCWF"), this.TempData);
return this.RedirectToAction("CourseCompletionReport");
return this.RedirectToAction("CourseProgressReport");
}

/// <summary>
Expand All @@ -254,7 +272,7 @@ public async Task<IActionResult> ViewReport(int reportHistoryId)
return this.RedirectToAction("Index");
}

var reportRequest = new DatabricksRequestModel { Take = ReportPageSize, Skip = 0 };
var reportRequest = new DatabricksRequestModel { Take = ReportPageSize, Skip = 0, ReportHistoryId = reportHistoryId };
var periodCheck = int.TryParse(report.PeriodDays.ToString(), out int numberOfDays);
if (report.PeriodDays > 0 && periodCheck)
{
Expand All @@ -267,7 +285,6 @@ public async Task<IActionResult> ViewReport(int reportHistoryId)
reportRequest.TimePeriod = "Custom";
reportRequest.StartDate = report.StartDate;
reportRequest.EndDate = report.EndDate;
reportRequest.ReportHistoryId = reportHistoryId;
}

if (report.CourseFilter == "all")
Expand All @@ -278,7 +295,7 @@ public async Task<IActionResult> ViewReport(int reportHistoryId)
reportRequest.Courses = report.CourseFilter.Split(',', StringSplitOptions.RemoveEmptyEntries).Select(f => f.Trim()).ToList();

await this.multiPageFormService.SetMultiPageFormData(reportRequest, MultiPageFormDataFeature.AddCustomWebForm("ReportWizardCWF"), this.TempData);
return this.RedirectToAction("CourseCompletionReport");
return this.RedirectToAction("CourseProgressReport");
}

/// <summary>
Expand Down Expand Up @@ -313,19 +330,19 @@ public async Task<IActionResult> DownloadReport(int reportHistoryId)
public async Task<IActionResult> QueueReportDownload(int reportHistoryId)
{
await this.reportService.QueueReportDownload(reportHistoryId);
return this.RedirectToAction("CourseCompletionReport");
return this.RedirectToAction("CourseProgressReport");
}

/// <summary>
/// CourseCompletionReport.
/// </summary>
/// <param name="courseCompletion">courseCompletion.</param>
/// <returns>A <see cref="Task{TResult}"/> representing the result of the asynchronous operation.</returns>
[Route("CourseCompletionReport")]
[Route("CourseProgressReport")]
[HttpGet]
[ResponseCache(CacheProfileName = "Never")]
[TypeFilter(typeof(RedirectMissingMultiPageFormData), Arguments = new object[] { "ReportWizardCWF" })]
public async Task<IActionResult> CourseCompletionReport(CourseCompletionViewModel courseCompletion = null)
public async Task<IActionResult> CourseProgressReport(CourseCompletionViewModel courseCompletion = null)
{
int page = 1;

Expand Down Expand Up @@ -395,7 +412,7 @@ public async Task<IActionResult> CourseCompletionReport(CourseCompletionViewMode

if (reportCreation.Courses.Count == 0)
{
matchedCourseNames = allCourses.Select(course => course.Value).ToList();
matchedCourseNames = new List<string> { "all courses" };
}
else
{
Expand All @@ -418,7 +435,7 @@ private async Task<List<KeyValuePair<string, string>>> GetCoursesAsync()

foreach (var subCategory in subCategories.Courses)
{
courses.Add(new KeyValuePair<string, string>(subCategory.Id.ToString(), subCategory.Displayname));
courses.Add(new KeyValuePair<string, string>(subCategory.Id.ToString(), UtilityHelper.ConvertToSentenceCase(subCategory.Displayname)));
}

return courses;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public List<DynamicCheckboxItemViewModel> BuildCourses(List<KeyValuePair<string,
this.AllCources = allCourses.Select(r => new DynamicCheckboxItemViewModel
{
Value = r.Key.ToString(),
Label = UtilityHelper.ConvertToSentenceCase(r.Value),
Label = r.Value,
}).ToList();
this.AllCources.Insert(0, new DynamicCheckboxItemViewModel { Value = "all", Label = "All courses", Exclusive = true });
return this.AllCources;
Expand Down
2 changes: 1 addition & 1 deletion LearningHub.Nhs.WebUI/Services/ReportService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public async Task<DatabricksDetailedViewModel> GetCourseCompletionReport(Databri

var client = await this.OpenApiHttpClient.GetClientAsync();

var request = $"Report/GetCourseCompletionReport";
var request = $"Report/GetCourseProgressReport";
var response = await client.PostAsync(request, stringContent).ConfigureAwait(false);

if (response.IsSuccessStatusCode)
Expand Down
27 changes: 26 additions & 1 deletion LearningHub.Nhs.WebUI/Styles/nhsuk/pages/reporting.scss
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,21 @@

.nhsuk-date-inline {
display: flex;
align-items: center;
flex-direction: row;
/* align-items: center;*/
gap: 0.5rem;
}

.date-range-container .nhsuk-date-inline .nhsuk-error-message {
max-width: 400px;
word-wrap: break-word;
white-space: normal;
}


.align-label-component {
display: flex;
align-items: flex-start;
gap: 0.5rem;
}

Expand Down Expand Up @@ -55,6 +69,13 @@
.date-range-container .nhsuk-label {
min-width: 50px;
}

.nhsuk-date-inline {
display: flex;
align-items: unset;
flex-direction: column;
gap: 0.5rem;
}
}

.nhsuk-radios__divider {
Expand All @@ -74,4 +95,8 @@
padding: 0;
visibility: hidden;
}

.nhsuk-checkboxes__item:first-child .nhsuk-checkboxes__label {
font-weight: 900;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
</dd>

<dd class="nhsuk-summary-list__actions">
<a asp-controller="Reports" asp-action="CreateReportCourseSelection">
<a asp-controller="Reports" asp-action="CreateReportCourseSelection" asp-route-returnUrl="@Url.Action("CourseProgressReport", "Reports")">
Change<span class="nhsuk-u-visually-hidden">&nbsp;Course</span>
</a>

Expand All @@ -89,7 +89,7 @@
</dd>

<dd class="nhsuk-summary-list__actions">
<a asp-controller="Reports" asp-action="CreateReportDateSelection">
<a asp-controller="Reports" asp-action="CreateReportDateSelection" asp-route-returnUrl="@Url.Action("CourseProgressReport", "Reports")">
Change<span class="nhsuk-u-visually-hidden">&nbsp;Reporting period</span>
</a>

Expand All @@ -103,18 +103,18 @@

@if (Model.TotalCount > 0)
{
<h2 class="nhsuk-heading-m">Displaying @startRow@endRow of @Model.TotalCount filtered row@(Model.TotalCount > 1 ? "s" : "")</h2>
<h2 class="nhsuk-heading-m">Displaying @startRow to @endRow of @Model.TotalCount filtered row@(Model.TotalCount > 1 ? "s" : "")</h2>


@if (Model.ReportHistoryModel != null && Model.ReportHistoryModel.DownloadRequest == null)
{
<p class="nhsuk-u-secondary-text-color nhsuk-u-reading-width">
Request to download this report in a spreadsheet (.xls) format.You will be notified
Request to download this report in a spreadsheet (.xls) format. You will be notified
when the report is ready.
</p>
<form method="post" asp-controller="Reports" asp-action="QueueReportDownload">
<input type="hidden" name="reportHistoryId" value="@Model.ReportHistoryId" />
<button class="nhsuk-button nhsuk-button--reverse nhsuk-button--with-border" type="submit">Request report</button>
<button class="nhsuk-button nhsuk-button--secondary" type="submit">Request report</button>
</form>
}
else if (Model.ReportHistoryModel != null && Model.ReportHistoryModel.DownloadRequest == true && Model.ReportHistoryModel.ReportStatusId == ((int)Status.Pending))
Expand Down
Loading
Loading