From 03572ec5692cfe27f77112c79719987c5e265e1a Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sat, 7 Mar 2009 15:58:39 +0000 Subject: [PATCH] Adds a sortable "Project" column to the issue list. It's displayed by default on the cross-project issue list (#2889). It's also available for saved queries. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2566 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/helpers/queries_helper.rb | 2 +- app/models/query.rb | 6 +++++- test/functional/issues_controller_test.rb | 4 ++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app/helpers/queries_helper.rb b/app/helpers/queries_helper.rb index 63d6a5356..b41e66afd 100644 --- a/app/helpers/queries_helper.rb +++ b/app/helpers/queries_helper.rb @@ -40,7 +40,7 @@ module QueriesHelper else case column.name when :subject - h((@project.nil? || @project != issue.project) ? "#{issue.project.name} - " : '') + + h((!@project.nil? && @project != issue.project) ? "#{issue.project.name} - " : '') + link_to(h(value), :controller => 'issues', :action => 'show', :id => issue) when :done_ratio progress_bar(value, :width => '80px') diff --git a/app/models/query.rb b/app/models/query.rb index 84e127b6b..5c9fad5e5 100644 --- a/app/models/query.rb +++ b/app/models/query.rb @@ -92,6 +92,7 @@ class Query < ActiveRecord::Base cattr_reader :operators_by_filter_type @@available_columns = [ + QueryColumn.new(:project, :sortable => "#{Project.table_name}.name"), QueryColumn.new(:tracker, :sortable => "#{Tracker.table_name}.position"), QueryColumn.new(:status, :sortable => "#{IssueStatus.table_name}.position"), QueryColumn.new(:priority, :sortable => "#{Enumeration.table_name}.position", :default_order => 'desc'), @@ -236,7 +237,10 @@ class Query < ActiveRecord::Base def columns if has_default_columns? - available_columns.select {|c| Setting.issue_list_default_columns.include?(c.name.to_s) } + available_columns.select do |c| + # Adds the project column by default for cross-project lists + Setting.issue_list_default_columns.include?(c.name.to_s) || (c.name == :project && project.nil?) + end else # preserve the column_names order column_names.collect {|name| available_columns.find {|col| col.name == name}}.compact diff --git a/test/functional/issues_controller_test.rb b/test/functional/issues_controller_test.rb index 6748f078f..f9ee2d767 100644 --- a/test/functional/issues_controller_test.rb +++ b/test/functional/issues_controller_test.rb @@ -58,6 +58,8 @@ class IssuesControllerTest < Test::Unit::TestCase end def test_index + Setting.default_language = 'en' + get :index assert_response :success assert_template 'index.rhtml' @@ -68,6 +70,8 @@ class IssuesControllerTest < Test::Unit::TestCase # private projects hidden assert_no_tag :tag => 'a', :content => /Issue of a private subproject/ assert_no_tag :tag => 'a', :content => /Issue on project 2/ + # project column + assert_tag :tag => 'th', :content => /Project/ end def test_index_should_not_list_issues_when_module_disabled -- 2.39.5