Module: Bolt::BoltHelper
- Included in:
- BoltController
- Defined in:
- app/helpers/bolt/bolt_helper.rb
Instance Method Summary collapse
- #bolt_check_box(form, obj, attribute, options = {}) ⇒ Object
- #bolt_check_box_group(form, obj, check_boxes = {}) ⇒ Object
- #bolt_collection_select(form, obj, object, attribute, collection, value_method, text_method, options = {}) ⇒ Object
- #bolt_date_select(form, obj, attribute, options = {}) ⇒ Object
- #bolt_datetime_select(form, obj, attribute, options = {}) ⇒ Object
- #bolt_file_field(form, obj, object_name, attribute, options = {}) ⇒ Object
- #bolt_generate_page_title ⇒ Object
- #bolt_get_access_level_array ⇒ Object
- #bolt_get_access_level_text(level) ⇒ Object
- #bolt_get_full_version_string ⇒ Object
- #bolt_get_short_version_string ⇒ Object
- #bolt_get_version_info ⇒ Object
- #bolt_hidden_field(form, obj, attribute, options = {}) ⇒ Object
- #bolt_password_field(form, obj, attribute, options = {}) ⇒ Object
- #bolt_radio_button(form, obj, attribute, tag_value, options = {}) ⇒ Object
- #bolt_radio_button_group(form, obj, radio_buttons = {}) ⇒ Object
- #bolt_select(form, obj, attribute, option_tags, options = {}) ⇒ Object
- #bolt_show_icon(icon_name) ⇒ Object
- #bolt_show_row_icon(icon_name) ⇒ Object
- #bolt_table_cell_link(contents, link, options = {}) ⇒ Object
- #bolt_table_cell_no_link(contents, options = {}) ⇒ Object
- #bolt_text_area(form, obj, attribute, options = {}) ⇒ Object
- #bolt_text_area_big(form, obj, attribute, options = {}) ⇒ Object
-
#bolt_text_field(form, obj, attribute, options = {}) ⇒ Object
Styled form tag helpers.
- #bolt_time_select(form, obj, attribute, options = {}) ⇒ Object
- #bolt_time_zone_select(form, obj, attribute, option_tags, options = {}) ⇒ Object
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, = {} form_tag = form.check_box(attribute, ()) if .key? :bolt_box_label form_tag = "<div>" + form_tag + "<span class=\"rcText\">#{[:bolt_box_label]}</span></div>".html_safe end bolt_form_tag_wrapper(form_tag, form, obj, attribute, ).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 = {} = "" for check_box in check_boxes += bolt_check_box form, obj, check_box[0], check_box[1] end bolt_form_tag_wrapper form_tag, form, obj, attribute, 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, = {} bolt_form_tag_wrapper(collection_select(object, attribute, collection, value_method, text_method, (), merged_class_hash(, 'boltSelect')), form, obj, attribute, ).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, = {} bolt_form_tag_wrapper(form.date_select(attribute, (), merged_class_hash(, 'boltDateTimeSelect')), form, obj, attribute, ).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, = {} bolt_form_tag_wrapper(form.datetime_select(attribute, (), merged_class_hash(, 'boltDateTimeSelect')), form, obj, attribute, ).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, = {} class_hash = merged_class_hash(, 'boltFileFieldContainer') contents = "<div class='#{class_hash[:class]}'>" + file_field(object_name, attribute, ()) + '</div>' bolt_form_tag_wrapper(contents, form, obj, attribute, ).html_safe end |
#bolt_generate_page_title ⇒ Object
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_array ⇒ Object
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_string ⇒ Object
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_string ⇒ Object
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_info ⇒ Object
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, = {} form.hidden_field(attribute, ()).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, = {} bolt_form_tag_wrapper(form.password_field(attribute, ((, 'boltTextField'))), form, obj, attribute, ).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 form, obj, attribute, tag_value, = {} form_tag = form.(obj, attribute, tag_value, ()) if .key? :bolt_button_label form_tag = "<div>" + form_tag + "<span class=\"rcText\">#{[:bolt_button_label]}</span></div>".html_safe end bolt_form_tag_wrapper(form_tag, form, obj, attribute, ).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 form, obj, = {} = "" for in += form, obj, check_box[0], check_box[1], check_box[2] end bolt_form_tag_wrapper(form_tag, form, obj, attribute, ).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, , = {} bolt_form_tag_wrapper(form.select(attribute, , (), merged_class_hash(, 'boltSelect')), form, obj, attribute, ).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 |
#bolt_table_cell_link(contents, link, options = {}) ⇒ Object
50 51 52 53 54 55 56 57 |
# File 'app/helpers/bolt/bolt_helper.rb', line 50 def bolt_table_cell_link contents, link, = {} if .key? :bolt_truncate contents = truncate(contents, :length => [:bolt_truncate], :omission => "...") end link_to "#{contents}".html_safe, link, end |
#bolt_table_cell_no_link(contents, options = {}) ⇒ Object
59 60 61 62 63 64 65 66 |
# File 'app/helpers/bolt/bolt_helper.rb', line 59 def bolt_table_cell_no_link contents, = {} if .key? :bolt_truncate contents = truncate(contents, :length => [: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, = {} bolt_form_tag_wrapper(form.text_area(attribute, ((, 'boltTextArea'))), form, obj, attribute, ).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, = {} bolt_form_tag_wrapper(form.text_area(attribute, ((, 'boltTextAreaBig'))), form, obj, attribute, ).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, = {} bolt_form_tag_wrapper(form.text_field(attribute, ((, 'boltTextField'))), form, obj, attribute, ).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, = {} bolt_form_tag_wrapper(form.time_select(attribute, (), merged_class_hash(, 'boltDateTimeSelect')), form, obj, attribute, ).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, , = {} bolt_form_tag_wrapper(form.time_zone_select(attribute, , (), merged_class_hash(, 'boltSelect')), form, obj, attribute, ).html_safe end |