Added acces rules for jobs, operator/jobs and admin/dashboard view, including lazy loading for cancel button in broadcasts
This commit is contained in:
28
app/views/jobs/_cancel_button.html.erb
Normal file
28
app/views/jobs/_cancel_button.html.erb
Normal file
@@ -0,0 +1,28 @@
|
||||
<%= turbo_frame_tag dom_id(job, :cancel_button) do %>
|
||||
<%# TODO: Refactor! %>
|
||||
<% if current_user %>
|
||||
<% if allowed_to? :cancel?, job %>
|
||||
<%= button_to icon("x-circle", class: "icon size-10 text-hsrm-red", title: "Druckauftrag abbrechen (Anmeldung erforderlich)"), cancel_job_path(job), method: :patch, form: {data: {turbo_confirm: 'Den Plottauftrag wirklich abbrechen?'}}, form_class: "inline" %>
|
||||
<% else %>
|
||||
<% if job.open? %>
|
||||
<% if job.created_by_operator %>
|
||||
<%= icon("x-circle", class: "icon icon-disabled size-10", title: "Druckauftrag kann nur vom Operator abgebrochen werden!") %>
|
||||
<% else %>
|
||||
<%= icon("x-circle", class: "icon icon-disabled size-10", title: "Sie sind nicht berechtigt diesen Druckauftrag abzubrechen") %>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<%= icon("x-circle", class: "icon icon-disabled size-10", title: "Kann nicht mehr abgebrochen werden") %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<% if job.open? %>
|
||||
<% if job.created_by_operator %>
|
||||
<%= icon("x-circle", class: "icon icon-disabled size-10", title: "Druckauftrag kann nur vom Operator abgebrochen werden!") %>
|
||||
<% else %>
|
||||
<%= button_to icon("x-circle", class: "icon size-10 text-hsrm-red", title: "Druckauftrag abbrechen (Anmeldung erforderlich)"), cancel_job_path(job), method: :patch, form: {data: {turbo_confirm: 'Den Plottauftrag wirklich abbrechen? (Anmeldung erforderlich!)'}}, form_class: "inline" %>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<%= icon("x-circle", class: "icon icon-disabled size-10", title: "Kann nicht mehr abgebrochen werden") %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
@@ -54,10 +54,15 @@
|
||||
</span>
|
||||
</td>
|
||||
<td class="p-2 py-3 text-right">
|
||||
<% if job.open? %>
|
||||
<%= button_to icon("x-circle", class: "icon size-10 text-hsrm-red", title: "Abbrechen"), cancel_job_path(job), method: :patch, form: {data: {turbo_confirm: 'Den Plottauftrag wirklich abbrechen?'}}, form_class: "inline" %>
|
||||
<% # TODO: Refactor to helper function %>
|
||||
<% if defined?(no_turbo_stream) && no_turbo_stream %>
|
||||
<%= turbo_frame_tag dom_id(job, :cancel_button) do %>
|
||||
<%= render partial: "jobs/cancel_button", locals: { job: job } %>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<%= icon("x-circle", class: "icon icon-disabled size-10", title: "Kann nicht mehr abgebrochen werden") %>
|
||||
<%= turbo_frame_tag dom_id(job, :cancel_button), src: cancel_button_job_path(job), loading: 'lazy' do %>
|
||||
<%= icon("ellipsis-horizontal-circle", class: "icon icon-disabled size-10", title: "Loading...") %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
<%= turbo_stream_from 'jobs' %>
|
||||
<div class="w-full">
|
||||
<%#= render partial: 'layouts/flash' %>
|
||||
<% content_for :title, "Current Print Jobs" %>
|
||||
<div class="flex items-center justify-between py-4">
|
||||
<h1 class="text-4xl font-bold text-hsrm-gray">Aktuelle Druckaufträge <span class="text-sm font-semibold"><%= Date.today.strftime("%d.%m.%Y") %></span></h1>
|
||||
@@ -25,8 +24,7 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<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" %>
|
||||
<%= render partial: "job_tr", collection: @jobs, as: :job, locals: { no_turbo_stream: @no_turbo_stream } %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user