Files
eminuxandCursor a33a281a96
CI / scan_ruby (push) Failing after 11m35s
CI / scan_js (push) Successful in 11m13s
CI / lint (push) Failing after 11m53s
Migliora pipeline e form per l'uso da cellulare.
Rende la pipeline verticale su mobile e semplifica i form lunghi con sezioni, tap target più grandi e azioni più facili da usare in movimento.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-18 11:38:48 +02:00

72 lines
3.4 KiB
ERB
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<%= form_with model: user, class: "space-y-6 rounded-xl border border-zinc-200 bg-white p-4 text-zinc-900 dark:border-zinc-800 dark:bg-zinc-900 dark:text-zinc-100 md: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 è lunico 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 min-h-11 items-center gap-2 rounded-lg border border-zinc-200 px-3 py-2 text-sm dark:border-zinc-700">
<%= check_box_tag "project_ids[]", project.id, user.project_enabled?(project), id: "user_project_#{project.id}", class: "size-5" %>
<%= project.name %>
</label>
<% end %>
</div>
</div>
<div class="flex flex-col gap-2 border-t border-zinc-100 pt-4 sm:flex-row dark:border-zinc-800">
<%= f.submit user.new_record? ? "Crea utente" : "Salva", class: "#{btn_primary} w-full sm:w-auto" %>
<%= link_to "Annulla", users_path, class: "#{btn_secondary} w-full sm:w-auto" %>
</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: è lunico amministratore attivo.</p>
<% end %>
</div>
<% end %>