fixes samples page for experiment level [fixes SCI-44]

This commit is contained in:
zmagod 2016-08-02 08:44:07 +02:00
parent c7e1dea1bc
commit 9581e2751f
6 changed files with 47 additions and 5 deletions

View file

@ -1,8 +1,8 @@
class ExperimentsController < ApplicationController
include PermissionHelper
before_action :set_experiment, except: [:new, :create]
before_action :set_project, only: [:new, :create]
before_action :check_view_permissions, only: [:canvas]
before_action :set_project, only: [:new, :create, :samples_index, :samples ]
# before_action :check_view_permissions, only: [:canvas]
# except parameter could be used but it is not working.
layout :choose_layout
@ -66,6 +66,22 @@ class ExperimentsController < ApplicationController
end
end
def samples
@samples_index_link = samples_index_experiment_path(@experiment, format: :json)
@organization = @experiment.project.organization
end
def samples_index
@organization = @experiment.project.organization
respond_to do |format|
format.html
format.json {
render json: ::SampleDatatable.new(view_context, @organization, @experiment, nil)
}
end
end
private
def set_experiment
@ -74,7 +90,7 @@ class ExperimentsController < ApplicationController
end
def set_project
@project = Project.find_by_id(params[:project_id])
@project = Project.find_by_id(params[:project_id]) || @experiment.project
render_404 unless @project
end

View file

@ -140,7 +140,8 @@ module PermissionHelper
:can_view_experiment,
:can_view_experiment_archive,
:can_archive_experiment,
:can_restore_experiment
:can_restore_experiment,
:can_view_experiment_samples
] do |proxy, *args, &block|
if args[0]
experiment = args[0]
@ -346,6 +347,9 @@ module PermissionHelper
experiment.archived? and is_user_or_higher_of_project(experiment.project)
end
def can_view_experiment_samples(experiment)
can_view_samples(experiment.project.organization)
end
# ---- WORKFLOW PERMISSIONS ----
def can_edit_canvas(experiment)

View file

@ -28,6 +28,10 @@ module SecondaryNavigationHelper
action_name == 'module_archive'
end
def is_experiment_samples?
action_name == 'samples'
end
def is_module_info?
action_name == 'show'
end

View file

@ -0,0 +1,7 @@
<% provide(:head_title, raw(t("projects.samples.head_title", project: @experiment.name))) %>
<%= render partial: "shared/sidebar" %>
<%= render partial: "shared/secondary_navigation" %>
<div id="content">
<%= render partial: "shared/samples" %>
</div>

View file

@ -99,6 +99,14 @@
<% end %>
<% elsif experiment_page? %>
<% if can_view_experiment_samples(@experiment) then %>
<li id="experiment-samples-nav-tab" class="<%= "active" if is_experiment_samples? %>">
<a href="<%= samples_experiment_url(@experiment) %>" title="<%=t "nav2.projects.samples" %>">
<span class="hidden-sm hidden-md"><%=t "nav2.projects.samples" %></span>
<span class="hidden-xs hidden-lg glyphicon glyphicon-tint"></span>
</a>
</li>
<% end %>
<% if can_view_experiment(@experiment) then %>
<li id="canvas-nav-tab" class="<%= "active" if is_experiment_canvas? %>">
<a href="<%= project_url(@project) %>" title="<%=t "nav2.experiments.canvas" %>">

View file

@ -101,7 +101,7 @@ Rails.application.routes.draw do
get 'users/edit', to: 'user_projects#index_edit'
end
resources :experiments do
resources :experiments, only: :show do
member do
get 'canvas' # Overview/structure for single experiment
get 'canvas/edit', to: 'canvas#edit' # AJAX-loaded canvas edit mode (from canvas)
@ -110,6 +110,9 @@ Rails.application.routes.draw do
get 'canvas/small_zoom', to: 'canvas#small_zoom' # AJAX-loaded canvas zoom
post 'canvas', to: 'canvas#update' # Save updated canvas action
get 'module_archive' # Module archive for single experiment
get 'samples' # Samples for single project
post 'samples_index' # Renders sample datatable for single project (ajax action)
post :delete_samples, constraints: CommitParamRouting.new(MyModulesController::DELETE_SAMPLES), action: :delete_samples
end
end