Skip to content

Commit

Permalink
refactor: booleans added to LocationInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
Maria committed Feb 7, 2025
1 parent e1a3e35 commit 54a9c92
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ public class LocationInfo
public int SectionNumber { get; set; }
public int PageNumber { get; set; }
public int TotalSections { get; set; }
public bool IsFirstPageOfFirstSection {get; set; }
public bool IsLastSection {get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -204,14 +204,19 @@ private void SetTrainingPagePreviousNavigation(int pageCounter, int sectionCount
}

private void SetTrainingPageCurrentLocation(int currentSectionIdx, Content page, PathwaysModuleSection section, int currentPageIdx)
{
{
bool isFirstPageOfFirstSection = currentPageIdx+1==1 && currentSectionIdx+1==1;
bool isLastSection = currentSectionIdx + 1 == page.PathwaysModule.Sections.Count;
this._currentLocation = new LocationInfo
{
SectionName = section.Name,
SectionNumber = currentSectionIdx + 1,
TotalSections = page.PathwaysModule.Sections.Count,
PageNumber = currentPageIdx + 1
PageNumber = currentPageIdx + 1,
IsFirstPageOfFirstSection = isFirstPageOfFirstSection,
IsLastSection = isLastSection
};

}

private string GetFirstSectionFirstPageId (Content page)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
</div>

@* Render credit line in Module Type: Introductory Module on page 1 of section 1*@
@if (Model.PathwaysModule?.CreditBlock != null && Model.PathwaysModule.Type == PathwaysModuleType.IntroductoryModule && @contextModel.NavigationHelper.CurrentLocation.SectionNumber==1 && @contextModel.NavigationHelper.CurrentLocation.PageNumber==1)
@if (Model.PathwaysModule?.CreditBlock != null && Model.PathwaysModule.Type == PathwaysModuleType.IntroductoryModule && @contextModel.NavigationHelper.CurrentLocation.IsFirstPageOfFirstSection)
{
<div class="govuk-grid-row">
<div class="govuk-grid-column-three-quarters">
Expand All @@ -54,7 +54,7 @@
</div>
}
@* Render credit block in all other pages except for last page of last section*@
else if (Model.PathwaysModule?.CreditBlock != null && @contextModel.NavigationHelper.CurrentLocation.SectionNumber!=@contextModel.NavigationHelper.CurrentLocation.TotalSections)
else if (Model.PathwaysModule?.CreditBlock != null && !@contextModel.NavigationHelper.CurrentLocation.IsLastSection)
{
<div class="govuk-grid-row">
<div class="govuk-grid-column-three-quarters">
Expand Down

0 comments on commit 54a9c92

Please sign in to comment.