module ActiveScaffold::Helpers::IdHelpers
A bunch of helper methods to produce the common view ids
Public Instance Methods
Source
# File lib/active_scaffold/helpers/id_helpers.rb, line 125 def action_iframe_id(options) "#{controller_id}-#{options[:action]}-#{options[:id]}-iframe" end
Source
# File lib/active_scaffold/helpers/id_helpers.rb, line 57 def action_link_id(link_action, link_id) "#{controller_id}-#{link_action}-#{link_id}-link" end
Source
# File lib/active_scaffold/helpers/id_helpers.rb, line 41 def active_scaffold_calculations_id(options = {}) "#{options[:controller_id] || controller_id}-calculations#{"-#{options[:column].name}" if options[:column]}" end
Source
# File lib/active_scaffold/helpers/id_helpers.rb, line 61 def active_scaffold_column_header_id(column) name = column.respond_to?(:name) ? column.name : column.to_s clean_id "#{controller_id}-#{name}-column" end
Source
# File lib/active_scaffold/helpers/id_helpers.rb, line 29 def active_scaffold_content_id "#{controller_id}-content" end
Source
# File lib/active_scaffold/helpers/id_helpers.rb, line 25 def active_scaffold_id "#{controller_id}-active-scaffold" end
Source
# File lib/active_scaffold/helpers/id_helpers.rb, line 37 def active_scaffold_messages_id(options = {}) "#{options[:controller_id] || controller_id}-messages" end
Source
# File lib/active_scaffold/helpers/id_helpers.rb, line 33 def active_scaffold_tbody_id "#{controller_id}-tbody" end
Source
# File lib/active_scaffold/helpers/id_helpers.rb, line 88 def association_subform_id(column) klass = column.association.klass.to_s.underscore clean_id "#{controller_id}-associated-#{klass}" end
Source
# File lib/active_scaffold/helpers/id_helpers.rb, line 49 def before_header_id "#{controller_id}-search-container" end
Source
# File lib/active_scaffold/helpers/id_helpers.rb, line 9 def controller_id(controller = params[:eid] || nested_id || params[:parent_controller] || params[:controller]) "as_#{id_from_controller(controller)}" end
Source
# File lib/active_scaffold/helpers/id_helpers.rb, line 73 def element_cell_id(options = {}) options[:action] ||= params[:action] options[:id] ||= params[:id] options[:id] ||= nested_parent_id if nested? options[:name] ||= params[:name] clean_id "#{controller_id}-#{options[:action]}-#{options[:id]}-#{options[:name]}-cell" end
Source
# File lib/active_scaffold/helpers/id_helpers.rb, line 81 def element_form_id(options = {}) options[:action] ||= params[:action] options[:id] ||= params[:id] options[:id] ||= nested_parent_id if nested? clean_id "#{controller_id}-#{options[:action]}-#{options[:id]}-form" end
Source
# File lib/active_scaffold/helpers/id_helpers.rb, line 118 def element_messages_id(options = {}) options[:action] ||= params[:action] options[:id] ||= params[:id] options[:id] ||= nested_parent_id if nested? clean_id "#{controller_id}-#{options[:action]}-#{options[:id]}-messages" end
Source
# File lib/active_scaffold/helpers/id_helpers.rb, line 66 def element_row_id(options = {}) options[:action] ||= params[:action] options[:id] ||= params[:id] options[:id] ||= nested_parent_id if nested? clean_id "#{options[:controller_id] || controller_id}-#{options[:action]}-#{options[:id]}-row" end
Source
# File lib/active_scaffold/helpers/id_helpers.rb, line 45 def empty_message_id "#{controller_id}-empty-message" end
Source
# File lib/active_scaffold/helpers/id_helpers.rb, line 5 def id_from_controller(controller) ERB::Util.h controller.to_s.gsub('/', '__') end
Source
# File lib/active_scaffold/helpers/id_helpers.rb, line 93 def loading_indicator_id(options = {}) options[:action] ||= params[:action] options[:id] ||= params[:id] options[:id] ||= nested_parent_id if nested? clean_id "#{controller_id}-#{options[:action]}-#{options[:id]}-loading-indicator" end
Source
# File lib/active_scaffold/helpers/id_helpers.rb, line 13 def nested? false # will be overrided in AS controllers with helper_method end
Source
# File lib/active_scaffold/helpers/id_helpers.rb, line 21 def nested_id(controller = nil) "#{nested.parent_scaffold.controller_path}-#{nested_parent_id}-#{controller || params[:parent_controller] || params[:controller]}" if nested? end
Source
# File lib/active_scaffold/helpers/id_helpers.rb, line 17 def nested_parent_id clean_id nested_parent_record.id.to_s end
Source
# File lib/active_scaffold/helpers/id_helpers.rb, line 129 def scope_id(scope) scope.gsub(/(\[|\])/, '_').gsub('__', '_').gsub(/_$/, '') end
Source
# File lib/active_scaffold/helpers/id_helpers.rb, line 53 def search_input_id "#{controller_id}-search-input" end
Source
# File lib/active_scaffold/helpers/id_helpers.rb, line 106 def sub_form_id(options = {}) options[:id] ||= params[:id] options[:id] ||= nested_parent_id if nested? clean_id "#{controller_id}-#{options[:id]}-#{options[:association]}#{'-' if options[:tab_id]}#{options[:tab_id]}-subform" end
Source
# File lib/active_scaffold/helpers/id_helpers.rb, line 112 def sub_form_list_id(options = {}) options[:id] ||= params[:id] options[:id] ||= nested_parent_id if nested? clean_id "#{controller_id}-#{options[:id]}-#{options[:association]}#{'-' if options[:tab_id]}#{options[:tab_id]}-subform-list" end
Source
# File lib/active_scaffold/helpers/id_helpers.rb, line 100 def sub_section_id(options = {}) options[:id] ||= params[:id] options[:id] ||= nested_parent_id if nested? clean_id "#{controller_id}-#{options[:id]}-#{options[:sub_section]}-subsection" end
Private Instance Methods
Source
# File lib/active_scaffold/helpers/id_helpers.rb, line 136 def clean_id(val) val.gsub(/[^-_0-9a-zA-Z]/, '-') end
whitelists id-safe characters