5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-23 01:46:21 +00:00

fix: la relación de traducción es como habtm

(cherry picked from commit 685845a558)
This commit is contained in:
f 2023-10-26 16:36:29 -03:00
parent 10610857b4
commit 381467ecc0
No known key found for this signature in database

View file

@ -181,7 +181,7 @@ PostService = Struct.new(:site, :usuarie, :post, :params, keyword_init: true) do
value = metadata.value.dup
case metadata.type
when 'has_and_belongs_to_many'
when 'has_and_belongs_to_many', 'locales'
associated_posts(value_was - value).each do |remove_post|
remove_relation_from(remove_post[inverse_attribute], post.uuid.value)
end
@ -211,7 +211,6 @@ PostService = Struct.new(:site, :usuarie, :post, :params, keyword_init: true) do
associated_posts(value).each do |add_post|
add_relation_to(add_post[inverse_attribute], post.uuid.value)
end
when 'locales'
end
end
@ -223,6 +222,9 @@ PostService = Struct.new(:site, :usuarie, :post, :params, keyword_init: true) do
end
# @todo por qué no podemos usar nil para deshabilitar un valor?
# @param :metadata [MetadataTemplate]
# @param :value [String]
# @return [nil]
def remove_relation_from(metadata, value)
case metadata.value
when Array then metadata.value.delete(value)
@ -234,6 +236,9 @@ PostService = Struct.new(:site, :usuarie, :post, :params, keyword_init: true) do
end
# @todo El validador ya debería eliminar valores duplicados
# @param :metadata [MetadataTemplate]
# @param :value [String]
# @return [nil]
def add_relation_to(metadata, value)
case metadata.value
when Array