Correct truncated styles on journal entries #914
This commit is contained in:
parent
23864d99b5
commit
1bc182405e
|
@ -114,23 +114,27 @@ module JournalFormatter
|
|||
end
|
||||
end
|
||||
|
||||
def format_html_detail(label, old_value, value)
|
||||
def format_html_detail(label, key, old_value, value, options = {})
|
||||
label = content_tag('strong', label)
|
||||
old_value = content_tag("i", h(old_value)) if old_value && !old_value.blank?
|
||||
old_value = content_tag("strike", old_value) if old_value and value.blank?
|
||||
value = content_tag("i", h(value)) if value.present?
|
||||
value ||= ""
|
||||
[label, old_value, value]
|
||||
end
|
||||
|
||||
# Formats a detail to be used with a Journal diff
|
||||
#
|
||||
# Truncates the content. Adds a link to view a diff.
|
||||
def format_html_diff_detail(key, label, old_value, value)
|
||||
link = link_to(l(:label_more), {:controller => 'journals', :action => 'diff', :id => id, :field => key.to_s}, :class => 'lightbox-ajax')
|
||||
old_value = truncate(old_value, :length => 80)
|
||||
value = truncate(value, :length => 80) + " " + link
|
||||
[old_value, value]
|
||||
# Sanitize values
|
||||
old_value, value = h(old_value), h(value)
|
||||
|
||||
# Truncate as needed
|
||||
old_value, value = truncate(old_value, :length => 80), truncate(value, :length => 80) if options[:truncate].present?
|
||||
|
||||
# Style
|
||||
old_value = content_tag("i", old_value) if old_value.present?
|
||||
old_value = content_tag("strike", old_value) if old_value.present? and value.blank?
|
||||
value = content_tag("i", value) if value.present?
|
||||
value ||= ""
|
||||
|
||||
# More link
|
||||
if options[:more_link].present?
|
||||
value += " " + link_to(l(:label_more), {:controller => 'journals', :action => 'diff', :id => id, :field => key.to_s}, :class => 'lightbox-ajax')
|
||||
end
|
||||
|
||||
[label, old_value, value]
|
||||
end
|
||||
|
||||
def property(detail)
|
||||
|
@ -195,11 +199,10 @@ module JournalFormatter
|
|||
label, old_value, value = [label, old_value, value].collect(&:to_s)
|
||||
|
||||
unless no_html
|
||||
label, old_value, value = *format_html_detail(label, old_value, value)
|
||||
options = {}
|
||||
options = options.merge({:truncate => true, :more_link => true}) if property(detail) == :attribute && key == "description"
|
||||
label, old_value, value = *format_html_detail(label, key, old_value, value, options)
|
||||
value = format_html_attachment_detail(key.sub("attachments", ""), value) if attachment_detail
|
||||
if property(detail) == :attribute && key == "description"
|
||||
old_value, value = *format_html_diff_detail(key, label, old_value, value)
|
||||
end
|
||||
end
|
||||
|
||||
unless value.blank?
|
||||
|
|
Loading…
Reference in New Issue