Module: ActiveScaffold::Helpers::IdHelpers
- Included in:
- ControllerHelpers, ViewHelpers
- Defined in:
- lib/active_scaffold/helpers/id_helpers.rb
Overview
A bunch of helper methods to produce the common view ids
Instance Method Summary collapse
- #action_iframe_id(options) ⇒ Object
- #action_link_id(link_action, link_id) ⇒ Object
- #active_scaffold_calculations_id(options = {}) ⇒ Object
- #active_scaffold_column_header_id(column) ⇒ Object
- #active_scaffold_content_id ⇒ Object
- #active_scaffold_id ⇒ Object
- #active_scaffold_messages_id(options = {}) ⇒ Object
- #active_scaffold_tbody_id ⇒ Object
- #association_subform_id(column) ⇒ Object
- #before_header_id ⇒ Object
- #controller_id(controller = params[:eid] || nested_id || params[:parent_controller] || params[:controller]) ⇒ Object
- #element_cell_id(options = {}) ⇒ Object
- #element_form_id(options = {}) ⇒ Object
- #element_messages_id(options = {}) ⇒ Object
- #element_row_id(options = {}) ⇒ Object
- #empty_message_id ⇒ Object
- #id_from_controller(controller) ⇒ Object
- #loading_indicator_id(options = {}) ⇒ Object
- #nested? ⇒ Boolean
- #nested_id(controller = nil) ⇒ Object
- #nested_parent_id ⇒ Object
- #scope_id(scope) ⇒ Object
- #search_input_id ⇒ Object
- #sub_form_id(options = {}) ⇒ Object
- #sub_form_list_id(options = {}) ⇒ Object
- #sub_section_id(options = {}) ⇒ Object
Instance Method Details
#action_iframe_id(options) ⇒ Object
127 128 129 |
# File 'lib/active_scaffold/helpers/id_helpers.rb', line 127 def action_iframe_id() "#{controller_id}-#{[:action]}-#{[:id]}-iframe" end |
#action_link_id(link_action, link_id) ⇒ Object
59 60 61 |
# File 'lib/active_scaffold/helpers/id_helpers.rb', line 59 def action_link_id(link_action, link_id) "#{controller_id}-#{link_action}-#{link_id}-link" end |
#active_scaffold_calculations_id(options = {}) ⇒ Object
43 44 45 |
# File 'lib/active_scaffold/helpers/id_helpers.rb', line 43 def active_scaffold_calculations_id( = {}) "#{[:controller_id] || controller_id}-calculations#{"-#{[:column].name}" if [:column]}" end |
#active_scaffold_column_header_id(column) ⇒ Object
63 64 65 66 |
# File 'lib/active_scaffold/helpers/id_helpers.rb', line 63 def active_scaffold_column_header_id(column) name = column.respond_to?(:name) ? column.name : column.to_s clean_id "#{controller_id}-#{name}-column" end |
#active_scaffold_content_id ⇒ Object
31 32 33 |
# File 'lib/active_scaffold/helpers/id_helpers.rb', line 31 def active_scaffold_content_id "#{controller_id}-content" end |
#active_scaffold_id ⇒ Object
27 28 29 |
# File 'lib/active_scaffold/helpers/id_helpers.rb', line 27 def active_scaffold_id "#{controller_id}-active-scaffold" end |
#active_scaffold_messages_id(options = {}) ⇒ Object
39 40 41 |
# File 'lib/active_scaffold/helpers/id_helpers.rb', line 39 def ( = {}) "#{[:controller_id] || controller_id}-messages" end |
#active_scaffold_tbody_id ⇒ Object
35 36 37 |
# File 'lib/active_scaffold/helpers/id_helpers.rb', line 35 def active_scaffold_tbody_id "#{controller_id}-tbody" end |
#association_subform_id(column) ⇒ Object
90 91 92 93 |
# File 'lib/active_scaffold/helpers/id_helpers.rb', line 90 def association_subform_id(column) klass = column.association.klass.to_s.underscore clean_id "#{controller_id}-associated-#{klass}" end |
#before_header_id ⇒ Object
51 52 53 |
# File 'lib/active_scaffold/helpers/id_helpers.rb', line 51 def before_header_id "#{controller_id}-search-container" end |
#controller_id(controller = params[:eid] || nested_id || params[:parent_controller] || params[:controller]) ⇒ Object
11 12 13 |
# File 'lib/active_scaffold/helpers/id_helpers.rb', line 11 def controller_id(controller = params[:eid] || nested_id || params[:parent_controller] || params[:controller]) "as_#{id_from_controller(controller)}" end |
#element_cell_id(options = {}) ⇒ Object
75 76 77 78 79 80 81 |
# File 'lib/active_scaffold/helpers/id_helpers.rb', line 75 def element_cell_id( = {}) [:action] ||= params[:action] [:id] ||= params[:id] [:id] ||= nested_parent_id if nested? [:name] ||= params[:name] clean_id "#{controller_id}-#{[:action]}-#{[:id]}-#{[:name]}-cell" end |
#element_form_id(options = {}) ⇒ Object
83 84 85 86 87 88 |
# File 'lib/active_scaffold/helpers/id_helpers.rb', line 83 def element_form_id( = {}) [:action] ||= params[:action] [:id] ||= params[:id] [:id] ||= nested_parent_id if nested? clean_id "#{controller_id}-#{[:action]}-#{[:id]}-form" end |
#element_messages_id(options = {}) ⇒ Object
120 121 122 123 124 125 |
# File 'lib/active_scaffold/helpers/id_helpers.rb', line 120 def ( = {}) [:action] ||= params[:action] [:id] ||= params[:id] [:id] ||= nested_parent_id if nested? clean_id "#{controller_id}-#{[:action]}-#{[:id]}-messages" end |
#element_row_id(options = {}) ⇒ Object
68 69 70 71 72 73 |
# File 'lib/active_scaffold/helpers/id_helpers.rb', line 68 def element_row_id( = {}) [:action] ||= params[:action] [:id] ||= params[:id] [:id] ||= nested_parent_id if nested? clean_id "#{[:controller_id] || controller_id}-#{[:action]}-#{[:id]}-row" end |
#empty_message_id ⇒ Object
47 48 49 |
# File 'lib/active_scaffold/helpers/id_helpers.rb', line 47 def "#{controller_id}-empty-message" end |
#id_from_controller(controller) ⇒ Object
7 8 9 |
# File 'lib/active_scaffold/helpers/id_helpers.rb', line 7 def id_from_controller(controller) ERB::Util.h controller.to_s.gsub('/', '__') end |
#loading_indicator_id(options = {}) ⇒ Object
95 96 97 98 99 100 |
# File 'lib/active_scaffold/helpers/id_helpers.rb', line 95 def loading_indicator_id( = {}) [:action] ||= params[:action] [:id] ||= params[:id] [:id] ||= nested_parent_id if nested? clean_id "#{controller_id}-#{[:action]}-#{[:id]}-loading-indicator" end |
#nested? ⇒ Boolean
15 16 17 |
# File 'lib/active_scaffold/helpers/id_helpers.rb', line 15 def nested? false # will be overrided in AS controllers with helper_method end |
#nested_id(controller = nil) ⇒ Object
23 24 25 |
# File 'lib/active_scaffold/helpers/id_helpers.rb', line 23 def nested_id(controller = nil) "#{nested.parent_scaffold.controller_path}-#{nested_parent_id}-#{controller || params[:parent_controller] || params[:controller]}" if nested? end |
#nested_parent_id ⇒ Object
19 20 21 |
# File 'lib/active_scaffold/helpers/id_helpers.rb', line 19 def nested_parent_id clean_id nested_parent_record.id.to_s end |
#scope_id(scope) ⇒ Object
131 132 133 |
# File 'lib/active_scaffold/helpers/id_helpers.rb', line 131 def scope_id(scope) scope.gsub(/(\[|\])/, '_').gsub('__', '_').gsub(/_$/, '') end |
#search_input_id ⇒ Object
55 56 57 |
# File 'lib/active_scaffold/helpers/id_helpers.rb', line 55 def search_input_id "#{controller_id}-search-input" end |
#sub_form_id(options = {}) ⇒ Object
108 109 110 111 112 |
# File 'lib/active_scaffold/helpers/id_helpers.rb', line 108 def sub_form_id( = {}) [:id] ||= params[:id] [:id] ||= nested_parent_id if nested? clean_id "#{controller_id}-#{[:id]}-#{[:association]}#{'-' if [:tab_id]}#{[:tab_id]}-subform" end |
#sub_form_list_id(options = {}) ⇒ Object
114 115 116 117 118 |
# File 'lib/active_scaffold/helpers/id_helpers.rb', line 114 def sub_form_list_id( = {}) [:id] ||= params[:id] [:id] ||= nested_parent_id if nested? clean_id "#{controller_id}-#{[:id]}-#{[:association]}#{'-' if [:tab_id]}#{[:tab_id]}-subform-list" end |
#sub_section_id(options = {}) ⇒ Object
102 103 104 105 106 |
# File 'lib/active_scaffold/helpers/id_helpers.rb', line 102 def sub_section_id( = {}) [:id] ||= params[:id] [:id] ||= nested_parent_id if nested? clean_id "#{controller_id}-#{[:id]}-#{[:sub_section]}-subsection" end |