Users pages have been stylized to fit in line with the app

This commit is contained in:
Ben 2024-02-16 15:13:09 -06:00
parent 12a9641ca7
commit e52a9da39c
3 changed files with 76 additions and 51 deletions

View File

@ -1,7 +1,7 @@
<%= form_with(model: user, local: true) do |form| %> <%= form_with(model: user, local: true, html: { class: 'needs-validation', novalidate: true }) do |form| %>
<% if user.errors.any? %> <% if user.errors.any? %>
<div id="error_explanation"> <div id="error_explanation" class="alert alert-danger" role="alert">
<h2><%= pluralize(user.errors.count, "error") %> prohibited this user from being saved:</h2> <h4><%= pluralize(user.errors.count, "error") %> prohibited this user from being saved:</h4>
<ul> <ul>
<% user.errors.full_messages.each do |message| %> <% user.errors.full_messages.each do |message| %>
<li><%= message %></li> <li><%= message %></li>
@ -10,18 +10,17 @@
</div> </div>
<% end %> <% end %>
<div class="field"> <div class="mb-3">
<%= form.label :email %><br> <%= form.label :email, class: 'form-label' %>
<%= form.email_field :email, id: :user_email %> <%= form.email_field :email, id: :user_email, class: 'form-control' %>
</div> </div>
<div class="field"> <div class="mb-3 form-check">
<%= form.label :admin %><br> <%= form.check_box :admin, class: 'form-check-input', id: :user_admin %>
<%= form.check_box :admin %> <%= form.label :admin, class: 'form-check-label' %>
</div> </div>
<div class="actions"> <div class="actions">
<%= form.submit 'Save', class: 'btn btn-primary' %> <%= form.submit 'Save', class: 'btn btn-dark' %>
</div> </div>
<% end %> <% end %>

View File

@ -1,5 +1,14 @@
<h1>Edit User</h1> <div class="container mt-5">
<div class="row justify-content-center">
<div class="col-md-6">
<h1 class="mb-4 text-center">Edit User</h1>
<%= render 'form', user: @user %> <%= render 'form', user: @user %>
<div class="mt-3 d-flex justify-content-between">
<%= link_to 'Back to Users', users_path, class: 'btn btn-secondary' %> <%= link_to 'Back to Users', users_path, class: 'btn btn-secondary' %>
<%= link_to 'Delete User', user_path(@user), method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-danger' %>
</div>
</div>
</div>
</div>

View File

@ -1,7 +1,11 @@
<h1>Users</h1> <div class="container mt-5">
<div class="row">
<div class="col-12">
<h1 class="mb-4 text-center">Users</h1>
</div>
<div class="col-12 mb-4">
<table class="table"> <table class="table">
<thead> <thead class="table-light">
<tr> <tr>
<th>Email</th> <th>Email</th>
<th>Admin</th> <th>Admin</th>
@ -14,10 +18,23 @@
<td><%= user.email %></td> <td><%= user.email %></td>
<td><%= user.admin? ? 'Yes' : 'No' %></td> <td><%= user.admin? ? 'Yes' : 'No' %></td>
<td> <td>
<%= link_to 'Edit', edit_user_path(user), class: 'btn btn-info' %> <%= link_to edit_user_path(user), class: 'btn btn-info btn-sm' do %>
<%= link_to 'Delete', user_path(user), method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-danger' %> <i class="bi bi-pencil-fill" style="color: white;"></i>
<% end %>
<%= link_to user_path(user), method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-danger btn-sm' do %>
<i class="bi bi-trash-fill"></i>
<% end %>
</td> </td>
</tr> </tr>
<% end %> <% end %>
</tbody> </tbody>
</table> </table>
</div>
</div>
<!-- Optionally, include action buttons or links here -->
<div class="row">
<div class="col-12 d-flex justify-content-between mb-4">
<%= link_to 'Back to Home', root_path, class: "btn btn-secondary" %> <!-- Adjust as needed -->
</div>
</div>
</div>