Project

General

Profile

Feature #13767 » 0001-Added-an-option-form-so-that-you-can-select-the-enco.patch

Yuichi HARADA, 2021-03-16 05:50

View differences:

app/helpers/roles_helper.rb
21 21
  include ApplicationHelper
22 22

  
23 23
  def permissions_to_csv(roles, permissions)
24
    Redmine::Export::CSV.generate do |csv|
24
    Redmine::Export::CSV.generate(:encoding => params[:encoding]) do |csv|
25 25
      # csv header fields
26 26
      headers = [l(:field_cvs_module), l(:label_permissions)] + roles.collect(&:name)
27 27
      csv << headers
app/views/roles/permissions.html.erb
86 86
<p><%= submit_tag l(:button_save) %></p>
87 87
<% end %>
88 88
<% other_formats_links do |f| %>
89
  <%= f.link_to 'CSV' %>
89
  <%= f.link_to_with_query_parameters 'CSV', {}, :onclick => "showModal('csv-export-options', '330px'); return false;" %>
90 90
<% end %>
91
<div id="csv-export-options" style="display: none;">
92
  <h3 class="title"><%= l(:label_export_options, :export_format => 'CSV') %></h3>
93
  <%= form_tag(permissions_roles_path(:format => 'csv'), :method => :get, :id => 'csv-export-form') do %>
94
  <%= export_csv_encoding_select_tag %>
95
  <p class="buttons">
96
    <%= submit_tag l(:button_export), :name => nil, :onclick => 'hideModal(this);', :data => {:disable_with => false} %>
97
    <%= link_to_function l(:button_cancel), 'hideModal(this);' %>
98
  </p>
99
  <% end %>
100
</div>
test/functional/roles_controller_test.rb
270 270
    assert_select 'input[name=?][type=checkbox][value=delete_issues]:not([checked])', 'permissions[3][]'
271 271
  end
272 272

  
273
  def test_permissions_should_include_csv_export
274
    get :permissions
275
    assert_response :success
276

  
277
    # Assert CSV export link
278
    assert_select 'p.other-formats a.csv'
279

  
280
    # Assert export modal
281
    assert_select '#csv-export-options' do
282
      assert_select 'form[action=?][method=get]', '/roles/permissions.csv'
283
    end
284
  end
285

  
273 286
  def test_permissions_csv_export
274 287
    get(
275 288
      :permissions,
(4-4/4)