mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-02-02 21:20:08 +08:00
Add state switch to experiment level for archived experiments [SCI-8503] (#5464)
This commit is contained in:
parent
1b01cc5407
commit
040b3bddce
8 changed files with 44 additions and 21 deletions
|
@ -138,6 +138,8 @@ var hammertime;
|
|||
* Initializes page
|
||||
*/
|
||||
function init() {
|
||||
if ($("#canvas-container").length === 0) return;
|
||||
|
||||
if($('#module-archive').length) {
|
||||
bindFullZoomAjaxTabs();
|
||||
bindEditTagsAjax($("div.module-large"));
|
||||
|
|
|
@ -81,15 +81,16 @@ class ExperimentsController < ApplicationController
|
|||
end
|
||||
|
||||
def canvas
|
||||
redirect_to module_archive_experiment_path(@experiment) if @experiment.archived_branch?
|
||||
@project = @experiment.project
|
||||
@active_modules = @experiment.my_modules.active.order(:name)
|
||||
.left_outer_joins(:designated_users, :task_comments)
|
||||
.preload(:tags, outputs: :to)
|
||||
.preload(:my_module_status, :my_module_group, user_assignments: %i(user user_role))
|
||||
.select('COUNT(DISTINCT users.id) as designated_users_count')
|
||||
.select('COUNT(DISTINCT comments.id) as task_comments_count')
|
||||
.select('my_modules.*').group(:id)
|
||||
@active_modules = unless @experiment.archived_branch?
|
||||
@experiment.my_modules.active.order(:name)
|
||||
.left_outer_joins(:designated_users, :task_comments)
|
||||
.preload(:tags, outputs: :to)
|
||||
.preload(:my_module_status, :my_module_group, user_assignments: %i(user user_role))
|
||||
.select('COUNT(DISTINCT users.id) as designated_users_count')
|
||||
.select('COUNT(DISTINCT comments.id) as task_comments_count')
|
||||
.select('my_modules.*').group(:id)
|
||||
end
|
||||
end
|
||||
|
||||
def table
|
||||
|
@ -108,10 +109,19 @@ class ExperimentsController < ApplicationController
|
|||
end
|
||||
|
||||
def load_table
|
||||
my_modules = @experiment.my_modules.readable_by_user(current_user)
|
||||
active_view_mode = params[:view_mode] == 'active'
|
||||
my_modules = nil
|
||||
|
||||
unless @experiment.archived_branch?
|
||||
my_modules = params[:view_mode] == 'archived' ? my_modules.archived : my_modules.active
|
||||
unless @experiment.archived_branch? && active_view_mode
|
||||
my_modules = @experiment.my_modules.readable_by_user(current_user)
|
||||
|
||||
unless @experiment.archived_branch?
|
||||
my_modules = if active_view_mode
|
||||
my_modules.active
|
||||
else
|
||||
my_modules.archived
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
render json: Experiments::TableViewService.new(@experiment, my_modules, current_user, params).call
|
||||
|
@ -646,7 +656,7 @@ class ExperimentsController < ApplicationController
|
|||
end
|
||||
|
||||
def view_mode_redirect_url(view_type)
|
||||
if params[:view_mode] == 'archived' || @experiment.archived_branch?
|
||||
if params[:view_mode] == 'archived'
|
||||
case view_type
|
||||
when 'canvas'
|
||||
module_archive_experiment_path(@experiment)
|
||||
|
|
|
@ -639,7 +639,7 @@ class MyModulesController < ApplicationController
|
|||
def set_navigator
|
||||
@navigator = {
|
||||
url: tree_navigator_my_module_path(@my_module),
|
||||
archived: @my_module.archived? || @my_module.experiment.archived_branch?,
|
||||
archived: params[:view_mode] == 'archived',
|
||||
id: @my_module.code
|
||||
}
|
||||
end
|
||||
|
|
|
@ -40,12 +40,12 @@ module Navigator
|
|||
}
|
||||
end
|
||||
|
||||
def my_module_serializer(my_module)
|
||||
def my_module_serializer(my_module, archived)
|
||||
{
|
||||
id: my_module.code,
|
||||
name: my_module.name,
|
||||
type: :my_module,
|
||||
url: protocols_my_module_path(my_module),
|
||||
url: protocols_my_module_path(my_module, view_mode: archived ? 'archived' : 'active'),
|
||||
archived: my_module.archived_branch?,
|
||||
has_children: false
|
||||
}
|
||||
|
@ -185,7 +185,7 @@ module Navigator
|
|||
|
||||
def my_module_level_branch(experiment, archived = false)
|
||||
fetch_my_modules(experiment, archived)
|
||||
.map { |i| my_module_serializer(i) }
|
||||
.map { |i| my_module_serializer(i, archived) }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -44,6 +44,12 @@ module Experiments
|
|||
end
|
||||
|
||||
def call
|
||||
if @my_modules.nil?
|
||||
return {
|
||||
next_page: nil,
|
||||
data: []
|
||||
}
|
||||
end
|
||||
result = []
|
||||
my_module_list = @my_modules
|
||||
@filters.each do |name, value|
|
||||
|
|
|
@ -56,7 +56,7 @@
|
|||
|
||||
<%= render partial: 'shared/state_view_switch', locals: {
|
||||
disabled: false,
|
||||
switchable: !@experiment.archived_branch?,
|
||||
switchable: true,
|
||||
archived: action_name == 'module_archive' || params[:view_mode] == 'archived',
|
||||
active_url: my_modules_experiment_path(@experiment),
|
||||
archived_url: my_modules_experiment_path(@experiment, view_mode: :archived),
|
||||
|
|
|
@ -51,10 +51,11 @@
|
|||
</div>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div id="canvas-container" data-project-id="<%= @project.id %>" data-module-tags-url="<%= my_module_tags_experiment_path(@experiment, format: :json) %>">
|
||||
<%= render partial: 'canvas/full_zoom', locals: { experiment: @experiment, my_modules: @active_modules } %>
|
||||
</div>
|
||||
<% if @active_modules %>
|
||||
<div id="canvas-container" data-project-id="<%= @project.id %>" data-module-tags-url="<%= my_module_tags_experiment_path(@experiment, format: :json) %>">
|
||||
<%= render partial: 'canvas/full_zoom', locals: { experiment: @experiment, my_modules: @active_modules } %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<!-- Manage tags modal -->
|
||||
|
|
|
@ -45,6 +45,10 @@
|
|||
<!-- Manage tags modal -->
|
||||
<%= render partial: 'my_modules/modals/manage_module_tags_modal', locals: { my_module: nil } %>
|
||||
|
||||
<% unless @my_modules.present? %>
|
||||
<%= render partial: 'task_view_dropdowns.html.erb' %>
|
||||
<% end %>
|
||||
|
||||
</div>
|
||||
<% unless @my_modules.present? %>
|
||||
<div class="row">
|
||||
|
|
Loading…
Reference in a new issue