<%# 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? %>

<%= vazio %>

<% else %>
<% cabecalhos.each_with_index do |c, i| %> <% end %> <% linhas.each do |celulas| %> <% ativo = filtro && base[filtro].to_s == celulas.first.to_s %> <% celulas.each_with_index do |cel, i| %> <% end %> <% end %> <% if total_rodape %> <% end %>
<%= c %>
<% if i.zero? && filtro %> <% destino = ativo ? base.except(filtro) : base.merge(filtro => cel.to_s) %> <%= link_to operacoes_dashboard_path(destino), data: { turbo: false }, title: (ativo ? 'Clique para remover o filtro' : "Filtrar por #{cel}"), class: "inline-flex items-center gap-1 hover:text-orange-400 #{'text-orange-400 font-semibold' if ativo}" do %> <%= cel %><% if ativo %> <% end %> <% end %> <% else %> <%= cel %> <% end %>
Total <%= total_rodape %>
<% end %>