3654: add selection dropdown to collections pages
[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", '/combine_selected',
8                   'data-href' => url_for('/combine_selected'),
9                   'data-selection-param-name' => 'selection[]',
10                   'data-selection-action' => 'combine',
11                   'data-remote' => true,
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.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             <%= link_to(raw('<i class="fa fa-search"></i>'),
45                         link_params.merge(disposition: 'inline'),
46                         {title: "View #{file_path}", class: "btn btn-info btn-sm"}) %>
47             <%= link_to(raw('<i class="fa fa-download"></i>'),
48                         link_params.merge(disposition: 'attachment'),
49                         {title: "Download #{file_path}", class: "btn btn-info btn-sm"}) %>
50           </div>
51
52           <div class="row pull-left">
53             <div class="col-md-1">
54               <% if !defined? no_checkboxes or !no_checkboxes %>
55               <%= check_box_tag 'uuids[]', "#{@object.uuid}/#{file_path}", false, {
56                     :class => 'persistent-selection',
57                     :friendly_type => "File",
58                     :friendly_name => "#{@object.uuid}/#{file_path}",
59                     :href => url_for(controller: 'collections', action: 'show_file',
60                                      uuid: @object.portable_data_hash, file: file_path),
61                     :title => "Include #{file_path} in your selections",
62                   } %>
63               <% end %>
64             </div>
65
66             <% if CollectionsHelper::is_image(filename) %>
67               <div class="collection_files_name col-md-9"><i class="fa fa-fw fa-bar-chart-o"></i> <%= filename %></div>
68              </div>
69                 <%= link_to(image_tag("#{url_for @object}/#{file_path}"),
70                             link_params.merge(disposition: 'inline'),
71                             {title: file_path}) %>
72             <% else %>
73               <div class="collection_files_name col-md-9"><i class="fa fa-fw fa-file"></i> <%= filename %></div>
74              </div>
75             <% end %>
76           </div>
77         </li>
78       <% end  # if file or directory %>
79     <% end  # file_tree.each %>
80     <%= raw(dirstack.map { |_| "</ul>" }.join("</li>")) %>
81   <% end  # if file_tree %>
82
83   <% content_for :footer_html do %>
84   <div id="collection-sharing-modal-window" class="modal fade" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"></div>
85   <% end %>
86
87 </div>