mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-07 21:55:20 +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),
|
tags: %w(img),
|
||||||
team: current_team
|
team: current_team
|
||||||
)
|
)
|
||||||
|
elsif form_field_value.is_a?(FormDatetimeFieldValue)
|
||||||
|
form_field_value&.formatted_localize
|
||||||
else
|
else
|
||||||
form_field_value&.formatted
|
form_field_value&.formatted
|
||||||
end
|
end
|
||||||
|
@ -144,7 +146,7 @@ module ReportsHelper
|
||||||
{
|
{
|
||||||
name: form_field.name,
|
name: form_field.name,
|
||||||
value: value,
|
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
|
submitted_by: form_field_value&.submitted_by&.full_name.to_s
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
|
@ -25,4 +25,12 @@ class FormDatetimeFieldValue < FormFieldValue
|
||||||
range? ? [datetime&.to_date, datetime_to&.to_date].join(' - ') : datetime&.to_date.to_s
|
range? ? [datetime&.to_date, datetime_to&.to_date].join(' - ') : datetime&.to_date.to_s
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
|
|
@ -26,13 +26,15 @@ module Reports
|
||||||
I18n.t('forms.export.values.not_applicable')
|
I18n.t('forms.export.values.not_applicable')
|
||||||
elsif form_field_value.is_a?(FormTextFieldValue)
|
elsif form_field_value.is_a?(FormTextFieldValue)
|
||||||
SmartAnnotations::TagToText.new(user, team, form_field_value&.formatted).text
|
SmartAnnotations::TagToText.new(user, team, form_field_value&.formatted).text
|
||||||
|
elsif form_field_value.is_a?(FormDatetimeFieldValue)
|
||||||
|
form_field_value&.formatted_localize
|
||||||
else
|
else
|
||||||
form_field_value&.formatted
|
form_field_value&.formatted
|
||||||
end
|
end
|
||||||
table << [
|
table << [
|
||||||
form_field.name,
|
form_field.name,
|
||||||
value,
|
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
|
form_field_value&.submitted_by&.full_name.to_s
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue