Skip to content

Commit 217f32b

Browse files
committed
TD-6652 Update
1 parent 2add541 commit 217f32b

File tree

12 files changed

+106
-58
lines changed

12 files changed

+106
-58
lines changed

LearningHub.Nhs.WebUI/Controllers/ReportsController.cs

Lines changed: 51 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ public async Task<IActionResult> CreateReportDateSelection()
180180
var reportCreation = await this.multiPageFormService.GetMultiPageFormData<DatabricksRequestModel>(MultiPageFormDataFeature.AddCustomWebForm("ReportWizardCWF"), this.TempData);
181181
var dateVM = new ReportCreationDateSelection();
182182
dateVM.TimePeriod = reportCreation.TimePeriod;
183-
if (reportCreation.StartDate.HasValue)
183+
if (reportCreation.StartDate.HasValue && reportCreation.TimePeriod == "Custom")
184184
{
185185
dateVM.StartDay = reportCreation.StartDate.HasValue ? reportCreation.StartDate.GetValueOrDefault().Day : 0;
186186
dateVM.StartMonth = reportCreation.StartDate.HasValue ? reportCreation.StartDate.GetValueOrDefault().Month : 0;
@@ -189,33 +189,11 @@ public async Task<IActionResult> CreateReportDateSelection()
189189
dateVM.EndMonth = reportCreation.EndDate.HasValue ? reportCreation.EndDate.GetValueOrDefault().Month : 0;
190190
dateVM.EndYear = reportCreation.EndDate.HasValue ? reportCreation.EndDate.GetValueOrDefault().Year : 0;
191191
}
192-
else
193-
{
194-
var result = await this.reportService.GetCourseCompletionReport(new DatabricksRequestModel
195-
{
196-
StartDate = reportCreation.StartDate,
197-
EndDate = reportCreation.EndDate,
198-
TimePeriod = reportCreation.TimePeriod,
199-
Courses = reportCreation.Courses,
200-
ReportHistoryId = reportCreation.ReportHistoryId,
201-
Take = 1,
202-
Skip = 1,
203-
});
204-
205-
if (result != null)
206-
{
207-
var validDate = DateTime.TryParse(result.MinValidDate, out DateTime startDate);
208-
dateVM.DataStart = validDate ? startDate : null;
209-
dateVM.HintText = validDate
210-
? $"For example, {startDate.Day} {startDate.Month} {startDate.Year}"
211-
: $"For example, {DateTime.Now.Day} {DateTime.Now.Month} {DateTime.Now.Year}";
212-
}
213-
else
214-
{
215-
dateVM.DataStart = null;
216-
dateVM.HintText = $"For example, {DateTime.Now.Day} {DateTime.Now.Month} {DateTime.Now.Year}";
217-
}
218-
}
192+
193+
var minDate = await this.GetMinDate();
194+
195+
dateVM.DataStart = minDate.DataStart;
196+
dateVM.HintText = minDate.HintText;
219197

