summaryrefslogtreecommitdiff
path: root/app/views/users/index.html.erb
blob: 8df0fd07cdb03e21a817238107aff1a440e80979 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<%= form_tag({controller: "users", action: "search_redirect"}, method: :post, style: "margin:0px;height:40px") do %>
  <%= text_field_tag "search", nil, placeholder: "Search for a user", style: "margin:0px;height:40px;width:300px" %>
  <%= submit_tag "Go", class: "btn blue", style: "margin:0px;height:40px;width:40px" %>
  <%= hidden_field_tag "role", params[:role] %>
<% end %>

<h1>
  <%
    if params[:role] && !params[:badge]
      text = "All '#{params[:role]}' users"
    elsif params[:badge] && !params[:role]
      text = "All '#{params[:badge]}' users"
    elsif params[:role] && params[:badge]
      text = "All '#{params[:role]}' and '#{params[:badge]}' users"
    else
      text = "All users"
    end
    text += " that contain '#{params[:search]}'" if params[:search]
  %>
  <%= title text %>
  <% if params[:search] %>
    (<%= @users.select {|u| u.name.downcase.include?(params[:search].downcase) || u.ign.downcase.include?(params[:search].downcase) }.size %>)
  <% else %>
    (<%= @count %>)
  <% end %>

</h1>
<%= link_to "show all", users_path if params[:role] || params[:badge] %>

<div id="userlist">
  <% @users.each do |u| %>
    <div class="list-user">
      <%= link_to(u.avatar(64), u) %>
      <div class="detail">
        <%= render partial: "users/username", locals: { user: u } %><br>
        <i><%= u.ign %></i>
      </div>
    </div>
  <% end %>
  <%= paginate @users %>
</div>