Module: IshManager::ApplicationHelper

Defined in:
app/helpers/ish_manager/application_helper.rb

Instance Method Summary collapse

Instance Method Details

#api_map_path(map) ⇒ Object

api paths



8
9
10
# File 'app/helpers/ish_manager/application_helper.rb', line 8

def api_map_path map
  "/api/maps/view/#{map.slug}"
end

#api_marker_path(marker) ⇒ Object



12
13
14
# File 'app/helpers/ish_manager/application_helper.rb', line 12

def api_marker_path marker
  "/api/markers/view/#{marker.id}"
end

#current_layoutObject



17
18
19
20
21
22
23
24
25
26
27
# File 'app/helpers/ish_manager/application_helper.rb', line 17

def current_layout
  layout = controller.class.send(:_layout)
  if layout.nil?
    '<default>'
  elsif layout.instance_of? String or layout.instance_of? Symbol
    layout
  else
    layout.inspect
    # File.basename(layout.identifier).split('.').first
  end
end

#my_truthy?(which) ⇒ Boolean

Returns:

  • (Boolean)


29
30
31
# File 'app/helpers/ish_manager/application_helper.rb', line 29

def my_truthy? which
  ["1", "t", "T", "true"].include?( which )
end

#pp_amount(a) ⇒ Object



63
64
65
66
# File 'app/helpers/ish_manager/application_helper.rb', line 63

def pp_amount a
  return '-' if !a
  "$ #{'%.2f' % a}"
end

#pp_bool(a) ⇒ Object



73
74
75
# File 'app/helpers/ish_manager/application_helper.rb', line 73

def pp_bool a
  a ? 'Y' : '-'
end

#pp_currency(a) ⇒ Object



68
# File 'app/helpers/ish_manager/application_helper.rb', line 68

def pp_currency a; pp_amount a; end

#pp_date(a) ⇒ Object



55
# File 'app/helpers/ish_manager/application_helper.rb', line 55

def pp_date a; pretty_date a; end

#pp_datetime(date) ⇒ Object



56
57
58
# File 'app/helpers/ish_manager/application_helper.rb', line 56

def pp_datetime date
  date&.strftime('%Y-%m-%d %l:%M%P %z')
end

#pp_errors(errors) ⇒ Object

def email_contexts_for_lead_path lead

"/manager/email_contexts/for_lead/#{lead.id.to_s}"

end



37
38
39
# File 'app/helpers/ish_manager/application_helper.rb', line 37

def pp_errors errors
  return errors
end

#pp_money(a) ⇒ Object



67
# File 'app/helpers/ish_manager/application_helper.rb', line 67

def pp_money a; pp_amount a; end

#pp_percent(a) ⇒ Object



69
70
71
# File 'app/helpers/ish_manager/application_helper.rb', line 69

def pp_percent a
  "#{(a*100).round(2)}%"
end

#pp_time(date) ⇒ Object



59
60
61
# File 'app/helpers/ish_manager/application_helper.rb', line 59

def pp_time date
  date&.strftime('%l:%M%P %z')
end

#pretty_date(date) ⇒ Object



51
52
53
54
# File 'app/helpers/ish_manager/application_helper.rb', line 51

def pretty_date date
  # date.to_s[0, 10]
  date&.strftime('%Y-%m-%d')
end

#user_path(user) ⇒ Object



41
42
43
44
45
46
47
48
49
# File 'app/helpers/ish_manager/application_helper.rb', line 41

def user_path user
  if user.class == 'String'
    "/users/#{user}"
  elsif user.class == User
    "/users/#{user.id}"
  elsif user.class == NilClass
    "/users"
  end
end