From 7ebc171cabd1c2589d10f024cae03094c9eaafad Mon Sep 17 00:00:00 2001 From: f Date: Wed, 23 Oct 2024 15:24:16 -0300 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20no=20modificar=20la=20relaci=C3=B3n?= =?UTF-8?q?=20si=20ya=20estaba=20deshecha?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/metadata_has_many.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/models/metadata_has_many.rb b/app/models/metadata_has_many.rb index b4db4454..a15f1241 100644 --- a/app/models/metadata_has_many.rb +++ b/app/models/metadata_has_many.rb @@ -42,6 +42,9 @@ class MetadataHasMany < MetadataRelatedPosts return true unless inverse? (had_many - has_many).each do |remove| + # No modificar nada si la relación ya estaba deshecha + next unless remove[inverse]&.value == post.uuid.value + remove[inverse]&.value = remove[inverse].default_value end From 52322c15c51a1f38af631eafbca7211f02c6764b Mon Sep 17 00:00:00 2001 From: f Date: Wed, 23 Oct 2024 15:24:47 -0300 Subject: [PATCH 2/2] =?UTF-8?q?fix:=20no=20enviar=20valores=20inversos=20v?= =?UTF-8?q?ac=C3=ADos?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/posts/_htmx_form.haml | 3 ++- app/views/posts/modal.haml | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/views/posts/_htmx_form.haml b/app/views/posts/_htmx_form.haml index 6968cda7..afa1b44c 100644 --- a/app/views/posts/_htmx_form.haml +++ b/app/views/posts/_htmx_form.haml @@ -75,6 +75,7 @@ Enviamos valores vacíos o arrastrados desde el formulario anterior para los atributos ignorados - except.each do |attr| - %input{ type: 'hidden', name: "#{base}[#{attr}]", value: pluck_param(attr, optional: true) } + - if (value = pluck_param(attr, optional: true)).present? + %input{ type: 'hidden', name: "#{base}[#{attr}]", value: value } = yield(:post_form) diff --git a/app/views/posts/modal.haml b/app/views/posts/modal.haml index e589dfa8..93d7e6a5 100644 --- a/app/views/posts/modal.haml +++ b/app/views/posts/modal.haml @@ -59,7 +59,7 @@ = render 'posts/attributes', site: site, post: post, dir: dir, base: base, locale: locale, except: except -# @todo Volver obligatorios? - except.each do |attr| - - if (value = pluck_param(attr, optional: true)) + - if (value = pluck_param(attr, optional: true)).present? = hidden_field_tag "#{base}[#{attr}]", value - content_for :"#{modal_id}_footer" do