Amélioration de la présentation des utilisateurs

This commit is contained in:
Jérémy Lecour 2022-01-22 18:48:11 +01:00 committed by Jérémy Lecour
parent 94590699b9
commit a42eb7d379
4 changed files with 38 additions and 22 deletions

View file

@ -48,10 +48,10 @@ class AccountsController < ApplicationController
private private
def create_user_params def create_user_params
params.require(:user).permit(:email, :password, :password_confirmation) params.require(:user).permit(:email, :password, :password_confirmation, :name)
end end
def update_user_params def update_user_params
params.require(:user).permit(:current_password, :password, :password_confirmation, :unconfirmed_email) params.require(:user).permit(:current_password, :password, :password_confirmation, :unconfirmed_email, :name)
end end
end end

View file

@ -8,18 +8,22 @@
<%= form.label :unconfirmed_email, "New Email" %> <%= form.label :unconfirmed_email, "New Email" %>
<%= form.text_field :unconfirmed_email %> <%= form.text_field :unconfirmed_email %>
</div> </div>
<div>
<%= form.label :name %>
<%= form.text_field :name, autocomplete: "name" %>
</div>
<div> <div>
<%= form.label :password, "Password (leave blank if you don't want to change it)" %> <%= form.label :password, "Password (leave blank if you don't want to change it)" %>
<%= form.password_field :password %> <%= form.password_field :password, autocomplete: "new-password" %>
</div> </div>
<div> <div>
<%= form.label :password_confirmation %> <%= form.label :password_confirmation %>
<%= form.password_field :password_confirmation %> <%= form.password_field :password_confirmation, autocomplete: "new-password" %>
</div> </div>
<hr/> <hr/>
<div> <div>
<%= form.label :current_password, "Current password (we need your current password to confirm your changes)" %> <%= form.label :current_password, "Current password (we need your current password to confirm your changes)" %>
<%= form.password_field :current_password, required: true %> <%= form.password_field :current_password, required: true, autocomplete: "current-password" %>
</div> </div>
<%= form.submit "Update Account" %> <%= form.submit "Update Account" %>
<% end %> <% end %>

View file

@ -4,6 +4,10 @@
<%= form.label :email %> <%= form.label :email %>
<%= form.text_field :email, required: true, autofocus: true, autocomplete: "email" %> <%= form.text_field :email, required: true, autofocus: true, autocomplete: "email" %>
</div> </div>
<div>
<%= form.label :name %>
<%= form.text_field :name, autocomplete: "name" %>
</div>
<div> <div>
<%= form.label :password %> <%= form.label :password %>
<%= form.password_field :password, required: true, autocomplete: "new-password" %> <%= form.password_field :password, required: true, autocomplete: "new-password" %>

View file

@ -13,20 +13,14 @@
<table class="min-w-full divide-y divide-gray-200"> <table class="min-w-full divide-y divide-gray-200">
<thead class="bg-gray-50"> <thead class="bg-gray-50">
<tr> <tr>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
Gravatar
</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
Email
</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider"> <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
Name Name
</th> </th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider"> <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
Created at Created at<br />Updated at
</th> </th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider"> <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
Updated at Status
</th> </th>
<th scope="col" class="relative px-6 py-3"> <th scope="col" class="relative px-6 py-3">
<span class="sr-only">Edit</span> <span class="sr-only">Edit</span>
@ -37,19 +31,33 @@
<% @users.each do |user| %> <% @users.each do |user| %>
<tr class="<%= cycle("bg-white", "bg-gray-50") %>"> <tr class="<%= cycle("bg-white", "bg-gray-50") %>">
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900"> <td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900">
<%= user_gravatar current_user, class: "h-10 w-10 rounded-full", size: 80 %> <div class="flex items-center">
</td> <div class="flex-shrink-0 h-10 w-10">
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900"> <%= user_gravatar current_user, class: "h-10 w-10 rounded-full", size: 80 %>
<%= user.email %> </div>
</td> <div class="ml-4">
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900"> <div class="text-sm font-medium text-gray-900">
<%= user.name %> <%= user.name.presence || "<i>Anonymous</i>".html_safe %>
</div>
<div class="text-sm text-gray-500">
<%= user.email %>
</div>
</div>
</div>
</td> </td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500"> <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
<%= user.created_at %> <%= user.created_at %><br /><%= user.updated_at %>
</td> </td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500"> <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
<%= user.updated_at %> <% if user.confirmed? %>
<span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-green-100 text-green-800">
Confirmed
</span>
<% else %>
<span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-yellow-100 text-yellow-800">
Unconfirmed
</span>
<% end %>
</td> </td>
<td class="px-6 py-4 whitespace-nowrap text-right text-sm font-medium"> <td class="px-6 py-4 whitespace-nowrap text-right text-sm font-medium">
<%= link_to "Show", user, class: "text-indigo-600 hover:text-indigo-900" %> <%= link_to "Show", user, class: "text-indigo-600 hover:text-indigo-900" %>