Merge pull request #930 from openHPI/own-project
Rebrush action sidebar for implement view
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class FileTree < Tree::TreeNode
|
||||
class FileTree
|
||||
def file_icon(file)
|
||||
if file.file_type.audio?
|
||||
'fa fa-file-audio-o'
|
||||
@ -26,9 +26,11 @@ class FileTree < Tree::TreeNode
|
||||
private :folder_icon
|
||||
|
||||
def initialize(files = [])
|
||||
super(root_label)
|
||||
# Our tree needs a root node, but we won't display it.
|
||||
@root = Tree::TreeNode.new('ROOT')
|
||||
|
||||
files.uniq(&:name_with_extension).each do |file|
|
||||
parent = self
|
||||
parent = @root
|
||||
(file.path || '').split('/').each do |segment|
|
||||
node = parent.children.detect {|child| child.name == segment } || parent.add(Tree::TreeNode.new(segment))
|
||||
parent = node
|
||||
@ -60,15 +62,10 @@ class FileTree < Tree::TreeNode
|
||||
end
|
||||
private :node_icon
|
||||
|
||||
def root_label
|
||||
I18n.t('exercises.editor_file_tree.file_root')
|
||||
end
|
||||
private :root_label
|
||||
|
||||
def to_js_tree
|
||||
{
|
||||
core: {
|
||||
data: map_to_js_tree(self),
|
||||
data: @root.children.map {|child| map_to_js_tree(child) },
|
||||
},
|
||||
}.to_json
|
||||
end
|
||||
|
Reference in New Issue
Block a user