Implemented status changes operator index

This commit is contained in:
2024-08-13 23:37:31 +02:00
parent 8732f07dd6
commit 3be019b58b
7 changed files with 42 additions and 42 deletions

View File

@@ -4,7 +4,7 @@ class JobsController < ApplicationController
@jobs = Job.currently_working_on @jobs = Job.currently_working_on
end end
# GET /jobs/new # GET /jobs/new
def new def new
@job = Job.new @job = Job.new
end end

View File

@@ -42,7 +42,6 @@ class Operator::JobsController < ApplicationController
def update def update
respond_to do |format| respond_to do |format|
if @job.update(job_params) if @job.update(job_params)
broadcast_update_job broadcast_update_job
format.html { redirect_to operator_jobs_url, notice: "Job was successfully updated." } format.html { redirect_to operator_jobs_url, notice: "Job was successfully updated." }
else else
@@ -51,20 +50,6 @@ class Operator::JobsController < ApplicationController
end end
end end
def cancel
if @job.canceled!
flash[:notice] = "Job successfully canceled"
else
flash[:alert] = "Job could not be canceled"
end
respond_to do |format|
broadcast_update_job
format.turbo_stream
format.html { redirect_to operator_jobs_url }
end
end
# DELETE /jobs/1 or /jobs/1.json # DELETE /jobs/1 or /jobs/1.json
def destroy def destroy
@job.destroy! @job.destroy!
@@ -84,7 +69,7 @@ class Operator::JobsController < ApplicationController
respond_to do |format| respond_to do |format|
broadcast_update_job broadcast_update_job
format.html { redirect_to operator_jobs_url, notice: "Job was successfully updated." } format.html { redirect_to operator_jobs_url }
end end
end end
@@ -114,6 +99,6 @@ class Operator::JobsController < ApplicationController
# Only allow a list of trusted parameters through. # Only allow a list of trusted parameters through.
def job_params def job_params
params.require(:job).permit(:operator_id, :costumer_id, :operator_firstname, :operator_lastname, :costumer_firstname, :costumer_lastname) params.require(:job).permit(:operator_id, :costumer_id, :operator_firstname, :operator_lastname, :costumer_firstname, :costumer_lastname, :status)
end end
end end

View File

@@ -79,7 +79,7 @@ class Job < ApplicationRecord
end end
def able_to_cancel? def able_to_cancel?
open? open? || printing?
# TODO: different check for operator and admin # TODO: different check for operator and admin
end end

View File

@@ -54,7 +54,7 @@
</span> </span>
</td> </td>
<td class="p-3 text-sm text-right text-hsrm-gray whitespace-nowrap"> <td class="p-3 text-sm text-right text-hsrm-gray whitespace-nowrap">
<% if job.able_to_cancel? %> <% if job.open? %>
<%= button_to icon("x-circle", class: "text-hsrm-red size-8 inline", title: "Abbrechen"), cancel_job_path(job), method: :patch, form: {data: {turbo_confirm: 'Den Plottauftrag wirklich abbrechen?'}}, form_class: "inline" %> <%= button_to icon("x-circle", class: "text-hsrm-red size-8 inline", title: "Abbrechen"), cancel_job_path(job), method: :patch, form: {data: {turbo_confirm: 'Den Plottauftrag wirklich abbrechen?'}}, form_class: "inline" %>
<% else %> <% else %>
<%= icon("x-circle", class: "text-hsrm-gray text-opacity-50 size-8 inline", title: "Kann nicht mehr abgebrochen werden") %> <%= icon("x-circle", class: "text-hsrm-gray text-opacity-50 size-8 inline", title: "Kann nicht mehr abgebrochen werden") %>

View File

