1 <div class="selection-action-container" style="padding-left: 1em">
2 <% if !defined? no_checkboxes or !no_checkboxes %>
4 <div class="pull-left">
5 <div class="btn-group btn-group-sm">
6 <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">Selection... <span class="caret"></span></button>
7 <ul class="dropdown-menu" role="menu">
8 <li><%= link_to "Create new collection with selected files", '#',
9 'data-href' => combine_selected_path(
10 action_data: {current_project_uuid: @object.owner_uuid}.to_json
12 'data-selection-param-name' => 'selection[]',
13 'data-selection-action' => 'combine-collections',
15 'data-toggle' => 'dropdown'
20 <div class="pull-right">
21 <%= form_tag collection_path(@object.uuid), {method: 'get'} do %>
22 <input class="form-control" id="file_regex" name="file_regex" placeholder="regular expression" value="<%= params[:file_regex] %>" type="text"/>
23 <button id="file_regex_submit" type="submit" class="btn btn-primary" autofocus>Filter</button>
30 <% file_regex = nil %>
31 <% if params[:file_regex] %>
33 <% file_regex = Regexp.new(params[:file_regex]) %>
34 <% rescue RegexpError %>
35 <% # If the pattern is not a valid regex, quote it %>
36 <% # (i.e. use it as a simple substring search) %>
37 <div class="alert alert-info">
38 <p>The search term <code><%= params[:file_regex] %></code> could not be parsed as a regular expression.</p>
39 <p>Searching for files named <code><%= params[:file_regex] %></code> instead.</p>
41 <% file_regex = Regexp.new(Regexp.quote(params[:file_regex])) %>
45 <% file_tree = @object.andand.files_tree %>
46 <% if file_tree.nil? or file_tree.empty? %>
47 <p>This collection is empty.</p>
49 <ul id="collection_files" class="collection_files">
50 <% dirstack = [file_tree.first.first] %>
51 <% file_tree.reject { |(dirname, filename, size)|
52 # Eliminate any files that don't match file_regex
53 # (or accept all files if no file_regex was given)
54 file_regex and !file_regex.match(filename)
57 .each_with_index do |(dirname, filename, size), index| %>
58 <% file_path = CollectionsHelper::file_path([dirname, filename]) %>
59 <% while dirstack.any? and (dirstack.last != dirname) %>
60 <% dirstack.pop %></ul></li>
63 <% if size.nil? # This is a subdirectory. %>
64 <% dirstack.push(File.join(dirname, filename)) %>
65 <div class="collection_files_row">
66 <div class="collection_files_name"><i class="fa fa-fw fa-folder-open"></i> <%= filename %></div>
68 <ul class="collection_files">
70 <% link_params = {controller: 'collections', action: 'show_file',
71 uuid: @object.portable_data_hash, file: file_path, size: size} %>
72 <div class="collection_files_row">
73 <div class="collection_files_buttons pull-right">
74 <%= raw(human_readable_bytes_html(size)) %>
75 <% disable_search = (Rails.configuration.filename_suffixes_with_view_icon.include? file_path.split('.')[-1]) ? false : true %>
76 <%= link_to(raw('<i class="fa fa-search"></i>'),
77 link_params.merge(disposition: 'inline'),
78 {title: "View #{file_path}", class: "btn btn-info btn-sm", disabled: disable_search}) %>
79 <%= link_to(raw('<i class="fa fa-download"></i>'),
80 link_params.merge(disposition: 'attachment'),
81 {title: "Download #{file_path}", class: "btn btn-info btn-sm"}) %>
84 <div class="collection_files_name">
85 <% if !defined? no_checkboxes or !no_checkboxes %>
86 <%= check_box_tag 'uuids[]', "#{@object.uuid}/#{file_path}", false, {
87 :class => 'persistent-selection',
88 :friendly_type => "File",
89 :friendly_name => "#{@object.uuid}/#{file_path}",
90 :href => url_for(controller: 'collections', action: 'show_file',
91 uuid: @object.portable_data_hash, file: file_path),
92 :title => "Include #{file_path} in your selections",
96 <% if CollectionsHelper::is_image(filename) %>
97 <i class="fa fa-fw fa-bar-chart-o"></i> <%= filename %></div>
99 <div class="collection_files_inline">
100 <%= link_to(image_tag("#{url_for @object}/#{file_path}"),
101 link_params.merge(disposition: 'inline'),
102 {title: file_path}) %>
105 <i class="fa fa-fw fa-file"></i> <%= filename %></div>
109 <% end # if file or directory %>
110 <% end # file_tree.each %>
111 <%= raw(dirstack.map { |_| "</ul>" }.join("</li>")) %>
112 <% end # if file_tree %>
114 <% content_for :footer_html do %>
115 <div id="collection-sharing-modal-window" class="modal fade" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"></div>