From 40ce276dfbba255f9e3a46efab4ae68db4df4d97 Mon Sep 17 00:00:00 2001 From: Stone Filipczak Date: Mon, 9 Dec 2024 17:24:22 -0500 Subject: [PATCH 01/46] working --- app/controllers/submissions_controller.rb | 2 +- app/javascript/controllers/index.js | 16 +++-- .../submission_details_controller.js | 22 +++++++ .../submissions/_judging_status.html.erb | 58 +++++++++++++++++++ app/views/submissions/show.html.erb | 1 + 5 files changed, 92 insertions(+), 7 deletions(-) create mode 100644 app/javascript/controllers/submission_details_controller.js create mode 100644 app/views/submissions/_judging_status.html.erb diff --git a/app/controllers/submissions_controller.rb b/app/controllers/submissions_controller.rb index b0fa2af9..b5f74a5f 100644 --- a/app/controllers/submissions_controller.rb +++ b/app/controllers/submissions_controller.rb @@ -19,7 +19,7 @@ def update private def submission_params - params.require(:submission).permit(:comments) + params.require(:submission).permit(:comments, :judging_status) end # User access enforced by role diff --git a/app/javascript/controllers/index.js b/app/javascript/controllers/index.js index 076ccf60..994b676b 100644 --- a/app/javascript/controllers/index.js +++ b/app/javascript/controllers/index.js @@ -2,12 +2,16 @@ // Run that command whenever you add a new controller or create them with // ./bin/rails generate stimulus controllerName -import { application } from "./application"; - -import EvaluationFormController from "./evaluation_form_controller"; -import EvaluationCriteriaController from "./evaluation_criteria_controller"; -application.register("evaluation-form", EvaluationFormController); -application.register("evaluation-criteria", EvaluationCriteriaController); +import { application } from "./application" import DeleteEvaluatorModalController from "./delete_evaluator_modal_controller" application.register("delete-evaluator-modal", DeleteEvaluatorModalController) + +import EvaluationCriteriaController from "./evaluation_criteria_controller" +application.register("evaluation-criteria", EvaluationCriteriaController) + +import EvaluationFormController from "./evaluation_form_controller" +application.register("evaluation-form", EvaluationFormController) + +import SubmissionDetailsController from "./submission_details_controller" +application.register("submission-details", SubmissionDetailsController) diff --git a/app/javascript/controllers/submission_details_controller.js b/app/javascript/controllers/submission_details_controller.js new file mode 100644 index 00000000..81eed370 --- /dev/null +++ b/app/javascript/controllers/submission_details_controller.js @@ -0,0 +1,22 @@ +import { Controller } from "@hotwired/stimulus" + +// Connects to data-controller="submission-details" +export default class extends Controller { + static targets = ["qualifiedForm", "selectedForm"] + + selectedSubmit(e) { + if (e.target.checked) { + e.target.form.submit() + } else { + this.qualifiedFormTarget.submit() + } + } + + winnerSubmit(e) { + if (e.target.checked) { + e.target.form.submit() + } else { + this.selectedFormTarget.submit() + } + } +} diff --git a/app/views/submissions/_judging_status.html.erb b/app/views/submissions/_judging_status.html.erb new file mode 100644 index 00000000..addbf995 --- /dev/null +++ b/app/views/submissions/_judging_status.html.erb @@ -0,0 +1,58 @@ +
+ <%= form_with(model: @submission, url: submission_path(@submission), class: "width-mobile-lg") do |form| %> +
+ + data-action="change->submission-details#selectedSubmit" + /> + +
+ <% end %> + <%= form_with(model: @submission, url: submission_path(@submission), class: "width-mobile-lg") do |form| %> +
+ + data-action="change->submission-details#winnerSubmit" + /> + +
+ <% end %> + <%= form_with(model: @submission, url: submission_path(@submission), class: "width-mobile-lg", data: {"submission-details-target": "qualifiedForm"}) do |form| %> + + <% end %> + <%= form_with(model: @submission, url: submission_path(@submission), class: "width-mobile-lg", data: {"submission-details-target": "selectedForm"}) do |form| %> + + <% end %> +
\ No newline at end of file diff --git a/app/views/submissions/show.html.erb b/app/views/submissions/show.html.erb index 5f74664e..cb13bfea 100644 --- a/app/views/submissions/show.html.erb +++ b/app/views/submissions/show.html.erb @@ -1,5 +1,6 @@

Submission ID <%= @submission.id %>

View submission information and assign evaluators to evaluate the submission.

