Module: Para::TreeHelper
- Included in:
- ApplicationHelper
- Defined in:
- app/helpers/para/tree_helper.rb
Instance Method Summary collapse
- #actions(resource) ⇒ Object
- #delete_button(resource) ⇒ Object
- #edit_button(resource) ⇒ Object
- #max_depth_for(model) ⇒ Object
- #needs_placeholder?(node) ⇒ Boolean
Instance Method Details
#actions(resource) ⇒ Object
11 12 13 14 15 |
# File 'app/helpers/para/tree_helper.rb', line 11 def actions(resource) content_tag(:div, class: 'pull-right btn-group') do (resource) + (resource) end end |
#delete_button(resource) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'app/helpers/para/tree_helper.rb', line 28 def (resource) link_to( component.relation_path(resource), method: :delete, data: { confirm: ::I18n.t('para.list.delete_confirmation') }, class: 'btn btn-danger' ) do content_tag(:i, '', class: 'fa fa-trash') end end |
#edit_button(resource) ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'app/helpers/para/tree_helper.rb', line 17 def (resource) link_to( component.relation_path( resource, action: :edit, return_to: view.request.fullpath ), class: 'btn btn-primary' ) do content_tag(:i, '', class: 'fa fa-pencil') end end |
#max_depth_for(model) ⇒ Object
7 8 9 |
# File 'app/helpers/para/tree_helper.rb', line 7 def max_depth_for(model) model.max_depth || Para.config.default_tree_max_depth end |
#needs_placeholder?(node) ⇒ Boolean
3 4 5 |
# File 'app/helpers/para/tree_helper.rb', line 3 def needs_placeholder?(node) node.children.empty? && node.depth < max_depth_for(node.class) end |