mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-11-10 16:31:22 +08:00
Merge pull request #650 from mlorb/ml_sci_1286
Fix bug with titles truncate in activities [SCI-1286]
This commit is contained in:
commit
3dc83cfe05
1 changed files with 14 additions and 7 deletions
|
|
@ -1,13 +1,20 @@
|
||||||
module ActivityHelper
|
module ActivityHelper
|
||||||
def activity_truncate(message, len = Constants::NAME_TRUNCATION_LENGTH)
|
def activity_truncate(message, len = Constants::NAME_TRUNCATION_LENGTH)
|
||||||
activity_title = message.match(/<strong>(.*?)<\/strong>/)[1]
|
activity_titles = message.scan(/<strong>(.*?)<\/strong>/)
|
||||||
|
activity_titles.each do |activity_title|
|
||||||
|
activity_title = activity_title[0]
|
||||||
if activity_title.length > Constants::NAME_TRUNCATION_LENGTH
|
if activity_title.length > Constants::NAME_TRUNCATION_LENGTH
|
||||||
title = "<div class='modal-tooltip'>#{truncate(activity_title, length: len)}
|
title = "<div class='modal-tooltip'>
|
||||||
<span class='modal-tooltiptext'>#{activity_title}</span></div>"
|
#{truncate(activity_title, length: len)}
|
||||||
|
<span class='modal-tooltiptext'>
|
||||||
|
#{activity_title}
|
||||||
|
</span>
|
||||||
|
</div>"
|
||||||
else
|
else
|
||||||
title = truncate(activity_title, length: len)
|
title = truncate(activity_title, length: len)
|
||||||
end
|
end
|
||||||
message = message.gsub(/#{activity_title}/, title )
|
message = message.gsub(/#{Regexp.escape(activity_title)}/, title)
|
||||||
|
end
|
||||||
sanitize_input(message) if message
|
sanitize_input(message) if message
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue