sanger/sequencescape

View on GitHub
app/views/studies/information/show.html.erb

Summary

Maintainability
Test Coverage

<% add :about, "This page details the current status of a study." -%>
<% if @study.approved? && @study.active? && can?(:create, Submission) -%>
  <% add :menu, "Create Submission" => new_submission_path(study_id: @study.id) -%>
  <% add :menu, "Start a Bulk Submission" => new_bulk_submission_path -%>
<% end -%>
<% add :menu, "Samples" => study_samples_path(@study) -%>
<% add :menu, "Sample Manifests" => sample_manifests_study_path(@study) %>
<% add :menu, "Suppliers" => suppliers_study_path(@study) %>
<% add :menu, "Receptacles (Formerly Assets)" => study_information_receptacles_path(@study) -%>
<% add :menu, "Asset groups" => study_asset_groups_path(@study) -%>
<% add :menu, "Projects" => projects_study_path(@study) -%>
<% if can? :print_asset_group_labels, @study %>
  <% add :menu, "Print Labels" => printing_study_asset_groups_path(@study) -%>
<% end %>
<% add :menu, "&nbsp;" => '' -%>
<% add :menu, "Contacts" => collaborators_study_path(@study) -%>
<% add :menu, "History" => summary_study_information_path(@study) -%>
<% add :menu, "&nbsp;" => '' -%>
<% if can? :activate, @study %>
  <% if @study.active? -%>
    <% add :menu, { 'Deactivate Study' => state_study_path(@study) }   -%>
  <% else -%>
    <% add :menu, { 'Activate Study' => state_study_path(@study) } -%>
  <% end -%>
<% end -%>

<% add :menu, display_follow(@study, current_user, "Study") => follow_study_path(@study) -%>
<% add :menu, pluralize(@study.comments.size, "comment") => study_comments_path(@study) -%>

<% if can? :accession, @study %>
  <% add :menu, @study.accession_number? ? "Update EBI Study data" : "Generate Accession Number" => url_for(controller: '/studies', action: 'accession', id: @study.id) -%>
  <% add :menu, "Generate DAC Accession Number" => url_for(controller: '/studies', action: 'dac_accession', id: @study.id) -%>
  <% add :menu, "Generate Policy Accession Number" => url_for(controller: '/studies', action: 'policy_accession', id: @study.id) -%>
<% end -%>

<% if can? :edit, @study %>
  <% add :menu, "Edit" => edit_study_url(@study) -%>
<% end %>

<% if can? :administer, @study %>
  <% add :menu, "Manage" => url_for(controller: "admin/studies", action: "show", id: @study.id) -%>
<% end %>

<% add :menu, "Submissions" => url_for(controller: "/submissions", action: "study", id: @study.id) -%>

<% add :menu, "QC Reports" => qc_reports_path -%>
<% add :menu, "Study QC Reports" => study_reports_study_path(@study) -%>

<% add :menu, "Accession all Samples" => accession_all_samples_study_path(@study) -%>

<% add :legend_option, icon('fas', 'hourglass-start', 'Pending') => "" -%>
<% add :legend_option, icon('fas', 'cog', 'Started') => "" -%>
<% add :legend_option, icon('far', 'check-circle', 'Passed') => "" -%>
<% add :legend_option, icon('far', 'times-circle', 'Failed') => "" -%>

<%= page_title @study.name, @study.id, titlecase: false %>
<%= alert(:info) do %>
  <h3>Bioinformatician?</h3>
  <p>If you are comfortable in a database, and want programmatic or large scale access to information you may find
    <%= help_link 'these resources', 'Useful+resources+for+bioinformaticians' %> useful.</p>
<% end %>

<div id='content-links'>
 <%= link_to "Study details", properties_study_path(@study) -%>
</div>

<div class='lead'>
  Created on <%= @study.created_at.to_formatted_s(:long) %> <%= @study.state.capitalize %> <br />
  Overall progress: <%= raw(progress_bar(@study.completed)) %>
</div>

<div class="content mt-3">
  <%#
    # This section is supposed to guide the user through generating their first
    # submission on the study. It tries to avoid asking the user to do something
    # that they don't have permission to do, or that the study isn't ready to
    # support. Essentially the pattern looks like this:
    # - If the study isn't approved, warn the user.
    # - If the study has no samples, link to the sample manifests.
    # - If the study is approved, and has samples, link to the submisison page.
    # These links only show if the user has permission to create the appropriate
    # records.
    # JG: I've made some modifications to this section to DRY out a nested
    #     if statement. As a result, there have been some slight modifications
    #     to the behaviour. (Most notably we alwyas show the study summary
    #     information)
    #%>

  <%= display_user_guide(I18n.t('studies.status.not_approved')) unless @study.approved? %>

  <% if @study.samples.empty? && can?(:create, SampleManifest) -%>
    <%= display_user_guide(I18n.t('studies.samples.no_samples_registered'), sample_manifests_study_path(@study)) %>
  <% end -%>

  <%= display_user_guide(I18n.t('studies.status.not_active')) unless @study.active? %>

  <%# Only show the prompt to create a submission if the study is not approved and has no
    # submissions or requests %>
  <% if @study.approved? && !(@submissions.exists? || @study.requests.exists?) && @study.active?  %>
    <%= display_user_guide(I18n.t('studies.guidance.now_create_submission'), new_submission_path(study_id: @study.id)) if can? :create, Order.new(study: @study) %>
  <% end %>

  <%= render partial: "submission_warning" %>
  <%= render partial: "study_summary", locals: { request_types: @request_types } %>
  <%= render partial: "items", locals: {summary: @summary} %>
</div>