YaleSTC/shifts

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

Summary

Maintainability
Test Coverage
<% title "Timeslots for #{@week_template.name}" %>

<div id="all_time_slots">
    <%= render partial: "all_time_slots", locals: {template_time_slots: @template_time_slots} %>
</div>
<p>
    <fieldset class = "index" >
        <legend>Add a new a time slot</legend>
        <%= form_for([@week_template, @template_time_slot], remote: true) do |f| %>
            <div id ="errors">
              <%= render partial: "template_time_slots/error_messages", locals: {f: f} %>
            </div>
            <p>
                Where:<br />
                <% @week_template.signup_locations.each do |location| %>
                    <%= check_box_tag "for_locations[]", location.id %>
                    <%= label_tag "location_#{location.id}", text = location.short_name %>
                    <%= "," unless location == @week_template.signup_locations.last %>
                <% end %>
            </p>
            <p>
                Start time:<br />
                <%= f.time_select "start_time", {
                                                                start_time: @start,
                                                                end_time: @end,
                                                                include_start_time: true,
                                                                include_end_time: false,
                                                                default: @start} %>
            </p>
            <p>
                End time:<br />
                <%= f.time_select "end_time", {
                                                                start_time: @start,
                                                                end_time: @end,
                                                                include_start_time: false,
                                                                include_end_time: true,
                                                                default: @end} %>
            </p>
            <p>
                Weekday:<br />
                <% RequestedShift::WEEK_DAY_SELECT.each do |day| %>
                    <%= check_box "template_time_slot[day]", day[1].to_i %> <%= "#{day[0][0..2]}" %>
                <% end %>
            </p>
            <%= f.submit 'Add' %>
        <% end %>
    </fieldset>
</p>

<%= link_to "Back to templates", templates_path %>