Skip to content

Commit

Permalink
Merge pull request #613 from DFE-Digital/next
Browse files Browse the repository at this point in the history
Pathways QA Issue Resolutions
  • Loading branch information
mattb-hippo authored Jan 22, 2025
2 parents 22e5bd6 + 42124a5 commit dbdd277
Show file tree
Hide file tree
Showing 21 changed files with 233 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,46 @@ public void Page_Of_Type_Pathways_Overview_Page_Associated_With_Pathways_Module_
sut.Next.Url.Should().Be("/" + "TRAINING_CONTENT_PAGE_ID");
}

[Test]
public void Page_Of_Type_Pathways_Overview_Page_Associated_With_Pathways_Module_Of_Type_Introductory_Module_Should_Have_Correct_Next_Location_Name()
{
// setup
var page = new Content()
{
PageType = PageType.PathwaysOverviewPage,
PathwaysModule = new PathwaysModule()
{
Type = PathwaysModuleType.IntroductoryModule
}
};

// act
var sut = new PathwaysNavigationHelper(page);

// assert
sut.Next.Name.Should().Be("Start module");
}

[Test]
public void Page_Of_Type_Pathways_Overview_Page_Associated_With_Pathways_Module_Of_Type_Regular_Module_Should_Have_Correct_Next_Location_Name()
{
// setup
var page = new Content()
{
PageType = PageType.PathwaysOverviewPage,
PathwaysModule = new PathwaysModule()
{
Type = PathwaysModuleType.RegularModule
}
};

// act
var sut = new PathwaysNavigationHelper(page);

// assert
sut.Next.Name.Should().Be("Start pathway");
}

#endregion

#region Contents Page
Expand Down Expand Up @@ -196,6 +236,32 @@ public void Page_Of_Type_Pathways_Contents_Page_Should_Have_Default_Next_Url_If_
sut.Next.Url.Should().Be("/");
}

[Test]
public void Pathway_Contents_Page_Should_Have_Pathway_Start_Page_As_Previous_Location ()
{
// setup
var page = new Content
{
PageType = PageType.PathwaysContentsPage,
Id = "PAGE_ID",
PathwaysModule = new PathwaysModule
{
OverviewPage = new Content
{
Id = "START_PAGE_ID",
BreadcrumbText = "START_PAGE_BREADCRUMB_TEXT"
}
}
};

// act
var sut = new PathwaysNavigationHelper(page);

// assert
sut.Previous.Url.Should().Be("/START_PAGE_ID");
sut.Previous.Name.Should().Be("Back to START_PAGE_BREADCRUMB_TEXT");
}

#endregion

#region Training Content Pages
Expand Down Expand Up @@ -510,8 +576,8 @@ public void Last_Page_In_Last_Section_Of_Module_Should_Have_All_Pathways_Page_Ne
var sut = new PathwaysNavigationHelper(page);

// assert
sut.Next.Name.Should().Be("Go back to all pathways");
sut.Next.Url.Should().Be("/pathways-social-work-leadership-modules-available");
sut.Next.Name.Should().Be("Go back to Available pathways");
sut.Next.Url.Should().Be("/pathways-social-work-leadership-modules/available-pathways");
sut.Previous.Name.Should().Be("Previous");
sut.Previous.Url.Should().Be("/section 2 page 2");
}
Expand Down Expand Up @@ -643,8 +709,8 @@ public void Pathways_Training_Content_Page_Which_Is_Only_Page_In_Only_Section_Sh
var sut = new PathwaysNavigationHelper(page);

// assert
sut.Next.Name.Should().Be("Go back to all pathways");
sut.Next.Url.Should().Be("/pathways-social-work-leadership-modules-available");
sut.Next.Name.Should().Be("Go back to Available pathways");
sut.Next.Url.Should().Be("/pathways-social-work-leadership-modules/available-pathways");
sut.Previous.Name.Should().Be("Previous");
sut.Previous.Url.Should().Be("/CONTENTS_PAGE_ID");
}
Expand Down Expand Up @@ -706,7 +772,7 @@ public void Page_Of_Type_All_Pathways_Overview_Page_Should_Render_With_Go_To_The
var sut = new PathwaysNavigationHelper(page);

// assert
sut.Next.Url.Should().Be("/pathways-social-work-leadership-modules-available");
sut.Next.Url.Should().Be("/pathways-social-work-leadership-modules/available-pathways");
}

