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



71
72
73
74
75
# File 'app/helpers/render_sortable_tree_helper.rb', line 71

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

.controlsObject



58
59
60
61
62
63
64
65
66
67
68
69
# File 'app/helpers/render_sortable_tree_helper.rb', line 58

def controls
  node = options[:node]

  edit_path = h.url_for(:controller => options[:klass].pluralize, :action => :edit, :id => node)
  destroy_path = h.url_for(:controller => options[:klass].pluralize, :action => :destroy, :id => node)

  "
    <a href='#{ edit_path }'>
      <i class='fa fa-edit fs20'></i>
    </a>
  "
end

.handlerObject



41
42
43
44
45
# File 'app/helpers/render_sortable_tree_helper.rb', line 41

def handler
  "<div class='the_sortable_tree-handler p5'>
    <i class='fa fa-arrows fs16'></i>
  </div>"
end

.render_node(h, options) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# 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 }' class='the_sortable_tree-item'>
      <div class='ptz_table w100p p5 the_sortable_tree-item_content'>
        <div class='ptz_tr'>
          <div class='ptz_td vam w30'>
            #{ handler }
          </div>

          <div class='ptz_td vam'>
            #{ show_link }
          </div>

          <div class='ptz_td vam br-off w10 pr5'>
            #{ controls }
          </div>
        </div>
      </div>

      #{ children }
    </li>
  "
end


47
48
49
50
51
52
53
54
55
56
# File 'app/helpers/render_sortable_tree_helper.rb', line 47

def show_link
  node = options[:node]
  ns   = options[:namespace]
  url = h.url_for(:controller => options[:klass].pluralize, :action => :show, :id => node)
  title_field = options[:title]

  "<div class='fs15'>
    #{ h.link_to(node.send(title_field), url) }
  </div>"
end