Module: RenderSortableTreeHelper::Render

Defined in:
app/helpers/render_sortable_tree_helper.rb

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.hObject

Returns the value of attribute h.



12
13
14
# File 'app/helpers/render_sortable_tree_helper.rb', line 12

def h
  @h
end

.optionsObject

Returns the value of attribute options.



12
13
14
# File 'app/helpers/render_sortable_tree_helper.rb', line 12

def options
  @options
end

Class Method Details

.childrenObject



54
55
56
57
58
# File 'app/helpers/render_sortable_tree_helper.rb', line 54

def children
  unless options[:children].blank?
    "<ol class='nested_set'>#{ options[:children] }</ol>"
  end
end

.controlsObject



40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'app/helpers/render_sortable_tree_helper.rb', line 40

def controls
  node = options[:node]

  edit_path = h.url_for(:controller => 'admin/properties', :action => :edit, :id => node)
  destroy_path = h.url_for(:controller => 'admin/properties', :action => :destroy, :id => node)

  "
    <div class='controls'>
      #{ h.link_to '', edit_path, :class => :edit }
      #{ h.link_to '', destroy_path, :class => :delete, :method => :delete, :data => { :confirm => 'Are you sure?' } }
    </div>
  "
end

.render_node(h, options) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/helpers/render_sortable_tree_helper.rb', line 14

def render_node(h, options)
  @h, @options = h, options
  node = options[:node]

  "
    <li data-node-id='#{ node.id }'>
      <div class='item'>
        <i class='handle'></i>
        #{ show_link }
        #{ controls }
      </div>
      #{ children }
    </li>
  "
end


30
31
32
33
34
35
36
37
38
# File 'app/helpers/render_sortable_tree_helper.rb', line 30

def show_link
  node = options[:node]
  ns   = options[:namespace]
  url = h.url_for(:controller => 'admin/properties', :action => :show, :id => node)
 #  url = h.url_for(ns + [node])
  title_field = node[:name]
  #p options
  "<h4>#{ h.link_to(title_field, url) }</h4>"
end