Defect #33169

Issues CSV export does not include custom fields with "Full width layout" enabled

Added by Go MAEDA 4 months ago. Updated 3 months ago.

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

0%

Category:Issues
Target version:4.1.1
Resolution:Fixed Affected version:4.1.0

Description

Steps to reproduce:

1. Add a long text custom field with "Full width layout" enabled
2. Export issues to CSV. The CSV file does not include the custom field
3. Disable "Full width layout" for the custom field
4. Export issues to CSV. You can see the field in the CSV

0001-Fix-issues-and-spent-time-CSV-export-does-not-includ.patch Magnifier (3.18 KB) Marius BALTEANU, 2020-03-19 23:51

all-columns-radio-button@2x.png (76.3 KB) Go MAEDA, 2020-03-20 02:47

check-on-all-of-block-columns.patch Magnifier (2.53 KB) Yuichi HARADA, 2020-03-26 07:21

csv-export.png (64.1 KB) Marius BALTEANU, 2020-03-29 15:09

0002-Option-to-Check-Uncheck-all-block-columns-in-export.patch Magnifier (3.76 KB) Marius BALTEANU, 2020-03-29 15:15


Related issues

Related to Redmine - Feature #26081: Allow full_width_layout long-text custom fields to appear... Closed
Related to Redmine - Patch #33211: Include block columns (ex: Description, Last notes) in CS... New

Associated revisions

Revision 19632
Added by Go MAEDA 3 months ago

