diff --git a/app/models/post/template_field.rb b/app/models/post/template_field.rb index 681fefb8..10f35ec6 100644 --- a/app/models/post/template_field.rb +++ b/app/models/post/template_field.rb @@ -84,6 +84,14 @@ class Post end end + def cols + complex? && contents.dig('cols') + end + + def align + complex? && contents.dig('align') + end + # El campo es requerido si es complejo y se especifica que lo sea def required? complex? && contents.dig('required') diff --git a/app/views/posts/template_field/_table.haml b/app/views/posts/template_field/_table.haml index 7d7b89ae..c481664a 100644 --- a/app/views/posts/template_field/_table.haml +++ b/app/views/posts/template_field/_table.haml @@ -27,10 +27,10 @@ = fa_icon 'close', title: t('posts.row.del', group: template.key.humanize) = t('posts.row.del', group: template.key.humanize) -# Separar los campos en dos columnas - - template.nested_fields.each_slice(2).to_a.each do |col| - .form-row + - template.nested_fields.each_slice(template.cols || 2).to_a.each do |col| + .form-row{class: "align-items-#{template.align || 'start'}"} - col.each do |nf| - .col + .col-md -# Si el template es un array, quiere decir que esperamos un array de hashes. -# El valor vacĂ­o luego es reemplazado por un id temporal - if template.array? @@ -51,4 +51,4 @@ .extra-groups - if template.array? .clearfix - %button.btn.btn-success.btn-block.add-group= t('posts.row.add', group: template.key.humanize) + %button.btn.btn-success.btn-block.add-group{data: { group: template.key }}= t('posts.row.add', group: template.key.humanize)