From 1b31319ed80693775b4f0ed70c626ff24e11d0d4 Mon Sep 17 00:00:00 2001 From: April Rieger Date: Wed, 13 Nov 2024 16:42:23 -0800 Subject: [PATCH 1/2] Updated how annotation IDs are accessed and reordering set_annotations_attributes before delete_removed_annotations to ensure new annotations are saved prior to deletion. --- app/transactions/ams/steps/create_aapb_admin_data.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/transactions/ams/steps/create_aapb_admin_data.rb b/app/transactions/ams/steps/create_aapb_admin_data.rb index 2e1dd61b..b669359e 100644 --- a/app/transactions/ams/steps/create_aapb_admin_data.rb +++ b/app/transactions/ams/steps/create_aapb_admin_data.rb @@ -43,8 +43,8 @@ def save_aapb_admin_data(change_set) set_admin_data_attributes(change_set.model.admin_data, change_set) change_set.model.admin_data.save! remove_admin_data_from_env_attributes(change_set) - delete_removed_annotations(change_set.model.admin_data, change_set) set_annotations_attributes(change_set.model.admin_data, change_set) + delete_removed_annotations(change_set.model.admin_data, change_set) remove_annotations_from_env_attributes(change_set) !!change_set.model.admin_data @@ -62,9 +62,9 @@ def set_admin_data_attributes(admin_data, change_set) def delete_removed_annotations(admin_data, change_set) return if admin_data.annotations.empty? return if change_set.annotations.blank? - ids_in_env = change_set.annotations.map(&:id) + ids_in_env = change_set.fields["annotations"].map { |a| a["id"] } admin_data.annotations.each do |annotation| - annotation.destroy unless ids_in_env.include?(annotation.id) + annotation.destroy unless ids_in_env.include?(annotation.id.to_s) end end From 00bc33b5e536cb3482ce6039f231cab22e33b2ca Mon Sep 17 00:00:00 2001 From: April Rieger Date: Fri, 15 Nov 2024 21:16:03 -0800 Subject: [PATCH 2/2] Taken from actor --- app/transactions/ams/steps/create_aapb_admin_data.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/transactions/ams/steps/create_aapb_admin_data.rb b/app/transactions/ams/steps/create_aapb_admin_data.rb index b669359e..2e1dd61b 100644 --- a/app/transactions/ams/steps/create_aapb_admin_data.rb +++ b/app/transactions/ams/steps/create_aapb_admin_data.rb @@ -43,8 +43,8 @@ def save_aapb_admin_data(change_set) set_admin_data_attributes(change_set.model.admin_data, change_set) change_set.model.admin_data.save! remove_admin_data_from_env_attributes(change_set) - set_annotations_attributes(change_set.model.admin_data, change_set) delete_removed_annotations(change_set.model.admin_data, change_set) + set_annotations_attributes(change_set.model.admin_data, change_set) remove_annotations_from_env_attributes(change_set) !!change_set.model.admin_data @@ -62,9 +62,9 @@ def set_admin_data_attributes(admin_data, change_set) def delete_removed_annotations(admin_data, change_set) return if admin_data.annotations.empty? return if change_set.annotations.blank? - ids_in_env = change_set.fields["annotations"].map { |a| a["id"] } + ids_in_env = change_set.annotations.map(&:id) admin_data.annotations.each do |annotation| - annotation.destroy unless ids_in_env.include?(annotation.id.to_s) + annotation.destroy unless ids_in_env.include?(annotation.id) end end