]> source.dussan.org Git - redmine.git/commitdiff
Introduce configuration for done ratio options interval (#31756).
authorGo MAEDA <maeda@farend.jp>
Wed, 29 May 2024 15:06:28 +0000 (15:06 +0000)
committerGo MAEDA <maeda@farend.jp>
Wed, 29 May 2024 15:06:28 +0000 (15:06 +0000)
Patch by Go MAEDA (@maeda).

git-svn-id: https://svn.redmine.org/redmine/trunk@22849 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/views/issue_statuses/_form.html.erb
app/views/issues/_attributes.html.erb
app/views/issues/bulk_edit.html.erb
app/views/settings/_issues.html.erb
app/views/settings/_repositories.html.erb
config/locales/en.yml
config/settings.yml
test/functional/issues_controller_test.rb

index 8f06451c69ee93d9dcfd172687e21c04801d1685..c2487b0029136071a2d9bf418a794617ce83a1f7 100644 (file)
@@ -4,7 +4,7 @@
 <p><%= f.text_field :name, :required => true %></p>
 <p><%= f.text_area :description, :rows => 4 %></p>
 <% if Issue.use_status_for_done_ratio? %>
-  <p><%= f.select :default_done_ratio, ((0..10).to_a.collect {|r| ["#{r*10} %", r*10] }), :include_blank => true, :label => :field_done_ratio %></p>
+  <p><%= f.select :default_done_ratio, ((0..100).step(Setting.issue_done_ratio_interval.to_i).to_a.collect {|r| ["#{r} %", r]}), :include_blank => true, :label => :field_done_ratio %></p>
 <% end %>
 <p><%= f.check_box :is_closed %></p>
 
index 40b89547ab219baecf9051c5efad06ff61f5aa74..517b67f95ebfc943237f44c044439077e8d44f9c 100644 (file)
@@ -88,7 +88,7 @@
 <% end %>
 
 <% if @issue.safe_attribute?('done_ratio') && Issue.use_field_for_done_ratio? %>
-<p><%= f.select :done_ratio, ((0..10).to_a.collect {|r| ["#{r*10} %", r*10] }), :required => @issue.required_attribute?('done_ratio') %></p>
+<p><%= f.select :done_ratio, ((0..100).step(Setting.issue_done_ratio_interval.to_i).to_a.collect {|r| ["#{r} %", r]}), :required => @issue.required_attribute?('done_ratio') %></p>
 <% end %>
 </div>
 </div>
index 4fe457b32eb5f6561198d62c5f99f9e5c768ea81..a379305be746e365cae585b09c078c3df6ce42f1 100644 (file)
 <% if @safe_attributes.include?('done_ratio') && Issue.use_field_for_done_ratio? %>
 <p>
   <label for='issue_done_ratio'><%= l(:field_done_ratio) %></label>
-  <%= select_tag 'issue[done_ratio]', options_for_select([[l(:label_no_change_option), '']] + (0..10).to_a.collect {|r| ["#{r*10} %", r*10] }, @issue_params[:done_ratio]) %>
+  <%= select_tag 'issue[done_ratio]', options_for_select([[l(:label_no_change_option), '']] + (0..100).step(Setting.issue_done_ratio_interval.to_i).to_a.collect {|r| ["#{r} %", r]}, @issue_params[:done_ratio]) %>
 </p>
 <% end %>
 </div>
index 68f9a1d7b5b24da26a547f217ba0ef0320d014f8..7532d5d0e1b8b33a1e57050e2f01d64bc90cb9ba 100644 (file)
@@ -17,6 +17,8 @@
 
 <p><%= setting_select :issue_done_ratio, Issue::DONE_RATIO_OPTIONS.collect {|i| [l("setting_issue_done_ratio_#{i}"), i]} %></p>
 
+<p><%= setting_select :issue_done_ratio_interval, [5, 10].collect {|i| ["#{i} %", i]} %></p>
+
 <p><%= setting_multiselect :non_working_week_days, (1..7).map {|d| [day_name(d), d.to_s]}, :inline => true %></p>
 
 <p><%= setting_text_field :issues_export_limit, :size => 6 %></p>
index adac52fc778e76b841f819d525097671139756d9..f89a27944a3e0137fdf84752d3150bb06d568b58 100644 (file)
         <%= select_tag("settings[commit_update_keywords][done_ratio][]",
                        options_for_select(
                           [["", ""]] +
-                          (0..10).to_a.collect {|r| ["#{r*10} %", "#{r*10}"] },
+                          (0..100).step(Setting.issue_done_ratio_interval.to_i).to_a.collect {|r| ["#{r} %", r]},
                        rule['done_ratio']),
                        :id => nil
                     ) %>
index c842e4d7b9baa09aced10228cc24d311d1e0a6ae..2361dac08207060d17706d6aa2e82da67055adc9 100644 (file)
@@ -477,6 +477,7 @@ en:
   setting_default_projects_modules: Default enabled modules for new projects
   setting_issue_done_ratio: Calculate the issue done ratio with
   setting_issue_done_ratio_issue_field: Use the issue field
+  setting_issue_done_ratio_interval: Done ratio options interval
   setting_issue_done_ratio_issue_status: Use the issue status
   setting_start_of_week: Start calendars on
   setting_rest_api_enabled: Enable REST web service
index bd37957560bb346250868d92a297d3c5d33d8330..346288a4a2afc37daea52dc92c5e92df39a67957 100644 (file)
@@ -256,6 +256,9 @@ default_project_query:
   default: ''
 issue_done_ratio:
   default: 'issue_field'
+issue_done_ratio_interval:
+  format: int
+  default: 10
 default_projects_public:
   default: 1
 default_projects_modules:
index 53cfd8146575fc7aaad8128b4ce77d879239971b..12ec7a6d5aef09b85d326afefb7bc9f7ffe440f7 100644 (file)
@@ -8736,4 +8736,19 @@ class IssuesControllerTest < Redmine::ControllerTest
       end
     end
   end
+
+  def test_get_new_with_issue_field_five_percent_increments
+    with_settings :issue_done_ratio => 'issue_field', :issue_done_ratio_interval => 5 do
+      @request.session[:user_id] = 1
+      get :new
+      assert_response :success
+
+      assert_select 'select#issue_done_ratio' do
+        assert_select 'option', count: 21
+        assert_select 'option:nth-of-type(1)', text: '0 %'
+        assert_select 'option:nth-of-type(2)', text: '5 %'
+        assert_select 'option:nth-of-type(21)', text: '100 %'
+      end
+    end
+  end
 end