220198
return this.View(dateVM);
221199
}
@@ -235,8 +213,20 @@ public async Task<IActionResult> CreateReportSummary(ReportCreationDateSelection
235213
var reportCreation = await this.multiPageFormService.GetMultiPageFormData<DatabricksRequestModel>(MultiPageFormDataFeature.AddCustomWebForm("ReportWizardCWF"), this.TempData);
236214
reportCreation.TimePeriod = reportCreationDate.TimePeriod;
237215

216+
if (reportCreation.TimePeriod == null)
217+
{
218+
var minDate = await this.GetMinDate();
219+
reportCreationDate.DataStart = minDate.DataStart;
220+
reportCreationDate.HintText = minDate.HintText;
221+
this.ModelState.AddModelError("TimePeriod", CommonValidationErrorMessages.ReportingPeriodRequired);
222+
return this.View("CreateReportDateSelection", reportCreationDate);
223+
}
224+
238225
if (!this.ModelState.IsValid)
239226
{
227+
var minDate = await this.GetMinDate();
228+
reportCreationDate.DataStart = minDate.DataStart;
229+
reportCreationDate.HintText = minDate.HintText;
240230
return this.View("CreateReportDateSelection", reportCreationDate);
241231
}
242232

@@ -433,5 +423,38 @@ private async Task<List<KeyValuePair<string, string>>> GetCoursesAsync()
433423

434424
return courses;
435425
}
426+
427+
private async Task<ReportCreationDateSelection> GetMinDate()
428+
{
429+
var dateVM = new ReportCreationDateSelection();
430+
var reportCreation = await this.multiPageFormService.GetMultiPageFormData<DatabricksRequestModel>(MultiPageFormDataFeature.AddCustomWebForm("ReportWizardCWF"), this.TempData);
431+
432+
var result = await this.reportService.GetCourseCompletionReport(new DatabricksRequestModel
433+
{
434+
StartDate = null,
435+
EndDate = null,
436+
TimePeriod = reportCreation.TimePeriod,
437+
Courses = reportCreation.Courses,
438+
ReportHistoryId = 0,
439+
Take = 1,
440+
Skip = 1,
441+
});
442+
443+
if (result != null)
444+
{
445+
var validDate = DateTime.TryParse(result.MinValidDate, out DateTime startDate);
446+
dateVM.DataStart = validDate ? startDate : null;
447+
dateVM.HintText = validDate
448+
? $"For example, {startDate.Day} {startDate.Month} {startDate.Year}"
449+
: $"For example, {DateTime.Now.Day} {DateTime.Now.Month} {DateTime.Now.Year}";
450+
}
451+
else
452+
{
453+
dateVM.DataStart = null;
454+
dateVM.HintText = $"For example, {DateTime.Now.Day} {DateTime.Now.Month} {DateTime.Now.Year}";
455+
}
456+
457+
return dateVM;
458+
}
436459
}
437460
}

LearningHub.Nhs.WebUI/Helpers/CommonValidationErrorMessages.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,5 +269,10 @@ public static class CommonValidationErrorMessages
269269
/// Course Required.
270270
/// </summary>
271271
public const string CourseRequired = "Select a course";
272+
273+
/// <summary>
274+
/// Course Required.
275+
/// </summary>
276+
public const string ReportingPeriodRequired = "Select a reporting period";
272277
}
273278
}

LearningHub.Nhs.WebUI/Models/DynamicCheckbox/DynamicCheckboxItemViewModel.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,10 @@ public class DynamicCheckboxItemViewModel
2424
/// Gets or sets a value indicating whether gets or sets a selected.
2525
/// </summary>
2626
public bool Selected { get; set; }
27+
28+
/// <summary>
29+
/// Gets or sets a value indicating whether the option is exclusive.
30+
/// </summary>
31+
public bool Exclusive { get; set; } = false;
2732
}
2833
}

LearningHub.Nhs.WebUI/Models/Report/ReportCreationCourseSelection.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public List<DynamicCheckboxItemViewModel> BuildCourses(List<KeyValuePair<string,
4040
Value = r.Key.ToString(),
4141
Label = UtilityHelper.ConvertToSentenceCase(r.Value),
4242
}).ToList();
43-
this.AllCources.Insert(0, new DynamicCheckboxItemViewModel { Value = "all", Label = "All courses", });
43+
this.AllCources.Insert(0, new DynamicCheckboxItemViewModel { Value = "all", Label = "All courses", Exclusive = true });
4444
return this.AllCources;
4545
}
4646
}

LearningHub.Nhs.WebUI/Scripts/vuesrc/notification/notification.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,8 @@
198198
return [{ text: 'Action required', className: 'fa-solid fa-triangle-exclamation text-warning pt-1' }];
199199
case NotificationType.AccessRequest:
200200
return [{ text: 'Access request', className: 'fa-solid fa-lock text-dark pt-1' }];
201+
case NotificationType.ReportProcessed:
202+
return [{ text: 'Report', className: 'fa-solid fa-circle-check text-success pt-1' }];
201203
default:
202204
return [{ text: 'unknown', className: '' }];
203205
}

LearningHub.Nhs.WebUI/Scripts/vuesrc/notification/notificationModel.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export enum NotificationType {
1919
UserPermission = 6,
2020
PublishFailed = 7,
2121
AccessRequest = 8,
22+
ReportProcessed = 9,
2223
}
2324

