Sha256: 3a23566fbac931f90b74d0fa3b7fd22248e58446b8c6dffb61a9d78917316ac1
Contents?: true
Size: 1.12 KB
Versions: 16
Compression:
Stored size: 1.12 KB
Contents
# frozen_string_literal: true module EffectiveResourcesWizardHelper def render_wizard_sidebar(resource, numbers: true, &block) sidebar = content_tag(:div, class: 'nav list-group wizard-sidebar') 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
16 entries across 16 versions & 1 rubygems