5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-15 03:31:42 +00:00

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
def params
map do |field, definition|
next if EXCLUDED_FIELDS.include? definition['type']
if ARRAY_FIELDS.include? definition['type']
{ field.to_sym => [] }
else
@ -21,6 +19,9 @@ class Site
end.compact
end
# Obtiene la traducción del campo
#
# @return String
def t(field)
dig(field.to_s, 'label', I18n.locale.to_s)
end
@ -46,12 +47,17 @@ class Site
forms.include? name.to_s
end
# Obtiene un formulario
# Obtiene un formulario con los campos definitivos
#
# @return Site::Forms::Form
def form(name)
@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

View file

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

View file

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