[ARVADOS] created: 6a1b128ede0d9bf244423c887a0350425ddf003f

git at public.curoverse.com git at public.curoverse.com
Wed May 21 16:14:46 EDT 2014


        at  6a1b128ede0d9bf244423c887a0350425ddf003f (commit)


commit 6a1b128ede0d9bf244423c887a0350425ddf003f
Author: Tom Clegg <tom at curoverse.com>
Date:   Wed May 21 16:14:17 2014 -0400

    2760: Show folder hierarchy on regular page, not in left nav

diff --git a/apps/workbench/app/assets/stylesheets/folders.css.scss b/apps/workbench/app/assets/stylesheets/folders.css.scss
index 1dea791..163c188 100644
--- a/apps/workbench/app/assets/stylesheets/folders.css.scss
+++ b/apps/workbench/app/assets/stylesheets/folders.css.scss
@@ -1,3 +1,8 @@
-// Place all the styles related to the folders controller here.
-// They will automatically be included in application.css.
-// You can use Sass (SCSS) here: http://sass-lang.com/
+.arv-folder-list > .row {
+    padding-top: 5px;
+    padding-bottom: 5px;
+    padding-right: 1em;
+}
+.arv-folder-list > .row.folder:hover {
+    background: #d9edf7;
+}
diff --git a/apps/workbench/app/controllers/application_controller.rb b/apps/workbench/app/controllers/application_controller.rb
index b62838f..4d6008a 100644
--- a/apps/workbench/app/controllers/application_controller.rb
+++ b/apps/workbench/app/controllers/application_controller.rb
@@ -14,7 +14,6 @@ class ApplicationController < ActionController::Base
   before_filter :check_user_notifications, except: ERROR_ACTIONS
   around_filter :using_reader_tokens, only: [:index, :show]
   before_filter :find_object_by_uuid, except: [:index] + ERROR_ACTIONS
-  before_filter :check_my_folders, :except => ERROR_ACTIONS
   theme :select_theme
 
   begin
@@ -423,15 +422,6 @@ class ApplicationController < ActionController::Base
     }
   }
 
-  def check_my_folders
-    @my_top_level_folders = lambda do
-      @top_level_folders ||= Group.
-        filter([['group_class','=','folder'],
-                ['owner_uuid','=',current_user.uuid]]).
-        sort_by { |x| x.name || '' }
-    end
-  end
-
   def check_user_notifications
     @notification_count = 0
     @notifications = []
diff --git a/apps/workbench/app/controllers/folders_controller.rb b/apps/workbench/app/controllers/folders_controller.rb
index 86ee42b..907d237 100644
--- a/apps/workbench/app/controllers/folders_controller.rb
+++ b/apps/workbench/app/controllers/folders_controller.rb
@@ -4,7 +4,7 @@ class FoldersController < ApplicationController
   end
 
   def index_pane_list
-    %w(My_folders Shared_with_me)
+    %w(Folders)
   end
 
   def remove_item
@@ -38,33 +38,38 @@ class FoldersController < ApplicationController
   end
 
   def index
-    @my_folders = []
-    @shared_with_me = []
     @objects = Group.where(group_class: 'folder').order('name')
-    owner_of = {}
-    moretodo = true
-    while moretodo
-      moretodo = false
-      @objects.each do |folder|
-        if !owner_of[folder.uuid]
-          moretodo = true
-          owner_of[folder.uuid] = folder.owner_uuid
-        end
-        if owner_of[folder.owner_uuid]
-          if owner_of[folder.uuid] != owner_of[folder.owner_uuid]
-            owner_of[folder.uuid] = owner_of[folder.owner_uuid]
-            moretodo = true
-          end
-        end
+    parent_of = {}
+    @objects.each do |ob|
+      parent_of[ob.uuid] = ob.owner_uuid
+    end
+    children_of = {false => [], current_user.uuid => []}
+    @objects.each do |ob|
+      if ob.owner_uuid != current_user.uuid and
+          not parent_of.has_key? ob.owner_uuid
+        parent_of[ob.uuid] = false
       end
+      children_of[parent_of[ob.uuid]] ||= []
+      children_of[parent_of[ob.uuid]] << ob
+      $stderr.puts "children of #{parent_of[ob.uuid]} << #{ob.uuid} #{ob.name}"
     end
-    @objects.each do |folder|
-      if owner_of[folder.uuid] == current_user.uuid
-        @my_folders << folder
-      else
-        @shared_with_me << folder
+    def buildtree children_of, root_uuid=false
+      tree = {}
+      children_of[root_uuid].andand.each do |ob|
+        tree[ob] = buildtree(children_of, ob.uuid)
+      end
+      tree
+    end
+    def sorted_paths tree, depth=0
+      paths = []
+      tree.keys.sort_by { |ob| ob.name || 'New folder' }.each do |ob|
+        paths << {object: ob, depth: depth}
+        paths += sorted_paths 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)
   end
 
   def show
diff --git a/apps/workbench/app/views/folders/_show_folders.html.erb b/apps/workbench/app/views/folders/_show_folders.html.erb
new file mode 100644
index 0000000..f2dd1c0
--- /dev/null
+++ b/apps/workbench/app/views/folders/_show_folders.html.erb
@@ -0,0 +1,19 @@
+<div class="container-fluid arv-folder-list">
+  <% [[@my_folder_tree, 'My folders'],
+     [@shared_folder_tree, 'Shared with me']].each do |tree, label| %>
+    <div class="row">
+      <i class="fa fa-fw fa-folder-open-o"></i> <%= label %>
+    </div>
+    <% tree.each do |foldernode| %>
+      <div class="folder row" style="padding-left: <%= 1 + foldernode[:depth] %>em;">
+        <i class="fa fa-fw fa-folder-o"></i>
+        <%= link_to foldernode[:object] do %>
+          <%= foldernode[:object].name || 'New folder' %>
+        <% end %>
+        <div class="pull-right">
+          <%= render partial: 'delete_object_button', locals: {object: foldernode[:object]} %>
+        </div>
+      </div>
+    <% end %>
+  <% end %>
+</div>
diff --git a/apps/workbench/app/views/folders/_show_my_folders.html.erb b/apps/workbench/app/views/folders/_show_my_folders.html.erb
deleted file mode 100644
index b009acf..0000000
--- a/apps/workbench/app/views/folders/_show_my_folders.html.erb
+++ /dev/null
@@ -1,2 +0,0 @@
-<%= render(partial: 'show_recent',
-    locals: { comparable: comparable, objects: @my_folders }) %>
diff --git a/apps/workbench/app/views/folders/_show_shared_with_me.html.erb b/apps/workbench/app/views/folders/_show_shared_with_me.html.erb
deleted file mode 100644
index 6ccf983..0000000
--- a/apps/workbench/app/views/folders/_show_shared_with_me.html.erb
+++ /dev/null
@@ -1,2 +0,0 @@
-<%= render(partial: 'show_recent',
-    locals: { comparable: comparable, objects: @shared_with_me }) %>
diff --git a/apps/workbench/app/views/layouts/application.html.erb b/apps/workbench/app/views/layouts/application.html.erb
index 2d3c4c0..4560885 100644
--- a/apps/workbench/app/views/layouts/application.html.erb
+++ b/apps/workbench/app/views/layouts/application.html.erb
@@ -77,17 +77,9 @@
             </li>
 
             <li class="dropdown">
-              <a href="/folders" class="dropdown-toggle" data-toggle="dropdown"><i class="fa fa-lg fa-folder-o fa-fw"></i> Folders <b class="caret"></b></a>
-              <ul class="dropdown-menu">
-                <li><%= link_to raw('<i class="fa fa-plus fa-fw"></i> Create new folder'), folders_path, method: :post %></li>
-                <% @my_top_level_folders.call[0..7].each do |folder| %>
-                <li><%= link_to raw('<i class="fa fa-folder-open fa-fw"></i> ') + folder.name, folder_path(folder) %></li>
-                <% end %>
-                <li><a href="/folders">
-                    <i class="fa fa-ellipsis-h fa-fw"></i> Show all folders
-                </a></li>
-              </ul>
-            </li>
+              <a href="/folders">
+                <i class="fa fa-lg fa-folder-o fa-fw"></i> Folders
+            </a></li>
             <li><a href="/collections">
                 <i class="fa fa-lg fa-briefcase fa-fw"></i> Collections (data files)
             </a></li>

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list