Implantação da geração de mensagem de forma livre e mudança na engine de mensagem

This commit is contained in:
2026-08-24 17:32:16 -03:00
parent 94bbe7556f
commit 88f19dd8f5
77 changed files with 4650 additions and 25 deletions

View File

@@ -0,0 +1,36 @@
<%# URL explícita: a rota se chama `grupo`/`grupos` (ver routes.rb), então a
rota polimórfica de `model:` procuraria admin_grupo_contato_path e estouraria.
O `model:` continua valendo para nomear os campos (grupo_contato[...]). %>
<%= form_with model: [:admin, grupo],
url: (grupo.persisted? ? admin_grupo_path(grupo) : admin_grupos_path),
data: { turbo: false }, class: 'space-y-5' do |f| %>
<% if grupo.errors.any? %>
<div class="bg-red-500/10 border border-red-500/30 rounded-xl px-4 py-3 text-red-300 text-sm">
<ul class="list-disc list-inside space-y-1">
<% grupo.errors.full_messages.each do |msg| %><li><%= msg %></li><% end %>
</ul>
</div>
<% end %>
<div>
<%= f.label :nome, class: 'block text-gray-400 text-sm mb-1' %>
<%= f.text_field :nome, required: true, placeholder: 'Diretoria',
class: 'w-full bg-[#1a1a1a] border border-white/10 rounded-xl text-white text-sm px-3 py-2.5 focus:outline-none focus:border-orange-500' %>
</div>
<div>
<%= f.label :descricao, 'Descrição', class: 'block text-gray-400 text-sm mb-1' %>
<%= f.text_field :descricao, placeholder: 'Quem acompanha o fechamento',
class: 'w-full bg-[#1a1a1a] border border-white/10 rounded-xl text-white text-sm px-3 py-2.5 focus:outline-none focus:border-orange-500' %>
</div>
<label class="flex items-center gap-2 text-sm text-gray-300">
<%= f.check_box :ativo, class: 'rounded border-white/20 bg-[#1a1a1a] text-orange-500' %>
Ativo (grupo inativo não recebe nada)
</label>
<div class="flex items-center gap-3">
<%= f.submit 'Salvar', class: 'px-4 py-2.5 rounded-xl text-sm font-semibold bg-orange-500 text-black hover:bg-orange-400 cursor-pointer' %>
<%= link_to 'Cancelar', admin_grupos_path, data: { turbo: false }, class: 'text-gray-400 hover:text-white text-sm' %>
</div>
<% end %>

View File

@@ -0,0 +1,4 @@
<div class="max-w-xl space-y-6">
<h1 class="text-2xl font-bold text-white">Editar grupo</h1>
<%= render 'form', grupo: @grupo %>
</div>

View File

@@ -0,0 +1,65 @@
<div class="space-y-6">
<div class="flex flex-col sm:flex-row sm:items-center justify-between gap-4">
<div>
<h1 class="text-2xl font-bold text-white">Grupos de contato</h1>
<p class="text-gray-400 text-sm mt-0.5">
É o grupo que assina os eventos — cadastrar alguém novo é escolher o grupo,
não repetir a configuração pessoa por pessoa.
</p>
</div>
<%= link_to 'Novo grupo', new_admin_grupo_path, data: { turbo: false },
class: 'px-4 py-2.5 rounded-xl text-sm font-semibold bg-orange-500 text-black hover:bg-orange-400' %>
</div>
<div class="bg-[#1a1a1a] rounded-2xl border border-white/5 overflow-hidden">
<% if @grupos.empty? %>
<p class="px-6 py-10 text-center text-gray-500 text-sm">
Nenhum grupo ainda. Crie um (ex.: <strong class="text-gray-300">Diretoria</strong>,
<strong class="text-gray-300">Motoristas</strong>) e depois cadastre os contatos dentro dele.
</p>
<% else %>
<div class="overflow-x-auto">
<table class="w-full text-sm">
<thead class="bg-white/5 text-gray-400 text-xs uppercase tracking-wider">
<tr>
<th class="text-left px-6 py-3 font-medium">Grupo</th>
<th class="text-left px-4 py-3 font-medium">Descrição</th>
<th class="text-right px-4 py-3 font-medium">Contatos</th>
<th class="text-left px-4 py-3 font-medium">Assina os eventos</th>
<th class="text-left px-4 py-3 font-medium">Situação</th>
<th class="px-4 py-3"></th>
</tr>
</thead>
<tbody class="divide-y divide-white/5">
<% @grupos.each do |grupo| %>
<tr class="hover:bg-white/5">
<td class="px-6 py-2.5 text-white font-semibold"><%= grupo.nome %></td>
<td class="px-4 py-2.5 text-gray-400"><%= grupo.descricao.presence || '—' %></td>
<td class="px-4 py-2.5 text-right">
<%= link_to grupo.contatos.size, admin_contatos_path(grupo_id: grupo.id),
data: { turbo: false }, class: 'text-orange-400 hover:text-orange-300 underline' %>
</td>
<td class="px-4 py-2.5 text-gray-300">
<% nomes = grupo.assinaturas.select(&:ativo).map { |a| a.evento_notificacao.nome } %>
<%= nomes.any? ? nomes.join(', ') : '— nenhum' %>
</td>
<td class="px-4 py-2.5">
<span class="<%= grupo.ativo? ? 'text-green-400' : 'text-gray-500' %>">
<%= grupo.ativo? ? 'Ativo' : 'Inativo' %>
</span>
</td>
<td class="px-4 py-2.5 text-right whitespace-nowrap">
<%= link_to 'Editar', edit_admin_grupo_path(grupo), data: { turbo: false },
class: 'text-gray-300 hover:text-orange-400 mr-3' %>
<%= button_to 'Excluir', admin_grupo_path(grupo), method: :delete,
form: { data: { turbo_confirm: "Excluir #{grupo.nome}? Os #{grupo.contatos.size} contato(s) ficam sem grupo e param de receber." } },
class: 'text-red-400 hover:text-red-300 inline' %>
</td>
</tr>
<% end %>
</tbody>
</table>
</div>
<% end %>
</div>
</div>

View File

@@ -0,0 +1,4 @@
<div class="max-w-xl space-y-6">
<h1 class="text-2xl font-bold text-white">Novo grupo de contato</h1>
<%= render 'form', grupo: @grupo %>
</div>