Commit a16533a04a3033772bdde2616ce812a3247e6fb5
1 parent
e37a043d
Exists in
master
and in
4 other branches
Add groups to search autocomplete. Use alphabetically scope for users order
Showing
6 changed files
with
8 additions
and
6 deletions
Show diff stats
app/controllers/admin/users_controller.rb
@@ -3,7 +3,7 @@ class Admin::UsersController < AdminController | @@ -3,7 +3,7 @@ class Admin::UsersController < AdminController | ||
3 | @admin_users = User.scoped | 3 | @admin_users = User.scoped |
4 | @admin_users = @admin_users.filter(params[:filter]) | 4 | @admin_users = @admin_users.filter(params[:filter]) |
5 | @admin_users = @admin_users.search(params[:name]) if params[:name].present? | 5 | @admin_users = @admin_users.search(params[:name]) if params[:name].present? |
6 | - @admin_users = @admin_users.order("name ASC").page(params[:page]) | 6 | + @admin_users = @admin_users.alphabetically.page(params[:page]) |
7 | end | 7 | end |
8 | 8 | ||
9 | def show | 9 | def show |
app/helpers/application_helper.rb
@@ -78,7 +78,8 @@ module ApplicationHelper | @@ -78,7 +78,8 @@ module ApplicationHelper | ||
78 | end | 78 | end |
79 | 79 | ||
80 | def search_autocomplete_source | 80 | def search_autocomplete_source |
81 | - projects = current_user.projects.map{ |p| { label: p.name_with_namespace, url: project_path(p) } } | 81 | + projects = current_user.authorized_projects.map { |p| { label: p.name_with_namespace, url: project_path(p) } } |
82 | + groups = current_user.authorized_groups.map { |group| { label: "<group> #{group.name}", url: group_path(group) } } | ||
82 | 83 | ||
83 | default_nav = [ | 84 | default_nav = [ |
84 | { label: "My Profile", url: profile_path }, | 85 | { label: "My Profile", url: profile_path }, |
@@ -113,7 +114,7 @@ module ApplicationHelper | @@ -113,7 +114,7 @@ module ApplicationHelper | ||
113 | ] | 114 | ] |
114 | end | 115 | end |
115 | 116 | ||
116 | - [projects, default_nav, project_nav, help_nav].flatten.to_json | 117 | + [groups, projects, default_nav, project_nav, help_nav].flatten.to_json |
117 | end | 118 | end |
118 | 119 | ||
119 | def emoji_autocomplete_source | 120 | def emoji_autocomplete_source |
app/models/user.rb
@@ -80,6 +80,7 @@ class User < ActiveRecord::Base | @@ -80,6 +80,7 @@ class User < ActiveRecord::Base | ||
80 | scope :admins, where(admin: true) | 80 | scope :admins, where(admin: true) |
81 | scope :blocked, where(blocked: true) | 81 | scope :blocked, where(blocked: true) |
82 | scope :active, where(blocked: false) | 82 | scope :active, where(blocked: false) |
83 | + scope :alphabetically, order('name ASC') | ||
83 | 84 | ||
84 | class << self | 85 | class << self |
85 | def filter filter_name | 86 | def filter filter_name |
app/views/groups/_new_group_member.html.haml
@@ -5,7 +5,7 @@ | @@ -5,7 +5,7 @@ | ||
5 | %h6 1. Choose people you want in the team | 5 | %h6 1. Choose people you want in the team |
6 | .clearfix | 6 | .clearfix |
7 | = f.label :user_ids, "People" | 7 | = f.label :user_ids, "People" |
8 | - .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}) | 8 | + .input= select_tag(:user_ids, options_from_collection_for_select(User.active.alphabetically, :id, :name), {data: {placeholder: "Select users"}, class: "chosen xxlarge", multiple: true}) |
9 | 9 | ||
10 | %h6 2. Set access level for them | 10 | %h6 2. Set access level for them |
11 | .clearfix | 11 | .clearfix |
app/views/groups/_new_member.html.haml
@@ -5,7 +5,7 @@ | @@ -5,7 +5,7 @@ | ||
5 | %h6 1. Choose people you want in the team | 5 | %h6 1. Choose people you want in the team |
6 | .clearfix | 6 | .clearfix |
7 | = f.label :user_ids, "People" | 7 | = f.label :user_ids, "People" |
8 | - .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}) | 8 | + .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}) |
9 | 9 | ||
10 | %h6 2. Set access level for them | 10 | %h6 2. Set access level for them |
11 | .clearfix | 11 | .clearfix |
app/views/team_members/_form.html.haml
@@ -11,7 +11,7 @@ | @@ -11,7 +11,7 @@ | ||
11 | %h6 1. Choose people you want in the team | 11 | %h6 1. Choose people you want in the team |
12 | .clearfix | 12 | .clearfix |
13 | = f.label :user_ids, "People" | 13 | = f.label :user_ids, "People" |
14 | - .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}) | 14 | + .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}) |
15 | 15 | ||
16 | %h6 2. Set access level for them | 16 | %h6 2. Set access level for them |
17 | .clearfix | 17 | .clearfix |