Merge pull request #8610 from aignatov-bio/ai-sci-12061-add-archived-results-to-unlinking

Fix linking for archived and deleted results [SCI-12061][SCI-12060]
This commit is contained in:
aignatov-bio 2025-06-27 13:46:10 +02:00 committed by GitHub
commit 2de9de69cd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 12 additions and 2 deletions

View file

@ -41,7 +41,12 @@ class ResultsController < ApplicationController
end
def list
@results = @my_module.results.active
if params[:with_linked_step_id].present?
step = @my_module.protocol.steps.find_by(id: params[:with_linked_step_id])
@results = @my_module.results.where(archived: false).or(@my_module.results.where(id: step.results.select(:id)))
else
@results = @my_module.results.active
end
update_and_apply_user_sort_preference!
end

View file

@ -94,7 +94,7 @@ export default {
},
computed: {
resultsListUrl() {
return list_my_module_results_path({ my_module_id: this.step.attributes.my_module_id });
return list_my_module_results_path({ my_module_id: this.step.attributes.my_module_id, with_linked_step_id: this.step.id });
},
resultsPageUrl() {
return my_module_results_path({ my_module_id: this.step.attributes.my_module_id });

View file

@ -39,6 +39,7 @@ class Result < ApplicationRecord
accepts_nested_attributes_for :tables
before_save :ensure_default_name
after_discard :delete_step_results
after_discard do
CleanupUserSettingsJob.perform_later('result_states', id)
end
@ -187,4 +188,8 @@ class Result < ApplicationRecord
def ensure_default_name
self.name = name.presence || I18n.t('my_modules.results.default_name')
end
def delete_step_results
step_results.destroy_all
end
end