Skip to content
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

Fix unlabelled nav on licence transaction pages #4080

Merged
merged 1 commit into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions app/presenters/licence_details_presenter.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
class LicenceDetailsPresenter
include Rails.application.routes.url_helpers

attr_reader :licence, :authority_slug, :interaction

def initialize(licence, authority_slug = nil, interaction = nil)
Expand All @@ -21,6 +23,26 @@ def has_any_actions?
authority && authority["actions"].present?
end

def actions_for_contents_list_component(publication)
items = [
{
text: "1. Overview",
href: !action ? nil : licence_transaction_authority_path(publication.slug, authority_slug, interaction: nil),
active: !action,
},
]

authority["actions"].keys.each_with_index do |action_key, index|
items << {
text: "#{index + 2}. How to #{action_key}",
href: action == action_key ? nil : licence_transaction_authority_interaction_path(publication.slug, authority_slug, action_key),
active: action == action_key,
}
end

items
end

def uses_licensify(chosen_action = action)
return false unless authority

Expand Down
11 changes: 5 additions & 6 deletions app/views/licence_transaction/_authority_base.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,11 @@

<p class="govuk-body">From <strong><%= licence_details.authority['name'] %></strong></p>

<nav role="navigation" class="page-navigation">
<ol class="govuk-list govuk-list--number">
<%= yield :overview %>
<%= yield :interactions_contents_list %>
</ol>
</nav>
<%= render "govuk_publishing_components/components/contents_list",
underline_links: true,
format_numbers: true,
contents: licence_details.actions_for_contents_list_component(publication)
%>

<article
role="article"
Expand Down
10 changes: 0 additions & 10 deletions app/views/licence_transaction/authority.html.erb
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
<% content_for :title, "#{publication.title}: #{licence_details.authority['name']} - GOV.UK" %>

<% content_for :overview do %>
<li class="active">Overview</li>
<% end %>

<% content_for :interactions_contents_list do %>
<% licence_details.authority['actions'].keys.uniq.each do |action| %>
<li><%= link_to "How to #{action}", licence_transaction_authority_interaction_path(publication.slug, licence_details.authority["slug"], action), class: "govuk-link" %></li>
<% end %>
<% end %>

<% content_for :main_content do %>
<%= render "govuk_publishing_components/components/govspeak", {} do %>
<%= raw publication.body %>
Expand Down
15 changes: 1 addition & 14 deletions app/views/licence_transaction/authority_interaction.html.erb
Original file line number Diff line number Diff line change
@@ -1,17 +1,4 @@
<% content_for :overview do %>
<li><%= link_to "Overview", licence_transaction_authority_path(publication.slug, licence_details.authority["slug"]), class: "govuk-link" %></li>
<% end %>

<% content_for :interactions_contents_list do %>
<% licence_details.authority['actions'].keys.uniq.each do |action| %>
<% if licence_details.action == action %>
<li class="active"><%= "How to #{action}" %></li>
<% content_for :title, "#{publication.title}: How to #{action} - GOV.UK" %>
<% else %>
<li><%= link_to "How to #{action}", licence_transaction_authority_interaction_path(publication.slug, licence_details.authority["slug"], action), class: "govuk-link" %></li>
<% end %>
<% end %>
<% end %>
<% content_for :title, "#{publication.title}: How to #{licence_details.action} - GOV.UK" %>

<% content_for :main_content do %>
<% if licence_details.action.present? %>
Expand Down