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