From beab461e6efd0ea08c16b9ad027b0ca735bfa5c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20B=C3=B6hm?= Date: Sun, 8 Sep 2024 00:07:20 +0200 Subject: [PATCH] Fixed show and edit action for operator/jobs --- app/controllers/operator/jobs_controller.rb | 4 +- app/views/operator/jobs/_form.html.erb | 60 +++++++++++---------- app/views/operator/jobs/edit.html.erb | 10 ++-- 3 files changed, 38 insertions(+), 36 deletions(-) diff --git a/app/controllers/operator/jobs_controller.rb b/app/controllers/operator/jobs_controller.rb index 5a5ffc8..5cd820c 100644 --- a/app/controllers/operator/jobs_controller.rb +++ b/app/controllers/operator/jobs_controller.rb @@ -44,7 +44,7 @@ class Operator::JobsController < ApplicationController respond_to do |format| if @job.save broadcast_update_job - format.turbo_stream + format.turbo_stream unless request.referrer.include? "edit" format.html { redirect_to operator_jobs_url, notice: "Job was successfully updated." } else flash[:alert] = "Job was not updated." @@ -115,7 +115,7 @@ class Operator::JobsController < ApplicationController # Only allow a list of trusted parameters through. def job_params - params.require(:job).permit(:operator_id, :costumer_id, :operator_firstname, :operator_lastname, :costumer_firstname, :costumer_lastname, :status) + params.require(:job).permit(:operator_id, :costumer_id, :operator_firstname, :operator_lastname, :costumer_firstname, :costumer_lastname, :status, :privacy_policy_accepted, :intern, :cost_center, :number_of_plans_a0, :number_of_plans_a1, :number_of_plans_a2, :number_of_plans_a3, :costum_qm_plan) end # FIXME: Move broadcast to model though i don't think view logic belongs in the model diff --git a/app/views/operator/jobs/_form.html.erb b/app/views/operator/jobs/_form.html.erb index 1f1b26a..8bd42d0 100644 --- a/app/views/operator/jobs/_form.html.erb +++ b/app/views/operator/jobs/_form.html.erb @@ -1,6 +1,6 @@ -<%= form_with(model: job, class: "contents") do |form| %> +<%= form_with(model: job, url: operator_job_path(job), method: "patch", class: "contents") do |form| %> <% if job.errors.any? %> -
+

<%= pluralize(job.errors.count, "error") %> prohibited this job from being saved:

    @@ -18,34 +18,38 @@ <%= form.label :costumer_lastname, 'Nachname' %> <%= form.text_field :costumer_lastname, class: "block shadow-lg rounded-md border border-hsrm-gray outline-none px-3 py-2 mt-2 w-full" %>
- - - - - - - - - - - - - - - - - - - - - - - - -
+
+ <%= form.label :intern %> + <%= form.check_box :intern, class: "block mt-2 h-5 w-5" %> +
+
+ <%= form.label :cost_center %> + <%= form.text_field :cost_center, class: "block shadow-lg rounded-md border border-hsrm-gray outline-none px-3 py-2 mt-2 w-full" %> +
+
+ <%= form.label :number_of_plans_a0 %> + <%= form.number_field :number_of_plans_a0, class: "block shadow-lg rounded-md border border-hsrm-gray outline-none px-3 py-2 mt-2 w-full" %> +
+
+ <%= form.label :number_of_plans_a1 %> + <%= form.number_field :number_of_plans_a1, class: "block shadow-lg rounded-md border border-hsrm-gray outline-none px-3 py-2 mt-2 w-full" %> +
+
+ <%= form.label :number_of_plans_a2 %> + <%= form.number_field :number_of_plans_a2, class: "block shadow-lg rounded-md border border-hsrm-gray outline-none px-3 py-2 mt-2 w-full" %> +
+
+ <%= form.label :number_of_plans_a3 %> + <%= form.number_field :number_of_plans_a3, class: "block shadow-lg rounded-md border border-hsrm-gray outline-none px-3 py-2 mt-2 w-full" %> +
+
+ <%= form.label :costum_qm_plan %> + <%= form.number_field :costum_qm_plan, in: 0..20.0, step: 0.01 ,class: "block shadow-lg rounded-md border border-hsrm-gray outline-none px-3 py-2 mt-2 w-full" %> +
+
<%= form.check_box :privacy_policy_accepted, class: "mt-2 h-5 w-5" %> <%= form.label :privacy_policy_accepted, "Datenschutzerklärung akzeptiert", class: "p-2" %>
diff --git a/app/views/operator/jobs/edit.html.erb b/app/views/operator/jobs/edit.html.erb index 34c8329..88e6f9a 100644 --- a/app/views/operator/jobs/edit.html.erb +++ b/app/views/operator/jobs/edit.html.erb @@ -1,8 +1,6 @@ -
-

Editing job

- +
+

Editing job

<%= render "form", job: @job %> - - <%= link_to "Show this job", @job, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %> - <%= link_to "Back to jobs", jobs_path, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %> + <%= link_to "Show this job", operator_job_path(@job), class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %> + <%= link_to "Back to jobs", operator_jobs_path, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %>