-
Notifications
You must be signed in to change notification settings - Fork 1
HEEDLS-431 - Populated course setup cards #492
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
f02ef4a
HEEDLS-431 - Populated course setup cards
DanBloxham-sw fd60274
HEEDLS-431 - Remove unused properties from view model
DanBloxham-sw dc83f8c
HEEDLS-431 - Prevent Copy Course Link from having visited styling
DanBloxham-sw ef08a8c
HEEDLS-431 - Review markups
DanBloxham-sw 72ec37d
HEEDLS-431 - fix lint test
DanBloxham-sw d1e30fb
Merge branch master into HEEDLS-431-CourseSetupPopulateCourseCards
DanBloxham-sw 5ce276e
HEEDLS-431 - neaten up JS and centre course card
DanBloxham-sw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
DigitalLearningSolutions.Web/Helpers/FilterOptions/CourseFilterOptions.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| namespace DigitalLearningSolutions.Web.Helpers.FilterOptions | ||
| { | ||
| using DigitalLearningSolutions.Data.Models.Courses; | ||
| using DigitalLearningSolutions.Web.Models.Enums; | ||
| using DigitalLearningSolutions.Web.ViewModels.Common.SearchablePage; | ||
|
|
||
| public static class CourseStatusFilterOptions | ||
| { | ||
| private const string Group = "Status"; | ||
|
|
||
| public static readonly FilterOptionViewModel IsInactive = new FilterOptionViewModel( | ||
| "Inactive", | ||
| Group + FilteringHelper.Separator + nameof(CourseStatistics.Active) + FilteringHelper.Separator + "false", | ||
| FilterStatus.Warning | ||
| ); | ||
|
|
||
| public static readonly FilterOptionViewModel IsActive = new FilterOptionViewModel( | ||
| "Active", | ||
| Group + FilteringHelper.Separator + nameof(CourseStatistics.Active) + FilteringHelper.Separator + "true", | ||
| FilterStatus.Success | ||
| ); | ||
|
|
||
| public static readonly FilterOptionViewModel IsHiddenInLearningPortal = new FilterOptionViewModel( | ||
| "Hidden in Learning Portal", | ||
| Group + FilteringHelper.Separator + nameof(CourseStatistics.HideInLearnerPortal) + | ||
| FilteringHelper.Separator + "true", | ||
| FilterStatus.Warning | ||
| ); | ||
|
|
||
| public static readonly FilterOptionViewModel IsNotHiddenInLearningPortal = new FilterOptionViewModel( | ||
| "Visible in Learning Portal", | ||
| Group + FilteringHelper.Separator + nameof(CourseStatistics.HideInLearnerPortal) + | ||
| FilteringHelper.Separator + "true", | ||
| FilterStatus.Success | ||
| ); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
DigitalLearningSolutions.Web/Scripts/trackingSystem/centreCourseSetup.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| const copyCourseLinkClass = 'copy-course-button'; | ||
| const copyLinkIdPrefix = 'copy-course-'; | ||
| const launchCourseButtonIdPrefix = 'launch-course-'; | ||
|
|
||
| setUpCourseLinkClipboardCopiers(); | ||
|
|
||
| function setUpCourseLinkClipboardCopiers() { | ||
| const copyCourseLinks = Array.from(document.getElementsByClassName(copyCourseLinkClass)); | ||
|
|
||
| copyCourseLinks.forEach( | ||
| (currentLink) => { | ||
| const linkId = currentLink.id; | ||
| const customisationId = linkId.slice(copyLinkIdPrefix.length); | ||
| currentLink.addEventListener('click', () => copyLaunchCourseLinkToClipboard(customisationId)); | ||
| }, | ||
| ); | ||
| } | ||
|
|
||
| function copyLaunchCourseLinkToClipboard(customisationId: string) { | ||
| const launchCourseButtonId = launchCourseButtonIdPrefix + customisationId; | ||
| const launchCourseButton = document.getElementById(launchCourseButtonId) as HTMLAnchorElement; | ||
| const link = launchCourseButton.href; | ||
| const succeeded = copyTextToClipboard(link); | ||
| const alertMessage = succeeded | ||
| ? `Copied the text: ${link}` | ||
| : `Copy not supported or blocked. Try manually selecting and copying: ${link}`; | ||
|
|
||
| alert(alertMessage); | ||
DanBloxham-sw marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| function copyTextToClipboard(textToCopy: string): boolean { | ||
| try { | ||
| navigator.clipboard.writeText(textToCopy); | ||
| return true; | ||
| } catch (e) { | ||
| return copyTextToClipboardFallback(textToCopy); | ||
| } | ||
| } | ||
|
|
||
| function copyTextToClipboardFallback(textToCopy: string): boolean { | ||
| const hiddenInput = document.body.appendChild(document.createElement('input')); | ||
stellake marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| hiddenInput.value = textToCopy; | ||
| hiddenInput.select(); | ||
| hiddenInput.setSelectionRange(0, textToCopy.length); | ||
| let succeeded: boolean; | ||
|
|
||
| try { | ||
| succeeded = document.execCommand('copy'); | ||
| } catch (e) { | ||
| succeeded = false; | ||
| } | ||
|
|
||
| document.body.removeChild(hiddenInput); | ||
| return succeeded; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
DigitalLearningSolutions.Web/Styles/trackingSystem/courseSetup.scss
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,18 @@ | ||
| @import "~nhsuk-frontend/packages/core/all"; | ||
| @import "../shared/cardWithButtons"; | ||
| @import "../shared/searchableElements/searchableElements"; | ||
|
|
||
| .copy-course-button{ | ||
| background: none; | ||
| border: none; | ||
| padding: 0; | ||
| color: $nhsuk-link-color; | ||
| @extend .nhsuk-u-font-size-19; | ||
| text-decoration: underline; | ||
|
|
||
| &:hover{ | ||
| color: $nhsuk-link-hover-color; | ||
| text-decoration: none; | ||
| cursor: pointer; | ||
| } | ||
| } |
29 changes: 20 additions & 9 deletions
29
...olutions.Web/ViewModels/TrackingSystem/CourseSetup/SearchableCourseStatisticsViewModel.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,28 +1,39 @@ | ||
| namespace DigitalLearningSolutions.Web.ViewModels.TrackingSystem.CourseSetup | ||
| { | ||
| using System; | ||
| using DigitalLearningSolutions.Data.Models.Courses; | ||
| using DigitalLearningSolutions.Web.Helpers; | ||
| using DigitalLearningSolutions.Web.ViewModels.Common.SearchablePage; | ||
|
|
||
| public class SearchableCourseStatisticsViewModel | ||
| public class SearchableCourseStatisticsViewModel : BaseFilterableViewModel | ||
| { | ||
| public SearchableCourseStatisticsViewModel(CourseStatistics courseStatistics) | ||
| { | ||
| CustomisationId = courseStatistics.CustomisationId; | ||
| CentreId = courseStatistics.CentreId; | ||
| Active = courseStatistics.Active; | ||
| DelegateCount = courseStatistics.DelegateCount; | ||
| CompletedCount = courseStatistics.CompletedCount; | ||
| InProgressCount = courseStatistics.InProgressCount; | ||
| PassRate = courseStatistics.PassRate; | ||
| CourseName = courseStatistics.CourseName; | ||
| CategoryName = courseStatistics.CategoryName; | ||
| LearningMinutes = courseStatistics.LearningMinutes; | ||
| Tags = FilterableTagHelper.GetCurrentTagsForCourseStatistics(courseStatistics); | ||
| } | ||
|
|
||
| public int CustomisationId { get; set; } | ||
| public int CentreId { get; set; } | ||
| public bool Active { get; set; } | ||
| public int DelegateCount { get; set; } | ||
| public int CompletedCount { get; set; } | ||
| public int InProgressCount { get; set; } | ||
| public string CourseName { get; set; } | ||
| public double PassRate { get; set; } | ||
| public string CategoryName { get; set; } | ||
| public string LearningMinutes { get; set; } | ||
|
|
||
| public string EmailHref => GenerateEmailHref(); | ||
|
|
||
| private string GenerateEmailHref() | ||
| { | ||
| var launchCourseLink = | ||
| $"{ConfigHelper.GetAppConfig()[ConfigHelper.AppRootPathName]}/LearningMenu/{CustomisationId}"; | ||
| var subject = Uri.EscapeDataString($"Digital Learning Solutions Course Link - {CourseName}"); | ||
| var content = Uri.EscapeDataString($"To start your {CourseName} course, go to {launchCourseLink}"); | ||
| return $"mailto:?subject={subject}&body={content}"; | ||
stellake marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.