rubyforgood/casa

View on GitHub
app/views/supervisors/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="title mb-30">
        <h1>Supervisors</h1>
      </div>
    </div>
    <!-- end col -->
    <div class="col-md-6">
      <div class="breadcrumb-wrapper mb-30">
        <span class="ml-5">
        <div class="dropdown pull-left mx-2 supervisor-filters">
          <button class="btn-sm main-btn dark-btn dropdown-toggle" type="button" id="dropdownMenuButton1" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
          <i class="lni lni-funnel mr-10"></i>Filter Status</button>
          <div class="dropdown-menu status-options" aria-labelledby="dropdownMenuButton">
            <div class="dropdown-item form-check checkbox-style">
              <%= check_box_tag "status_option_active", "true", true,
                            class: "active form-check-input",
                            data: { value: "true" } %>
              <%= label_tag "status_option_active", "Active", class: "form-check-label" %>
            </div>
            <div class="dropdown-item form-check checkbox-style">
              <%= check_box_tag "status_option_inactive", "false", false,
                            class: "inactive form-check-input",
                            data: { value: "false" } %>
              <%= label_tag "status_option_inactive", "Inactive", class: "form-check-label" %>
            </div>
          </div>
        </div>
        </span>
        <span class="ml-5">
          <% if policy(Supervisor).create? %>
            <%= link_to new_supervisor_path, class: "btn-sm main-btn secondary-btn" do %>
              <i class="lni lni-plus mr-10"></i>
              New Supervisor
            <% end %>
          <% end %>
        </span>
      </div>
    </div>
  </div>
</div>

<!-- ========== tables-wrapper start ========== -->
<div class="tables-wrapper">
  <div class="row">
    <div class="col-lg-12">
      <div class="card-style mb-30">
        <h6 class="mb-10">Legend for Supervisor List</h6>
        <p class="text-sm mb-20">
          <span class="status-btn success-bg text-white mb-10">Number of Volunteers attempting contact (within 2 weeks)</span><br>
          <span class="status-btn danger-bg text-white mb-10">Number of Volunteers not attempting contact (within 2 weeks)</span><br>
          <span class="status-btn deactive-bg text-black">Count of Transition Aged Youth</span>
        </p>
        <div class="table-wrapper table-responsive">
          <table
            id="supervisors"
            class="table"
            data-source="<%= datatable_supervisors_path format: :json %>">
            <thead>
            <tr>
              <th><h6>Supervisor Name</h6></th>
              <th><h6>Volunteer Info</h6></th>
              <th><h6>Actions</h6></th>
            </tr>
            <!-- end table row-->
            </thead>
            <tbody>
            <% @supervisors.each do |supervisor| %>
              <tr>
                <td id="name-<%= supervisor.id %>" class="min-width">
                  <%= link_to(supervisor.display_name, edit_supervisor_path(supervisor)) %>
                </td>
                <td class="min-width">
                  <% no_attempt_volunteers = supervisor.no_attempt_for_two_weeks %>
                  <% active_volunteers = (supervisor.active_volunteers - no_attempt_volunteers).nonzero? %>
                  <% transition_volunteers = supervisor.volunteers_serving_transition_aged_youth %>

                    <div class="d-flex flex-row w-100">
                      <% if active_volunteers %>
                        <div class="status-btn success-bg text-white flex-grow-1" style="max-width: <%= (active_volunteers * 15) %>%; text-align: center"><%= active_volunteers %></div>
                      <% end %>
                      <% if no_attempt_volunteers.nonzero? %>
                        <div class="status-btn danger-bg text-white flex-grow-1" style="max-width: <%= (no_attempt_volunteers * 15) %>%; text-align: center"><%= no_attempt_volunteers %></div>
                      <% else %>
                        <div class="flex-grow-1"></div>
                      <% end %>
                    </div>

                    <div class="d-flex flex-row py-2" style="max-width: 50%;">
                      <% if !(active_volunteers || no_attempt_volunteers.nonzero?) %>
                        <div class="status-btn bg-secondary text-white">No assigned volunteers</div>
                      <% else %>
                        <div class="status-btn deactive-bg text-black" style="width:<%= (transition_volunteers * 15) %>; % text-align: center">
                          <%= transition_volunteers %>
                        </div>
                      <% end %>
                    </div>
                </td>
                <td>
                  <%= link_to edit_supervisor_path(supervisor) do %>
                    <div class="action">
                      <button class="text-danger">
                        <i class="lni lni-pencil-alt"></i> Edit
                      </button>
                    </div>
                  <% end %>
                </td>
              </tr>
            <% end %>
            </tbody>
          </table>
          <!-- end table -->
        </div>
      </div>
      <!-- end card -->
    </div>
    <!-- end col -->
  </div>
