summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2013-04-03 16:48:28 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2013-04-03 16:48:28 +0000
commit25209273d33de5d690b0c89b4a462b979bfd4324 (patch)
treeb98f13f833bc649e04f4403bae408bf7f48ea208
parent4224a0c3feebda795190dedb8e61521dee2e8ffe (diff)
downloadredmine-25209273d33de5d690b0c89b4a462b979bfd4324.tar.gz
redmine-25209273d33de5d690b0c89b4a462b979bfd4324.zip
Fixed that CSV Export of Spent Time ignores filters and columns selection (#13618).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@11696 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--app/helpers/queries_helper.rb24
-rw-r--r--app/views/timelog/index.html.erb3
-rw-r--r--test/functional/timelog_controller_test.rb40
3 files changed, 66 insertions, 1 deletions
diff --git a/app/helpers/queries_helper.rb b/app/helpers/queries_helper.rb
index 592bba42a..2de6b0c90 100644
--- a/app/helpers/queries_helper.rb
+++ b/app/helpers/queries_helper.rb
@@ -29,6 +29,30 @@ module QueriesHelper
end
end
+ def query_filters_hidden_tags(query)
+ tags = ''.html_safe
+ query.filters.each do |field, options|
+ tags << hidden_field_tag("f[]", field, :id => nil)
+ tags << hidden_field_tag("op[#{field}]", options[:operator], :id => nil)
+ options[:values].each do |value|
+ tags << hidden_field_tag("v[#{field}][]", value, :id => nil)
+ end
+ end
+ tags
+ end
+
+ def query_columns_hidden_tags(query)
+ tags = ''.html_safe
+ query.columns.each do |column|
+ tags << hidden_field_tag("c[]", column.name, :id => nil)
+ end
+ tags
+ end
+
+ def query_hidden_tags(query)
+ query_filters_hidden_tags(query) + query_columns_hidden_tags(query)
+ end
+
def available_block_columns_tags(query)
tags = ''.html_safe
query.available_block_columns.each do |column|
diff --git a/app/views/timelog/index.html.erb b/app/views/timelog/index.html.erb
index 35ddf8121..fa0c20ff3 100644
--- a/app/views/timelog/index.html.erb
+++ b/app/views/timelog/index.html.erb
@@ -27,7 +27,8 @@
<div id="csv-export-options" style="display:none;">
<h3 class="title"><%= l(:label_export_options, :export_format => 'CSV') %></h3>
- <%= form_tag(params.merge({:format => 'csv',:page=>nil}), :method => :get, :id => 'csv-export-form') do %>
+ <%= form_tag(params.slice(:project_id, :issue_id).merge(:format => 'csv', :page=>nil), :method => :get, :id => 'csv-export-form') do %>
+ <%= query_hidden_tags @query %>
<p>
<label><%= radio_button_tag 'columns', '', true %> <%= l(:description_selected_columns) %></label><br />
<label><%= radio_button_tag 'columns', 'all' %> <%= l(:description_all_columns) %></label>
diff --git a/test/functional/timelog_controller_test.rb b/test/functional/timelog_controller_test.rb
index 021f6624c..7b9c9e891 100644
--- a/test/functional/timelog_controller_test.rb
+++ b/test/functional/timelog_controller_test.rb
@@ -548,6 +548,46 @@ class TimelogControllerTest < ActionController::TestCase
assert assigns(:items).first.is_a?(TimeEntry)
end
+ def test_index_at_project_level_should_include_csv_export_dialog
+ get :index, :project_id => 'ecookbook',
+ :f => ['spent_on'],
+ :op => {'spent_on' => '>='},
+ :v => {'spent_on' => ['2007-04-01']},
+ :c => ['spent_on', 'user']
+ assert_response :success
+
+ assert_select '#csv-export-options' do
+ assert_select 'form[action=?][method=get]', '/projects/ecookbook/time_entries.csv' do
+ # filter
+ assert_select 'input[name=?][value=?]', 'f[]', 'spent_on'
+ assert_select 'input[name=?][value=?]', 'op[spent_on]', '&gt;='
+ assert_select 'input[name=?][value=?]', 'v[spent_on][]', '2007-04-01'
+ # columns
+ assert_select 'input[name=?][value=?]', 'c[]', 'spent_on'
+ assert_select 'input[name=?][value=?]', 'c[]', 'user'
+ assert_select 'input[name=?]', 'c[]', 2
+ end
+ end
+ end
+
+ def test_index_cross_project_should_include_csv_export_dialog
+ get :index
+ assert_response :success
+
+ assert_select '#csv-export-options' do
+ assert_select 'form[action=?][method=get]', '/time_entries.csv'
+ end
+ end
+
+ def test_index_at_issue_level_should_include_csv_export_dialog
+ get :index, :project_id => 'ecookbook', :issue_id => 3
+ assert_response :success
+
+ assert_select '#csv-export-options' do
+ assert_select 'form[action=?][method=get]', '/projects/ecookbook/issues/3/time_entries.csv'
+ end
+ end
+
def test_index_csv_all_projects
Setting.date_format = '%m/%d/%Y'
get :index, :format => 'csv'