Add persistent/cache toggle to collections table on dashboard.
authorTom Clegg <tom@curoverse.com>
Fri, 25 Apr 2014 00:14:28 +0000 (20:14 -0400)
committerTom Clegg <tom@curoverse.com>
Fri, 25 Apr 2014 00:14:28 +0000 (20:14 -0400)
apps/workbench/app/controllers/users_controller.rb
apps/workbench/app/views/users/_tables.html.erb

index a3756e896a8e6907fd7c0fdcd5ba15cbac91e2a8..37b8470089d9c3e2174c91c96b599599ee61651b 100644 (file)
@@ -102,10 +102,24 @@ class UsersController < ApplicationController
       limit(10).
       order('created_at desc').
       where(created_by: current_user.uuid)
+    collection_uuids = @my_collections.collect &:uuid
 
-    Link.limit(1000).where(head_uuid: @my_collections.collect(&:uuid),
-                           link_class: 'tag').each do |link|
-      (@my_tag_links[link.head_uuid] ||= []) << link
+    @persist_state = {}
+    collection_uuids.each do |uuid|
+      @persist_state[uuid] = 'cache'
+    end
+
+    Link.limit(1000).filter([['head_uuid', 'in', collection_uuids],
+                             ['link_class', 'in', ['tag', 'resources']]]).
+      each do |link|
+      case link.link_class
+      when 'tag'
+        (@my_tag_links[link.head_uuid] ||= []) << link
+      when 'resources'
+        if link.name == 'wants'
+          @persist_state[link.head_uuid] = 'persistent'
+        end
+      end
     end
 
     @my_pipelines = PipelineInstance.
index 0ea76acb7fbc477bdd989f731813dc6b9b55c84d..53e511738f57d0ffbad7d11a96a7283ec9e4aa49 100644 (file)
     <table class="table table-bordered table-condensed table-fixedlayout">
       <colgroup>
         <col width="46%" />
-        <col width="27%" />
-        <col width="27%" />
+        <col width="24%" />
+        <col width="10%" />
+        <col width="20%" />
       </colgroup>
 
       <tr>
-       <th>Contents</th>
-       <th>Tags</th>
-       <th>Age</th>
+        <th>Contents</th>
+        <th>Tags</th>
+        <th>Age</th>
+        <th>Storage</th>
       </tr>
 
       <% @my_collections[0..6].each do |c| %>
               <%= raw(distance_of_time_in_words(c.created_at, Time.now).sub('about ','~').sub(' ','&nbsp;')) if c.created_at %>
             </small>
           </td>
+          <td>
+            <%= render partial: 'collections/toggle_persist', locals: { uuid: c.uuid, current_state: @persist_state[c.uuid] } %>
+          </td>
         </tr>
       <% end %>
     </table>