Updated job view for operator

This commit is contained in:
2024-08-27 12:28:46 +02:00
parent f4068c10bd
commit 7b7ba97032
6 changed files with 102 additions and 78 deletions

View File

@@ -17,4 +17,12 @@ module ApplicationHelper
else "x-mark" else "x-mark"
end end
end end
def operator?
controller.class.name.split("::").first=="Operator"
end
def admin?
controller.class.name.split("::").first=="Admin"
end
end end

View File

@@ -34,4 +34,8 @@ class User < ApplicationRecord
after_update if: :password_digest_previously_changed? do after_update if: :password_digest_previously_changed? do
sessions.where.not(id: Current.session).delete_all sessions.where.not(id: Current.session).delete_all
end end
def name
[ firstname, " ", lastname ].join
end
end end

View File

@@ -1,15 +1,15 @@
<header class="container flex items-center justify-between px-4 py-6 mx-auto border-b-2 border-gray-300"> <header class="container flex items-center justify-between px-4 py-6 mx-auto border-b-2 border-gray-300">
<a href="/" class="text-4xl font-bold text-hsrm-gray">Plottservice Fachbereich AB</a> <a href="/" class="text-4xl font-bold text-hsrm-gray">Plottservice Fachbereich AB</a>
<% if user_signed_in? && current_user.admin? || current_user.operator? %> <% if user_signed_in? && (current_user.admin? || current_user.operator?) %>
<nav> <nav>
<ul class="flex justify-center font-semibold items-color"> <ul class="flex justify-center space-x-2 font-semibold items-color">
<li class="relative"> <li class="relative">
<button class="px-4 py-2 cursor-default hover:text-hsrm-red"> <button class="px-4 py-2 cursor-default hover:text-hsrm-red border-b-4 <%= admin? && 'border-hsrm-red-light' %>">
<%= link_to_if current_user.admin?, "Admin", admin_dashboard_path %> <%= link_to_if current_user.admin?, "Admin", admin_dashboard_path %>
</button> </button>
</li> </li>
<li class="relative"> <li class="relative">
<button class="px-4 py-2 cursor-default hover:text-hsrm-red"> <button class="px-4 py-2 cursor-default hover:text-hsrm-red border-b-4 <%= operator? && 'border-hsrm-red-light' %>">
<%= link_to 'Operator', operator_jobs_path %> <%= link_to 'Operator', operator_jobs_path %>
</button> </button>
</li> </li>

View File

