diff --git a/app/controllers/protocols_controller.rb b/app/controllers/protocols_controller.rb index 7bd814a51..fcd326646 100644 --- a/app/controllers/protocols_controller.rb +++ b/app/controllers/protocols_controller.rb @@ -23,6 +23,7 @@ class ProtocolsController < ApplicationController linked_children linked_children_datatable ) + before_action :switch_team_with_param, only: :index before_action :check_view_all_permissions, only: %i( index datatable diff --git a/app/controllers/reports_controller.rb b/app/controllers/reports_controller.rb index 6658c8aba..9a372166b 100644 --- a/app/controllers/reports_controller.rb +++ b/app/controllers/reports_controller.rb @@ -31,6 +31,7 @@ class ReportsController < ApplicationController only: %i(new edit available_repositories) before_action :check_manage_permissions, only: BEFORE_ACTION_METHODS + before_action :switch_team_with_param, only: :index # Index showing all reports of a single project def index; end diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 943737507..3c7fbfc16 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -5,7 +5,9 @@ class RepositoriesController < ApplicationController include ActionView::Helpers::TagHelper include ActionView::Context include IconsHelper + include TeamsHelper + before_action :switch_team_with_param, only: :show before_action :load_vars, except: %i(index create create_modal parse_sheet) before_action :load_parent_vars, except: diff --git a/app/helpers/global_activities_helper.rb b/app/helpers/global_activities_helper.rb index 46762a846..42d8dee4f 100644 --- a/app/helpers/global_activities_helper.rb +++ b/app/helpers/global_activities_helper.rb @@ -44,15 +44,15 @@ module GlobalActivitiesHelper when Team path = projects_path(team: obj.id) when Repository - path = repository_path(obj) + path = repository_path(obj, team: obj.team.id) when RepositoryRow return current_value unless obj.repository - path = repository_path(obj.repository) + path = repository_path(obj.repository, team: obj.repository.team.id) when RepositoryColumn return current_value unless obj.repository - path = repository_path(obj.repository) + path = repository_path(obj.repository, team: obj.repository.team.id) when Project path = obj.archived? ? projects_path : project_path(obj) when Experiment @@ -73,11 +73,11 @@ module GlobalActivitiesHelper end when Protocol if obj.in_repository_public? - path = protocols_path(type: :public) + path = protocols_path(type: :public, team: obj.team.id) elsif obj.in_repository_private? - path = protocols_path(type: :private) + path = protocols_path(type: :private, team: obj.team.id) elsif obj.in_repository_archived? - path = protocols_path(type: :archive) + path = protocols_path(type: :archive, team: obj.team.id) elsif obj.my_module.navigable? path = protocols_my_module_path(obj.my_module) else @@ -90,7 +90,7 @@ module GlobalActivitiesHelper when Step return current_value when Report - path = reports_path + path = reports_path(team: obj.team.id) else return current_value end diff --git a/app/helpers/teams_helper.rb b/app/helpers/teams_helper.rb index 7fa0070a8..9c5d116bb 100644 --- a/app/helpers/teams_helper.rb +++ b/app/helpers/teams_helper.rb @@ -20,4 +20,8 @@ module TeamsHelper def team_created_by(team) User.find_by_id(team.created_by_id) end + + def switch_team_with_param + current_team_switch(Team.find_by(id: params[:team])) if params[:team] + end end diff --git a/app/views/global_activities/references/_report.html.erb b/app/views/global_activities/references/_report.html.erb index ede016a46..0abdcf90c 100644 --- a/app/views/global_activities/references/_report.html.erb +++ b/app/views/global_activities/references/_report.html.erb @@ -3,7 +3,7 @@