+<%= render partial: "judging_status" %> <%= render partial: "submission_materials" %> <%= render partial: "comment_form" %> \ No newline at end of file From 3f1e16da6e0323bc425d841d2c8693eee207fd02 Mon Sep 17 00:00:00 2001 From: Stone Filipczak Date: Tue, 10 Dec 2024 09:29:06 -0500 Subject: [PATCH 02/46] disabling and verbage --- app/controllers/submissions_controller.rb | 2 +- app/views/submissions/_judging_status.html.erb | 10 ++++++---- config/locales/en.yml | 1 + 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/app/controllers/submissions_controller.rb b/app/controllers/submissions_controller.rb index b5f74a5f..93d5f1bc 100644 --- a/app/controllers/submissions_controller.rb +++ b/app/controllers/submissions_controller.rb @@ -9,7 +9,7 @@ def show; end def update if @submission.update!(submission_params) - flash.now[:success] = I18n.t("comments_saved") + flash.now[:success] = I18n.t("submission_updated") render :show, submission: @submission else render :show, status: :unprocessable_entity, submission: @submission diff --git a/app/views/submissions/_judging_status.html.erb b/app/views/submissions/_judging_status.html.erb index addbf995..f92f828d 100644 --- a/app/views/submissions/_judging_status.html.erb +++ b/app/views/submissions/_judging_status.html.erb @@ -1,5 +1,5 @@
- <%= form_with(model: @submission, url: submission_path(@submission), class: "width-mobile-lg") do |form| %> + <%= form_with(model: @submission, url: submission_path(@submission), class: "maxw-mobile-lg") do |form| %>
<%= if @submission.judging_status.in?(["selected", "winner"]) then "checked" end %> data-action="change->submission-details#selectedSubmit" /> @@ -18,7 +19,7 @@ >
<% end %> - <%= form_with(model: @submission, url: submission_path(@submission), class: "width-mobile-lg") do |form| %> + <%= form_with(model: @submission, url: submission_path(@submission), class: "maxw-mobile-lg") do |form| %>
<%= if @submission.judging_status == "winner" then "checked" end %> data-action="change->submission-details#winnerSubmit" /> @@ -37,7 +39,7 @@ >
<% end %> - <%= form_with(model: @submission, url: submission_path(@submission), class: "width-mobile-lg", data: {"submission-details-target": "qualifiedForm"}) do |form| %> + <%= form_with(model: @submission, url: submission_path(@submission), data: {"submission-details-target": "qualifiedForm"}) do |form| %> <% end %> - <%= form_with(model: @submission, url: submission_path(@submission), class: "width-mobile-lg", data: {"submission-details-target": "selectedForm"}) do |form| %> + <%= form_with(model: @submission, url: submission_path(@submission), data: {"submission-details-target": "selectedForm"}) do |form| %> Date: Tue, 10 Dec 2024 11:32:20 -0500 Subject: [PATCH 03/46] specs --- .../submissions/_judging_status.html.erb | 4 +- app/views/submissions/show.html.erb | 2 +- spec/factories/submission.rb | 1 + spec/system/submission_details_spec.rb | 43 +++++++++++++++++++ 4 files changed, 47 insertions(+), 3 deletions(-) create mode 100644 spec/system/submission_details_spec.rb diff --git a/app/views/submissions/_judging_status.html.erb b/app/views/submissions/_judging_status.html.erb index f92f828d..ccfa3c1b 100644 --- a/app/views/submissions/_judging_status.html.erb +++ b/app/views/submissions/_judging_status.html.erb @@ -42,7 +42,7 @@ <%= form_with(model: @submission, url: submission_path(@submission), data: {"submission-details-target": "qualifiedForm"}) do |form| %> Submission ID <%= @submission.id %> -

View submission information and assign evaluators to evaluate the submission.

+

View submission information and assign evaluators to evaluate the submission.

<%= render partial: "judging_status" %> <%= render partial: "submission_materials" %> diff --git a/spec/factories/submission.rb b/spec/factories/submission.rb index 6f740bb9..f1be95be 100644 --- a/spec/factories/submission.rb +++ b/spec/factories/submission.rb @@ -8,5 +8,6 @@ title { Faker::Lorem.sentence } status { "draft" } + external_url { "www.example.com" } end end diff --git a/spec/system/submission_details_spec.rb b/spec/system/submission_details_spec.rb new file mode 100644 index 00000000..2eed73ba --- /dev/null +++ b/spec/system/submission_details_spec.rb @@ -0,0 +1,43 @@ +# 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_content(submission.id) + expect(page).to(be_axe_clean) + end + + it "allows manipulation of judging status" do + visit submission_path(submission) + + check('This submission is eligible for evaluation', allow_label_click: true) + updated_submission = Submission.find(submission.id) + expect(updated_submission.judging_status).to eq('selected') + + check('This submission is selected to advance', allow_label_click: true) + 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 From ff410ccb8cf0a68bdb1f6c1e5b4eb7506f4256c0 Mon Sep 17 00:00:00 2001 From: Stone Filipczak Date: Tue, 10 Dec 2024 11:33:28 -0500 Subject: [PATCH 04/46] reorder --- app/views/submissions/show.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/submissions/show.html.erb b/app/views/submissions/show.html.erb index 4d2c4584..bb80990e 100644 --- a/app/views/submissions/show.html.erb +++ b/app/views/submissions/show.html.erb @@ -2,5 +2,5 @@

