diff options
author | Valery Sizov <valery@gitlab.com> | 2016-11-03 13:22:56 +0300 |
---|---|---|
committer | Valery Sizov <valery@gitlab.com> | 2016-11-04 14:41:14 +0300 |
commit | b7dff1b072204c8c2ad480301b3139e4823c41f4 (patch) | |
tree | b880d065fab69692dca0c637b27ae526d66d25ce /app | |
parent | 5ef2bd192aa9b3ecbfc23e83c6984e2a818fb736 (diff) |
Fix: Todos Filter Shows All Users
Diffstat (limited to 'app')
-rw-r--r-- | app/assets/javascripts/users_select.js | 4 | ||||
-rw-r--r-- | app/controllers/autocomplete_controller.rb | 6 | ||||
-rw-r--r-- | app/models/user.rb | 1 | ||||
-rw-r--r-- | app/views/dashboard/todos/index.html.haml | 2 |
4 files changed, 11 insertions, 2 deletions
diff --git a/app/assets/javascripts/users_select.js b/app/assets/javascripts/users_select.js index 3847278e80a..7a2221dbaf5 100644 --- a/app/assets/javascripts/users_select.js +++ b/app/assets/javascripts/users_select.js @@ -23,6 +23,8 @@ $dropdown = $(dropdown); options.projectId = $dropdown.data('project-id'); options.showCurrentUser = $dropdown.data('current-user'); + options.todoFilter = $dropdown.data('todo-filter'); + options.todoStateFilter = $dropdown.data('todo-state-filter'); showNullUser = $dropdown.data('null-user'); showMenuAbove = $dropdown.data('showMenuAbove'); showAnyUser = $dropdown.data('any-user'); @@ -394,6 +396,8 @@ project_id: options.projectId || null, group_id: options.groupId || null, skip_ldap: options.skipLdap || null, + todo_filter: options.todoFilter || null, + todo_state_filter: options.todoStateFilter || null, current_user: options.showCurrentUser || null, push_code_to_protected_branches: options.pushCodeToProtectedBranches || null, author_id: options.authorId || null, diff --git a/app/controllers/autocomplete_controller.rb b/app/controllers/autocomplete_controller.rb index b48668eea87..daa82336208 100644 --- a/app/controllers/autocomplete_controller.rb +++ b/app/controllers/autocomplete_controller.rb @@ -11,9 +11,13 @@ class AutocompleteController < ApplicationController @users = @users.reorder(:name) @users = @users.page(params[:page]) + if params[:todo_filter].present? + @users = @users.todo_authors(current_user.id, params[:todo_state_filter]) + end + if params[:search].blank? # Include current user if available to filter by "Me" - if params[:current_user] && current_user + if params[:current_user].present? && current_user @users = [*@users, current_user] end diff --git a/app/models/user.rb b/app/models/user.rb index af3c0b7dc02..65e96ee6b2e 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -173,6 +173,7 @@ class User < ActiveRecord::Base scope :active, -> { with_state(:active) } scope :not_in_project, ->(project) { project.users.present? ? where("id not in (:ids)", ids: project.users.map(&:id) ) : all } scope :without_projects, -> { where('id NOT IN (SELECT DISTINCT(user_id) FROM members)') } + scope :todo_authors, ->(user_id, state) { where(id: Todo.where(user_id: user_id, state: state).select(:author_id)) } def self.with_two_factor joins("LEFT OUTER JOIN u2f_registrations AS u2f ON u2f.user_id = users.id"). diff --git a/app/views/dashboard/todos/index.html.haml b/app/views/dashboard/todos/index.html.haml index 2411cc45724..e247eebc3fc 100644 --- a/app/views/dashboard/todos/index.html.haml +++ b/app/views/dashboard/todos/index.html.haml @@ -37,7 +37,7 @@ - if params[:author_id].present? = hidden_field_tag(:author_id, params[:author_id]) = dropdown_tag(user_dropdown_label(params[:author_id], 'Author'), options: { toggle_class: 'js-user-search js-filter-submit js-author-search', title: 'Filter by author', filter: true, filterInput: 'input#author-search', dropdown_class: 'dropdown-menu-user dropdown-menu-selectable dropdown-menu-author js-filter-submit', - placeholder: 'Search authors', data: { any_user: 'Any Author', first_user: (current_user.username if current_user), current_user: true, project_id: (@project.id if @project), selected: params[:author_id], field_name: 'author_id', default_label: 'Author' } }) + placeholder: 'Search authors', data: { any_user: 'Any Author', first_user: (current_user.username if current_user), project_id: (@project.id if @project), selected: params[:author_id], field_name: 'author_id', default_label: 'Author', todo_filter: true, todo_state_filter: params[:state] || 'pending' } }) .filter-item.inline - if params[:type].present? = hidden_field_tag(:type, params[:type]) |