Skip to content

Commit 630eaa0

Browse files
authored
Merge pull request #2093 from TechnologyEnhancedLearning/Develop/Fixes/TD-2371_View_more_link_should_be_hidden_if_displayed_data_rows_is_less_or_equal_to_5
TD-2371 Hide 'View more' link if displayed data rows is less than or equal to count 5 on report screens
2 parents 3798b6b + a207990 commit 630eaa0

File tree

12 files changed

+149
-100
lines changed

12 files changed

+149
-100
lines changed

DigitalLearningSolutions.Data/DataServices/SupervisorService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ FROM CandidateAssessmentSupervisorVerifications AS casv
554554
(SELECT COUNT(*) AS Expr1
555555
FROM SelfAssessmentResultSupervisorVerifications AS sarsv
556556
WHERE (CandidateAssessmentSupervisorID = cas.ID) AND (Verified IS NULL) AND (Superceded = 0)) AS ResultsVerificationRequests,
557-
ca.NonReportable
557+
ca.NonReportable,ca.DelegateUserID
558558
FROM CandidateAssessmentSupervisors AS cas INNER JOIN
559559
CandidateAssessments AS ca ON cas.CandidateAssessmentID = ca.ID INNER JOIN
560560
SelfAssessments AS sa ON sa.ID = ca.SelfAssessmentID INNER JOIN
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace DigitalLearningSolutions.Data.Enums
2+
{
3+
public enum ViewDelegateNavigationType
4+
{
5+
PromoteToAdmin
6+
}
7+
}

DigitalLearningSolutions.Web.Tests/Controllers/TrackingSystem/Delegates/ViewDelegateControllerTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public void Index_shows_centre_specific_email_if_not_null()
6767
A.CallTo(() => userService.GetDelegateById(delegateId)).Returns(delegateEntity);
6868

6969
// When
70-
var result = viewDelegateController.Index(delegateId);
70+
var result = viewDelegateController.Index(delegateId, null);
7171

7272
// Then
7373
result.As<ViewResult>().Model.As<ViewDelegateViewModel>().DelegateInfo.Email.Should()
@@ -83,7 +83,7 @@ public void Index_shows_primary_email_if_centre_specific_email_is_null()
8383
A.CallTo(() => userService.GetDelegateById(delegateId)).Returns(delegateEntity);
8484

8585
// When
86-
var result = viewDelegateController.Index(delegateId);
86+
var result = viewDelegateController.Index(delegateId, null);
8787

8888
// Then
8989
result.As<ViewResult>().Model.As<ViewDelegateViewModel>().DelegateInfo.Email.Should()
@@ -98,7 +98,7 @@ public void Index_returns_not_found_result_if_no_delegate_found_with_given_id()
9898
A.CallTo(() => userService.GetDelegateById(delegateId)).Returns(null);
9999

100100
// When
101-
var result = viewDelegateController.Index(delegateId);
101+
var result = viewDelegateController.Index(delegateId, null);
102102

103103
// Then
104104
result.Should().BeNotFoundResult();

DigitalLearningSolutions.Web/Controllers/SupervisorController/Supervisor.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,8 @@ public IActionResult ReviewDelegateSelfAssessment(int supervisorDelegateId, int
347347
CompetencyGroups = competencies.GroupBy(competency => competency.CompetencyGroup),
348348
IsSupervisorResultsReviewed = delegateSelfAssessment.IsSupervisorResultsReviewed,
349349
SearchViewModel = searchModel,
350+
CandidateAssessmentId = candidateAssessmentId,
351+
ExportToExcelHide = delegateSelfAssessment.SupervisorRoleTitle.Contains("Assessor")
350352
};
351353

352354
var flags = frameworkService.GetSelectedCompetencyFlagsByCompetecyIds(reviewedCompetencies.Select(c => c.Id).ToArray());
@@ -1299,9 +1301,19 @@ private int IsSupervisorDelegateExistAndActive(int adminId, string delegateEmail
12991301
{
13001302
return 0;
13011303
}
1302-
13031304
}
13041305
return existingId;
13051306
}
1307+
1308+
public IActionResult ExportCandidateAssessment(int candidateAssessmentId, string delegateName, string selfAssessmentName,int delegateUserID)
1309+
{
1310+
var content = candidateAssessmentDownloadFileService.GetCandidateAssessmentDownloadFileForCentre(candidateAssessmentId, delegateUserID, true);
1311+
var fileName = $"{selfAssessmentName.Substring(0,29)}-{delegateName}-{clockUtility.UtcNow:yyyy-MM-dd}.xlsx";
1312+
return File(
1313+
content,
1314+
FileHelper.GetContentTypeFromFileName(fileName),
1315+
fileName
1316+
);
1317+
}
13061318
}
13071319
}

