Module: Bolt::BoltHelper

Included in:
BoltController
Defined in:
app/helpers/bolt/bolt_helper.rb

Instance Method Summary collapse

Instance Method Details

#bolt_check_box(form, obj, attribute, options = {}) ⇒ Object



94
95
96
97
98
99
100
101
102
# File 'app/helpers/bolt/bolt_helper.rb', line 94

def bolt_check_box form, obj, attribute, options = {}
  form_tag = form.check_box(attribute, strip_bolt_options(options))
  
  if options.key? :bolt_box_label
    form_tag = "<div>" + form_tag + "<span class=\"rcText\">#{options[:bolt_box_label]}</span></div>".html_safe
  end
  
  bolt_form_tag_wrapper(form_tag, form, obj, attribute, options).html_safe
end

#bolt_check_box_group(form, obj, check_boxes = {}) ⇒ Object



104
105
106
107
108
109
110
111
112
# File 'app/helpers/bolt/bolt_helper.rb', line 104

def bolt_check_box_group form, obj, check_boxes = {}
  form_tags = ""
  
  for check_box in check_boxes
    form_tags += bolt_check_box form, obj, check_box[0], check_box[1]
  end
  
  bolt_form_tag_wrapper form_tag, form, obj, attribute, options
end

#bolt_collection_select(form, obj, object, attribute, collection, value_method, text_method, options = {}) ⇒ Object



142
143
144
# File 'app/helpers/bolt/bolt_helper.rb', line 142

def bolt_collection_select form, obj, object, attribute, collection, value_method, text_method, options = {}
  bolt_form_tag_wrapper(collection_select(object, attribute, collection, value_method, text_method, strip_bolt_options(options), merged_class_hash(options, 'boltSelect')), form, obj, attribute, options).html_safe
end

#bolt_date_select(form, obj, attribute, options = {}) ⇒ Object



146
147
148
# File 'app/helpers/bolt/bolt_helper.rb', line 146

def bolt_date_select form, obj, attribute, options = {}
  bolt_form_tag_wrapper(form.date_select(attribute, strip_bolt_options(options), merged_class_hash(options, 'boltDateTimeSelect')), form, obj, attribute, options).html_safe
end

#bolt_datetime_select(form, obj, attribute, options = {}) ⇒ Object



154
155
156
# File 'app/helpers/bolt/bolt_helper.rb', line 154

def bolt_datetime_select form, obj, attribute, options = {}
  bolt_form_tag_wrapper(form.datetime_select(attribute, strip_bolt_options(options), merged_class_hash(options, 'boltDateTimeSelect')), form, obj, attribute, options).html_safe
end

#bolt_file_field(form, obj, object_name, attribute, options = {}) ⇒ Object



158
159
160
161
162
# File 'app/helpers/bolt/bolt_helper.rb', line 158

def bolt_file_field form, obj, object_name, attribute, options = {}
  class_hash = merged_class_hash(options, 'boltFileFieldContainer')
  contents = "<div class='#{class_hash[:class]}'>" + file_field(object_name, attribute, strip_bolt_options(options)) + '</div>'
  bolt_form_tag_wrapper(contents, form, obj, attribute, options).html_safe
end

#bolt_generate_page_titleObject



18
19
20
21
22
23
24
25
# File 'app/helpers/bolt/bolt_helper.rb', line 18

def bolt_generate_page_title
  
  if @bolt_page_title.nil?
    return bolt_config_website_name
  end
  
  @bolt_page_title + " > " + bolt_config_website_name
end

#bolt_get_access_level_arrayObject



46
47
48
# File 'app/helpers/bolt/bolt_helper.rb', line 46

def bolt_get_access_level_array
  [["Administrator", $BOLT_USER_ACCESS_LEVEL_ADMIN], ["User", $BOLT_USER_ACCESS_LEVEL_USER], ["API user", $BOLT_USER_ACCESS_LEVEL_TO_API], ["CMS user", $BOLT_USER_ACCESS_LEVEL_TO_CMS], ["CMS and API User",$BOLT_USER_ACCESS_LEVEL_TO_API_AND_CMS], ["Ignore User", $BOLT_ACCESS_NONE]]
end

#bolt_get_access_level_text(level) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'app/helpers/bolt/bolt_helper.rb', line 27

def bolt_get_access_level_text level
  case level
  when $BOLT_USER_ACCESS_LEVEL_ADMIN
    return "Administrator"
  when $BOLT_USER_ACCESS_LEVEL_USER
    return "User"
  when $BOLT_USER_ACCESS_LEVEL_TO_API 
    return "API User"
  when $BOLT_USER_ACCESS_LEVEL_TO_CMS
    return "CMS USER"
  when $BOLT_USER_ACCESS_LEVEL_TO_API_AND_CMS
    return "CMS and API user"
  when $BOLT_ACCESS_NONE
    return "Ignored"
  else
    return "Unknown"
  end
end

#bolt_get_full_version_stringObject



8
9
10
11
# File 'app/helpers/bolt/bolt_helper.rb', line 8

def bolt_get_full_version_string
  version_info = bolt_get_version_info
  "v.#{version_info['major']}.#{version_info['minor']}.#{version_info['patch']}"
end

#bolt_get_short_version_stringObject



13
14
15
16
# File 'app/helpers/bolt/bolt_helper.rb', line 13

def bolt_get_short_version_string
  version_info = bolt_get_version_info
  "v.#{version_info['major']}"
end

#bolt_get_version_infoObject



4
5
6
# File 'app/helpers/bolt/bolt_helper.rb', line 4

def bolt_get_version_info  
  YAML::load_file File.join(File.dirname(__FILE__), '..', '..', '..', 'PUBLIC_VERSION.yml')
end

#bolt_hidden_field(form, obj, attribute, options = {}) ⇒ Object



