convertir en un fieldset con columnas

This commit is contained in:
f 2018-06-20 13:54:41 -03:00
parent a0ea4ca510
commit 6350a33043
No known key found for this signature in database
GPG key ID: F3FDAB97B5F9F7E7
4 changed files with 44 additions and 25 deletions

View file

@ -0,0 +1,6 @@
.form-group
= label_tag name.join('_'), template.help, id: name.join('_')
= render "posts/template_field/#{template.type}",
template: template,
name: name,
value: value

View file

@ -1,25 +1,30 @@
- template = local_assigns[:template]
%table.table.table-condensed.table-striped
%thead
%tr
- template.nested_fields.each do |nf|
%td= nf.help || nf.human
%td
- if template.array?
%button.btn.btn-success= t('posts.row.add')
%tbody
%tr
- template.nested_fields.each do |nf|
- value = @post.new? ? nf.values : @post.get_front_matter(template)[nf]
-# Si el template es un array, quiere decir que esperamos un array de hashes.
-# El 0 luego es reemplazado por un id temporal
- if template.array?
- name = [template.key, '', nf.key]
- else
- name = [template.key, nf.key]
%td= render "posts/template_field/#{nf.type}",
template: nf,
name: name,
value: value
- if template.array?
%td= fa_icon 'close', title: t('posts.row.del')
.field-items{class: template.key}
%small.text-muted= t('posts.table')
- if template.array?
.clearfix
%button.btn.btn-success= t('posts.row.add')
.field-item{class: template.key}
- if template.array?
.clearfix
%small.pull-right
= fa_icon 'close', title: t('posts.row.del')
= t('posts.row.del')
-# Separar los campos en dos columnas
- template.nested_fields.each_slice(2).to_a.each do |group|
.form-row
- group.each do |nf|
.col
-# 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?
- name = [template.key, '', nf.key]
- else
- name = [template.key, nf.key]
- if @post.new?
- value = nf.values
- else
- value = @post.get_front_matter(template)[nf]
= render 'posts/template_field/nested',
template: nf,
value: value,
name: name

View file

@ -207,3 +207,7 @@ en:
private: '🔒 The values of this field will remain private'
select:
placeholder: 'Type to filter available options'
table: 'This field is a group of fields, you can add more groups with the "Add group" button or remove them with the "Remove group" button.'
row:
add: 'Add group'
del: 'Remove group'

View file

@ -203,3 +203,7 @@ es:
private: '🔒 Los valores de este campo serán privados'
select:
placeholder: 'Empieza a escribir para filtrar las opciones disponibles'
table: 'Este campo es un grupo de campos, puede agregar los que necesites con el botón "Agregar grupo" o eliminar los que no con "Eliminar grupo"'
row:
add: 'Agregar grupo'
del: 'Eliminar grupo'