Merge pull request #7799 from aignatov-bio/ai-sci-10978-checkbox-to-hide-metadata-from-reports

Add exclude metadata from reports [SCI-10978]
This commit is contained in:
aignatov-bio 2024-08-19 14:09:41 +02:00 committed by GitHub
commit 36821c691f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
29 changed files with 184 additions and 106 deletions

View file

@ -1052,6 +1052,8 @@ function reportHandsonTableConverter() {
reportData.report.settings.task.result_order = dropdownSelector.getValues('#taskResultsOrder');
reportData.report.settings.exclude_metadata = $('.exclude-metadata-setting')[0].checked;
return reportData;
}

View file

@ -4,6 +4,7 @@ module Reports::Docx::DrawExperiment
def draw_experiment(subject)
color = @color
link_style = @link_style
settings = @settings
scinote_url = @scinote_url
experiment = subject.experiment
return unless can_read_experiment?(@user, experiment)
@ -15,8 +16,10 @@ module Reports::Docx::DrawExperiment
end
@docx.p do
text I18n.t('projects.reports.elements.experiment.user_time',
code: experiment.code, timestamp: I18n.l(experiment.created_at, format: :full)), color: color[:gray]
unless settings['exclude_metadata']
text I18n.t('projects.reports.elements.experiment.user_time',
code: experiment.code, timestamp: I18n.l(experiment.created_at, format: :full)), color: color[:gray]
end
if experiment.archived?
text ' | '
text I18n.t('search.index.archived'), color: color[:gray]

View file

@ -4,6 +4,7 @@ module Reports::Docx::DrawMyModule
def draw_my_module(subject, without_results: false, without_repositories: false)
color = @color
link_style = @link_style
settings = @settings
scinote_url = @scinote_url
my_module = subject.my_module
tags = my_module.tags.order(:id)
@ -16,8 +17,10 @@ module Reports::Docx::DrawMyModule
end
@docx.p do
text I18n.t('projects.reports.elements.module.user_time', code: my_module.code,
timestamp: I18n.l(my_module.created_at, format: :full)), color: color[:gray]
unless settings['exclude_metadata']
text I18n.t('projects.reports.elements.module.user_time', code: my_module.code,
timestamp: I18n.l(my_module.created_at, format: :full)), color: color[:gray]
end
if my_module.archived?
text ' | '
text I18n.t('search.index.archived'), color: color[:gray]
@ -38,22 +41,24 @@ module Reports::Docx::DrawMyModule
end
end
status = my_module.my_module_status
@docx.p do
text I18n.t('projects.reports.elements.module.status')
text ' '
text "[#{status.name}]", color: (status.light_color? ? '000000' : status.color.delete('#'))
if my_module.completed?
text " #{I18n.t('my_modules.states.completed')} #{I18n.l(my_module.completed_on, format: :full)}"
end
end
if tags.present?
unless settings['exclude_metadata']
status = my_module.my_module_status
@docx.p do
text I18n.t('projects.reports.elements.module.tags_header')
tags.each do |tag|
text ' '
text "[#{tag.name}]", color: tag.color.delete('#')
text I18n.t('projects.reports.elements.module.status')
text ' '
text "[#{status.name}]", color: (status.light_color? ? '000000' : status.color.delete('#'))
if my_module.completed?
text " #{I18n.t('my_modules.states.completed')} #{I18n.l(my_module.completed_on, format: :full)}"
end
end
if tags.present?
@docx.p do
text I18n.t('projects.reports.elements.module.tags_header')
tags.each do |tag|
text ' '
text "[#{tag.name}]", color: tag.color.delete('#')
end
end
end
end

View file

@ -12,8 +12,10 @@ module Reports::Docx::DrawMyModuleProtocol
end
if @settings.dig('task', 'protocol', 'description') && protocol.description.present?
@docx.p I18n.t('projects.reports.elements.module.protocol.user_time', code: protocol.original_code,
timestamp: I18n.l(protocol.created_at, format: :full)), color: @color[:gray]
unless @settings['exclude_metadata']
@docx.p I18n.t('projects.reports.elements.module.protocol.user_time', code: protocol.original_code,
timestamp: I18n.l(protocol.created_at, format: :full)), color: @color[:gray]
end
html = custom_auto_link(protocol.description, team: @report_team)
Reports::HtmlToWordConverter.new(@docx, { scinote_url: @scinote_url,
link_style: @link_style }).html_to_word_converter(html)

View file

@ -15,10 +15,12 @@ module Reports::Docx::DrawProjectHeader
link_style
end
@docx.p do
text I18n.t('projects.reports.elements.project_header.user_time', code: project.code,
timestamp: I18n.l(project.created_at, format: :full)), color: color[:gray]
br
unless @settings['exclude_metadata']
@docx.p do
text I18n.t('projects.reports.elements.project_header.user_time', code: project.code,
timestamp: I18n.l(project.created_at, format: :full)), color: color[:gray]
br
end
end
end
end

View file

@ -25,8 +25,10 @@ module Reports::Docx::DrawResultAsset
end
text " #{I18n.t('search.index.archived')} ", bold: true if result.archived?
text ' ' + I18n.t('projects.reports.elements.result_asset.file_name', file: asset.file_name)
text ' ' + I18n.t('projects.reports.elements.result_asset.user_time',
user: result.user.full_name, timestamp: I18n.l(timestamp, format: :full)), color: color[:gray]
unless settings['exclude_metadata']
text ' ' + I18n.t('projects.reports.elements.result_asset.user_time',
user: result.user.full_name, timestamp: I18n.l(timestamp, format: :full)), color: color[:gray]
end
if settings.dig(:task, :file_results_previews) && ActiveStorageFileUtil.previewable_document?(asset&.file&.blob)
text " #{I18n.t('projects.reports.elements.result_asset.full_preview_attached')}", color: color[:gray]

View file

@ -5,6 +5,7 @@ module Reports::Docx::DrawResultTable
result = element.result
table = element.orderable.table
timestamp = table.created_at
settings = @settings
color = @color
obj = self
table_data = JSON.parse(table.contents_utf_8)['data']
@ -40,8 +41,10 @@ module Reports::Docx::DrawResultTable
@docx.p do
text I18n.t 'projects.reports.elements.result_table.table_name', name: table.name
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]
unless settings['exclude_metadata']
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
end
end
end

View file

