Module: EffectiveResourcesWizardHelper
- Defined in:
- app/helpers/effective_resources_wizard_helper.rb
Instance Method Summary collapse
- #render_wizard_resource(resource, only: [], except: [], as: nil, path: nil) ⇒ Object
- #render_wizard_resource_step(resource, step, as: nil, path: nil) ⇒ Object
- #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_resource(resource, only: [], except: [], as: nil, path: nil) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'app/helpers/effective_resources_wizard_helper.rb', line 49 def render_wizard_resource(resource, only: [], except: [], as: nil, path: nil) effective_resource = Effective::Resource.new(resource) # Render path as ||= effective_resource.name path ||= effective_resource.wizard_file_path(resource) raise('expected a path') unless path.present? resource.render_path = path.to_s.chomp('/') # Render steps only = Array(only) except = Array(except) steps = resource.render_steps steps = (steps - except) if except.present? steps = (steps & only) if only.present? steps.map do |step| resource.render_step = step render_if_exists("#{path}/#{step}", as.to_sym => resource) || render('effective/acts_as_wizard/wizard_step', resource: resource, resource_path: path) end.join.html_safe end |
#render_wizard_resource_step(resource, step, as: nil, path: nil) ⇒ Object
45 46 47 |
# File 'app/helpers/effective_resources_wizard_helper.rb', line 45 def render_wizard_resource_step(resource, step, as: nil, path: nil) render_wizard_resource(resource, only: step, as: as, path: path) end |
#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, 'data-turbolinks': false) end end |