Feature #42335 » 0001-Adds-interval-ratio-setting-to-progressbar-custom-fi.patch
app/models/custom_field.rb | ||
---|---|---|
101 | 101 |
'version_status', |
102 | 102 |
'extensions_allowed', |
103 | 103 |
'full_width_layout', |
104 |
'thousands_delimiter' |
|
104 |
'thousands_delimiter', |
|
105 |
'ratio_interval' |
|
105 | 106 |
) |
106 | 107 | |
107 | 108 |
def copy_from(arg, options={}) |
... | ... | |
231 | 232 |
thousands_delimiter == '1' |
232 | 233 |
end |
233 | 234 | |
235 |
def ratio_interval |
|
236 |
[5, read_attribute(:ratio_interval).to_i].max |
|
237 |
end |
|
238 | ||
234 | 239 |
# Returns a ORDER BY clause that can used to sort customized |
235 | 240 |
# objects by their value of the custom field. |
236 | 241 |
# Returns nil if the custom field can not be used for sorting. |
app/views/custom_fields/formats/_progressbar.html.erb | ||
---|---|---|
1 |
<p> |
|
2 |
<%= f.select :ratio_interval, [5, 10].collect {|i| ["#{i} %", i]} %> |
|
3 |
</p> |
lib/redmine/field_format.rb | ||
---|---|---|
1086 | 1086 |
class ProgressbarFormat < Numeric |
1087 | 1087 |
add 'progressbar' |
1088 | 1088 | |
1089 |
self.form_partial = nil
|
|
1089 |
self.form_partial = 'custom_fields/formats/progressbar'
|
|
1090 | 1090 |
self.totalable_supported = false |
1091 |
field_attributes :ratio_interval |
|
1091 | 1092 | |
1092 | 1093 |
def label |
1093 | 1094 |
"label_progressbar" |
... | ... | |
1116 | 1117 |
view.select_tag( |
1117 | 1118 |
tag_name, |
1118 | 1119 |
view.options_for_select( |
1119 |
(0..100).step(Setting.issue_done_ratio_interval.to_i).to_a.collect {|r| ["#{r} %", r]},
|
|
1120 |
(0..100).step(custom_value.custom_field.ratio_interval.to_i).to_a.collect {|r| ["#{r} %", r]},
|
|
1120 | 1121 |
custom_value.value |
1121 | 1122 |
), |
1122 | 1123 |
options.merge(id: tag_id, style: "width: 75px;") |
... | ... | |
1124 | 1125 |
end |
1125 | 1126 | |
1126 | 1127 |
def bulk_edit_tag(view, tag_id, tag_name, custom_field, objects, value, options={}) |
1127 |
opts = view.options_for_select([[l(:label_no_change_option), '']] + (0..100).step(Setting.issue_done_ratio_interval.to_i).to_a.collect {|r| ["#{r} %", r]})
|
|
1128 |
opts = view.options_for_select([[l(:label_no_change_option), '']] + (0..100).step(custom_field.ratio_interval.to_i).to_a.collect {|r| ["#{r} %", r]})
|
|
1128 | 1129 |
view.select_tag(tag_name, opts, options.merge(id: tag_id, style: "width: 75px;")) + |
1129 | 1130 |
bulk_clear_tag(view, tag_id, tag_name, custom_field, value) |
1130 | 1131 |
end |
test/functional/custom_fields_controller_test.rb | ||
---|---|---|
282 | 282 |
assert_select '[name=?]', 'custom_field[full_width_layout]', 0 |
283 | 283 |
end |
284 | 284 | |
285 |
def test_setting_ratio_interval_should_be_present_only_for_progressbar_format |
|
286 |
get( |
|
287 |
:new, |
|
288 |
:params => { |
|
289 |
:type => 'IssueCustomField', |
|
290 |
:custom_field => { |
|
291 |
:field_format => 'progressbar' |
|
292 |
} |
|
293 |
} |
|
294 |
) |
|
295 |
assert_response :success |
|
296 |
assert_select '[name=?]', 'custom_field[ratio_interval]' do |
|
297 |
assert_select 'option[value=?]', '5' |
|
298 |
assert_select 'option[value=?]', '10' |
|
299 |
end |
|
300 |
end |
|
301 | ||
285 | 302 |
def test_new_js |
286 | 303 |
get( |
287 | 304 |
:new, |
test/functional/issues_controller_test.rb | ||
---|---|---|
5970 | 5970 |
end |
5971 | 5971 |
end |
5972 | 5972 | |
5973 |
def test_get_edit_with_custom_field_progress_bar |
|
5974 |
cf = IssueCustomField.generate!(:tracker_ids => [1], :is_for_all => true, :field_format => 'progressbar') |
|
5975 | ||
5976 |
@request.session[:user_id] = 1 |
|
5977 |
get(:edit, :params => {:id => 1}) |
|
5978 |
assert_response :success |
|
5979 | ||
5980 |
puts response.body |
|
5981 |
assert_select "select[id=?]", "issue_custom_field_values_#{cf.id}", 1 |
|
5982 |
end |
|
5983 | ||
5973 | 5984 |
def test_get_edit_with_me_assigned_to_id |
5974 | 5985 |
@request.session[:user_id] = 2 |
5975 | 5986 |
get( |
test/unit/lib/redmine/field_format/progressbar_format_test.rb | ||
---|---|---|
21 | 21 |
require 'redmine/field_format' |
22 | 22 | |
23 | 23 |
module Redmine::FieldFormat |
24 |
class ProgressbarFormatTest < ActiveSupport::TestCase
|
|
24 |
class ProgressbarFormatTest < ActionView::TestCase
|
|
25 | 25 |
def setup |
26 | 26 |
@field = IssueCustomField.new(name: 'ProgressbarTest', field_format: 'progressbar') |
27 | 27 |
@format = Redmine::FieldFormat::ProgressbarFormat.instance |
... | ... | |
81 | 81 |
options = @format.query_filter_options(@field, nil) |
82 | 82 |
assert_equal :integer, options[:type] |
83 | 83 |
end |
84 | ||
85 |
def test_ratio_interval |
|
86 |
@field.update(ratio_interval: 5) |
|
87 |
assert_equal 5, @field.ratio_interval |
|
88 |
end |
|
89 | ||
90 |
def test_edit_tag_possible_values_with_ratio_interval |
|
91 |
[5, 10].each do |ratio_interval| |
|
92 |
@field.update(ratio_interval: ratio_interval) |
|
93 |
value = CustomValue.new(custom_field: @field, value: '90') |
|
94 | ||
95 |
tag = @field.format.edit_tag(self, 'id', 'name', value) |
|
96 |
assert_select_in tag, 'select' do |
|
97 |
assert_select 'option', 100 / ratio_interval + 1 |
|
98 |
end |
|
99 |
end |
|
100 |
end |
|
101 | ||
102 |
def test_bulk_edit_tag_possible_values_with_ratio_interval |
|
103 |
[5, 10].each do |ratio_interval| |
|
104 |
@field.update(ratio_interval: ratio_interval) |
|
105 |
value = CustomValue.new(custom_field: @field, value: '90') |
|
106 |
objects = [Issue.new, Issue.new] |
|
107 | ||
108 |
tag = @field.format.bulk_edit_tag(self, 'id', 'name', @field, objects, value) |
|
109 |
assert_select_in tag, 'select' do |select| |
|
110 |
assert_select select.first, 'option', 100 / ratio_interval + 2 |
|
111 |
end |
|
112 |
end |
|
113 |
end |
|
84 | 114 |
end |
85 | 115 |
end |
- « Previous
- 1
- …
- 3
- 4
- 5
- Next »