Fix issue with protocol and result text name [SCI-9420]

This commit is contained in:
wandji20 2023-10-03 10:06:53 +01:00
parent 1c84a97bd7
commit 6358ad2da4
10 changed files with 36 additions and 25 deletions

View file

@ -329,13 +329,12 @@ function importProtocolFromFile(
}
function addStepTextPreview(stepEl, stepTextNode, folder, stepGuid) {
var itemId = $(stepTextNode).attr('id');
const itemName = $(stepTextNode).children('name').text();
const itemText = displayTinyMceAssetInDescription(stepTextNode, folder, stepGuid);
var itemText = displayTinyMceAssetInDescription(stepTextNode, folder, stepGuid);
var textEl = newPreviewElement(
const textEl = newPreviewElement(
'step-text',
{ text: itemText }
{ name: itemName, text: itemText }
);
stepEl.append(textEl);

View file

@ -430,8 +430,16 @@ label {
}
}
/* Result text element style */
// Text element style
.report-step-text-element,
.report-result-text-element {
.report-element-header {
.text-name {
font-size: 10pt;
font-weight: bold;
}
}
.report-element-body {
.text-container {
border-radius: 4px;

View file

@ -15,7 +15,8 @@ class ResultText < ApplicationRecord
def duplicate(result, position = nil)
ActiveRecord::Base.transaction do
new_result_text = result.result_texts.create!(
text: text
text: text,
name: name
)
# Copy results tinyMce assets

View file

@ -21,7 +21,8 @@ class StepText < ApplicationRecord
def duplicate(step, position = nil)
ActiveRecord::Base.transaction do
new_step_text = step.step_texts.create!(
text: text
text: text,
name: name
)
# Copy steps tinyMce assets

View file

@ -4,16 +4,8 @@ module Reports::Docx::DrawResultText
def draw_result_text(element)
result = element.result
result_text = element.orderable
timestamp = result.created_at
color = @color
@docx.p
@docx.p do
text result.name.presence || I18n.t('projects.reports.unnamed'), italic: true
text " #{I18n.t('search.index.archived')} ", bold: true if result.archived?
text ' '
text I18n.t('projects.reports.elements.result_table.user_time',
timestamp: I18n.l(timestamp, format: :full), user: result.user.full_name), color: color[:gray]
end
@docx.p result_text.name.presence || '', italic: true
html = custom_auto_link(result_text.text, team: @report_team)
Reports::HtmlToWordConverter.new(@docx, { scinote_url: @scinote_url,
link_style: @link_style }).html_to_word_converter(html)

View file

@ -2,6 +2,7 @@
module Reports::Docx::DrawStepText
def draw_step_text(step_text)
@docx.p step_text.name.presence || '', italic: true
if step_text.text.present?
html = custom_auto_link(step_text.text, team: @report_team)
Reports::HtmlToWordConverter.new(@docx, { scinote_url: @scinote_url,

View file

@ -86,6 +86,7 @@ module ProtocolsExporterV2
def step_text_xml(step_text)
xml = "<stepText id=\"#{step_text.id}\" guid=\"#{get_guid(step_text.id)}\">\n" \
"<name>#{step_text.name}</name>\n"\
"<contents>\n" \
"<!--[CDATA[ #{Nokogiri::HTML::DocumentFragment.parse(step_text.text)} ]]-->"\
"</contents>\n"

View file

@ -46,6 +46,9 @@
</div>
<div data-template="step-text" class="col-xs-12">
<div>
<strong data-val="name"></strong>
</div>
<div data-val="text"></div>
</div>

View file

@ -5,15 +5,12 @@
<% export_all = defined?(export_all) && export_all %>
<div class="report-element report-result-element report-result-text-element">
<div class="report-element-header">
<div class="result-name">
<%= name.presence || I18n.t('projects.reports.unnamed') %>
<% if result.archived? %>
<span class="label label-warning"><%= t('search.index.archived') %></span>
<div class="text-name">
<% if result_text.name.present? %>
<em>
<%= truncate(result_text.name, length: Constants::FILENAME_TRUNCATION_LENGTH) %>
</em>
<% end %>
</div>
<div class="user-time">
<%= t('projects.reports.elements.result_text.user_time', user: result.user.full_name, timestamp: l(timestamp, format: :full)) %>
</div>
</div>
<div class="report-element-body">
<div class="row">

View file

@ -1,4 +1,12 @@
<div class="report-element report-step-attachment-element report-step-text-element">
<div class="report-element-header">
<div class="text-name">
<% if step_text.name.present? %>
<em>
<%= truncate(step_text.name, length: Constants::FILENAME_TRUNCATION_LENGTH) %>
</em>
<% end %>
</div>
<div class="report-element-body">
<% if step_text.text.present? %>
<%= custom_auto_link(step_text.prepare_for_report(:text, export_all),