mirror of
https://0xacab.org/sutty/sutty
synced 2024-12-01 10:06:22 +00:00
Merge branch 'issue-17333' into production.panel.sutty.nl
This commit is contained in:
commit
8118657b57
3 changed files with 20 additions and 3 deletions
|
@ -1,9 +1,26 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class MetadataDate < MetadataTemplate
|
||||
# La fecha de hoy si no hay nada
|
||||
#
|
||||
# @return [Date,nil]
|
||||
def default_value
|
||||
case (dv = super)
|
||||
when String
|
||||
if dv.present?
|
||||
begin
|
||||
Date.parse(dv)
|
||||
rescue Date::Error => e
|
||||
ExceptionNotifier.notify_exception(e, data: { site: site.name, post: post.id, name:, type: })
|
||||
nil
|
||||
end
|
||||
else
|
||||
nil
|
||||
end
|
||||
else
|
||||
Date.today
|
||||
end
|
||||
end
|
||||
|
||||
# Devuelve una fecha, si no hay ninguna es la fecha de hoy.
|
||||
#
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
%tr{ id: attribute }
|
||||
%th= post_label_t(attribute, post: post)
|
||||
%td{ dir: dir, lang: locale }= l metadata.value.to_date
|
||||
%td{ dir: dir, lang: locale }= l metadata.value
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
.form-group
|
||||
= label_tag "#{base}_#{attribute}", post_label_t(attribute, post: post)
|
||||
= date_field base, attribute, value: metadata.value.to_date.strftime('%F'),
|
||||
= date_field base, attribute, value: metadata.value&.strftime('%F'),
|
||||
**field_options(attribute, metadata), pattern: '\d{4}-\d{2}-\d{2}',
|
||||
data: { 'pattern-mismatch': t('metadata.date.invalid_format') }
|
||||
= render 'posts/attribute_feedback',
|
||||
|
|
Loading…
Reference in a new issue