Render report element children container only if children are present [SCI-5739]

This commit is contained in:
Oleksii Kriuchykhin 2021-05-20 14:16:39 +02:00
parent ed1467635f
commit 7bfde7dc1e
15 changed files with 77 additions and 49 deletions

View file

@ -31,7 +31,7 @@ class ReportsController < ApplicationController
before_action :check_manage_permissions, only: BEFORE_ACTION_METHODS
before_action :switch_team_with_param, only: :index
after_action :generate_pdf_report, only: %i(create update)
after_action :generate_pdf_report, only: %i(create update generate_pdf)
# Index showing all reports of a single project
def index; end
@ -101,7 +101,6 @@ class ReportsController < ApplicationController
).save_with_content
if @report.errors.blank?
@report.pdf_processing!
log_activity(:create_report)
flash[:success] = t('projects.reports.index.generation.accepted_message')
@ -138,7 +137,6 @@ class ReportsController < ApplicationController
).save_with_content
if @report.errors.blank?
@report.pdf_processing!
log_activity(:edit_report)
flash[:success] = t('projects.reports.index.generation.accepted_message')
@ -194,9 +192,6 @@ class ReportsController < ApplicationController
def generate_pdf
respond_to do |format|
format.json do
@report.pdf_processing!
log_activity(:generate_pdf_report)
Reports::PdfJob.perform_later(@report.id, current_user)
render json: {
message: I18n.t('projects.reports.index.generation.accepted_message')
}
@ -562,7 +557,10 @@ class ReportsController < ApplicationController
end
def generate_pdf_report
return unless @report.persisted?
@report.pdf_processing!
log_activity(:generate_pdf_report)
Reports::PdfJob.perform_later(@report.id, current_user) if @report.persisted?
Reports::PdfJob.perform_later(@report.id, current_user)
end
end

View file

@ -41,7 +41,9 @@
</div>
</div>
</div>
<div class="report-element-children">
<%= children if (defined? children and children.present?) %>
</div>
<% if defined?(children) %>
<div class="report-element-children">
<%= children %>
</div>
<% end %>
</div>

View file

@ -44,7 +44,9 @@
</div>
</div>
</div>
<div class="report-element-children">
<%= children if (defined? children and children.present?) %>
</div>
<% if defined?(children) %>
<div class="report-element-children">
<%= children %>
</div>
<% end %>
</div>

View file

@ -99,9 +99,13 @@
<% end %>
<% end %>
</div>
<div class="report-element-children">
<%= children if (defined? children and children.present?) %>
</div>
<% if defined?(children) %>
<div class="report-element-children">
<%= children %>
</div>
<% end %>
<% if @settings.dig('task', 'activities') %>
<div class="report-element-children">
<%= render partial: 'reports/elements/my_module_activity_element.html.erb', locals: { my_module: my_module } %>

View file

@ -47,7 +47,9 @@
</div>
<% end %>
</div>
<div class="report-element-children">
<%= children if defined?(children) && children.present? %>
</div>
<% if defined?(children) %>
<div class="report-element-children">
<%= children %>
</div>
<% end %>
</div>

View file

@ -65,7 +65,9 @@
<%= render partial: 'reports/elements/result_comments_element.html.erb', locals: { result: result } %>
<% end %>
</div>
<div class="report-element-children">
<%= children if (defined? children and children.present?) %>
</div>
<% if defined?(children) %>
<div class="report-element-children">
<%= children %>
</div>
<% end %>
</div>

View file

@ -43,7 +43,9 @@
<%= render partial: 'reports/elements/result_comments_element.html.erb', locals: { result: result } %>
<% end %>
</div>
<div class="report-element-children">
<%= children if (defined? children and children.present?) %>
</div>
<% if defined?(children) %>
<div class="report-element-children">
<%= children %>
</div>
<% end %>
</div>

View file

@ -40,7 +40,9 @@
<%= render partial: 'reports/elements/result_comments_element.html.erb', locals: { result: result } %>
<% end %>
</div>
<div class="report-element-children">
<%= children if (defined? children and children.present?) %>
</div>
<% if defined?(children) %>
<div class="report-element-children">
<%= children %>
</div>
<% end %>
</div>

View file

@ -68,7 +68,9 @@
<%= render partial: 'reports/elements/step_comments_element.html.erb', locals: { step: step } %>
<% end %>
</div>
<div class="report-element-children">
<%= children if (defined? children and children.present?) %>
</div>
<% if defined?(children) %>
<div class="report-element-children">
<%= children %>
</div>
<% end %>
</div>

View file

@ -20,7 +20,9 @@
</div>
</div>
</div>
<div class="report-element-children">
<%= children if (defined? children and children.present?) %>
</div>
<% if defined?(children) %>
<div class="report-element-children">
<%= children %>
</div>
<% end %>
</div>

View file

@ -32,7 +32,9 @@
</div>
</div>
</div>
<div class="report-element-children">
<%= children if (defined? children and children.present?) %>
</div>
<% if defined?(children) %>
<div class="report-element-children">
<%= children %>
</div>
<% end %>
</div>

View file

@ -42,7 +42,9 @@
</div>
<% end %>
</div>
<div class="report-element-children">
<%= children if (defined? children and children.present?) %>
</div>
<% if defined?(children) %>
<div class="report-element-children">
<%= children %>
</div>
<% end %>
</div>

View file

@ -38,7 +38,9 @@
<% end %>
</ul>
</div>
<div class="report-element-children">
<%= children if (defined? children and children.present?) %>
</div>
<% if defined?(children) %>
<div class="report-element-children">
<%= children %>
</div>
<% end %>
</div>

View file

@ -32,7 +32,9 @@
</div>
</div>
</div>
<div class="report-element-children">
<%= children if (defined? children and children.present?) %>
</div>
<% if defined?(children) %>
<div class="report-element-children">
<%= children %>
</div>
<% end %>
</div>

View file

@ -33,7 +33,9 @@
<div class="hot-table-container"></div>
<table class="report-common-table-format"></table>
</div>
<div class="report-element-children">
<%= children if (defined? children and children.present?) %>
</div>
<% if defined?(children) %>
<div class="report-element-children">
<%= children %>
</div>
<% end %>
</div>