Module: EffectiveResourcesWizardHelper
- Defined in:
- app/helpers/effective_resources_wizard_helper.rb
Instance Method Summary collapse
- #render_wizard_sidebar(resource, numbers: true, path: nil, horizontal: false, &block) ⇒ Object
- #render_wizard_sidebar_item(resource, nav_step:, path: nil, index: nil) ⇒ Object
Instance Method Details
#render_wizard_sidebar(resource, numbers: true, path: nil, horizontal: false, &block) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'app/helpers/effective_resources_wizard_helper.rb', line 5 def (resource, numbers: true, path: nil, horizontal: false, &block) if path.present? raise('expected path to be a string with /build/ in it ') unless path.to_s.include?('/build/') path = path.split('/build/').first + '/build/' end klasses = ['wizard-sidebar', 'list-group', ('list-group-horizontal' if horizontal)].compact.join(' ') = content_tag(:div, class: klasses) do resource..map.with_index do |nav_step, index| (resource, nav_step: nav_step, index: (index + 1 if numbers), path: (path + nav_step.to_s if path)) end.join.html_safe end return unless block_given? content_tag(:div, class: 'row') do content_tag(:div, class: 'col-lg-3') { } + content_tag(:div, class: 'col-lg-9') { yield } end end |
#render_wizard_sidebar_item(resource, nav_step:, path: nil, index: nil) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'app/helpers/effective_resources_wizard_helper.rb', line 27 def (resource, nav_step:, path: nil, 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', 'list-group-item-action', ('active' if current), ('disabled' if disabled && !current)].compact.join(' ') if (current || disabled) content_tag(:a, label, class: klass) else link_to(label, path || wizard_path(nav_step), class: klass) end end |