Feature #5794 » 5794_git_without_option.diff
| app/helpers/custom_fields_helper.rb | ||
|---|---|---|
| 90 | 90 |
end |
| 91 | 91 | |
| 92 | 92 |
# Return a string used to display a custom value |
| 93 |
def show_value(custom_value) |
|
| 93 |
def show_value(custom_value, options = {})
|
|
| 94 | 94 |
return "" unless custom_value |
| 95 |
format_value(custom_value.value, custom_value.custom_field.field_format) |
|
| 95 |
|
|
| 96 |
options = {:textilize => true, :simple_format => false}.merge(options)
|
|
| 97 |
value = custom_value.value |
|
| 98 |
if options[:simple_format] |
|
| 99 |
value = simple_format_without_paragraph(h(value)) |
|
| 100 |
elsif options[:textilize] |
|
| 101 |
value = textilizable(value) |
|
| 102 |
else |
|
| 103 |
value = h(value) |
|
| 104 |
end |
|
| 105 |
|
|
| 106 |
format_value(value, custom_value.custom_field.field_format) |
|
| 96 | 107 |
end |
| 97 | 108 |
|
| 98 | 109 |
# Return a string used to display a custom value |
| app/helpers/issues_helper.rb | ||
|---|---|---|
| 79 | 79 |
n = 0 |
| 80 | 80 |
ordered_values.compact.each do |value| |
| 81 | 81 |
s << "</tr>\n<tr>\n" if n > 0 && (n % 2) == 0 |
| 82 |
s << "\t<th>#{ h(value.custom_field.name) }:</th><td>#{ simple_format_without_paragraph(h(show_value(value))) }</td>\n"
|
|
| 82 |
s << "\t<th>#{ h(value.custom_field.name) }:</th><td>#{ show_value(value) }</td>\n"
|
|
| 83 | 83 |
n += 1 |
| 84 | 84 |
end |
| 85 | 85 |
s << "</tr>\n" |
| ... | ... | |
| 226 | 226 |
format_time(issue.created_on), |
| 227 | 227 |
format_time(issue.updated_on) |
| 228 | 228 |
] |
| 229 |
custom_fields.each {|f| fields << show_value(issue.custom_value_for(f)) }
|
|
| 229 |
custom_fields.each {|f| fields << show_value(issue.custom_value_for(f), :textilize => false) }
|
|
| 230 | 230 |
fields << issue.description |
| 231 | 231 |
csv << fields.collect {|c| begin; ic.iconv(c.to_s); rescue; c.to_s; end }
|
| 232 | 232 |
end |
| app/helpers/timelog_helper.rb | ||
|---|---|---|
| 115 | 115 |
entry.hours.to_s.gsub('.', decimal_separator),
|
| 116 | 116 |
entry.comments |
| 117 | 117 |
] |
| 118 |
fields += custom_fields.collect {|f| show_value(entry.custom_value_for(f)) }
|
|
| 118 |
fields += custom_fields.collect {|f| show_value(entry.custom_value_for(f), :textilize => false) }
|
|
| 119 | 119 |
|
| 120 | 120 |
csv << fields.collect {|c| begin; ic.iconv(c.to_s); rescue; c.to_s; end }
|
| 121 | 121 |
end |
| app/views/mailer/_issue_text_html.rhtml | ||
|---|---|---|
| 8 | 8 |
<li><%=l(:field_category)%>: <%=h issue.category %></li> |
| 9 | 9 |
<li><%=l(:field_fixed_version)%>: <%=h issue.fixed_version %></li> |
| 10 | 10 |
<% issue.custom_values.each do |c| %> |
| 11 |
<li><%=h c.custom_field.name %>: <%=h show_value(c) %></li>
|
|
| 11 |
<li><%=h c.custom_field.name %>: <%= show_value(c) %></li> |
|
| 12 | 12 |
<% end %> |
| 13 | 13 |
</ul> |
| 14 | 14 | |
| app/views/mailer/_issue_text_plain.rhtml | ||
|---|---|---|
| 7 | 7 |
<%=l(:field_assigned_to)%>: <%= issue.assigned_to %> |
| 8 | 8 |
<%=l(:field_category)%>: <%= issue.category %> |
| 9 | 9 |
<%=l(:field_fixed_version)%>: <%= issue.fixed_version %> |
| 10 |
<% issue.custom_values.each do |c| %><%= c.custom_field.name %>: <%= show_value(c) %> |
|
| 10 |
<% issue.custom_values.each do |c| %><%= c.custom_field.name %>: <%= show_value(c, :textilize => false) %>
|
|
| 11 | 11 |
<% end %> |
| 12 | 12 | |
| 13 | 13 |
<%= issue.description %> |
| app/views/projects/show.rhtml | ||
|---|---|---|
| 18 | 18 |
<% end %> |
| 19 | 19 |
<% @project.custom_values.each do |custom_value| %> |
| 20 | 20 |
<% if !custom_value.value.blank? %> |
| 21 |
<li><%= custom_value.custom_field.name%>: <%=h show_value(custom_value) %></li>
|
|
| 21 |
<li><%= custom_value.custom_field.name%>: <%= show_value(custom_value) %></li> |
|
| 22 | 22 |
<% end %> |
| 23 | 23 |
<% end %> |
| 24 | 24 |
</ul> |
| app/views/users/show.rhtml | ||
|---|---|---|
| 11 | 11 |
<% end %> |
| 12 | 12 |
<% for custom_value in @custom_values %> |
| 13 | 13 |
<% if !custom_value.value.blank? %> |
| 14 |
<li><%=h custom_value.custom_field.name%>: <%=h show_value(custom_value) %></li>
|
|
| 14 |
<li><%=h custom_value.custom_field.name%>: <%= show_value(custom_value) %></li> |
|
| 15 | 15 |
<% end %> |
| 16 | 16 |
<% end %> |
| 17 | 17 |
<li><%=l(:label_registered_on)%>: <%= format_date(@user.created_on) %></li> |
| app/views/versions/_overview.rhtml | ||
|---|---|---|
| 8 | 8 |
<ul> |
| 9 | 9 |
<% version.custom_values.each do |custom_value| %> |
| 10 | 10 |
<% if !custom_value.value.blank? %> |
| 11 |
<li><%=h custom_value.custom_field.name %>: <%=h show_value(custom_value) %></li>
|
|
| 11 |
<li><%=h custom_value.custom_field.name %>: <%= show_value(custom_value) %></li> |
|
| 12 | 12 |
<% end %> |
| 13 | 13 |
<% end %> |
| 14 | 14 |
</ul> |
| test/fixtures/custom_fields.yml | ||
|---|---|---|
| 129 | 129 |
field_format: date |
| 130 | 130 |
default_value: "" |
| 131 | 131 |
editable: true |
| 132 |
custom_fields_010: |
|
| 133 |
name: Textilizable cf |
|
| 134 |
min_length: 0 |
|
| 135 |
regexp: "" |
|
| 136 |
is_for_all: true |
|
| 137 |
is_filter: true |
|
| 138 |
type: IssueCustomField |
|
| 139 |
max_length: 0 |
|
| 140 |
possible_values: "" |
|
| 141 |
id: 10 |
|
| 142 |
is_required: false |
|
| 143 |
field_format: string |
|
| test/fixtures/custom_fields_trackers.yml | ||
|---|---|---|
| 17 | 17 |
custom_fields_trackers_006: |
| 18 | 18 |
custom_field_id: 6 |
| 19 | 19 |
tracker_id: 3 |
| 20 |
custom_fields_trackers_007: |
|
| 21 |
custom_field_id: 10 |
|
| 22 |
tracker_id: 1 |
|
| test/fixtures/custom_values.yml | ||
|---|---|---|
| 101 | 101 |
customized_id: 1 |
| 102 | 102 |
id: 17 |
| 103 | 103 |
value: '2009-12-01' |
| 104 |
custom_values_018: |
|
| 105 |
customized_type: Issue |
|
| 106 |
custom_field_id: 10 |
|
| 107 |
customized_id: 1 |
|
| 108 |
id: 18 |
|
| 109 |
value: "*Issue* test: #1\n(powered by http://www.redmine.org/)" |
|
| test/unit/helpers/custom_fields_helper_test.rb | ||
|---|---|---|
| 18 | 18 |
require File.dirname(__FILE__) + '/../../test_helper' |
| 19 | 19 | |
| 20 | 20 |
class CustomFieldsHelperTest < HelperTestCase |
| 21 |
include ApplicationHelper |
|
| 22 |
include ActionView::Helpers::TextHelper |
|
| 21 | 23 |
include CustomFieldsHelper |
| 22 | 24 |
include Redmine::I18n |
| 23 | 25 |
|
| ... | ... | |
| 26 | 28 |
assert_equal 'Yes', format_value('1', 'bool')
|
| 27 | 29 |
assert_equal 'No', format_value('0', 'bool')
|
| 28 | 30 |
end |
| 31 | ||
| 32 |
def test_show_value |
|
| 33 |
cv = CustomValue.find(18) |
|
| 34 |
str = cv.value |
|
| 35 |
assert_equal str, show_value(cv, :textilize => false) |
|
| 36 |
assert_equal str.gsub("\n","\n<br />"), show_value(cv, :simple_format => true)
|
|
| 37 |
assert_equal textilizable(str), show_value(cv) |
|
| 38 |
end |
|
| 29 | 39 |
end |
- « Previous
- 1
- 2
- Next »