diff --git a/app/services/reports/docx/draw_my_module.rb b/app/services/reports/docx/draw_my_module.rb index ec1763f67..ddfefd7df 100644 --- a/app/services/reports/docx/draw_my_module.rb +++ b/app/services/reports/docx/draw_my_module.rb @@ -70,24 +70,26 @@ module Reports::Docx::DrawMyModule draw_step(step) end - @docx.h4 I18n.t('Results') if my_module.results.any? && (%w(file_results table_results text_results).any? { |k| @settings.dig('task', k) }) - order_results_for_report(my_module.results, @settings.dig('task', 'result_order')).each do |result| - @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] - end - draw_result_asset(result, @settings) - result.result_orderable_elements.each do |element| - if element.orderable_type == "ResultTable" - draw_result_table(element) - elsif element.orderable_type == "ResultText" - draw_result_text(element) + if my_module.results.any? && (%w(file_results table_results text_results).any? { |k| @settings.dig('task', k) }) + @docx.h4 I18n.t('Results') + order_results_for_report(my_module.results, @settings.dig('task', 'result_order')).each do |result| + @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] end + draw_result_asset(result, @settings) if @settings.dig('task', 'file_results') + result.result_orderable_elements.each do |element| + if @settings.dig('task', 'table_results') && element.orderable_type == 'ResultTable' + draw_result_table(element) + elsif @settings.dig('task', 'text_results') && element.orderable_type == 'ResultText' + draw_result_text(element) + end + end + draw_result_comments(result) if @settings.dig('task', 'result_comments') end - draw_result_comments(result) if @settings.dig('task', 'result_comments') end @docx.p diff --git a/app/views/reports/elements/_my_module_element.html.erb b/app/views/reports/elements/_my_module_element.html.erb index 5d91b2d0a..9f0c30da2 100644 --- a/app/views/reports/elements/_my_module_element.html.erb +++ b/app/views/reports/elements/_my_module_element.html.erb @@ -67,38 +67,40 @@ <% end %> - <% if %w(file_results table_results text_results).any? { |k| @settings.dig('task', k) } %> + <% if my_module.results.any? && %w(file_results table_results text_results).any? { |k| @settings.dig('task', k) } %>
<%= t('projects.reports.elements.module.results') %>

- <% end %> - <% order_results_for_report(my_module.results, @settings.dig('task', 'result_order')).each do |result| %> -
- <%= result.name.presence || I18n.t('projects.reports.unnamed') %> - <% if result.archived? %> - <%= t('search.index.archived') %> - <% end %> -
+ <% order_results_for_report(my_module.results, @settings.dig('task', 'result_order')).each do |result| %> +
+ <%= result.name.presence || I18n.t('projects.reports.unnamed') %> + <% if result.archived? %> + <%= t('search.index.archived') %> + <% end %> +
- <% result.result_orderable_elements.each do |element| %> - <% if element.orderable_type == "ResultTable" %> - <%= render partial: 'reports/elements/my_module_result_table_element', locals: { result: result, export_all: export_all, element: element} %> - <% elsif element.orderable_type == "ResultText" %> - <%= render partial: 'reports/elements/my_module_result_text_element', locals: { result: result, export_all: export_all, element: element } %> + <% result.result_orderable_elements.each do |element| %> + <% if element.orderable_type == "ResultTable" && @settings.dig('task', 'table_results') %> + <%= render partial: 'reports/elements/my_module_result_table_element', locals: { result: result, export_all: export_all, element: element} %> + <% elsif element.orderable_type == "ResultText" && @settings.dig('task', 'text_results') %> + <%= render partial: 'reports/elements/my_module_result_text_element', locals: { result: result, export_all: export_all, element: element } %> + <% end %> <% end %> + + <% if @settings.dig('task', 'file_results') %> + <%= render partial: 'reports/elements/my_module_result_asset_element', locals: { result: result, report: report, export_all: export_all } %> +
+ <%= t('projects.reports.elements.result.user_time', user: result.user.full_name, timestamp: l(result.created_at, format: :full)) %> +
+ <% end %> + +
+ <% if @settings.dig('task', 'result_comments') %> + <%= render partial: 'reports/elements/result_comments_element', locals: { result: result } %> + <% end %> +
<% end %> - - <%= render partial: 'reports/elements/my_module_result_asset_element', locals: { result: result, report: report, export_all: export_all } %> -
- <%= t('projects.reports.elements.result.user_time', user: result.user.full_name, timestamp: l(result.created_at, format: :full)) %> -
- -
- <% if @settings.dig('task', 'result_comments') %> - <%= render partial: 'reports/elements/result_comments_element', locals: { result: result } %> - <% end %> -
<% end %>