-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[74] Enter Evaluators A11y Fix #343
base: dev
Are you sure you want to change the base?
Changes from 6 commits
ddf39d7
bf53f50
77aa9d7
0dcc23b
e4ecf73
ecdf880
d0b4922
c942595
95e863c
0589077
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ def initialize(challenge, phase) | |
end | ||
|
||
def process_evaluator_invitation(email, invitation_params) | ||
@invitation_params = invitation_params | ||
user = User.find_by(email:) | ||
user ? add_existing_user_as_evaluator(user) : handle_invitation(email, invitation_params) | ||
end | ||
|
@@ -44,6 +45,24 @@ def resend_invitation(invitation) | |
|
||
private | ||
|
||
def update_name_for_existing_user(user) | ||
names = @invitation_params[:full_name].to_s.strip.split(/\s+/, 2) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I feel like it's potentially problematic to duplicate this field parsing logic with the EvaluatorInvitation model, in case things change in the future. Can you extract these into a single function? Something like For the validation error message, you can just have a method that adds those errors directly to the model if |
||
if names.length < 2 | ||
return { | ||
success: false, | ||
message: "First and last name are required" | ||
} | ||
end | ||
|
||
first_name, last_name = names | ||
user.update( | ||
first_name:, | ||
last_name: | ||
) | ||
|
||
{ success: true } | ||
end | ||
|
||
def add_existing_user_as_evaluator(user) | ||
if @phase.evaluators.include?(user) | ||
return { | ||
|
@@ -61,6 +80,9 @@ def add_existing_user_as_evaluator(user) | |
} | ||
end | ||
|
||
updated_name = update_name_for_existing_user(user) | ||
return updated_name unless updated_name[:success] | ||
|
||
cpe = ChallengePhasesEvaluator.find_or_create_by(challenge: @challenge, phase: @phase, user:) | ||
|
||
if cpe.persisted? | ||
|
@@ -101,7 +123,8 @@ def create_new_invitation(invitation_params) | |
else | ||
{ | ||
success: false, | ||
message: invitation.errors.full_messages.join(", ") | ||
message: invitation.errors.full_messages.join(", "), | ||
evaluator_invitation: invitation | ||
} | ||
end | ||
end | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,39 +2,73 @@ | |
<div data-page="manage-evaluators"> | ||
<%= render 'shared/back_link', path: phases_path(@phase) %> | ||
stepchud marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
<h1><%= @challenge.title %> - <%= @phase.title %></h1> | ||
<h1><%= challenge_phase_title(@challenge, @phase) %></h1> | ||
<p>Create and manage a list of evaluators for the challenge.</p> | ||
<h2 class="padding-top-3">Add Evaluators</h2> | ||
<p>Evaluators will not be assigned to submissions until you assign in the submission detail view.</p> | ||
<%= form_with(model: EvaluatorInvitation.new, url: phase_evaluators_path(@phase), method: :post, local: true) do |form| %> | ||
<%= form_with(model: @evaluator_invitation || EvaluatorInvitation.new, url: phase_evaluators_path(@phase), method: :post, local: true, data: { controller: "evaluator-form modal" }, html: { novalidate: true }) do |form| %> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. since you're using the |
||
<%= form.hidden_field :challenge_id, value: @challenge.id %> | ||
<%= form.hidden_field :phase_id, value: @phase.id %> | ||
<%= form.hidden_field :last_invite_sent, value: Time.current %> | ||
|
||
<% if form.object.errors.any? %> | ||
<div style="color: darkred"> | ||
<div class="usa-alert usa-alert--error" role="alert"> | ||
<div class="usa-alert__body"> | ||
<h3 class="usa-alert__heading"> | ||
<%= pluralize(form.object.errors.count, "error") %> prohibited this evaluator from being added: | ||
</h3> | ||
<ul> | ||
<% form.object.errors.each do |error| %> | ||
<li><%= error.full_message %></li> | ||
<% end %> | ||
</ul> | ||
</div> | ||
</div> | ||
</div> | ||
<% end %> | ||
|
||
<div class="usa-form-group"> | ||
<%= form.label :first_name, class: "usa-label font-sans-md" do %> | ||
<span class="text-bold">First Name</span><span class="text-red">*</span> | ||
<% end %> | ||
<div class="usa-hint font-sans-2xs text-normal">Add evaluator's first name.</div> | ||
<%= form.text_field :first_name, class: "usa-input", required: true, autocomplete: "given-name", style: "border: 1.5px solid #565c65;" %> | ||
</div> | ||
<div class="usa-form-group"> | ||
<%= form.label :last_name, class: "usa-label font-sans-md" do %> | ||
<span class="text-bold">Last Name</span><span class="text-red">*</span> | ||
<% end %> | ||
<div class="usa-hint font-sans-2xs text-normal">Add evaluator's last name.</div> | ||
<%= form.text_field :last_name, class: "usa-input", required: true, autocomplete: "family-name", style: "border: 1.5px solid #565c65;" %> | ||
<div class="display-flex flex-align-center text-bold"> | ||
<%= form.label :full_name, class: "usa-label font-sans-md #{label_error_class(form, :first_name)}" do %> | ||
<span class="text-bold">First & Last Name</span><span class="text-red">*</span> | ||
<% end %> | ||
</div> | ||
<%= form.text_field :full_name, | ||
class: "usa-input #{input_error_class(form, :last_name)}", | ||
required: true, | ||
autocomplete: "name", | ||
style: "border: 1.5px solid #565c65;", | ||
data: { | ||
action: "evaluator-form#validatePresence focusout->evaluator-form#validatePresence" | ||
}, | ||
value: form.object.full_name | ||
%> | ||
<%= inline_error(form, :last_name) %> | ||
</div> | ||
|
||
<div class="usa-form-group"> | ||
<%= form.label :email, class: "usa-label font-sans-md" do %> | ||
<span class="text-bold">Email Address</span><span class="text-red">*</span> | ||
<% end %> | ||
<div class="usa-hint font-sans-2xs text-normal">Add a single email address for the individual.</div> | ||
<%= form.email_field :email, class: "usa-input", required: true, autocomplete: "email", style: "border: 1.5px solid #565c65;" %> | ||
<div class="display-flex flex-align-center text-bold"> | ||
<%= form.label :email, class: "usa-label font-sans-md #{label_error_class(form, :email)}" do %> | ||
<span class="text-bold">Email Address</span><span class="text-red">*</span> | ||
<% end %> | ||
</div> | ||
<%= form.email_field :email, | ||
class: "usa-input #{input_error_class(form, :email)}", | ||
required: true, | ||
autocomplete: "email", | ||
style: "border: 1.5px solid #565c65;", | ||
data: { | ||
action: "evaluator-form#validatePresence focusout->evaluator-form#validatePresence" | ||
} | ||
%> | ||
<%= inline_error(form, :email) %> | ||
</div> | ||
|
||
<%= form.button type: 'submit', class: "usa-button margin-top-5 margin-bottom-3" do %> | ||
<%= image_tag('images/usa-icons/person.svg', class: "usa-icon--size-3 icon-white", alt: "Add evaluator") %> | ||
<%= image_tag('images/usa-icons/person.svg', class: "usa-icon--size-3 icon-white", alt: "") %> | ||
<span>Add to evaluator list</span> | ||
<% end %> | ||
<% end %> | ||
<% end %> | ||
|
||
<h2>Evaluator List</h2> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm seeing some inconsistency with the error message display depending on the path it takes. Can we try to ensure that if there are any validation issues with the name(s) missing, that the
First & Last Name
label is always highlighted in red (as it does for new users)?existing user
new user
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The first screenshot is also missing the inline error text label describing the issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is also a case where only the first name is entered,
First & Last Name
label should be red: