a ver si con esto se arregla

This commit is contained in:
f 2020-06-03 10:57:52 -03:00
parent 4658fb0f5e
commit 2434c51f79
3 changed files with 12 additions and 6 deletions

View file

@ -11,8 +11,6 @@ class Site
# @return Array # @return Array
def params def params
map do |field, definition| map do |field, definition|
next if EXCLUDED_FIELDS.include? definition['type']
if ARRAY_FIELDS.include? definition['type'] if ARRAY_FIELDS.include? definition['type']
{ field.to_sym => [] } { field.to_sym => [] }
else else
@ -21,6 +19,9 @@ class Site
end.compact end.compact
end end
# Obtiene la traducción del campo
#
# @return String
def t(field) def t(field)
dig(field.to_s, 'label', I18n.locale.to_s) dig(field.to_s, 'label', I18n.locale.to_s)
end end
@ -46,12 +47,17 @@ class Site
forms.include? name.to_s forms.include? name.to_s
end end
# Obtiene un formulario # Obtiene un formulario con los campos definitivos
# #
# @return Site::Forms::Form # @return Site::Forms::Form
def form(name) def form(name)
@cached_forms ||= {} @cached_forms ||= {}
@cached_forms[name] ||= Form[data.dig('forms', name)] @cached_forms[name] ||= Form[data.dig('forms', name).reject { |k,_| excluded? k }]
end
# Detecta si el campo está excluido del formulario final
def excluded?(field)
EXCLUDED_FIELDS.include? field.to_s
end end
end end
end end

View file

@ -1,4 +1,4 @@
- @params[:form].each do |field, value| - @params[:form].each do |field, value|
%p %p
%strong= @params[:form_definition].t(field) || field + ':' %strong= @params[:form_definition].t(field) + ':'
= value = value

View file

@ -1,3 +1,3 @@
- @params[:form].each do |field, value| - @params[:form].each do |field, value|
"#{@params[:form_definition].t(field) || field}: #{value}" "#{@params[:form_definition].t(field)}: #{value}"
\ \