Some UX improvements
This commit is contained in:
parent
48c0067076
commit
8c81237501
81 changed files with 791 additions and 151 deletions
|
|
@ -12,7 +12,7 @@ class ElementsController < ApplicationController
|
|||
|
||||
# GET /elements/new
|
||||
def new
|
||||
@element = Element.new
|
||||
@element = Element.new(report_id: params[:report_id])
|
||||
end
|
||||
|
||||
# GET /elements/1/edit
|
||||
|
|
@ -23,13 +23,15 @@ class ElementsController < ApplicationController
|
|||
def create
|
||||
checklist_id = element_params.delete(:checklist_id)
|
||||
checklist = Checklist.find(checklist_id)
|
||||
@element = Element.new(element_params.merge(title: checklist.name))
|
||||
@element = Element.new(element_params)
|
||||
@element.title = checklist.name if @element.title.blank?
|
||||
|
||||
if @element.save
|
||||
checklist.checks.each do |check|
|
||||
@element.success_criteria.create!(title: check.name, description: check.success_criterion, level: check.level)
|
||||
@element.success_criteria.create!(title: check.name, description_html: check.success_criterion_html,
|
||||
level: check.level)
|
||||
end
|
||||
redirect_to [:work, @element.report], notice: 'Element was successfully created.'
|
||||
redirect_to @element.report, notice: 'Element was successfully created.'
|
||||
else
|
||||
render :new, status: :unprocessable_entity
|
||||
end
|
||||
|
|
@ -59,6 +61,6 @@ class ElementsController < ApplicationController
|
|||
|
||||
# Only allow a list of trusted parameters through.
|
||||
def element_params
|
||||
params.require(:element).permit(:report_id, :path, :title, :description, :checklist_id)
|
||||
params.require(:element).permit(:report_id, :path, :title, :description_html, :checklist_id)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue