From 35527700767df148aef25eaffe5ff7eebddf37cc Mon Sep 17 00:00:00 2001 From: f Date: Thu, 23 May 2024 15:23:24 -0300 Subject: [PATCH 1/3] fix: eliminar nice_partials MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit a veces hacía que se rendericen los campos dos veces! --- Gemfile | 1 - Gemfile.lock | 3 --- app/views/bootstrap/_modal.haml | 3 +++ 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Gemfile b/Gemfile index 500face1..30794e83 100644 --- a/Gemfile +++ b/Gemfile @@ -86,7 +86,6 @@ gem 'after_commit_everywhere', '~> 1.0' gem 'aasm' gem 'que-web' gem 'nanoid' -gem 'nice_partials' # database gem 'hairtrigger' diff --git a/Gemfile.lock b/Gemfile.lock index a0d203d5..db6b892d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -385,8 +385,6 @@ GEM net-protocol net-ssh (7.2.1) netaddr (2.0.6) - nice_partials (0.10.0) - actionview (>= 4.2.6) nio4r (2.7.0-x86_64-linux-musl) nokogiri (1.16.0-x86_64-linux-musl) mini_portile2 (~> 2.8.2) @@ -682,7 +680,6 @@ DEPENDENCIES mobility nanoid net-ssh - nice_partials nokogiri pg pg_search diff --git a/app/views/bootstrap/_modal.haml b/app/views/bootstrap/_modal.haml index f6dafc2a..28014c6a 100644 --- a/app/views/bootstrap/_modal.haml +++ b/app/views/bootstrap/_modal.haml @@ -23,6 +23,9 @@ local_assigns[:hide_actions] << 'click->modal#hide' local_assigns[:modal_content_attributes] ||= {} +-# XXX: Necesario para poder generar todas las demás += yield + .modal.fade{ tabindex: -1, aria: { hidden: 'true' }, data: { target: 'modal.modal' } } .modal-backdrop.fade{ data: { target: 'modal.backdrop', action: local_assigns[:hide_actions].join(' ') } } .modal-dialog.modal-dialog-scrollable.modal-dialog-centered From c279d09f4601b1db12fb5896a13183013cb9a652 Mon Sep 17 00:00:00 2001 From: f Date: Thu, 23 May 2024 15:24:32 -0300 Subject: [PATCH 2/3] fix: los id no llevan corchetes --- app/views/posts/attributes/_new_array.haml | 2 +- app/views/posts/attributes/_new_has_many.haml | 2 +- app/views/posts/attributes/_new_predefined_array.haml | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/views/posts/attributes/_new_array.haml b/app/views/posts/attributes/_new_array.haml index 394345a6..692a6898 100644 --- a/app/views/posts/attributes/_new_array.haml +++ b/app/views/posts/attributes/_new_array.haml @@ -1,7 +1,7 @@ -# Genera un listado de checkboxes entre los que se puede elegir para guardar :ruby - id = "#{base}_#{attribute}" + id = "#{base.gsub(/[\[\]]/, '_')}_#{attribute}".squeeze('_') name = "#{base}[#{attribute}][]" form_id = "form-#{Nanoid.generate}" diff --git a/app/views/posts/attributes/_new_has_many.haml b/app/views/posts/attributes/_new_has_many.haml index 16d68322..48230759 100644 --- a/app/views/posts/attributes/_new_has_many.haml +++ b/app/views/posts/attributes/_new_has_many.haml @@ -8,7 +8,7 @@ del formulario principal porque no se pueden anidar. :ruby - id = "#{base}_#{attribute}" + id = "#{base.gsub(/[\[\]]/, '_')}_#{attribute}".squeeze('_') name = "#{base}[#{attribute}][]" form_id = "form-#{Nanoid.generate}" modal_id = "modal-#{Nanoid.generate}" diff --git a/app/views/posts/attributes/_new_predefined_array.haml b/app/views/posts/attributes/_new_predefined_array.haml index 5203c12b..218a2cc2 100644 --- a/app/views/posts/attributes/_new_predefined_array.haml +++ b/app/views/posts/attributes/_new_predefined_array.haml @@ -3,7 +3,8 @@ guardar, pero no se pueden agregar nuevos. :ruby - id = "#{base}_#{attribute}" + # @todo Convertir en un helper + id = "#{base.gsub(/[\[\]]/, '_')}_#{attribute}".squeeze('_') name = "#{base}[#{attribute}][]" form_id = "form-#{Nanoid.generate}" From 8e9847c69c46be31f85c9f84f8d117bbdc02b131 Mon Sep 17 00:00:00 2001 From: f Date: Thu, 23 May 2024 15:24:49 -0300 Subject: [PATCH 3/3] fix: usar la base en todos lados --- app/services/post_service.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/services/post_service.rb b/app/services/post_service.rb index 4f5427ca..628d1b63 100644 --- a/app/services/post_service.rb +++ b/app/services/post_service.rb @@ -18,11 +18,11 @@ PostService = Struct.new(:site, :usuarie, :post, :params, keyword_init: true) do end # Crea los posts anidados - create_nested_posts! post, params[:post] + create_nested_posts! post, params[base] post.save update_related_posts - commit(action: :created, add: files) + commit(action: :created, add: files) if post.valid? update_site_license! @@ -46,14 +46,14 @@ PostService = Struct.new(:site, :usuarie, :post, :params, keyword_init: true) do def update post.usuaries << usuarie - params[:post][:draft] = true if site.invitade? usuarie + params[base][:draft] = true if site.invitade? usuarie # Eliminar ("mover") el archivo si cambió de ubicación. if post.update(post_params) rm = [] rm << post.path.value_was if post.path.changed? - create_nested_posts! post, params[:post] + create_nested_posts! post, params[base] update_related_posts # Es importante que el artículo se guarde primero y luego los @@ -144,11 +144,11 @@ PostService = Struct.new(:site, :usuarie, :post, :params, keyword_init: true) do end def locale - params.dig(:post, :lang)&.to_sym || I18n.locale + params.dig(base, :lang)&.to_sym || I18n.locale end def layout - params.dig(:post, :layout) || params[:layout] + params.dig(base, :layout) || params[:layout] end # Actualiza los artículos relacionados según los métodos que los