3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'app/helpers/lcp_ruby/tree_helper.rb', line 3
def render_tree_rows(roots, children_map, columns, depth:, default_expanded:, match_ids:,
reparentable: false, search_active: false)
return "".html_safe if roots.blank?
@_tree_col_field_defs ||= {}
@_tree_col_model_names ||= {}
columns.each do |col|
path = col["field"]
next unless path
next if @_tree_col_field_defs.key?(path)
fd, mn = LcpRuby::Metadata::FieldPath.terminal(current_model_definition, path, through_collections: true)
@_tree_col_field_defs[path] = fd
@_tree_col_model_names[path] = mn || current_model_name
end
roots.each_with_index.map { |record, idx|
render_tree_row(record, children_map, columns, depth: depth,
default_expanded: default_expanded, match_ids: match_ids,
reparentable: reparentable, search_active: search_active,
guides: [], is_last: idx == roots.size - 1)
}.join.html_safe
end
|