Sha256: 2166b49aff4e9e42e9788e8f7fde5de6020b1628a8a503cc12cda54460c16b02
Contents?: true
Size: 1.33 KB
Versions: 7
Compression:
Stored size: 1.33 KB
Contents
module Storefront module WorkflowHelper def current_workflow params[:flow] end def flow?(*args) args.present? ? args.any? { |flow| current_workflow == flow.to_s } : current_workflow.present? end def workflow_steps(current, *labels) steps = labels.flatten.map do |label| if label.is_a?(Hash) label.symbolize_keys else {:title => label, :description => ""} end end steps.each_with_index do |step, index| step[:active] = index == (current - 1) end steps end def workflow_step(label, current, desired) image_name = "step_#{desired}" image_name << "_active" if current == desired image_name << ".png" td_class = current == desired ? "step_active" : "step" result = capture_haml do haml_tag :td, :class => :number do haml_tag :img, :class => :step_number, :src => "/images/#{image_name}" end haml_tag :td, :class => td_class do haml_concat label end end result end def next_step_tag(resource = self.resource) result = capture_haml do haml_concat hidden_field_tag(:event, current_step) if resource && resource.id haml_concat hidden_field_tag(:id, resource.id) end end end end end
Version data entries
7 entries across 7 versions & 1 rubygems