rubyforgood/casa

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

Summary

Maintainability
Test Coverage
<div class="title-wrapper pt-30">
  <div class="row align-items-center">
    <div class="col-md-6">
      <div class="col-sm-12 dashboard-table-header mb-30">
        <h1>Other Duties</h1>
        <% if current_user.volunteer? %>
          <%= link_to new_other_duty_path, class: "main-btn btn-sm primary-btn btn-hover" do %>
            <i class="lni lni-plus"></i>
            New Duty
          <% end %>
        <% end %>
      </div>
    </div>
  </div>
</div>
<div class="tables-wrapper">
  <div class="row">
    <div class="col-lg-12">
      <div class="card-style mb-30">
        <% if @volunteer_duties.empty? %>
          There are no duties to display!
        <% else %>
          <% @volunteer_duties.each do |volunteer| %>
            <% if volunteer[:other_duties].any? %>
                <% unless current_user.id == volunteer[:volunteer].id %>
                  <%= link_to(volunteer[:volunteer].display_name, volunteer_path(volunteer[:volunteer].id)) %>
                <% end %>
                <div class="table-wrapper table-responsive">
                  <table class="table">
                    <thead>
                    <tr>
                      <th>Duties Occurred</th>
                      <th>Created</th>
                      <th>Duration</th>
                      <th>Title</th>
                    </tr>
                    </thead>
                    <tbody>
                    <% volunteer[:other_duties].decorate.each do |duty| %>
                      <td><%= I18n.l(duty.occurred_at, format: :full, default: nil) %></td>
                      <td><%= I18n.l(duty.created_at, format: :full, default: nil) %></td>
                      <td><%= duty.duration_in_minutes %></td>
                      <td><%= duty.truncate_notes %></td>
                      <% if current_user.volunteer? %>
                        <td><%= link_to "Edit", edit_other_duty_path(duty) %></td>
                      <% end %>
                      </tr>
                    <% end %>
                    </tbody>
                  </table>
                </div>
            <% end %>
          <% end %>
        <% end %>
      </div>
    </div>
  </div>
</div>