Defect #31511

CSV export of time entries report does not honor project filter

Added by Xavier Calland 3 months ago. Updated 3 months ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:Go MAEDA% Done:

0%

Category:Time tracking
Target version:4.0.4
Resolution:Fixed Affected version:4.0.2

Description

When exporting a report of time entries in a projet (from an URL like /project/foo/time_entries/report) the URL used (when the export options dialog is closed) is not the project specific URL (i.e. /time_entries/report.csv and not /project/foo/time_entries/report.csv).

It seems the report.csv is generated source:/trunk/app/views/timelog/report.html.erb@18146#L91 with

<%= report_time_entries_path(:format => 'csv') %>

and the original form_tag source:/trunk/app/views/timelog/report.html.erb@18146#L91 uses

<%= form_tag(_report_time_entries_path(@project, nil), :method => :get, :id => 'query_form') do %>

issue_31511.diff Magnifier (1.27 KB) Xavier Calland, 2019-06-04 10:42


Related issues

Related to Redmine - Feature #26279: Allow switching the encoding to UTF-8 when exporting to CSV Closed
Duplicated by Redmine - Defect #30809: Spent time report > CSV not obeying filters Closed

Associated revisions

Revision 18227
Added by Go MAEDA 3 months ago

CSV export of time entries report does not honor project filter (#31511).

Patch by Xavier Calland.

Revision 18228
Added by Go MAEDA 3 months ago

Merged r18227 from trunk to 4.0-stable (#31511).

History

#1 Updated by Mizuki ISHIKAWA 3 months ago

Thank you for sharing the probrem.
I have confirmed that the following changes solve the problem.

diff --git a/app/views/timelog/report.html.erb b/app/views/timelog/report.html.erb
index ae64a891e1..24425a55d0 100644
--- a/app/views/timelog/report.html.erb
+++ b/app/views/timelog/report.html.erb
@@ -88,8 +88,8 @@
 $(document).ready(function(){
   $('input#csv-export-button').click(function(){
     $('form input#encoding').val($('select#encoding option:selected').val());
-    $('form#query_form').attr('action', '<%= report_time_entries_path(:format => 'csv') %>').submit();
-    $('form#query_form').attr('action', '<%= report_time_entries_path %>');
+    $('form#query_form').attr('action', '<%= _report_time_entries_path(@project, nil, :format => 'csv') %>').submit();
+    $('form#query_form').attr('action', '<%= _report_time_entries_path(@project, nil) %>');
     hideModal(this);
   });
 });

#2 Updated by Xavier Calland 3 months ago

Here is a patch for this issue (its tracker may be changed).

Tests done :
  • Export from "/time_entries/report"
    → uses "/time_entries/report.csv"
  • Export from "/project/foo/time_entries/report"
    → uses "/project/foo/time_entries/report.csv"

#3 Updated by Go MAEDA 3 months ago

  • Target version set to 4.0.4

Setting the target version to 4.0.4.

#4 Updated by Go MAEDA 3 months ago

  • Related to Feature #26279: Allow switching the encoding to UTF-8 when exporting to CSV added

#5 Updated by Go MAEDA 3 months ago

  • Subject changed from CSV export of time entries does not honor project filter to CSV export of time entries report does not honor project filter
  • Status changed from New to Confirmed

#6 Updated by Go MAEDA 3 months ago

  • Status changed from Confirmed to Resolved
  • Assignee set to Go MAEDA
  • Resolution set to Fixed

Committed the fix. Thank you for reporting and fixing this issue.

#7 Updated by Go MAEDA 3 months ago

  • Status changed from Resolved to Closed

#8 Updated by Go MAEDA 2 months ago

  • Duplicated by Defect #30809: Spent time report > CSV not obeying filters added

Also available in: Atom PDF