mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-09 22:55:34 +08:00
fix project navigation to work with archived pages and correct current team
This commit is contained in:
parent
b13e997350
commit
600ec99c82
6 changed files with 29 additions and 24 deletions
|
@ -7,20 +7,19 @@ class ExperimentsController < ApplicationController
|
|||
include Rails.application.routes.url_helpers
|
||||
|
||||
before_action :set_experiment,
|
||||
except: [:new, :create]
|
||||
except: %i(new create)
|
||||
before_action :set_project,
|
||||
only: [:new, :create, :samples_index, :samples, :module_archive,
|
||||
:clone_modal, :move_modal, :delete_samples]
|
||||
before_action :load_projects_by_teams, only: %i(canvas samples)
|
||||
only: %i(new create samples_index samples module_archive
|
||||
clone_modal move_modal delete_samples)
|
||||
before_action :load_projects_by_teams, only: %i(canvas samples module_archive)
|
||||
before_action :check_view_permissions,
|
||||
only: [:canvas, :module_archive]
|
||||
only: %i(canvas module_archive)
|
||||
before_action :check_manage_permissions, only: :edit
|
||||
before_action :check_archive_permissions, only: :archive
|
||||
before_action :check_clone_permissions, only: %i(clone_modal clone)
|
||||
before_action :check_move_permissions, only: %i(move_modal move)
|
||||
|
||||
# except parameter could be used but it is not working.
|
||||
layout :choose_layout
|
||||
layout 'fluid'.freeze
|
||||
|
||||
# Action defined in SampleActions
|
||||
DELETE_SAMPLES = 'Delete'.freeze
|
||||
|
@ -350,7 +349,8 @@ class ExperimentsController < ApplicationController
|
|||
end
|
||||
|
||||
def load_projects_by_teams
|
||||
@projects_by_teams = current_user.projects_by_teams
|
||||
@projects_by_teams = current_user.projects_by_teams(current_team.id,
|
||||
nil, false)
|
||||
end
|
||||
|
||||
def check_view_permissions
|
||||
|
@ -373,10 +373,6 @@ class ExperimentsController < ApplicationController
|
|||
render_403 unless can_move_experiment?(@experiment)
|
||||
end
|
||||
|
||||
def choose_layout
|
||||
action_name.in?(%w(index archive)) ? 'main' : 'fluid'
|
||||
end
|
||||
|
||||
def experiment_annotation_notification(old_text = nil)
|
||||
smart_annotation_notification(
|
||||
old_text: old_text,
|
||||
|
|
|
@ -17,8 +17,8 @@ class MyModulesController < ApplicationController
|
|||
before_action :load_repository, only: %i(assign_repository_records
|
||||
unassign_repository_records
|
||||
repository_index)
|
||||
before_action :load_projects_by_teams,
|
||||
only: %i(protocols results activities samples repository)
|
||||
before_action :load_projects_by_teams, only: %i(protocols results activities
|
||||
samples repository archive)
|
||||
before_action :check_manage_permissions,
|
||||
only: %i(update destroy description due_date)
|
||||
before_action :check_view_info_permissions, only: :show
|
||||
|
@ -608,7 +608,8 @@ class MyModulesController < ApplicationController
|
|||
end
|
||||
|
||||
def load_projects_by_teams
|
||||
@projects_by_teams = current_user.projects_by_teams
|
||||
@projects_by_teams = current_user.projects_by_teams(current_team.id,
|
||||
nil, false)
|
||||
end
|
||||
|
||||
def check_manage_permissions
|
||||
|
|
|
@ -9,15 +9,15 @@ class ProjectsController < ApplicationController
|
|||
notifications reports
|
||||
samples experiment_archive
|
||||
delete_samples samples_index)
|
||||
before_action :load_projects_by_teams, only: %i(index show samples archive)
|
||||
before_action :load_projects_by_teams, only: %i(index show samples archive
|
||||
experiment_archive)
|
||||
before_action :load_archive_vars, only: :archive
|
||||
before_action :check_view_permissions, only: %i(show reports notifications
|
||||
samples experiment_archive
|
||||
samples_index)
|
||||
before_action :check_create_permissions, only: %i(new create)
|
||||
before_action :check_manage_permissions, only: :edit
|
||||
|
||||
@filter_by_archived = false
|
||||
|
||||
# except parameter could be used but it is not working.
|
||||
layout 'fluid'
|
||||
|
||||
|
@ -36,7 +36,6 @@ class ProjectsController < ApplicationController
|
|||
end
|
||||
|
||||
def archive
|
||||
@filter_by_archived = true
|
||||
index
|
||||
end
|
||||
|
||||
|
@ -322,7 +321,16 @@ class ProjectsController < ApplicationController
|
|||
@current_sort = params[:sort].to_s
|
||||
@projects_by_teams = current_user.projects_by_teams(@current_team_id,
|
||||
@current_sort,
|
||||
@filter_by_archived)
|
||||
false)
|
||||
else
|
||||
@projects_by_teams = []
|
||||
end
|
||||
end
|
||||
|
||||
def load_archive_vars
|
||||
if current_user.teams.any?
|
||||
@archived_projects_by_teams =
|
||||
current_user.projects_by_teams(@current_team_id, @current_sort, true)
|
||||
else
|
||||
@projects_by_teams = []
|
||||
end
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<% provide(:head_title, t("projects.archive.head_title")) %>
|
||||
<%= render partial: "shared/sidebar" %>
|
||||
|
||||
<% if @projects_by_teams.length > 0 %>
|
||||
<% if @archived_projects_by_teams.length > 0 %>
|
||||
<div id="projects-toolbar">
|
||||
|
||||
<form class="form-inline" action="<%= projects_archive_path %>">
|
||||
|
@ -29,7 +29,7 @@
|
|||
</form>
|
||||
</div>
|
||||
|
||||
<% @projects_by_teams.each do |team, projects| %>
|
||||
<% @archived_projects_by_teams.each do |team, projects| %>
|
||||
<%= render partial: 'projects/archive/team_projects',
|
||||
locals: {team: team, projects: projects} %>
|
||||
<% end %>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<div id="slide-panel" class="visible">
|
||||
<div class="tree">
|
||||
<ul>
|
||||
<% if project_page? && action_name == 'index' ||
|
||||
<% if project_page? && action_name.in?(%w(index archive)) ||
|
||||
sample_types_page_project? ||
|
||||
sample_groups_page_project? %>
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<% @projects_by_teams.each do |team, projects| %>
|
||||
<% projects.each do |project| %>
|
||||
|
||||
<% if (project_page? && action_name == 'show' ||
|
||||
<% if (project_page? && action_name.in?(%w(show experiment_archive)) ||
|
||||
sample_types_page_project? ||
|
||||
sample_groups_page_project?) && project == @project %>
|
||||
<li class="active" data-parent="candidate">
|
||||
|
|
Loading…
Add table
Reference in a new issue