</div>

<div class="tables-wrapper">
  <div class="row">
    <div class="col-lg-12">
      <div class="card-style mb-30">
        <div class="title mb-30">
          <h2>Volunteers without Supervisors</h2>
        </div>
        <% if @available_volunteers.any? %>
          <div class="table-wrapper table-responsive">
            <table id="active_volunteers" class="table">
              <thead>
              <tr>
                <th>Active volunteers not assigned to supervisors</th>
                <th>Assigned to Case(s)</th>
              </tr>
              <!-- end table row-->
              </thead>
              <tbody>
              <% @available_volunteers.each do |volunteer| %>
                <tr>
                  <td>
                    <%= link_to volunteer.display_name, edit_volunteer_path(volunteer) %>
                  </td>
                  <td>
                    <% volunteer.casa_cases.map do |casa_case| %>
                      <%= link_to(casa_case.case_number, casa_case_path(casa_case)) %> <br>
                    <% end %>
                  </td>
                </tr>
              <% end %>
              </tbody>
            </table>
        <% else %>
          There are no active volunteers without supervisors to display here
        <% end %>
        </div>
      </div>
    </div>
  </div>

  <div class="row">
    <div class="col-lg-12">
      <div class="card-style">
        <div class="title mb-30">
          <h2>Casa Cases without Court Dates</h2>
        </div>
        <div class="table-wrapper table-responsive">
          <table class="table striped-table" id="casa_cases">
            <thead>
              <tr>
                <th>Case Number</th>
                <th>Hearing Type</th>
                <th>Judge</th>
                <th>Status</th>
                <th>Transition Aged Youth</th>
                <th>Assigned To</th>
                <th>Actions</th>
                <th></th>
              </tr>
            </thead>
            <tbody>
              <% @casa_cases.each do |casa_case| %>
                <tr class="<%= casa_case.decorate.inactive_class %>">
                  <td class="min-width"><%= link_to(casa_case.case_number, casa_case) %></td>
                  <td class="min-width"><%= casa_case.hearing_type_name %></td>
                  <td class="min-width"><%= casa_case.judge_name %></td>
                  <td class="min-width"><%= casa_case.decorate.status %></td>
                  <td class="min-width"><%= casa_case.decorate.transition_aged_youth %></td>
                  <td class="min-width">
                    <% if casa_case.active? %>
                      <% if current_user.volunteer? %>
                        <%= safe_join(casa_case.assigned_volunteers.map { |vol|
                      vol.display_name }, ", ") %>
                      <% else %>
                        <%= safe_join(casa_case.assigned_volunteers.map { |vol|
                      link_to(vol.display_name, edit_volunteer_path(vol)) },
                                  ", ") %>
                      <% end %>
                    <% else %>
                      Case was deactivated on: <%= I18n.l(casa_case.updated_at, format: :standard, default: nil) %>
                    <% end %>
                  </td>
                  <td class="min-width">
                    <i class="lni lni-search-alt text-active"></i>
                    <%= link_to "Detail View", casa_case_path(casa_case) %>
                  </td>
                  <td>
                    <i class="lni lni-pencil-alt text-danger"></i>
                    <%= link_to "Edit", edit_casa_case_path(casa_case), class: 'text-danger' %>
                  </td>
                </tr>
              <% end %>
            </tbody>
          </table>
        </div>
      </div>
    </div>
  </div>
</div>