Index: app/helpers/application_helper.rb
===================================================================
--- app/helpers/application_helper.rb (revision 21789)
+++ app/helpers/application_helper.rb (working copy)
@@ -1803,6 +1803,23 @@
end
end
+ def export_csv_separator_select_tag
+ options = [%w(, ,), %w(; ;), %w(: :), %w({tab} {tab}), %w({space} {space})]
+ # Add the separator from translations if it is missing
+ general_csv_separator = l(:general_csv_separator)
+ unless options.index { |option| option.first == general_csv_separator }
+ options << Array.new(2, general_csv_separator)
+ end
+ content_tag(:p) do
+ concat(
+ content_tag(:label) do
+ concat l(:label_fields_separator) + ' '
+ concat select_tag('field_separator', options_for_select(options, general_csv_separator))
+ end
+ )
+ end
+ end
+
# Returns an array of error messages for bulk edited items (issues, time entries)
def bulk_edit_error_messages(items)
messages = {}
Index: app/helpers/queries_helper.rb
===================================================================
--- app/helpers/queries_helper.rb (revision 21789)
+++ app/helpers/queries_helper.rb (working copy)
@@ -319,7 +319,7 @@
def query_to_csv(items, query, options={})
columns = query.columns
- Redmine::Export::CSV.generate(:encoding => params[:encoding]) do |csv|
+ Redmine::Export::CSV.generate(encoding: params[:encoding], field_separator: params[:field_separator]) do |csv|
# csv header fields
csv << columns.map {|c| c.caption.to_s}
# csv lines
Index: app/views/issues/index.html.erb
===================================================================
--- app/views/issues/index.html.erb (revision 21789)
+++ app/views/issues/index.html.erb (working copy)
@@ -59,6 +59,7 @@
<% end %>
<%= export_csv_encoding_select_tag %>
+ <%= export_csv_separator_select_tag %>
<% if @issue_count > Setting.issues_export_limit.to_i %>
<%= l(:setting_issues_export_limit) %>: <%= Setting.issues_export_limit.to_i %>
Index: app/views/projects/_list.html.erb
===================================================================
--- app/views/projects/_list.html.erb (revision 21789)
+++ app/views/projects/_list.html.erb (working copy)
@@ -66,6 +66,7 @@
<%= export_csv_encoding_select_tag %>
+ <%= export_csv_separator_select_tag %>
<%= submit_tag l(:button_export), :name => nil, :onclick => "hideModal(this);", :data => { :disable_with => false } %>
<%= link_to_function l(:button_cancel), "hideModal(this);" %>
Index: app/views/reports/_details.html.erb
===================================================================
--- app/views/reports/_details.html.erb (revision 21789)
+++ app/views/reports/_details.html.erb (working copy)
@@ -32,6 +32,7 @@
<%= l(:label_export_options, :export_format => 'CSV') %>
<%= form_tag(project_issues_report_details_path(@project, :detail => params[:detail], :format => 'csv'), :method => :get, :id => 'csv-export-form') do %>
<%= export_csv_encoding_select_tag %>
+ <%= export_csv_separator_select_tag %>
<%= submit_tag l(:button_export), :name => nil, :onclick => 'hideModal(this);', :data => {:disable_with => false} %>
<%= link_to_function l(:button_cancel), 'hideModal(this);' %>
Index: app/views/roles/permissions.html.erb
===================================================================
--- app/views/roles/permissions.html.erb (revision 21789)
+++ app/views/roles/permissions.html.erb (working copy)
@@ -92,6 +92,7 @@
<%= l(:label_export_options, :export_format => 'CSV') %>
<%= form_tag(permissions_roles_path(:format => 'csv'), :method => :get, :id => 'csv-export-form') do %>
<%= export_csv_encoding_select_tag %>
+ <%= export_csv_separator_select_tag %>
<%= submit_tag l(:button_export), :name => nil, :onclick => 'hideModal(this);', :data => {:disable_with => false} %>
<%= link_to_function l(:button_cancel), 'hideModal(this);' %>
Index: app/views/timelog/index.html.erb
===================================================================
--- app/views/timelog/index.html.erb (revision 21789)
+++ app/views/timelog/index.html.erb (working copy)
@@ -52,6 +52,7 @@
<% end %>
<%= export_csv_encoding_select_tag %>
+ <%= export_csv_separator_select_tag %>
<%= submit_tag l(:button_export), :name => nil, :onclick => "hideModal(this);", :data => { :disable_with => false } %>
<%= link_to_function l(:button_cancel), "hideModal(this);" %>
Index: app/views/timelog/report.html.erb
===================================================================
--- app/views/timelog/report.html.erb (revision 21789)
+++ app/views/timelog/report.html.erb (working copy)
@@ -72,6 +72,7 @@
<%= l(:label_export_options, :export_format => 'CSV') %>
<%= export_csv_encoding_select_tag %>
+ <%= export_csv_separator_select_tag %>
<%= submit_tag l(:button_export), :name => nil, :id => 'csv-export-button' %>
<%= submit_tag l(:button_cancel), :name => nil, :onclick => 'hideModal(this);', :type => 'button' %>
Index: app/views/users/index.html.erb
===================================================================
--- app/views/users/index.html.erb (revision 21789)
+++ app/views/users/index.html.erb (working copy)
@@ -78,6 +78,7 @@
<%= l(:label_export_options, :export_format => 'CSV') %>
<%= export_csv_encoding_select_tag %>
+ <%= export_csv_separator_select_tag %>
<%= submit_tag l(:button_export), :name => nil, :id => 'csv-export-button' %>
<%= submit_tag l(:button_cancel), :name => nil, :onclick => 'hideModal(this);', :type => 'button' %>
Index: lib/redmine/export/csv.rb
===================================================================
--- lib/redmine/export/csv.rb (revision 21789)
+++ lib/redmine/export/csv.rb (working copy)
@@ -31,7 +31,15 @@
class << self
def generate(options = {}, &block)
- col_sep = l(:general_csv_separator)
+ col_sep = options[:field_separator].present? ? options[:field_separator] : l(:general_csv_separator)
+ col_sep = case col_sep
+ when '{tab}'
+ "\t"
+ when '{space}'
+ ' '
+ else
+ col_sep
+ end
encoding = Encoding.find(options[:encoding]) rescue Encoding.find(l(:general_csv_encoding))
str =
Index: test/helpers/application_helper_test.rb
===================================================================
--- test/helpers/application_helper_test.rb (revision 21789)
+++ test/helpers/application_helper_test.rb (working copy)
@@ -2201,6 +2201,15 @@
end
end
+ def test_export_csv_separator_select_tag
+ with_locale 'en' do
+ result = export_csv_separator_select_tag
+ assert_select_in result,
+ "option[selected='selected'][value='#{l(:general_csv_separator)}']",
+ text: l(:general_csv_separator)
+ end
+ end
+
private
def wiki_links_with_special_characters