SpeciesFileGroup/taxonworks

View on GitHub
app/views/sources/_form.html.erb

Summary

Maintainability
Test Coverage
<!-- DEPRECATED, WILL BE REMOVED -->
<h2> Please use the <%= link_to('New source task', new_source_task_path(source_id: @source.id)) %> to create sources, this form will deprecate shortly. </h2>

<% if @source.persisted? %>
  <div class="actions" class="right_float" >
    <%= button_to "Clone", { action: "clone", id: @source.id },
      data: { confirm: "Clone this record? Changes will not be saved!" } %>
  </div>
<% end %>

<%= form_for(@source, as: :source, url: (@source.new_record? ? sources_path : source_path(@source)), method: (@source.new_record? ? :post : :patch)) do |f| %>

  <%= render 'shared/errors', object: @source %>

  <div class="actions">
    <%= f.submit  id: :top_submit %>
  </div>

  <div class="field" id="source_edit_type">
    <%= f.label :type %><br>
    <ul>
      <li> <%= content_tag(:span, 'BibTeX', data: {help: 'The citation is in BibTeX format, the default for TaxonWorks that gives you the most flexibility.'}) -%> <%= f.radio_button :type, 'Source::Bibtex' %> </li>
      <li> <%= content_tag(:span, 'Verbatim', data: {help: 'The citation is a single field, with no parts broken out.'}) -%>  <%= f.radio_button :type, 'Source::Verbatim' %></li>
      <li><span> Person </span> <%= f.radio_button :type, 'Source::Human' %></li>
    </ul>
  </div>

  <div id="fields_for_human" class="flexbox" style="justify-content: normal">
    <%= render partial: '/people/role_picker', locals: {role: SourceSource.new(), object: @source, f: f} %>
  </div>

  <div id="fields_for_bibtex" class="flexbox" style="justify-content: normal">
    <div class="item item1">

      <div class="field">
        <%= f.label :bibtex_type, "BibTeX type", data: {help: 'Type is required for all records. Most will be "article".'} %><br>
        <%= f.select :bibtex_type, options_for_select(VALID_BIBTEX_TYPES, f.object.bibtex_type), :include_blank => true %>
      </div>

      <div class="field">
        <%= f.label :title %><br>
        <%= f.text_area :title, cols: 60, rows: 5 %>
      </div>

      <%= render partial: '/people/role_picker', locals: {role: SourceAuthor.new(), object: @source, f: f} %>

      <div class="side_by_side_fields">
        <div class="field">
          <%= f.label :year, data: {help: 'If you have a single year, the value goes here. If you have two years, the actual year of publication goes here.' } %><br>
          <%= f.number_field :year, in: 1500..5.years.from_now.year %>
        </div>

        <div class="field">
          <%= f.label :year_suffix, data: {help: "The \"a\" of 1920a. Usage is recommend only for historical reference, new systems should depend advanced search, hyperlinks etc. to determine a source's identity."} %><br>
          <%= f.text_field :year_suffix, size: 4 %>
        </div>

        <div class="field">
          <%= f.label :stated_year, data: {help: 'Use only if Year is provided, and it differs from the actual year of publication.  See Year.'} %><br>
          <%= f.number_field :stated_year, in: 1500..5.years.from_now.year %>
        </div>
      </div>

      <div class="side_by_side_fields">
        <div class="field">
          <%= f.label :month, data: {help: 'Values are in format of legal BibTeX.'} %><br>
          <%= f.select :month, ::VALID_BIBTEX_MONTHS.dup, include_blank: true %>
        </div>

        <div class="field">
          <%= f.label :day %><br>
          <%= f.number_field :day, max: 31, in: 1..31 %>
        </div>
      </div>

      <div class="field">
        <%= f.label :serial_id %><br>
        <%= render partial: 'workbench/elements/forms/ajax_select',
          locals: {controller: 'serials',
                   object: 'source',
                   method: 'serial_id',
                   tag_id: 'serial_id_for_source',
                   size: '60',
                   display: @source.respond_to?(:serial) ? serial_for_select(@source.serial) : nil} %>
      </div>


      <div class="side_by_side_fields">
        <div class="field">
          <%= f.label :volume %><br>
          <%= f.text_field :volume, size: 6 %>
        </div>
        <div class="field">
          <%= f.label :number %><br>
          <%= f.text_field :number, size: 6 %>
        </div>
      </div>

      <div class="field">
        <%= f.label :pages %><br>
        <%= f.text_field :pages %>
      </div>

      <div class="field">
        <%= f.label :language_id %><br>
        <%= render partial: 'workbench/elements/forms/ajax_select',
          locals: {controller: 'languages',
                    object: 'source',
                    method: 'language_id',
                    tag_id: 'language_id_for_source',
                    size: '60',
                    display: @source.respond_to?(:source_language) ? language_tag(@source.source_language) : nil} %>
      </div>
    </div>

    <div class="item item2">
      <div class="field">
        <%= f.label :booktitle %><br>
        <%= f.text_area :booktitle, rows: 4, cols: 60 %>
      </div>
      <div class="field">
        <%= f.label :chapter %><br>
        <%= f.text_field :chapter %>
      </div>

      <div class="field">
        <%= f.label :edition %><br>
        <%= f.text_field :edition %>
      </div>

      <div class="field">
        <%= f.label :series %><br>
        <%= f.text_field :series %>
      </div>

      <%= render partial: '/people/role_picker', locals: {role: SourceEditor.new(), object: @source, f: f} %>

      <div class="field">
        <%= f.label :organization %><br>
        <%= f.text_field :organization, size: 60 %>
      </div>

      <div class="field">
        <%= f.label :institution %><br>
        <%= f.text_field :institution, size: 60 %>
      </div>

      <div class="field">
        <%= f.label :howpublished %><br>
        <%= f.text_field :howpublished %>
      </div>

      <div class="field">
        <%= f.label :publisher %><br>
        <%= f.text_field :publisher, size: 60 %>
      </div>

      <div class="field">
        <%= f.label :address %><br>
        <%= f.text_area :address, rows: 4, cols: 60 %>
      </div>

      <div class="field">
        <%= f.label :school %><br>
        <%= f.text_field :school %>
      </div>

      <div class="field">
        <%= f.label :copyright %><br>
        <%= f.text_field :copyright %>
      </div>

      <div class="field">
        <%= f.label :translator %><br>
        <%= f.text_field :translator %>
      </div>

      <div class="field">
        <%= f.label :language %><br>
        <%= f.text_field :language %>
      </div>
    </div>

    <div class="item item3">
      <div class="field">
        <%= f.label :abstract %><br>
        <%= f.text_area :abstract, cols: 60, rows: 4  %>
      </div>

      <div class="side_by_side_fields">
        <div class="field">
          <%= f.label :key %><br>
          <%= f.text_field :key, size: 6 %>
        </div>

        <div class="field">
          <%= f.label :crossref %><br>
          <%= f.text_field :crossref, size: 6 %>
        </div>
      </div>

      <div class="field">
        <%= f.label :url %><br>
        <%= f.text_field :url, size: 60 %>
      </div>


      <h3> Verbatim from BibTeX </h3>

      <div class="field">
        <%= f.label :author, 'Author(s)' %><br>
        <%= f.text_field :author, size: 60 %>
      </div>

      <div class="field">
        <%= f.label :editor, 'Editor(s)' %><br>
        <%= f.text_field :editor, size: 60 %>
      </div>

      <div class="field">
        <%= f.label :journal, 'Journal' %><br>
        <%= f.text_field :journal, size: 60 %>
      </div>

      <h3 data-help="These data are from BibTeX but variously automatically translated to normalized values in TW." > BibTeX crosslinks  </h3> 

      <div class="field">
        <%= f.label :doi %><br>
        <%= f.text_field :doi, size: 60 %>
      </div>

      <div class="field">
        <%= f.label :isbn %><br>
        <%= f.text_field :isbn %>
      </div>

      <div class="field">
        <%= f.label :issn %><br>
        <%= f.text_field :issn, size: 60 %>
      </div>

      <div class="field">
        <%= f.label :note %><br>
        <%= f.text_area :note, cols: 60, rows: 4 %>
      </div>

      <div class="field">
        <%= f.label :annote %><br>
        <%= f.text_field :annote %>
      </div>

      <h3 data-help="These are not BibTeX attributes. They are largely used in imports and are reflections of past databases.  Currently you should use Documentation for content, and Tags for keywords. " > TW attributes  </h3>

      <div class="field">
        <%= f.label :verbatim_contents %><br>
        <%= f.text_area :verbatim_contents, cols: 60, rows: 4 %>
      </div>

      <div class="field">
        <%= f.label :verbatim_keywords %><br>
        <%= f.text_area :verbatim_keywords, cols: 60, rows: 4 %>
      </div>

    </div>

  </div>

  <div id="fields_for_verbatim">
    <div class="field">
      <%= f.label :verbatim %><br>
      <%= f.text_area :verbatim, cols: 60, rows: 8 %>
    </div>
  </div>

  <div class="actions">
    <%= f.submit id: :bottom_submit %>
  </div>

<% end %>