diff --git a/app/javascript/controllers/array_controller.js b/app/javascript/controllers/array_controller.js index 7b0ba8c4..5540e839 100644 --- a/app/javascript/controllers/array_controller.js +++ b/app/javascript/controllers/array_controller.js @@ -6,7 +6,11 @@ export default class extends Controller { connect() { // TODO: Stimulus >1 this.newArrayValueURL = new URL(window.location.origin); - this.newArrayValueURL.pathname = this.element.dataset.arrayNewArrayValue; + + const [ pathname, search ] = this.element.dataset.arrayNewArrayValue.split("?"); + + this.newArrayValueURL.pathname = pathname; + this.newArrayValueURL.search = `?${search}`; this.originalValue = JSON.parse(this.element.dataset.arrayOriginalValue); } diff --git a/app/views/posts/_new_related_post.haml b/app/views/posts/_new_related_post.haml index 7dcb264f..236abc42 100644 --- a/app/views/posts/_new_related_post.haml +++ b/app/views/posts/_new_related_post.haml @@ -26,6 +26,7 @@ - form_params[:modal_id] = form_params[:show] = modal_id = random_id -# Asociar un modal con una tarjeta - form_params[:result_id] = card_id + - form_params[:inverse] = local_assigns[:inverse] -# @todo Poder indicar en qué elemento queremos asociar lo descargado = render 'bootstrap/btn', content: t('.edit'), data: { controller: 'htmx', action: 'modal#showAnother htmx#getUrlOnce', 'modal-show-value': modal_id, 'htmx-get-url-param': site_posts_modal_path(post.site, **form_params) }, id: random_id diff --git a/app/views/posts/attributes/_new_belongs_to.haml b/app/views/posts/attributes/_new_belongs_to.haml index 7f9a66dd..849b3eff 100644 --- a/app/views/posts/attributes/_new_belongs_to.haml +++ b/app/views/posts/attributes/_new_belongs_to.haml @@ -46,7 +46,7 @@ .row.no-gutters.placeholder-glow{ data: { 'array-target': 'current' } } -# @todo issue-7537 - if !metadata.empty? && (indexed_post = site.indexed_posts.find_by(post_id: metadata.value)) - = render 'posts/new_related_post', post: indexed_post, attribute: metadata.type + = render 'posts/new_related_post', post: indexed_post, attribute: metadata.type, inverse: metadata.inverse = render 'bootstrap/modal', id: id, modal_content_attributes: { class: 'h-100' }, hide_actions: ['array#cancel'], keydown_actions: %w[keydown->array#cancelWithEscape] do - content_for :"#{id}_header" do diff --git a/app/views/posts/attributes/_new_has_and_belongs_to_many.haml b/app/views/posts/attributes/_new_has_and_belongs_to_many.haml index 0859ae33..c5d91e7f 100644 --- a/app/views/posts/attributes/_new_has_and_belongs_to_many.haml +++ b/app/views/posts/attributes/_new_has_and_belongs_to_many.haml @@ -20,7 +20,7 @@ controllers = %w[modal array] controllers << 'required-checkbox' if metadata.required -%div{ id: modal_id, data: { controller: controllers.join(' '), 'array-original-value': metadata.value.to_json, 'array-new-array-value': site_posts_new_related_post_path(site) } } +%div{ id: modal_id, data: { controller: controllers.join(' '), 'array-original-value': metadata.value.to_json, 'array-new-array-value': site_posts_new_related_post_path(site, inverse: metadata.inverse) } } %template{ data: { 'array-target': 'placeholder' } } .col.p-3{ 'aria-hidden': 'true' } %span.placeholder.w-100 @@ -48,7 +48,7 @@ -# @todo issue-7537 - metadata.value.each do |uuid| - if (indexed_post = site.indexed_posts.find_by(post_id: uuid)) - = render 'posts/new_related_post', post: indexed_post, attribute: metadata.type + = render 'posts/new_related_post', post: indexed_post, attribute: metadata.type, inverse: metadata.inverse = render 'bootstrap/modal', id: id, modal_content_attributes: { class: 'h-100' }, hide_actions: ['array#cancel'], keydown_actions: %w[keydown->array#cancelWithEscape] do - content_for :"#{id}_header" do diff --git a/app/views/posts/attributes/_new_has_many.haml b/app/views/posts/attributes/_new_has_many.haml index ff657359..e2d9d758 100644 --- a/app/views/posts/attributes/_new_has_many.haml +++ b/app/views/posts/attributes/_new_has_many.haml @@ -47,7 +47,7 @@ -# @todo issue-7537 - metadata.value.each do |uuid| - if (indexed_post = site.indexed_posts.find_by(post_id: uuid)) - = render 'posts/new_related_post', post: indexed_post, attribute: metadata.type + = render 'posts/new_related_post', post: indexed_post, attribute: metadata.type, inverse: metadata.inverse = render 'bootstrap/modal', id: id, modal_content_attributes: { class: 'h-100' }, hide_actions: ['array#cancel'], keydown_actions: %w[keydown->array#cancelWithEscape] do - content_for :"#{id}_header" do diff --git a/app/views/posts/modal.haml b/app/views/posts/modal.haml index 14836118..2b50e41c 100644 --- a/app/views/posts/modal.haml +++ b/app/views/posts/modal.haml @@ -16,6 +16,11 @@ result_id = pluck_param(:result_id) form_id = random_id except = %i[date] + + if (inverse = pluck_param(:inverse, optional: true)) + except << inverse.to_sym + end + options = { id: form_id, multipart: true, @@ -45,6 +50,8 @@ = hidden_field_tag 'result_id', result_id = hidden_field_tag 'modal_id', modal_id = hidden_field_tag "#{base}[layout]", post.layout.name + - if inverse + = hidden_field_tag 'inverse', inverse = render 'errors', post: post = render 'posts/attributes', site: site, post: post, dir: dir, base: base, locale: locale, except: except diff --git a/app/views/posts/new_related_post.haml b/app/views/posts/new_related_post.haml index 11fdf3af..1b173fa9 100644 --- a/app/views/posts/new_related_post.haml +++ b/app/views/posts/new_related_post.haml @@ -1 +1 @@ -= render 'posts/new_related_post', post: @indexed_post, modal_id: pluck_param(:modal_id, optional: true) += render 'posts/new_related_post', post: @indexed_post, modal_id: pluck_param(:modal_id, optional: true), inverse: pluck_param(:inverse, optional: true)