2016-02-12 23:52:43 +08:00
|
|
|
class ReportsController < ApplicationController
|
2017-01-25 00:06:51 +08:00
|
|
|
include TeamsHelper
|
2017-03-08 21:14:03 +08:00
|
|
|
include ReportActions
|
2016-02-12 23:52:43 +08:00
|
|
|
# Ignore CSRF protection just for PDF generation (because it's
|
|
|
|
# used via target='_blank')
|
2017-03-08 21:14:03 +08:00
|
|
|
protect_from_forgery with: :exception, except: :generate
|
2016-02-12 23:52:43 +08:00
|
|
|
|
2018-04-18 22:47:52 +08:00
|
|
|
BEFORE_ACTION_METHODS = %i(
|
2018-02-22 20:51:22 +08:00
|
|
|
new
|
|
|
|
create
|
|
|
|
edit
|
|
|
|
update
|
|
|
|
generate
|
|
|
|
save_modal
|
|
|
|
project_contents_modal
|
|
|
|
experiment_contents_modal
|
|
|
|
module_contents_modal
|
|
|
|
step_contents_modal
|
|
|
|
result_contents_modal
|
|
|
|
project_contents
|
|
|
|
module_contents
|
|
|
|
step_contents
|
|
|
|
result_contents
|
2018-04-18 22:47:52 +08:00
|
|
|
).freeze
|
|
|
|
|
|
|
|
before_action :load_vars, only: %i(edit update)
|
|
|
|
before_action :load_vars_nested, only: BEFORE_ACTION_METHODS
|
|
|
|
before_action :load_visible_projects, only: %i(index visible_projects)
|
2018-05-16 15:31:19 +08:00
|
|
|
before_action :load_available_repositories,
|
|
|
|
only: %i(new edit available_repositories)
|
2018-04-18 22:47:52 +08:00
|
|
|
|
|
|
|
before_action :check_manage_permissions, only: BEFORE_ACTION_METHODS
|
2016-02-12 23:52:43 +08:00
|
|
|
|
2016-07-21 19:11:15 +08:00
|
|
|
# Index showing all reports of a single project
|
2018-04-18 22:47:52 +08:00
|
|
|
def index; end
|
|
|
|
|
|
|
|
def datatable
|
|
|
|
respond_to do |format|
|
|
|
|
format.json do
|
|
|
|
render json: ::ReportDatatable.new(
|
|
|
|
view_context,
|
|
|
|
current_user,
|
|
|
|
current_team.datatables_reports.visible_by(current_user, current_team)
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
2016-02-12 23:52:43 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
# Report grouped by modules
|
2016-07-21 19:11:15 +08:00
|
|
|
def new
|
2016-02-12 23:52:43 +08:00
|
|
|
@report = nil
|
|
|
|
end
|
|
|
|
|
|
|
|
# Creating new report from the _save modal of the new page
|
|
|
|
def create
|
|
|
|
continue = true
|
|
|
|
begin
|
|
|
|
report_contents = JSON.parse(params.delete(:report_contents))
|
|
|
|
rescue
|
|
|
|
continue = false
|
|
|
|
end
|
|
|
|
|
|
|
|
@report = Report.new(report_params)
|
|
|
|
@report.project = @project
|
|
|
|
@report.user = current_user
|
2018-04-18 22:47:52 +08:00
|
|
|
@report.team = current_team
|
2016-02-12 23:52:43 +08:00
|
|
|
@report.last_modified_by = current_user
|
|
|
|
|
2017-03-08 21:14:03 +08:00
|
|
|
if continue && @report.save_with_contents(report_contents)
|
2016-11-02 16:18:06 +08:00
|
|
|
# record an activity
|
|
|
|
Activity.create(
|
|
|
|
type_of: :create_report,
|
|
|
|
project: @report.project,
|
|
|
|
user: current_user,
|
|
|
|
message: I18n.t(
|
|
|
|
'activities.create_report',
|
|
|
|
user: current_user.full_name,
|
|
|
|
report: @report.name
|
|
|
|
)
|
|
|
|
)
|
2016-02-12 23:52:43 +08:00
|
|
|
respond_to do |format|
|
2017-03-08 21:14:03 +08:00
|
|
|
format.json do
|
2018-04-18 22:47:52 +08:00
|
|
|
render json: { url: reports_path }, status: :ok
|
2017-03-08 21:14:03 +08:00
|
|
|
end
|
2016-02-12 23:52:43 +08:00
|
|
|
end
|
|
|
|
else
|
|
|
|
respond_to do |format|
|
2017-03-08 21:14:03 +08:00
|
|
|
format.json do
|
2016-02-12 23:52:43 +08:00
|
|
|
render json: @report.errors, status: :unprocessable_entity
|
2017-03-08 21:14:03 +08:00
|
|
|
end
|
2016-02-12 23:52:43 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def edit
|
2016-07-21 19:11:15 +08:00
|
|
|
# cleans all the deleted report
|
2017-01-24 23:57:14 +08:00
|
|
|
current_team_switch(@report.project.team)
|
2016-07-21 19:11:15 +08:00
|
|
|
@report.cleanup_report
|
2016-10-11 22:46:30 +08:00
|
|
|
render 'reports/new.html.erb'
|
2016-02-12 23:52:43 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
# Updating existing report from the _save modal of the new page
|
|
|
|
def update
|
|
|
|
continue = true
|
|
|
|
begin
|
|
|
|
report_contents = JSON.parse(params.delete(:report_contents))
|
|
|
|
rescue
|
|
|
|
continue = false
|
|
|
|
end
|
|
|
|
|
|
|
|
@report.last_modified_by = current_user
|
|
|
|
@report.assign_attributes(report_params)
|
|
|
|
|
2017-03-08 21:14:03 +08:00
|
|
|
if continue && @report.save_with_contents(report_contents)
|
2016-11-02 16:18:06 +08:00
|
|
|
# record an activity
|
|
|
|
Activity.create(
|
|
|
|
type_of: :edit_report,
|
|
|
|
project: @report.project,
|
|
|
|
user: current_user,
|
|
|
|
message: I18n.t(
|
|
|
|
'activities.edit_report',
|
|
|
|
user: current_user.full_name,
|
|
|
|
report: @report.name
|
|
|
|
)
|
|
|
|
)
|
2016-02-12 23:52:43 +08:00
|
|
|
respond_to do |format|
|
2017-03-08 21:14:03 +08:00
|
|
|
format.json do
|
2018-04-20 17:57:52 +08:00
|
|
|
render json: { url: reports_path }, status: :ok
|
2017-03-08 21:14:03 +08:00
|
|
|
end
|
2016-02-12 23:52:43 +08:00
|
|
|
end
|
|
|
|
else
|
|
|
|
respond_to do |format|
|
2017-03-08 21:14:03 +08:00
|
|
|
format.json do
|
2016-02-12 23:52:43 +08:00
|
|
|
render json: @report.errors, status: :unprocessable_entity
|
2017-03-08 21:14:03 +08:00
|
|
|
end
|
2016-02-12 23:52:43 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
# Destroy multiple entries action
|
|
|
|
def destroy
|
|
|
|
begin
|
|
|
|
report_ids = JSON.parse(params[:report_ids])
|
|
|
|
rescue
|
|
|
|
render_404
|
|
|
|
end
|
|
|
|
|
|
|
|
report_ids.each do |report_id|
|
|
|
|
report = Report.find_by_id(report_id)
|
2018-04-18 22:47:52 +08:00
|
|
|
next unless report.present? && can_manage_reports?(current_team)
|
2017-03-08 21:14:03 +08:00
|
|
|
# record an activity
|
|
|
|
Activity.create(
|
|
|
|
type_of: :delete_report,
|
|
|
|
project: report.project,
|
|
|
|
user: current_user,
|
|
|
|
message: I18n.t(
|
|
|
|
'activities.delete_report',
|
|
|
|
user: current_user.full_name,
|
|
|
|
report: report.name
|
2016-11-02 16:18:06 +08:00
|
|
|
)
|
2017-03-08 21:14:03 +08:00
|
|
|
)
|
|
|
|
report.destroy
|
2016-02-12 23:52:43 +08:00
|
|
|
end
|
|
|
|
|
2018-04-18 22:47:52 +08:00
|
|
|
redirect_to reports_path
|
2016-02-12 23:52:43 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
# Generation action
|
|
|
|
# Currently, only .PDF is supported
|
|
|
|
def generate
|
2018-05-17 17:21:34 +08:00
|
|
|
content = params[:html]
|
|
|
|
content = I18n.t('projects.reports.new.no_content_for_PDF_html') if content.blank?
|
2016-02-12 23:52:43 +08:00
|
|
|
respond_to do |format|
|
2017-03-08 21:14:03 +08:00
|
|
|
format.pdf do
|
2018-05-17 17:21:34 +08:00
|
|
|
render pdf: 'report', header: { right: '[page] of [topage]' },
|
|
|
|
locals: { content: content },
|
|
|
|
template: 'reports/report.pdf.erb',
|
|
|
|
disable_javascript: true
|
2017-03-08 21:14:03 +08:00
|
|
|
end
|
2016-02-12 23:52:43 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-05-16 15:31:19 +08:00
|
|
|
def save_pdf_to_inventory_item
|
2018-05-17 19:17:19 +08:00
|
|
|
save_pdf_to_inventory_item = ReportActions::SavePdfToInventoryItem.new(
|
2018-05-16 15:31:19 +08:00
|
|
|
current_user, current_team, save_PDF_params
|
|
|
|
)
|
2018-05-17 19:17:19 +08:00
|
|
|
if save_pdf_to_inventory_item.save
|
2018-05-16 15:31:19 +08:00
|
|
|
render json: {
|
|
|
|
message: I18n.t(
|
|
|
|
'projects.reports.new.save_PDF_to_inventory_modal.success_flash'
|
|
|
|
)
|
|
|
|
}, status: :ok
|
|
|
|
else
|
2018-05-17 19:17:19 +08:00
|
|
|
render json: { message: save_pdf_to_inventory_item.error_messages },
|
2018-05-16 15:31:19 +08:00
|
|
|
status: :unprocessable_entity
|
|
|
|
end
|
2018-05-17 17:21:34 +08:00
|
|
|
rescue ReportActions::RepositoryPermissionError => error
|
2018-05-16 15:31:19 +08:00
|
|
|
render json: { message: error },
|
2018-05-17 19:17:19 +08:00
|
|
|
status: :forbidden
|
2018-05-16 15:31:19 +08:00
|
|
|
rescue Exception => error
|
|
|
|
render json: { message: error.message },
|
2018-05-17 19:17:19 +08:00
|
|
|
status: :internal_server_error
|
2018-05-16 15:31:19 +08:00
|
|
|
end
|
|
|
|
|
2016-02-12 23:52:43 +08:00
|
|
|
# Modal for saving the existsing/new report
|
|
|
|
def save_modal
|
|
|
|
# Assume user is updating existing report
|
|
|
|
@report = Report.find_by_id(params[:id])
|
|
|
|
@method = :put
|
|
|
|
|
|
|
|
# Case when saving a new report
|
|
|
|
if @report.blank?
|
|
|
|
@report = Report.new
|
|
|
|
@method = :post
|
|
|
|
@url = project_reports_path(@project, format: :json)
|
|
|
|
else
|
|
|
|
@url = project_report_path(@project, @report, format: :json)
|
|
|
|
end
|
|
|
|
|
2017-03-08 21:14:03 +08:00
|
|
|
render_403 and return unless params.include? :contents
|
|
|
|
|
2016-02-12 23:52:43 +08:00
|
|
|
@report_contents = params[:contents]
|
|
|
|
|
|
|
|
respond_to do |format|
|
2017-03-08 21:14:03 +08:00
|
|
|
format.json do
|
2016-02-12 23:52:43 +08:00
|
|
|
render json: {
|
2017-03-08 21:14:03 +08:00
|
|
|
html: render_to_string(
|
|
|
|
partial: 'reports/new/modal/save.html.erb'
|
|
|
|
)
|
2016-02-12 23:52:43 +08:00
|
|
|
}
|
2017-03-08 21:14:03 +08:00
|
|
|
end
|
2016-02-12 23:52:43 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
# Modal for adding contents into project element
|
|
|
|
def project_contents_modal
|
|
|
|
respond_to do |format|
|
2017-03-08 21:14:03 +08:00
|
|
|
format.json do
|
2016-02-12 23:52:43 +08:00
|
|
|
render json: {
|
2017-03-08 21:14:03 +08:00
|
|
|
html: render_to_string(
|
|
|
|
partial: 'reports/new/modal/project_contents.html.erb',
|
2016-02-12 23:52:43 +08:00
|
|
|
locals: { project: @project }
|
2017-03-08 21:14:03 +08:00
|
|
|
)
|
2016-02-12 23:52:43 +08:00
|
|
|
}
|
2017-03-08 21:14:03 +08:00
|
|
|
end
|
2016-02-12 23:52:43 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-07-29 22:53:50 +08:00
|
|
|
# Experiment for adding contents into experiment element
|
|
|
|
def experiment_contents_modal
|
2017-06-05 18:24:06 +08:00
|
|
|
experiment = Experiment.find_by_id(params[:experiment_id])
|
2016-07-29 22:53:50 +08:00
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
if experiment.blank?
|
|
|
|
format.json do
|
|
|
|
render json: {}, status: :not_found
|
|
|
|
end
|
|
|
|
else
|
|
|
|
format.json do
|
|
|
|
render json: {
|
|
|
|
html: render_to_string(
|
2016-08-05 14:29:49 +08:00
|
|
|
partial: 'reports/new/modal/experiment_contents.html.erb',
|
2016-07-29 22:53:50 +08:00
|
|
|
locals: { project: @project, experiment: experiment }
|
|
|
|
)
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-02-12 23:52:43 +08:00
|
|
|
# Modal for adding contents into module element
|
|
|
|
def module_contents_modal
|
2017-06-05 18:24:06 +08:00
|
|
|
my_module = MyModule.find_by_id(params[:my_module_id])
|
2016-02-12 23:52:43 +08:00
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
if my_module.blank?
|
2016-07-29 22:53:50 +08:00
|
|
|
format.json do
|
2016-02-12 23:52:43 +08:00
|
|
|
render json: {}, status: :not_found
|
2016-07-29 22:53:50 +08:00
|
|
|
end
|
2016-02-12 23:52:43 +08:00
|
|
|
else
|
2016-07-29 22:53:50 +08:00
|
|
|
format.json do
|
2016-02-12 23:52:43 +08:00
|
|
|
render json: {
|
2016-07-29 22:53:50 +08:00
|
|
|
html: render_to_string(
|
2017-03-08 21:14:03 +08:00
|
|
|
partial: 'reports/new/modal/module_contents.html.erb',
|
2016-02-12 23:52:43 +08:00
|
|
|
locals: { project: @project, my_module: my_module }
|
2016-07-29 22:53:50 +08:00
|
|
|
)
|
2016-02-12 23:52:43 +08:00
|
|
|
}
|
2016-07-29 22:53:50 +08:00
|
|
|
end
|
2016-02-12 23:52:43 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-05-18 00:18:57 +08:00
|
|
|
# Modal for adding contents into step element
|
|
|
|
def step_contents_modal
|
2017-06-05 18:24:06 +08:00
|
|
|
step = Step.find_by_id(params[:step_id])
|
2017-05-18 00:18:57 +08:00
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
if step.blank?
|
|
|
|
format.json do
|
|
|
|
render json: {}, status: :not_found
|
|
|
|
end
|
|
|
|
else
|
|
|
|
format.json do
|
|
|
|
render json: {
|
|
|
|
html: render_to_string(
|
|
|
|
partial: 'reports/new/modal/step_contents.html.erb',
|
|
|
|
locals: { project: @project, step: step }
|
|
|
|
)
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
# Modal for adding contents into result element
|
|
|
|
def result_contents_modal
|
2017-06-05 18:24:06 +08:00
|
|
|
result = Result.find_by_id(params[:result_id])
|
2017-05-18 00:18:57 +08:00
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
if result.blank?
|
|
|
|
format.json do
|
|
|
|
render json: {}, status: :not_found
|
|
|
|
end
|
|
|
|
else
|
|
|
|
format.json do
|
|
|
|
render json: {
|
|
|
|
html: render_to_string(
|
|
|
|
partial: 'reports/new/modal/result_contents.html.erb',
|
|
|
|
locals: { project: @project, result: result }
|
|
|
|
)
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-02-12 23:52:43 +08:00
|
|
|
def project_contents
|
|
|
|
respond_to do |format|
|
|
|
|
elements = generate_project_contents_json
|
|
|
|
|
|
|
|
if elements_empty? elements
|
|
|
|
format.json { render json: {}, status: :no_content }
|
|
|
|
else
|
|
|
|
format.json {
|
|
|
|
render json: {
|
|
|
|
status: :ok,
|
|
|
|
elements: elements
|
|
|
|
}
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-08-02 15:05:11 +08:00
|
|
|
def experiment_contents
|
2016-08-03 15:39:34 +08:00
|
|
|
experiment = Experiment.find_by_id(params[:id])
|
2016-08-05 14:29:49 +08:00
|
|
|
modules = (params[:modules].select { |_, p| p == "1" })
|
|
|
|
.keys
|
|
|
|
.collect(&:to_i)
|
2016-08-03 15:39:34 +08:00
|
|
|
|
2016-08-02 15:05:11 +08:00
|
|
|
respond_to do |format|
|
2016-08-03 15:39:34 +08:00
|
|
|
if experiment.blank?
|
|
|
|
format.json { render json: {}, status: :not_found }
|
|
|
|
elsif modules.blank?
|
|
|
|
format.json { render json: {}, status: :no_content }
|
|
|
|
else
|
|
|
|
elements = generate_experiment_contents_json(experiment, modules)
|
|
|
|
end
|
2016-08-02 15:05:11 +08:00
|
|
|
|
|
|
|
if elements_empty? elements
|
|
|
|
format.json { render json: {}, status: :no_content }
|
|
|
|
else
|
2016-08-05 14:29:49 +08:00
|
|
|
format.json do
|
2016-08-02 15:05:11 +08:00
|
|
|
render json: {
|
|
|
|
status: :ok,
|
|
|
|
elements: elements
|
|
|
|
}
|
2016-08-05 14:29:49 +08:00
|
|
|
end
|
2016-08-02 15:05:11 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-02-12 23:52:43 +08:00
|
|
|
def module_contents
|
|
|
|
my_module = MyModule.find_by_id(params[:id])
|
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
if my_module.blank?
|
|
|
|
format.json { render json: {}, status: :not_found }
|
|
|
|
else
|
|
|
|
elements = generate_module_contents_json(my_module)
|
|
|
|
|
|
|
|
if elements_empty? elements
|
|
|
|
format.json { render json: {}, status: :no_content }
|
|
|
|
else
|
2017-03-08 21:14:03 +08:00
|
|
|
format.json do
|
2016-02-12 23:52:43 +08:00
|
|
|
render json: {
|
|
|
|
status: :ok,
|
|
|
|
elements: elements
|
|
|
|
}
|
2017-03-08 21:14:03 +08:00
|
|
|
end
|
2016-02-12 23:52:43 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-05-18 00:18:57 +08:00
|
|
|
def step_contents
|
|
|
|
step = Step.find_by_id(params[:id])
|
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
if step.blank?
|
|
|
|
format.json { render json: {}, status: :not_found }
|
|
|
|
else
|
|
|
|
elements = generate_step_contents_json(step)
|
|
|
|
|
|
|
|
if elements_empty? elements
|
|
|
|
format.json { render json: {}, status: :no_content }
|
|
|
|
else
|
|
|
|
format.json {
|
|
|
|
render json: {
|
|
|
|
status: :ok,
|
|
|
|
elements: elements
|
|
|
|
}
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def result_contents
|
|
|
|
result = Result.find_by_id(params[:id])
|
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
if result.blank?
|
|
|
|
format.json { render json: {}, status: :not_found }
|
|
|
|
else
|
|
|
|
elements = generate_result_contents_json(result)
|
|
|
|
|
|
|
|
if elements_empty? elements
|
|
|
|
format.json { render json: {}, status: :no_content }
|
|
|
|
else
|
|
|
|
format.json {
|
|
|
|
render json: {
|
|
|
|
status: :ok,
|
|
|
|
elements: elements
|
|
|
|
}
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-04-18 22:47:52 +08:00
|
|
|
def visible_projects
|
|
|
|
render json: { projects: @visible_projects }, status: :ok
|
|
|
|
end
|
|
|
|
|
2018-05-16 15:31:19 +08:00
|
|
|
def available_repositories
|
|
|
|
render json: { results: @available_repositories }, status: :ok
|
|
|
|
end
|
|
|
|
|
2016-02-12 23:52:43 +08:00
|
|
|
private
|
|
|
|
|
2018-05-03 20:24:23 +08:00
|
|
|
include StringUtility
|
2018-04-18 22:47:52 +08:00
|
|
|
VisibleProject = Struct.new(:path, :name)
|
2018-05-16 15:31:19 +08:00
|
|
|
AvailableRepository = Struct.new(:id, :name)
|
2018-04-18 22:47:52 +08:00
|
|
|
|
2016-02-12 23:52:43 +08:00
|
|
|
def load_vars
|
|
|
|
@report = Report.find_by_id(params[:id])
|
2017-03-08 21:14:03 +08:00
|
|
|
render_404 unless @report
|
2016-02-12 23:52:43 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
def load_vars_nested
|
|
|
|
@project = Project.find_by_id(params[:project_id])
|
2017-03-08 21:14:03 +08:00
|
|
|
render_404 unless @project
|
2016-02-12 23:52:43 +08:00
|
|
|
end
|
|
|
|
|
2018-01-22 23:25:53 +08:00
|
|
|
def check_manage_permissions
|
2018-04-18 22:47:52 +08:00
|
|
|
render_403 unless can_manage_reports?(@project.team)
|
|
|
|
end
|
|
|
|
|
|
|
|
def load_visible_projects
|
|
|
|
render_404 unless current_team
|
2018-05-21 20:45:18 +08:00
|
|
|
projects = current_team.projects.visible_from_user_by_name(
|
|
|
|
current_user, current_team, search_params[:q]
|
|
|
|
).limit(Constants::SEARCH_LIMIT).select(:id, :name)
|
2018-04-18 22:47:52 +08:00
|
|
|
@visible_projects = projects.collect do |project|
|
2018-05-03 20:24:23 +08:00
|
|
|
VisibleProject.new(new_project_reports_path(project),
|
2018-05-18 20:12:12 +08:00
|
|
|
ellipsize(project.name, 50, 40))
|
2018-04-18 22:47:52 +08:00
|
|
|
end
|
2016-02-12 23:52:43 +08:00
|
|
|
end
|
|
|
|
|
2018-05-16 15:31:19 +08:00
|
|
|
def load_available_repositories
|
|
|
|
repositories = current_team.repositories
|
|
|
|
.name_like(search_params[:q])
|
2018-05-17 17:21:34 +08:00
|
|
|
.limit(Constants::SEARCH_LIMIT)
|
2018-05-16 15:31:19 +08:00
|
|
|
.select(:id, :name)
|
|
|
|
@available_repositories = repositories.collect do |repository|
|
|
|
|
AvailableRepository.new(repository.id,
|
2018-05-17 17:21:34 +08:00
|
|
|
ellipsize(repository.name, 75, 50))
|
2018-05-16 15:31:19 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-02-12 23:52:43 +08:00
|
|
|
def report_params
|
2017-03-08 21:14:03 +08:00
|
|
|
params.require(:report)
|
|
|
|
.permit(:name, :description, :grouped_by, :report_contents)
|
2016-02-12 23:52:43 +08:00
|
|
|
end
|
2018-04-18 22:47:52 +08:00
|
|
|
|
|
|
|
def search_params
|
|
|
|
params.permit(:q)
|
|
|
|
end
|
2018-05-16 15:31:19 +08:00
|
|
|
|
|
|
|
def save_PDF_params
|
|
|
|
params.permit(:repository_id,
|
|
|
|
:respository_column_id,
|
|
|
|
:repository_item_id,
|
|
|
|
:html)
|
|
|
|
end
|
2016-07-21 19:11:15 +08:00
|
|
|
end
|