Module: Comatose::AdminHelper

Defined in:
app/helpers/comatose/admin_helper.rb

Instance Method Summary collapse

Instance Method Details

#collection_from_child_for_select(node, level, hide, options = []) ⇒ Object

Called by collection_from_node_for_select



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'app/helpers/comatose/admin_helper.rb', line 62

def collection_from_child_for_select(node, level, hide, options=[])
  padding     = " " * level * 4
  padding     += '* ' unless level == 0

  hide_values = Array.new
  hide_values << hide if hide

  unless hide_values.include?(node.id)
    options << ["#{padding}#{node.title}", node.id]
    node.children.each do |child|
      collection_from_child_for_select(child, level + 1, hide, options)
    end
  end
  return options
end

#collection_from_node_for_select(nodes, hide = nil, label = "Parent", add_initial = false) ⇒ Object

Used in the Page Form to build an indented drop-down list of pages



46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'app/helpers/comatose/admin_helper.rb', line 46

def collection_from_node_for_select(nodes, hide=nil, label="Parent", add_initial=false)
  level       = 0
  options     = []

  if add_initial
    options << ["No #{label}", 0]
  end

  nodes.each do |node|
    collection_from_child_for_select(node, level, hide, options)
  end
  return options
end

#comatose_admin_javascripts(*names) ⇒ Object

TODO - broken



17
18
19
20
21
22
23
24
# File 'app/helpers/comatose/admin_helper.rb', line 17

def comatose_admin_javascripts(*names)
  strings = []
  names ||= ['comatose_admin']
  names.each do |name|
    strings << javascript_include_tag(name)
  end
  strings
end

#comatose_admin_stylesheets(*names) ⇒ Object

TODO - broken



5
6
7
8
9
10
11
12
13
# File 'app/helpers/comatose/admin_helper.rb', line 5

def comatose_admin_stylesheets(*names)
  strings = []
  names ||= ['comatose_admin']
  names.each do |name|
    Comatose.logger.debug("[**Comatose**]: stylesheet tag for: #{name}")
    strings << stylesheet_link_tag(name)
  end
  strings.join("\n")
end

#select_from_node(nodes, selected = nil, hide = nil, html_options = {}) ⇒ Object



33
34
35
36
37
38
39
40
41
42
# File 'app/helpers/comatose/admin_helper.rb', line 33

def select_from_node(nodes, selected=nil, hide=nil, html_options={})
  html_options[:tabindex] ||= 9
  html_options[:label]    ||= "Parent"
  html_options[:name]     ||= "page[parent_id]"
  html_options[:id]       ||= "page_parent"
  html_options[:blank]    ||= false

  options = options_for_select(collection_from_node_for_select(nodes, hide, html_options[:label], html_options[:blank]), selected)
  select_tag html_options[:name], options, :id => html_options[:id], :tabindex => html_options[:tabindex]
end

#show_field?(key) ⇒ Boolean

Checks the hidden_meta_fields class variable for a specified field name…

Returns:

  • (Boolean)


28
29
30
# File 'app/helpers/comatose/admin_helper.rb', line 28

def show_field?(key)
  !Comatose.config.hidden_meta_fields.include? key
end