From e9e55945d93984454cd577bca8c08737895f83c8 Mon Sep 17 00:00:00 2001 From: f Date: Thu, 4 Jul 2024 15:05:58 -0300 Subject: [PATCH] fix: editar el post de has_one desde su modal #16665 --- app/views/posts/_new_has_one.haml | 2 +- app/views/posts/_new_related_post.haml | 6 ++++-- app/views/posts/attributes/_new_has_one.haml | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/views/posts/_new_has_one.haml b/app/views/posts/_new_has_one.haml index 54a370cd..f5286670 100644 --- a/app/views/posts/_new_has_one.haml +++ b/app/views/posts/_new_has_one.haml @@ -1,2 +1,2 @@ -= render 'posts/new_related_post', post: post += render 'posts/new_related_post', post: post, modal_id: modal_id %input{ type: 'hidden', name: name, value: value } diff --git a/app/views/posts/_new_related_post.haml b/app/views/posts/_new_related_post.haml index 046080c9..9e342a6c 100644 --- a/app/views/posts/_new_related_post.haml +++ b/app/views/posts/_new_related_post.haml @@ -1,4 +1,6 @@ :ruby + local_assigns[:modal_id] ||= 'generic_modal' + image = nil description = nil @@ -6,9 +8,9 @@ description = post.post.image.value['description'] end -.col.mb-3.p-1 +.col.mb-3.p-1{ data: { controller: 'modal' } } = render('bootstrap/card', image: image, description: description, title: post.title, class: 'h-100') do - if post.post.attribute?(:description) %p.card-text= post.post.description.value - = link_to t('.edit'), edit_site_post_path(post.site, post.path), class: 'btn btn-secondary' + = render 'bootstrap/btn', content: t('.edit'), data: { action: 'modal#showAnother', 'modal-show-value': local_assigns[:modal_id] }, id: random_id diff --git a/app/views/posts/attributes/_new_has_one.haml b/app/views/posts/attributes/_new_has_one.haml index c082da6d..09cc9b7f 100644 --- a/app/views/posts/attributes/_new_has_one.haml +++ b/app/views/posts/attributes/_new_has_one.haml @@ -34,7 +34,7 @@ .row.no-gutters.placeholder-glow{ id: target_id } -# @todo issue-7537 - if !metadata.empty? && (indexed_post = site.indexed_posts.find_by(post_id: metadata.value)) - = render 'posts/new_has_one', post: indexed_post, name: name, value: metadata.value + = render 'posts/new_has_one', post: indexed_post, name: name, value: metadata.value, modal_id: modal_id -# El modal se genera por fuera del formulario, para poder enviar los