mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-01-01 21:21:50 +08:00
Merge pull request #1114 from ZmagoD/zd_SCI_2304
removes samples from views [fixes SCI-2304]
This commit is contained in:
commit
b277501e6d
13 changed files with 65 additions and 198 deletions
|
@ -17,7 +17,6 @@ class SearchController < ApplicationController
|
|||
search_protocols if @search_category == :protocols
|
||||
search_steps if @search_category == :steps
|
||||
search_checklists if @search_category == :checklists
|
||||
search_samples if @search_category == :samples
|
||||
if @search_category == :repositories && params[:repository]
|
||||
search_repository
|
||||
end
|
||||
|
@ -254,12 +253,6 @@ class SearchController < ApplicationController
|
|||
@search_count = @checklist_search_count
|
||||
end
|
||||
|
||||
def search_samples
|
||||
@sample_results = []
|
||||
@sample_results = search_by_name(Sample) if @sample_search_count > 0
|
||||
@search_count = @sample_search_count
|
||||
end
|
||||
|
||||
def search_repository
|
||||
@repository = Repository.find_by_id(params[:repository])
|
||||
render_403 unless can_read_team?(@repository.team)
|
||||
|
|
|
@ -64,14 +64,6 @@
|
|||
</span>
|
||||
</a>
|
||||
</li>
|
||||
<li role="presentation">
|
||||
<a class="btn btn-link task-card-view-samples" href="<%= my_module_sample_my_modules_url(my_module_id: my_module.id, format: :json) %>" aria-controls="<%= my_module.id %>_samples" role="tab" data-remote="true">
|
||||
<span class="glyphicon glyphicon-tint" aria-hidden="true"></span>
|
||||
<% if my_module.samples.count.positive? %>
|
||||
<span class="badge badge-indicator"><%= my_module.samples.count %></span>
|
||||
<% end %>
|
||||
</a>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
|
||||
|
@ -82,7 +74,6 @@
|
|||
<div role="tabpanel" class="tab-pane" id="<%= my_module.id %>_users" data-contents="users"></div>
|
||||
<div role="tabpanel" class="tab-pane" id="<%= my_module.id %>_activities" data-contents="activities"></div>
|
||||
<div role="tabpanel" class="tab-pane" id="<%= my_module.id %>_comments" data-contents="comments"></div>
|
||||
<div role="tabpanel" class="tab-pane" id="<%= my_module.id %>_samples" data-contents="samples"></div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -3,5 +3,5 @@
|
|||
<%= render partial: "shared/secondary_navigation" %>
|
||||
|
||||
<div id="content">
|
||||
<%= render partial: "shared/samples" %>
|
||||
<%#= render partial: "shared/samples" %>
|
||||
</div>
|
||||
|
|
|
@ -3,5 +3,5 @@
|
|||
<%= render partial: "shared/secondary_navigation" %>
|
||||
|
||||
<div id="content">
|
||||
<%= render partial: "shared/samples" %>
|
||||
<%#= render partial: "shared/samples" %>
|
||||
</div>
|
||||
|
|
|
@ -3,5 +3,5 @@
|
|||
<%= render partial: "shared/secondary_navigation" %>
|
||||
|
||||
<div id="content">
|
||||
<%= render partial: "shared/samples" %>
|
||||
<%#= render partial: "shared/samples" %>
|
||||
</div>
|
||||
|
|
|
@ -66,9 +66,6 @@
|
|||
<li>
|
||||
<%= form.check_box :module_activity, label: t("projects.reports.elements.modals.module_contents_inner.activity") %>
|
||||
</li>
|
||||
<li>
|
||||
<%= form.check_box :module_samples, label: t("projects.reports.elements.modals.module_contents_inner.samples") %>
|
||||
</li>
|
||||
<% # List all repositories, no matter whether rows are assigned or not %>
|
||||
<% Repository.where(team: @project.team).order(created_at: :asc).select(:id, :name).find_each do |repository| %>
|
||||
<li>
|
||||
|
|
|
@ -170,20 +170,6 @@
|
|||
<%= t'Checklists' %>
|
||||
</a>
|
||||
</li>
|
||||
<li role="presentation"
|
||||
class="
|
||||
<%= "active" if @search_category.present? and @search_category == :samples %>
|
||||
<%= "disabled" if @sample_search_count == 0 %>"
|
||||
>
|
||||
<a href="?<%= {category: 'samples', q: @search_query,
|
||||
whole_word: @search_whole_word, whole_phrase: @search_whole_phrase,
|
||||
match_case: @search_case, utf8: '✓',
|
||||
search_id: @search_id}.to_query %>">
|
||||
<span class="badge pull-right"><%= @sample_search_count %></span>
|
||||
<span class="glyphicon glyphicon-tint"></span>
|
||||
<%= t'Samples' %>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<li role="presentation"
|
||||
class="
|
||||
|
@ -290,9 +276,6 @@
|
|||
<% if @search_category == :checklists and @checklist_search_count > 0 %>
|
||||
<%= render 'search/results/checklists', search_query: @search_query, results: @checklist_results %>
|
||||
<% end %>
|
||||
<% if @search_category == :samples and @sample_search_count > 0 %>
|
||||
<%= render 'search/results/samples', search_query: @search_query, results: @sample_results %>
|
||||
<% end %>
|
||||
<% if @search_category == :repositories and @repository_search_count_total > 0 %>
|
||||
<%= render 'search/results/repositories', search_query: @search_query, results: @repository_results, repository: @repository %>
|
||||
<% end %>
|
||||
|
|
|
@ -14,10 +14,6 @@
|
|||
<% else %>
|
||||
<% if can_read_experiment?(my_module.experiment) %>
|
||||
<% case link_to_page %>
|
||||
<% when :samples %>
|
||||
<%= route_to_other_team samples_my_module_path(my_module),
|
||||
my_module.experiment.project.team,
|
||||
text %>
|
||||
<% when :repositories %>
|
||||
<%= route_to_other_team repository_my_module_path(my_module, repository),
|
||||
my_module.experiment.project.team,
|
||||
|
|
|
@ -27,14 +27,6 @@
|
|||
<span class="hidden-xs hidden-lg glyphicon glyphicon-blackboard"></span>
|
||||
</a>
|
||||
</li>
|
||||
<li id="project-samples-nav-tab" class="<%= "active" if is_project_samples? ||
|
||||
sample_types_page_project? ||
|
||||
sample_groups_page_project? %>">
|
||||
<a href="<%= samples_project_url(@project) %>" 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>
|
||||
<li id="project-archive-nav-tab" data-turbolinks="false" class="<%= "active" if is_project_archive? %>">
|
||||
<a href="<%= experiment_archive_project_url(@project) %>" title="<%=t "nav2.projects.archive" %>">
|
||||
<span class="glyphicon glyphicon-briefcase"></span>
|
||||
|
@ -52,14 +44,6 @@
|
|||
<span class="hidden-xs hidden-lg glyphicon glyphicon-blackboard"></span>
|
||||
</a>
|
||||
</li>
|
||||
<li id="experiment-samples-nav-tab" class="<%= "active" if is_experiment_samples? ||
|
||||
sample_groups_page_experiment? ||
|
||||
sample_types_page_expermient? %>">
|
||||
<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_read_project?(@experiment.project) %>
|
||||
<li id="project-archive-nav-tab" data-turbolinks="false" class="<%= "active" if is_experiment_archive? %>">
|
||||
|
@ -94,17 +78,6 @@
|
|||
<% end %>
|
||||
|
||||
<li data-hook="secondary-navigation-tabs"></li>
|
||||
|
||||
<% if can_read_experiment?(@my_module.experiment) %>
|
||||
<li id="module-samples-nav-tab" class="<%= "active" if is_module_samples? ||
|
||||
sample_types_page_my_module? ||
|
||||
sample_groups_page_my_module? %>">
|
||||
<a href="<%= samples_my_module_url(@my_module) %>" title="<%=t "nav2.modules.samples" %>">
|
||||
<span class="hidden-sm hidden-md"><%=t "nav2.modules.samples" %></span>
|
||||
<span class="hidden-xs hidden-lg glyphicon glyphicon-tint"></span>
|
||||
</a>
|
||||
</li>
|
||||
<% end %>
|
||||
<% if can_read_team?(@my_module.experiment.project.team) &&
|
||||
@my_module.experiment.project.team.repositories.exists? %>
|
||||
<li id="repositories-nav-tab" class="<%= "active" if module_repository_page? %>">
|
||||
|
|
|
@ -41,10 +41,10 @@ Rails.application.config.assets.precompile += %w(jquery.ui.touch-punch.min.js)
|
|||
Rails.application.config.assets.precompile += %w(bootstrap-colorselector.js)
|
||||
Rails.application.config.assets.precompile += %w(eventPause-min.js)
|
||||
Rails.application.config.assets.precompile += %w(sidebar.js)
|
||||
Rails.application.config.assets.precompile += %w(samples/samples.js)
|
||||
Rails.application.config.assets.precompile += %w(samples/sample_datatable.js)
|
||||
# Rails.application.config.assets.precompile += %w(samples/samples.js)
|
||||
# Rails.application.config.assets.precompile += %w(samples/sample_datatable.js)
|
||||
Rails.application.config.assets.precompile += %w(projects/index.js)
|
||||
Rails.application.config.assets.precompile += %w(samples/samples_importer.js)
|
||||
# Rails.application.config.assets.precompile += %w(samples/samples_importer.js)
|
||||
Rails.application.config.assets.precompile += %w(projects/canvas.js)
|
||||
Rails.application.config.assets.precompile +=
|
||||
%w(experiments/dropdown_actions.js)
|
||||
|
@ -73,7 +73,7 @@ Rails.application.config.assets.precompile += %w(comments.js)
|
|||
Rails.application.config.assets.precompile += %w(projects/show.js)
|
||||
Rails.application.config.assets.precompile += %w(notifications.js)
|
||||
Rails.application.config.assets.precompile += %w(users/invite_users_modal.js)
|
||||
Rails.application.config.assets.precompile += %w(samples/sample_types_groups.js)
|
||||
# Rails.application.config.assets.precompile += %w(samples/sample_types_groups.js)
|
||||
Rails.application.config.assets.precompile += %w(highlightjs-github-theme.css)
|
||||
Rails.application.config.assets.precompile += %w(search.js)
|
||||
Rails.application.config.assets.precompile += %w(repositories/index.js)
|
||||
|
|
|
@ -94,10 +94,6 @@ module ReportExtends
|
|||
:activity,
|
||||
false,
|
||||
%i(my_module order)),
|
||||
ModuleElement.new([:samples],
|
||||
:samples,
|
||||
false,
|
||||
%i(my_module order)),
|
||||
ModuleElement.new([:repository],
|
||||
:repository,
|
||||
false,
|
||||
|
@ -113,14 +109,12 @@ module ReportExtends
|
|||
# adds :order local to listed elements views
|
||||
# ADD REPORT ELEMENT TYPE WHICH YOU WANT TO PASS 'ORDER' LOCAL IN THE PARTIAL
|
||||
SORTED_ELEMENTS = %w(my_module_activity
|
||||
my_module_samples
|
||||
my_module_repository
|
||||
step_comments
|
||||
result_comments)
|
||||
# sets local :my_module to the listed my_module child elements
|
||||
MY_MODULE_ELEMENTS = %w(my_module
|
||||
my_module_activity
|
||||
my_module_samples
|
||||
my_module_repository)
|
||||
|
||||
# sets local name to first element of the listed elements
|
||||
|
|
116
config/routes.rb
116
config/routes.rb
|
@ -27,15 +27,15 @@ Rails.application.routes.draw do
|
|||
# end
|
||||
|
||||
# Save sample table state
|
||||
post '/state_save/:team_id/:user_id',
|
||||
to: 'user_samples#save_samples_table_status',
|
||||
as: 'save_samples_table_status',
|
||||
defaults: { format: 'json' }
|
||||
|
||||
post '/state_load/:team_id/:user_id',
|
||||
to: 'user_samples#load_samples_table_status',
|
||||
as: 'load_samples_table_status',
|
||||
defaults: { format: 'json' }
|
||||
# post '/state_save/:team_id/:user_id',
|
||||
# to: 'user_samples#save_samples_table_status',
|
||||
# as: 'save_samples_table_status',
|
||||
# defaults: { format: 'json' }
|
||||
#
|
||||
# post '/state_load/:team_id/:user_id',
|
||||
# to: 'user_samples#load_samples_table_status',
|
||||
# as: 'load_samples_table_status',
|
||||
# defaults: { format: 'json' }
|
||||
|
||||
resources :activities, only: [:index]
|
||||
|
||||
|
@ -156,22 +156,22 @@ Rails.application.routes.draw do
|
|||
post 'copy', to: 'repositories#copy',
|
||||
defaults: { format: 'json' }
|
||||
end
|
||||
resources :samples, only: [:new, :create]
|
||||
resources :sample_types, except: [:show, :new] do
|
||||
get 'sample_type_element', to: 'sample_types#sample_type_element'
|
||||
get 'destroy_confirmation', to: 'sample_types#destroy_confirmation'
|
||||
end
|
||||
resources :sample_groups, except: [:show, :new] do
|
||||
get 'sample_group_element', to: 'sample_groups#sample_group_element'
|
||||
get 'destroy_confirmation', to: 'sample_groups#destroy_confirmation'
|
||||
end
|
||||
resources :custom_fields, only: [:create, :edit, :update, :destroy] do
|
||||
get 'destroy_html'
|
||||
end
|
||||
# resources :samples, only: [:new, :create]
|
||||
# resources :sample_types, except: [:show, :new] do
|
||||
# get 'sample_type_element', to: 'sample_types#sample_type_element'
|
||||
# get 'destroy_confirmation', to: 'sample_types#destroy_confirmation'
|
||||
# end
|
||||
# resources :sample_groups, except: [:show, :new] do
|
||||
# get 'sample_group_element', to: 'sample_groups#sample_group_element'
|
||||
# get 'destroy_confirmation', to: 'sample_groups#destroy_confirmation'
|
||||
# end
|
||||
# resources :custom_fields, only: [:create, :edit, :update, :destroy] do
|
||||
# get 'destroy_html'
|
||||
# end
|
||||
member do
|
||||
post 'parse_sheet', defaults: { format: 'json' }
|
||||
post 'import_samples'
|
||||
post 'export_samples'
|
||||
# post 'import_samples'
|
||||
# post 'export_samples'
|
||||
post 'export_repository', to: 'repositories#export_repository'
|
||||
# Used for atwho (smart annotations)
|
||||
get 'atwho_users', to: 'at_who#users'
|
||||
|
@ -254,15 +254,15 @@ Rails.application.routes.draw do
|
|||
member do
|
||||
# Notifications popup for individual project in projects index
|
||||
get 'notifications'
|
||||
get 'samples' # Samples for single project
|
||||
# get 'samples' # Samples for single project
|
||||
# Renders sample datatable for single project (ajax action)
|
||||
post 'samples_index'
|
||||
# post 'samples_index'
|
||||
get 'experiment_archive' # Experiment archive for single project
|
||||
post :delete_samples,
|
||||
constraints: CommitParamRouting.new(
|
||||
ProjectsController::DELETE_SAMPLES
|
||||
),
|
||||
action: :delete_samples
|
||||
# post :delete_samples,
|
||||
# constraints: CommitParamRouting.new(
|
||||
# ProjectsController::DELETE_SAMPLES
|
||||
# ),
|
||||
# action: :delete_samples
|
||||
end
|
||||
|
||||
# This route is defined outside of member block
|
||||
|
@ -286,16 +286,16 @@ Rails.application.routes.draw do
|
|||
post 'clone' # clone experiment
|
||||
get 'move_modal' # return modal with move options
|
||||
post 'move' # move experiment
|
||||
get 'samples' # Samples for single project
|
||||
# get 'samples' # Samples for single project
|
||||
get 'updated_img' # Checks if the workflow image is updated
|
||||
get 'fetch_workflow_img' # Get udated workflow img
|
||||
# Renders sample datatable for single project (ajax action)
|
||||
post 'samples_index'
|
||||
post :delete_samples,
|
||||
constraints: CommitParamRouting.new(
|
||||
ExperimentsController::DELETE_SAMPLES
|
||||
),
|
||||
action: :delete_samples
|
||||
# post 'samples_index'
|
||||
# post :delete_samples,
|
||||
# constraints: CommitParamRouting.new(
|
||||
# ExperimentsController::DELETE_SAMPLES
|
||||
# ),
|
||||
# action: :delete_samples
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -308,7 +308,7 @@ Rails.application.routes.draw do
|
|||
resources :my_module_comments,
|
||||
path: '/comments',
|
||||
only: [:index, :create, :edit, :update, :destroy]
|
||||
resources :sample_my_modules, path: '/samples_index', only: [:index]
|
||||
# resources :sample_my_modules, path: '/samples_index', only: [:index]
|
||||
resources :result_texts, only: [:new, :create]
|
||||
resources :result_assets, only: [:new, :create]
|
||||
resources :result_tables, only: [:new, :create]
|
||||
|
@ -321,7 +321,7 @@ Rails.application.routes.draw do
|
|||
get 'due_date'
|
||||
get 'protocols' # Protocols view for single module
|
||||
get 'results' # Results view for single module
|
||||
get 'samples' # Samples view for single module
|
||||
# get 'samples' # Samples view for single module
|
||||
# Repository view for single module
|
||||
get 'repository/:repository_id',
|
||||
to: 'my_modules#repository',
|
||||
|
@ -339,22 +339,22 @@ Rails.application.routes.draw do
|
|||
get 'complete_my_module'
|
||||
post 'toggle_task_state'
|
||||
# Renders sample datatable for single module (ajax action)
|
||||
post 'samples_index'
|
||||
post :assign_samples,
|
||||
constraints: CommitParamRouting.new(
|
||||
MyModulesController::ASSIGN_SAMPLES
|
||||
),
|
||||
action: :assign_samples
|
||||
post :assign_samples,
|
||||
constraints: CommitParamRouting.new(
|
||||
MyModulesController::UNASSIGN_SAMPLES
|
||||
),
|
||||
action: :unassign_samples
|
||||
post :assign_samples,
|
||||
constraints: CommitParamRouting.new(
|
||||
MyModulesController::DELETE_SAMPLES
|
||||
),
|
||||
action: :delete_samples
|
||||
# post 'samples_index'
|
||||
# post :assign_samples,
|
||||
# constraints: CommitParamRouting.new(
|
||||
# MyModulesController::ASSIGN_SAMPLES
|
||||
# ),
|
||||
# action: :assign_samples
|
||||
# post :assign_samples,
|
||||
# constraints: CommitParamRouting.new(
|
||||
# MyModulesController::UNASSIGN_SAMPLES
|
||||
# ),
|
||||
# action: :unassign_samples
|
||||
# post :assign_samples,
|
||||
# constraints: CommitParamRouting.new(
|
||||
# MyModulesController::DELETE_SAMPLES
|
||||
# ),
|
||||
# action: :delete_samples
|
||||
end
|
||||
|
||||
# Those routes are defined outside of member block
|
||||
|
@ -384,8 +384,8 @@ Rails.application.routes.draw do
|
|||
only: [:create, :index, :edit, :update, :destroy]
|
||||
end
|
||||
|
||||
resources :samples, only: [:edit, :update, :destroy]
|
||||
get 'samples/:id', to: 'samples#show'
|
||||
# resources :samples, only: [:edit, :update, :destroy]
|
||||
# get 'samples/:id', to: 'samples#show'
|
||||
|
||||
resources :result_texts, only: [:edit, :update, :destroy]
|
||||
get 'result_texts/:id/download' => 'result_texts#download',
|
||||
|
@ -521,7 +521,7 @@ Rails.application.routes.draw do
|
|||
post 'auth/token', to: 'api#authenticate'
|
||||
scope '20170715', module: 'v20170715' do
|
||||
get 'tasks/tree', to: 'core_api#tasks_tree'
|
||||
get 'tasks/:task_id/samples', to: 'core_api#task_samples'
|
||||
# get 'tasks/:task_id/samples', to: 'core_api#task_samples'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -12,66 +12,6 @@ describe Api::V20170715::CoreApiController, type: :controller do
|
|||
UserProject.create!(user: user, project: task.experiment.project, role: 0)
|
||||
end
|
||||
|
||||
describe 'GET #task_samples' do
|
||||
context 'When valid request' do
|
||||
before do
|
||||
request.headers['HTTP_ACCEPT'] = 'application/json'
|
||||
request.headers['Authorization'] = 'Bearer ' + generate_token(user.id)
|
||||
get :task_samples, params: { task_id: task.id }
|
||||
end
|
||||
|
||||
it 'Returns HTTP success' do
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
|
||||
it 'Returns JSON body containing expected Samples' do
|
||||
hash_body = nil
|
||||
expect { hash_body = json }.not_to raise_exception
|
||||
expect(hash_body).to match(
|
||||
[{ 'sample_id' => sample1.id.to_s, 'name' => sample1.name },
|
||||
{ 'sample_id' => sample2.id.to_s, 'name' => sample2.name },
|
||||
{ 'sample_id' => sample3.id.to_s, 'name' => sample3.name }]
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
context 'When invalid request' do
|
||||
context 'When invalid token' do
|
||||
before do
|
||||
request.headers['HTTP_ACCEPT'] = 'application/json'
|
||||
request.headers['Authorization'] = 'Bearer WroNgToken'
|
||||
get :task_samples, params: { task_id: task.id }
|
||||
end
|
||||
|
||||
it 'Returns HTTP unauthorized' do
|
||||
expect(response).to have_http_status(401)
|
||||
end
|
||||
end
|
||||
|
||||
context 'When valid token, but invalid request' do
|
||||
before do
|
||||
request.headers['HTTP_ACCEPT'] = 'application/json'
|
||||
request.headers['Authorization'] = 'Bearer ' + generate_token(user.id)
|
||||
end
|
||||
|
||||
it 'Returns HTTP not found' do
|
||||
get :task_samples, params: { task_id: 1000 }
|
||||
expect(response).to have_http_status(404)
|
||||
expect(json).to match({})
|
||||
end
|
||||
|
||||
it 'Returns HTTP access denied' do
|
||||
UserProject.where(user: user, project: task.experiment.project)
|
||||
.first
|
||||
.destroy!
|
||||
get :task_samples, params: { task_id: task.id }
|
||||
expect(response).to have_http_status(403)
|
||||
expect(json).to match({})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'GET #tasks_tree' do
|
||||
let!(:user_team) { create :user_team, team: team, user: user }
|
||||
context 'When valid request' do
|
||||
|
|
Loading…
Reference in a new issue