rubyforgood/babywearing

View on GitHub
app/views/carriers/_carrier_form.html.erb

Summary

Maintainability
Test Coverage
<%= form_for @carrier do |form| %>
  <%= form_errors @carrier %>

  <div class="form-group">
    <%= form.label :name %>
    <%= form.text_field :name, class: "form-control" %>
  </div>

  <div class="form-group">
    <%= form.label :item_id %>
    <%= form.text_field :item_id, class: "form-control" %>
  </div>

  <div class="form-group">
    <%= form.label :manufacturer %>
    <%= form.text_field :manufacturer, class: "form-control" %>
  </div>

  <div class="form-group">
    <%= form.label :model %>
    <%= form.text_field :model, class: "form-control" %>
  </div>

  <div class="form-group">
    <%= form.label :color %>
    <%= form.text_field :color, class: "form-control" %>
  </div>

  <div class="form-group">
    <%= form.label :size %>
    <%= form.text_field :size, class: "form-control" %>
  </div>

  <div class="form-group">
    <%= form.label :weight_limit, "Weight Limit(in lbs)" %>
    <%= form.number_field :weight_limit, class: "form-control" %>
  </div>

  <div class="form-group">
    <%= form.label :safety_link, 'Safety Link' %>
    <%= form.text_field :safety_link, class: "form-control" %>
  </div>

  <div class="form-group">
    <%= form.label :home_location_id, 'Home Location' %>
    <%= form.collection_select :home_location_id, @locations, :id, :name, {}, class: "form-control" %>
  </div>

  <div class="form-group">
    <%= form.label :current_location_id, 'Current Location' %>
    <%= form.collection_select :current_location_id, @locations, :id, :name, {}, class: "form-control" %>
  </div>

  <div class="form-group">
    <%= form.label :category_id %>
    <%= form.collection_select :category_id, @categories, :id, :name, {}, class: "form-control" %>
  </div>

  <div class="form-group">
    <%= form.label :state %>
    <% if @carrier.checked_out? %>
      <div><%= link_to "Checked Out", carrier_path(@carrier) %></div>
    <% else %>
      <%= form.select :state, carrier_editable_states_for_select, {}, { class: "form-control" } %>
    <% end %>
  </div>

  <div class="form-group">
    <%= form.label :default_loan_length_days, 'Default Loan Length' %>
    <%= form.number_field :default_loan_length_days, class: "form-control" %> days
  </div>

  <div class="form-group">
    <%= form.label :notes %>
    <%= form.text_area :notes, rows: 4, class: "form-control" %>
  </div>

  <div class="form-group">
    <% if @carrier.photos.attached? %>
      <% @carrier.photos.each do |photo| %>
        <div class="card col-3">
          <%= image_tag(photo.variant(resize: "100x100").processed, class: "card-img-top") %>
          <div class="card-body">
            <%= link_to 'Remove', photo_path(photo.id), method: :delete, data: { confirm: 'Are you sure?' }, class: "btn btn-danger" %>
          </div>
        </div>
      <% end %>
    <% end%>
  </div>

  <div class="form-group">
    <%= form.label :photos, class: "pl-1 mb-0" %>
    <%= form.file_field :photos, multiple: true, class: "btn pl-1" %>
  </div>

  <%= form.submit class: "btn btn-primary" %>
<% end %>