asxpio/views/admin/invoices/index.erb
Sergei Poljanski 8471570187
admin: per-area permissions on every route
Give each user independent read, write and delete flags per area
(invoices, bingo, users), so someone can e.g. review and remove bingo
incidents without being able to add any. The request method and path
decide the flag needed: GET is read except the new/duplicate forms, POST
to .../delete is delete, any other POST is write. Unmapped admin paths
are superuser-only, and a test enumerates every registered admin route
so a new one cannot ship without a rule.

Pages follow the same flags: nav and dashboard tiles show readable areas
only, write forms and delete buttons are hidden, and the datacenter form
is shown read-only.

Assisted-by: Claude:opus-5
2026-10-10 08:27:37 +04:00

42 lines
1.6 KiB
Text

<%== erb :'admin/_nav', layout: false %>
<div class="header">
<h1>Invoices</h1>
<% if can?('invoices', 'write') %><p class="tagline"><a href="/admin/invoices/new">+ New invoice</a></p><% end %>
</div>
<% if @invoices.empty? %>
<section class="section">
<p>No invoices yet.<% if can?('invoices', 'write') %> <a href="/admin/invoices/new">Create the first one</a>.<% end %></p>
</section>
<% else %>
<section class="section">
<table class="invoice-list">
<thead>
<tr>
<th>Number</th>
<th>Client</th>
<th>Issued</th>
<th class="num">Total</th>
<th>Status</th>
<th></th>
</tr>
</thead>
<tbody>
<% @invoices.each do |inv| %>
<tr>
<td class="mono"><%= inv.number %></td>
<td><%= inv.client_name %></td>
<td class="mono"><%= inv.issued_on.strftime('%Y-%m-%d') %></td>
<td class="num mono"><%= inv.currency %> <%= '%.2f' % inv.total %></td>
<td>
<span class="badge badge-<%= inv.status %>"><%= inv.status %></span>
</td>
<td class="actions">
<a href="/admin/invoices/<%= inv.uuid %>">view</a>
</td>
</tr>
<% end %>
</tbody>
</table>
</section>
<% end %>