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

Instance Method Details

#action_iframe_id(options) ⇒ Object



115
116
117
# File 'lib/active_scaffold/helpers/id_helpers.rb', line 115

def action_iframe_id(options)
  "#{controller_id}-#{options[:action]}-#{options[:id]}-iframe"
end


49
50
51
# File 'lib/active_scaffold/helpers/id_helpers.rb', line 49

def action_link_id(link_action,link_id)
  "#{controller_id}-#{link_action}-#{link_id}-link"
end

#active_scaffold_calculations_id(column = nil) ⇒ Object



29
30
31
# File 'lib/active_scaffold/helpers/id_helpers.rb', line 29

def active_scaffold_calculations_id(column = nil)
  "#{controller_id}-calculations#{'-' + column.name.to_s if column}"
end

#active_scaffold_column_header_id(column) ⇒ Object



53
54
55
56
# File 'lib/active_scaffold/helpers/id_helpers.rb', line 53

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_idObject



17
18
19
# File 'lib/active_scaffold/helpers/id_helpers.rb', line 17

def active_scaffold_content_id
  "#{controller_id}-content"
end

#active_scaffold_idObject



13
14
15
# File 'lib/active_scaffold/helpers/id_helpers.rb', line 13

def active_scaffold_id
  "#{controller_id}-active-scaffold"
end

#active_scaffold_messages_id(options = {}) ⇒ Object



25
26
27
# File 'lib/active_scaffold/helpers/id_helpers.rb', line 25

def active_scaffold_messages_id(options = {})
  "#{options[:controller_id] || controller_id}-messages"
end

#active_scaffold_tbody_idObject



21
22
23
# File 'lib/active_scaffold/helpers/id_helpers.rb', line 21

def active_scaffold_tbody_id
  "#{controller_id}-tbody"
end

#association_subform_id(column) ⇒ Object



80
81
82
83
# File 'lib/active_scaffold/helpers/id_helpers.rb', line 80

def association_subform_id(column)
  klass = column.association.klass.to_s.underscore
  clean_id "#{controller_id}-associated-#{klass}"
end

#before_header_idObject



37
38
39
# File 'lib/active_scaffold/helpers/id_helpers.rb', line 37

def before_header_id
  "#{controller_id}-search-container"
end

#controller_id(controller = (params[:eid] || params[:parent_controller] || params[:controller])) ⇒ Object



9
10
11
# File 'lib/active_scaffold/helpers/id_helpers.rb', line 9

def controller_id(controller = (params[:eid] || params[:parent_controller] || params[:controller]))
  controller_id ||= 'as_' + id_from_controller(controller)
end

#element_cell_id(options = {}) ⇒ Object



65
66
67
68
69
70
71
# File 'lib/active_scaffold/helpers/id_helpers.rb', line 65

def element_cell_id(options = {})
  options[:action] ||= params[:action]
  options[:id] ||= params[:id]
  options[:id] ||= params[:parent_id]
  options[:name] ||= params[:name]
  clean_id "#{controller_id}-#{options[:action]}-#{options[:id]}-#{options[:name]}-cell"
end

#element_form_id(options = {}) ⇒ Object



73
74
75
76
77
78
# File 'lib/active_scaffold/helpers/id_helpers.rb', line 73

def element_form_id(options = {})
  options[:action] ||= params[:action]
  options[:id] ||= params[:id]
  options[:id] ||= params[:parent_id]
  clean_id "#{controller_id}-#{options[:action]}-#{options[:id]}-form"
end

#element_messages_id(options = {}) ⇒ Object



108
109
110
111
112
113
# File 'lib/active_scaffold/helpers/id_helpers.rb', line 108

def element_messages_id(options = {})
  options[:action] ||= params[:action]
  options[:id] ||= params[:id]
  options[:id] ||= params[:parent_id]
  clean_id "#{controller_id}-#{options[:action]}-#{options[:id]}-messages"
end

#element_row_id(options = {}) ⇒ Object



58
59
60
61
62
63
# File 'lib/active_scaffold/helpers/id_helpers.rb', line 58

def element_row_id(options = {})
  options[:action] ||= params[:action]
  options[:id] ||= params[:id]
  options[:id] ||= params[:parent_id]
  clean_id "#{options[:controller_id] || controller_id}-#{options[:action]}-#{options[:id]}-row"
end

#empty_message_idObject



33
34
35
# File 'lib/active_scaffold/helpers/id_helpers.rb', line 33

def empty_message_id
  "#{controller_id}-empty-message"
end

#id_from_controller(controller) ⇒ Object



5
6
7
# File 'lib/active_scaffold/helpers/id_helpers.rb', line 5

def id_from_controller(controller)
  controller.to_s.gsub("/", "__")
end

#loading_indicator_id(options = {}) ⇒ Object



85
86
87
88
# File 'lib/active_scaffold/helpers/id_helpers.rb', line 85

def loading_indicator_id(options = {})
  options[:action] ||= params[:action]
  clean_id "#{controller_id}-#{options[:action]}-#{options[:id]}-loading-indicator"
end

#search_input_idObject



41
42
43
# File 'lib/active_scaffold/helpers/id_helpers.rb', line 41

def search_input_id
  "#{controller_id}-search-input"
end

#sub_form_id(options = {}) ⇒ Object



96
97
98
99
100
# File 'lib/active_scaffold/helpers/id_helpers.rb', line 96

def sub_form_id(options = {})
  options[:id] ||= params[:id]
  options[:id] ||= params[:parent_id]
  clean_id "#{controller_id}-#{options[:id]}-#{options[:association]}-subform"
end

#sub_form_list_id(options = {}) ⇒ Object



102
103
104
105
106
# File 'lib/active_scaffold/helpers/id_helpers.rb', line 102

def sub_form_list_id(options = {})
  options[:id] ||= params[:id]
  options[:id] ||= params[:parent_id]
  clean_id "#{controller_id}-#{options[:id]}-#{options[:association]}-subform-list"
end

#sub_section_id(options = {}) ⇒ Object



90
91
92
93
94
# File 'lib/active_scaffold/helpers/id_helpers.rb', line 90

def sub_section_id(options = {})
  options[:id] ||= params[:id]
  options[:id] ||= params[:parent_id]
  clean_id "#{controller_id}-#{options[:id]}-#{options[:sub_section]}-subsection"
end

#table_action_id(name) ⇒ Object



45
46
47
# File 'lib/active_scaffold/helpers/id_helpers.rb', line 45

def table_action_id(name)
  "#{controller_id}-action-table-#{name}"
end