X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/8f20c1723c0614fabedb2c2468932d9245a1fc86..747aa7b4d080b4ea95bf7d6d8643c43e70966f33:/apps/workbench/app/controllers/folders_controller.rb?ds=sidebyside diff --git a/apps/workbench/app/controllers/folders_controller.rb b/apps/workbench/app/controllers/folders_controller.rb index b87a94bc2a..8ebb1a34b1 100644 --- a/apps/workbench/app/controllers/folders_controller.rb +++ b/apps/workbench/app/controllers/folders_controller.rb @@ -39,11 +39,11 @@ class FoldersController < ApplicationController def index @objects = Group.where(group_class: 'folder').order('name') - parent_of = {} + parent_of = {current_user.uuid => 'me'} @objects.each do |ob| parent_of[ob.uuid] = ob.owner_uuid end - children_of = {false => [], current_user.uuid => []} + children_of = {false => [], 'me' => [current_user]} @objects.each do |ob| if ob.owner_uuid != current_user.uuid and not parent_of.has_key? ob.owner_uuid @@ -52,23 +52,33 @@ class FoldersController < ApplicationController children_of[parent_of[ob.uuid]] ||= [] children_of[parent_of[ob.uuid]] << ob end - def buildtree children_of, root_uuid=false + buildtree = lambda do |children_of, root_uuid=false| tree = {} children_of[root_uuid].andand.each do |ob| - tree[ob] = buildtree(children_of, ob.uuid) + tree[ob] = buildtree.call(children_of, ob.uuid) end tree end - def sorted_paths tree, depth=0 + sorted_paths = lambda do |tree, depth=0| paths = [] - tree.keys.sort_by { |ob| ob.name || 'New folder' }.each do |ob| + tree.keys.sort_by { |ob| + ob.is_a?(String) ? ob : ob.friendly_link_name + }.each do |ob| paths << {object: ob, depth: depth} - paths += sorted_paths tree[ob], depth+1 + paths += sorted_paths.call tree[ob], depth+1 end paths end - @my_folder_tree = sorted_paths buildtree(children_of, current_user.uuid) - @shared_folder_tree = sorted_paths buildtree(children_of, false) + @my_folder_tree = + sorted_paths.call buildtree.call(children_of, 'me') + @shared_folder_tree = + sorted_paths.call({'Shared with me' => + buildtree.call(children_of, false)}) + end + + def choose + index + render partial: 'choose' end def show @@ -100,4 +110,9 @@ class FoldersController < ApplicationController @new_resource_attrs[:name] ||= 'New folder' super end + + def update + @updates = params['folder'] + super + end end