Gui improvements and ideas
This commit is contained in:
parent
3f4c7d17bf
commit
2ae0b55e42
54 changed files with 639 additions and 237 deletions
|
|
@ -8,6 +8,29 @@ class ReportsController < ApplicationController
|
|||
|
||||
# GET /reports/1
|
||||
def show
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.pdf
|
||||
format.xlsx do
|
||||
response.headers['Content-Disposition'] = %(attachment; filename="#{filename(@report, extension: 'xlsx')}")
|
||||
render
|
||||
end
|
||||
format.docx do
|
||||
template = Sablon.template(Rails.root.join('lib/templates/docx/report.docx'))
|
||||
context = {
|
||||
person: OpenStruct.new(first_name: @report.name),
|
||||
skills: [],
|
||||
education: [],
|
||||
career: [],
|
||||
referees: []
|
||||
}
|
||||
|
||||
template.render_to_file(Rails.root.join('tmp/output.docx'), context)
|
||||
send_file Rails.root.join('tmp/output.docx'),
|
||||
filename: filename(@report, extension: 'docx'),
|
||||
type: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# GET /reports/new
|
||||
|
|
@ -60,4 +83,8 @@ class ReportsController < ApplicationController
|
|||
def report_params
|
||||
params.require(:report).permit(:name, :comment_html)
|
||||
end
|
||||
|
||||
def filename(report, extension: 'html')
|
||||
"#{report.name}-#{Time.current.strftime('%Y%m%d%H%M')}.#{extension}"
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue