mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-06 21:24:23 +08:00
Fix date format for form response in reports [SCI-11811]
This commit is contained in:
parent
16c9d8fa71
commit
fde255b132
3 changed files with 14 additions and 2 deletions
|
@ -137,6 +137,8 @@ module ReportsHelper
|
|||
tags: %w(img),
|
||||
team: current_team
|
||||
)
|
||||
elsif form_field_value.is_a?(FormDatetimeFieldValue)
|
||||
form_field_value&.formatted_localize
|
||||
else
|
||||
form_field_value&.formatted
|
||||
end
|
||||
|
@ -144,7 +146,7 @@ module ReportsHelper
|
|||
{
|
||||
name: form_field.name,
|
||||
value: value,
|
||||
submitted_at: form_field_value&.submitted_at&.utc.to_s,
|
||||
submitted_at: form_field_value&.submitted_at ? I18n.l(form_field_value&.submitted_at) : '',
|
||||
submitted_by: form_field_value&.submitted_by&.full_name.to_s
|
||||
}
|
||||
end
|
||||
|
|
|
@ -25,4 +25,12 @@ class FormDatetimeFieldValue < FormFieldValue
|
|||
range? ? [datetime&.to_date, datetime_to&.to_date].join(' - ') : datetime&.to_date.to_s
|
||||
end
|
||||
end
|
||||
|
||||
def formatted_localize
|
||||
format = form_field.data['time'] ? :full : :full_date
|
||||
from = datetime ? I18n.l(datetime, format: format) : ''
|
||||
to = datetime_to ? I18n.l(datetime_to, format: format) : ''
|
||||
|
||||
range? ? [from, to].join(' - ') : from
|
||||
end
|
||||
end
|
||||
|
|
|
@ -26,13 +26,15 @@ module Reports
|
|||
I18n.t('forms.export.values.not_applicable')
|
||||
elsif form_field_value.is_a?(FormTextFieldValue)
|
||||
SmartAnnotations::TagToText.new(user, team, form_field_value&.formatted).text
|
||||
elsif form_field_value.is_a?(FormDatetimeFieldValue)
|
||||
form_field_value&.formatted_localize
|
||||
else
|
||||
form_field_value&.formatted
|
||||
end
|
||||
table << [
|
||||
form_field.name,
|
||||
value,
|
||||
form_field_value&.submitted_at&.utc.to_s,
|
||||
form_field_value&.submitted_at ? I18n.l(form_field_value&.submitted_at) : '',
|
||||
form_field_value&.submitted_by&.full_name.to_s
|
||||
]
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue