unepwcmc/SAPI

View on GitHub
app/views/admin/taxon_concepts/_basic_info.html.erb

Summary

Maintainability
Test Coverage
<div class="row-fluid header">
  <h1 class="<%= @taxon_concept.taxonomy.name.downcase %>" title="<%= @taxon_concept.rank.name %>">
    <%= @taxon_concept.full_name %>
    <span>
      <%= link_to 'in Species+', speciesplus_taxon_concept_url(@taxon_concept),
        title: 'View in Species+',
        alt: 'Link to Species+'
      %>
    </span>
  </h1>
  <dl class="pull-right well well-small dl-horizontal">
    <dt>Created:</dt><dd><%= @taxon_concept.created_at.strftime("%d/%m/%Y") %> (<%= @taxon_concept.creator.try(:name) || "DATA_IMPORT" %>)</dd>
    <dt>Updated:</dt><dd><%= @taxon_concept.updated_at.strftime("%d/%m/%Y") %> (<%= @taxon_concept.updater.try(:name) || "DATA_IMPORT" %>)</dd>
    <dt>Associations updated:</dt><dd><%= @taxon_concept.dependents_updated_at && @taxon_concept.dependents_updated_at.strftime("%d/%m/%Y") %> (<%= @taxon_concept.dependents_updater.try(:name) || "DATA_IMPORT" %>)</dd>
  </dl>
  <%= link_to edit_icon, edit_admin_taxon_concept_url(@taxon_concept), :remote => true %>
  <% if can? :destroy, @taxon_concept %>
    <%= link_to delete_icon, admin_taxon_concept_url(@taxon_concept), 
      data: { confirm: "Warning: you are about to delete data. Are you sure?" }, :method => :delete %>
  <% end %>
  <%= @taxon_concept.author_year %>
  <% if @taxon_concept.tag_list %>
    <%= tag_list(@taxon_concept.tag_list) %><br />
  <% end %>
  <span>NAME STATUS:</span> <%= @taxon_concept.name_status %><br>
  <% if @taxon_concept.has_accepted_names? %>
    <div>
      <span>SYNONYM OF:</span>
      <ul>
        <% @taxon_concept.inverse_synonym_relationships.includes(:taxon_concept).each do |rel| %>
          <li>
            <%= link_to rel.taxon_concept.try(:full_name),
              admin_taxon_concept_names_url(taxon_concept_id: rel.taxon_concept_id)
            %>
            <% if can? :destroy, rel %>
              <%= link_to delete_icon,
                admin_taxon_concept_synonym_relationship_url(rel.taxon_concept, rel),
                data: { confirm: "Warning: you are about to delete data. Are you sure?" },
                :method => :delete %>
            <% end %>
          </li>
        <% end %>
      </ul>
    </div>
  <% elsif @taxon_concept.has_hybrid_parents? %>
    <div>
      <span>HYBRID OF:</span>
      <ul>
        <% @taxon_concept.inverse_hybrid_relationships.includes(:taxon_concept).each do |rel| %>
          <li>
            <%= link_to rel.taxon_concept.try(:full_name),
              admin_taxon_concept_names_url(taxon_concept_id: rel.taxon_concept_id)
            %>
            <% if can? :destroy, rel %>
              <%= link_to delete_icon,
                admin_taxon_concept_hybrid_relationship_url(rel.taxon_concept, rel),
                data: { confirm: "Warning: you are about to delete data. Are you sure?" },
                :method => :delete %>
            <% end %>
          </li>
        <% end %>
      </ul>
    </div>
  <% elsif @taxon_concept.has_accepted_names_for_trade_name? %>
    <div>
      <span>TRADE NAME OF:</span>
      <ul>
        <% @taxon_concept.inverse_trade_name_relationships.includes(:taxon_concept).each do |rel| %>
          <li>
            <%= link_to rel.taxon_concept.try(:full_name),
              admin_taxon_concept_names_url(taxon_concept_id: rel.taxon_concept_id)
            %>
            <% if can? :destroy, rel %>
              <%= link_to delete_icon,
                admin_taxon_concept_trade_name_relationship_url(rel.taxon_concept, rel),
                data: { confirm: "Warning: you are about to delete data. Are you sure?" },
                :method => :delete %>
            <% end %>
          </li>
        <% end %>
      </ul>
    </div>
  <% end %>
  <%= ancestors_path(@taxon_concept) %>
</div>

<% case @taxon_concept.name_status %>
<% when 'A' %>
  <%= admin_new_taxon_concept_modal(nested: true, title: 'Edit Taxon Concept') %>
<% when 'N' %>
  <%= admin_new_n_name_modal(nested: true, title: 'Edit Taxon Concept') %>
<% when 'S' %>
  <%= admin_new_synonym_modal(nested: true, title: 'Edit Taxon Concept') %>
<% when 'T' %>
  <%= admin_new_trade_name_modal(nested: true, title: 'Edit Taxon Concept') %>
<% when 'H' %>
  <%= admin_new_hybrid_modal(nested: true, title: 'Edit Taxon Concept') %>
<% end %>
<% unless @taxon_concept.is_synonym? || @taxon_concept.is_hybrid? || @taxon_concept.is_trade_name? %>
<ul id="taxon-concept-tabs" class="nav nav-tabs">

  <% @taxon_concept.designations.each do |d| %>
    <% if d.is_cites? %>
      <li class="dropdown <%= if @designation && @designation.is_cites? ||
        %w(quotas taxon_concept_cites_suspensions).include?(controller_name) then 'active' end %>">
        <a href="#" class="dropdown-toggle" data-toggle="dropdown">CITES legislation<b class="caret"></b></a>
        <ul class="dropdown-menu">
          <li class="<%= if controller_name == "listing_changes" && @designation.is_cites? then "active" end%>">
            <%= link_to "CITES listings", admin_taxon_concept_designation_listing_changes_path(@taxon_concept, d) %>
          </li>
          <li class="<%= if controller_name == 'quotas' then 'active' end%>">
            <%= link_to "CITES Quotas", admin_taxon_concept_quotas_path(@taxon_concept) %>
          </li>
          <li class="<%= if controller_name == 'taxon_concept_cites_suspensions' then 'active' end%>">
            <%= link_to "CITES Suspensions", admin_taxon_concept_cites_suspensions_path(@taxon_concept) %>
          </li>
          <li class="<%= if controller_name == 'cites_captivity_processes' then 'active' end%>">
            <%= link_to "CITES Captivity processes", admin_taxon_concept_cites_captivity_processes_path(@taxon_concept) %>
          </li>
        </ul>
      </li>
    <% elsif d.is_eu? %>
      <li class="dropdown <%= if @designation &&@designation.is_eu? ||
        %w(eu_opinions eu_suspensions).include?(controller_name) then 'active' end %>">
        <a href="#" class="dropdown-toggle" data-toggle="dropdown">EU legislation <b class="caret"></b></a>
        <ul class="dropdown-menu">
          <li class="<%= if controller_name == "listing_changes" && @designation.is_eu? then "active" end%>">
            <%= link_to "EU listings", admin_taxon_concept_designation_listing_changes_path(@taxon_concept, d) %>
          </li>
          <li class="<%= if controller_name == 'eu_opinions' then 'active' end%>">
            <%= link_to "EU Opinions", admin_taxon_concept_eu_opinions_path(@taxon_concept) %>
          </li>
          <li class="<%= if controller_name == 'eu_suspensions' then 'active' end%>">
            <%= link_to "EU Suspensions", admin_taxon_concept_eu_suspensions_path(@taxon_concept) %>
          </li>
        </ul>
      </li>
    <% elsif d.is_cms? %>
      <li class="<%= if @designation && @designation.is_cms? then 'active' end %>">
        <%= link_to "CMS listings", admin_taxon_concept_designation_listing_changes_path(@taxon_concept, d) %>
      </li>
      <li class="<%= if @taxon_instruments then 'active' end %>">
        <%= link_to "Instruments", admin_taxon_concept_taxon_instruments_path(@taxon_concept) %>
      </li>
    <% end %>
  <% end %>
  <li class="<%= if controller_name == 'names' then 'active' end %>">
    <%= link_to "Names", admin_taxon_concept_names_path(@taxon_concept) %>
  </li>
  <li class="<%= if controller_name == 'distributions' then 'active' end %>">
    <%= link_to "Distribution", admin_taxon_concept_distributions_path(@taxon_concept) %>
  </li>
  <li class="<%= if controller_name == 'taxon_concept_references' then 'active' end %>">
    <%= link_to "References", admin_taxon_concept_taxon_concept_references_path(@taxon_concept) %>
  </li>

  <li class="<%= if controller_name == "taxon_relationships" then "active" end%>">
    <%= link_to "Taxon Relationships", admin_taxon_concept_taxon_relationships_path(@taxon_concept) %>
  </li>

  <li class="<%= if controller_name == "children" then "active" end%>">
    <%= link_to "Children", admin_taxon_concept_children_path(@taxon_concept) %>
  </li>

  <li class="<%= if controller_name == "taxon_concept_comments" then "active" end%>">
    <%= link_to admin_taxon_concept_comments_path(@taxon_concept) do %>
      Notes
      <% if @taxon_concept.has_comments? %>
        <%= taxon_concept_internal_notes_popover_link %>
      <% end %>
    <% end %>
  </li>
</ul>
<% end %>
<div id="taxon_concept_internal_notes_popover" class="hidden">
    <%= taxon_concept_internal_note_display(@taxon_concept.general_comment) %>
    <%= taxon_concept_internal_note_display(@taxon_concept.nomenclature_comment) %>
    <%= taxon_concept_internal_note_display(@taxon_concept.distribution_comment) %>
</table>