Commit iniziale di eminuxCRM: CRM Rails con pipeline, campagne email e Docker.
Include autenticazione, progetti isolati, mail marketing HTML con SMTP, test A/B e editor WYSIWYG. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
<%= form_with model: user, class: "space-y-6 rounded-xl border border-zinc-200 bg-white text-zinc-900 dark:border-zinc-800 dark:bg-zinc-900 dark:text-zinc-100 p-6" do |f| %>
|
||||
<%= render "shared/errors", object: user %>
|
||||
|
||||
<div class="grid gap-4 md:grid-cols-2">
|
||||
<div>
|
||||
<label class="mb-1 block text-sm font-medium">Nome</label>
|
||||
<%= f.text_field :first_name, required: true, class: input_class %>
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-1 block text-sm font-medium">Cognome</label>
|
||||
<%= f.text_field :last_name, required: true, class: input_class %>
|
||||
</div>
|
||||
<div class="md:col-span-2">
|
||||
<label class="mb-1 block text-sm font-medium">Email</label>
|
||||
<%= f.email_field :email, required: true, class: input_class %>
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-1 block text-sm font-medium">Ruolo</label>
|
||||
<%= f.select :role, [["Utente", "user"], ["Admin", "admin"]], {}, class: input_class, disabled: user.last_active_admin? %>
|
||||
<% if user.last_active_admin? %>
|
||||
<%= f.hidden_field :role, value: "admin" %>
|
||||
<p class="mt-1 text-xs text-amber-700">Questo è l’unico admin attivo: il ruolo non si può cambiare.</p>
|
||||
<% end %>
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-1 block text-sm font-medium">Stato</label>
|
||||
<%= f.select :active, [["Attivo", true], ["Disabilitato", false]], {}, class: input_class, disabled: user.last_active_admin? %>
|
||||
<% if user.last_active_admin? %>
|
||||
<%= f.hidden_field :active, value: "true" %>
|
||||
<% end %>
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-1 block text-sm font-medium">Password<%= " (opzionale)" unless user.new_record? %></label>
|
||||
<%= f.password_field :password, required: user.new_record?, autocomplete: "new-password", class: input_class %>
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-1 block text-sm font-medium">Conferma password</label>
|
||||
<%= f.password_field :password_confirmation, required: user.new_record?, autocomplete: "new-password", class: input_class %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<div class="mb-2 text-sm font-medium">Progetti abilitati</div>
|
||||
<p class="mb-3 text-xs text-zinc-500">Ignorato per gli admin, che hanno sempre accesso a tutti i progetti.</p>
|
||||
<div class="flex flex-wrap gap-3">
|
||||
<% @projects.each do |project| %>
|
||||
<label class="inline-flex items-center gap-2 text-sm">
|
||||
<%= check_box_tag "project_ids[]", project.id, user.project_enabled?(project), id: "user_project_#{project.id}" %>
|
||||
<%= project.name %>
|
||||
</label>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-wrap items-center gap-2 border-t border-zinc-100 pt-4 dark:border-zinc-800">
|
||||
<%= f.submit user.new_record? ? "Crea utente" : "Salva", class: btn_primary %>
|
||||
<%= link_to "Annulla", users_path, class: btn_secondary %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<% unless user.new_record? || user == current_user %>
|
||||
<div class="mt-4">
|
||||
<% if user.can_be_destroyed? %>
|
||||
<%= button_to "Elimina utente", user_path(user), method: :delete,
|
||||
class: btn_danger,
|
||||
form: { data: { turbo_confirm: "Eliminare #{user.full_name}? Lo storico delle attività resta, senza questo utente." } } %>
|
||||
<% else %>
|
||||
<p class="text-xs text-zinc-500">Elimina non disponibile: è l’unico amministratore attivo.</p>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
@@ -0,0 +1,8 @@
|
||||
<div class="mx-auto max-w-2xl space-y-6">
|
||||
<div>
|
||||
<h1 class="text-2xl font-semibold tracking-tight">Modifica utente</h1>
|
||||
<p class="mt-1 text-sm text-zinc-500"><%= @user.email %></p>
|
||||
</div>
|
||||
|
||||
<%= render "form", user: @user %>
|
||||
</div>
|
||||
@@ -0,0 +1,57 @@
|
||||
<div class="space-y-6">
|
||||
<div class="flex flex-wrap items-end justify-between gap-3">
|
||||
<div>
|
||||
<h1 class="text-2xl font-semibold tracking-tight">Utenti</h1>
|
||||
<p class="mt-1 text-sm text-zinc-500">
|
||||
<%= link_to "Impostazioni", admin_path, class: "hover:underline" %>
|
||||
· account globali. Gli admin vedono tutti i progetti; gli utenti solo quelli abilitati.
|
||||
</p>
|
||||
</div>
|
||||
<%= link_to "Nuovo utente", new_user_path, class: btn_primary %>
|
||||
</div>
|
||||
|
||||
<div class="overflow-hidden <%= card_class %>">
|
||||
<table class="<%= table_class %>">
|
||||
<thead class="border-b border-zinc-100 bg-zinc-50 text-left text-xs font-medium uppercase tracking-wide text-zinc-500 dark:border-zinc-800 dark:bg-zinc-800 dark:text-zinc-400">
|
||||
<tr>
|
||||
<th class="px-4 py-3">Nome</th>
|
||||
<th class="px-4 py-3">Email</th>
|
||||
<th class="px-4 py-3">Ruolo</th>
|
||||
<th class="px-4 py-3">Stato</th>
|
||||
<th class="px-4 py-3">Progetti</th>
|
||||
<th class="px-4 py-3"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-zinc-100 dark:divide-zinc-800">
|
||||
<% @users.each do |user| %>
|
||||
<tr class="<%= "opacity-60" unless user.active? %>">
|
||||
<td class="px-4 py-3 font-medium">
|
||||
<%= user.full_name %>
|
||||
<% if user == current_user %><span class="ml-1 text-xs font-normal text-zinc-400">(tu)</span><% end %>
|
||||
</td>
|
||||
<td class="px-4 py-3 text-zinc-600 dark:text-zinc-300"><%= user.email %></td>
|
||||
<td class="px-4 py-3"><%= user.admin? ? "Admin" : "Utente" %></td>
|
||||
<td class="px-4 py-3">
|
||||
<% if user.active? %>
|
||||
<span class="text-zinc-900 dark:text-zinc-100">Attivo</span>
|
||||
<% else %>
|
||||
<span class="text-rose-700">Disabilitato</span>
|
||||
<% end %>
|
||||
</td>
|
||||
<td class="px-4 py-3 text-zinc-600 dark:text-zinc-300">
|
||||
<% if user.admin? %>
|
||||
Tutti
|
||||
<% else %>
|
||||
<% names = user.user_projects.select(&:enabled?).filter_map { |up| up.project&.name } %>
|
||||
<%= names.any? ? names.join(", ") : "—" %>
|
||||
<% end %>
|
||||
</td>
|
||||
<td class="px-4 py-3 text-right">
|
||||
<%= link_to "Modifica", edit_user_path(user), class: "text-zinc-700 hover:underline dark:text-zinc-300" %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,8 @@
|
||||
<div class="mx-auto max-w-2xl space-y-6">
|
||||
<div>
|
||||
<h1 class="text-2xl font-semibold tracking-tight">Nuovo utente</h1>
|
||||
<p class="mt-1 text-sm text-zinc-500">Crea un account e, se non è admin, scegli i progetti a cui può accedere.</p>
|
||||
</div>
|
||||
|
||||
<%= render "form", user: @user %>
|
||||
</div>
|
||||
Reference in New Issue
Block a user