5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-22 20:36:21 +00:00

fix: pasar la relación inversa

This commit is contained in:
f 2024-10-21 16:16:52 -03:00
parent e1ac21674b
commit ee7d21030e
No known key found for this signature in database
7 changed files with 18 additions and 6 deletions

View file

@ -6,7 +6,11 @@ export default class extends Controller {
connect() { connect() {
// TODO: Stimulus >1 // TODO: Stimulus >1
this.newArrayValueURL = new URL(window.location.origin); 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); this.originalValue = JSON.parse(this.element.dataset.arrayOriginalValue);
} }

View file

@ -26,6 +26,7 @@
- form_params[:modal_id] = form_params[:show] = modal_id = random_id - form_params[:modal_id] = form_params[:show] = modal_id = random_id
-# Asociar un modal con una tarjeta -# Asociar un modal con una tarjeta
- form_params[:result_id] = card_id - form_params[:result_id] = card_id
- form_params[:inverse] = local_assigns[:inverse]
-# @todo Poder indicar en qué elemento queremos asociar lo descargado -# @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 = 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

View file

@ -46,7 +46,7 @@
.row.no-gutters.placeholder-glow{ data: { 'array-target': 'current' } } .row.no-gutters.placeholder-glow{ data: { 'array-target': 'current' } }
-# @todo issue-7537 -# @todo issue-7537
- if !metadata.empty? && (indexed_post = site.indexed_posts.find_by(post_id: metadata.value)) - 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 = 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 - content_for :"#{id}_header" do

View file

@ -20,7 +20,7 @@
controllers = %w[modal array] controllers = %w[modal array]
controllers << 'required-checkbox' if metadata.required 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' } } %template{ data: { 'array-target': 'placeholder' } }
.col.p-3{ 'aria-hidden': 'true' } .col.p-3{ 'aria-hidden': 'true' }
%span.placeholder.w-100 %span.placeholder.w-100
@ -48,7 +48,7 @@
-# @todo issue-7537 -# @todo issue-7537
- metadata.value.each do |uuid| - metadata.value.each do |uuid|
- if (indexed_post = site.indexed_posts.find_by(post_id: 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 = 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 - content_for :"#{id}_header" do

View file

@ -47,7 +47,7 @@
-# @todo issue-7537 -# @todo issue-7537
- metadata.value.each do |uuid| - metadata.value.each do |uuid|
- if (indexed_post = site.indexed_posts.find_by(post_id: 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 = 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 - content_for :"#{id}_header" do

View file

@ -16,6 +16,11 @@
result_id = pluck_param(:result_id) result_id = pluck_param(:result_id)
form_id = random_id form_id = random_id
except = %i[date] except = %i[date]
if (inverse = pluck_param(:inverse, optional: true))
except << inverse.to_sym
end
options = { options = {
id: form_id, id: form_id,
multipart: true, multipart: true,
@ -45,6 +50,8 @@
= hidden_field_tag 'result_id', result_id = hidden_field_tag 'result_id', result_id
= hidden_field_tag 'modal_id', modal_id = hidden_field_tag 'modal_id', modal_id
= hidden_field_tag "#{base}[layout]", post.layout.name = hidden_field_tag "#{base}[layout]", post.layout.name
- if inverse
= hidden_field_tag 'inverse', inverse
= render 'errors', post: post = render 'errors', post: post
= render 'posts/attributes', site: site, post: post, dir: dir, base: base, locale: locale, except: except = render 'posts/attributes', site: site, post: post, dir: dir, base: base, locale: locale, except: except

View file

@ -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)