1
0
mirror of https://github.com/meineerde/redmine.git synced 2026-01-10 17:41:31 +00:00

Filter after projects (#29482).

Patch by Marius BALTEANU.

git-svn-id: http://svn.redmine.org/redmine/trunk@18762 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2019-10-19 11:37:30 +00:00
parent 6c5440a21b
commit 80844362db
3 changed files with 24 additions and 1 deletions

View File

@ -20,6 +20,7 @@
class ProjectQuery < Query
self.queried_class = Project
self.view_permission = :search_project
self.available_columns = []
@ -31,6 +32,9 @@ class ProjectQuery < Query
def initialize_available_filters
add_available_filter "status",
:type => :list, :values => lambda { project_statuses_values }
add_available_filter("id",
:type => :list, :values => lambda { project_values }, :label => :field_project
)
add_available_filter "name", :type => :text
add_available_filter "description", :type => :text
add_available_filter "is_public",

View File

@ -905,7 +905,7 @@ class Query < ActiveRecord::Base
end
end
if field == 'project_id'
if field == 'project_id' || (self.type == 'ProjectQuery' && field == 'id')
if v.delete('mine')
v += User.current.memberships.map(&:project_id).map(&:to_s)
end

View File

@ -56,6 +56,25 @@ class ProjectsControllerTest < Redmine::ControllerTest
assert_select 'feed>entry', :count => Project.visible(User.current).count
end
def test_index_with_project_filter_is_my_projects
@request.session[:user_id] = 2
get :index, :params => {
:f => ['id'],
:op => {'id' => '='},
:v => {'id' => ['mine']}
}
assert_response :success
assert_select 'div#projects-index ul' do
assert_select 'a.project', 3
assert_select 'a', :text => 'eCookbook'
assert_select 'a', :text => 'OnlineStore'
assert_select 'a', :text => 'Private child of eCookbook'
end
end
def test_autocomplete_js
get :autocomplete, :params => {
:format => 'js',