Gui improvements and ideas
This commit is contained in:
parent
3f4c7d17bf
commit
2ae0b55e42
54 changed files with 639 additions and 237 deletions
|
|
@ -24,7 +24,7 @@ class ChecklistEntriesController < ApplicationController
|
|||
@checklist_entry = ChecklistEntry.new(checklist_entry_params)
|
||||
|
||||
if @checklist_entry.save
|
||||
redirect_to @checklist_entry, notice: 'Checklist entry was successfully created.'
|
||||
redirect_to @checklist_entry.checklist, notice: 'Checklist entry was successfully created.'
|
||||
else
|
||||
render :new, status: :unprocessable_entity
|
||||
end
|
||||
|
|
@ -33,7 +33,8 @@ class ChecklistEntriesController < ApplicationController
|
|||
# PATCH/PUT /checklist_entries/1
|
||||
def update
|
||||
if @checklist_entry.update(checklist_entry_params)
|
||||
redirect_to @checklist_entry, notice: 'Checklist entry was successfully updated.', status: :see_other
|
||||
redirect_to @checklist_entry.checklist, notice: 'Checklist entry was successfully updated.',
|
||||
status: :see_other
|
||||
else
|
||||
render :edit, status: :unprocessable_entity
|
||||
end
|
||||
|
|
@ -42,7 +43,12 @@ class ChecklistEntriesController < ApplicationController
|
|||
# DELETE /checklist_entries/1
|
||||
def destroy
|
||||
@checklist_entry.destroy!
|
||||
redirect_to checklist_entries_url, notice: 'Checklist entry was successfully destroyed.', status: :see_other
|
||||
respond_to do |format|
|
||||
format.html do
|
||||
redirect_to checklist_entries_url, notice: 'Checklist entry was successfully destroyed.', status: :see_other
|
||||
end
|
||||
format.turbo_stream
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ class ChecklistsController < ApplicationController
|
|||
@checklist = Checklist.new(checklist_params)
|
||||
|
||||
if @checklist.save
|
||||
redirect_to @checklist, notice: 'Checklist was successfully created.'
|
||||
redirect_to [:edit, @checklist], notice: 'Checklist was successfully created.'
|
||||
else
|
||||
render :new, status: :unprocessable_entity
|
||||
end
|
||||
|
|
|
|||
|
|
@ -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