poder especificar las columnas

This commit is contained in:
f 2018-07-23 17:42:51 -03:00
parent b3518aa6db
commit 4330393b3a
No known key found for this signature in database
GPG key ID: F3FDAB97B5F9F7E7
2 changed files with 12 additions and 4 deletions

View file

@ -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')

View file

@ -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)