#endregion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ namespace Childrens_Social_Care_CPD.Contentful.Models;
public class PathwaysModuleSection: IContent
{
public string Name { get; set; }
public string ShortName {get; set; }
public string Summary { get; set; }
public List<Content> Pages { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ public interface INavigationHelper
{
public NavigationLocation Next { get; }
public NavigationLocation Previous { get; }
public NavigationLocation AvailablePathwaysPage { get; }
public LocationInfo CurrentLocation { get; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class PathwaysNavigationHelper : INavigationHelper
private NavigationLocation _previous;
private readonly NavigationLocation _availablePathwaysPage = new NavigationLocation
{
Url = "/pathways-social-work-leadership-modules-available"
Url = "/pathways-social-work-leadership-modules/available-pathways"
};
private LocationInfo _currentLocation;

Expand Down Expand Up @@ -67,7 +67,10 @@ public PathwaysNavigationHelper(Content page)

this._next = new NavigationLocation
{
Url = url
Url = url,
Name = page.PathwaysModule?.Type == PathwaysModuleType.IntroductoryModule
? "Start module"
: "Start pathway"
};
break;

Expand All @@ -77,6 +80,12 @@ public PathwaysNavigationHelper(Content page)
{
Url = "/" + GetFirstSectionFirstPageId(page)
};

this._previous = new NavigationLocation
{
Url = "/" + page.PathwaysModule?.OverviewPage?.Id,
Name = "Back to " + page.PathwaysModule?.OverviewPage?.BreadcrumbText
};
break;

case PageType.PathwaysTrainingContent:
Expand Down Expand Up @@ -135,11 +144,11 @@ private void SetTrainingPageNextNavigation(int pageCounter, int sectionCounter,
}
else
{
// last page in last module, next navigates to 'all pathways page'
// last page in last module, next navigates to 'Available pathways page'
this._next = new NavigationLocation
{
Url = AvailablePathwaysPage.Url,
Name = "Go back to all pathways"
Name = "Go back to Available pathways"
};
}
}
Expand Down
63 changes: 46 additions & 17 deletions Childrens-Social-Care-CPD/Views/Shared/_BreadcrumbTrail.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,54 @@

<div class="govuk-breadcrumbs govuk-breadcrumbs--collapse-on-mobile">
<ul>
@if (Model.PageType == PageType.PathwaysTrainingContent)
{
<li class="govuk-breadcrumbs__list-item">
&lt;
<a class="govuk-breadcrumbs__link" href="/@Model.PathwaysModule.OverviewPage.Id">
Back to @Model.PathwaysModule.OverviewPage.Title
</a>
</li>
}
else
{
@foreach(KeyValuePair<string, string> trailItem in breadcrumbs)
@{
switch (Model.PageType)
{
<li class="govuk-breadcrumbs__list-item">
<a class="govuk-breadcrumbs__link" href="/@trailItem.Value">
@trailItem.Key
</a>
</li>
case PageType.PathwaysTrainingContent:
Content navigationPage = @Model.PathwaysModule.Type == PathwaysModuleType.IntroductoryModule
? Model.PathwaysModule.OverviewPage
: Model.PathwaysModule.ContentsPage;

string linkText = navigationPage.BreadcrumbText ?? navigationPage.Title;

<li class="govuk-breadcrumbs__list-item">
&lt;
<a class="govuk-breadcrumbs__link" href="/@navigationPage.Id">
Back to @linkText
</a>
</li>
break;

case PageType.PathwaysOverviewPage:
<li class="govuk-breadcrumbs__list-item">
&lt;
<a class="govuk-breadcrumbs__link" href="@contextModel.NavigationHelper.AvailablePathwaysPage.Url">
Back to Available pathways
</a>
</li>
break;

case PageType.PathwaysContentsPage:
<li class="govuk-breadcrumbs__list-item">
&lt;
<a class="govuk-breadcrumbs__link" href="@contextModel.NavigationHelper.Previous.Url">
@contextModel.NavigationHelper.Previous.Name
</a>
</li>
break;

default:
@foreach(KeyValuePair<string, string> trailItem in breadcrumbs)
{
<li class="govuk-breadcrumbs__list-item">
<a class="govuk-breadcrumbs__link" href="/@trailItem.Value">
@trailItem.Key
</a>
</li>
}
break;
}
}

</ul>
</div>
2 changes: 1 addition & 1 deletion Childrens-Social-Care-CPD/Views/Shared/_ErrorLayout.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
@if (featuresConfig.IsEnabled(Features.PathwaysTraining))
{
<li class="dfe-header__navigation-item" id="mmi-pathwaysTraning">
<a class="dfe-header__navigation-link" href="/pathways-social-work-leadership-modules-overview">
<a class="dfe-header__navigation-link" href="/pathways-social-work-leadership-modules/about-pathways">
Pathways training
<svg class="dfe-icon dfe-icon__chevron-right" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" width="34" height="34">
<path d="M15.5 12a1 1 0 0 1-.29.71l-5 5a1 1 0 0 1-1.42-1.42l4.3-4.29-4.3-4.29a1 1 0 0 1 1.42-1.42l5 5a1 1 0 0 1 .29.71z"></path>
Expand Down
2 changes: 1 addition & 1 deletion Childrens-Social-Care-CPD/Views/Shared/_Header.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
}
if (featuresConfig.IsEnabled(Features.PathwaysTraining))
{
RenderMenuItem("pathwaysTraining", "Pathways training", "pathways-social-work-leadership-modules-overview", category == "Pathways training");
RenderMenuItem("pathwaysTraining", "Pathways training", "pathways-social-work-leadership-modules/about-pathways", category == "Pathways training");
}
}
</ul>
Expand Down
45 changes: 34 additions & 11 deletions Childrens-Social-Care-CPD/Views/Shared/_InfoBox.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,39 @@
break;
}
}

<div class="@css">
<div class="govuk-grid-row">
<div class="govuk-grid-column-one-quarter">
@Html.Raw(@svg)
</div>
<div class="govuk-grid-column-three-quarters">
@{ RenderTitle(); }
<partial name="_RichText" model="Model.Document" />
@if (ViewBag.ContextModel.UseContainers ?? true)
{
<div class="govuk-width-container dfe-width-container">
<div class="govuk-grid-row">
<div class="govuk-grid-row">
<div class="@css govuk-grid-column-three-quarters">
<div class="govuk-grid-row">
<div class="govuk-grid-column-one-quarter">
@Html.Raw(@svg)
</div>
<div class="govuk-grid-column-three-quarters">
@{ RenderTitle(); }
<partial name="_RichText" model="Model.Document" />
</div>
</div>
</div>
</div>
</div>
</div>
</div>

}
else
{
<div class="govuk-grid-row">
<div class="@css">
<div class="govuk-grid-row">
<div class="govuk-grid-column-one-quarter">
@Html.Raw(@svg)
</div>
<div class="govuk-grid-column-three-quarters">
@{ RenderTitle(); }
<partial name="_RichText" model="Model.Document" />
</div>
</div>
</div>
</div>
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,24 +41,28 @@
@if (Model.PathwaysModule?.Sections != null) {
foreach (var moduleSection in Model.PathwaysModule.Sections)
{
string displayText = moduleSection.ShortName ?? moduleSection.Name;
sectionCount++;
<section class="module-overview--section">
<div class="progress-bar">
<span class="icon not_started">
<span class="number">@sectionCount</span>
</span>
<div class="line"></div>
@if(moduleSection != Model.PathwaysModule.Sections[Model.PathwaysModule.Sections.Count - 1])
{
<div class="line"></div>
}
</div>
<div class="module-section--content">
<div class="module-section--header">
<h4 class="govuk-heading-s">
<h4 class="govuk-heading-s pathways-module-index">
@if (moduleSection.Pages == null) {
<div class="contentful-configuration-error">
Configuration problem in Module Section: <span class="highlight">No pages defined</span><br />
Add Content item(s) to this Pathways Module Section to resolve this.
</div>
}
@moduleSection.Name <span class="module-section--pages">(@moduleSection.Pages?.Count pages)</span>
@displayText <span class="module-section--pages">(@moduleSection.Pages?.Count pages)</span>
</h4>
<a href="/@moduleSection.Pages?[0].Id" class="section-nav-link govuk-link" data-track-label="">Go to this section</a>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
@{
ContextModel contextModel = (ContextModel)ViewBag.ContextModel;
<a href="@contextModel.NavigationHelper.Next.Url" draggable="false" class="govuk-button govuk-button--start" data-module="govuk-button">
Start module
@contextModel.NavigationHelper.Next.Name
<svg class="govuk-button__start-icon" xmlns="http://www.w3.org/2000/svg" width="17.5" height="19" viewBox="0 0 33 40" aria-hidden="true" focusable="false">
<path fill="currentColor" d="M0 0h13l20 20-20 20H0l20-20z" />
</svg>
Expand Down
2 changes: 2 additions & 0 deletions Childrens-Social-Care-CPD/Views/Shared/_QuoteBox.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

<div class="blockquote-container">
<div class="govuk-grid-row">
<div class="govuk-grid-column-three-quarters">
<blockquote class="quote">
@{
await Html.RenderPartialAsync("_RichText", Model.QuoteText);
Expand All @@ -31,5 +32,6 @@
</div>
}
</blockquote>
</div>
</div>
</div>
Loading

0 comments on commit dbdd277

Please sign in to comment.