164
165
166
# File 'app/helpers/bolt/bolt_helper.rb', line 164

def bolt_hidden_field form, obj, attribute, options = {}
  form.hidden_field(attribute, strip_bolt_options(options)).html_safe
end

#bolt_password_field(form, obj, attribute, options = {}) ⇒ Object



82
83
84
# File 'app/helpers/bolt/bolt_helper.rb', line 82

def bolt_password_field form, obj, attribute, options = {}
  bolt_form_tag_wrapper(form.password_field(attribute, strip_bolt_options(options_hash_with_merged_classes(options, 'boltTextField'))), form, obj, attribute, options).html_safe
end

#bolt_radio_button(form, obj, attribute, tag_value, options = {}) ⇒ Object



114
115
116
117
118
119
120
121
122
# File 'app/helpers/bolt/bolt_helper.rb', line 114

def bolt_radio_button form, obj, attribute, tag_value, options = {}
  form_tag = form.radio_button(obj, attribute, tag_value, strip_bolt_options(options))
  
  if options.key? :bolt_button_label
    form_tag = "<div>" + form_tag + "<span class=\"rcText\">#{options[:bolt_button_label]}</span></div>".html_safe
  end
  
  bolt_form_tag_wrapper(form_tag, form, obj, attribute, options).html_safe
end

#bolt_radio_button_group(form, obj, radio_buttons = {}) ⇒ Object



124
125
126
127
128
129
130
131
132
# File 'app/helpers/bolt/bolt_helper.rb', line 124

def bolt_radio_button_group form, obj, radio_buttons = {}
  form_tags = ""
  
  for radio_button in radio_buttons
    form_tags += bolt_radio_button form, obj, check_box[0], check_box[1], check_box[2]
  end
  
  bolt_form_tag_wrapper(form_tag, form, obj, attribute, options).html_safe
end

#bolt_select(form, obj, attribute, option_tags, options = {}) ⇒ Object



134
135
136
# File 'app/helpers/bolt/bolt_helper.rb', line 134

def bolt_select form, obj, attribute, option_tags, options = {}
  bolt_form_tag_wrapper(form.select(attribute, option_tags, strip_bolt_options(options), merged_class_hash(options, 'boltSelect')), form, obj, attribute, options).html_safe
end

#bolt_show_icon(icon_name) ⇒ Object



68
69
70
# File 'app/helpers/bolt/bolt_helper.rb', line 68

def bolt_show_icon icon_name
  "<div class='icon'><img src='/bolt/images/icons/#{icon_name}.png' alt='' /></div>".html_safe
end

#bolt_show_row_icon(icon_name) ⇒ Object



72
73
74
# File 'app/helpers/bolt/bolt_helper.rb', line 72

def bolt_show_row_icon icon_name
  "<div class='iconRow'><img src='/bolt/images/icons/#{icon_name}.png' alt='' /></div>".html_safe
end


50
51
52
53
54
55
56
57
# File 'app/helpers/bolt/bolt_helper.rb', line 50

def bolt_table_cell_link contents, link, options = {}
  
  if options.key? :bolt_truncate
    contents = truncate(contents, :length => options[:bolt_truncate], :omission => "...")
  end
  
  link_to "#{contents}".html_safe, link, options
end


59
60
61
62
63
64
65
66
# File 'app/helpers/bolt/bolt_helper.rb', line 59

def bolt_table_cell_no_link contents, options = {}
  
  if options.key? :bolt_truncate
    contents = truncate(contents, :length => options[:bolt_truncate], :omission => "...")
  end
  
  "<div class='noLink'>#{contents}</div>".html_safe
end

#bolt_text_area(form, obj, attribute, options = {}) ⇒ Object



86
87
88
# File 'app/helpers/bolt/bolt_helper.rb', line 86

def bolt_text_area form, obj, attribute, options = {}
  bolt_form_tag_wrapper(form.text_area(attribute, strip_bolt_options(options_hash_with_merged_classes(options, 'boltTextArea'))), form, obj, attribute, options).html_safe
end

#bolt_text_area_big(form, obj, attribute, options = {}) ⇒ Object



90
91
92
# File 'app/helpers/bolt/bolt_helper.rb', line 90

def bolt_text_area_big form, obj, attribute, options = {}
  bolt_form_tag_wrapper(form.text_area(attribute, strip_bolt_options(options_hash_with_merged_classes(options, 'boltTextAreaBig'))), form, obj, attribute, options).html_safe
end

#bolt_text_field(form, obj, attribute, options = {}) ⇒ Object

Styled form tag helpers



78
79
80
# File 'app/helpers/bolt/bolt_helper.rb', line 78

def bolt_text_field form, obj, attribute, options = {}
  bolt_form_tag_wrapper(form.text_field(attribute, strip_bolt_options(options_hash_with_merged_classes(options, 'boltTextField'))), form, obj, attribute, options).html_safe
end

#bolt_time_select(form, obj, attribute, options = {}) ⇒ Object



150
151
152
# File 'app/helpers/bolt/bolt_helper.rb', line 150

def bolt_time_select form, obj, attribute, options = {}
  bolt_form_tag_wrapper(form.time_select(attribute, strip_bolt_options(options), merged_class_hash(options, 'boltDateTimeSelect')), form, obj, attribute, options).html_safe
end

#bolt_time_zone_select(form, obj, attribute, option_tags, options = {}) ⇒ Object



138
139
140
# File 'app/helpers/bolt/bolt_helper.rb', line 138

def bolt_time_zone_select form, obj, attribute, option_tags, options = {}
  bolt_form_tag_wrapper(form.time_zone_select(attribute, option_tags, strip_bolt_options(options), merged_class_hash(options, 'boltSelect')), form, obj, attribute, options).html_safe
end