Module: ActiveAdmin::ActiveadminAncestryView::NodesHelper
- Defined in:
- app/helpers/active_admin/activeadmin_ancestry_view/nodes_helper.rb
Constant Summary collapse
- CLASSES =
{ child: 'panel-childless', parent: 'panel-parent', root: 'panel-root' }
- PRETTY_COLORS =
{ red: [255, 102, 102], yellow: [255, 178, 102], green: [102, 255, 102], blue: [102, 178, 255], violet: [178, 102, 255], gray: [192, 192, 192] }
Instance Method Summary collapse
- #generate_panel_classes(resource) ⇒ Object
-
#last_child(resource) ⇒ Object
for ‘data-last-child’ attribute.
- #panel_shift(resource, multiplicator = 4) ⇒ Object
- #random_bckgr_color(resource, no_color = false) ⇒ Object
Instance Method Details
#generate_panel_classes(resource) ⇒ Object
16 17 18 19 20 21 22 |
# File 'app/helpers/active_admin/activeadmin_ancestry_view/nodes_helper.rb', line 16 def generate_panel_classes(resource) attributes = [] attributes << resource.path_ids if resource.ancestry attributes << child_class(resource) attributes << CLASSES[:root] if resource.root? attributes.flatten.join(' ') end |
#last_child(resource) ⇒ Object
for ‘data-last-child’ attribute
25 26 27 |
# File 'app/helpers/active_admin/activeadmin_ancestry_view/nodes_helper.rb', line 25 def last_child(resource) "#{resource.parent.id}" if last_child?(resource) end |
#panel_shift(resource, multiplicator = 4) ⇒ Object
29 30 31 32 33 |
# File 'app/helpers/active_admin/activeadmin_ancestry_view/nodes_helper.rb', line 29 def panel_shift(resource, multiplicator = 4) unless resource.depth.zero? "margin-left: #{multiplicator * resource.depth}em;" end end |
#random_bckgr_color(resource, no_color = false) ⇒ Object
35 36 37 38 39 40 |
# File 'app/helpers/active_admin/activeadmin_ancestry_view/nodes_helper.rb', line 35 def random_bckgr_color(resource, no_color = false) return if no_color return if childless_child?(resource) color = random_color.join(', ') "background-color: rgba(#{color}, 0.7) !important" end |