Commit a16533a0 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Add groups to search autocomplete. Use alphabetically scope for users order

parent e37a043d
...@@ -3,7 +3,7 @@ class Admin::UsersController < AdminController ...@@ -3,7 +3,7 @@ class Admin::UsersController < AdminController
@admin_users = User.scoped @admin_users = User.scoped
@admin_users = @admin_users.filter(params[:filter]) @admin_users = @admin_users.filter(params[:filter])
@admin_users = @admin_users.search(params[:name]) if params[:name].present? @admin_users = @admin_users.search(params[:name]) if params[:name].present?
@admin_users = @admin_users.order("name ASC").page(params[:page]) @admin_users = @admin_users.alphabetically.page(params[:page])
end end
def show def show
......
...@@ -78,7 +78,8 @@ module ApplicationHelper ...@@ -78,7 +78,8 @@ module ApplicationHelper
end end
def search_autocomplete_source def search_autocomplete_source
projects = current_user.projects.map{ |p| { label: p.name_with_namespace, url: project_path(p) } } projects = current_user.authorized_projects.map { |p| { label: p.name_with_namespace, url: project_path(p) } }
groups = current_user.authorized_groups.map { |group| { label: "<group> #{group.name}", url: group_path(group) } }
default_nav = [ default_nav = [
{ label: "My Profile", url: profile_path }, { label: "My Profile", url: profile_path },
...@@ -113,7 +114,7 @@ module ApplicationHelper ...@@ -113,7 +114,7 @@ module ApplicationHelper
] ]
end end
[projects, default_nav, project_nav, help_nav].flatten.to_json [groups, projects, default_nav, project_nav, help_nav].flatten.to_json
end end
def emoji_autocomplete_source def emoji_autocomplete_source
......
...@@ -80,6 +80,7 @@ class User < ActiveRecord::Base ...@@ -80,6 +80,7 @@ class User < ActiveRecord::Base
scope :admins, where(admin: true) scope :admins, where(admin: true)
scope :blocked, where(blocked: true) scope :blocked, where(blocked: true)
scope :active, where(blocked: false) scope :active, where(blocked: false)
scope :alphabetically, order('name ASC')
class << self class << self
def filter filter_name def filter filter_name
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
%h6 1. Choose people you want in the team %h6 1. Choose people you want in the team
.clearfix .clearfix
= f.label :user_ids, "People" = f.label :user_ids, "People"
.input= select_tag(:user_ids, options_from_collection_for_select(User.active.order('name ASC'), :id, :name), {data: {placeholder: "Select users"}, class: "chosen xxlarge", multiple: true}) .input= select_tag(:user_ids, options_from_collection_for_select(User.active.alphabetically, :id, :name), {data: {placeholder: "Select users"}, class: "chosen xxlarge", multiple: true})
%h6 2. Set access level for them %h6 2. Set access level for them
.clearfix .clearfix
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
%h6 1. Choose people you want in the team %h6 1. Choose people you want in the team
.clearfix .clearfix
= f.label :user_ids, "People" = f.label :user_ids, "People"
.input= select_tag(:user_ids, options_from_collection_for_select(User.not_in_project(@project).order('name').all, :id, :name), {data: {placeholder: "Select users"}, class: "chosen xxlarge", multiple: true}) .input= select_tag(:user_ids, options_from_collection_for_select(User.not_in_project(@project).alphabetically, :id, :name), {data: {placeholder: "Select users"}, class: "chosen xxlarge", multiple: true})
%h6 2. Set access level for them %h6 2. Set access level for them
.clearfix .clearfix
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
%h6 1. Choose people you want in the team %h6 1. Choose people you want in the team
.clearfix .clearfix
= f.label :user_ids, "People" = f.label :user_ids, "People"
.input= select_tag(:user_ids, options_from_collection_for_select(User.active.not_in_project(@project).all, :id, :name), {data: {placeholder: "Select users"}, class: "chosen xxlarge", multiple: true}) .input= select_tag(:user_ids, options_from_collection_for_select(User.active.not_in_project(@project).alphabetically, :id, :name), {data: {placeholder: "Select users"}, class: "chosen xxlarge", multiple: true})
%h6 2. Set access level for them %h6 2. Set access level for them
.clearfix .clearfix
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment