Correções para funcionamento do dash,criar login do motorista senha, e gerar quelátório
This commit is contained in:
@@ -134,20 +134,21 @@
|
||||
</div>
|
||||
|
||||
<script>
|
||||
const roleSelect = document.querySelector('select[name="user[role]"]');
|
||||
const fieldsEmail = document.getElementById('fields-email');
|
||||
const fieldsPin = document.getElementById('fields-pin');
|
||||
// IIFE: evita "Identifier already declared" quando o Turbo re-executa o script
|
||||
// ao navegar (o que antes abortava o toggle e escondia o campo de PIN).
|
||||
(function () {
|
||||
const roleSelect = document.querySelector('select[name="user[role]"]');
|
||||
const fieldsEmail = document.getElementById('fields-email');
|
||||
const fieldsPin = document.getElementById('fields-pin');
|
||||
if (!roleSelect || !fieldsEmail || !fieldsPin) return;
|
||||
|
||||
function toggleFields() {
|
||||
if (roleSelect.value === 'motorista') {
|
||||
fieldsEmail.classList.add('hidden');
|
||||
fieldsPin.classList.remove('hidden');
|
||||
} else {
|
||||
fieldsEmail.classList.remove('hidden');
|
||||
fieldsPin.classList.add('hidden');
|
||||
function toggleFields() {
|
||||
const motorista = roleSelect.value === 'motorista';
|
||||
fieldsEmail.classList.toggle('hidden', motorista);
|
||||
fieldsPin.classList.toggle('hidden', !motorista);
|
||||
}
|
||||
}
|
||||
|
||||
roleSelect.addEventListener('change', toggleFields);
|
||||
toggleFields(); // run on load
|
||||
roleSelect.addEventListener('change', toggleFields);
|
||||
toggleFields(); // estado inicial
|
||||
})();
|
||||
</script>
|
||||
|
||||
@@ -57,9 +57,11 @@
|
||||
</button>
|
||||
<%= link_to '📄 Relatório Individual',
|
||||
gerar_pdf_relatorio_consolidacao_path(@consolidacao, motorista: cm.motorista_nome),
|
||||
data: { turbo: false },
|
||||
class: 'bg-orange-800 hover:bg-orange-700 text-white font-semibold px-4 py-3 rounded-lg text-sm min-h-[48px] flex items-center' %>
|
||||
<%= link_to '🧾 Gerar Holerite',
|
||||
gerar_pdf_holerite_consolidacao_path(@consolidacao, motorista: cm.motorista_nome),
|
||||
data: { turbo: false },
|
||||
class: 'bg-orange-500 hover:bg-orange-600 text-black font-bold px-4 py-3 rounded-lg text-sm min-h-[48px] flex items-center' %>
|
||||
</div>
|
||||
</div>
|
||||
@@ -79,7 +81,7 @@
|
||||
<div class="flex justify-center py-10"><div class="spinner w-10 h-10"></div></div>
|
||||
</div>
|
||||
<div class="flex gap-3 px-6 py-4 border-t border-[#2a2a2a]">
|
||||
<a id="modal-confirmar" href="#"
|
||||
<a id="modal-confirmar" href="#" data-turbo="false"
|
||||
class="flex-1 bg-orange-500 hover:bg-orange-600 text-black font-bold py-3 rounded-lg text-center min-h-[48px] flex items-center justify-center">
|
||||
✓ Confirmar e baixar PDF
|
||||
</a>
|
||||
|
||||
@@ -14,10 +14,11 @@
|
||||
</div>
|
||||
|
||||
<%# Filtro de calendário — seleciona uma faixa de datas %>
|
||||
<form id="dashboard-filtro-form" method="get" action="<%= dashboard_path %>" class="flex items-center gap-2">
|
||||
<form id="dashboard-filtro-form" method="get" action="<%= dashboard_path %>" data-turbo="false" class="flex items-center gap-2">
|
||||
<div class="relative">
|
||||
<span class="pointer-events-none absolute right-3 top-1/2 -translate-y-1/2 text-orange-500">📅</span>
|
||||
<input type="text" id="periodo-range" readonly placeholder="Selecione o período"
|
||||
value="<%= @periodo_inicio.strftime('%d/%m/%Y') %> até <%= @periodo_fim.strftime('%d/%m/%Y') %>"
|
||||
class="cursor-pointer pl-4 pr-10 py-2.5 bg-[#1a1a1a] border border-white/10 rounded-xl
|
||||
text-white text-sm w-[240px] focus:outline-none focus:border-orange-500 placeholder-gray-500">
|
||||
</div>
|
||||
@@ -189,7 +190,11 @@
|
||||
<script src="https://cdn.jsdelivr.net/npm/chart.js@4.4.0/dist/chart.umd.min.js"></script>
|
||||
|
||||
<script>
|
||||
// IIFE: evita "Identifier already declared" quando o Turbo re-executa o script
|
||||
// ao navegar (o que antes fazia o gráfico não aparecer).
|
||||
(function () {
|
||||
const ctx = document.getElementById('grafico-diario');
|
||||
if (!ctx || typeof Chart === 'undefined') return;
|
||||
|
||||
const labels = <%= raw @grafico_diario[:labels].to_json %>;
|
||||
const valores = <%= raw @grafico_diario[:valores].to_json %>;
|
||||
@@ -254,4 +259,5 @@
|
||||
}
|
||||
}
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
|
||||
@@ -53,6 +53,7 @@
|
||||
<% if c.finalizada? %>
|
||||
<%= link_to '⬇️ Baixar meu holerite',
|
||||
gerar_pdf_holerite_consolidacao_path(c, motorista: current_user.nome),
|
||||
data: { turbo: false },
|
||||
class: 'bg-orange-500 hover:bg-orange-600 text-black font-bold px-5 py-3.5 rounded-lg min-h-[48px] flex items-center justify-center text-center' %>
|
||||
<% else %>
|
||||
<span class="text-gray-500 text-sm px-4 py-3 border border-[#2a2a2a] rounded-lg text-center">
|
||||
|
||||
Reference in New Issue
Block a user