From bf17d976a7be3404e30a0211c4c9b5ef78bf5104 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Wed, 13 Mar 2013 21:37:50 +0200 Subject: [PATCH] add api users filter and integrate users select2 --- app/assets/javascripts/application.js | 1 + app/assets/stylesheets/application.scss | 1 + app/assets/stylesheets/common.scss | 15 +++++++++++++++ app/controllers/application_controller.rb | 2 ++ app/helpers/application_helper.rb | 4 ++++ app/views/team_members/_form.html.haml | 4 +++- lib/api/users.rb | 3 ++- 7 files changed, 28 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 49effdf9c..adb4009fb 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -17,6 +17,7 @@ //= require bootstrap //= require modernizr //= require chosen-jquery +//= require select2 //= require raphael //= require g.raphael-min //= require g.bar-min diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index 6b500b888..f4afc3546 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -5,6 +5,7 @@ *= require jquery.ui.gitlab *= require jquery.atwho *= require chosen + *= require select2 *= require_self */ diff --git a/app/assets/stylesheets/common.scss b/app/assets/stylesheets/common.scss index c967c2d1c..2e7df61e0 100644 --- a/app/assets/stylesheets/common.scss +++ b/app/assets/stylesheets/common.scss @@ -554,3 +554,18 @@ img.emoji { .appear-data { display: none; } + +.ajax-users-select { + width: 400px; +} + +.user-result { + .user-image { + float: left; + } + .user-name { + } + .user-username { + color: #999; + } +} diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 6b72f3252..69d234774 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -152,5 +152,7 @@ class ApplicationController < ActionController::Base def add_gon_variables gon.default_issues_tracker = Project.issues_tracker.default_value + gon.api_token = current_user.private_token + gon.gravatar_url = request.ssl? ? Gitlab.config.gravatar.ssl_url : Gitlab.config.gravatar.plain_url end end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 955dbc172..45972612b 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -169,4 +169,8 @@ module ApplicationHelper end alias_method :url_to_image, :image_url + + def users_select_tag(id) + hidden_field_tag(id, '', class: "ajax-users-select") + end end diff --git a/app/views/team_members/_form.html.haml b/app/views/team_members/_form.html.haml index 63bfbecdc..e45c6f6fc 100644 --- a/app/views/team_members/_form.html.haml +++ b/app/views/team_members/_form.html.haml @@ -11,7 +11,9 @@ %h6 1. Choose people you want in the team .clearfix = f.label :user_ids, "People" - .input= select_tag(:user_ids, options_from_collection_for_select(User.active.not_in_project(@project).alphabetically, :id, :name_with_username), {data: {placeholder: "Select users"}, class: "chosen xxlarge", multiple: true}) + .input + = users_select_tag(:user_ids) + -#= select_tag(:user_ids, options_from_collection_for_select(User.active.not_in_project(@project).alphabetically, :id, :name_with_username), {data: {placeholder: "Select users"}, class: "chosen xxlarge", multiple: true}) %h6 2. Set access level for them .clearfix diff --git a/lib/api/users.rb b/lib/api/users.rb index 6cc3a7e52..1462e7b4c 100644 --- a/lib/api/users.rb +++ b/lib/api/users.rb @@ -9,7 +9,8 @@ module Gitlab # Example Request: # GET /users get do - @users = paginate User + @users = User.scoped + @users = @users.search(params[:search]) if params[:search].present? present @users, with: Entities::User end -- 2.11.0