zeiv/caseadilla

View on GitHub
app/views/caseadilla/users/index.html.erb

Summary

Maintainability
Test Coverage
<h2>Users<%= caseadilla_pagination_details @users %></h2>

<table class="table table-striped table-hover table-condensed">
  <thead>
    <tr>
      <th><%= caseadilla_sort_link 'Email', :email %></th>
      <th><%= caseadilla_sort_link 'Name', :last_name %></th>
      <th>Role</th>
      <th>&nbsp;</th>
    </tr>
  </thead>

  <% @users.each do |user| %> 
    <tr>
      <td><%= caseadilla_table_cell_link user.email, caseadilla_user_path(user) %></td>
      <td><%= caseadilla_table_cell_link user.name, caseadilla_user_path(user) %></td>
      <td><%= caseadilla_table_cell_link user.role_symbols.join(', ').titleize, caseadilla_user_path(user) %></td>
      <td class="delete">
        <% confirm_message = "Are you sure you want to delete #{user.email}?" %>
    
        <% if user.id == current_user.id %>
          <% confirm_message += "\n\nWARNING: This is your user account. You will be signed out if you proceed." %>
        <% end %>
      
        <%= link_to(caseadilla_show_row_icon("trash"), caseadilla_user_path(user), :method => :delete, :data => { :confirm => confirm_message }) %>
      </td>
    </tr>
  <% end %>
</table>

<div class="text-center">
  <%= will_paginate @users %>
</div>

<%= content_for :sidebar do %>
  <li><%= link_to "#{caseadilla_show_icon('plus-sign')}Add a new user".html_safe, new_caseadilla_user_path %></li>
<% end %>