@ -4,12 +4,15 @@ module Reports::Docx::DrawResultText
def draw_result_text(element)
result_text = element.orderable
timestamp = element.created_at
settings = @settings
color = @color
@docx.p do
text result_text.name.presence || '', italic: true
text ' '
text I18n.t('projects.reports.elements.result_text.user_time',
timestamp: I18n.l(timestamp, format: :full)), color: color[:gray]
unless settings['exclude_metadata']
text I18n.t('projects.reports.elements.result_text.user_time',
timestamp: I18n.l(timestamp, format: :full)), color: color[:gray]
end
end
html = custom_auto_link(result_text.text, team: @report_team)
Reports::HtmlToWordConverter.new(@docx, { scinote_url: @scinote_url,

View file

@ -3,6 +3,7 @@
module Reports::Docx::DrawResults
def draw_results(my_module)
color = @color
settings = @settings
return unless can_read_my_module?(@user, my_module)
if my_module.results.any? && (%w(file_results table_results text_results).any? { |k| @settings.dig('task', k) })
@ -11,9 +12,11 @@ module Reports::Docx::DrawResults
@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 I18n.t('projects.reports.elements.result.user_time',
timestamp: I18n.l(result.created_at, format: :full),
user: result.user.full_name), color: color[:gray]
unless settings['exclude_metadata']
text I18n.t('projects.reports.elements.result.user_time',
timestamp: I18n.l(result.created_at, format: :full),
user: result.user.full_name), color: color[:gray]
end
end
draw_result_asset(result, @settings) if @settings.dig('task', 'file_results')
result.result_orderable_elements.each do |element|

View file

@ -6,6 +6,7 @@ module Reports::Docx::DrawStep
step_type_str = step.completed ? 'completed' : 'uncompleted'
user = (step.completed? && step.last_modified_by) || step.user
timestamp = step.completed ? step.completed_on : step.created_at
settings = @settings
@docx.p
@docx.h4(
"#{I18n.t('projects.reports.elements.step.step_pos', pos: step.position_plus_one)} #{step.name}"
@ -17,11 +18,13 @@ module Reports::Docx::DrawStep
text I18n.t('protocols.steps.uncompleted'), color: color[:gray], bold: true
end
text ' | '
text I18n.t(
"projects.reports.elements.step.#{step_type_str}.user_time",
user: user.full_name,
timestamp: I18n.l(timestamp, format: :full)
), color: color[:gray]
unless settings['exclude_metadata']
text I18n.t(
"projects.reports.elements.step.#{step_type_str}.user_time",
user: user.full_name,
timestamp: I18n.l(timestamp, format: :full)
), color: color[:gray]
end
end
step.step_orderable_elements.order(:position).each do |element|

View file

@ -5,6 +5,7 @@ module Reports::Docx::DrawStepAsset
timestamp = asset.created_at
asset_url = Rails.application.routes.url_helpers.asset_download_url(asset)
color = @color
settings = @settings
@docx.p
begin
@ -23,8 +24,10 @@ module Reports::Docx::DrawStepAsset
italic true
end
text ' '
text I18n.t('projects.reports.elements.step_asset.user_time',
timestamp: I18n.l(timestamp, format: :full)), color: color[:gray]
unless settings['exclude_metadata']
text I18n.t('projects.reports.elements.step_asset.user_time',
timestamp: I18n.l(timestamp, format: :full)), color: color[:gray]
end
end
end
end

View file

@ -4,6 +4,7 @@ module Reports::Docx::DrawStepChecklist
def draw_step_checklist(checklist)
team = @report_team
user = @user
settings = @settings
items = checklist.checklist_items
timestamp = checklist.created_at
@ -16,8 +17,10 @@ module Reports::Docx::DrawStepChecklist
I18n.t('projects.reports.elements.step_checklist.checklist_name', name: checklist.name)
).text, italic: true
text ' '
text I18n.t('projects.reports.elements.step_checklist.user_time',
timestamp: I18n.l(timestamp, format: :full)), color: color[:gray]
unless settings['exclude_metadata']
text I18n.t('projects.reports.elements.step_checklist.user_time',
timestamp: I18n.l(timestamp, format: :full)), color: color[:gray]
end
end
if items.any?
@docx.ul do

View file

@ -4,6 +4,7 @@ module Reports::Docx::DrawStepTable
def draw_step_table(table, table_type)
color = @color
timestamp = table.created_at
settings = @settings
obj = self
table_data = JSON.parse(table.contents_utf_8)['data']
table_data = obj.add_headers_to_table(table_data, table_type == 'step_well_plates_table')
@ -39,8 +40,10 @@ module Reports::Docx::DrawStepTable
@docx.p do
text I18n.t("projects.reports.elements.#{table_type}.table_name", name: table.name), italic: true
text ' '
text I18n.t("projects.reports.elements.#{table_type}.user_time",
timestamp: I18n.l(timestamp, format: :full)), color: color[:gray]
unless settings['exclude_metadata']
text I18n.t("projects.reports.elements.#{table_type}.user_time",
timestamp: I18n.l(timestamp, format: :full)), color: color[:gray]
end
end
end
end

View file

@ -5,11 +5,14 @@ module Reports::Docx::DrawStepText
step_text = element.orderable
timestamp = element.created_at
color = @color
settings = @settings
@docx.p do
text step_text.name.presence || '', italic: true
text ' '
text I18n.t('projects.reports.elements.result_text.user_time',
timestamp: I18n.l(timestamp, format: :full)), color: color[:gray]
unless settings['exclude_metadata']
text I18n.t('projects.reports.elements.result_text.user_time',
timestamp: I18n.l(timestamp, format: :full)), color: color[:gray]
end
end
if step_text.text.present?
html = custom_auto_link(step_text.text, team: @report_team)

View file

@ -9,9 +9,11 @@
<span class="label label-warning"><%= t('search.index.archived') %></span>
<% end %>
</h3>
<div class="user-time">
<%= t('projects.reports.elements.experiment.user_time', code: experiment.code, timestamp: l(timestamp, format: :full)) %>
</div>
<% unless @settings['exclude_metadata'] %>
<div class="user-time">
<%= t('projects.reports.elements.experiment.user_time', code: experiment.code, timestamp: l(timestamp, format: :full)) %>
</div>
<% end %>
<% if experiment.description.present? %>
<%= custom_auto_link(experiment.description, team: current_team, base64_encoded_imgs: export_all) %>
<% end %>

View file

@ -9,9 +9,11 @@
<span class="label label-warning"><%= t('search.index.archived') %></span>
<% end %>
</h4>
<div class="user-time">
<%= t('projects.reports.elements.module.user_time', code: my_module.code, timestamp: l(timestamp, format: :full)) %>
</div>
<% unless @settings['exclude_metadata'] %>
<div class="user-time">
<%= t('projects.reports.elements.module.user_time', code: my_module.code, timestamp: l(timestamp, format: :full)) %>
</div>
<% end %>
<p class="module-start-date">
<% if my_module.started_on.present? %>
<%= t('projects.reports.elements.module.started_on', started_on: l(my_module.started_on, format: :full)) %>
@ -22,32 +24,36 @@
<%= t('projects.reports.elements.module.due_date', due_date: l(my_module.due_date, format: :full)) %>
<% end %>
</p>
<p class="module-status">
<% status = my_module.my_module_status %>
<%= t('projects.reports.elements.module.status') %>
<span class="status-block" style="background: <%= status.color %>;
<%= 'color: #000000; border: 1px solid #D0D5DD;' if status.light_color? %>">
<%= status.name %>
</span>
<% if my_module.completed? %>
<span style="margin-left: 10px;">
<%= t('my_modules.states.completed') %>
<%= l(my_module.completed_on, format: :full) %>
<% unless @settings['exclude_metadata'] %>
<p class="module-status">
<% status = my_module.my_module_status %>
<%= t('projects.reports.elements.module.status') %>
<span class="status-block" style="background: <%= status.color %>;
<%= 'color: #000000; border: 1px solid #D0D5DD;' if status.light_color? %>">
<%= status.name %>
</span>
<% end %>
</p>
<div class="row module-tags">
<div class="pull-left">
<%= t('projects.reports.elements.module.tags_header') %>
</div>
<% if (tags = my_module.tags.order(:id)).present? %>
<% tags.each do |tag| %>
<div class="pull-left module-tag" style="background-color: <%= tag.color %>;">
<%= tag.name %>
</div>
<% if my_module.completed? %>
<span style="margin-left: 10px;">
<%= t('my_modules.states.completed') %>
<%= l(my_module.completed_on, format: :full) %>
</span>
<% end %>
<% end %>
</div>
</p>
<% end %>
<% unless @settings['exclude_metadata'] %>
<div class="row module-tags">
<div class="pull-left">
<%= t('projects.reports.elements.module.tags_header') %>
</div>
<% if (tags = my_module.tags.order(:id)).present? %>
<% tags.each do |tag| %>
<div class="pull-left module-tag" style="background-color: <%= tag.color %>;">
<%= tag.name %>
</div>
<% end %>
<% end %>
</div>
<% end %>
<div class="row">
<div class="col-xs-12">
<% if my_module.description.present? %>

View file

@ -9,9 +9,11 @@
<%= t('projects.reports.elements.module.protocol.name') %>
<% end %>
</h4>
<div class="user-time">
<%= t('projects.reports.elements.module.protocol.user_time', code: protocol.original_code, timestamp: l(protocol.created_at, format: :full)) %>
</div>
<% unless @settings['exclude_metadata'] %>
<div class="user-time">
<%= t('projects.reports.elements.module.protocol.user_time', code: protocol.original_code, timestamp: l(protocol.created_at, format: :full)) %>
</div>
<% end %>
<div class="row module-protocol-description">
<% if @settings.dig('task', 'protocol', 'description') && protocol.description.present? %>
<%= custom_auto_link(protocol.prepare_for_report(:description, export_all: export_all),

View file

@ -26,7 +26,9 @@
<% end %>
</div>
<div class="user-time">
<%= t("projects.reports.elements.result_asset.user_time", user: result.user.full_name, timestamp: l(timestamp, format: :full)) %>
<% unless @settings['exclude_metadata'] %>
<%= t("projects.reports.elements.result_asset.user_time", user: result.user.full_name, timestamp: l(timestamp, format: :full)) %>
<% end %>
<% if report.settings.dig(:task, :file_results_previews) && ActiveStorageFileUtil.previewable_document?(asset&.file&.blob) %>
<%= t('projects.reports.elements.result_asset.full_preview_attached') %>
<% end %>

View file

@ -21,9 +21,11 @@
<% end %>
<% end %>
</div>
<div class="user-time">
<%= t('projects.reports.elements.result_table.user_time', timestamp: l(timestamp, format: :full)) %>
</div>
<% unless @settings['exclude_metadata'] %>
<div class="user-time">
<%= t('projects.reports.elements.result_table.user_time', timestamp: l(timestamp, format: :full)) %>
</div>
<% end %>
</div>
<div class="report-element-body">
<input type="hidden" class="hot-table-contents" value="<%= table.contents_utf_8.gsub(/\</, '&lt;').gsub(/\>/, '&gt;') %>" />

View file

@ -11,9 +11,11 @@
</em>
<% end %>
</div>
<div class="user-time">
<%= t("projects.reports.elements.result_text.user_time", timestamp: l(timestamp, format: :full)) %>
</div>
<% unless @settings['exclude_metadata'] %>
<div class="user-time">
<%= t("projects.reports.elements.result_text.user_time", timestamp: l(timestamp, format: :full)) %>
</div>
<% end %>
</div>
<div class="report-element-body">
<div class="row">

View file

@ -10,9 +10,11 @@
<b><%= t('projects.reports.elements.step.step_pos', pos: (step.position_plus_one)) %></b>&nbsp;<%= step.name %>
<%= step_status_label(step) %>
</h5>
<div class="user-time">
<%= t("projects.reports.elements.step.#{step_type_str}.user_time", user: user.full_name , timestamp: l(timestamp, format: :full)) %>
</div>
<% unless @settings['exclude_metadata'] %>
<div class="user-time">
<%= t("projects.reports.elements.step.#{step_type_str}.user_time", user: user.full_name , timestamp: l(timestamp, format: :full)) %>
</div>
<% end %>
</div>
<div class="report-element-children">
<% step.step_orderable_elements.order(:position).each do |e| %>

View file

@ -7,9 +7,11 @@
<span class="label label-warning"><%= t('search.index.archived') %></span>
<% end %>
</h2>
<div class="user-time">
<%= t('projects.reports.elements.project_header.user_time', code: project.code, timestamp: l(project.created_at, format: :full)) %>
</div>
<% unless @settings['exclude_metadata'] %>
<div class="user-time">
<%= t('projects.reports.elements.project_header.user_time', code: project.code, timestamp: l(project.created_at, format: :full)) %>
</div>
<% end %>
</div>
<% if defined?(children) %>
<div class="report-element-children">

View file

@ -18,9 +18,11 @@
</em>
<% end %>
</span>
<div class="user-time">
&nbsp;<%= t('projects.reports.elements.step_asset.user_time', timestamp: l(timestamp, format: :full)) %>
</div>
<% unless @settings['exclude_metadata'] %>
<div class="user-time">
&nbsp;<%= t('projects.reports.elements.step_asset.user_time', timestamp: l(timestamp, format: :full)) %>
</div>
<% end %>
</div>
<div class="report-element-body">
<% if asset.previewable? && !asset.list? %>

View file

@ -9,9 +9,11 @@
team: current_team,
base64_encoded_imgs: export_all) %>
</div>
<div class="user-time">
<%= t('projects.reports.elements.step_checklist.user_time', timestamp: l(timestamp, format: :full)) %>
</div>
<% unless @settings['exclude_metadata'] %>
<div class="user-time">
<%= t('projects.reports.elements.step_checklist.user_time', timestamp: l(timestamp, format: :full)) %>
</div>
<% end %>
</div>
<div class="report-element-body">
<% items.each do |item| %>

View file

@ -18,9 +18,11 @@
<% end %>
<% end %>
</div>
<div class="user-time">
<%= t("projects.reports.elements.#{table_type}.user_time", timestamp: l(timestamp, format: :full)) %>
</div>
<% unless @settings['exclude_metadata'] %>
<div class="user-time">
<%= t("projects.reports.elements.#{table_type}.user_time", timestamp: l(timestamp, format: :full)) %>
</div>
<% end %>
</div>
<div class="report-element-body">
<input type="hidden" class="hot-table-contents" value="<%= table.contents_utf_8.gsub(/\</, '&lt;').gsub(/\>/, '&gt;') %>" />

View file

@ -8,9 +8,11 @@
</em>
<% end %>
</div>
<div class="user-time">
<%= t("projects.reports.elements.step_text.user_time", timestamp: l(timestamp, format: :full)) %>
</div>
<% unless @settings['exclude_metadata'] %>
<div class="user-time">
<%= t("projects.reports.elements.step_text.user_time", timestamp: l(timestamp, format: :full)) %>
</div>
<% end %>
</div>
<div class="report-element-body">
<% if step_text.text.present? %>

View file

@ -194,6 +194,16 @@
<div class="divider"></div>
</div>
</li>
<li>
<div class="select-all-container">
<span class="sci-checkbox-container">
<input type="checkbox" class="sci-checkbox exclude-metadata-setting" value="exclude_metadata" <%= 'checked' if report.settings.dig(:exclude_metadata) %>/>
<span class="sci-checkbox-label"></span>
</span>
<%= t("projects.reports.wizard.third_step.exclude_metadata") %>
<div class="divider"></div>
</div>
</li>
</ul>
</ul>
</div>

View file

@ -35,7 +35,6 @@ development:
# The password associated with the postgres role (username).
# password: mysecretpassword
# Connect on a TCP socket. Omitted by default since the client uses a
# domain socket that doesn't need configuration. Windows does not have
# domain sockets, so uncomment these lines.

View file

@ -851,6 +851,7 @@ en:
results_comments: "Result comments"
additional_content: "Additional content"
task_activity: "Include task activity"
exclude_metadata: "Exclude metadata"
archived: "[archived]"
deleted: "[deleted]"