YaleSTC/shifts

View on GitHub
app/views/shift_preferences/index.html.erb

Summary

Maintainability
Test Coverage
<h1>All general shift preferences for <%= @week_template.name %> </h1>

<table class = "tablesorter">
 <thead>
  <tr>
    <th>Name</th>
    <th colspan=2 >Total hours</th>
    <th colspan=2 >Continuous hours</th>
    <th colspan=2 >Number of shifts</th>
    <th>Hours per day</th>
    <th colspan=3 >Locations</th>
  </tr>

  <tr>
    <th></th>
    <th>Max</th>
    <th>Min</th>
    <th>Max</th>
    <th>Min</th>
    <th>Max</th>
    <th>Min</th>
    <th>Max</th>
        <th>Prefer</th>
        <th>Able</th>
        <th>Unable</th>
  </tr>
 <thead>

    <tbody>
        <% @shift_preferences.each do |shift_preference| %>
        <tr>
                <td><%= shift_preference.user.name %></td>
            <td><%= shift_preference.max_total_hours %></td>
            <td><%= shift_preference.min_total_hours %></td>
            <td><%= shift_preference.max_continuous_hours %></td>
            <td><%= shift_preference.min_continuous_hours %></td>
            <td><%= shift_preference.max_number_of_shifts %></td>
            <td><%= shift_preference.min_number_of_shifts %></td>
            <td><%= shift_preference.max_hours_per_day %></td>
                <td><%= Location.find(shift_preference.locations_shift_preferences.where(kind: "yes").collect(&:location_id)).collect{|l| l.short_name}.to_sentence %></td>
                <td><%= Location.find(shift_preference.locations_shift_preferences.where(kind: "maybe").collect(&:location_id)).collect{|l| l.short_name}.to_sentence %></td>
                <td><%= Location.find(shift_preference.locations_shift_preferences.where(kind: "no").collect(&:location_id)).collect{|l| l.short_name}.to_sentence %></td>
            <td><%= link_to 'Show', template_shift_preference_path(@week_template, shift_preference) %></td>
            <td><%= link_to 'Edit', edit_template_shift_preference_path(@week_template, shift_preference) %></td>
            <td><%= link_to 'Delete', template_shift_preference_path(@week_template, shift_preference), confirm: 'Are you sure?', method: :delete %></td>
          </tr>
        <% end %>
    </tbody>
</table>

<br />

<%= link_to 'New Shift Preference', new_template_shift_preference_path(@week_template) %>

<br />
<br />

<%= link_to 'Back to Template', templates_path() %> |
<%= link_to 'Go to All Requested Shifts', template_requested_shifts_path() %>