Commit 6b24c375cbf39ad407b504d1ac386566a1571c76

Authored by Dmitriy Zaporozhets
1 parent fd5dc597

style admin -> users page. Search by username too

app/models/user.rb
@@ -138,7 +138,7 @@ class User < ActiveRecord::Base @@ -138,7 +138,7 @@ class User < ActiveRecord::Base
138 end 138 end
139 139
140 def search query 140 def search query
141 - where("name LIKE :query or email LIKE :query", query: "%#{query}%") 141 + where("name LIKE :query OR email LIKE :query OR username LIKE :query", query: "%#{query}%")
142 end 142 end
143 end 143 end
144 144
app/views/admin/users/index.html.haml
@@ -3,56 +3,60 @@ @@ -3,56 +3,60 @@
3 = link_to 'New User', new_admin_user_path, class: "btn btn-small pull-right" 3 = link_to 'New User', new_admin_user_path, class: "btn btn-small pull-right"
4 %br 4 %br
5 5
6 -= form_tag admin_users_path, method: :get, class: 'form-inline' do  
7 - = text_field_tag :name, params[:name], class: "xlarge"  
8 - = submit_tag "Search", class: "btn submit btn-primary"  
9 -%ul.nav.nav-tabs  
10 - %li{class: "#{'active' unless params[:filter]}"}  
11 - = link_to admin_users_path do  
12 - Active  
13 - %span.badge= User.active.count  
14 - %li{class: "#{'active' if params[:filter] == "admins"}"}  
15 - = link_to admin_users_path(filter: "admins") do  
16 - Admins  
17 - %span.badge= User.admins.count  
18 - %li{class: "#{'active' if params[:filter] == "blocked"}"}  
19 - = link_to admin_users_path(filter: "blocked") do  
20 - Blocked  
21 - %span.badge= User.blocked.count  
22 - %li{class: "#{'active' if params[:filter] == "wop"}"}  
23 - = link_to admin_users_path(filter: "wop") do  
24 - Without projects  
25 - %span.badge= User.without_projects.count 6 +.row
  7 + .span3
  8 + .admin-filter
  9 + = form_tag admin_users_path, method: :get, class: 'form-inline' do
  10 + = search_field_tag :name, params[:name], placeholder: 'Name, email or username', class: 'search-text-input span2'
  11 + = button_tag type: 'submit', class: 'btn' do
  12 + %i.icon-search
  13 + %ul.nav.nav-pills.nav-stacked
  14 + %li{class: "#{'active' unless params[:filter]}"}
  15 + = link_to admin_users_path do
  16 + Active
  17 + %small.pull-right= User.active.count
  18 + %li{class: "#{'active' if params[:filter] == "admins"}"}
  19 + = link_to admin_users_path(filter: "admins") do
  20 + Admins
  21 + %small.pull-right= User.admins.count
  22 + %li{class: "#{'active' if params[:filter] == "blocked"}"}
  23 + = link_to admin_users_path(filter: "blocked") do
  24 + Blocked
  25 + %small.pull-right= User.blocked.count
  26 + %li{class: "#{'active' if params[:filter] == "wop"}"}
  27 + = link_to admin_users_path(filter: "wop") do
  28 + Without projects
  29 + %small.pull-right= User.without_projects.count
  30 + %hr
  31 + = link_to 'Reset', admin_users_path, class: "btn btn-cancel"
26 32
27 -%table  
28 - %thead  
29 - %tr  
30 - %th Admin  
31 - %th  
32 - Name  
33 - %i.icon-sort-down  
34 - %th Username  
35 - %th Email  
36 - %th Projects  
37 - %th Edit  
38 - %th.cred Danger Zone!  
39 -  
40 - - @admin_users.each do |user|  
41 - %tr  
42 - %td= check_box_tag "admin", 1, user.admin, disabled: :disabled  
43 - %td= link_to user.name, [:admin, user]  
44 - %td= user.username  
45 - %td= user.email  
46 - %td= user.users_projects.count  
47 - %td= link_to 'Edit', edit_admin_user_path(user), id: "edit_#{dom_id(user)}", class: "btn btn-small"  
48 - %td.bgred  
49 - - if user == current_user  
50 - %span.cred It's you!  
51 - - else  
52 - - if user.blocked  
53 - = link_to 'Unblock', unblock_admin_user_path(user), method: :put, class: "btn btn-small success"  
54 - - else  
55 - = link_to 'Block', block_admin_user_path(user), confirm: 'USER WILL BE BLOCKED! Are you sure?', method: :put, class: "btn btn-small btn-remove"  
56 - = link_to 'Destroy', [:admin, user], confirm: "USER #{user.name} WILL BE REMOVED! Are you sure?", method: :delete, class: "btn btn-small btn-remove"  
57 -  
58 -= paginate @admin_users, theme: "admin" 33 + .span9
  34 + .ui-box
  35 + %h5.title
  36 + Users (#{@admin_users.total_count})
  37 + %ul.well-list
  38 + - @admin_users.each do |user|
  39 + %li
  40 + - if user.blocked?
  41 + %i.icon-lock.cred
  42 + - else
  43 + %i.icon-user.cgreen
  44 + = link_to user.name, [:admin, user]
  45 + - if user.admin?
  46 + %strong.cred (Admin)
  47 + - if user == current_user
  48 + %span.cred It's you!
  49 + .pull-right
  50 + %span.light
  51 + %i.icon-envelope
  52 + = mail_to user.email, user.email, class: 'light'
  53 +  
  54 + = link_to 'Edit', edit_admin_user_path(user), id: "edit_#{dom_id(user)}", class: "btn btn-small"
  55 + - unless user == current_user
  56 + - if user.blocked
  57 + = link_to 'Unblock', unblock_admin_user_path(user), method: :put, class: "btn btn-small success"
  58 + - else
  59 + = link_to 'Block', block_admin_user_path(user), confirm: 'USER WILL BE BLOCKED! Are you sure?', method: :put, class: "btn btn-small btn-remove"
  60 + = link_to 'Destroy', [:admin, user], confirm: "USER #{user.name} WILL BE REMOVED! Are you sure?", method: :delete, class: "btn btn-small btn-remove"
  61 + %li.bottom
  62 + = paginate @admin_users, theme: "gitlab"