Add flag to disable simple_format in custom_auto_link [SCI-940]

This commit is contained in:
Oleksii Kriuchykhin 2017-01-25 17:15:22 +01:00
parent 310d8c1920
commit c55f3cb99c
7 changed files with 13 additions and 8 deletions

View file

@ -130,7 +130,7 @@ class SampleDatatable < AjaxDatatablesRails::Base
# Add custom attributes
record.sample_custom_fields.each do |scf|
sample[@cf_mappings[scf.custom_field_id]] =
custom_auto_link(scf.value, @organization)
custom_auto_link(scf.value, true, @organization)
end
sample
end

View file

@ -11,9 +11,14 @@ module InputSanitizeHelper
ERB::Util.html_escape(text)
end
def custom_auto_link(text, org = nil)
def custom_auto_link(text, simple_format = true, org = nil)
text = if simple_format
simple_format(sanitize_input(text))
else
sanitize_input(text)
end
auto_link(
smart_annotation_parser(simple_format(sanitize_input(text)), org),
smart_annotation_parser(text, org),
link: :urls,
sanitize: false,
html: { target: '_blank' }

View file

@ -23,7 +23,7 @@
<div class="report-element-body">
<div class="row">
<div class="col-xs-12 text-container ql-editor">
<%= custom_auto_link(result_text.text) %>
<%= custom_auto_link(result_text.text, false) %>
</div>
</div>
</div>

View file

@ -8,7 +8,7 @@
<span class="glyphicon glyphicon-list"></span>
</div>
<div class="pull-left checklist-name">
<%= custom_auto_link(t 'projects.reports.elements.step_checklist.checklist_name', name: checklist.name) %>
<%= custom_auto_link(t('projects.reports.elements.step_checklist.checklist_name', name: checklist.name)) %>
</div>
<div class="pull-left user-time">
<%=t 'projects.reports.elements.step_checklist.user_time', timestamp: l(timestamp, format: :full) %>

View file

@ -27,7 +27,7 @@
<div class="row">
<div class="col-xs-12 ql-editor">
<% if strip_tags(step.description).present? %>
<%= custom_auto_link(step.description) %>
<%= custom_auto_link(step.description, false) %>
<% else %>
<em><%=t "projects.reports.elements.step.no_description" %></em>
<% end %>

View file

@ -1,3 +1,3 @@
<div class="ql-editor">
<%= custom_auto_link(result.result_text.text) %>
<%= custom_auto_link(result.result_text.text, false) %>
</div>

View file

@ -37,7 +37,7 @@
<em><%= t("protocols.steps.no_description") %></em>
<% else %>
<div class="ql-editor">
<%= custom_auto_link(step.description) %>
<%= custom_auto_link(step.description, false) %>
</div>
<% end %>
</div>