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] .field-items{class: template.key}
%table.table.table-condensed.table-striped %small.text-muted= t('posts.table')
%thead - if template.array?
%tr .clearfix
- template.nested_fields.each do |nf| %button.btn.btn-success= t('posts.row.add')
%td= nf.help || nf.human .field-item{class: template.key}
%td - if template.array?
- if template.array? .clearfix
%button.btn.btn-success= t('posts.row.add') %small.pull-right
%tbody = fa_icon 'close', title: t('posts.row.del')
%tr = t('posts.row.del')
- template.nested_fields.each do |nf| -# Separar los campos en dos columnas
- value = @post.new? ? nf.values : @post.get_front_matter(template)[nf] - template.nested_fields.each_slice(2).to_a.each do |group|
-# Si el template es un array, quiere decir que esperamos un array de hashes. .form-row
-# El 0 luego es reemplazado por un id temporal - group.each do |nf|
- if template.array? .col
- name = [template.key, '', nf.key] -# Si el template es un array, quiere decir que esperamos un array de hashes.
- else -# El valor vacío luego es reemplazado por un id temporal
- name = [template.key, nf.key] - if template.array?
%td= render "posts/template_field/#{nf.type}", - name = [template.key, '', nf.key]
template: nf, - else
name: name, - name = [template.key, nf.key]
value: value - if @post.new?
- if template.array? - value = nf.values
%td= fa_icon 'close', title: t('posts.row.del') - 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' private: '🔒 The values of this field will remain private'
select: select:
placeholder: 'Type to filter available options' 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' private: '🔒 Los valores de este campo serán privados'
select: select:
placeholder: 'Empieza a escribir para filtrar las opciones disponibles' 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'