diff --git a/Gemfile b/Gemfile index ae53f421..022275b8 100644 --- a/Gemfile +++ b/Gemfile @@ -87,7 +87,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 547fab74..556f16e6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -389,8 +389,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.4-x86_64-linux-musl) mini_portile2 (~> 2.8.2) @@ -687,7 +685,6 @@ DEPENDENCIES mobility nanoid net-ssh - nice_partials nokogiri pg pg_search diff --git a/app/services/post_service.rb b/app/services/post_service.rb index 1de50f1b..db118d6c 100644 --- a/app/services/post_service.rb +++ b/app/services/post_service.rb @@ -20,11 +20,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! @@ -50,14 +50,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 @@ -149,11 +149,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 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 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}"