mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-04 12:14:37 +08:00
Fix dates formatting in report templates [SCI-5774]
This commit is contained in:
parent
93a34fc343
commit
92821d7f1e
5 changed files with 29 additions and 2 deletions
|
@ -333,6 +333,11 @@
|
|||
}
|
||||
}
|
||||
|
||||
.datetime-picker-container {
|
||||
display: block;
|
||||
max-width: 40%;
|
||||
}
|
||||
|
||||
.sci-checkbox-container {
|
||||
float: left;
|
||||
margin-right: .5em;
|
||||
|
|
|
@ -1,8 +1,20 @@
|
|||
<% if @editing %>
|
||||
<div class="sci-input-container">
|
||||
<%= label_tag @name, @label %>
|
||||
<%= date_field_tag @name, @value, placeholder: @placeholder, class: 'sci-input-field', data: { type: 'DateInputComponent' } %>
|
||||
<div class="datetime-picker-container">
|
||||
<span class="fas fa-calendar-alt"></span>
|
||||
<input type="datetime"
|
||||
name="<%= @name %>"
|
||||
data-toggle='date-time-picker'
|
||||
class="sci-input-field"
|
||||
placeholder="<%= @placeholder %>"
|
||||
data-date-format="<%= datetime_picker_format_date_only %>"
|
||||
data-date-locale="<%= I18n.locale %>"
|
||||
data-date-use-current="false"
|
||||
data-type="DateInputComponent"
|
||||
value="<%= @value.present? ? l(Date.parse(@value), format: :full) : '' %>"/>
|
||||
</div>
|
||||
</div>
|
||||
<% else %>
|
||||
<%= @value %>
|
||||
<%= @value.present? ? l(Date.parse(@value), format: :full) : '' %>
|
||||
<% end %>
|
||||
|
|
|
@ -2,5 +2,6 @@
|
|||
|
||||
module Reports
|
||||
class DateInputComponent < TemplateValueComponent
|
||||
include BootstrapFormHelper
|
||||
end
|
||||
end
|
||||
|
|
|
@ -39,6 +39,12 @@ module ReportActions
|
|||
|
||||
if @template_values.present?
|
||||
formatted_template_values = @template_values.as_json.map { |k, v| v['name'] = k; v }
|
||||
formatted_template_values.each do |template_value|
|
||||
if template_value['view_component'] == 'DateInputComponent'
|
||||
template_value['value'] =
|
||||
Date.strptime(template_value['value'], I18n.backend.date_format.dup.gsub(/%-/, '%')).iso8601
|
||||
end
|
||||
end
|
||||
# Save new template values
|
||||
@report.report_template_values.create!(formatted_template_values)
|
||||
end
|
||||
|
|
|
@ -2291,6 +2291,9 @@ en:
|
|||
user_invalid: "Invalid email."
|
||||
too_many_emails: "Only invited first %{nr} emails. To invite more users, "
|
||||
|
||||
date:
|
||||
formats:
|
||||
full: "%{date_format}"
|
||||
time:
|
||||
formats:
|
||||
full_js: "D.M.YYYY HH:mm"
|
||||
|
|
Loading…
Add table
Reference in a new issue