3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
# File 'app/helpers/product_lines_helper.rb', line 3
def product_lines_hash(product_lines: nil, selected_product_line: nil, selected_product_line_ids: nil)
product_lines ||= ProductLine.roots
data = []
product_lines.order(:slug_ltree).each do |pl|
pl_hsh = {
text: link_to(pl.decorated_product_line_name, product_line_path(pl, tab: "items"))}
if (children = pl.children).present?
sub_nodes = product_lines_hash(product_lines: children, selected_product_line_ids: selected_product_line_ids)
pl_hsh[:nodes] = sub_nodes
end
data << pl_hsh
end
data
end
|