Sha256: 2cfa57fca56161bc9d0330701e08342f189425365f678ab0e5eb4c576f198b08

Contents?: true

Size: 1.22 KB

Versions: 26

Compression:

Stored size: 1.22 KB

Contents

# frozen_string_literal: true

module EffectiveResourcesWizardHelper

  def render_wizard_sidebar(resource, numbers: true, horizontal: false, &block)
    klasses = ['wizard-sidebar', 'list-group', ('list-group-horizontal' if horizontal)].compact.join(' ')

    sidebar = content_tag(:div, class: klasses) do
      resource.required_steps.map.with_index do |nav_step, index|
        render_wizard_sidebar_item(resource, nav_step, (index + 1 if numbers))
      end.join.html_safe
    end

    return sidebar unless block_given?

    content_tag(:div, class: 'row') do
      content_tag(:div, class: 'col-3') { sidebar } +
      content_tag(:div, class: 'col-9') { yield }
    end
  end

  def render_wizard_sidebar_item(resource, nav_step, index = nil)
    # From Controller
    current = (nav_step == step)
    title = resource_wizard_step_title(resource, nav_step)

    # From Model
    disabled = !resource.can_visit_step?(nav_step)

    label = [index, title].compact.join('. ')
    klass = ['list-group-item', ('active' if current), ('disabled' if disabled && !current)].compact.join(' ')

    if (current || disabled)
      content_tag(:li, label, class: klass)
    else
      link_to(label, wizard_path(nav_step), class: klass)
    end
  end

end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
effective_resources-1.9.18 app/helpers/effective_resources_wizard_helper.rb
effective_resources-1.9.17 app/helpers/effective_resources_wizard_helper.rb
effective_resources-1.9.16 app/helpers/effective_resources_wizard_helper.rb
effective_resources-1.9.15 app/helpers/effective_resources_wizard_helper.rb
effective_resources-1.9.14 app/helpers/effective_resources_wizard_helper.rb
effective_resources-1.9.13 app/helpers/effective_resources_wizard_helper.rb
effective_resources-1.9.12 app/helpers/effective_resources_wizard_helper.rb
effective_resources-1.9.11 app/helpers/effective_resources_wizard_helper.rb
effective_resources-1.9.10 app/helpers/effective_resources_wizard_helper.rb
effective_resources-1.9.9 app/helpers/effective_resources_wizard_helper.rb
effective_resources-1.9.8 app/helpers/effective_resources_wizard_helper.rb
effective_resources-1.9.7 app/helpers/effective_resources_wizard_helper.rb
effective_resources-1.9.6 app/helpers/effective_resources_wizard_helper.rb
effective_resources-1.9.5 app/helpers/effective_resources_wizard_helper.rb
effective_resources-1.9.4 app/helpers/effective_resources_wizard_helper.rb
effective_resources-1.9.3 app/helpers/effective_resources_wizard_helper.rb
effective_resources-1.9.2 app/helpers/effective_resources_wizard_helper.rb
effective_resources-1.9.1 app/helpers/effective_resources_wizard_helper.rb
effective_resources-1.9.0 app/helpers/effective_resources_wizard_helper.rb
effective_resources-1.8.38 app/helpers/effective_resources_wizard_helper.rb