YaleSTC/shifts

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

Summary

Maintainability
Test Coverage
<h1>All requested shifts for <%= @week_template.name %></h1>
<p>
    <table class = "tablesorter">
     <thead>
        <tr>
            <th>User</th>
          <th colspan=2>Preferred</th>
          <th colspan=2>Acceptable</th>
          <th>Day</th>
            <th>Locations</th>
        </tr>
        <tr>
            <th></th>
          <th>Start</th>
          <th>End</th>
          <th>Start</th>
          <th>End</th>
          <th></th>
            <th></th>
        </tr>
    </thead>

    <% @requested_shifts.sort_by{|s| [s.day, s.acceptable_start, s.acceptable_end]}.each do |requested_shift| %>
   <tbody>
    <tr>
            <td><%= requested_shift.user.name %></td>
          <td><%= requested_shift.preferred_start.strftime("%I:%M %p") if requested_shift.preferred_start %></td>
          <td><%= requested_shift.preferred_end.strftime("%I:%M %p") if requested_shift.preferred_end %></td>
          <td><%= requested_shift.acceptable_start.strftime("%I:%M %p") %></td>
          <td><%= requested_shift.acceptable_end.strftime("%I:%M %p") %></td>
          <td><%= RequestedShift::WEEK_DAY_SELECT[requested_shift.day][0]%></td>
            <td><%= requested_shift.locations.collect{|l| l.short_name}.to_sentence %></td>
          <td><%= link_to 'Edit', edit_template_requested_shift_path(@week_template, requested_shift) %></td>
          <td><%= link_to 'Delete', template_requested_shift_path(@week_template, requested_shift), confirm: 'Are you sure?', method: :delete %></td>
        </tr>
   </tbody>
    <% end %>
    </table>
</p>
<p>
<%= link_to 'Back to template', templates_path() %> |
<%= link_to 'View all general shift preferences', template_shift_preferences_path() %>
<%= render partial: "/requested_shifts/schedule/day", collection: [6,0,1,2,3,4,5] %>
<%#= render partial: 'week' %>