From 7d9a79456aa1ef0d48d9686c34b94e74659df756 Mon Sep 17 00:00:00 2001 From: Oleksii Kriuchykhin Date: Thu, 20 May 2021 21:21:27 +0200 Subject: [PATCH] Remove task from report if it is moved to another experiment [SCI-5741] --- app/models/my_module.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/models/my_module.rb b/app/models/my_module.rb index 9eb22be8b..ab2b8b907 100644 --- a/app/models/my_module.rb +++ b/app/models/my_module.rb @@ -8,10 +8,11 @@ class MyModule < ApplicationRecord enum state: Extends::TASKS_STATES + before_validation :archiving_and_restoring_extras, on: :update, if: :archived_changed? + before_save -> { report_elements.destroy_all }, if: -> { !new_record? && experiment_id_changed? } + around_save :exec_status_consequences, if: :my_module_status_id_changed? before_create :create_blank_protocol before_create :assign_default_status_flow - before_validation :archiving_and_restoring_extras, on: :update, if: :archived_changed? - around_save :exec_status_consequences, if: :my_module_status_id_changed? after_save -> { experiment.workflowimg.purge }, if: -> { (saved_changes.keys & %w(x y experiment_id my_module_group_id input_id output_id archived)).any? }