Project

General

Profile

Feature #29482 » 0002-Filter-after-projects.patch

Marius BĂLTEANU, 2019-09-28 18:45

View differences:

app/models/project_query.rb
20 20
class ProjectQuery < Query
21 21

  
22 22
  self.queried_class = Project
23
  self.view_permission = :search_project
23 24

  
24 25
  self.available_columns = []
25 26

  
......
31 32
  def initialize_available_filters
32 33
    add_available_filter "status",
33 34
      :type => :list, :values => lambda { project_statuses_values }
35
    add_available_filter("id",
36
      :type => :list, :values => lambda { project_values }, :label => :field_project
37
    )
34 38
    add_available_filter "name", :type => :text
35 39
    add_available_filter "description", :type => :text
36 40
    add_available_filter "is_public",
app/models/query.rb
904 904
        end
905 905
      end
906 906

  
907
      if field == 'project_id'
907
      if field == 'project_id' || (self.type == 'ProjectQuery' && field == 'id')
908 908
        if v.delete('mine')
909 909
          v += User.current.memberships.map(&:project_id).map(&:to_s)
910 910
        end
test/functional/projects_controller_test.rb
56 56
    assert_select 'feed>entry', :count => Project.visible(User.current).count
57 57
  end
58 58

  
59
  def test_index_with_project_filter_is_my_projects
60
    @request.session[:user_id] = 2
61

  
62
    get :index, :params => {
63
      :f => ['id'],
64
      :op => {'id' => '='},
65
      :v => {'id' => ['mine']}
66
    }
67

  
68
    assert_response :success
69

  
70
    assert_select 'div#projects-index ul' do
71
      assert_select 'a.project',  3
72
      assert_select 'a', :text => 'eCookbook'
73
      assert_select 'a', :text => 'OnlineStore'
74
      assert_select 'a', :text => 'Private child of eCookbook'
75
    end
76
  end
77

  
59 78
  def test_autocomplete_js
60 79
    get :autocomplete, :params => {
61 80
        :format => 'js',
(7-7/16)