mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-11-10 08:21:37 +08:00
Fix form responses export [SCI-11506]
This commit is contained in:
parent
8b8d2900c1
commit
25c6f5d4fa
2 changed files with 18 additions and 8 deletions
|
|
@ -27,19 +27,29 @@ class FormResponsesZipExportJob < ZipExportJob
|
||||||
|
|
||||||
workbook.add_worksheet(name: 'Form submissions') do |sheet|
|
workbook.add_worksheet(name: 'Form submissions') do |sheet|
|
||||||
sheet.add_row build_header(form)
|
sheet.add_row build_header(form)
|
||||||
|
form_fields = form.form_fields
|
||||||
|
|
||||||
form.form_responses.where(status: 'submitted').find_each do |form_response|
|
form.form_responses.where(status: 'submitted').find_each do |form_response|
|
||||||
|
form_field_values = form_response.form_field_values
|
||||||
sheet.add_row do |row|
|
sheet.add_row do |row|
|
||||||
row.add_cell breadcrumbs(form_response)
|
row.add_cell breadcrumbs(form_response)
|
||||||
row.add_cell form_response.submitted_at.to_s
|
row.add_cell form_response.submitted_at.utc.to_s
|
||||||
row.add_cell form_response.submitted_by.full_name
|
row.add_cell form_response.submitted_by.full_name
|
||||||
form_response.form_field_values.joins(:form_field).where(latest: true).order(:position).each do |form_field_value|
|
form_fields.each do |form_field|
|
||||||
if form_field_value.value_in_range?
|
form_field_value = form_field_values.find_by(form_field_id: form_field.id, latest: true)
|
||||||
row.add_cell form_field_value.formatted
|
if form_field_value.present?
|
||||||
|
if form_field_value.value_in_range?
|
||||||
|
row.add_cell form_field_value.formatted
|
||||||
|
else
|
||||||
|
row.add_cell form_field_value.formatted, style: warning_bg_style
|
||||||
|
end
|
||||||
|
row.add_cell form_field_value.submitted_at.utc.to_s
|
||||||
|
row.add_cell form_field_value.submitted_by.full_name
|
||||||
else
|
else
|
||||||
row.add_cell form_field_value.formatted, style: warning_bg_style
|
row.add_cell ''
|
||||||
|
row.add_cell ''
|
||||||
|
row.add_cell ''
|
||||||
end
|
end
|
||||||
row.add_cell form_field_value.submitted_at.to_s
|
|
||||||
row.add_cell form_field_value.submitted_by.full_name
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,6 @@ class FormDatetimeFieldValue < FormFieldValue
|
||||||
end
|
end
|
||||||
|
|
||||||
def formatted
|
def formatted
|
||||||
range? ? [datetime, datetime_to].join(' - ') : datetime.to_s
|
range? ? [datetime.utc, datetime_to.utc].join(' - ') : datetime.utc.to_s
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue