a11yist/app/controllers/checks_controller.rb

125 lines
4.2 KiB
Ruby
Raw Normal View History

2024-09-05 22:54:38 +02:00
# frozen_string_literal: true
class ChecksController < ApplicationController
2024-09-22 21:57:05 +02:00
include BackofficeMenu
before_action :set_check, only: %i[show edit update destroy]
# GET /checks or /checks.json
def index
2024-09-12 00:50:38 +02:00
@pagy, @checks = pagy(Check.filter_by(filter_params).order(:conformity_level))
end
# GET /checks/1 or /checks/1.json
2024-09-05 22:54:38 +02:00
def show; end
# GET /checks/new
def new
@check = Check.new
end
# GET /checks/1/edit
2024-09-05 22:54:38 +02:00
def edit; end
# POST /checks or /checks.json
def create
@check = Check.new(check_params)
respond_to do |format|
if @check.save
format.html do
redirect_to check_url(@check),
2024-09-05 22:54:38 +02:00
notice: t("scaffold.model_created_successfully", model: @check.model_name.human)
end
format.json { render :show, status: :created, location: @check }
else
2024-09-05 22:54:38 +02:00
flash[:alert] = t("there_were_errors", count: @check.errors.size)
format.html { render :new, status: :unprocessable_entity }
format.json { render json: @check.errors, status: :unprocessable_entity }
end
end
end
# PATCH/PUT /checks/1 or /checks/1.json
def update
respond_to do |format|
if @check.update(check_params)
format.html do
redirect_to check_url(@check),
2024-09-05 22:54:38 +02:00
notice: t("scaffold.model_updated_successfully", model: @check.model_name.human)
end
format.json { render :show, status: :ok, location: @check }
else
format.html { render :edit, status: :unprocessable_entity }
format.json { render json: @check.errors, status: :unprocessable_entity }
end
end
end
# DELETE /checks/1 or /checks/1.json
def destroy
@check.destroy!
respond_to do |format|
format.html do
2024-09-05 22:54:38 +02:00
redirect_to checks_url, notice: t("scaffold.model_destroyed_successfully", model: @check.model_name.human)
end
format.json { head :no_content }
end
end
2024-07-21 00:33:38 +02:00
def filter_params
2024-09-12 00:50:38 +02:00
@filter_params ||= params.permit(filter: [ :s, priority: [], conformity_level: [], standard_ids: [], principle_id: [] ])[:filter] || {}
2024-07-21 00:33:38 +02:00
end
private
# Use callbacks to share common setup or constraints between actions.
def set_check
@check = Check.find(params[:id])
end
# Only allow a list of trusted parameters through.
def check_params
2024-09-05 22:54:38 +02:00
params.require(:check).permit(:principle_id,
:number,
:name_de,
:name_en,
:standard_id,
:visual,
:auditory,
:physical,
:cognitive,
:applicable_to_app,
:applicable_to_web,
:external_number,
2024-10-25 19:25:01 +02:00
:external_url,
2024-09-05 22:54:38 +02:00
:conformity_level,
:conformity_notice_de,
:conformity_notice_en,
:priority,
:quick_criterion_de,
:quick_criterion_en,
:quick_fail_de,
:quick_fail_en,
:quick_fix_de,
:quick_fix_en,
:criterion_de,
:criterion_en,
:criterion_details_de,
:criterion_details_en,
:example_de,
:example_en,
:exemption_details_de,
:exemption_details_en,
:standard_text_de,
:standard_text_en,
:test_instructions,
:powerpoint_text_de,
:powerpoint_text_en,
:comment,
link_ids: [],
standard_ids: [])
end
end