Skip to content

Commit

Permalink
Merge pull request #809 from alphagov/update-step-navs
Browse files Browse the repository at this point in the history
Render step by step navigation from content items
  • Loading branch information
sihugh authored Mar 8, 2018
2 parents fba29f3 + e845296 commit 3bda9b4
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 25 deletions.
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ GEM
debug_inspector (0.0.3)
domain_name (0.5.20170404)
unf (>= 0.0.5, < 1.0.0)
erubi (1.7.0)
erubi (1.7.1)
execjs (2.7.0)
faker (1.8.7)
i18n (>= 0.7)
Expand Down Expand Up @@ -250,7 +250,7 @@ GEM
rake
raindrops (0.19.0)
rake (12.3.0)
rb-fsevent (0.10.2)
rb-fsevent (0.10.3)
rb-inotify (0.9.10)
ffi (>= 0.5.0, < 2)
request_store (1.4.0)
Expand Down
11 changes: 3 additions & 8 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,10 @@ class ApplicationController < ActionController::Base

private

def current_step_nav
@step_nav ||= GovukNavigationHelpers::StepNavContent.current_step_nav(request.path)
def step_nav_helper
@step_nav_helpers ||= GovukPublishingComponents::StepNavHelper.new(content_item.content_item, request.path)
end
helper_method :current_step_nav

def show_step_nav?
current_step_nav && current_step_nav.show_step_nav?
end
helper_method :show_step_nav?
helper_method :step_nav_helper

def content_item_path
path_and_optional_locale = params
Expand Down
2 changes: 1 addition & 1 deletion app/views/content_items/publication.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<%= content_for :no_breadcrumbs, show_step_nav? %>
<%= content_for :no_breadcrumbs, step_nav_helper.show_header? %>
<%= content_for :simple_header, @navigation.should_present_taxonomy_navigation? %>

<div class="grid-row">
Expand Down
4 changes: 2 additions & 2 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@

<div id="wrapper" class="<%= wrapper_class %>">
<%= render_phase_label @content_item, content_for(:phase_message) %>
<% if show_step_nav?%>
<%= render 'shared/step_nav_header', step_nav_content: current_step_nav %>
<% if step_nav_helper.show_header? %>
<%= render 'shared/step_nav_header' %>
<% else %>
<% if !content_for(:no_breadcrumbs) %>
<%= render 'shared/breadcrumbs' %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/shared/_sidebar_navigation.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<% if show_step_nav? %>
<% if step_nav_helper.show_related_links? %>
<%= render 'shared/sidebar_step_nav', no_margin: true %>
<% else %>
<div class="column-third">
Expand Down
9 changes: 4 additions & 5 deletions app/views/shared/_sidebar_step_nav.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
no_margin ||= false
%>
<nav class="column-third <%= "step-by-step-nav-sidebar" unless no_margin %>">
<%= render 'govuk_publishing_components/components/step_by_step_nav_related', links: [{
href: current_step_nav.base_path,
text: current_step_nav.title
}] %>
<%= render 'govuk_publishing_components/components/step_by_step_nav', current_step_nav.set_current_step %>
<%= render 'govuk_publishing_components/components/step_by_step_nav_related', links: step_nav_helper.related_links %>
<% if step_nav_helper.show_sidebar? && step_nav_helper %>
<%= render 'govuk_publishing_components/components/step_by_step_nav', step_nav_helper.sidebar %>
<% end %>
</nav>
8 changes: 3 additions & 5 deletions app/views/shared/_step_nav_header.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
<%= render "govuk_publishing_components/components/step_by_step_nav_header",
title: current_step_nav.title,
path: current_step_nav.base_path,
skip_link: current_step_nav.skip_link
%>
<% if step_nav_helper.show_header? %>
<%= render 'govuk_publishing_components/components/step_by_step_nav_header', step_nav_helper.header %>
<% end %>
2 changes: 1 addition & 1 deletion test/controllers/step_navigation_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class ContentItemsControllerTest < ActionController::TestCase

%w(guide answer publication).each do |schema_name|
test "#{schema_name} shows step by step navigation where relevant" do
content_item = content_store_has_schema_example(schema_name, schema_name)
content_item = content_store_has_schema_example(schema_name, "#{schema_name}-with-step-navs")
content_item['base_path'] = "/pass-plus"
path = content_item['base_path'][1..-1]

Expand Down

0 comments on commit 3bda9b4

Please sign in to comment.