Include autenticazione, progetti isolati, mail marketing HTML con SMTP, test A/B e editor WYSIWYG. Co-authored-by: Cursor <cursoragent@cursor.com>
72 lines
3.3 KiB
ERB
72 lines
3.3 KiB
ERB
<%= 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 %>
|