mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-02-27 01:05:21 +08:00
Fix Hounds warning
This commit is contained in:
parent
a25a4354c6
commit
2f0dc57ea6
3 changed files with 49 additions and 50 deletions
|
@ -128,10 +128,11 @@
|
|||
}
|
||||
|
||||
ul {
|
||||
.project-contents-list {
|
||||
&.project-contents-list {
|
||||
padding-left: 15px !important;
|
||||
}
|
||||
.experiment-contents-list {
|
||||
|
||||
&.experiment-contents-list {
|
||||
padding-left: 30px !important;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -228,7 +228,7 @@ class ReportsController < ApplicationController
|
|||
format.json do
|
||||
render json: {
|
||||
html: render_to_string(
|
||||
partial: "reports/new/modal/experiment_contents.html.erb",
|
||||
partial: 'reports/new/modal/experiment_contents.html.erb',
|
||||
locals: { project: @project, experiment: experiment }
|
||||
)
|
||||
}
|
||||
|
@ -322,12 +322,9 @@ class ReportsController < ApplicationController
|
|||
|
||||
def experiment_contents
|
||||
experiment = Experiment.find_by_id(params[:id])
|
||||
if params.include? :modules then
|
||||
modules =
|
||||
(params[:modules].select { |m, p| p == "1" })
|
||||
.keys
|
||||
.collect { |id| id.to_i }
|
||||
end
|
||||
modules = (params[:modules].select { |_, p| p == "1" })
|
||||
.keys
|
||||
.collect(&:to_i)
|
||||
|
||||
respond_to do |format|
|
||||
if experiment.blank?
|
||||
|
@ -341,12 +338,12 @@ class ReportsController < ApplicationController
|
|||
if elements_empty? elements
|
||||
format.json { render json: {}, status: :no_content }
|
||||
else
|
||||
format.json {
|
||||
format.json do
|
||||
render json: {
|
||||
status: :ok,
|
||||
elements: elements
|
||||
}
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -449,19 +446,18 @@ class ReportsController < ApplicationController
|
|||
|
||||
def generate_project_contents_json
|
||||
res = []
|
||||
if params.include? :modules then
|
||||
modules =
|
||||
(params[:modules].select { |m, p| p == "1" })
|
||||
.keys
|
||||
.collect { |id| id.to_i }
|
||||
if params.include? :modules
|
||||
modules = (params[:modules].select { |_, p| p == "1" })
|
||||
.keys
|
||||
.collect(&:to_i)
|
||||
|
||||
# Get unique experiments from given modules
|
||||
experiments = MyModule.where(id: modules).map(&:experiment).uniq
|
||||
experiments.each do |experiment|
|
||||
res << generate_new_el(false)
|
||||
el = generate_el(
|
||||
"reports/elements/experiment_element.html.erb",
|
||||
{ experiment: experiment }
|
||||
'reports/elements/experiment_element.html.erb',
|
||||
experiment: experiment
|
||||
)
|
||||
el[:children] = generate_experiment_contents_json(experiment, modules)
|
||||
res << el
|
||||
|
@ -474,16 +470,16 @@ class ReportsController < ApplicationController
|
|||
def generate_experiment_contents_json(experiment, selected_modules)
|
||||
res = []
|
||||
experiment.my_modules.each do |my_module|
|
||||
if selected_modules.include?(my_module.id)
|
||||
res << generate_new_el(false)
|
||||
el = generate_el(
|
||||
"reports/elements/my_module_element.html.erb",
|
||||
{ my_module: my_module }
|
||||
)
|
||||
el[:children] = generate_module_contents_json(my_module)
|
||||
res << el
|
||||
res << generate_new_el(false)
|
||||
end
|
||||
next unless selected_modules.include?(my_module.id)
|
||||
|
||||
res << generate_new_el(false)
|
||||
el = generate_el(
|
||||
'reports/elements/my_module_element.html.erb',
|
||||
my_module: my_module
|
||||
)
|
||||
el[:children] = generate_module_contents_json(my_module)
|
||||
res << el
|
||||
res << generate_new_el(false)
|
||||
end
|
||||
res
|
||||
end
|
||||
|
|
|
@ -61,37 +61,39 @@ Rails.application.routes.draw do
|
|||
post 'generate', to: 'reports#generate'
|
||||
get 'new/', to: 'reports#new'
|
||||
get 'new/project_contents_modal',
|
||||
to: 'reports#project_contents_modal',
|
||||
as: :project_contents_modal
|
||||
to: 'reports#project_contents_modal',
|
||||
as: :project_contents_modal
|
||||
post 'new/project_contents',
|
||||
to: 'reports#project_contents',
|
||||
as: :project_contents
|
||||
to: 'reports#project_contents',
|
||||
as: :project_contents
|
||||
get 'new/experiment_contents_modal',
|
||||
to: 'reports#experiment_contents_modal',
|
||||
as: :experiment_contents_modal
|
||||
to: 'reports#experiment_contents_modal',
|
||||
as: :experiment_contents_modal
|
||||
post 'new/experiment_contents',
|
||||
to: 'reports#experiment_contents',
|
||||
as: :experiment_contents
|
||||
to: 'reports#experiment_contents',
|
||||
as: :experiment_contents
|
||||
get 'new/module_contents_modal',
|
||||
to: 'reports#module_contents_modal',
|
||||
as: :module_contents_modal
|
||||
to: 'reports#module_contents_modal',
|
||||
as: :module_contents_modal
|
||||
post 'new/module_contents',
|
||||
to: 'reports#module_contents',
|
||||
as: :module_contents
|
||||
to: 'reports#module_contents',
|
||||
as: :module_contents
|
||||
get 'new/step_contents_modal',
|
||||
to: 'reports#step_contents_modal',
|
||||
as: :step_contents_modal
|
||||
to: 'reports#step_contents_modal',
|
||||
as: :step_contents_modal
|
||||
post 'new/step_contents',
|
||||
to: 'reports#step_contents',
|
||||
as: :step_contents
|
||||
to: 'reports#step_contents',
|
||||
as: :step_contents
|
||||
get 'new/result_contents_modal',
|
||||
to: 'reports#result_contents_modal',
|
||||
as: :result_contents_modal
|
||||
to: 'reports#result_contents_modal',
|
||||
as: :result_contents_modal
|
||||
post 'new/result_contents',
|
||||
to: 'reports#result_contents',
|
||||
as: :result_contents
|
||||
post '_save', to: 'reports#save_modal', as: :save_modal
|
||||
post 'destroy', as: :destroy # Destroy multiple entries at once
|
||||
to: 'reports#result_contents',
|
||||
as: :result_contents
|
||||
post '_save',
|
||||
to: 'reports#save_modal',
|
||||
as: :save_modal
|
||||
post 'destroy', as: :destroy # Destroy multiple entries at once
|
||||
end
|
||||
end
|
||||
resources :experiments, only: [:new, :create, :edit, :update, :archive], defaults: { format: 'json' }
|
||||
|
|
Loading…
Reference in a new issue