Module: ActiveScaffold::Helpers::ViewHelpers
- Includes:
- AssociationHelpers, CountryHelpers, FormColumnHelpers, IdHelpers, ListColumnHelpers, NumberHelpers, PaginationHelpers, SearchColumnHelpers, ShowColumnHelpers
- Defined in:
- lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/view_helpers.rb,
lib/six-updater-web/vendor/plugins/activescaffold_advanced_search/lib/helpers/view_helpers.rb
Overview
All extra helpers that should be included in the View. Also a dumping ground for uncategorized helpers.
Constant Summary
Constants included from CountryHelpers
CountryHelpers::COUNTRIES, CountryHelpers::USASTATES
Instance Method Summary collapse
-
#active_scaffold_config ⇒ Object
access to the configuration variable.
- #active_scaffold_config_for(*args) ⇒ Object
- #active_scaffold_controller_for(*args) ⇒ Object
-
#active_scaffold_ie_stylesheets(frontend = :default) ⇒ Object
Provides stylesheets for IE to include with
stylesheet_link_tag
. -
#active_scaffold_includes(*args) ⇒ Object
easy way to include ActiveScaffold assets.
- #active_scaffold_includes_with_advanced_search(frontend = :default) ⇒ Object
-
#active_scaffold_javascripts(frontend = :default) ⇒ Object
Provides list of javascripts to include with
javascript_include_tag
You can use this with your javascripts like <%= javascript_include_tag :defaults, ‘your_own_cool_script’, active_scaffold_javascripts, :cache => true %>. -
#active_scaffold_stylesheets(frontend = :default) ⇒ Object
Provides stylesheets to include with
stylesheet_link_tag
. - #column_calculation(column) ⇒ Object
- #column_class(column, column_value) ⇒ Object
- #column_empty?(column_value) ⇒ Boolean
-
#column_show_add_existing(column) ⇒ Object
AST Begin.
- #column_show_add_new(column, associated, action) ⇒ Object
- #form_remote_upload_tag(url_for_options = {}, options = {}) ⇒ Object
-
#generate_temporary_id ⇒ Object
Uncategorized.
-
#in_subform?(column, parent_record) ⇒ Boolean
Should this column be displayed in the subform?.
-
#link_to_visibility_toggle(options = {}) ⇒ Object
Creates a javascript-based link that toggles the visibility of some element on the page.
-
#loading_indicator_tag(options) ⇒ Object
a general-use loading indicator (the “stuff is happening, please wait” feedback).
-
#option_tags_for(select_options, options = {}) ⇒ Object
Turns [[label, value]] into <option> tags Takes optional parameter of :include_blank.
-
#render_action_link(link, url_options, link_html_options = {}) ⇒ Object
AST link_html_options = {}.
- #skip_action_link(link) ⇒ Object
Methods included from NumberHelpers
#usa_number_to_phone, #usa_number_to_ssn, #usa_number_to_zip
Methods included from SearchColumnHelpers
#active_scaffold_search_boolean, #active_scaffold_search_date, #active_scaffold_search_datetime, #active_scaffold_search_for, #active_scaffold_search_multi_select, #active_scaffold_search_options, #active_scaffold_search_range, #active_scaffold_search_record_select, #active_scaffold_search_select, #active_scaffold_search_time, #active_scaffold_search_usa_state, #override_search, #override_search?, #override_search_field, #override_search_field?, #search_session_column_multi_select_values, #search_session_column_range_values
Methods included from CountryHelpers
#country_options_for_select, #country_select, #usa_state_options_for_select, #usa_state_select
Methods included from FormColumnHelpers
#active_scaffold_add_existing_input, #active_scaffold_add_existing_label, #active_scaffold_input_boolean, #active_scaffold_input_checkbox, #active_scaffold_input_country, #active_scaffold_input_file_column, #active_scaffold_input_for, #active_scaffold_input_hidden, #active_scaffold_input_options, #active_scaffold_input_password, #active_scaffold_input_percentage, #active_scaffold_input_phone_number, #active_scaffold_input_plural_association, #active_scaffold_input_radio, #active_scaffold_input_record_select, #active_scaffold_input_select, #active_scaffold_input_singular_association, #active_scaffold_input_ssn, #active_scaffold_input_text_options, #active_scaffold_input_textarea, #active_scaffold_input_timezone, #active_scaffold_input_true_false_radio, #active_scaffold_input_usa_money, #active_scaffold_input_usa_state, #active_scaffold_input_usa_zip_code, #active_scaffold_input_virtual, #active_scaffold_input_yes_no_radio, #active_scaffold_observe, #column_renders_as, #column_scope, #form_partial_for_column, #is_subform?, #is_subsection?, #javascript_for_update_column, #onsubmit, #override_form_field, #override_form_field?, #override_form_field_partial, #override_form_field_partial?, #override_input, #override_input?, #override_subform_partial, #override_subform_partial?, #remote_image_submit_tag, #subform_partial_for_column
Methods included from ShowColumnHelpers
#active_scaffold_show_text, #override_show_column_ui, #override_show_column_ui?, #show_column_override, #show_column_override?, #show_column_value
Methods included from ListColumnHelpers
#action_link_to_inline_form, #active_scaffold_column_checkbox, #active_scaffold_column_download_link, #active_scaffold_column_download_link_url_options, #active_scaffold_column_download_link_with_filename, #active_scaffold_column_percentage, #active_scaffold_column_phone_number, #active_scaffold_column_ssn, #active_scaffold_column_text, #active_scaffold_column_thumbnail, #active_scaffold_column_usa_money, #active_scaffold_column_usa_zip_code, #active_scaffold_in_place_editor, #active_scaffold_inplace_edit, #cache_association, #clean_column_value, #column_override, #column_override?, #format_association_value, #format_column_value, #format_inplace_edit_column, #format_number_value, #format_value, #get_column_value, #inplace_edit?, #inplace_edit_cloning?, #inplace_edit_control, #inplace_edit_control_css_class, #nested_label, #override_column_ui, #override_column_ui?, #render_list_column
Methods included from PaginationHelpers
#pagination_ajax_link, #pagination_ajax_links
Methods included from AssociationHelpers
#association_options_count, #association_options_find, #options_for_association, #options_for_association_conditions, #options_for_association_count
Methods included from IdHelpers
#action_iframe_id, #action_link_id, #active_scaffold_calculations_id, #active_scaffold_column_header_id, #active_scaffold_content_id, #active_scaffold_id, #active_scaffold_messages_id, #active_scaffold_tbody_id, #active_scaffold_tools_form_columns_to_ignore, #active_scaffold_tools_list_columns, #association_subform_id, #before_header_id, #controller_id, #customize_form_id, #element_cell_id, #element_form_id, #element_messages_id, #element_row_id, #empty_message_id, #field_error_id, #id_from_controller, #loading_indicator_id, #nested_id, #search_form_id, #search_input_id, #sub_form_id, #sub_form_list_id, #table_action_id
Instance Method Details
#active_scaffold_config ⇒ Object
access to the configuration variable
22 23 24 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/view_helpers.rb', line 22 def active_scaffold_config @controller.class.active_scaffold_config end |
#active_scaffold_config_for(*args) ⇒ Object
26 27 28 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/view_helpers.rb', line 26 def active_scaffold_config_for(*args) @controller.class.active_scaffold_config_for(*args) end |
#active_scaffold_controller_for(*args) ⇒ Object
30 31 32 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/view_helpers.rb', line 30 def active_scaffold_controller_for(*args) @controller.class.active_scaffold_controller_for(*args) end |
#active_scaffold_ie_stylesheets(frontend = :default) ⇒ Object
Provides stylesheets for IE to include with stylesheet_link_tag
103 104 105 106 107 108 109 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/view_helpers.rb', line 103 def active_scaffold_ie_stylesheets(frontend = :default) # AST Begin css = [ActiveScaffold::Config::Core.asset_path("stylesheet-ie.css", frontend)] css << ActiveScaffold::Config::Core.asset_path('tools-left-handed-stylesheet-ie.css', frontend) if ActiveScaffold::Config::Core.left_handed css # AST End end |
#active_scaffold_includes(*args) ⇒ Object
easy way to include ActiveScaffold assets
112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/view_helpers.rb', line 112 def active_scaffold_includes(*args) frontend = args.first.is_a?(Symbol) ? args.shift : :default = args.first.is_a?(Hash) ? args.shift : {} js = javascript_include_tag(*active_scaffold_javascripts(frontend).push()) css = stylesheet_link_tag(*active_scaffold_stylesheets(frontend).push()) [:cache] += '_ie' if [:cache].is_a? String [:concat] += '_ie' if [:concat].is_a? String ie_css = stylesheet_link_tag(*active_scaffold_ie_stylesheets(frontend).push()) #js + "\n" + css + "\n<!--[if IE]>" + ie_css + "<![endif]-->\n" "#{js}\n#{css}\n<!--[if IE]>#{ie_css}<![endif]-->\n" end |
#active_scaffold_includes_with_advanced_search(frontend = :default) ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'lib/six-updater-web/vendor/plugins/activescaffold_advanced_search/lib/helpers/view_helpers.rb', line 7 def active_scaffold_includes_with_advanced_search(frontend = :default) css = stylesheet_link_tag(ActiveScaffold::Config::Core.asset_path('advanced_search.css', frontend)) # ie_css = stylesheet_link_tag(ActiveScaffold::Config::Core.asset_path("export-stylesheet-ie.css", frontend)) ie_css = "" js = javascript_include_tag(ActiveScaffold::Config::Core.asset_path('advanced_search.js', frontend)) #active_scaffold_includes_without_advanced_search + "\n" + css + "\n<!--[if IE]>" + ie_css + "<![endif]-->\n" + js "#{active_scaffold_includes_without_advanced_search}\n#{css}\n<!--[if IE]>#{ie_css}<![endif]-->\n#{js}" end |
#active_scaffold_javascripts(frontend = :default) ⇒ Object
Provides list of javascripts to include with javascript_include_tag
You can use this with your javascripts like
<%= javascript_include_tag :defaults, 'your_own_cool_script', active_scaffold_javascripts, :cache => true %>
87 88 89 90 91 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/view_helpers.rb', line 87 def active_scaffold_javascripts(frontend = :default) ActiveScaffold::Config::Core.javascripts(frontend).collect do |name| ActiveScaffold::Config::Core.asset_path(name, frontend) end end |
#active_scaffold_stylesheets(frontend = :default) ⇒ Object
Provides stylesheets to include with stylesheet_link_tag
94 95 96 97 98 99 100 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/view_helpers.rb', line 94 def active_scaffold_stylesheets(frontend = :default) # AST Begin css = [ActiveScaffold::Config::Core.asset_path("stylesheet.css", frontend)] css << ActiveScaffold::Config::Core.asset_path('tools-left-handed-stylesheet.css', frontend) if ActiveScaffold::Config::Core.left_handed css # AST End end |
#column_calculation(column) ⇒ Object
210 211 212 213 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/view_helpers.rb', line 210 def column_calculation(column) calculation = active_scaffold_config.model.calculate(column.calculate, column.name, :conditions => controller.send(:all_conditions), :joins => controller.send(:joins_for_collection), :include => controller.send(:active_scaffold_joins)) end |
#column_class(column, column_value) ⇒ Object
192 193 194 195 196 197 198 199 200 201 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/view_helpers.rb', line 192 def column_class(column, column_value) classes = [] classes << "#{column.name}-column" classes << column.css_class unless column.css_class.nil? classes << 'empty' if column_empty? column_value classes << 'sorted' if active_scaffold_config.list.user.sorting.sorts_on?(column) # AST - allow format of column to be specified via Column#list_ui classes << 'numeric' if [:number].include?(column.list_ui) or (column.column and [:decimal, :float, :integer].include?(column.column.type)) classes.join(' ') end |
#column_empty?(column_value) ⇒ Boolean
203 204 205 206 207 208 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/view_helpers.rb', line 203 def column_empty?(column_value) empty = column_value.nil? empty ||= column_value.empty? if column_value.respond_to? :empty? empty ||= [' ', active_scaffold_config.list.empty_field_text].include? column_value if String === column_value return empty end |
#column_show_add_existing(column) ⇒ Object
AST Begin
216 217 218 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/view_helpers.rb', line 216 def column_show_add_existing(column) (column.allow_add_existing and !column.through_association? and (column.association) > 0) end |
#column_show_add_new(column, associated, action) ⇒ Object
220 221 222 223 224 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/view_helpers.rb', line 220 def column_show_add_new(column, associated, action) value = !column.through_association? and (column.plural_association? or (column.singular_association? and not associated.empty?)) value = false unless @record.class.(:action => action) value end |
#form_remote_upload_tag(url_for_options = {}, options = {}) ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/view_helpers.rb', line 69 def form_remote_upload_tag( = {}, = {}) onsubmits = [:onsubmit] ? [ [:onsubmit] ] : [ ] # simulate a "loading". the setTimeout prevents the Form.disable from being called before the submit, so that data actually posts. onsubmits << "setTimeout(function() { #{[:loading]} }, 10); " onsubmits << "return true" # make sure the form still submits [:onsubmit] = onsubmits * ';' [:target] = action_iframe_id() [:multipart] = true output="" output << "<iframe id='#{action_iframe_id()}' name='#{action_iframe_id()}' style='display:none'></iframe>" output << form_tag(, ) end |
#generate_temporary_id ⇒ Object
Uncategorized
38 39 40 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/view_helpers.rb', line 38 def generate_temporary_id (Time.now.to_f*1000).to_i.to_s end |
#in_subform?(column, parent_record) ⇒ Boolean
Should this column be displayed in the subform?
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/view_helpers.rb', line 53 def in_subform?(column, parent_record) return true unless column.association # Polymorphic associations can't appear because they *might* be the reverse association, and because you generally don't assign an association from the polymorphic side ... I think. return false if column.polymorphic_association? # We don't have the UI to currently handle habtm in subforms return false if column.association.macro == :has_and_belongs_to_many # A column shouldn't be in the subform if it's the reverse association to the parent return false if column.association.reverse_for?(parent_record.class) #return false if column.association.klass == parent_record.class return true end |
#link_to_visibility_toggle(options = {}) ⇒ Object
Creates a javascript-based link that toggles the visibility of some element on the page. By default, it toggles the visibility of the sibling after the one it’s nested in. You may pass custom javascript logic in options to change that, though. For example, you could say :of => ‘$(“my_div_id”)’. You may also flag whether the other element is visible by default or not, and the initial text will adjust accordingly.
134 135 136 137 138 139 140 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/view_helpers.rb', line 134 def link_to_visibility_toggle( = {}) [:of] ||= '$(this.parentNode).next()' [:default_visible] = true if [:default_visible].nil? link_text = [:default_visible] ? as_(:hide) : as_(:show) link_to_function link_text, "e = #{[:of]}; e.toggle(); this.innerHTML = (e.style.display == 'none') ? '#{as_(:show)}' : '#{as_(:hide)}'", :class => 'visibility-toggle' end |
#loading_indicator_tag(options) ⇒ Object
a general-use loading indicator (the “stuff is happening, please wait” feedback)
127 128 129 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/view_helpers.rb', line 127 def loading_indicator_tag() image_tag "/images/active_scaffold/default/indicator.gif", :style => "visibility:hidden;", :id => loading_indicator_id(), :alt => "loading indicator", :class => "loading-indicator" end |
#option_tags_for(select_options, options = {}) ⇒ Object
Turns [[label, value]] into <option> tags Takes optional parameter of :include_blank
44 45 46 47 48 49 50 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/view_helpers.rb', line 44 def (, = {}) .insert(0,[as_(:_select_),nil]) if [:include_blank] .collect do |option| label, value = option[0], option[1] value.nil? ? "<option value="">#{label}</option>" : "<option value=\"#{value}\">#{label}</option>" end end |
#render_action_link(link, url_options, link_html_options = {}) ⇒ Object
AST link_html_options = {}
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/view_helpers.rb', line 147 def render_action_link(link, , = {}) = .clone [:action] = link.action [:controller] = link.controller if link.controller .delete(:search) if link.controller and link.controller.to_s != params[:controller] .merge! link.parameters if link.parameters # AST link_html_options = link..merge({:class => link.action}).merge() if link.inline? # NOTE this is in url_options instead of html_options on purpose. the reason is that the client-side # action link javascript needs to submit the proper method, but the normal html_options[:method] # argument leaves no way to extract the proper method from the rendered tag. [:_method] = link.method if link.method != :get and respond_to?(:protect_against_forgery?) and protect_against_forgery? [:authenticity_token] = form_authenticity_token end # robd: protect against submitting get links as forms, since this causes annoying # 'Do you wish to resubmit your form?' messages whenever you go back and forwards. elsif link.method != :get # Needs to be in html_options to as the adding _method to the url is no longer supported by Rails [:method] = link.method end [:confirm] = as_(link.confirm) if link.confirm? [:position] = link.position if link.position and link.inline? [:class] += ' action' if link.inline? [:popup] = true if link.popup? [:id] = action_link_id("#{id_from_controller([:controller]) + '-' if [:parent_controller]}" + "#{[:associations].to_s + '-' if [:associations]}" + [:action],[:id] || [:parent_id]) if link.dhtml_confirm? [:class] += ' action' if !link.inline? [:page_link] = 'true' if !link.inline? [:dhtml_confirm] = link.dhtml_confirm.value [:onclick] = link.dhtml_confirm.onclick_function(controller,action_link_id([:action],[:id] || [:parent_id])) end [:class] += " #{link.[:class]}" unless link.[:class].blank? # issue 260, use url_options[:link] if it exists. This prevents DB data from being localized. label = .delete(:link) || link.label link_to label, , end |
#skip_action_link(link) ⇒ Object
142 143 144 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/view_helpers.rb', line 142 def skip_action_link(link) (link.security_method_set? or controller.respond_to? link.security_method) and !controller.send(link.security_method) end |