Correct truncated styles on journal entries #914
This commit is contained in:
parent
23864d99b5
commit
1bc182405e
@ -114,23 +114,27 @@ module JournalFormatter
|
|||||||
end
|
end
|
||||||
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)
|
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?
|
# Sanitize values
|
||||||
value = content_tag("i", h(value)) if value.present?
|
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 ||= ""
|
value ||= ""
|
||||||
[label, old_value, 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
|
end
|
||||||
|
|
||||||
# Formats a detail to be used with a Journal diff
|
[label, old_value, value]
|
||||||
#
|
|
||||||
# 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]
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def property(detail)
|
def property(detail)
|
||||||
@ -195,11 +199,10 @@ module JournalFormatter
|
|||||||
label, old_value, value = [label, old_value, value].collect(&:to_s)
|
label, old_value, value = [label, old_value, value].collect(&:to_s)
|
||||||
|
|
||||||
unless no_html
|
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
|
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
|
end
|
||||||
|
|
||||||
unless value.blank?
|
unless value.blank?
|
||||||
|
Loading…
x
Reference in New Issue
Block a user