cirandas.net

ref: master

plugins/community_track/lib/community_track_plugin/step_helper.rb


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
module CommunityTrackPlugin::StepHelper

  def self.status_descriptions
    [_('Closed'), _('Join!'), _('Soon')]
  end

  def self.status_classes
    ['step_finished', 'step_active', 'step_waiting']
  end

  def status_description(step)
    CommunityTrackPlugin::StepHelper.status_descriptions[status_index(step)]
  end

  def status_class(step)
    CommunityTrackPlugin::StepHelper.status_classes[status_index(step)]
  end

  def link_to_step(step, options={}, name=nil)
    url = step.tool ? step.tool.view_url : step.view_url
    link_to url, options do
      block_given? ? yield : name
    end
  end

  protected

  def status_index(step)
    [step.finished?, step.active?, step.waiting?].find_index(true)
  end

end