5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-23 11:36: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 # Helpers
module ApplicationHelper module ApplicationHelper
BRACKETS = /[\[\]]/
# Devuelve el atributo name de un campo anidado en el formato que # Devuelve el atributo name de un campo anidado en el formato que
# esperan los helpers *_field # esperan los helpers *_field
# #
@ -19,6 +21,14 @@ module ApplicationHelper
[root, name] [root, name]
end 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) def plain_field_name_for(*names)
root, name = field_name_for(*names) root, name = field_name_for(*names)

View file

@ -7,6 +7,7 @@
@param :dir [Symbol, String] @param :dir [Symbol, String]
:ruby :ruby
options = { options = {
id: base,
multipart: true, multipart: true,
class: 'form post ', class: 'form post ',
'hx-swap': params.require(:swap), 'hx-swap': params.require(:swap),
@ -29,13 +30,7 @@
%input{ type: 'hidden', name: 'name', value: params.require(:name) } %input{ type: 'hidden', name: 'name', value: params.require(:name) }
%input{ type: 'hidden', name: 'base', value: params.require(:base) } %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 = hidden_field_tag "#{base}[layout]", post.layout.name
-# Dibuja cada atributo -# Dibuja cada atributo
= render 'posts/attributes', site: site, post: post, dir: dir, base: base, locale: locale = 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 Genera un listado de checkboxes entre los que se puede elegir para guardar
:ruby :ruby
id = "#{base.gsub(/[\[\]]/, '_')}_#{attribute}".squeeze('_') id = id_for(base, attribute)
name = "#{base}[#{attribute}][]" name = "#{base}[#{attribute}][]"
form_id = "form-#{Nanoid.generate}" form_id = "form-#{Nanoid.generate}"

View file

@ -8,7 +8,7 @@
del formulario principal porque no se pueden anidar. del formulario principal porque no se pueden anidar.
:ruby :ruby
id = "#{base.gsub(/[\[\]]/, '_')}_#{attribute}".squeeze('_') id = id_for(base, attribute)
name = "#{base}[#{attribute}][]" name = "#{base}[#{attribute}][]"
form_id = "form-#{Nanoid.generate}" form_id = "form-#{Nanoid.generate}"
modal_id = "modal-#{Nanoid.generate}" modal_id = "modal-#{Nanoid.generate}"
@ -90,3 +90,5 @@
= render 'bootstrap/modal', id: post_id, modal_content_attributes: { class: 'h-100' } do = render 'bootstrap/modal', id: post_id, modal_content_attributes: { class: 'h-100' } do
- content_for :"#{post_id}_body" do - content_for :"#{post_id}_body" do
%div{ id: post_form_loaded_id } %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. guardar, pero no se pueden agregar nuevos.
:ruby :ruby
# @todo Convertir en un helper id = id_for(base, attribute)
id = "#{base.gsub(/[\[\]]/, '_')}_#{attribute}".squeeze('_')
name = "#{base}[#{attribute}][]" name = "#{base}[#{attribute}][]"
form_id = "form-#{Nanoid.generate}" form_id = "form-#{Nanoid.generate}"

View file

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

View file

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