Set name from current user to new jobs in form

This commit is contained in:
2024-09-05 12:30:13 +02:00
parent 68ced40cbf
commit 26ccaa9bb4
3 changed files with 7 additions and 3 deletions

View File

@@ -7,7 +7,7 @@ class JobsController < ApplicationController
# GET /jobs/new # GET /jobs/new
def new def new
@job = Job.new @job = Job.new(costumer_firstname: current_user.firstname, costumer_lastname: current_user.lastname)
end end
# POST /jobs or /jobs.json # POST /jobs or /jobs.json

View File

@@ -26,6 +26,10 @@ module ApplicationHelper
controller.class.name.split("::").first=="Admin" controller.class.name.split("::").first=="Admin"
end end
def is_admin_or_operator?
current_user.admin? || current_user.operator?
end
def profile? def profile?
controller_name=="profiles" controller_name=="profiles"
end end

View File

@@ -12,11 +12,11 @@
<% end %> <% end %>
<div class="my-5"> <div class="my-5">
<%= form.label :costumer_firstname, 'Vorname' %> <%= form.label :costumer_firstname, 'Vorname' %>
<%= form.text_field :costumer_firstname, class: "block shadow-lg rounded-md border border-hsrm-gray outline-none px-3 py-2 mt-2 w-full" %> <%= form.text_field :costumer_firstname, disabled: !is_admin_or_operator? ,class: "block shadow-lg rounded-md border border-hsrm-gray outline-none px-3 py-2 mt-2 w-full" %>
</div> </div>
<div class="my-5"> <div class="my-5">
<%= form.label :costumer_lastname, 'Nachname' %> <%= 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.text_field :costumer_lastname, disabled: !is_admin_or_operator? ,class: "block shadow-lg rounded-md border border-hsrm-gray outline-none px-3 py-2 mt-2 w-full" %>
</div> </div>
<div> <div>
<%= form.label :pdf, "Plan auswählen (PDF-Format)" %> <%= form.label :pdf, "Plan auswählen (PDF-Format)" %>