Method: EffectiveResourcesHelper#wizard_card

Defined in:
app/helpers/effective_resources_helper.rb

#wizard_card(resource, &block) ⇒ Object



267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
# File 'app/helpers/effective_resources_helper.rb', line 267

def wizard_card(resource, &block)
  raise('expected a block') unless block_given?
  raise('expected an acts_as_wizard resource') unless resource.class.respond_to?(:acts_as_wizard?)

  step = resource.render_step
  raise('expected a render_step') unless step.present?

  title = resource.wizard_step_title(step)
  raise("expected a title for step #{step}") unless title.present?

  link = if edit_effective_wizard? && resource.can_visit_step?(step)
    link_to('Edit', wizard_path(step), title: "Edit #{title}")
  end

  (:div, class: 'card') do
    (:div, class: 'card-body') do
      (:div, class: 'row') do
        (:div, class: 'col-sm') do
          (:h5, title, class: 'card-title')
        end +
        (:div, class: 'col-sm-auto text-right') do
          (link || '')
        end
      end + capture(&block)
    end
  end
end