3654: redirection to newly created collection is now working.
[arvados.git] / apps / workbench / app / views / collections / _show_files.html.erb
1 <div class="selection-action-container" style="padding-left: 1em">
2   <div class="row">
3     <div class="pull-left">
4       <div class="btn-group btn-group-sm">
5         <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">Selection... <span class="caret"></span></button>
6         <ul class="dropdown-menu" role="menu">
7           <li><%= link_to "Combine selections into a new collection", '#',
8                   'data-href' => combine_selected_path,
9                   'data-selection-param-name' => 'selection[]',
10                   'data-selection-action' => 'combine-collections',
11                   'method' => 'post',
12                   'data-toggle' => 'dropdown'
13             %></li>
14         </ul>
15       </div>
16     </div>
17   </div>
18   <p/>
19
20 <% file_tree = @object.andand.files_tree %>
21 <% if file_tree.nil? or file_tree.empty? %>
22   <p>This collection is empty.</p>
23 <% else %>
24   <ul id="collection_files" class="collection_files">
25   <% dirstack = [file_tree.first.first] %>
26   <% file_tree.take(10000).each_with_index do |(dirname, filename, size), index| %>
27     <% file_path = CollectionsHelper::file_path([dirname, filename]) %>
28     <% while dirstack.any? and (dirstack.last != dirname) %>
29       <% dirstack.pop %></ul></li>
30     <% end %>
31     <li>
32     <% if size.nil?  # This is a subdirectory. %>
33       <% dirstack.push(File.join(dirname, filename)) %>
34       <div class="collection_files_row">
35        <div class="collection_files_name"><i class="fa fa-fw fa-folder-open"></i> <%= filename %></div>
36       </div>
37       <ul class="collection_files">
38     <% else %>
39       <% link_params = {controller: 'collections', action: 'show_file',
40                         uuid: @object.portable_data_hash, file: file_path, size: size} %>
41        <div class="collection_files_row">
42         <div class="collection_files_buttons pull-right">
43           <%= raw(human_readable_bytes_html(size)) %>
44           <% if !defined? no_checkboxes or !no_checkboxes %>
45           <%= check_box_tag 'uuids[]', "#{@object.uuid}/#{file_path}", false, {
46                 :class => 'persistent-selection',
47                 :friendly_type => "File",
48                 :friendly_name => "#{@object.uuid}/#{file_path}",
49                 :href => url_for(controller: 'collections', action: 'show_file',
50                                  uuid: @object.portable_data_hash, file: file_path),
51                 :title => "Include #{file_path} in your selections",
52               } %>
53           <% end %>
54           <%= link_to(raw('<i class="fa fa-search"></i>'),
55                       link_params.merge(disposition: 'inline'),
56                       {title: "View #{file_path}", class: "btn btn-info btn-sm"}) %>
57           <%= link_to(raw('<i class="fa fa-download"></i>'),
58                       link_params.merge(disposition: 'attachment'),
59                       {title: "Download #{file_path}", class: "btn btn-info btn-sm"}) %>
60         </div>
61       <% if CollectionsHelper::is_image(filename) %>
62         <div class="collection_files_name"><i class="fa fa-fw fa-bar-chart-o"></i> <%= filename %></div>
63        </div>
64         <div class="collection_files_inline">
65           <%= link_to(image_tag("#{url_for @object}/#{file_path}"),
66                       link_params.merge(disposition: 'inline'),
67                       {title: file_path}) %>
68         </div>
69       <% else %>
70         <div class="collection_files_name"><i class="fa fa-fw fa-file"></i> <%= filename %></div>
71        </div>
72       <% end %>
73       </li>
74     <% end  # if file or directory %>
75   <% end  # file_tree.each %>
76   <%= raw(dirstack.map { |_| "</ul>" }.join("</li>")) %>
77 <% end  # if file_tree %>
78
79 <% content_for :footer_html do %>
80 <div id="collection-sharing-modal-window" class="modal fade" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"></div>
81 <% end %>
82
83 </div>