Project

General

Profile

Feature #5794 » 5794_git_without_option.diff

Jean-Baptiste Barth, 2010-07-08 06:32

View differences:

app/helpers/custom_fields_helper.rb
end
# Return a string used to display a custom value
def show_value(custom_value)
def show_value(custom_value, options = {})
return "" unless custom_value
format_value(custom_value.value, custom_value.custom_field.field_format)
options = {:textilize => true, :simple_format => false}.merge(options)
value = custom_value.value
if options[:simple_format]
value = simple_format_without_paragraph(h(value))
elsif options[:textilize]
value = textilizable(value)
else
value = h(value)
end
format_value(value, custom_value.custom_field.field_format)
end
# Return a string used to display a custom value
app/helpers/issues_helper.rb
n = 0
ordered_values.compact.each do |value|
s << "</tr>\n<tr>\n" if n > 0 && (n % 2) == 0
s << "\t<th>#{ h(value.custom_field.name) }:</th><td>#{ simple_format_without_paragraph(h(show_value(value))) }</td>\n"
s << "\t<th>#{ h(value.custom_field.name) }:</th><td>#{ show_value(value) }</td>\n"
n += 1
end
s << "</tr>\n"
......
format_time(issue.created_on),
format_time(issue.updated_on)
]
custom_fields.each {|f| fields << show_value(issue.custom_value_for(f)) }
custom_fields.each {|f| fields << show_value(issue.custom_value_for(f), :textilize => false) }
fields << issue.description
csv << fields.collect {|c| begin; ic.iconv(c.to_s); rescue; c.to_s; end }
end
app/helpers/timelog_helper.rb
entry.hours.to_s.gsub('.', decimal_separator),
entry.comments
]
fields += custom_fields.collect {|f| show_value(entry.custom_value_for(f)) }
fields += custom_fields.collect {|f| show_value(entry.custom_value_for(f), :textilize => false) }
csv << fields.collect {|c| begin; ic.iconv(c.to_s); rescue; c.to_s; end }
end
app/views/mailer/_issue_text_html.rhtml
<li><%=l(:field_category)%>: <%=h issue.category %></li>
<li><%=l(:field_fixed_version)%>: <%=h issue.fixed_version %></li>
<% issue.custom_values.each do |c| %>
<li><%=h c.custom_field.name %>: <%=h show_value(c) %></li>
<li><%=h c.custom_field.name %>: <%= show_value(c) %></li>
<% end %>
</ul>
app/views/mailer/_issue_text_plain.rhtml
<%=l(:field_assigned_to)%>: <%= issue.assigned_to %>
<%=l(:field_category)%>: <%= issue.category %>
<%=l(:field_fixed_version)%>: <%= issue.fixed_version %>
<% issue.custom_values.each do |c| %><%= c.custom_field.name %>: <%= show_value(c) %>
<% issue.custom_values.each do |c| %><%= c.custom_field.name %>: <%= show_value(c, :textilize => false) %>
<% end %>
<%= issue.description %>
app/views/projects/show.rhtml
<% end %>
<% @project.custom_values.each do |custom_value| %>
<% if !custom_value.value.blank? %>
<li><%= custom_value.custom_field.name%>: <%=h show_value(custom_value) %></li>
<li><%= custom_value.custom_field.name%>: <%= show_value(custom_value) %></li>
<% end %>
<% end %>
</ul>
app/views/users/show.rhtml
<% end %>
<% for custom_value in @custom_values %>
<% if !custom_value.value.blank? %>
<li><%=h custom_value.custom_field.name%>: <%=h show_value(custom_value) %></li>
<li><%=h custom_value.custom_field.name%>: <%= show_value(custom_value) %></li>
<% end %>
<% end %>
<li><%=l(:label_registered_on)%>: <%= format_date(@user.created_on) %></li>
app/views/versions/_overview.rhtml
<ul>
<% version.custom_values.each do |custom_value| %>
<% if !custom_value.value.blank? %>
<li><%=h custom_value.custom_field.name %>: <%=h show_value(custom_value) %></li>
<li><%=h custom_value.custom_field.name %>: <%= show_value(custom_value) %></li>
<% end %>
<% end %>
</ul>
test/fixtures/custom_fields.yml
field_format: date
default_value: ""
editable: true
custom_fields_010:
name: Textilizable cf
min_length: 0
regexp: ""
is_for_all: true
is_filter: true
type: IssueCustomField
max_length: 0
possible_values: ""
id: 10
is_required: false
field_format: string
test/fixtures/custom_fields_trackers.yml
custom_fields_trackers_006:
custom_field_id: 6
tracker_id: 3
custom_fields_trackers_007:
custom_field_id: 10
tracker_id: 1
test/fixtures/custom_values.yml
customized_id: 1
id: 17
value: '2009-12-01'
custom_values_018:
customized_type: Issue
custom_field_id: 10
customized_id: 1
id: 18
value: "*Issue* test: #1\n(powered by http://www.redmine.org/)"
test/unit/helpers/custom_fields_helper_test.rb
require File.dirname(__FILE__) + '/../../test_helper'
class CustomFieldsHelperTest < HelperTestCase
include ApplicationHelper
include ActionView::Helpers::TextHelper
include CustomFieldsHelper
include Redmine::I18n
......
assert_equal 'Yes', format_value('1', 'bool')
assert_equal 'No', format_value('0', 'bool')
end
def test_show_value
cv = CustomValue.find(18)
str = cv.value
assert_equal str, show_value(cv, :textilize => false)
assert_equal str.gsub("\n","\n<br />"), show_value(cv, :simple_format => true)
assert_equal textilizable(str), show_value(cv)
end
end
(2-2/2)