DigitalLearningSolutions.Web/Controllers/SupervisorController/SupervisorController.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
{
33
using DigitalLearningSolutions.Data.DataServices;
44
using DigitalLearningSolutions.Data.DataServices.UserDataService;
5+
using DigitalLearningSolutions.Data.Services;
6+
using DigitalLearningSolutions.Data.Utilities;
57
using DigitalLearningSolutions.Web.Helpers;
68
using DigitalLearningSolutions.Web.Services;
79
using GDS.MultiPageFormData;
@@ -26,6 +28,8 @@ public partial class SupervisorController : Controller
2628
private readonly IUserService userService;
2729
private readonly IEmailGenerationService emailGenerationService;
2830
private readonly IEmailService emailService;
31+
private readonly ICandidateAssessmentDownloadFileService candidateAssessmentDownloadFileService;
32+
private readonly IClockUtility clockUtility;
2933

3034
public SupervisorController(
3135
ISupervisorService supervisorService,
@@ -43,9 +47,11 @@ public SupervisorController(
4347
IRegistrationService registrationService,
4448
ICentresDataService centresDataService,
4549
IUserService userService,
46-
IEmailGenerationService emailGenerationService,
47-
IEmailService emailService
48-
)
50+
IEmailGenerationService emailGenerationService,
51+
IEmailService emailService,
52+
ICandidateAssessmentDownloadFileService candidateAssessmentDownloadFileService,
53+
IClockUtility clockUtility
54+
)
4955
{
5056
this.supervisorService = supervisorService;
5157
this.frameworkNotificationService = frameworkNotificationService;
@@ -60,6 +66,8 @@ IEmailService emailService
6066
this.userService = userService;
6167
this.emailGenerationService = emailGenerationService;
6268
this.emailService = emailService;
69+
this.candidateAssessmentDownloadFileService = candidateAssessmentDownloadFileService;
70+
this.clockUtility = clockUtility;
6371
}
6472

6573
private int GetCentreId()

DigitalLearningSolutions.Web/Controllers/TrackingSystem/Delegates/PromoteToAdminController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ public IActionResult Index(AdminRolesFormData formData, int delegateId)
173173
return new StatusCodeResult(500);
174174
}
175175
TempData["IsDelegatePromoted"] = true;
176-
return RedirectToAction("Index", "ViewDelegate", new { delegateId });
176+
return RedirectToAction("Index", "ViewDelegate", new { delegateId = delegateId, callType = ViewDelegateNavigationType.PromoteToAdmin });
177177
}
178178
}
179179
}

DigitalLearningSolutions.Web/Controllers/TrackingSystem/Delegates/ViewDelegateController.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ IEmailVerificationDataService emailVerificationDataService
5757
this.emailVerificationDataService = emailVerificationDataService;
5858
}
5959

60-
public IActionResult Index(int delegateId)
60+
public IActionResult Index(int delegateId, string? callType)
6161
{
6262
var centreId = User.GetCentreIdKnownNotNull();
6363

@@ -68,7 +68,7 @@ public IActionResult Index(int delegateId)
6868
return NotFound();
6969
}
7070

71-
if (TempData["IsDelegatePromoted"] != null)
71+
if (string.IsNullOrEmpty(callType) && TempData["IsDelegatePromoted"] != null)
7272
{
7373
TempData.Remove("IsDelegatePromoted");
7474
}

DigitalLearningSolutions.Web/Styles/frameworks/frameworksShared.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,3 +248,6 @@ h1.truncate-overflow::after {
248248
inline-size: 305px;
249249
}
250250
}
251+
.float-right{
252+
float:right;
253+
}

