YaleSTC/shifts

View on GitHub
app/views/timeline/_signup_bar.html.erb

Summary

Maintainability
Test Coverage
<% show_text ||= false %>
<li id="location<%=location.id%>_<%=day%>_free_time" style="width:100%; z-index: -100" class="no_signups"></li>
<% current_block = 0 %>
<% while current_block < @total_blocks %>
  <% style = @signup_bar[current_block] %>
  <% start_block = current_block %>
  <% length = 1 %>
  <% while @signup_bar[current_block+1] == style %>
    <% length += 1 %>
    <% current_block += 1 %>
  <% end %>
    <li id="location<%=location.id%>_<%=day%>_slot" style="width:<%= length / @total_blocks * 100 %>%; left:<%= start_block / @total_blocks * 100 %>%" class="<%=style%> bar">
      <div class="time-slot">
        <div class="center_container">
          <div class="center_content signup_bar">
            <% if show_text and length >= 3 %>
              <%= style == "bar_open click_to_add_new" ? (link_to "sign up", new_shift_path) : "" %>
              <%= style == "bar_full no_signups" ? "full" : "" %>
              <%= style == "bar_pending no_signups" ? "pending" : "" %>
            <% end %>
          </div>
        </div>
      </div>
    </li>
  
  <% current_block += 1 %>
<% end %>