From 5823481d6ef074904c495bb25ee76c86b1972d4e Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Tue, 5 Apr 2011 22:18:49 +0000 Subject: [PATCH] Wrap text custom fields in the issue list (#8064). git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@5332 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/models/query.rb | 8 ++++++++ app/views/issues/_list.rhtml | 2 +- public/stylesheets/application.css | 3 ++- test/functional/issues_controller_test.rb | 15 +++++++++++++++ 4 files changed, 26 insertions(+), 2 deletions(-) diff --git a/app/models/query.rb b/app/models/query.rb index 87663aca8..9f4d6d5c2 100644 --- a/app/models/query.rb +++ b/app/models/query.rb @@ -42,6 +42,10 @@ class QueryColumn def value(issue) issue.send name end + + def css_classes + name + end end class QueryCustomFieldColumn < QueryColumn @@ -68,6 +72,10 @@ class QueryCustomFieldColumn < QueryColumn cv = issue.custom_values.detect {|v| v.custom_field_id == @cf.id} cv && @cf.cast_value(cv.value) end + + def css_classes + @css_classes ||= "#{name} #{@cf.field_format}" + end end class Query < ActiveRecord::Base diff --git a/app/views/issues/_list.rhtml b/app/views/issues/_list.rhtml index 7d3a03c2e..1d08d5498 100644 --- a/app/views/issues/_list.rhtml +++ b/app/views/issues/_list.rhtml @@ -28,7 +28,7 @@ "> <%= check_box_tag("ids[]", issue.id, false, :id => nil) %> <%= link_to issue.id, :controller => 'issues', :action => 'show', :id => issue %> - <% query.columns.each do |column| %><%= content_tag 'td', column_content(column, issue), :class => column.name %><% end %> + <% query.columns.each do |column| %><%= content_tag 'td', column_content(column, issue), :class => column.css_classes %><% end %> <% end -%> diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index 2589b327f..83e786b49 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -127,9 +127,10 @@ tr.project.idnt-8 td.name {padding-left: 11em;} tr.project.idnt-9 td.name {padding-left: 12.5em;} tr.issue { text-align: center; white-space: nowrap; } -tr.issue td.subject, tr.issue td.category, td.assigned_to { white-space: normal; } +tr.issue td.subject, tr.issue td.category, td.assigned_to, tr.issue td.string, tr.issue td.text { white-space: normal; } tr.issue td.subject { text-align: left; } tr.issue td.done_ratio table.progress { margin-left:auto; margin-right: auto;} +tr.issue td. tr.issue.idnt td.subject a {background: url(../images/bullet_arrow_right.png) no-repeat 0 50%; padding-left: 16px;} tr.issue.idnt-1 td.subject {padding-left: 0.5em;} diff --git a/test/functional/issues_controller_test.rb b/test/functional/issues_controller_test.rb index 2630e9684..4c6e33266 100644 --- a/test/functional/issues_controller_test.rb +++ b/test/functional/issues_controller_test.rb @@ -261,6 +261,21 @@ class IssuesControllerTest < ActionController::TestCase assert_kind_of Array, session[:query][:column_names] assert_equal columns, session[:query][:column_names].map(&:to_s) end + + def test_index_with_custom_field_column + columns = %w(tracker subject cf_2) + get :index, :set_filter => 1, :c => columns + assert_response :success + + # query should use specified columns + query = assigns(:query) + assert_kind_of Query, query + assert_equal columns, query.column_names.map(&:to_s) + + assert_tag :td, + :attributes => {:class => 'cf_2 string'}, + :ancestor => {:tag => 'table', :attributes => {:class => /issues/}} + end def test_show_by_anonymous get :show, :id => 1