@@ -15,6 +15,7 @@
</td> </td>
<td class="p-3 text-sm text-hsrm-gray whitespace-nowrap"> <td class="p-3 text-sm text-hsrm-gray whitespace-nowrap">
<% if job.pdf.attached? %> <% if job.pdf.attached? %>
<%= link_to_if job.printing?, icon("document-arrow-down", class: "text-hsrm-gray #{ unless job.printing?; 'text-opacity-25' else; 'hover:text-opacity-75'; end} size-6 inline", title: "Download"), job.pdf, download:true %>
<%#= link_to job.pdf.filename, rails_blob_path(job.pdf, disposition: "attachment") %> <%#= link_to job.pdf.filename, rails_blob_path(job.pdf, disposition: "attachment") %>
<%= link_to_if job.printing?, job.pdf.filename, job.pdf, download:true %> <%= link_to_if job.printing?, job.pdf.filename, job.pdf, download:true %>
<span class="p-1.5 bg-gray-300 bg-opacity-50 text-hsrm-gray font-medium rounded-lg ml-2"> <span class="p-1.5 bg-gray-300 bg-opacity-50 text-hsrm-gray font-medium rounded-lg ml-2">
@@ -58,24 +59,29 @@
</td> </td>
<td class="p-3 text-sm text-right text-hsrm-gray whitespace-nowrap"> <td class="p-3 text-sm text-right text-hsrm-gray whitespace-nowrap">
<!-- TODO: move logic to model --> <!-- TODO: move logic to model -->
<% if job.open? %> <% if job.printing? || job.canceled? || job.paid? %>
<%= button_to icon("printer", class: "text-hsrm-gray size-6 inline drop-shadow hover:text-opacity-75", title: "Drucken"), printing_operator_job_path(job), method: :patch, form_class: "inline" %> <%= button_to icon("inbox-stack", class: "text-hsrm-gray size-6 inline drop-shadow hover:text-opacity-75", title: "Zurück in die Warteschlange"), operator_job_path(job), method: :patch, params: {:job => {status: :open}}, form_class: "inline" %>
<% else %>
<%= icon("inbox-stack", class: "text-hsrm-gray text-opacity-25 size-6 inline drop-shadow", title: "") %>
<% end %>
<% if job.open? || job.canceled? || job.paid? %>
<%= button_to icon("printer", class: "text-hsrm-gray size-6 inline drop-shadow hover:text-opacity-75", title: "Drucken"), operator_job_path(job), method: :patch, params: {:job => {status: :printing}}, form_class: "inline" %>
<% else %> <% else %>
<%= icon("printer", class: "text-hsrm-gray text-opacity-25 size-6 inline drop-shadow", title: "") %> <%= icon("printer", class: "text-hsrm-gray text-opacity-25 size-6 inline drop-shadow", title: "") %>
<% end %> <% end %>
<%= link_to_if job.printing?, icon("document-arrow-down", class: "text-hsrm-gray #{ unless job.printing?; 'text-opacity-25' else; 'hover:text-opacity-75'; end} size-6 inline", title: "Download"), job.pdf, download:true %> <% if job.printing? || job.paid? %>
<% if job.printing? %> <%= button_to icon("arrow-up-tray", class: "text-hsrm-gray size-6 inline drop-shadow hover:text-opacity-75", 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: 'Sind die Pläne gedruckt und die Seitenanzahl und QM korrekt?'}}, form_class: "inline" %>
<%= button_to icon("check-circle", class: "text-green-700 size-6 inline drop-shadow hover:text-opacity-75", title: "Pläne sind fertig gedruckt"), pickup_operator_job_path(job), method: :patch, form: {data: {turbo_confirm: 'Sind die Pläne gedruckt und die Seitenanzahl und QM korrekt?'}}, form_class: "inline" %>
<% else %> <% else %>
<%= icon("check-circle", class: "text-hsrm-gray text-opacity-25 size-6 inline drop-shadow", title: "Kann nicht mehr abgebrochen werden") %> <%= icon("arrow-up-tray", class: "text-hsrm-gray text-opacity-25 size-6 inline drop-shadow", title: "") %>
<% end %> <% end %>
<% if job.pickup? %> <% if job.pickup? || job.printing? %>
<%= button_to icon("banknotes", class: "text-status-paid size-6 inline drop-shadow hover:text-opacity-75", title: "Bezahlt"), paid_operator_job_path(job), method: :patch, form_class: "inline" %> <% job.printing? && turbo_confirm = 'Sind die Pläne gedruckt und die Seitenanzahl und QM korrekt?' %>
<%= button_to icon("banknotes", class: "text-status-paid size-6 inline drop-shadow hover:text-opacity-75", title: "Bezahlt"), operator_job_path(job), method: :patch, params: {:job => {status: :paid}}, form: {data: {turbo_confirm: turbo_confirm}}, form_class: "inline" %>
<% else %> <% else %>
<%= icon("banknotes", class: "text-hsrm-gray text-opacity-25 size-6 inline drop-shadow ", title: "") %> <%= icon("banknotes", class: "text-hsrm-gray text-opacity-25 size-6 inline drop-shadow ", title: "") %>
<% end %> <% end %>
<% if job.open? || job.printing? || job.pickup? %> <% if job.open? || job.printing? || job.pickup? %>
<%= button_to icon("x-circle", class: "text-hsrm-red size-6 inline drop-shadow hover:text-opacity-75", title: "Abbrechen"), cancel_operator_job_path(job), method: :patch, form: {data: {turbo_confirm: 'Den Plottauftrag wirklich abbrechen?'}}, form_class: "inline" %> <%= button_to icon("x-circle", class: "text-hsrm-red size-6 inline drop-shadow hover:text-opacity-75", 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("x-circle", class: "text-hsrm-gray text-opacity-25 size-6 inline drop-shadow", title: "Kann nicht mehr abgebrochen werden") %> <%= icon("x-circle", class: "text-hsrm-gray text-opacity-25 size-6 inline drop-shadow", title: "Kann nicht mehr abgebrochen werden") %>
<% end %> <% end %>

View File

@@ -47,6 +47,19 @@
<h1 class="font-bold text-hsrm-gray text-4xl"> <h1 class="font-bold text-hsrm-gray text-4xl">
Printing Printing
</h1> </h1>
<% if @openjobs.any? %>
<%= button_to icon("printer",
class: "text-hsrm-gray size-6 inline drop-shadow hover:text-opacity-75 mr-2",
title: "Drucken") + "Start next job (" + @openjobs.count.to_s + ")", operator_job_path(@openjobs.first),
params: { :job => { status: :printing} },
method: :patch,
form_class: "inline px-3 py-2 font-semibold bg-green-500 hover:opacity-90 shadow-lg transition-colors duration-100 bg-opacity-100 flex items-center group text-hsrm-gray" %>
<% else %>
<span class="px-3 py-2 font-semibold bg-gray-300 shadow-lg transition-colors duration-100 bg-opacity-100 flex items-center group text-white">
<%= icon("printer", class: "text-hsrm-gray text-opacity-25 size-6 inline drop-shadow mr-2", title: "") %>
Start next job
</span>
<% end %>
</div> </div>
<%# render partial: "job_card", collection: @printingjobs, as: :job %> <%# render partial: "job_card", collection: @printingjobs, as: :job %>
<div id="printingjobs-h" class="overflow-auto min-w-full shadow-lg"> <div id="printingjobs-h" class="overflow-auto min-w-full shadow-lg">
@@ -61,10 +74,10 @@
<th class="p-3 text-sm font-semibold tracking-wide text-center w-1"> A1 </th> <th class="p-3 text-sm font-semibold tracking-wide text-center w-1"> A1 </th>
<th class="p-3 text-sm font-semibold tracking-wide text-center w-1"> A2 </th> <th class="p-3 text-sm font-semibold tracking-wide text-center w-1"> A2 </th>
<th class="p-3 text-sm font-semibold tracking-wide text-center w-1"> A3 </th> <th class="p-3 text-sm font-semibold tracking-wide text-center w-1"> A3 </th>
<th class="p-3 text-sm font-semibold tracking-wide text-center w-1"> no DIN </th> <th class="p-3 text-sm font-semibold tracking-wide text-center w-1 text-nowrap"> no DIN </th>
<th class="p-3 text-sm font-semibold tracking-wide text-center w-1"> Kosten </th> <th class="p-3 text-sm font-semibold tracking-wide text-center w-1"> Kosten </th>
<th class="p-3 text-sm font-semibold tracking-wide text-center w-1"> Status </th> <th class="p-3 text-sm font-semibold tracking-wide text-center w-1"> Status </th>
<th class="p-3 text-sm font-semibold tracking-wide text-center w-1"></th> <th class="p-3 text-sm font-semibold tracking-wide text-center w-40">Action</th>
</tr> </tr>
</thead> </thead>
<tbody id='printingjobs' class="divide-y divivde-gray-300"> <tbody id='printingjobs' class="divide-y divivde-gray-300">
@@ -90,10 +103,10 @@
<th class="p-3 text-sm font-semibold tracking-wide text-left w-1"> A1 </th> <th class="p-3 text-sm font-semibold tracking-wide text-left w-1"> A1 </th>
<th class="p-3 text-sm font-semibold tracking-wide text-left w-1"> A2 </th> <th class="p-3 text-sm font-semibold tracking-wide text-left w-1"> A2 </th>
<th class="p-3 text-sm font-semibold tracking-wide text-left w-1"> A3 </th> <th class="p-3 text-sm font-semibold tracking-wide text-left w-1"> A3 </th>
<th class="p-3 text-sm font-semibold tracking-wide text-center w-1"> no DIN </th> <th class="p-3 text-sm font-semibold tracking-wide text-center w-1 text-nowrap"> no DIN </th>
<th class="p-3 text-sm font-semibold tracking-wide text-center w-1"> Kosten </th> <th class="p-3 text-sm font-semibold tracking-wide text-center w-1"> Kosten </th>
<th class="p-3 text-sm font-semibold tracking-wide text-center w-1"> Status </th> <th class="p-3 text-sm font-semibold tracking-wide text-center w-1"> Status </th>
<th class="p-3 text-sm font-semibold tracking-wide text-center w-1"></th> <th class="p-3 text-sm font-semibold tracking-wide text-center w-1">Action</th>
</tr> </tr>
</thead> </thead>
<tbody id='pickupjobs' class="divide-y divivde-gray-300"> <tbody id='pickupjobs' class="divide-y divivde-gray-300">
@@ -119,10 +132,10 @@
<th class="p-3 text-sm font-semibold tracking-wide text-left w-1"> A1 </th> <th class="p-3 text-sm font-semibold tracking-wide text-left w-1"> A1 </th>
<th class="p-3 text-sm font-semibold tracking-wide text-left w-1"> A2 </th> <th class="p-3 text-sm font-semibold tracking-wide text-left w-1"> A2 </th>
<th class="p-3 text-sm font-semibold tracking-wide text-left w-1"> A3 </th> <th class="p-3 text-sm font-semibold tracking-wide text-left w-1"> A3 </th>
<th class="p-3 text-sm font-semibold tracking-wide text-center w-1"> no DIN </th> <th class="p-3 text-sm font-semibold tracking-wide text-center w-1 text-nowrap"> no DIN </th>
<th class="p-3 text-sm font-semibold tracking-wide text-center w-1"> Kosten </th> <th class="p-3 text-sm font-semibold tracking-wide text-center w-1"> Kosten </th>
<th class="p-3 text-sm font-semibold tracking-wide text-center w-1"> Status </th> <th class="p-3 text-sm font-semibold tracking-wide text-center w-1"> Status </th>
<th class="p-3 text-sm font-semibold tracking-wide text-center w-1"></th> <th class="p-3 text-sm font-semibold tracking-wide text-center w-1">Action</th>
</tr> </tr>
</thead> </thead>
<tbody id='openjobs' class="divide-y divivde-gray-300"> <tbody id='openjobs' class="divide-y divivde-gray-300">
@@ -148,7 +161,7 @@
<th class="p-3 text-sm font-semibold tracking-wide text-left w-1"> A1 </th> <th class="p-3 text-sm font-semibold tracking-wide text-left w-1"> A1 </th>
<th class="p-3 text-sm font-semibold tracking-wide text-left w-1"> A2 </th> <th class="p-3 text-sm font-semibold tracking-wide text-left w-1"> A2 </th>
<th class="p-3 text-sm font-semibold tracking-wide text-left w-1"> A3 </th> <th class="p-3 text-sm font-semibold tracking-wide text-left w-1"> A3 </th>
<th class="p-3 text-sm font-semibold tracking-wide text-center w-1"> no DIN </th> <th class="p-3 text-sm font-semibold tracking-wide text-center w-1 text-nowrap"> no DIN </th>
<th class="p-3 text-sm font-semibold tracking-wide text-center w-1"> Kosten </th> <th class="p-3 text-sm font-semibold tracking-wide text-center w-1"> Kosten </th>
<th class="p-3 text-sm font-semibold tracking-wide text-center w-1"> Status </th> <th class="p-3 text-sm font-semibold tracking-wide text-center w-1"> Status </th>
<th class="p-3 text-sm font-semibold tracking-wide text-center w-1"></th> <th class="p-3 text-sm font-semibold tracking-wide text-center w-1"></th>

View File

@@ -7,12 +7,8 @@ Rails.application.routes.draw do
namespace :operator do namespace :operator do
resources :jobs do resources :jobs do
member do member do
patch "cancel" patch "increment_page", :din
patch "pickup" patch "decrement_page", :din
patch "printing"
patch "paid"
patch "increment_page"
patch "decrement_page"
end end
end end
end end