start of iteration 2
Some checks failed
/ Run tests (push) Failing after 1m19s
/ Run system tests (push) Failing after 1m18s
/ Build, push and deploy image (push) Has been skipped

This commit is contained in:
david 2024-10-31 23:13:18 +01:00
parent 9fb87a74ce
commit 729ed13521
75 changed files with 705 additions and 170 deletions

View file

@ -1,6 +1,7 @@
# frozen_string_literal: true
class ElementsController < ApplicationController
before_action :set_page, only: %i[index new create]
before_action :set_element, only: %i[show edit update destroy]
# GET /elements
@ -13,7 +14,8 @@ class ElementsController < ApplicationController
# GET /elements/new
def new
@element = Element.new(report_id: params[:report_id])
@element = Element.new(page_id: params[:page_id])
@element.page = @page
end
# GET /elements/1/edit
@ -21,16 +23,20 @@ class ElementsController < ApplicationController
# POST /elements
def create
checklist_id = element_params.delete(:checklist_id)
checklist = Checklist.find(checklist_id)
# checklist_id = element_params.delete(:checklist_id)
# checklist = Checklist.find(checklist_id)
@element = Element.new(element_params)
@element.title = checklist.name if @element.title.blank?
@element.page = @page
# @element.title = checklist.name if @element.title.blank?
if @element.save
checklist.checks.each do |check|
@element.success_criteria.create!(title: check.t_name, description_html: check.t_criterion,
level: check.level)
end
# checklist.checks.each do |check|
# @element.success_criteria.create!(
# check:,
# title: check.t_name,
# level: check.conformity_level,
# quick_criterion: check.t_quick_criterion)
# end
respond_to do |format|
format.html { redirect_to @element.report, notice: "Element was successfully created." }
format.turbo_stream
@ -62,8 +68,12 @@ class ElementsController < ApplicationController
@element = Element.find(params[:id])
end
def set_page
@page = Page.find(params[:page_id])
end
# Only allow a list of trusted parameters through.
def element_params
params.require(:element).permit(:report_id, :path, :title, :description_html, :checklist_id)
params.require(:element).permit(:page_id, :title, :description)
end
end