@@ -29,6 +29,30 module QueriesHelper | |||||
29 | end |
|
29 | end | |
30 | end |
|
30 | end | |
31 |
|
31 | |||
|
32 | def query_filters_hidden_tags(query) | |||
|
33 | tags = ''.html_safe | |||
|
34 | query.filters.each do |field, options| | |||
|
35 | tags << hidden_field_tag("f[]", field, :id => nil) | |||
|
36 | tags << hidden_field_tag("op[#{field}]", options[:operator], :id => nil) | |||
|
37 | options[:values].each do |value| | |||
|
38 | tags << hidden_field_tag("v[#{field}][]", value, :id => nil) | |||
|
39 | end | |||
|
40 | end | |||
|
41 | tags | |||
|
42 | end | |||
|
43 | ||||
|
44 | def query_columns_hidden_tags(query) | |||
|
45 | tags = ''.html_safe | |||
|
46 | query.columns.each do |column| | |||
|
47 | tags << hidden_field_tag("c[]", column.name, :id => nil) | |||
|
48 | end | |||
|
49 | tags | |||
|
50 | end | |||
|
51 | ||||
|
52 | def query_hidden_tags(query) | |||
|
53 | query_filters_hidden_tags(query) + query_columns_hidden_tags(query) | |||
|
54 | end | |||
|
55 | ||||
32 | def available_block_columns_tags(query) |
|
56 | def available_block_columns_tags(query) | |
33 | tags = ''.html_safe |
|
57 | tags = ''.html_safe | |
34 | query.available_block_columns.each do |column| |
|
58 | query.available_block_columns.each do |column| |
@@ -27,7 +27,8 | |||||
27 |
|
27 | |||
28 | <div id="csv-export-options" style="display:none;"> |
|
28 | <div id="csv-export-options" style="display:none;"> | |
29 | <h3 class="title"><%= l(:label_export_options, :export_format => 'CSV') %></h3> |
|
29 | <h3 class="title"><%= l(:label_export_options, :export_format => 'CSV') %></h3> | |
30 |
<%= form_tag(params.merge( |
|
30 | <%= form_tag(params.slice(:project_id, :issue_id).merge(:format => 'csv', :page=>nil), :method => :get, :id => 'csv-export-form') do %> | |
|
31 | <%= query_hidden_tags @query %> | |||
31 | <p> |
|
32 | <p> | |
32 | <label><%= radio_button_tag 'columns', '', true %> <%= l(:description_selected_columns) %></label><br /> |
|
33 | <label><%= radio_button_tag 'columns', '', true %> <%= l(:description_selected_columns) %></label><br /> | |
33 | <label><%= radio_button_tag 'columns', 'all' %> <%= l(:description_all_columns) %></label> |
|
34 | <label><%= radio_button_tag 'columns', 'all' %> <%= l(:description_all_columns) %></label> |
@@ -548,6 +548,46 class TimelogControllerTest < ActionController::TestCase | |||||
548 | assert assigns(:items).first.is_a?(TimeEntry) |
|
548 | assert assigns(:items).first.is_a?(TimeEntry) | |
549 | end |
|
549 | end | |
550 |
|
550 | |||
|
551 | def test_index_at_project_level_should_include_csv_export_dialog | |||
|
552 | get :index, :project_id => 'ecookbook', | |||
|
553 | :f => ['spent_on'], | |||
|
554 | :op => {'spent_on' => '>='}, | |||
|
555 | :v => {'spent_on' => ['2007-04-01']}, | |||
|
556 | :c => ['spent_on', 'user'] | |||
|
557 | assert_response :success | |||
|
558 | ||||
|
559 | assert_select '#csv-export-options' do | |||
|
560 | assert_select 'form[action=?][method=get]', '/projects/ecookbook/time_entries.csv' do | |||
|
561 | # filter | |||
|
562 | assert_select 'input[name=?][value=?]', 'f[]', 'spent_on' | |||
|
563 | assert_select 'input[name=?][value=?]', 'op[spent_on]', '>=' | |||
|
564 | assert_select 'input[name=?][value=?]', 'v[spent_on][]', '2007-04-01' | |||
|
565 | # columns | |||
|
566 | assert_select 'input[name=?][value=?]', 'c[]', 'spent_on' | |||
|
567 | assert_select 'input[name=?][value=?]', 'c[]', 'user' | |||
|
568 | assert_select 'input[name=?]', 'c[]', 2 | |||
|
569 | end | |||
|
570 | end | |||
|
571 | end | |||
|
572 | ||||
|
573 | def test_index_cross_project_should_include_csv_export_dialog | |||
|
574 | get :index | |||
|
575 | assert_response :success | |||
|
576 | ||||
|
577 | assert_select '#csv-export-options' do | |||
|
578 | assert_select 'form[action=?][method=get]', '/time_entries.csv' | |||
|
579 | end | |||
|
580 | end | |||
|
581 | ||||
|
582 | def test_index_at_issue_level_should_include_csv_export_dialog | |||
|
583 | get :index, :project_id => 'ecookbook', :issue_id => 3 | |||
|
584 | assert_response :success | |||
|
585 | ||||
|
586 | assert_select '#csv-export-options' do | |||
|
587 | assert_select 'form[action=?][method=get]', '/projects/ecookbook/issues/3/time_entries.csv' | |||
|
588 | end | |||
|
589 | end | |||
|
590 | ||||
551 | def test_index_csv_all_projects |
|
591 | def test_index_csv_all_projects | |
552 | Setting.date_format = '%m/%d/%Y' |
|
592 | Setting.date_format = '%m/%d/%Y' | |
553 | get :index, :format => 'csv' |
|
593 | get :index, :format => 'csv' |
General Comments 0
You need to be logged in to leave comments.
Login now