10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'app/helpers/kkt_shoppe/product_category_helper.rb', line 10
def nested_product_category_rows(category, current_category = nil, link_to_current = true, relative_depth = 0)
if category.present? && category.children.count > 0
String.new.tap do |s|
category.children.ordered.each do |child|
s << "<tr>"
s << "<td>"
if child == current_category
if link_to_current == false
s << "#{nested_product_category_spacing_adjusted_for_depth child, relative_depth} ↳ #{child.name} (#{t('kkt_shoppe.product_category.nesting.current_category')})"
else
s << "#{nested_product_category_spacing_adjusted_for_depth child, relative_depth} ↳ #{link_to(child.name, [:edit, child]).html_safe} (#{t('kkt_shoppe.product_category.nesting.current_category')})"
end
else
s << "#{nested_product_category_spacing_adjusted_for_depth child, relative_depth} ↳ #{link_to(child.name, [:edit, child]).html_safe}"
end
s << "</td>"
s << "</tr>"
s << nested_product_category_rows(child, current_category, link_to_current, relative_depth)
end
end.html_safe
else
""
end
end
|