Adição do Usuario Externo e Correção da data no dashboard
This commit is contained in:
BIN
Imagens para correção /Imagem colada (13).png
Normal file
BIN
Imagens para correção /Imagem colada (13).png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 13 KiB |
@@ -57,6 +57,7 @@ module ApplicationHelper
|
|||||||
when 'gerente' then { cor: 'bg-orange-800 text-white' }
|
when 'gerente' then { cor: 'bg-orange-800 text-white' }
|
||||||
when 'operador' then { cor: 'bg-gray-700 text-white' }
|
when 'operador' then { cor: 'bg-gray-700 text-white' }
|
||||||
when 'motorista' then { cor: 'bg-gray-900 text-orange-400 border border-orange-500' }
|
when 'motorista' then { cor: 'bg-gray-900 text-orange-400 border border-orange-500' }
|
||||||
|
when 'externo' then { cor: 'bg-blue-900 text-blue-200 border border-blue-500' }
|
||||||
else { cor: 'bg-gray-800 text-gray-400' }
|
else { cor: 'bg-gray-800 text-gray-400' }
|
||||||
end
|
end
|
||||||
label = User::ROLES_LABEL[role.to_s] || role.to_s.humanize
|
label = User::ROLES_LABEL[role.to_s] || role.to_s.humanize
|
||||||
|
|||||||
@@ -7,13 +7,16 @@ class User < ApplicationRecord
|
|||||||
:validatable
|
:validatable
|
||||||
|
|
||||||
# ── Roles ──────────────────────────────────────────────────
|
# ── Roles ──────────────────────────────────────────────────
|
||||||
enum role: { admin: 0, gerente: 1, operador: 2, motorista: 3 }
|
# externo: acesso somente-leitura ao dashboard (ex.: gerências de outras áreas
|
||||||
|
# que só precisam visualizar os indicadores). Login normal por e-mail/senha.
|
||||||
|
enum role: { admin: 0, gerente: 1, operador: 2, motorista: 3, externo: 4 }
|
||||||
|
|
||||||
ROLES_LABEL = {
|
ROLES_LABEL = {
|
||||||
'admin' => 'Administrador',
|
'admin' => 'Administrador',
|
||||||
'gerente' => 'Gerente',
|
'gerente' => 'Gerente',
|
||||||
'operador' => 'Operador',
|
'operador' => 'Operador',
|
||||||
'motorista' => 'Motorista'
|
'motorista' => 'Motorista',
|
||||||
|
'externo' => 'Externo (só dashboard)'
|
||||||
}.freeze
|
}.freeze
|
||||||
|
|
||||||
# ── Validações ──────────────────────────────────────────────
|
# ── Validações ──────────────────────────────────────────────
|
||||||
|
|||||||
@@ -441,11 +441,19 @@
|
|||||||
String(d.getMonth() + 1).padStart(2, '0') + '-' +
|
String(d.getMonth() + 1).padStart(2, '0') + '-' +
|
||||||
String(d.getDate()).padStart(2, '0');
|
String(d.getDate()).padStart(2, '0');
|
||||||
|
|
||||||
|
// Os valores vêm em ISO (YYYY-MM-DD), mas o dateFormat exibido é d/m/Y.
|
||||||
|
// Convertendo para Date local antes evita o flatpickr interpretar errado
|
||||||
|
// (era a causa da caixa mostrar uma data solta em vez do período).
|
||||||
|
const parseISO = (s) => {
|
||||||
|
const [y, m, d] = s.split('-').map(Number);
|
||||||
|
return new Date(y, m - 1, d);
|
||||||
|
};
|
||||||
|
|
||||||
flatpickr(input, {
|
flatpickr(input, {
|
||||||
mode: 'range',
|
mode: 'range',
|
||||||
locale: 'pt',
|
locale: Object.assign({}, flatpickr.l10ns.pt, { rangeSeparator: ' até ' }),
|
||||||
dateFormat: 'd/m/Y',
|
dateFormat: 'd/m/Y',
|
||||||
defaultDate: [inicio, fim],
|
defaultDate: [parseISO(inicio), parseISO(fim)],
|
||||||
maxDate: 'today',
|
maxDate: 'today',
|
||||||
onClose: function (selectedDates) {
|
onClose: function (selectedDates) {
|
||||||
if (selectedDates.length === 0) return;
|
if (selectedDates.length === 0) return;
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
<%= current_user.admin? ? 'bg-orange-500 text-black' :
|
<%= current_user.admin? ? 'bg-orange-500 text-black' :
|
||||||
current_user.gerente? ? 'bg-orange-800 text-white' :
|
current_user.gerente? ? 'bg-orange-800 text-white' :
|
||||||
current_user.operador? ? 'bg-gray-700 text-white' :
|
current_user.operador? ? 'bg-gray-700 text-white' :
|
||||||
|
current_user.externo? ? 'bg-blue-900 text-blue-200 border border-blue-500' :
|
||||||
'bg-gray-900 text-orange-400 border border-orange-500' %>">
|
'bg-gray-900 text-orange-400 border border-orange-500' %>">
|
||||||
<%= current_user.role_label %>
|
<%= current_user.role_label %>
|
||||||
</span>
|
</span>
|
||||||
@@ -33,9 +34,13 @@
|
|||||||
<%# Navegação %>
|
<%# Navegação %>
|
||||||
<nav class="px-3 py-4 space-y-1 flex-1 overflow-y-auto">
|
<nav class="px-3 py-4 space-y-1 flex-1 overflow-y-auto">
|
||||||
|
|
||||||
<%# Dashboard — admin/gerente/operador %>
|
<%# Dashboard — admin/gerente/operador/externo (todos menos motorista) %>
|
||||||
<% unless current_user.motorista? %>
|
<% unless current_user.motorista? %>
|
||||||
<%= nav_link_to '📊 Dashboard', dashboard_path %>
|
<%= nav_link_to '📊 Dashboard', dashboard_path %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<%# Consolidações — só quem pode consolidar (exclui o externo) %>
|
||||||
|
<% if current_user.pode_consolidar? %>
|
||||||
<%= nav_link_to '📦 Consolidações', consolidacoes_path %>
|
<%= nav_link_to '📦 Consolidações', consolidacoes_path %>
|
||||||
<%= nav_link_to '📁 Arquivadas', arquivadas_consolidacoes_path %>
|
<%= nav_link_to '📁 Arquivadas', arquivadas_consolidacoes_path %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
Reference in New Issue
Block a user