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