Sha256: d25c8080059967de4df475e0d4e52ae9996f8f23d834edf6d34eadfc3d78b8ea
Contents?: true
Size: 1.54 KB
Versions: 6
Compression:
Stored size: 1.54 KB
Contents
module KktShoppe module ProductCategoryHelper def nested_product_category_spacing_adjusted_for_depth(category, relative_depth) depth = category.depth - relative_depth spacing = depth < 2 ? 0.8 : 1.5 ("<span style='display:inline-block;width:#{spacing}em;'></span>"*category.depth).html_safe end 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 end end
Version data entries
6 entries across 6 versions & 1 rubygems