Module: EventsHelper

Included in:
EventsController
Defined in:
app/helpers/events_helper.rb

Instance Method Summary collapse

Instance Method Details

#event_abbrev_date(event) ⇒ Object



12
13
14
15
16
17
18
# File 'app/helpers/events_helper.rb', line 12

def event_abbrev_date(event)
  if event.one_day?
    "(<em>#{event.start_on.strftime("%a")} #{event.start_day.ordinalize}</em>)".html_safe
  else
    "(<em>#{event.start_on.strftime("%a")} #{event.start_day.ordinalize} - #{event.end_on.strftime("%a")} #{event.end_day.ordinalize}</em>)".html_safe
  end
end


20
21
22
23
# File 'app/helpers/events_helper.rb', line 20

def event_details_link(event)
  path = event.deleted? ? 'event_revision_path' : 'event_path'
  "<span class=\"fake_button\">#{link_to('Details', send(path, event))}</span>".html_safe
end

#event_one_liner(event) ⇒ Object



2
3
4
5
6
7
8
9
10
# File 'app/helpers/events_helper.rb', line 2

def event_one_liner(event)
  [
    h(event.name),
    event_abbrev_date(event),
    event_type_label(event.event_type),
    event_details_link(event)
  ].
  join(" ").html_safe
end

#event_type_css_class(event_type) ⇒ Object



29
30
31
32
# File 'app/helpers/events_helper.rb', line 29

def event_type_css_class(event_type)
  css_class = event_type.parameterize('_').downcase
  h("#{css_class}_event")
end

#event_type_label(event_type) ⇒ Object



25
26
27
# File 'app/helpers/events_helper.rb', line 25

def event_type_label(event_type)
  "<span class=\"category_label #{event_type_css_class(event_type)}\">#{h(event_type)}</span>".html_safe
end

#event_type_legend(wrapper_css_class, wrapper_css_style = '') ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
# File 'app/helpers/events_helper.rb', line 34

def event_type_legend(wrapper_css_class, wrapper_css_style='')
  return '' unless @event_types.any?
  
   :ul, :class => "#{wrapper_css_class} legend", :style => wrapper_css_style do
    @event_types.map do |event_type|
      css_class = event_type_css_class(event_type)
       :li, :class => "#{css_class} category_label" do
        link_to h(event_type), events_path(:event_type => event_type)
      end
    end.join("\n").html_safe
  end
end