Fix issues and spent time CSV export does not include custom fields with "Full width layout" enabled (#33169).

Patch by Marius BALTEANU.

Revision 19633
Added by Go MAEDA 3 months ago

Option to Check/Uncheck all block columns in export (#33169).

Patch by Marius BALTEANU.

Revision 19634
Added by Go MAEDA 3 months ago

Merged r19632 and r19633 from trunk to 4.1-stable (#33169).

History

#1 Updated by Marius BALTEANU 4 months ago

  • Assignee set to Marius BALTEANU

#2 Updated by Go MAEDA 4 months ago

  • Related to Feature #26081: Allow full_width_layout long-text custom fields to appear in the issue list like 'Description' (as a block column) added

#3 Updated by Marius BALTEANU 4 months ago

#4 Updated by Go MAEDA 4 months ago

Thank you for posting the fix so quickly. But I think full-width columns should be exported even when "All columns" radio button is selected because they are columns.

#5 Updated by Marius BALTEANU 4 months ago

Go MAEDA wrote:

Thank you for posting the fix so quickly. But I think full-width columns should be exported even when "All columns" radio button is selected because they are columns.

Description is a column too and it's not exported when you select "All columns" because "All columns" refers to only inline columns.

Anyway, I think we can fix this for 4.1.1 and we can discuss for 4.2.0 to change the current behaviour to a simplified one where all columns includes all columns, regardless the type of the column and drop the checkboxes for block columns.

#6 Updated by Go MAEDA 4 months ago

I think the style of custom fields (inline / block) is just a UI matter, so it should not affect the exported data. The behavior is a bit confusing for me. Another problem is that users should click many checkboxes to get CSV data including all columns. It is a hassle for users if the project has many full-width custom fields.

However, if it is not easy to get back the behavior of Redmine 4.0, I think that having a button to check/uncheck all checkboxes can mitigate the second problem I mentioned above.

Marius, could you consider adding a check/uncheck button ( ) if you think the dialog should have checkboxes for full-width custom fields?

#7 Updated by Marius BALTEANU 4 months ago

Go MAEDA wrote:

I think the style of custom fields (inline / block) is just a UI matter, so it should not affect the exported data. The behavior is a bit confusing for me. Another problem is that users should click many checkboxes to get CSV data including all columns. It is a hassle for users if the project has many full-width custom fields.

However, if it is not easy to get back the behavior of Redmine 4.0, I think that having a button to check/uncheck all checkboxes can mitigate the second problem I mentioned above.

I'm confused. Are you sure that in Redmine 4.0, selecting "All Columns" without checking any block column, exports all the columns including "Description" and "Last notes"? Can you describe the old behaviour?

#8 Updated by Go MAEDA 4 months ago

Marius BALTEANU wrote:

I'm confused. Are you sure that in Redmine 4.0, selecting "All Columns" without checking any block column, exports all the columns including "Description" and "Last notes"? Can you describe the old behaviour?

In Redmine 4.0, selecting "All columns" does not export "Description" and "Last notes" but exports custom fields with full-width layout is enabled.

"The behavior of Redmine 4.0" I wrote in #33169#note-6 means that selecting "All columns" always exports custom fields with long text format, independent of the custom field's appearance (the value of "Full width layout" option).

#9 Updated by Marius BALTEANU 4 months ago

Go MAEDA wrote:

Marius BALTEANU wrote:

I'm confused. Are you sure that in Redmine 4.0, selecting "All Columns" without checking any block column, exports all the columns including "Description" and "Last notes"? Can you describe the old behaviour?

In Redmine 4.0, selecting "All columns" does not export "Description" and "Last notes" but exports custom fields with full-width layout is enabled.

"The behavior of Redmine 4.0" I wrote in #33169#note-6 means that selecting "All columns" always exports custom fields with long text format, independent of the custom field's appearance (the value of "Full width layout" option).

Yes, but it was this way because of an incomplete implementation of #21705 where the full width columns were considered inline columns. #26081 fixed that issue and generated this one. From my point of view, the existing behaviour is the following:
  • All or Selected columns refers only to inline columns
  • Each block column is shown as a checkbox.

I agree with you that is not the best solution and this is way I proposed to fix this as I proposed and to change totally the behaviour in 4.2.0 in order to have only All and Selected columns, regardless the type of the column (inline, block). I won't change this in a minor release.

#10 Updated by Go MAEDA 4 months ago

Marius BALTEANU wrote:

I agree with you that is not the best solution and this is way I proposed to fix this as I proposed and to change totally the behaviour in 4.2.0 in order to have only All and Selected columns, regardless the type of the column (inline, block). I won't change this in a minor release.

Thank you for the explanation.

I think the most important thing now is to add an ability to export full-width custom fields, putting my opinion aside. I think your patch is one of the good solutions for that and should be merged for 4.1.1.

However, I would like you to add a small feature. Could you consider to add a button to select/deselect all checkboxes? It is useful when issues have many full-width custom fields.

Imagine that each issue has 5 full-width custom fields. When a user wants to export all fields including full-width custom fields, the user should click "All columns", the checkbox for custom field 1, the checkbox for custom field 2, ... and the checkbox for custom field 5. It requires 6 clicks on the dialog before clicking "Export" button. Doing it every time you get a CSV is very tedious. The button to select/deselect all checkboxes can resolve the tediousness.

#11 Updated by Marius BALTEANU 4 months ago

Go MAEDA wrote:

Marius BALTEANU wrote:

I agree with you that is not the best solution and this is way I proposed to fix this as I proposed and to change totally the behaviour in 4.2.0 in order to have only All and Selected columns, regardless the type of the column (inline, block). I won't change this in a minor release.

Thank you for the explanation.

I think the most important thing now is to add an ability to export full-width custom fields, putting my opinion aside. I think your patch is one of the good solutions for that and should be merged for 4.1.1.

However, I would like you to add a small feature. Could you consider to add a button to select/deselect all checkboxes? It is useful when issues have many full-width custom fields.

Imagine that each issue has 5 full-width custom fields. When a user wants to export all fields including full-width custom fields, the user should click "All columns", the checkbox for custom field 1, the checkbox for custom field 2, ... and the checkbox for custom field 5. It requires 6 clicks on the dialog before clicking "Export" button. Doing it every time you get a CSV is very tedious. The button to select/deselect all checkboxes can resolve the tediousness.

I agree, feel free to add this on top of my patch.

#12 Updated by Marius BALTEANU 4 months ago

  • Assignee changed from Marius BALTEANU to Go MAEDA

#13 Updated by Yuichi HARADA 4 months ago

Marius, I understand very well what you want to say. However, many Redmine users do not think that "All columns" means only inline columns.
I suggest adding the following JavaScript to your patch( 0001-Fix-issues-and-spent-time-CSV-export-does-not-includ.patch ).
When you select "All Columns" and not checked any of the block columns, check all of the block columns. Probably, I think that many Redmine users can use it without discomfort.

diff --git a/app/views/issues/index.html.erb b/app/views/issues/index.html.erb
index c4719569d..a0ad8b5e7 100644
--- a/app/views/issues/index.html.erb
+++ b/app/views/issues/index.html.erb
@@ -47,11 +47,21 @@
     <label><%= radio_button_tag 'c[]', '', true %> <%= l(:description_selected_columns) %></label><br />
     <label><%= radio_button_tag 'c[]', 'all_inline' %> <%= l(:description_all_columns) %></label>
   </p>
-  <p>
+  <p id="csv-export-block-columns">
     <% @query.available_block_columns.each do |column| %>
-      <label><%= check_box_tag 'c[]', column.name, @query.has_column?(column) %> <%= column.caption %></label>
+      <label><%= check_box_tag 'c[]', column.name, @query.has_column?(column), :id => nil %> <%= column.caption %></label>
     <% end %>
   </p>
+  <%= javascript_tag do %>
+  $(function(){
+    $('input[type="radio"][value="all_inline"]').click(function(){
+      var block_columns = $('#csv-export-block-columns input[type="checkbox"]');
+      if(block_columns.length && !block_columns.is(':checked')){
+        block_columns.prop('checked', true);
+      }
+    });
+  });
+  <% end %>
   <%= export_csv_encoding_select_tag %>
   <% if @issue_count > Setting.issues_export_limit.to_i %>
   <p class="icon icon-warning">
diff --git a/app/views/timelog/index.html.erb b/app/views/timelog/index.html.erb
index f60b51064..8ee8e4fe7 100644
--- a/app/views/timelog/index.html.erb
+++ b/app/views/timelog/index.html.erb
@@ -40,11 +40,21 @@
     <label><%= radio_button_tag 'c[]', '', true %> <%= l(:description_selected_columns) %></label><br />
     <label><%= radio_button_tag 'c[]', 'all_inline' %> <%= l(:description_all_columns) %></label>
   </p>
-  <p>
+  <p id="csv-export-block-columns">
     <% @query.available_block_columns.each do |column| %>
-      <label><%= check_box_tag 'c[]', column.name, @query.has_column?(:column) %> <%= column.caption %></label>
+      <label><%= check_box_tag 'c[]', column.name, @query.has_column?(:column), :id => nil %> <%= column.caption %></label>
     <% end %>
   </p>
+  <%= javascript_tag do %>
+  $(function(){
+    $('input[type="radio"][value="all_inline"]').click(function(){
+      var block_columns = $('#csv-export-block-columns input[type="checkbox"]');
+      if(block_columns.length && !block_columns.is(':checked')){
+        block_columns.prop('checked', true);
+      }
+    });
+  });
+  <% end %>
   <%= export_csv_encoding_select_tag %>
   <p class="buttons">
     <%= submit_tag l(:button_export), :name => nil, :onclick => "hideModal(this);", :data => { :disable_with => false } %>

#14 Updated by Marius BALTEANU 4 months ago

The patch contains too many lines of duplicated code and it doesn't work very well because the block columns are not unchecked after you select again "Selected columns" (to reproduce: check "All columns" and then check "Selected Columns"). Also, it changes the current behaviour where "Description" and "Last notes" are not selected when you check "All columns".

If we really want to fix this small issue in a minor version, let's do it by wrapping the checkboxes in a fieldset and have the existing green tick to handle the "Check/Uncheck all". Patch attached.

#15 Updated by Go MAEDA 3 months ago

  • Status changed from New to Closed
  • Resolution set to Fixed

#16 Updated by Marius BALTEANU 3 months ago

  • Related to Patch #33211: Include block columns (ex: Description, Last notes) in CSV export when option "All columns" is selected added

Also available in: Atom PDF