2009-01-15 18:26:37 +01:00
|
|
|
module MessagesHelper
|
2009-01-15 20:10:50 +01:00
|
|
|
def format_subject(message, length)
|
2009-03-09 13:02:43 +01:00
|
|
|
if message.subject.length > length
|
|
|
|
subject = truncate(message.subject, :length => length)
|
|
|
|
body = ""
|
|
|
|
else
|
|
|
|
subject = message.subject
|
2023-02-09 17:18:25 +01:00
|
|
|
body = truncate(message.body.to_plain_text, :length => length - subject.length)
|
2009-03-09 13:02:43 +01:00
|
|
|
end
|
2011-05-18 14:47:17 +02:00
|
|
|
"<b>#{link_to(h(subject), message)}</b> <span style='color:grey'>#{h(body)}</span>".html_safe
|
2009-01-15 18:26:37 +01:00
|
|
|
end
|
2012-10-08 15:24:32 +02:00
|
|
|
|
|
|
|
def link_to_new_message(options = {})
|
|
|
|
messages_params = options[:message_params] || nil
|
2015-04-10 18:46:12 +02:00
|
|
|
link_text = content_tag :i, nil, class: 'icon-envelope'
|
2012-10-08 15:24:32 +02:00
|
|
|
link_text << " #{options[:text]}" if options[:text].present?
|
|
|
|
link_to(link_text.html_safe, new_message_path(message: messages_params), class: 'btn',
|
2021-03-01 15:27:26 +01:00
|
|
|
title: I18n.t('helpers.submit.message.create'))
|
2012-10-08 15:24:32 +02:00
|
|
|
end
|
2009-01-15 18:26:37 +01:00
|
|
|
end
|