5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-23 04:46:21 +00:00

Merge branch 'issue-15068' into production.panel.sutty.nl

This commit is contained in:
f 2024-05-23 17:51:48 -03:00
commit a823f9718b
No known key found for this signature in database
7 changed files with 18 additions and 10 deletions

View file

@ -2,6 +2,8 @@
# Helpers
module ApplicationHelper
BRACKETS = /[\[\]]/
# Devuelve el atributo name de un campo anidado en el formato que
# esperan los helpers *_field
#
@ -19,6 +21,14 @@ module ApplicationHelper
[root, name]
end
# Obtiene un ID
#
# @param base [String]
# @param attribute [String, Symbol]
def id_for(base, attribute)
"#{base.gsub(BRACKETS, '_')}_#{attribute}".squeeze('_')
end
def plain_field_name_for(*names)
root, name = field_name_for(*names)

View file

@ -7,6 +7,7 @@
@param :dir [Symbol, String]
:ruby
options = {
id: base,
multipart: true,
class: 'form post ',
'hx-swap': params.require(:swap),
@ -29,13 +30,7 @@
%input{ type: 'hidden', name: 'name', value: params.require(:name) }
%input{ type: 'hidden', name: 'base', value: params.require(:base) }
-# Botones de guardado
= render 'posts/submit', site: site, post: post
= hidden_field_tag "#{base}[layout]", post.layout.name
-# Dibuja cada atributo
= render 'posts/attributes', site: site, post: post, dir: dir, base: base, locale: locale
-# Botones de guardado
= render 'posts/submit', site: site, post: post

View file

@ -1,7 +1,7 @@
-#
Genera un listado de checkboxes entre los que se puede elegir para guardar
:ruby
id = "#{base.gsub(/[\[\]]/, '_')}_#{attribute}".squeeze('_')
id = id_for(base, attribute)
name = "#{base}[#{attribute}][]"
form_id = "form-#{Nanoid.generate}"

View file

@ -8,7 +8,7 @@
del formulario principal porque no se pueden anidar.
:ruby
id = "#{base.gsub(/[\[\]]/, '_')}_#{attribute}".squeeze('_')
id = id_for(base, attribute)
name = "#{base}[#{attribute}][]"
form_id = "form-#{Nanoid.generate}"
modal_id = "modal-#{Nanoid.generate}"
@ -90,3 +90,5 @@
= render 'bootstrap/modal', id: post_id, modal_content_attributes: { class: 'h-100' } do
- content_for :"#{post_id}_body" do
%div{ id: post_form_loaded_id }
- content_for :"#{post_id}_footer" do
= render 'bootstrap/btn', form: id, content: t('.save'), type: 'submit'

View file

@ -3,8 +3,7 @@
guardar, pero no se pueden agregar nuevos.
:ruby
# @todo Convertir en un helper
id = "#{base.gsub(/[\[\]]/, '_')}_#{attribute}".squeeze('_')
id = id_for(base, attribute)
name = "#{base}[#{attribute}][]"
form_id = "form-#{Nanoid.generate}"

View file

@ -946,3 +946,4 @@ en:
cancel: "Cancel"
edit: "Edit"
filter: "Start typing to filter..."
save: "Save"

View file

@ -954,3 +954,4 @@ es:
cancel: "Cancelar"
edit: "Editar"
filter: "Empezá a escribir para filtrar..."
save: "Guardar"