mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-12 08:04:34 +08:00
Fix links for archived objects in global activities [SCI-3229]
This commit is contained in:
parent
9f5b331b9f
commit
d7d45bec70
13 changed files with 84 additions and 65 deletions
|
@ -183,13 +183,6 @@ class CanvasController < ApplicationController
|
|||
to_archive.each do |module_id|
|
||||
my_module = MyModule.find_by_id(module_id)
|
||||
next if my_module.blank?
|
||||
Activities::CreateActivityService
|
||||
.call(activity_type: :archive_module,
|
||||
owner: current_user,
|
||||
team: my_module.experiment.project.team,
|
||||
project: my_module.experiment.project,
|
||||
subject: my_module,
|
||||
message_items: { my_module: my_module.id })
|
||||
end
|
||||
|
||||
# Create workflow image
|
||||
|
|
|
@ -171,13 +171,11 @@ class ProjectsController < ApplicationController
|
|||
@project.last_modified_by = current_user
|
||||
if !return_error && @project.update(project_params)
|
||||
# Add activities if needed
|
||||
if message_visibility.present?
|
||||
log_activity(:change_project_visibility,
|
||||
visibility: message_visibility)
|
||||
end
|
||||
if message_renamed.present?
|
||||
log_activity(:rename_project)
|
||||
end
|
||||
|
||||
log_activity(:change_project_visibility, visibility: message_visibility) if message_visibility.present?
|
||||
log_activity(:rename_project) if message_renamed.present?
|
||||
log_activity(:archive_project) if project_params[:archived] == 'true'
|
||||
log_activity(:restore_project) if project_params[:archived] == 'false'
|
||||
|
||||
flash_success = t('projects.update.success_flash', name: @project.name)
|
||||
if project_params[:archived] == 'true'
|
||||
|
@ -192,12 +190,10 @@ class ProjectsController < ApplicationController
|
|||
# The project should be restored
|
||||
unless @project.archived
|
||||
@project.restore(current_user)
|
||||
log_activity(:restore_project)
|
||||
end
|
||||
elsif @project.archived
|
||||
# The project should be archived
|
||||
@project.archive(current_user)
|
||||
log_activity(:archive_project)
|
||||
end
|
||||
redirect_to projects_path
|
||||
flash[:success] = flash_success
|
||||
|
|
|
@ -30,37 +30,45 @@ module GlobalActivitiesHelper
|
|||
|
||||
current_value = obj.public_send(getter || 'name')
|
||||
|
||||
link = case obj
|
||||
when User
|
||||
popover_for_user_name(obj, activity.team, false, true)
|
||||
when Tag
|
||||
# Not link for now
|
||||
current_value
|
||||
when Team
|
||||
route_to_other_team(projects_path(team: obj),
|
||||
obj,
|
||||
current_value)
|
||||
when Project
|
||||
link_to current_value, project_path(obj)
|
||||
when Experiment
|
||||
link_to current_value, canvas_experiment_path(obj)
|
||||
when MyModule
|
||||
link_to current_value, protocols_my_module_path(obj)
|
||||
when Protocol
|
||||
if obj.in_repository?
|
||||
route_to_other_team protocols_path, obj.team, current_value
|
||||
else
|
||||
link_to current_value, protocols_my_module_path(obj.my_module)
|
||||
end
|
||||
when Repository
|
||||
link_to current_value, repository_path(obj)
|
||||
when RepositoryRow
|
||||
link_to current_value, repository_path(obj.repository)
|
||||
when RepositoryColumn
|
||||
link_to current_value, repository_path(obj.repository)
|
||||
when Result
|
||||
link_to current_value, results_my_module_path(obj.my_module)
|
||||
end
|
||||
link
|
||||
case obj
|
||||
when User
|
||||
popover_for_user_name(obj, activity.team, false, true)
|
||||
when Tag
|
||||
# Not link for now
|
||||
current_value
|
||||
when Team
|
||||
route_to_other_team(projects_path(team: obj), obj, current_value)
|
||||
when Repository
|
||||
link_to(current_value, repository_path(obj))
|
||||
when RepositoryRow
|
||||
link_to(current_value, repository_path(obj.repository))
|
||||
when RepositoryColumn
|
||||
link_to(current_value, repository_path(obj.repository))
|
||||
when Project
|
||||
path = obj.archived? ? projects_path : project_path(obj)
|
||||
link_to(current_value, path)
|
||||
when Experiment
|
||||
return current_value unless obj.navigable?
|
||||
path = obj.archived? ? experiment_archive_project_path(obj.project) : canvas_experiment_path(obj)
|
||||
link_to(current_value, path)
|
||||
when MyModule
|
||||
return current_value unless obj.navigable?
|
||||
path = obj.archived? ? module_archive_experiment_path(obj.experiment) : protocols_my_module_path(obj)
|
||||
link_to(current_value, path)
|
||||
when Protocol
|
||||
if obj.in_repository?
|
||||
route_to_other_team(protocols_path, obj.team, current_value)
|
||||
elsif obj.my_module.navigable?
|
||||
link_to(current_value, protocols_my_module_path(obj.my_module))
|
||||
else
|
||||
current_value
|
||||
end
|
||||
when Result
|
||||
return current_value unless obj.navigable?
|
||||
path = obj.archived? ? archive_my_module_path(obj.my_module) : results_my_module_path(obj.my_module)
|
||||
link_to(current_value, path)
|
||||
else
|
||||
current_value
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -87,7 +87,6 @@ class Activity < ApplicationRecord
|
|||
when Team
|
||||
breadcrumbs[:team] = subject.name
|
||||
end
|
||||
save!
|
||||
end
|
||||
|
||||
def activity_version
|
||||
|
|
|
@ -108,6 +108,10 @@ class Experiment < ApplicationRecord
|
|||
where(project: Project.viewable_by_user(user, teams))
|
||||
end
|
||||
|
||||
def navigable?
|
||||
!project.archived?
|
||||
end
|
||||
|
||||
def active_modules
|
||||
my_modules.where(archived: false)
|
||||
end
|
||||
|
|
|
@ -141,9 +141,13 @@ class MyModule < ApplicationRecord
|
|||
where(experiment: Experiment.viewable_by_user(user, teams))
|
||||
end
|
||||
|
||||
def navigable?
|
||||
!experiment.archived? && experiment.navigable?
|
||||
end
|
||||
|
||||
# Removes assigned samples from module and connections with other
|
||||
# modules.
|
||||
def archive (current_user)
|
||||
def archive(current_user)
|
||||
self.x = 0
|
||||
self.y = 0
|
||||
# Remove association with module group.
|
||||
|
|
|
@ -70,6 +70,10 @@ class Result < ApplicationRecord
|
|||
where(my_module: MyModule.viewable_by_user(user, teams))
|
||||
end
|
||||
|
||||
def navigable?
|
||||
!my_module.archived? && my_module.navigable?
|
||||
end
|
||||
|
||||
def space_taken
|
||||
is_asset ? result_asset.space_taken : 0
|
||||
end
|
||||
|
|
|
@ -25,8 +25,8 @@ module Activities
|
|||
|
||||
def call
|
||||
enrich_message_items
|
||||
@activity.save!
|
||||
@activity.generate_breadcrumbs
|
||||
@activity.save!
|
||||
self
|
||||
end
|
||||
|
||||
|
|
|
@ -2,13 +2,15 @@
|
|||
locals: { subject: subject&.project, breadcrumbs: breadcrumbs } %>
|
||||
<div class="ga-breadcrumb">
|
||||
<%= image_tag 'icon_small/experiment.svg' %>
|
||||
<% if subject %>
|
||||
<%= link_to experiment_path(subject), title: subject.name do %>
|
||||
<% if subject&.navigable? %>
|
||||
<% path = subject.archived? ? experiment_archive_project_path(subject.project) : canvas_experiment_path(subject) %>
|
||||
<%= link_to path, title: subject.name do %>
|
||||
<%= subject.name&.truncate(Constants::NAME_TRUNCATION_LENGTH) %>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<span title="<%= breadcrumbs[:experiment] %>">
|
||||
<%= breadcrumbs[:experiment]&.truncate(Constants::NAME_TRUNCATION_LENGTH) %>
|
||||
<% name = subject&.name || breadcrumbs[:experiment] %>
|
||||
<span title="<%= name %>">
|
||||
<%= name&.truncate(Constants::NAME_TRUNCATION_LENGTH) %>
|
||||
</span>
|
||||
<% end %>
|
||||
</div>
|
||||
|
|
|
@ -2,13 +2,15 @@
|
|||
locals: { subject: subject&.experiment, breadcrumbs: breadcrumbs } %>
|
||||
<div class="ga-breadcrumb">
|
||||
<%= image_tag 'icon_small/task.svg' %>
|
||||
<% if subject %>
|
||||
<%= link_to my_module_path(subject), title: subject.name do %>
|
||||
<% if subject&.navigable? %>
|
||||
<% path = subject.archived? ? module_archive_experiment_path(subject.experiment) : protocols_my_module_path(subject) %>
|
||||
<%= link_to path, title: subject.name do %>
|
||||
<%= subject.name&.truncate(Constants::NAME_TRUNCATION_LENGTH) %>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<span title="<%= breadcrumbs[:my_module] %>">
|
||||
<%= breadcrumbs[:my_module]&.truncate(Constants::NAME_TRUNCATION_LENGTH) %>
|
||||
<% name = subject&.name || breadcrumbs[:my_module] %>
|
||||
<span title="<%= name %>">
|
||||
<%= name&.truncate(Constants::NAME_TRUNCATION_LENGTH) %>
|
||||
</span>
|
||||
<% end %>
|
||||
</div>
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
<div class="ga-breadcrumb">
|
||||
<%= image_tag 'icon_small/project.svg' %>
|
||||
<% if subject %>
|
||||
<%= link_to project_path(subject), title: subject.name do %>
|
||||
<% path = subject.archived? ? projects_path : project_path(subject) %>
|
||||
<%= link_to path, title: subject.name do %>
|
||||
<%= subject.name&.truncate(Constants::NAME_TRUNCATION_LENGTH) %>
|
||||
<% end %>
|
||||
<% else %>
|
||||
|
|
|
@ -13,9 +13,13 @@
|
|||
subject.team,
|
||||
subject.name&.truncate(Constants::NAME_TRUNCATION_LENGTH),
|
||||
title: subject.name %>
|
||||
<% else %>
|
||||
<% elsif subject.my_module.navigable? %>
|
||||
<%= link_to subject.name&.truncate(Constants::NAME_TRUNCATION_LENGTH),
|
||||
protocols_my_module_path(subject.my_module), title: subject.name %>
|
||||
<% else %>
|
||||
<span title="<%= subject.name %>">
|
||||
<%= subject.name&.truncate(Constants::NAME_TRUNCATION_LENGTH) %>
|
||||
</span>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<span title="<%= breadcrumbs[:protocol] %>">
|
||||
|
|
|
@ -3,13 +3,15 @@
|
|||
<div class="ga-breadcrumb">
|
||||
|
||||
<span class="<%=result_icon_class(subject)%>"></span>
|
||||
<% if subject %>
|
||||
<%= link_to results_my_module_path(subject.my_module), title: subject.name do %>
|
||||
<% if subject&.navigable? %>
|
||||
<% path = subject.archived? ? archive_my_module_path(subject.my_module) : results_my_module_path(subject.my_module) %>
|
||||
<%= link_to path, title: subject.name do %>
|
||||
<%= subject.name&.truncate(Constants::NAME_TRUNCATION_LENGTH) %>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<span title="<%= breadcrumbs[:result] %>">
|
||||
<%= breadcrumbs[:result]&.truncate(Constants::NAME_TRUNCATION_LENGTH) %>
|
||||
<% name = subject&.name || breadcrumbs[:result] %>
|
||||
<span title="<%= name %>">
|
||||
<%= name&.truncate(Constants::NAME_TRUNCATION_LENGTH) %>
|
||||
</span>
|
||||
<% end %>
|
||||
</div>
|
||||
|
|
Loading…
Add table
Reference in a new issue