mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-15 03:51:41 +00:00
convertir en un fieldset con columnas
This commit is contained in:
parent
a0ea4ca510
commit
6350a33043
4 changed files with 44 additions and 25 deletions
6
app/views/posts/template_field/_nested.haml
Normal file
6
app/views/posts/template_field/_nested.haml
Normal 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
|
|
@ -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
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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'
|
||||
|
|
Loading…
Reference in a new issue