Feature #37621 » field_separator_in_csv_export_options.patch
app/helpers/application_helper.rb (working copy) | ||
---|---|---|
1803 | 1803 |
end |
1804 | 1804 |
end |
1805 | 1805 | |
1806 |
def export_csv_separator_select_tag |
|
1807 |
options = [%w(, ,), %w(; ;), %w(: :), %w({tab} {tab}), %w({space} {space})] |
|
1808 |
# Add the separator from translations if it is missing |
|
1809 |
general_csv_separator = l(:general_csv_separator) |
|
1810 |
unless options.index { |option| option.first == general_csv_separator } |
|
1811 |
options << Array.new(2, general_csv_separator) |
|
1812 |
end |
|
1813 |
content_tag(:p) do |
|
1814 |
concat( |
|
1815 |
content_tag(:label) do |
|
1816 |
concat l(:label_fields_separator) + ' ' |
|
1817 |
concat select_tag('field_separator', options_for_select(options, general_csv_separator)) |
|
1818 |
end |
|
1819 |
) |
|
1820 |
end |
|
1821 |
end |
|
1822 | ||
1806 | 1823 |
# Returns an array of error messages for bulk edited items (issues, time entries) |
1807 | 1824 |
def bulk_edit_error_messages(items) |
1808 | 1825 |
messages = {} |
app/helpers/queries_helper.rb (working copy) | ||
---|---|---|
319 | 319 |
def query_to_csv(items, query, options={}) |
320 | 320 |
columns = query.columns |
321 | 321 | |
322 |
Redmine::Export::CSV.generate(:encoding => params[:encoding]) do |csv|
|
|
322 |
Redmine::Export::CSV.generate(encoding: params[:encoding], field_separator: params[:field_separator]) do |csv|
|
|
323 | 323 |
# csv header fields |
324 | 324 |
csv << columns.map {|c| c.caption.to_s} |
325 | 325 |
# csv lines |
app/views/issues/index.html.erb (working copy) | ||
---|---|---|
59 | 59 |
</fieldset> |
60 | 60 |
<% end %> |
61 | 61 |
<%= export_csv_encoding_select_tag %> |
62 |
<%= export_csv_separator_select_tag %> |
|
62 | 63 |
<% if @issue_count > Setting.issues_export_limit.to_i %> |
63 | 64 |
<p class="icon icon-warning"> |
64 | 65 |
<%= l(:setting_issues_export_limit) %>: <%= Setting.issues_export_limit.to_i %> |
app/views/projects/_list.html.erb (working copy) | ||
---|---|---|
66 | 66 |
<label><%= radio_button_tag 'c[]', 'all_inline' %> <%= l(:description_all_columns) %></label> |
67 | 67 |
</p> |
68 | 68 |
<%= export_csv_encoding_select_tag %> |
69 |
<%= export_csv_separator_select_tag %> |
|
69 | 70 |
<p class="buttons"> |
70 | 71 |
<%= submit_tag l(:button_export), :name => nil, :onclick => "hideModal(this);", :data => { :disable_with => false } %> |
71 | 72 |
<%= link_to_function l(:button_cancel), "hideModal(this);" %> |
app/views/reports/_details.html.erb (working copy) | ||
---|---|---|
32 | 32 |
<h3 class="title"><%= l(:label_export_options, :export_format => 'CSV') %></h3> |
33 | 33 |
<%= form_tag(project_issues_report_details_path(@project, :detail => params[:detail], :format => 'csv'), :method => :get, :id => 'csv-export-form') do %> |
34 | 34 |
<%= export_csv_encoding_select_tag %> |
35 |
<%= export_csv_separator_select_tag %> |
|
35 | 36 |
<p class="buttons"> |
36 | 37 |
<%= submit_tag l(:button_export), :name => nil, :onclick => 'hideModal(this);', :data => {:disable_with => false} %> |
37 | 38 |
<%= link_to_function l(:button_cancel), 'hideModal(this);' %> |
app/views/roles/permissions.html.erb (working copy) | ||
---|---|---|
92 | 92 |
<h3 class="title"><%= l(:label_export_options, :export_format => 'CSV') %></h3> |
93 | 93 |
<%= form_tag(permissions_roles_path(:format => 'csv'), :method => :get, :id => 'csv-export-form') do %> |
94 | 94 |
<%= export_csv_encoding_select_tag %> |
95 |
<%= export_csv_separator_select_tag %> |
|
95 | 96 |
<p class="buttons"> |
96 | 97 |
<%= submit_tag l(:button_export), :name => nil, :onclick => 'hideModal(this);', :data => {:disable_with => false} %> |
97 | 98 |
<%= link_to_function l(:button_cancel), 'hideModal(this);' %> |
app/views/timelog/index.html.erb (working copy) | ||
---|---|---|
52 | 52 |
</fieldset> |
53 | 53 |
<% end %> |
54 | 54 |
<%= export_csv_encoding_select_tag %> |
55 |
<%= export_csv_separator_select_tag %> |
|
55 | 56 |
<p class="buttons"> |
56 | 57 |
<%= submit_tag l(:button_export), :name => nil, :onclick => "hideModal(this);", :data => { :disable_with => false } %> |
57 | 58 |
<%= link_to_function l(:button_cancel), "hideModal(this);" %> |
app/views/timelog/report.html.erb (working copy) | ||
---|---|---|
72 | 72 |
<div id="csv-export-options" style="display: none;"> |
73 | 73 |
<h3 class="title"><%= l(:label_export_options, :export_format => 'CSV') %></h3> |
74 | 74 |
<%= export_csv_encoding_select_tag %> |
75 |
<%= export_csv_separator_select_tag %> |
|
75 | 76 |
<p class="buttons"> |
76 | 77 |
<%= submit_tag l(:button_export), :name => nil, :id => 'csv-export-button' %> |
77 | 78 |
<%= submit_tag l(:button_cancel), :name => nil, :onclick => 'hideModal(this);', :type => 'button' %> |
app/views/users/index.html.erb (working copy) | ||
---|---|---|
78 | 78 |
<div id="csv-export-options" style="display: none;"> |
79 | 79 |
<h3 class="title"><%= l(:label_export_options, :export_format => 'CSV') %></h3> |
80 | 80 |
<%= export_csv_encoding_select_tag %> |
81 |
<%= export_csv_separator_select_tag %> |
|
81 | 82 |
<p class="buttons"> |
82 | 83 |
<%= submit_tag l(:button_export), :name => nil, :id => 'csv-export-button' %> |
83 | 84 |
<%= submit_tag l(:button_cancel), :name => nil, :onclick => 'hideModal(this);', :type => 'button' %> |
lib/redmine/export/csv.rb (working copy) | ||
---|---|---|
31 | 31 | |
32 | 32 |
class << self |
33 | 33 |
def generate(options = {}, &block) |
34 |
col_sep = l(:general_csv_separator) |
|
34 |
col_sep = options[:field_separator].present? ? options[:field_separator] : l(:general_csv_separator) |
|
35 |
col_sep = case col_sep |
|
36 |
when '{tab}' |
|
37 |
"\t" |
|
38 |
when '{space}' |
|
39 |
' ' |
|
40 |
else |
|
41 |
col_sep |
|
42 |
end |
|
35 | 43 |
encoding = Encoding.find(options[:encoding]) rescue Encoding.find(l(:general_csv_encoding)) |
36 | 44 | |
37 | 45 |
str = |
test/helpers/application_helper_test.rb (working copy) | ||
---|---|---|
2201 | 2201 |
end |
2202 | 2202 |
end |
2203 | 2203 | |
2204 |
def test_export_csv_separator_select_tag |
|
2205 |
with_locale 'en' do |
|
2206 |
result = export_csv_separator_select_tag |
|
2207 |
assert_select_in result, |
|
2208 |
"option[selected='selected'][value='#{l(:general_csv_separator)}']", |
|
2209 |
text: l(:general_csv_separator) |
|
2210 |
end |
|
2211 |
end |
|
2212 | ||
2204 | 2213 |
private |
2205 | 2214 | |
2206 | 2215 |
def wiki_links_with_special_characters |