diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 8331293b0..7a9d21871 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -9,7 +9,7 @@ class ApplicationController < ActionController::Base
helper_method :current_organization
before_action :generate_intro_tutorial, if: :is_current_page_root?
around_action :set_time_zone, if: :current_user
- layout "main"
+ layout 'main'
def forbidden
render_403
@@ -20,7 +20,7 @@ class ApplicationController < ActionController::Base
end
def is_current_page_root?
- controller_name == "projects" && action_name == "index"
+ controller_name == 'projects' && action_name == 'index'
end
# Sets current organization for all controllers
diff --git a/app/controllers/experiments_controller.rb b/app/controllers/experiments_controller.rb
index 99adbcf15..e8f11ceb2 100644
--- a/app/controllers/experiments_controller.rb
+++ b/app/controllers/experiments_controller.rb
@@ -55,6 +55,7 @@ class ExperimentsController < ApplicationController
def canvas
@project = @experiment.project
+ current_organization_switch(@project.organization)
end
def edit
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb
index a9b04b088..556445a36 100644
--- a/app/controllers/projects_controller.rb
+++ b/app/controllers/projects_controller.rb
@@ -23,10 +23,11 @@ class ProjectsController < ApplicationController
DELETE_SAMPLES = I18n.t("samples.delete_samples")
def index
- @current_organization_id = params[:organization].to_i
+ @current_organization_id = current_organization.id
@current_sort = params[:sort].to_s
- @projects_by_orgs = current_user.projects_by_orgs(
- @current_organization_id, @current_sort, @filter_by_archived)
+ @projects_by_orgs = current_user.projects_by_orgs(@current_organization_id,
+ @current_sort,
+ @filter_by_archived)
@organizations = current_user.organizations
# New project for create new project modal
@@ -237,6 +238,7 @@ class ProjectsController < ApplicationController
def show
# This is the "info" view
+ current_organization_switch(@project.organization)
end
def notifications
@@ -261,6 +263,7 @@ class ProjectsController < ApplicationController
end
def experiment_archive
+ current_organization_switch(@project.organization)
end
def samples_index
diff --git a/app/controllers/protocols_controller.rb b/app/controllers/protocols_controller.rb
index 29705c8ba..93cccf17c 100644
--- a/app/controllers/protocols_controller.rb
+++ b/app/controllers/protocols_controller.rb
@@ -741,9 +741,7 @@ class ProtocolsController < ApplicationController
end
def load_organization_and_type
- @organizations = current_user.organizations.order(name: :asc)
- @current_organization = @organizations.select{ |org| org.id == params[:organization].to_i }.first
- @current_organization ||= @organizations.first
+ @current_organization = current_organization
# :public, :private or :archive
@type = (params[:type] || "public").to_sym
end
diff --git a/app/controllers/users/settings_controller.rb b/app/controllers/users/settings_controller.rb
index eeaaaeba5..eaf12837e 100644
--- a/app/controllers/users/settings_controller.rb
+++ b/app/controllers/users/settings_controller.rb
@@ -498,10 +498,10 @@ class Users::SettingsController < ApplicationController
if @user.save
flash[:success] = t('users.settings.changed_org_flash',
team: @changed_org.name)
- redirect_to :back
+ redirect_to root_path
else
flash[:alert] = t('users.settings.changed_org_error_flash')
- redirect_to :back
+ redirect_to root_path
end
end
diff --git a/app/helpers/organizations_helper.rb b/app/helpers/organizations_helper.rb
index 24cc9a80e..f83ea5d8a 100644
--- a/app/helpers/organizations_helper.rb
+++ b/app/helpers/organizations_helper.rb
@@ -1,2 +1,9 @@
module OrganizationsHelper
+ def current_organization_switch(org)
+ # resets the current organization if needed
+ if org != current_organization
+ current_user.current_organization_id = org.id
+ current_user.save
+ end
+ end
end
diff --git a/app/helpers/search_helper.rb b/app/helpers/search_helper.rb
index 3bb3591be..ee40a4c92 100644
--- a/app/helpers/search_helper.rb
+++ b/app/helpers/search_helper.rb
@@ -6,4 +6,15 @@ module SearchHelper
end
experiments.uniq
end
+
+ def route_to_other_org(path, search_org, text)
+ if search_org != current_organization
+ link_to text,
+ path,
+ data: { confirm: t('users.settings.changed_org_in_search',
+ team: search_org.name) }
+ else
+ link_to text, path
+ end
+ end
end
diff --git a/app/views/projects/index.html.erb b/app/views/projects/index.html.erb
index cf0129a2c..140bd58fd 100644
--- a/app/views/projects/index.html.erb
+++ b/app/views/projects/index.html.erb
@@ -77,27 +77,6 @@
<% end %>
-
-
-
-
-
-
<% end %>
-<% if @projects_by_orgs.length > 0 %>
- <% @projects_by_orgs.each do |org, projects| %>
- <%= render partial: "projects/index/org_projects", locals: {org: org, projects: projects} %>
- <% end %>
+<%= render partial: 'projects/index/introductory_popup' %>
+<%= javascript_include_tag 'projects/introdutory_popup' %>
+
+<% if current_organization.projects.length> 0 %>
+ <%= render partial: "projects/index/org_projects",
+ locals: { org: current_organization,
+ projects: current_organization.projects } %>
+
<% end %>
<%= javascript_include_tag "projects/index", "data-turbolinks-track" => true %>
diff --git a/app/views/protocols/_breadcrumbs.html.erb b/app/views/protocols/_breadcrumbs.html.erb
index 99bff0afb..9891d4adc 100644
--- a/app/views/protocols/_breadcrumbs.html.erb
+++ b/app/views/protocols/_breadcrumbs.html.erb
@@ -1,20 +1,7 @@
<% if action_name == "index" %>
- <%= t("protocols.nav.breadcrumbs.manager") %>
- -
- <%= current_organization.name %>
-
-
+ - <%= current_organization.name %>
<% else %>
- <%= link_to t("protocols.nav.breadcrumbs.manager"), protocols_path(organization: current_organization, type: type) %>
- <%= current_organization.name %>
@@ -24,4 +11,4 @@
<%= t("protocols.nav.breadcrumbs.edit") %>
<% end %>
-
\ No newline at end of file
+
diff --git a/app/views/protocols/index.html.erb b/app/views/protocols/index.html.erb
index bbcbe57ab..ba14ede53 100644
--- a/app/views/protocols/index.html.erb
+++ b/app/views/protocols/index.html.erb
@@ -1,6 +1,6 @@
<% provide(:head_title, t("protocols.index.head_title")) %>
-<% if @organizations.count > 0 %>
+<% if current_organization %>
<%= render partial: "protocols/breadcrumbs.html.erb", locals: { organizations: @organizations, current_organization: @current_organization, type: @type } %>
diff --git a/app/views/search/results/partials/_asset_text.html.erb b/app/views/search/results/partials/_asset_text.html.erb
index 907e0d592..897e0f8bc 100644
--- a/app/views/search/results/partials/_asset_text.html.erb
+++ b/app/views/search/results/partials/_asset_text.html.erb
@@ -11,4 +11,4 @@
<% else %>
<%= text %>
-<% end %>
\ No newline at end of file
+<% end %>
diff --git a/app/views/search/results/partials/_experiment_text.html.erb b/app/views/search/results/partials/_experiment_text.html.erb
index 287ab39f5..51604d486 100644
--- a/app/views/search/results/partials/_experiment_text.html.erb
+++ b/app/views/search/results/partials/_experiment_text.html.erb
@@ -4,17 +4,15 @@
<% if experiment.archived? %>
<%=t "search.index.archived" %>
<% if can_view_experiment(experiment) and can_restore_experiment(experiment.project) %>
-
- <%= text %>
-
+ <%= route_to_other_org root_path, experiment.project.organization, text %>
<% else %>
<%= text %>
<% end %>
<% else %>
<% if can_view_experiment(experiment) %>
-
- <%= text %>
-
+ <%= route_to_other_org canvas_experiment_path(experiment),
+ experiment.project.organization,
+ text %>
<% else %>
<%= text %>
<% end %>
diff --git a/app/views/search/results/partials/_my_module_text.html.erb b/app/views/search/results/partials/_my_module_text.html.erb
index 335eabe1f..a654fb320 100644
--- a/app/views/search/results/partials/_my_module_text.html.erb
+++ b/app/views/search/results/partials/_my_module_text.html.erb
@@ -5,9 +5,9 @@
<% if my_module.archived? %>
<%=t "search.index.archived" %>
<% if can_view_experiment_archive(my_module.experiment) and can_restore_module(my_module) %>
-
- <%= text %>
-
+ <%= route_to_other_org module_archive_experiment_url(my_module.experiment),
+ my_module.experiment.project.organization,
+ text %>
<% else %>
<%= text %>
<% end %>
@@ -15,21 +15,21 @@
<% if can_view_module(my_module) %>
<% case link_to_page %>
<% when :samples %>
-
- <%= text %>
-
+ <%= route_to_other_org samples_my_module_path(my_module),
+ my_module.experiment.project.organization,
+ text %>
<% when :protocols %>
-
- <%= text %>
-
+ <%= route_to_other_org protocols_my_module_path(my_module),
+ my_module.experiment.project.organization,
+ text %>
<% when :canvas %>
-
- <%= text %>
-
+ <%= route_to_other_org canvas_experiment_path(my_module.experiment),
+ my_module.experiment.project.organization,
+ text %>
<% when :results %>
-
- <%= text %>
-
+ <%= route_to_other_org results_my_module_path(my_module),
+ my_module.experiment.project.organization,
+ text %>
<% else %>
<%= text %>
<% end %>
diff --git a/app/views/search/results/partials/_organization_text.html.erb b/app/views/search/results/partials/_organization_text.html.erb
index 9669942e9..06a98df4b 100644
--- a/app/views/search/results/partials/_organization_text.html.erb
+++ b/app/views/search/results/partials/_organization_text.html.erb
@@ -1,7 +1,7 @@
<% if can_view_projects(organization) %>
-
- <%= organization.name %>
-
+ <%= route_to_other_org projects_path(organization: organization.id),
+ organization,
+ organization.name %>
<% else %>
<%= organization.name %>
-<% end %>
\ No newline at end of file
+<% end %>
diff --git a/app/views/search/results/partials/_project_text.html.erb b/app/views/search/results/partials/_project_text.html.erb
index d4ab21de6..3956b71b2 100644
--- a/app/views/search/results/partials/_project_text.html.erb
+++ b/app/views/search/results/partials/_project_text.html.erb
@@ -5,24 +5,24 @@
<% if project.archived? %>
<%=t "search.index.archived" %>
<% if can_view_projects(project.organization) and can_restore_project(project) %>
-
- <%= text %>
-
+ <%= route_to_other_org projects_archive_path(organization: project.organization),
+ project.organization,
+ text %>
<% else %>
<%= text %>
<% end %>
<% else %>
<% if can_view_project(project) %>
<% if link_to_page == :show %>
-
- <%= text %>
-
+ <%= route_to_other_org project_path(project),
+ project.organization,
+ text %>
<% else %>
-
- <%= text %>
-
+ <%= route_to_other_org root_path,
+ nil,
+ text %>
<% end %>
<% else %>
<%= text %>
<% end %>
-<% end %>
\ No newline at end of file
+<% end %>
diff --git a/app/views/search/results/partials/_protocol_text.html.erb b/app/views/search/results/partials/_protocol_text.html.erb
index 35007c800..137f7a62d 100644
--- a/app/views/search/results/partials/_protocol_text.html.erb
+++ b/app/views/search/results/partials/_protocol_text.html.erb
@@ -7,9 +7,9 @@
<% if can_view_steps_in_protocol(protocol) %>
-
- <%= text %>
-
+ <%= route_to_other_org protocols_my_module_path(protocol.my_module),
+ protocol.organization,
+ text %>
<% else %>
<%= text %>
<% end %>
@@ -31,9 +31,9 @@
<% end %>
<% if can_edit_protocol(protocol) %>
-
- <%= text %>
-
+ <%= route_to_other_org edit_protocol_path(protocol),
+ protocol.organization,
+ text %>
<% else %>
<%= text %>
<% end %>
diff --git a/app/views/search/results/partials/_report_text.html.erb b/app/views/search/results/partials/_report_text.html.erb
index 2b7b81dec..2335b7920 100644
--- a/app/views/search/results/partials/_report_text.html.erb
+++ b/app/views/search/results/partials/_report_text.html.erb
@@ -5,6 +5,9 @@
<%= text %>
+ <%= route_to_other_org edit_project_report_path(report.project, report),
+ report.project.organization,
+ text %>
<% else %>
<%= text %>
-<% end %>
\ No newline at end of file
+<% end %>
diff --git a/app/views/search/results/partials/_result_text.html.erb b/app/views/search/results/partials/_result_text.html.erb
index 08719ea16..69a439459 100644
--- a/app/views/search/results/partials/_result_text.html.erb
+++ b/app/views/search/results/partials/_result_text.html.erb
@@ -6,13 +6,14 @@
<%=t "search.index.archived" %>
<% if can_view_module_archive(result.my_module) %>
<% if target == :comment %>
- <%= link_to archive_my_module_path(result.my_module, ctarget: "result-panel-#{result.id}") do %>
- <%= text %>
- <% end %>
+ <%= route_to_other_org archive_my_module_path(result.my_module, ctarget: "result-panel-#{result.id}"),
+ result.my_module.experiment.project.organization,
+ text %>
+
<% else %>
-
- <%= text %>
-
+ <%= route_to_other_org archive_my_module_path(result.my_module),
+ result.my_module.experiment.project.organization,
+ text %>
<% end %>
<% else %>
<%= text %>
@@ -20,13 +21,13 @@
<% else %>
<% if can_view_results_in_module(result.my_module) %>
<% if target == :comment %>
- <%= link_to results_my_module_path(result.my_module, ctarget: "result-panel-#{result.id}") do %>
- <%= text %>
- <% end %>
+ <%= route_to_other_org results_my_module_path(result.my_module, ctarget: "result-panel-#{result.id}"),
+ result.my_module.experiment.project.organization,
+ text %>
<% else %>
-
- <%= text %>
-
+ <%= route_to_other_org results_my_module_path(result.my_module),
+ result.my_module.experiment.project.organization,
+ text %>
<% end %>
<% else %>
<%= text %>
diff --git a/app/views/search/results/partials/_step_text.html.erb b/app/views/search/results/partials/_step_text.html.erb
index 871a79afa..cd486f9d6 100644
--- a/app/views/search/results/partials/_step_text.html.erb
+++ b/app/views/search/results/partials/_step_text.html.erb
@@ -5,18 +5,18 @@
<% if can_view_steps_in_protocol(step.protocol) %>
<% if step.protocol.in_module? %>
<% if target == :comment %>
- <%= link_to protocols_my_module_path(step.protocol.my_module, ctarget: "step-panel-#{step.id}") do %>
- <%= text %>
- <% end %>
+ <%= route_to_other_org protocols_my_module_path(step.protocol.my_module, ctarget: "step-panel-#{step.id}"),
+ step.protocol.organization,
+ text %>
<% else %>
-
- <%= text %>
-
+ <%= route_to_other_org protocols_my_module_path(step.protocol.my_module),
+ step.protocol.organization,
+ text %>
<% end %>
<% elsif can_edit_protocol(step.protocol) %>
-
- <%= text %>
-
+ <%= route_to_other_org edit_protocol_path(step.protocol),
+ step.protocol.organization,
+ text %>
<% else %>
<%= text %>
<% end %>
diff --git a/app/views/shared/_navigation.html.erb b/app/views/shared/_navigation.html.erb
index 541c0bad7..aa181136a 100644
--- a/app/views/shared/_navigation.html.erb
+++ b/app/views/shared/_navigation.html.erb
@@ -105,14 +105,14 @@
<%= current_organization.name %>
-