SMERM/EMUForm

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

Summary

Maintainability
Test Coverage
<%= form_for(@work) do |f| %>
  <% if @work.errors.any? %>
    <div id="error_explanation">

      <ul>
      <% @work.errors.full_messages.each do |message| %>
        <li><%= message %></li>
      <% end %>
      </ul>
    </div>
  <% end %>

    <div class="field">
      <%= f.label :category %><br>
      <%= f.collection_select :category_id, Edition.current.categories, :id, :full_title, prompt: true %>
    </div>
    <div class="field">
      <%= f.label :title %><br>
      <%= f.text_field :title %>
    </div>
    <div class="field">
      <%= f.label :year %><br>
      <%= f.date_select :year, :start_year=>Time.zone.now.year, :end_year=>1900, :discard_day=>true, :discard_month=>true %>
    </div>
    <div class="field">
      <%= f.label :duration %><br>
      <%= f.time_select :duration, :include_seconds=>true, :prompt => true %>
    </div>
    <div class="field">
      <%= f.label 'Description:' %><br>
      <em><%= f.label 'e.g. sound diffusion setup for Acousmatic works, a list of Instruments for Live Electronics works' =%></em>
      <%= f.text_field :instruments %>
    </div>
    <div class="field"> <%= f.label 'Program Notes (in english)' %><br>
      <%= f.text_area :program_notes_en %>
    </div>
    <div class="field"> <%= f.label 'Note di Programma (in italiano - optional)' %><br>
      <%= f.text_area :program_notes_it %>
    </div>

    <hr>

    <% unless @work.new_record? %>
      <div class="authors">
         <%= f.label 'Associated authors' %><br />

         <table class="table" id="authors">
           <thead>
             <th>Name</th>
             <th>Year</th>
             <th>Roles</th>
             <th></th>
             <th></th>
             <th></th>
           </thead>
           <tbody>
             <%= render partial: 'authors/author_item', collection: @work.authors.uniq %>
           </tbody>
         </table>

      </div>
        <%= link_to 'Add new author', new_work_author_path(@work), class:"btn" %>
        <%= link_to 'Add new files', attach_file_work_path(@work), class:"btn" %>


    <% end %>

  <div class="actions">
    <%= f.submit 'Select author(s)', class:"btn" %>
  </div>
<% end %>