Skip to content

Commit

Permalink
Inline form_fields partial into users edit template
Browse files Browse the repository at this point in the history
I'm doing some reorganisation of this page as part of the move to use
the GOV.UK Design System. Doing this first will make that easier.
  • Loading branch information
floehopper committed Nov 30, 2023
1 parent ab651af commit b0a4256
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 83 deletions.
82 changes: 0 additions & 82 deletions app/views/users/_form_fields.html.erb

This file was deleted.

83 changes: 82 additions & 1 deletion app/views/users/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,88 @@
<% end %>

<%= form_for @user, :html => {:class => 'well add-top-margin'} do |f| %>
<%= render partial: "form_fields", locals: { f: f } %>
<p>
<strong>Name:</strong> <%= @user.name %>
<%= link_to edit_user_name_path(@user) do %>
Change<span class="invisible"> name</span>
<% end %>
</p>

<p>
<strong>Email:</strong> <%= @user.email %>
<%= link_to edit_user_email_path(@user) do %>
Change<span class="invisible"> email</span>
<% end %>
</p>

<p>
<strong>Role:</strong> <%= @user.role.humanize %>
<% if policy(User).assign_role? %>
<%= link_to edit_user_role_path(@user) do %>
Change<span class="invisible"> role</span>
<% end %>
<% end %>
</p>

<p>
<strong>Organisation:</strong> <%= @user.organisation.present? ? @user.organisation.name : Organisation::NONE %>
<% if policy(User).assign_organisation? %>
<%= link_to edit_user_organisation_path(@user) do %>
Change<span class="invisible"> organisation</span>
<% end %>
<% end %>
</p>

<dl>
<dt>Account security</dt>
<dd>
<% if @user.exempt_from_2sv? %>
<p>
The user has been made exempt from 2-step verification for the following reason: <%= @user.reason_for_2sv_exemption %>
<% if policy(@user).exempt_from_two_step_verification? %>
<br>
<%= link_to 'Edit reason or expiry date for 2-step verification exemption', edit_two_step_verification_exemption_path(@user) %>
<% end %>
</p>
<% elsif @user.has_2sv? %>
<p>2-step verification enabled</p>
<p>
<%= link_to 'Reset 2-step verification', edit_user_two_step_verification_reset_path(@user) %>
</p>
<% elsif @user.require_2sv? %>
<p>2-step verification required but not set up</p>
<% else %>
<p>2-step verification not set up</p>
<% end %>

<% unless @user.require_2sv? %>
<% if policy(@user).mandate_2sv? %>
<p>
<%= link_to(
"Mandate 2-step verification for this user#{@user.exempt_from_2sv? ? ' (this will remove their exemption)' : nil}",
edit_user_two_step_verification_mandation_path(@user)
) %>
</p>
<% end %>
<% end %>

<% if policy(@user).exempt_from_two_step_verification? && !@user.exempt_from_2sv? %>
<p>
<%= link_to 'Exempt user from 2-step verification', edit_two_step_verification_exemption_path(@user) %>
<br/>
Exempt a user from 2-step verification (requires a reason to be supplied).
</p>
<% end %>
</dd>
</dl>

<h2 class="add-vertical-margins"> <%= "Editable " if (current_user.publishing_manager? ) %>Permissions</h2>
<%= render partial: "shared/user_permissions", locals: { user_object: @user }%>

<% if current_user.publishing_manager? %>
<h2 class="add-vertical-margins">All Permissions for this user</h2>
<%= render partial: "app_permissions", locals: { user_object: @user }%>
<% end %>

<hr>

Expand Down

0 comments on commit b0a4256

Please sign in to comment.