2024-02-16 15:13:09 -06:00
|
|
|
<%= form_with(model: user, local: true, html: { class: 'needs-validation', novalidate: true }) do |form| %>
|
2024-04-09 17:48:54 -05:00
|
|
|
|
|
|
|
<%# Display validation errors, if any %>
|
2024-02-16 15:13:09 -06:00
|
|
|
<% if user.errors.any? %>
|
2024-04-12 02:40:09 -05:00
|
|
|
<div class="alert alert-danger">
|
|
|
|
<strong>Please correct the following errors:</strong>
|
|
|
|
<ul>
|
|
|
|
<% user.errors.full_messages.each do |msg| %>
|
|
|
|
<li><%= msg %></li>
|
|
|
|
<% end %>
|
|
|
|
</ul>
|
|
|
|
</div>
|
2024-02-15 17:23:54 -06:00
|
|
|
<% end %>
|
2024-02-16 15:13:09 -06:00
|
|
|
|
2024-04-09 17:48:54 -05:00
|
|
|
<%# User attributes fields %>
|
|
|
|
<div class="mb-3">
|
2024-04-12 02:55:34 -05:00
|
|
|
<%= form.label :first_name, 'First Name', class: 'form-label' %>
|
2024-04-09 17:48:54 -05:00
|
|
|
<%= form.text_field :first_name, id: :user_first_name, class: 'form-control' %>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="mb-3">
|
2024-04-12 02:55:34 -05:00
|
|
|
<%= form.label :last_name, 'Last Name', class: 'form-label' %>
|
2024-04-09 17:48:54 -05:00
|
|
|
<%= form.text_field :last_name, id: :user_last_name, class: 'form-control' %>
|
|
|
|
</div>
|
|
|
|
|
2024-04-11 16:40:32 -05:00
|
|
|
<div class="mb-3">
|
|
|
|
<%= form.label :email, class: 'form-label' %>
|
|
|
|
<%= form.email_field :email, id: :user_email, class: 'form-control' %>
|
|
|
|
</div>
|
|
|
|
|
2024-04-12 02:55:34 -05:00
|
|
|
<div class="mb-3">
|
|
|
|
<%= form.label :new_password, 'New Password', class: 'form-label' %>
|
|
|
|
<%= form.password_field :password, id: :user_password, class: 'form-control', autocomplete: "new-password" %>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="mb-3">
|
|
|
|
<%= form.label :password_confirmation, 'Password Confirmation', class: 'form-label' %>
|
|
|
|
<%= form.password_field :password_confirmation, id: "user_password_confirmation", class: 'form-control', autocomplete: "new-password" %>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
2024-04-09 17:48:54 -05:00
|
|
|
<div class="mb-3">
|
|
|
|
<%= form.label :phone, class: 'form-label' %>
|
|
|
|
<%= form.telephone_field :phone, id: :user_phone, class: 'form-control' %>
|
|
|
|
</div>
|
|
|
|
|
2024-04-03 18:32:15 -05:00
|
|
|
<div class="mb-3">
|
2024-04-09 17:48:54 -05:00
|
|
|
<%= form.label :company, class: 'form-label' %>
|
|
|
|
<%= form.text_field :company, id: :user_company, class: 'form-control' %>
|
2024-02-16 15:13:09 -06:00
|
|
|
</div>
|
|
|
|
|
2024-04-09 17:48:54 -05:00
|
|
|
<div class="mb-3">
|
|
|
|
<%= form.label :roles, 'Assign Role(s)', class: 'form-label' %>
|
|
|
|
<%= form.collection_select :roles, Role.all, :name, :name, {}, { multiple: true, class: 'form-select' } %>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="mb-3">
|
|
|
|
<%= form.check_box :access_revoked, class: 'form-check-input' %>
|
|
|
|
<%= form.label :access_revoked, 'Access Revoked', class: 'form-check-label' %>
|
|
|
|
</div>
|
|
|
|
|
2024-04-12 02:40:09 -05:00
|
|
|
<h3>Access Periods</h3>
|
2024-04-11 23:48:16 -05:00
|
|
|
<table class="table">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th>Access Start Date</th>
|
|
|
|
<th>Access End Date</th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
2024-04-12 02:40:09 -05:00
|
|
|
<% @user.access_periods.order(:start_date).each do |period| %>
|
2024-04-11 23:48:16 -05:00
|
|
|
<tr>
|
2024-04-12 02:40:09 -05:00
|
|
|
<td><%= period.start_date ? period.start_date.strftime("%B %d, %Y") : 'Not set' %></td>
|
|
|
|
<td><%= period.end_date ? period.end_date.strftime("%B %d, %Y") : 'Currently has access' %></td>
|
2024-04-11 23:48:16 -05:00
|
|
|
</tr>
|
|
|
|
<% end %>
|
|
|
|
</tbody>
|
|
|
|
</table>
|
2024-04-12 02:40:09 -05:00
|
|
|
|
|
|
|
<%# Date fields for access control %>
|
|
|
|
<%= form.fields_for :access_periods do |period_form| %>
|
|
|
|
<div class="row">
|
|
|
|
<div class="col-md-5">
|
|
|
|
<%= period_form.label :start_date, 'Access Start Date' %>
|
|
|
|
<%= period_form.date_field :start_date, class: 'form-control' %>
|
|
|
|
</div>
|
|
|
|
<div class="col-md-5">
|
|
|
|
<%= period_form.label :end_date, 'Access End Date' %>
|
|
|
|
<%= period_form.date_field :end_date, class: 'form-control' %>
|
|
|
|
</div>
|
|
|
|
<% if period_form.object.persisted? %>
|
|
|
|
<div class="col-md-2">
|
|
|
|
<%= period_form.check_box :_destroy %>
|
|
|
|
<%= period_form.label :_destroy, 'Remove' %>
|
|
|
|
</div>
|
|
|
|
<% end %>
|
|
|
|
</div>
|
|
|
|
<% end %>
|
2024-04-11 23:48:16 -05:00
|
|
|
|
2024-04-09 17:48:54 -05:00
|
|
|
<%# Submit button %>
|
2024-04-12 02:40:09 -05:00
|
|
|
<div class="actions mt-3">
|
2024-04-11 23:48:16 -05:00
|
|
|
<%= form.submit 'Save', class: 'btn btn-dark' %>
|
|
|
|
</div>
|
2024-04-11 16:40:32 -05:00
|
|
|
|
2024-04-11 23:48:16 -05:00
|
|
|
<% end %>
|