Compare commits

...

4 Commits

Author SHA1 Message Date
7b7ba97032 Updated job view for operator 2024-08-27 12:28:46 +02:00
f4068c10bd Updated icon class 2024-08-27 11:31:58 +02:00
4f3342a850 Added new icon helper 2024-08-27 11:24:50 +02:00
1195da6843 Updated routes 2024-08-27 11:14:09 +02:00
8 changed files with 119 additions and 88 deletions

View File

@@ -22,13 +22,13 @@
@apply block w-24; @apply block w-24;
} }
.icon { .icon {
@apply inline text-hsrm-gray size-7 drop-shadow hover:text-opacity-75; @apply inline text-hsrm-gray size-7 drop-shadow;
} }
.icon-disabled { .icon-disabled {
@apply text-opacity-25 hover:text-opacity-25; @apply text-opacity-25 hover:text-opacity-25;
} }
.icon-nohover { .icon-hover {
@apply hover:text-opacity-100; @apply hover:text-opacity-75;
} }
.card-status { .card-status {
@apply uppercase shadow-lg bg-opacity-60 min-h-20 hover:bg-opacity-80; @apply uppercase shadow-lg bg-opacity-60 min-h-20 hover:bg-opacity-80;

View File

@@ -4,10 +4,25 @@ module ApplicationHelper
options[:aria] = true options[:aria] = true
options[:nocomment] = true options[:nocomment] = true
options[:variant] ||= :outline options[:variant] ||= :outline
#options[:class] = options.fetch(:class, nil) # options[:class] = options.fetch(:class, nil)
options[:class] = "size-5" unless options[:class] options[:class] = "size-5" unless options[:class]
path = options.fetch(:path, "icons/#{options[:variant]}/#{name}.svg") path = options.fetch(:path, "icons/#{options[:variant]}/#{name}.svg")
icon = path icon = path
inline_svg_tag(icon, options) inline_svg_tag(icon, options)
end end
def bool_icon(bool)
case bool
when true then "check"
else "x-mark"
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? %>
@@ -60,29 +62,29 @@
<td class="p-2 py-3 text-right"> <td class="p-2 py-3 text-right">
<!-- TODO: move logic to model --> <!-- TODO: move logic to model -->
<% if job.printing? || job.canceled? || job.paid? %> <% if job.printing? || job.canceled? || job.paid? %>
<%= button_to icon(status_icon(:open), class: "icon", title: "Zurück in die Warteschlange"), operator_job_path(job), method: :patch, params: {:job => {status: :open}}, form_class: "inline" %> <%= button_to icon(status_icon(:open), class: "icon icon-hover", title: "Zurück in die Warteschlange"), operator_job_path(job), method: :patch, params: {:job => {status: :open}}, form_class: "inline" %>
<% else %> <% else %>
<%= icon(status_icon(:open), class: "icon icon-disabled", title: "") %> <%= icon(status_icon(:open), class: "icon icon-disabled", title: "") %>
<% end %> <% end %>
<% if job.open? || job.canceled? || job.paid? %> <% if job.open? || job.canceled? || job.paid? %>
<%= button_to icon(status_icon(:printing), class: "icon", title: "Drucken"), operator_job_path(job), method: :patch, params: {:job => {status: :printing}}, form_class: "inline" %> <%= button_to icon(status_icon(:printing), class: "icon icon-hover", title: "Drucken"), operator_job_path(job), method: :patch, params: {:job => {status: :printing}}, form_class: "inline" %>
<% else %> <% else %>
<%= icon(status_icon(:printing), class: "icon icon-disabled", title: "") %> <%= icon(status_icon(:printing), class: "icon icon-disabled", title: "") %>
<% end %> <% end %>
<% if job.printing? || job.paid? %> <% if job.printing? || job.paid? %>
<% job.printing? && turbo_confirm = 'Sind die Pläne gedruckt und die Seitenanzahl und QM korrekt?' %> <% job.printing? && turbo_confirm = 'Sind die Pläne gedruckt und die Seitenanzahl und QM korrekt?' %>
<%= button_to icon(status_icon(:pickup), class: "icon", title: "Pläne sind fertig gedruckt und bereit abgeholt zu werden."), operator_job_path(job), method: :patch, params: {:job => {status: :pickup}}, form: {data: {turbo_confirm: turbo_confirm}}, form_class: "inline" %> <%= button_to icon(status_icon(:pickup), class: "icon icon-hover", title: "Pläne sind fertig gedruckt und bereit abgeholt zu werden."), operator_job_path(job), method: :patch, params: {:job => {status: :pickup}}, form: {data: {turbo_confirm: turbo_confirm}}, form_class: "inline" %>
<% else %> <% else %>
<%= icon(status_icon(:pickup), class: "icon icon-disabled", title: "") %> <%= icon(status_icon(:pickup), class: "icon icon-disabled", title: "") %>
<% end %> <% end %>
<% if job.pickup? || job.printing? %> <% if job.pickup? || job.printing? %>
<% job.printing? && turbo_confirm = 'Sind die Pläne gedruckt und die Seitenanzahl und QM korrekt?' %> <% job.printing? && turbo_confirm = 'Sind die Pläne gedruckt und die Seitenanzahl und QM korrekt?' %>
<%= button_to icon(status_icon(:paid), class: "icon", title: "Bezahlt"), operator_job_path(job), method: :patch, params: {:job => {status: :paid}}, form: {data: {turbo_confirm: turbo_confirm}}, form_class: "inline" %> <%= button_to icon(status_icon(:paid), class: "icon icon-hover", title: "Bezahlt"), operator_job_path(job), method: :patch, params: {:job => {status: :paid}}, form: {data: {turbo_confirm: turbo_confirm}}, form_class: "inline" %>
<% else %> <% else %>
<%= icon(status_icon(:paid), class: "icon icon-disabled ", title: "") %> <%= icon(status_icon(:paid), class: "icon icon-disabled ", title: "") %>
<% end %> <% end %>
<% if job.open? || job.printing? || job.pickup? %> <% if job.open? || job.printing? || job.pickup? %>
<%= button_to icon(status_icon(:canceled), class: "icon text-hsrm-red", title: "Abbrechen"), operator_job_path(job), method: :patch, params: {:job => {status: :canceled}}, form: {data: {turbo_confirm: 'Den Plottauftrag wirklich abbrechen?'}}, form_class: "inline" %> <%= button_to icon(status_icon(:canceled), class: "icon icon-hover text-hsrm-red", title: "Abbrechen"), operator_job_path(job), method: :patch, params: {:job => {status: :canceled}}, form: {data: {turbo_confirm: 'Den Plottauftrag wirklich abbrechen?'}}, form_class: "inline" %>
<% else %> <% else %>
<%= icon(status_icon(:canceled), class: "icon icon-disabled", title: "Kann nicht mehr abgebrochen werden") %> <%= icon(status_icon(:canceled), class: "icon icon-disabled", title: "Kann nicht mehr abgebrochen werden") %>
<% end %> <% end %>

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>

View File

@@ -10,7 +10,7 @@ Rails.application.routes.draw do
resource :email_verification, only: [ :show, :create ] resource :email_verification, only: [ :show, :create ]
resource :password_reset, only: [ :new, :edit, :create, :update ] resource :password_reset, only: [ :new, :edit, :create, :update ]
end end
resources :jobs do resources :jobs, only: [ :index, :new, :create, :destroy ] do
member do member do
patch "cancel" patch "cancel"
end end