DigitalLearningSolutions.Web/ViewModels/Supervisor/ReviewSelfAssessmentViewModel.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,7 @@ public string VocabPlural(string vocabulary)
1919
{
2020
return FrameworkVocabularyHelper.VocabularyPlural(vocabulary);
2121
}
22+
public int CandidateAssessmentId { get; set; }
23+
public bool ExportToExcelHide { get; set; }
2224
}
2325
}
Lines changed: 44 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,52 @@
11
@using DigitalLearningSolutions.Web.ViewModels.Common
22
@model SelfAssessmentActivityTableViewModel
33
@{
4-
const int defaultNumOfRowsVisible = 5;
4+
const int defaultNumOfRowsVisible = 5;
55

6-
//These must match with the name in trackingSystem/reports.ts
7-
const string toggleableActivityButtonId = "js-toggle-row-button";
8-
const string toggleableActivityRowClass = "js-toggleable-activity-row";
6+
//These must match with the name in trackingSystem/reports.ts
7+
const string toggleableActivityButtonId = "js-toggle-row-button";
8+
const string toggleableActivityRowClass = "js-toggleable-activity-row";
99
}
1010

1111
<table role="table" class="nhsuk-table-responsive">
12-
<thead role="rowgroup" class="nhsuk-table__head">
13-
<tr role="row">
14-
<th role="columnheader" scope="col">
15-
Period
16-
</th>
17-
<th role="columnheader" scope="col">
18-
Enrolments
19-
</th>
20-
<th role="columnheader" scope="col">
21-
Completions
22-
</th>
23-
</tr>
24-
</thead>
25-
<tbody class="nhsuk-table__body">
26-
@foreach (var (activityRow, rowNumber) in Model.Rows.Select((row, index) => (row, index + 1)))
27-
{
28-
<tr role="row" class="nhsuk-table__row @(rowNumber > defaultNumOfRowsVisible ? toggleableActivityRowClass : string.Empty)">
29-
<td role="cell" class="nhsuk-table__cell">
30-
<span class="nhsuk-table-responsive__heading">Period </span>@activityRow.Period
31-
</td>
32-
<td role="cell" class="nhsuk-table__cell">
33-
<span class="nhsuk-table-responsive__heading">Enrolments </span>@activityRow.Enrolments
34-
</td>
35-
<td role="cell" class="nhsuk-table__cell">
36-
<span class="nhsuk-table-responsive__heading">Completions </span>@activityRow.Completions
37-
</td>
38-
</tr>
39-
}
40-
</tbody>
12+
<thead role="rowgroup" class="nhsuk-table__head">
13+
<tr role="row">
14+
<th role="columnheader" scope="col">
15+
Period
16+
</th>
17+
<th role="columnheader" scope="col">
18+
Enrolments
19+
</th>
20+
<th role="columnheader" scope="col">
21+
Completions
22+
</th>
23+
</tr>
24+
</thead>
25+
<tbody class="nhsuk-table__body">
26+
@foreach (var (activityRow, rowNumber) in Model.Rows.Select((row, index) => (row, index + 1)))
27+
{
28+
<tr role="row" class="nhsuk-table__row @(rowNumber > defaultNumOfRowsVisible ? toggleableActivityRowClass : string.Empty)">
29+
<td role="cell" class="nhsuk-table__cell">
30+
<span class="nhsuk-table-responsive__heading">Period </span>@activityRow.Period
31+
</td>
32+
<td role="cell" class="nhsuk-table__cell">
33+
<span class="nhsuk-table-responsive__heading">Enrolments </span>@activityRow.Enrolments
34+
</td>
35+
<td role="cell" class="nhsuk-table__cell">
36+
<span class="nhsuk-table-responsive__heading">Completions </span>@activityRow.Completions
37+
</td>
38+
</tr>
39+
}
40+
</tbody>
4141
</table>
42-
43-
<div class="nhsuk-u-margin-top-4">
44-
<a id="@(toggleableActivityButtonId)"
45-
role="button"
46-
class="nhsuk-u-margin-top-4 js-only-inline"
47-
href="#">
48-
View more
49-
</a>
50-
</div>
42+
@if (Model.Rows.Count() > defaultNumOfRowsVisible)
43+
{
44+
<div class="nhsuk-u-margin-top-4">
45+
<a id="@(toggleableActivityButtonId)"
46+
role="button"
47+
class="nhsuk-u-margin-top-4 js-only-inline"
48+
href="#">
49+
View more
50+
</a>
51+
</div>
52+
}

0 commit comments

Comments
 (0)