AyuntamientoMadrid/participacion

View on GitHub
app/views/admin/officials/search.html.erb

Summary

Maintainability
Test Coverage
<h2><%= t("admin.officials.search.title") %></h2>

<%= render "admin/shared/user_search", url: search_admin_officials_path %>

<% if @users.any? %>

  <h3><%= page_entries_info @users %></h3>

  <table>
    <thead>
        <th scope="col"><%= t("admin.officials.index.name") %></th>
        <th scope="col"><%= t("admin.officials.index.official_position") %></th>
        <th scope="col"><%= t("admin.officials.index.official_level") %></th>
        <th scope="col" class="small-3"><%= t("admin.shared.actions") %></th>
    </thead>
    <tbody>
      <% @users.each do |user| %>
        <tr>
          <td>
            <%= link_to user.name, edit_admin_official_path(user) %>
          </td>
          <td>
            <% if user.official? %>
              <span class="label round level-<%= user.official_level %>">
                <%= user.official_position %>
              </span>
            <% else %>
              <%= t("admin.officials.level_0") %>
            <% end %>
          </td>
          <td>
            <%= t("admin.officials.level_#{user.official_level}") %>
          </td>
          <td>
            <%= render Admin::TableActionsComponent.new(
              user,
              actions: [:edit],
              edit_path: edit_admin_official_path(user),
              edit_text: (t("admin.officials.search.make_official") unless user.official?)
            ) %>
          </td>
        </tr>
      <% end %>
    </tbody>
  </table>
<% else %>
  <div class="callout alert">
    <%= t("admin.officials.search.no_results") %>
  </div>
<% end %>