Skip to content

Commit

Permalink
Merge pull request #2096 from DFE-Digital/redesign-personas
Browse files Browse the repository at this point in the history
Improve personas design
  • Loading branch information
thomasleese authored Mar 26, 2024
2 parents 67c0846 + f749af8 commit 96cacfd
Show file tree
Hide file tree
Showing 8 changed files with 212 additions and 214 deletions.
28 changes: 26 additions & 2 deletions app/controllers/personas_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@ class PersonasController < ApplicationController
include EligibilityCurrentNamespace

before_action :ensure_feature_active
before_action :load_teacher_personas, :load_eligible_personas, only: :index

before_action :load_staff_personas,
:load_teacher_personas,
:load_eligible_personas,
only: :index

def index
@staff = Staff.all
render layout: "full_from_desktop"
end

def eligible_sign_in
Expand Down Expand Up @@ -113,13 +117,28 @@ def load_eligible_personas
end
end

def load_staff_personas
@staff_personas =
Staff.order(
assess_permission: :desc,
change_name_permission: :desc,
change_work_history_permission: :desc,
reverse_decision_permission: :desc,
support_console_permission: :desc,
verify_permission: :desc,
withdraw_permission: :desc,
email: :asc,
)
end

TEACHER_PERSONAS =
%w[online written none]
.product(
%w[online written none],
%w[
draft
not_started
waiting_on_lops
waiting_on_consent
waiting_on_further_information
awarded
Expand Down Expand Up @@ -155,6 +174,11 @@ def load_teacher_personas

stage_or_status = persona[:stage_or_status]

if stage_or_status == "waiting_on_lops" &&
!application_form.teaching_authority_provides_written_statement
next
end

application_form.stage == stage_or_status ||
application_form.statuses.include?(stage_or_status)
end
Expand Down
38 changes: 38 additions & 0 deletions app/views/personas/_eligible_checks.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<%= govuk_table(classes: "app-personas") do |table|
table.with_head do |head|
head.with_row do |row|
row.with_cell(header: true, text: "Bucket")
row.with_cell(header: true, text: "Country/Region")
row.with_cell(header: true, text: "Status check")
row.with_cell(header: true, text: "Sanction check")
row.with_cell(header: true, text: "Skips work history")
row.with_cell(header: true, text: "Teaching authority provides written statement")
row.with_cell(header: true, text: "Reduced evidence accepted")
row.with_cell(header: true)
end
end

table.with_body do |body|
@eligible_personas.each do |persona|
body.with_row do |row|
row.with_cell do
bucket = region_bucket_for_persona(persona)
govuk_tag(text: bucket) if bucket
end

row.with_cell { CountryName.from_region(persona[:region]) }

row.with_cell { persona_check_tag(persona[:status_check]) }
row.with_cell { persona_check_tag(persona[:sanction_check]) }

row.with_cell { govuk_boolean_tag(persona[:application_form_skip_work_history]) }
row.with_cell { govuk_boolean_tag(persona[:teaching_authority_provides_written_statement]) }
row.with_cell { govuk_boolean_tag(persona[:reduced_evidence_accepted]) }

row.with_cell(numeric: true) do
govuk_button_to "Sign&nbsp;in".html_safe, eligible_sign_in_persona_path(persona[:region])
end
end
end
end
end %>
1 change: 1 addition & 0 deletions app/views/personas/_ineligible_checks.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<%= govuk_button_to "Sign&nbsp;in".html_safe, ineligible_sign_in_personas_path %>
47 changes: 47 additions & 0 deletions app/views/personas/_staff.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<%= govuk_table(classes: "app-personas") do |table|
table.with_colgroup do |colgroup|
colgroup.with_col(span: 1)
colgroup.with_col(span: 7)
colgroup.with_col(span: 1)
end

table.with_head do |head|
head.with_row do |row|
row.with_cell(scope: false)
row.with_cell(header: true, text: "Permissions", colspan: 7)
row.with_cell(scope: false)
end

head.with_row do |row|
row.with_cell(header: true, text: "Email")
row.with_cell(header: true, text: "Assess")
row.with_cell(header: true, text: "Change names")
row.with_cell(header: true, text: "Change work history")
row.with_cell(header: true, text: "Reverse decisions")
row.with_cell(header: true, text: "Support console")
row.with_cell(header: true, text: "Verify")
row.with_cell(header: true, text: "Withdraw")
row.with_cell(header: true)
end
end

table.with_body do |body|
@staff_personas.each do |staff|
body.with_row do |row|
row.with_cell(text: staff.email)

row.with_cell { govuk_boolean_tag(staff.assess_permission) }
row.with_cell { govuk_boolean_tag(staff.change_name_permission) }
row.with_cell { govuk_boolean_tag(staff.change_work_history_permission) }
row.with_cell { govuk_boolean_tag(staff.reverse_decision_permission) }
row.with_cell { govuk_boolean_tag(staff.support_console_permission) }
row.with_cell { govuk_boolean_tag(staff.verify_permission) }
row.with_cell { govuk_boolean_tag(staff.withdraw_permission) }

row.with_cell(numeric: true) do
govuk_button_to "Sign&nbsp;in ".html_safe, staff_sign_in_persona_path(staff)
end
end
end
end
end %>
36 changes: 36 additions & 0 deletions app/views/personas/_teachers.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<%= govuk_table(classes: "app-personas") do |table|
table.with_head do |head|
head.with_row do |row|
row.with_cell(header: true, text: "Bucket")
row.with_cell(header: true, text: "Country")
row.with_cell(header: true, text: "Status check")
row.with_cell(header: true, text: "Sanction check")
row.with_cell(header: true, text: "Stage/status")
row.with_cell(header: true, text: "Email address")
row.with_cell(header: true)
end
end

table.with_body do |body|
@teacher_personas.each do |persona|
body.with_row do |row|
row.with_cell do
bucket = region_bucket_for_persona(persona)
govuk_tag(text: bucket) if bucket
end
row.with_cell { CountryName.from_country(persona[:application_form].country) }

row.with_cell { persona_check_tag(persona[:status_check]) }
row.with_cell { persona_check_tag(persona[:sanction_check]) }
row.with_cell do
render(StatusTag::Component.new(persona[:stage_or_status]))
end
row.with_cell { persona[:teacher].email }

row.with_cell(numeric: true) do
govuk_button_to "Sign&nbsp;in".html_safe, teacher_sign_in_persona_path(persona[:teacher])
end
end
end
end
end %>
160 changes: 6 additions & 154 deletions app/views/personas/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,157 +2,9 @@

<h1 class="govuk-heading-xl">Personas</h1>

<section id="app-personas-staff" class="app-personas">
<h2 class="govuk-heading-l">Staff</h2>

<% if @staff.empty? %>
<p class="govuk-body">No staff personas.</p>
<% else %>
<%= govuk_table do |table|
table.with_colgroup do |colgroup|
colgroup.with_col(span: 1)
colgroup.with_col(span: 7)
colgroup.with_col(span: 1)
end

table.with_head do |head|
head.with_row do |row|
row.with_cell(scope: false)
row.with_cell(header: true, text: "Permissions", colspan: 7)
row.with_cell(scope: false)
end

head.with_row do |row|
row.with_cell(header: true, text: "Email")
row.with_cell(header: true, text: "Assess applicants")
row.with_cell(header: true, text: "Change names")
row.with_cell(header: true, text: "Change work history")
row.with_cell(header: true, text: "Reverse decisions")
row.with_cell(header: true, text: "Support console")
row.with_cell(header: true, text: "Verify applicants")
row.with_cell(header: true, text: "Withdraw")
row.with_cell(header: true, text: "Actions", numeric: true)
end
end

table.with_body do |body|
@staff.each do |staff|
body.with_row do |row|
row.with_cell(text: staff.email)

row.with_cell { govuk_boolean_tag(staff.assess_permission) }
row.with_cell { govuk_boolean_tag(staff.change_name_permission) }
row.with_cell { govuk_boolean_tag(staff.change_work_history_permission) }
row.with_cell { govuk_boolean_tag(staff.reverse_decision_permission) }
row.with_cell { govuk_boolean_tag(staff.support_console_permission) }
row.with_cell { govuk_boolean_tag(staff.verify_permission) }
row.with_cell { govuk_boolean_tag(staff.withdraw_permission) }

row.with_cell(numeric: true) do
govuk_button_to "Sign&nbsp;in".html_safe, staff_sign_in_persona_path(staff)
end
end
end
end
end %>
<% end %>
</section>

<section id="app-personas-eligibles" class="app-personas">
<h2 class="govuk-heading-l">Eligible checks</h2>

<% if @eligible_personas.empty? %>
<p class="govuk-body">No eligible personas.</p>
<% else %>
<%= govuk_table do |table|
table.with_head do |head|
head.with_row do |row|
row.with_cell(header: true, text: "Bucket")
row.with_cell(header: true, text: "Country/Region")
row.with_cell(header: true, text: "Status check")
row.with_cell(header: true, text: "Sanction check")
row.with_cell(header: true, text: "Skips work history")
row.with_cell(header: true, text: "Teaching authority provides written statement")
row.with_cell(header: true, text: "Reduced evidence accepted")
row.with_cell(header: true, text: "Actions", numeric: true)
end
end

table.with_body do |body|
@eligible_personas.each do |persona|
body.with_row do |row|
row.with_cell do
bucket = region_bucket_for_persona(persona)
govuk_tag(text: bucket) if bucket
end

row.with_cell { CountryName.from_region(persona[:region]) }

row.with_cell { persona_check_tag(persona[:status_check]) }
row.with_cell { persona_check_tag(persona[:sanction_check]) }

row.with_cell { govuk_boolean_tag(persona[:application_form_skip_work_history]) }
row.with_cell { govuk_boolean_tag(persona[:teaching_authority_provides_written_statement]) }
row.with_cell { govuk_boolean_tag(persona[:reduced_evidence_accepted]) }

row.with_cell(numeric: true) do
govuk_button_to "Sign&nbsp;in".html_safe, eligible_sign_in_persona_path(persona[:region])
end
end
end
end
end %>
<% end %>
</section>

<section id="app-personas-ineligibles" class="app-personas">
<h2 class="govuk-heading-l">Ineligible check</h2>
<p class="govuk-body">
<%= govuk_button_to "Sign&nbsp;in".html_safe, ineligible_sign_in_personas_path %>
</p>
</section>

<section id="app-personas-teachers" class="app-personas">
<h2 class="govuk-heading-l">Teachers</h2>

<% if @teacher_personas.empty? %>
<p class="govuk-body">No teacher personas.</p>
<% else %>
<%= govuk_table do |table|
table.with_head do |head|
head.with_row do |row|
row.with_cell(header: true, text: "Bucket")
row.with_cell(header: true, text: "Country")
row.with_cell(header: true, text: "Status check")
row.with_cell(header: true, text: "Sanction check")
row.with_cell(header: true, text: "Stage/status")
row.with_cell(header: true, text: "Email address")
row.with_cell(header: true, text: "Actions", numeric: true)
end
end

table.with_body do |body|
@teacher_personas.each do |persona|
body.with_row do |row|
row.with_cell do
bucket = region_bucket_for_persona(persona)
govuk_tag(text: bucket) if bucket
end
row.with_cell { CountryName.from_country(persona[:application_form].country) }

row.with_cell { persona_check_tag(persona[:status_check]) }
row.with_cell { persona_check_tag(persona[:sanction_check]) }
row.with_cell do
render(StatusTag::Component.new(persona[:stage_or_status]))
end
row.with_cell { persona[:teacher].email }

row.with_cell(numeric: true) do
govuk_button_to "Sign&nbsp;in".html_safe, teacher_sign_in_persona_path(persona[:teacher])
end
end
end
end
end %>
<% end %>
</section>
<%= govuk_tabs(title: "Contents") do |tabs|
tabs.with_tab(label: "Staff") { render "staff" }
tabs.with_tab(label: "Eligible checks") { render "eligible_checks" }
tabs.with_tab(label: "Ineligible checks") { render "ineligible_checks" }
tabs.with_tab(label: "Teachers") { render "teachers" }
end %>
Loading

0 comments on commit 96cacfd

Please sign in to comment.