-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[305] Submission Details - Judging Status and Comments (#318)
* working single form approach * disabling checkboxes with javascript --------- Co-authored-by: Stephen Chudleigh <[email protected]> Co-authored-by: Stephen Chudleigh <[email protected]>
- Loading branch information
1 parent
0788919
commit 7f4a480
Showing
9 changed files
with
133 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
app/javascript/controllers/submission_details_controller.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { Controller } from "@hotwired/stimulus" | ||
|
||
// Connects to data-controller="submission-details" | ||
export default class extends Controller { | ||
static targets = ["judgingStatusHidden", "eligibleCheckbox", "winnerCheckbox"]; | ||
|
||
eligibleCheck(e) { | ||
if (e.target.checked) { | ||
this.judgingStatusHiddenTarget.value = "selected" | ||
this.winnerCheckboxTarget.disabled = false | ||
} else { | ||
this.judgingStatusHiddenTarget.value = "not_selected" | ||
this.winnerCheckboxTarget.disabled = true | ||
} | ||
} | ||
|
||
selectedCheck(e) { | ||
if (e.target.checked) { | ||
this.judgingStatusHiddenTarget.value = "winner" | ||
this.eligibleCheckboxTarget.disabled = true | ||
} else { | ||
this.judgingStatusHiddenTarget.value = "selected" | ||
this.eligibleCheckboxTarget.disabled = false | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<div data-controller="submission-details"> | ||
<% rand = SecureRandom.hex(8) %> | ||
<%= form_with(model: @submission, url: submission_path(@submission), class: "maxw-mobile-lg") do |form| %> | ||
<div class="usa-checkbox" id="eligible-for-evaluation"> | ||
<input | ||
class="usa-checkbox__input usa-checkbox__input--tile" | ||
type="checkbox" | ||
id="<%= "#{rand}-judging-status-selected" %>" | ||
value="selected" | ||
<%= if @submission.judging_status == "winner" then "disabled" end %> | ||
<%= "checked" if @submission.judging_status.in?(["selected", "winner"]) %> | ||
data-action="change->submission-details#eligibleCheck" | ||
data-submission-details-target="eligibleCheckbox" | ||
/> | ||
<label class="usa-checkbox__label" for="<%= "#{rand}-judging-status-selected" %>" | ||
>This submission is eligible for evaluation. | ||
<span class="usa-checkbox__label-description" | ||
>Check the box if the submission is pre-screened and is eligible for the evaluation process.</span | ||
></label | ||
> | ||
</div> | ||
<div class="usa-checkbox" id="selected-to-advance"> | ||
<input | ||
class="usa-checkbox__input usa-checkbox__input--tile" | ||
id="<%= "#{rand}-judging-status-winner" %>" | ||
type="checkbox" | ||
<%= "disabled" unless @submission.judging_status.in?(["selected", "winner"]) %> | ||
<%= "checked" if @submission.judging_status == "winner" %> | ||
data-action="change->submission-details#selectedCheck" | ||
data-submission-details-target="winnerCheckbox" | ||
/> | ||
<label class="usa-checkbox__label" for="<%= "#{rand}-judging-status-winner" %>" | ||
>This submission is selected to advance. | ||
<span class="usa-checkbox__label-description" | ||
>Check the box to select this submission to advance or for award after all evaluations are completed.</span | ||
></label | ||
> | ||
</div> | ||
<input | ||
id="judging-status-hidden" | ||
type="hidden" | ||
name="submission[judging_status]" | ||
data-submission-details-target="judgingStatusHidden" | ||
/> | ||
<div class="usa-form-group"> | ||
<%= form.label :comments, "Comments and notes:", class: "usa-label" %> | ||
<%= form.text_area :comments, class: "usa-textarea", default: @submission.comments %> | ||
</div> | ||
<button type="submit" name="commit" class="usa-button font-body-2xs text-no-wrap margin-y-2"> | ||
Save | ||
</button> | ||
<% end %> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
<h1>Submission ID <%= @submission.id %></h1> | ||
<p class="text-normal">View submission information and assign evaluators to evaluate the submission.</p> | ||
<h2 class="font-body-sm text-normal">View submission information and assign evaluators to evaluate the submission.</h2> | ||
|
||
<%= render partial: "layouts/hotdog", locals: {left: 'submissions/comment_form', right: 'submissions/submission_materials', name: 'Submission Materials'} %> | ||
<%= render partial: "layouts/hotdog", locals: {left: 'submissions/submission_details', right: 'submissions/submission_materials', name: 'Submission Materials'} %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,5 +8,6 @@ | |
|
||
title { Faker::Lorem.sentence } | ||
status { "draft" } | ||
external_url { "www.example.com" } | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
|
||
describe "A11y", :js do | ||
describe "Logged-in as a Challenge Manager" do | ||
let(:user) { create_user(role: "challenge_manager") } | ||
let(:challenge) { create_challenge(user: user, title: "Boston Tea Party Cleanup") } | ||
let(:submission) { create(:submission, manager: user, challenge: challenge) } | ||
|
||
|
||
before { system_login_user(user) } | ||
|
||
it "submission details page is accessible" do | ||
visit submission_path(submission) | ||
expect(user.role).to eq("challenge_manager") | ||
expect(page).to have_css('h1', text: "Submission ID #{submission.id}") | ||
expect(page).to(be_axe_clean) | ||
end | ||
|
||
it "allows manipulation of judging status" do | ||
visit submission_path(submission) | ||
|
||
find_by_id('eligible-for-evaluation').click | ||
click_on('Save') | ||
updated_submission = Submission.find(submission.id) | ||
expect(updated_submission.judging_status).to eq('selected') | ||
|
||
find_by_id('selected-to-advance').click | ||
click_on('Save') | ||
updated_submission = Submission.find(submission.id) | ||
expect(updated_submission.judging_status).to eq('winner') | ||
end | ||
|
||
it "saves comments" do | ||
visit submission_path(submission) | ||
comments = Faker::Lorem.sentence | ||
|
||
fill_in "Comments and notes:", with: comments | ||
click_on('Save') | ||
updated_submission = Submission.find(submission.id) | ||
expect(updated_submission.comments).to eq(comments) | ||
end | ||
end | ||
end |