@@ -1,64 +1,76 @@
<div id="<%= dom_id job %>"> <div id="<%= dom_id job %>" class="flex flex-row space-x-4 shadow">
<iframe src=<%= url_for(@job.pdf) %> <div>
width="700" height="780" style="border: none;"></iframe> <iframe src=<%= url_for(@job.pdf) %> width="400" height="600" style="border: solid 1px;"></iframe>
<p class="my-5"> </div>
<strong class="block font-medium mb-1">Operator:</strong> <div>
<%= job.operator_id %> <p class="my-3">
</p> <strong class="mb-1 font-medium">Operator ID:</strong>
<p class="my-5"> <%= job.operator_id %>
<strong class="block font-medium mb-1">Costumer:</strong> <% if job.operator %>
<%= job.costumer_id %> (<%= job.operator.name %>)
</p> <% else %>
<p class="my-5"> -
<strong class="block font-medium mb-1">Operator firstname:</strong> <% end %>
<%= job.operator_firstname %> </p>
</p> <p class="my-3">
<p class="my-5"> <strong class="mb-1 font-medium">Costumer ID:</strong>
<strong class="block font-medium mb-1">Operator lastname:</strong> <%= job.costumer_id %>
<%= job.operator_lastname %> <% if job.costumer %>
</p> (<%= job.costumer.name %>)
<p class="my-5"> <% else %>
<strong class="block font-medium mb-1">Costumer firstname:</strong> -
<%= job.costumer_firstname %> <% end %>
</p> </p>
<p class="my-5"> <p class="my-3">
<strong class="block font-medium mb-1">Costumer lastname:</strong> <strong class="mb-1 font-medium">Operator:</strong>
<%= job.costumer_lastname %> <%= "#{job.operator_firstname} #{job.operator_lastname}" %>
</p> </p>
<p class="my-5"> <p class="my-3">
<strong class="block font-medium mb-1">Paid:</strong> <strong class="mb-1 font-medium">Costumer:</strong>
<%= job.paid %> <%= "#{job.costumer_firstname} #{job.costumer_lastname}" %>
</p> </p>
<p class="my-5"> <p class="my-3">
<strong class="block font-medium mb-1">Printed at:</strong> <strong class="mb-1 font-medium">Paid:</strong>
<%= job.printed_at %> <%= icon bool_icon(job.paid), class: "icon" %>
</p> </p>
<p class="my-5"> <p class="my-3">
<strong class="block font-medium mb-1">Intern:</strong> <strong class="mb-1 font-medium">Paid at:</strong>
<%= job.intern %> <%= job.paid_at %>
</p> </p>
<p class="my-5"> <p class="my-3">
<strong class="block font-medium mb-1">Cost center:</strong> <strong class="mb-1 font-medium">Printed:</strong>
<%= job.cost_center %> <%= icon bool_icon(job.printed), class: "icon" %>
</p> </p>
<p class="my-5"> <p class="my-3">
<strong class="block font-medium mb-1">Number of plans a0:</strong> <strong class="mb-1 font-medium">Printed at:</strong>
<%= job.number_of_plans_a0 %> <%= job.printed_at %>
</p> </p>
<p class="my-5"> <p class="my-3">
<strong class="block font-medium mb-1">Number of plans a1:</strong> <strong class="mb-1 font-medium">Intern:</strong>
<%= job.number_of_plans_a1 %> <%= icon bool_icon(job.intern), class: "icon" %>
</p> </p>
<p class="my-5"> <p class="my-3">
<strong class="block font-medium mb-1">Number of plans a2:</strong> <strong class="mb-1 font-medium">Cost center:</strong>
<%= job.number_of_plans_a2 %> <%= job.cost_center %>
</p> </p>
<p class="my-5"> <p class="my-3">
<strong class="block font-medium mb-1">Number of plans a3:</strong> <strong class="block mb-1 font-medium">Plans:
<%= job.number_of_plans_a3 %> <table class="text-center">
</p> <tr class="p-2 bg-gray-300">
<p class="my-5"> <th class="p-2">a0</th>
<strong class="block font-medium mb-1">Costum qm plan:</strong> <th class="p-2">a1</th>
<%= job.costum_qm_plan %> <th class="p-2">a2</th>
</p> <th class="p-2">a3</th>
</div> <th class="p-2">costum</td>
</tr>
<tr>
<td><%= job.number_of_plans_a0 %></td>
<td><%= job.number_of_plans_a1 %></td>
<td><%= job.number_of_plans_a2 %></td>
<td><%= job.number_of_plans_a3 %></td>
<td><%= job.costum_qm_plan %> qm</td>
</tr>
</table>
</p>
</div>
</div>

View File

@@ -1,8 +1,10 @@
<tr id="<%= dom_id job %>" class="bg-status-<%= job.status %>-light odd:bg-opacity-20 even:bg-opacity-10 text-hsrm-gray whitespace-nowrap hover:bg-opacity-30"> <tr id="<%= dom_id job %>" class="bg-status-<%= job.status %>-light odd:bg-opacity-20 even:bg-opacity-10 text-hsrm-gray whitespace-nowrap hover:bg-opacity-30">
<td class="p-2 py-3 text-center"> <td class="p-2 py-3 text-center">
<span class="badge badge-xl text-status-<%= job.status %> bg-status-<%= job.status %>-light"> <%= link_to operator_job_path(job) do %>
<%= job.id %> <span class="badge badge-xl text-status-<%= job.status %> bg-status-<%= job.status %>-light">
</span> <%= job.id %>
</span>
<% end %>
</td> </td>
<td class="p-2 py-3 text-center"> <td class="p-2 py-3 text-center">
<% if job.pdf.attached? %> <% if job.pdf.attached? %>

View File

@@ -1,15 +1,13 @@
<div class="mx-auto md:w-2/3 w-full flex"> <div class="flex w-full mx-auto md:w-2/3">
<div class="mx-auto"> <div class="mx-auto">
<% if notice.present? %> <% if notice.present? %>
<p class="py-2 px-3 bg-green-50 mb-5 text-green-500 font-medium rounded-lg inline-block" id="notice"><%= notice %></p> <p class="inline-block px-3 py-2 mb-5 font-medium text-green-500 rounded-lg bg-green-50" id="notice"><%= notice %></p>
<% end %> <% end %>
<%= render @job %> <%= render @job %>
<%= link_to "Edit this job", edit_operator_job_path(@job), class: "mt-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %>
<%= link_to "Edit this job", edit_job_path(@job), class: "mt-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" %>
<%= link_to "Back to jobs", jobs_path, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %>
<div class="inline-block ml-2"> <div class="inline-block ml-2">
<%= button_to "Destroy this job", @job, method: :delete, class: "mt-2 rounded-lg py-3 px-5 bg-gray-100 font-medium" %> <%= button_to "Destroy this job", operator_job_path(@job), method: :delete, class: "mt-2 rounded-lg py-3 px-5 bg-gray-100 font-medium" %>
</div> </div>
</div> </div>
</div> </div>