unepwcmc/SAPI

View on GitHub
app/views/admin/taxon_concept_references/_form.html.erb

Summary

Maintainability
Test Coverage
<ul class="nav nav-tabs new-reference-tabs">
  <li class="active"><a href="#new"><%= @taxon_concept_reference.new_record? ? "Create new" : "Edit" %> reference</a></li>
  <% if @taxon_concept_reference.new_record? %>
    <li><a href="#search">Search for a reference</a></li>
  <% end %>
</ul>

<%= nested_form_for [:admin, @taxon_concept, @taxon_concept_reference], :remote => true, :html => { :class => "form-horizontal" } do |f| %>
  <%= error_messages_for(@taxon_concept_reference) %>
  <div class="tab-content">
    <div class="tab-pane fade in active" id="new">
      <%= f.fields_for :reference do |ff| %>
        <div class="control-group">
          <%= ff.label :citation %>
          <div class="controls">
            <%= ff.text_area :citation, :class => "input-xxlarge", :disabled => !@taxon_concept_reference.new_record? %>
          </div>
        </div>
      <% end %>
    </div>
    <% if @taxon_concept_reference.new_record? %>
      <div class="tab-pane fade reference_search_form" id="search">
        <div class="control-group">
          <label>Search by citation:</label>
          <div class="controls">
            <%= text_field_tag 'reference[id]', nil, :class =>'input-xxlarge' %>
          </div>
        </div>
      </div>
    <% end %>
    <div class="control-group">
      <div class="controls">
        <label class="checkbox">
          <%= f.check_box :is_standard %>
          Is Standard?
        </label>
      </div>
    </div>
    <div class="control-group">
      <div class="controls">
        <label class="checkbox">
          <%= f.check_box :is_cascaded %>
          Cascade?
        </label>
      </div>
    </div>

    <div class="control-group">
      <%= f.label :excluded_taxon_concepts_ids, "Excluded taxa" %>
      <div class="controls">
        <%= f.hidden_field :excluded_taxon_concepts_ids,
          "data-taxon-concept-scope" => 'descendants',
          "data-taxon-concept-id" => @taxon_concept.id,
          "data-taxonomy-id" => @taxon_concept.taxonomy_id,
          :style => 'width: 600px',
          :id => 'excluded_taxon_concepts_ids',
          :value => @taxon_concept_reference.excluded_taxon_concepts.map{|tc| "#{tc.id}:#{tc.full_name}"}.join(',')
        %>
      </div>
    </div>
  </div>
<% end %>