9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'app/helpers/spree/billing/sortable_tree_helper.rb', line 9
def build_sortable_tree(parent_resource, child_resource)
child_resource_name = child_resource.class.name.demodulize.underscore
descendants = []
unless child_resource.leaf?
child_resource.children.each do |child_item|
descendants << build_sortable_tree(parent_resource, child_item) unless child_resource.leaf?
end
end
row = sortable_tree_bar(parent_resource, child_resource)
container = content_tag(:div, raw(descendants.join), data: { sortable_tree_parent_id_value: child_resource.id })
content_tag(:div, row + container,
class: 'sortable-tree-item draggable removable-dom-element',
data: {
sortable_tree_resource_name_value: child_resource_name.singularize,
sortable_tree_update_url_value: "/api/v2/platform/#{child_resource_name.pluralize}/#{child_resource.id}/reposition"
}
)
end
|