Added broadcast to jobs create and update
This commit is contained in:
@@ -11,6 +11,9 @@ class Job < ApplicationRecord
|
||||
before_save :update_paid_at, if: :will_save_change_to_status?
|
||||
before_save :update_status_changed_at, if: :will_save_change_to_status?
|
||||
|
||||
after_create_commit -> { broadcast_prepend_later_to 'jobs', partial: 'jobs/job_tr' }
|
||||
after_update_commit -> { broadcast_replace_later_to 'jobs', partial: 'jobs/job_tr' }
|
||||
|
||||
# NOTE: Multiple status if paing before brinting?
|
||||
enum status: {
|
||||
open: 0,
|
||||
@@ -40,7 +43,7 @@ class Job < ApplicationRecord
|
||||
.or(Job.where(status: %i[paid canceled])
|
||||
.where('status_changed_at >= ?', Time.now.beginning_of_day))
|
||||
# .in_status_order
|
||||
# .order(created_at: :asc)
|
||||
.order(created_at: :desc)
|
||||
.order(:costumer_firstname, :costumer_lastname)
|
||||
end
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
<%= turbo_stream_from 'jobs' %>
|
||||
<div class="w-full">
|
||||
<% if notice.present? %>
|
||||
<p class="px-3 py-2 bg-green-100 mb-5 text-green-700 font-medium rounded-lg inline-block" id="notice"><%= notice %></p>
|
||||
@@ -7,7 +8,7 @@
|
||||
<h1 class="font-bold text-hsrm-gray text-4xl">Aktuelle Plottaufträge <span class="font-semibold text-sm"><%= Date.today.strftime("%d.%m.%Y") %></span></h1>
|
||||
<%= link_to "Plottauftrag aufgeben", new_job_path, class: "px-3 py-2 bg-hsrm-red drop-shadow-lg transition-colors hover:bg-hsrm-red-light text-white block font-medium" %>
|
||||
</div>
|
||||
<div id="jobs" class="overflow-auto min-w-full drop-shadow-lg">
|
||||
<div class="overflow-auto min-w-full drop-shadow-lg">
|
||||
<table class="w-full py-8 table-auto">
|
||||
<thead class="bg-gray-200 text-hsrm-gray border-b-2 border-hsrm-gray">
|
||||
<tr>
|
||||
@@ -21,7 +22,7 @@
|
||||
<th class="p-3 text-sm font-semibold tracking-wide text-left w-1"> Status </th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y divivde-gray-300">
|
||||
<tbody id='jobs' class="divide-y divivde-gray-300">
|
||||
<%= render partial: "job_tr", collection: @jobs, as: :job %>
|
||||
<%#= link_to "Show this job", job, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %>
|
||||
</tbody>
|
||||
|
||||
Reference in New Issue
Block a user