YaleSTC/shifts

View on GitHub
app/views/templates/show.html.erb

Summary

Maintainability
Test Coverage
<% title @week_template.name%>


<span style = "float:right"><%= link_to 'Edit This Template', edit_template_path(@week_template) %> |
<%= link_to 'Back', templates_path %> </span> <br /> <br />

<table class = "tablesorter">
 <thead>
  <tr>
    <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>Roles</th>
        <th>Locations</th>
  </tr>
  <tr>
    <th>Max</th>
    <th>Min</th>
    <th>Max</th>
    <th>Min</th>
    <th>Max</th>
    <th>Min</th>
    <th>Max</th>
        <th></th>
        <th></th>
  </tr>
 </thead>
 <tbody>
<tr>
    <td><%= @week_template.max_total_hours %></td>
    <td><%= @week_template.min_total_hours %></td>
    <td><%= @week_template.max_continuous_hours %></td>
    <td><%= @week_template.min_continuous_hours %></td>
    <td><%= @week_template.max_number_of_shifts %></td>
    <td><%= @week_template.min_number_of_shifts %></td>
    <td><%= @week_template.max_hours_per_day %></td>
        <td><%= @week_template.roles.collect{|role| role.name}.to_sentence %></td>
        <td><%= @week_template.timeslot_locations.uniq.collect{|loc| loc.short_name}.to_sentence %></td>
    <td><%= link_to 'View', @week_template %></td>
    <td><%= link_to 'Edit', edit_template_path(@week_template) %></td>
    <td><%= link_to 'Delete', @week_template, confirm: 'Are you sure?', method: :delete %></td>
  </tr>
 </tbody>
</table>

    <%= link_to 'View all submitted shift preferences', template_shift_preferences_path(@week_template) %> |
    <%= link_to 'View all requested shifts', template_requested_shifts_path(@week_template) %>
    </p>
</p>

<%= render partial: "/templates/schedule/day", collection: [6,0,1,2,3,4,5] %>

<% for day in [6,0,1,2,3,4,5] %>
  <% for event in @week_template.requested_shifts.on_day(day) %>
    <% for location in @week_template.timeslot_locations %>
      <div class="tooltip" id="tip_event_<%= event.id %>_<%= location.id %>">
          <a href="#" class="closetooltip" style="float:right;">[X]</a><br/>
                    <%= form_for([@week_template, event]) do |f| %>
                        Submitted start - end:
                        <%= event.acceptable_start.strftime("%I:%M %p") %> - <%= event.acceptable_start.strftime("%I:%M %p") %> <br/>
                Set assigned start - end:
                      <%= f.time_select :assigned_start, {
                                              start_time: event.acceptable_start,
                                              end_time: event.acceptable_end,
                                              default: event.acceptable_start,
                                              include_start_time: true,
                                              include_end_time: false
                                                      } %> -
                        <%= f.time_select :assigned_end, {
                                              start_time: event.acceptable_start,
                                                 end_time: event.acceptable_end,
                                              default: event.acceptable_end,
                                              include_start_time: false,
                                              include_end_time: true
                                                    } %>
                        Set assigned location:
                        <%= select_tag "assigned_location", options_from_collection_for_select(@week_template.signup_locations, "id", "short_name", selected: location.id) %>
                <%= hidden_field_tag "assign_flag", true %>
                        <%= f.submit "Assign" %>
                    <% end %>
          <div style="clear:both;"></div>
      </div>
    <% end %>
  <% end %>
<% end %>