summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAzul <azul@leap.se>2012-11-26 19:17:08 +0100
committerAzul <azul@leap.se>2012-11-26 19:17:08 +0100
commitfa58393f4b665434830535b3e0c1a325c31ce03b (patch)
treedff2714a47805f248913fb9b4773a6e267d864b0
parentbf74255d1530fe5852dc6e6c27ef975ce9aa8d3c (diff)
parenta941c89293bcbb067c6152b63765ead38a484b81 (diff)
Merge branch 'feature/admin-users-list' into develop
-rw-r--r--app/assets/stylesheets/application.scss9
-rw-r--r--users/app/assets/javascripts/users.js.coffee4
-rw-r--r--users/app/controllers/users_controller.rb8
-rw-r--r--users/app/models/user.rb1
-rw-r--r--users/app/views/users/index.html.haml18
5 files changed, 38 insertions, 2 deletions
diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss
index 3465431..8dec07d 100644
--- a/app/assets/stylesheets/application.scss
+++ b/app/assets/stylesheets/application.scss
@@ -3,3 +3,12 @@ body {
padding: 40px;
}
@import "bootstrap-responsive";
+
+
+table.table-hover .btn {
+ opacity: 0;
+}
+
+table.table-hover tr:hover .btn {
+ opacity: 1;
+}
diff --git a/users/app/assets/javascripts/users.js.coffee b/users/app/assets/javascripts/users.js.coffee
index f0bb3dd..76a6d79 100644
--- a/users/app/assets/javascripts/users.js.coffee
+++ b/users/app/assets/javascripts/users.js.coffee
@@ -21,6 +21,9 @@ srp.error = (message) ->
else
alert(message)
+pollUsers = (query, process) ->
+ $.get( "/users.json", query: query).done(process)
+
$(document).ready ->
$('#new_user').submit preventDefault
$('#new_user').submit srp.signup
@@ -28,4 +31,5 @@ $(document).ready ->
$('#new_session').submit srp.login
$('.user.form.edit').submit srp.update
$('.user.form.edit').submit preventDefault
+ $('.user.typeahead').typeahead({source: pollUsers});
diff --git a/users/app/controllers/users_controller.rb b/users/app/controllers/users_controller.rb
index 4912ac8..925b584 100644
--- a/users/app/controllers/users_controller.rb
+++ b/users/app/controllers/users_controller.rb
@@ -8,7 +8,13 @@ class UsersController < ApplicationController
respond_to :json, :html
def index
- @users = User.all
+ if params[:query]
+ @users = User.by_login.startkey(params[:query]).endkey(params[:query].succ)
+ else
+ @users = User.by_created_at.descending
+ end
+ @users = @users.limit(10)
+ respond_with @users.map(&:login).sort
end
def new
diff --git a/users/app/models/user.rb b/users/app/models/user.rb
index 39d079a..325c981 100644
--- a/users/app/models/user.rb
+++ b/users/app/models/user.rb
@@ -27,6 +27,7 @@ class User < CouchRest::Model::Base
design do
view :by_login
+ view :by_created_at
end
class << self
diff --git a/users/app/views/users/index.html.haml b/users/app/views/users/index.html.haml
index 7db6038..9e6a179 100644
--- a/users/app/views/users/index.html.haml
+++ b/users/app/views/users/index.html.haml
@@ -1 +1,17 @@
-%h1= User.model_name.human(:count =>@users.count)
+.page-header
+ %h1= User.model_name.human(:count =>User.count)
+.row
+ .span8
+ %h2= params[:query] ? "Users starting with '#{params[:query]}'" : "Last users who signed up"
+ %table.table.table-hover
+ %tr
+ %th Login
+ %th Created
+ %th Action
+ = render @users.all
+ .span4
+ %h4 Find user
+ = form_tag users_path, :method => :get, :class => "form-search" do
+ .input-append
+ = text_field_tag :query, "", :class => "user typeahead span2 search-query", :autocomplete => :off
+ %button.btn{:type => :submit} Search