52 lines
2.1 KiB
Plaintext
52 lines
2.1 KiB
Plaintext
<%# locals:
|
|
cabecalhos (Array), linhas (Array de Array), vazio (String),
|
|
total (opcional) — linha de rodapé "Total"
|
|
filtro (opcional) — nome do param (ex.: 'f_driver') que torna a 1ª coluna
|
|
clicável para cross-filter %>
|
|
<% total_rodape = local_assigns[:total] %>
|
|
<% filtro = local_assigns[:filtro] %>
|
|
<% base = request.query_parameters %>
|
|
<% if linhas.blank? %>
|
|
<p class="text-center py-6 text-gray-500 text-sm"><%= vazio %></p>
|
|
<% else %>
|
|
<div class="overflow-x-auto">
|
|
<table class="w-full text-sm">
|
|
<thead>
|
|
<tr class="text-gray-400 text-left border-b border-white/5">
|
|
<% cabecalhos.each_with_index do |c, i| %>
|
|
<th class="pb-2 font-medium <%= i.zero? ? 'pr-3' : 'pl-4 text-right whitespace-nowrap' %>"><%= c %></th>
|
|
<% end %>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<% linhas.each do |celulas| %>
|
|
<% ativo = filtro && base[filtro].to_s == celulas.first.to_s %>
|
|
<tr class="border-b border-white/5 <%= 'bg-orange-500/10' if ativo %>">
|
|
<% celulas.each_with_index do |cel, i| %>
|
|
<td class="py-2 align-top <%= i.zero? ? 'pr-3 text-gray-300' : 'pl-4 text-right whitespace-nowrap font-semibold text-white' %>">
|
|
<% if i.zero? && filtro %>
|
|
<%= link_to cel,
|
|
operacoes_dashboard_path(base.merge(filtro => cel.to_s)),
|
|
data: { turbo: false },
|
|
title: "Filtrar por #{cel}",
|
|
class: "inline-flex items-center gap-1 hover:text-orange-400 #{'text-orange-400 font-semibold' if ativo}" %>
|
|
<% else %>
|
|
<%= cel %>
|
|
<% end %>
|
|
</td>
|
|
<% end %>
|
|
</tr>
|
|
<% end %>
|
|
</tbody>
|
|
<% if total_rodape %>
|
|
<tfoot>
|
|
<tr class="text-white font-bold">
|
|
<td class="pt-2 pr-3">Total</td>
|
|
<td class="pt-2 pl-4 text-right whitespace-nowrap" colspan="<%= cabecalhos.size - 1 %>"><%= total_rodape %></td>
|
|
</tr>
|
|
</tfoot>
|
|
<% end %>
|
|
</table>
|
|
</div>
|
|
<% end %>
|