rubyforgood/casa

View on GitHub
app/views/learning_hours/_learning_hours_table.html.erb

Summary

Maintainability
Test Coverage
<div class="card card-container">
  <div class="card-body">
    <div class="table-wrapper table-responsive">
      <table class="table learning-hours-list" id="all-learning-hours">
        <thead>
          <tr>
            <th>Title</th>
            <th>Learning Type</th>
            <% if current_user.casa_org.learning_topic_active %>
              <th>Learning Topic</th>
            <% end %>
            <th>Date</th>
            <th>Time Spent</th>
          </tr>
        </thead>
        <tbody>
          <% learning_hours.order(occurred_at: :desc).each do |learning_hour| %>
            <tr>
              <td>
                <% if current_user.volunteer? %>
                  <%= link_to learning_hour.name, learning_hour_path(id: learning_hour.id) %>
                <% else %>
                  <%= learning_hour.name %>
                <% end %>
              </td>
              <td> <%= learning_hour.learning_hour_type.name %> </td>
              <% if current_user.casa_org.learning_topic_active %>
                <td> <%= learning_hour.learning_hour_topic&.name %> </td>
              <% end %>
              <td> <%= learning_hour.occurred_at.strftime("%B %-d, %Y") %> </td>
              <td>
              <% if (learning_hour.duration_hours > 0) %>
                <%= learning_hour.duration_hours %> hr
              <% end %>
              <%= learning_hour.duration_minutes %> min
              </td>
            </tr>
          <% end %>
        </tbody>
      </table>
    </div>
  </div>
</div>