# File lib/govuk_publishing_components/presenters/page_with_step_by_step_navigation.rb, line 97 def primary_step_by_steps? step_navs_combined_list.any? end
class GovukPublishingComponents::Presenters::PageWithStepByStepNavigation
@private Only used by the step by step component
Constants
- MAX_SECTION_LENGTH
Attributes
content_item[R]
current_path[R]
Public Class Methods
new(content_store_response, current_path, query_parameters = {})
click to toggle source
# File lib/govuk_publishing_components/presenters/page_with_step_by_step_navigation.rb, line 8 def initialize(content_store_response, current_path, query_parameters = {}) @content_item = content_store_response.to_h.deep_symbolize_keys @current_path = current_path @query_parameters = query_parameters end
Public Instance Methods
active_step_by_step()
click to toggle source
# File lib/govuk_publishing_components/presenters/page_with_step_by_step_navigation.rb, line 105 def active_step_by_step step_navs_list = step_navs_combined_list @active_step_navs ||= step_navs_list.select { |step_nav| step_nav.content_id == active_step_nav_content_id } @active_step_navs.first end
active_step_by_step?()
click to toggle source
# File lib/govuk_publishing_components/presenters/page_with_step_by_step_navigation.rb, line 101 def active_step_by_step? active_step_nav_content_id.present? && active_step_by_step.present? end
header()
click to toggle source
# File lib/govuk_publishing_components/presenters/page_with_step_by_step_navigation.rb, line 85 def header if show_header? { title: current_step_nav.title, path: current_step_nav.base_path, tracking_id: current_step_nav.content_id, } else {} end end
primary_step_by_steps?()
click to toggle source
secondary_step_by_step()
click to toggle source
# File lib/govuk_publishing_components/presenters/page_with_step_by_step_navigation.rb, line 115 def secondary_step_by_step secondary_step_by_steps.first end
secondary_step_by_step?()
click to toggle source
# File lib/govuk_publishing_components/presenters/page_with_step_by_step_navigation.rb, line 111 def secondary_step_by_step? secondary_step_by_steps.any? end
secondary_step_by_steps()
click to toggle source
# File lib/govuk_publishing_components/presenters/page_with_step_by_step_navigation.rb, line 26 def secondary_step_by_steps @secondary_step_by_steps ||= parsed_secondary_to_step_navs.map do |step_nav| StepByStepModel.new(step_nav) end end
show_header?()
click to toggle source
# File lib/govuk_publishing_components/presenters/page_with_step_by_step_navigation.rb, line 36 def show_header? step_navs.count == 1 || active_step_by_step? || show_secondary_step_by_step? end
show_secondary_step_by_step?()
click to toggle source
# File lib/govuk_publishing_components/presenters/page_with_step_by_step_navigation.rb, line 119 def show_secondary_step_by_step? !primary_step_by_steps? && secondary_step_by_step? && secondary_step_by_steps.count == 1 end
Private Instance Methods
steps()
click to toggle source
# File lib/govuk_publishing_components/presenters/page_with_step_by_step_navigation.rb, line 145 def steps @steps ||= step_nav[:steps] end