2425
export enum NotificationPriority {

LearningHub.Nhs.WebUI/ViewComponents/DynamicCheckboxesViewComponent.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ public IViewComponentResult Invoke(
4747
Value = cb.Value,
4848
Label = cb.Label,
4949
HintText = cb.HintText,
50+
Exclusive = cb.Exclusive,
5051
Selected = selectedList.Contains(cb.Value),
5152
}).ToList(),
5253
};

LearningHub.Nhs.WebUI/Views/Reports/CourseCompletionReport.cshtml

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
@model LearningHub.Nhs.WebUI.Models.Report.CourseCompletionViewModel
77

88
@{
9-
ViewData["Title"] = "Course completion report";
9+
ViewData["Title"] = "Course progress report";
1010
var returnUrl = $"{Context.Request.Path}{Context.Request.QueryString}";
1111

1212

@@ -38,19 +38,27 @@
3838
<a href="/Reports">Reports</a>
3939
</div>
4040

41-
<h1 class="nhsuk-heading-xl"> Course completion report</h1>
41+
<h1 class="nhsuk-heading-xl"> Course progress report</h1>
4242
<dl class="nhsuk-summary-list nhsuk-u-reading-width">
4343
<div class="nhsuk-summary-list__row">
4444
<dt class="nhsuk-summary-list__key">
4545
Course@(distinctCourses.Count() > 1 ? "s" : "")
4646
</dt>
4747
<dd class="nhsuk-summary-list__value">
48-
<ul>
49-
@foreach (var entry in distinctCourses)
50-
{
51-
<li>@entry</li>
52-
}
53-
</ul>
48+
@if (distinctCourses.Count() > 1)
49+
{
50+
<ul>
51+
@foreach (var entry in distinctCourses)
52+
{
53+
<li>@entry</li>
54+
}
55+
</ul>
56+
}
57+
else
58+
{
59+
<p>@distinctCourses.FirstOrDefault()</p>
60+
}
61+
5462

5563
</dd>
5664

@@ -97,15 +105,16 @@
97105
{
98106
<h2 class="nhsuk-heading-m">Displaying @startRow@endRow of @Model.TotalCount filtered row@(Model.TotalCount > 1 ? "s" : "")</h2>
99107

100-
<p class="nhsuk-u-secondary-text-color nhsuk-u-reading-width">
101-
Request to download this report in a spreadsheet (.xls) format.You will be notified
102-
when the report is ready.
103-
</p>
108+
104109
@if (Model.ReportHistoryModel != null && Model.ReportHistoryModel.DownloadRequest == null)
105110
{
111+
<p class="nhsuk-u-secondary-text-color nhsuk-u-reading-width">
112+
Request to download this report in a spreadsheet (.xls) format.You will be notified
113+
when the report is ready.
114+
</p>
106115
<form method="post" asp-controller="Reports" asp-action="QueueReportDownload">
107116
<input type="hidden" name="reportHistoryId" value="@Model.ReportHistoryId" />
108-
<button class="nhsuk-button nhsuk-button--reverse nhsuk-button--with-border" type="submit">Request report as spreadsheet</button>
117+
<button class="nhsuk-button nhsuk-button--reverse nhsuk-button--with-border" type="submit">Request report</button>
109118
</form>
110119
}
111120
else if (Model.ReportHistoryModel != null && Model.ReportHistoryModel.DownloadRequest == true && Model.ReportHistoryModel.ReportStatusId == ((int)Status.Pending))

LearningHub.Nhs.WebUI/Views/Reports/CreateReportDateSelection.cshtml

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,45 +27,42 @@
2727
<div class="nhsuk-hint">
2828
Create a course completion report
2929
</div>
30+
3031
<h1 class="nhsuk-heading-xl">
31-
Reporting Period
32+
Reporting period
3233
</h1>
3334
<div class="nhsuk-u-padding-bottom-9">
3435

3536
@if (errorHasOccurred)
3637
{
3738
<vc:error-summary order-of-property-names="@(new[] { nameof(Model.TimePeriod) })" />
3839
}
39-
4040
<form asp-controller="Reports" asp-action="CreateReportSummary" method="post">
4141
@Html.HiddenFor(x=>x.HintText)
4242
@Html.HiddenFor(x =>x.DataStart)
43-
<div class="nhsuk-form-group">
43+
<div class="nhsuk-form-group @(errorHasOccurred ? "nhsuk-form-group--error" : "")">
4444
<fieldset class="nhsuk-fieldset">
45-
<legend class="nhsuk-fieldset__legend nhsuk-fieldset__legend--l">
46-
<h1 class="nhsuk-fieldset__heading">
47-
</h1>
48-
</legend>
4945
<div class="nhsuk-hint">
5046
For the last:
5147
</div>
48+
5249
<div class="nhsuk-radios" data-module="nhsuk-radios">
5350
@foreach (var (radio, index) in Model.PopulateDateRange().Select((r, i) => (r, i)))
5451
{
55-
var radioId = $"TimePeriod-{index}";
52+
var radioId = index == 0 ? "TimePeriod" : $"TimePeriod-{index}";
5653
@if (radio.Value != "Custom")
5754
{
5855

5956
<div class="nhsuk-radios__item">
6057
<input class="nhsuk-radios__input"
6158
id="@radioId"
59+
asp-for="TimePeriod"
6260
name="TimePeriod"
6361
type="radio"
6462
value="@radio.Value"
6563
aria-describedby="@(!string.IsNullOrEmpty(radio.HintText) ? $"{radio.Value}-item-hint" : string.Empty)"
6664
data-val-required="Select a time period"
67-
data-val="true"
68-
@(radio.Value == Model.TimePeriod ? "checked" : string.Empty) />
65+
data-val="false" />
6966
<label class="nhsuk-label nhsuk-radios__label" for="@radioId">
7067
@radio.Label
7168
</label>
@@ -92,7 +89,7 @@
9289
<div class="date-range-container">
9390
<div class="date-range-item">
9491
<div class="nhsuk-form-group nhsuk-date-inline">
95-
<label class="nhsuk-label nhsuk-label--strong nhsuk-u-padding-top-5" for="StartDate">From</label>
92+
<label class="nhsuk-label nhsuk-label--strong nhsuk-u-font-weight-bold nhsuk-u-padding-top-5" for="StartDate">From</label>
9693
<vc:date-input id="StartDate"
9794
label=""
9895
day-id="StartDay"
@@ -104,7 +101,7 @@
104101
</div>
105102
<div class="date-range-item">
106103
<div class="nhsuk-form-group nhsuk-date-inline">
107-
<label class="nhsuk-label nhsuk-label--strong nhsuk-u-padding-top-5" for="EndDate">To</label>
104+
<label class="nhsuk-label nhsuk-label--strong nhsuk-u-font-weight-bold nhsuk-u-padding-top-5" for="EndDate">To</label>
108105
<vc:date-input id="EndDate"
109106
label=""
110107
day-id="EndDay"
@@ -129,7 +126,7 @@
129126
</div>
130127
<div class="nhsuk-u-padding-top-7 nhsuk-u-padding-bottom-7">
131128

132-
<button class="nhsuk-button" type="submit">Continue</button>
129+
<button class="nhsuk-button" type="submit">Submit</button>
133130
</div>
134131

135132

LearningHub.Nhs.WebUI/Views/Shared/Components/DynamicCheckboxes/Default.cshtml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
@model DynamicCheckboxesViewModel
33
@{
44
var propertyName = ViewData["PropertyName"]?.ToString() ?? "SelectedValues";
5+
var exclusiveGroup = $"{propertyName}-list";
56
}
67

78
<div class="nhsuk-form-group @(Model.Required && !Model.SelectedValues.Any() ? "nhsuk-form-group--error" : "")">
@@ -17,14 +18,16 @@
1718
@for (int i = 0; i < Model.Checkboxes.Count; i++)
1819
{
1920
var checkbox = Model.Checkboxes[i];
20-
var inputId = $"{propertyName}_{i}";
21+
var inputId = i == 0 ? propertyName : $"{propertyName}_{i}";
2122

2223
<div class="nhsuk-checkboxes__item">
2324
<input class="nhsuk-checkboxes__input"
2425
id="@inputId"
2526
name="@propertyName"
2627
type="checkbox"
2728
value="@checkbox.Value"
29+
@(checkbox.Exclusive ? "data-checkbox-exclusive" : null)
30+
data-checkbox-exclusive-group="@exclusiveGroup"
2831
@(checkbox.Selected ? "checked" : null) />
2932

3033
<label class="nhsuk-label nhsuk-checkboxes__label" for="@inputId">

0 commit comments

Comments
 (0)