sleepepi/sleepportal

View on GitHub
app/views/searches/_available_files.html.erb

Summary

Maintainability
Test Coverage
<% source_ids = @search.sources.collect{|s| s.id} %>
<span class="large"><strong>All Selected Sources</strong></span><br />
<ul>
<% FileType.available.with_source(source_ids).each_with_index do |file_type| %>
  <% if (file_type.sources.collect{|s| s.id} | source_ids).size == file_type.sources.collect{|s| s.id}.size %>
    <li><%= link_to file_type.name_and_short_extension, load_file_type_search_path(@search, file_type_id: file_type.id), method: :post, remote: true, onclick: "showWaiting('#file_popup_info', ' Loading File Information', true)" %><br /><br /></li>
  <% end %>
<% end %>
</ul>

<% @search.sources.each do |source| %>
<span class="large"><strong><%= source.name %></strong></span><br />
  <ul>
  <% FileType.available.with_source(source.id).each_with_index do |file_type| %>
    <% unless (file_type.sources.collect{|s| s.id} | source_ids).size == file_type.sources.collect{|s| s.id}.size %>
      <% if source.user_has_action?(current_user, "download files") %>
        <li><%= link_to file_type.name_and_short_extension, load_file_type_search_path(@search, file_type_id: file_type.id), method: :post, remote: true, onclick: "showWaiting('#file_popup_info', ' Loading File Information', true)" %><br /><br /></li>
      <% else %>
        <li><span class="quiet" style="text-decoration: line-through;"><%= file_type.name_and_short_extension %></span><br /><br /></li>
      <% end %>
    <% end %>
  <% end %>
    <% unless source.user_has_action?(current_user, "download files") %>
      <li><span class="quiet">You do not have the <span class="source_rule_text">download files</span> access rule for this data source.</span><br /><br /></li>
    <% end %>
  </ul>
<% end %>