View submission information and assign evaluators to evaluate the submission.

<%= render partial: "judging_status" %> +<%= render partial: "comment_form" %> <%= render partial: "submission_materials" %> -<%= render partial: "comment_form" %> \ No newline at end of file From 21456369f60cdb7cf78bfa2993128da544b68af5 Mon Sep 17 00:00:00 2001 From: Stone Filipczak Date: Tue, 10 Dec 2024 12:56:47 -0500 Subject: [PATCH 05/46] render everything --- app/views/submissions/_submission_details.html.erb | 2 ++ app/views/submissions/show.html.erb | 8 +------- 2 files changed, 3 insertions(+), 7 deletions(-) create mode 100644 app/views/submissions/_submission_details.html.erb diff --git a/app/views/submissions/_submission_details.html.erb b/app/views/submissions/_submission_details.html.erb new file mode 100644 index 00000000..e6a177ed --- /dev/null +++ b/app/views/submissions/_submission_details.html.erb @@ -0,0 +1,2 @@ +<%= render partial: 'judging_status' %> +<%= render partial: 'comment_form' %> diff --git a/app/views/submissions/show.html.erb b/app/views/submissions/show.html.erb index deb2a524..ba16d732 100644 --- a/app/views/submissions/show.html.erb +++ b/app/views/submissions/show.html.erb @@ -1,10 +1,4 @@

Submission ID <%= @submission.id %>

View submission information and assign evaluators to evaluate the submission.

-<<<<<<< HEAD -<%= render partial: "judging_status" %> -<%= render partial: "comment_form" %> -<%= render partial: "submission_materials" %> -======= -<%= render partial: "layouts/hotdog", locals: {left: 'submissions/comment_form', right: 'submissions/submission_materials', name: 'Submission Materials'} %> ->>>>>>> dev +<%= render partial: "layouts/hotdog", locals: {left: 'submissions/submission_details', right: 'submissions/submission_materials', name: 'Submission Materials'} %> From a10efbb1ab2945a93132bd8efd5282482ffa2d02 Mon Sep 17 00:00:00 2001 From: Stone Filipczak Date: Tue, 10 Dec 2024 13:24:44 -0500 Subject: [PATCH 06/46] fix spec --- app/views/submissions/_judging_status.html.erb | 4 ++-- spec/system/submission_details_spec.rb | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/views/submissions/_judging_status.html.erb b/app/views/submissions/_judging_status.html.erb index ccfa3c1b..c15eeca1 100644 --- a/app/views/submissions/_judging_status.html.erb +++ b/app/views/submissions/_judging_status.html.erb @@ -1,6 +1,6 @@
<%= form_with(model: @submission, url: submission_path(@submission), class: "maxw-mobile-lg") do |form| %> -
+
<% end %> <%= form_with(model: @submission, url: submission_path(@submission), class: "maxw-mobile-lg") do |form| %> -
+
Date: Thu, 12 Dec 2024 11:43:51 -0500 Subject: [PATCH 07/46] initialize --- app/views/submissions/_submission_details.html.erb | 5 +++++ app/views/submissions/_submission_evaluation.html.erb | 1 + 2 files changed, 6 insertions(+) create mode 100644 app/views/submissions/_submission_evaluation.html.erb diff --git a/app/views/submissions/_submission_details.html.erb b/app/views/submissions/_submission_details.html.erb index e6a177ed..85b43c55 100644 --- a/app/views/submissions/_submission_details.html.erb +++ b/app/views/submissions/_submission_details.html.erb @@ -1,2 +1,7 @@ <%= render partial: 'judging_status' %> <%= render partial: 'comment_form' %> +<% if @submission.judging_status.in?(["selected", "winner"]) %> + <%= render partial: 'submission_evaluation' %> +<% end %> + + diff --git a/app/views/submissions/_submission_evaluation.html.erb b/app/views/submissions/_submission_evaluation.html.erb new file mode 100644 index 00000000..6313a735 --- /dev/null +++ b/app/views/submissions/_submission_evaluation.html.erb @@ -0,0 +1 @@ +Submission Evaluation \ No newline at end of file From e321bf7cfa79bbc25be7a69b4425f713bac01eec Mon Sep 17 00:00:00 2001 From: Stone Filipczak Date: Thu, 12 Dec 2024 14:13:00 -0500 Subject: [PATCH 08/46] missing evaluation form --- app/views/shared/_alert_error.html.erb | 2 +- app/views/submissions/_submission_evaluation.html.erb | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/views/shared/_alert_error.html.erb b/app/views/shared/_alert_error.html.erb index dce010d2..c817ce60 100644 --- a/app/views/shared/_alert_error.html.erb +++ b/app/views/shared/_alert_error.html.erb @@ -1,5 +1,5 @@
-
+