From 64b984195e96aad797ab35642c655278f39e6a28 Mon Sep 17 00:00:00 2001 From: Chris Preisinger Date: Thu, 17 Oct 2024 22:24:13 -0400 Subject: [PATCH 01/23] 162 Initial eval criteria commit for eval form --- Gemfile.lock | 24 ++--- .../evaluation_forms_controller.rb | 6 +- app/helpers/evaluation_forms_helper.rb | 20 +++++ app/javascript/application.js | 1 + app/javascript/evaluation_criteria.js | 90 +++++++++++++++++++ app/models/evaluation_criterion.rb | 2 - app/models/evaluation_form.rb | 24 ++++- .../_evaluation_criterion_fields.html.erb | 49 ++++++++++ app/views/evaluation_forms/_form.html.erb | 29 +++++- config/initializers/inflections.rb | 5 +- config/locales/en.yml | 4 +- ...ue_title_index_from_evaluation_criteria.rb | 6 ++ db/structure.sql | 8 +- package.json | 1 + yarn.lock | 5 ++ 15 files changed, 245 insertions(+), 29 deletions(-) create mode 100644 app/javascript/evaluation_criteria.js create mode 100644 app/views/evaluation_forms/_evaluation_criterion_fields.html.erb create mode 100644 db/migrate/20241017172408_remove_unique_title_index_from_evaluation_criteria.rb diff --git a/Gemfile.lock b/Gemfile.lock index 7082c283..0a442425 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -154,7 +154,7 @@ GEM jsbundling-rails (1.3.1) railties (>= 6.0.0) json (2.7.2) - jwt (2.9.1) + jwt (2.9.3) base64 language_server-protocol (3.17.0.3) logger (1.6.1) @@ -171,10 +171,10 @@ GEM method_source (1.1.0) mini_mime (1.1.5) minitest (5.25.1) - msgpack (1.7.2) + msgpack (1.7.3) net-http (0.4.1) uri - net-imap (0.4.16) + net-imap (0.4.17) date net-protocol net-pop (0.1.2) @@ -201,7 +201,7 @@ GEM ast (~> 2.4.1) racc pg (1.5.8) - prism (1.0.0) + prism (1.2.0) propshaft (0.9.1) actionpack (>= 7.0.0) activesupport (>= 7.0.0) @@ -216,7 +216,7 @@ GEM puma (6.4.3) nio4r (~> 2.0) racc (1.8.1) - rack (3.1.7) + rack (3.1.8) rack-session (2.0.0) rack (>= 3.0.0) rack-test (2.1.0) @@ -259,7 +259,7 @@ GEM zeitwerk (~> 2.6) rainbow (3.1.1) rake (13.2.1) - rbs (3.6.0) + rbs (3.6.1) logger rdoc (6.7.0) psych (>= 4.0.0) @@ -272,7 +272,7 @@ GEM rspec-expectations (3.13.3) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.13.0) - rspec-mocks (3.13.1) + rspec-mocks (3.13.2) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.13.0) rspec-rails (7.0.1) @@ -310,11 +310,11 @@ GEM rubocop-ast (>= 1.31.1, < 2.0) rubocop-rake (0.6.0) rubocop (~> 1.0) - rubocop-rspec (3.0.5) + rubocop-rspec (3.1.0) rubocop (~> 1.61) - ruby-lsp (0.18.4) + ruby-lsp (0.20.0) language_server-protocol (~> 3.17.0) - prism (~> 1.0) + prism (>= 1.2, < 2.0) rbs (>= 3, < 4) sorbet-runtime (>= 0.5.10782) ruby-progressbar (1.13.0) @@ -331,7 +331,7 @@ GEM json (>= 1.8, < 3) simplecov-html (~> 0.10.0) simplecov-html (0.10.2) - sorbet-runtime (0.5.11589) + sorbet-runtime (0.5.11602) stimulus-rails (1.3.4) railties (>= 6.0.0) stringio (3.1.1) @@ -366,7 +366,7 @@ GEM websocket-extensions (0.1.5) xpath (3.2.0) nokogiri (~> 1.8) - zeitwerk (2.6.18) + zeitwerk (2.7.0) PLATFORMS aarch64-linux diff --git a/app/controllers/evaluation_forms_controller.rb b/app/controllers/evaluation_forms_controller.rb index fc526a7f..e40a9175 100644 --- a/app/controllers/evaluation_forms_controller.rb +++ b/app/controllers/evaluation_forms_controller.rb @@ -75,6 +75,10 @@ def set_evaluation_forms # Only allow a list of trusted parameters through. def evaluation_form_params params.require(:evaluation_form).permit(:title, :instructions, :challenge_phase, :status, :comments_required, - :weighted_scoring, :publication_date, :closing_date, :challenge_id) + :weighted_scoring, :publication_date, :closing_date, :challenge_id, + evaluation_criteria_attributes: %i[ + id title description points_or_weight scoring_type + option_range_start option_range_end option_labels _destroy + ]) end end diff --git a/app/helpers/evaluation_forms_helper.rb b/app/helpers/evaluation_forms_helper.rb index cd61e778..89d000e5 100644 --- a/app/helpers/evaluation_forms_helper.rb +++ b/app/helpers/evaluation_forms_helper.rb @@ -12,4 +12,24 @@ def status_colors def challenge_with_phase(evaluation_form) "#{evaluation_form.challenge.title} - Phase #{evaluation_form.challenge_phase}" end + + def criteria_field_id(form, attribute, is_template) + prefix = "evaluation_form_evaluation_criteria_attributes" + + if is_template + "#{prefix}_NEW_CRITERIA_#{attribute}" + else + "#{prefix}_#{form.options[:child_index]}_#{attribute}" + end + end + + def criteria_field_name(form, attribute, is_template) + prefix = "evaluation_form[evaluation_criteria_attributes]" + + if is_template + "#{prefix}[NEW_CRITERIA][#{attribute}]" + else + "#{prefix}[#{form.options[:child_index]}][#{attribute}]" + end + end end diff --git a/app/javascript/application.js b/app/javascript/application.js index e69de29b..2a2882d2 100644 --- a/app/javascript/application.js +++ b/app/javascript/application.js @@ -0,0 +1 @@ +import "./evaluation_criteria"; diff --git a/app/javascript/evaluation_criteria.js b/app/javascript/evaluation_criteria.js new file mode 100644 index 00000000..aa9d3b8b --- /dev/null +++ b/app/javascript/evaluation_criteria.js @@ -0,0 +1,90 @@ +document.addEventListener("DOMContentLoaded", function () { + let criteriaCounter = document.querySelectorAll(".criteria-row").length; + let criteriaList = document.getElementById("criteria-list"); + let addCriteriaButton = document.getElementById("add-criteria-button"); + + // Add Criteria Button + if (addCriteriaButton) { + addCriteriaButton.addEventListener("click", function () { + createNewCriteriaRow(); + }); + } + + // Remove Criteria Button + if (criteriaList) { + criteriaList.addEventListener("click", function (event) { + if (event.target.classList.contains("delete-criteria-button")) { + let criteriaList = document.getElementById("criteria-list"); + let criteriaRow = event.target.closest(".criteria-row"); + + // Don't count hidden criteria rows marked for deletion + let visibleCriteriaRows = Array.from(criteriaList.children).filter( + (row) => row.style.display !== "none" + ); + + if (visibleCriteriaRows.length > 1) { + destroyCriteriaRow(criteriaRow); + } else { + destroyCriteriaRow(criteriaRow); + createNewCriteriaRow(); + } + } + }); + } + + function createNewCriteriaRow() { + let template = document.getElementById("criteria-template"); + let newCriteria = template.cloneNode(true); + + criteriaCounter++; + + newCriteria.style.display = "block"; + newCriteria.removeAttribute("id"); + + newCriteria.querySelectorAll("input, textarea").forEach(function (input) { + let id = input.getAttribute("id"); + let name = input.getAttribute("name"); + + // TODO: Remove condition when adding other scoring types + if (input.type !== "radio") { + input.disabled = false; + } + + if (id) { + let newId = id.replace("NEW_CRITERIA", criteriaCounter); + input.setAttribute("id", newId); + } + + if (name) { + let newName = name.replace("NEW_CRITERIA", criteriaCounter); + input.setAttribute("name", newName); + } + }); + + document.getElementById("criteria-list").appendChild(newCriteria); + } + + function destroyCriteriaRow(criteriaRow) { + let idField = criteriaRow.querySelector("input[name*='[id]']"); + let destroyField = criteriaRow.querySelector( + ".destroy-evaluation-criteria" + ); + + if (idField) { + // If existing evaluation criteria mark for destruction + criteriaRow.style.display = "none"; + destroyField.value = "true"; + + criteriaRow.querySelectorAll("input, textarea").forEach(function (input) { + // Preserve hidden id and _destroy inputs + if (input.type !== "hidden") { + // Disable inputs to prevent unfocusable browser error + input.disabled = true; + } + }); + } else { + // Otherwise remove row entirely + criteriaRow.remove(); + } + } +}); diff --git a/app/models/evaluation_criterion.rb b/app/models/evaluation_criterion.rb index e6716122..ecad8d8e 100644 --- a/app/models/evaluation_criterion.rb +++ b/app/models/evaluation_criterion.rb @@ -35,6 +35,4 @@ class EvaluationCriterion < ApplicationRecord # Validations validates :title, :description, :points_or_weight, presence: true validates :points_or_weight, numericality: { only_integer: true } - validates :title, - uniqueness: { scope: :evaluation_form_id, message: I18n.t("evaluation_criterion_unique_title_in_form") } end diff --git a/app/models/evaluation_form.rb b/app/models/evaluation_form.rb index 30021255..3b1210a1 100644 --- a/app/models/evaluation_form.rb +++ b/app/models/evaluation_form.rb @@ -17,7 +17,10 @@ # class EvaluationForm < ApplicationRecord belongs_to :challenge - has_many :evaluation_criteria, dependent: :destroy + has_many :evaluation_criteria, lambda { + order(:created_at) + }, class_name: 'EvaluationCriterion', dependent: :destroy, inverse_of: :evaluation_form + accepts_nested_attributes_for :evaluation_criteria, allow_destroy: true scope :by_user, lambda { |user| joins(challenge: :challenge_manager_users). @@ -29,4 +32,23 @@ class EvaluationForm < ApplicationRecord validates :closing_date, presence: true validates :challenge_phase, presence: true validates :challenge_phase, uniqueness: { scope: :challenge_id } + + validate :criteria_weights_must_sum_to_one_hundred, if: :weighted_scoring? + validate :validate_unique_criteria_titles + + def validate_unique_criteria_titles + titles = evaluation_criteria.reject(&:marked_for_destruction?).map(&:title) + + return unless titles.uniq.length != titles.length + + errors.add(:base, I18n.t("evaluation_criterion_unique_title_in_form_error")) + end + + def criteria_weights_must_sum_to_one_hundred + total_weight = evaluation_criteria.reject(&:marked_for_destruction?).sum(&:points_or_weight) + + return unless total_weight != 100 + + errors.add(:base, I18n.t("evaluation_form_criteria_weight_total_error")) + end end diff --git a/app/views/evaluation_forms/_evaluation_criterion_fields.html.erb b/app/views/evaluation_forms/_evaluation_criterion_fields.html.erb new file mode 100644 index 00000000..650ba1fa --- /dev/null +++ b/app/views/evaluation_forms/_evaluation_criterion_fields.html.erb @@ -0,0 +1,49 @@ +<% if f.object.persisted? %> + <%= f.hidden_field :id, value: f.object.id %> + <%= f.hidden_field :_destroy, class: "destroy-evaluation-criteria" %> +<% end %> + +<%= f.text_field :title, + id: criteria_field_id(f, "title", is_template), + name: criteria_field_name(f, "title", is_template), + class: 'usa-input', + placeholder: 'Add criteria title here', + required: true, + disabled: is_template +%> + +<%= button_tag type: "button", class: "delete-criteria-button usa-button usa-button--unstyled", title: "Delete criteria" do %> + X +<% end %> + +<%= f.text_area :description, + id: criteria_field_id(f, "description", is_template), + name: criteria_field_name(f, "description", is_template), + class: 'usa-textarea', + placeholder: 'Description', + required: true, + disabled: is_template +%> + +<%= f.number_field :points_or_weight, + id: criteria_field_id(f, "points_or_weight", is_template), + name: criteria_field_name(f, "points_or_weight", is_template), + class: 'usa-input', + min: 1, + step: 1, + required: true, + disabled: is_template +%> + +<% scoring_types = { "numeric" => "Numeric", "rating" => "Rating", "binary" => "Binary" } %> +<% scoring_types.each do |value, label| %> + <%= f.radio_button :scoring_type, value, + id: criteria_field_id(f, "scoring_type_#{value}", is_template), + name: criteria_field_name(f, :scoring_type, is_template), + class: "usa-radio", + checked: (value == "numeric"), + # TODO: Remove when adding other scoring_types + disabled: (value != "numeric") %> + + <%= label_tag criteria_field_id(f, "scoring_type_#{value}", is_template), label %> +<% end %> diff --git a/app/views/evaluation_forms/_form.html.erb b/app/views/evaluation_forms/_form.html.erb index b260d329..5b226ec6 100644 --- a/app/views/evaluation_forms/_form.html.erb +++ b/app/views/evaluation_forms/_form.html.erb @@ -69,6 +69,32 @@ + +
+ <% if evaluation_form.evaluation_criteria.empty? %> + <%= form.fields_for :evaluation_criteria, EvaluationCriterion.new do |ec| %> +
+ <%= render partial: 'evaluation_criterion_fields', locals: {f: ec, is_template: false} %> +
+ <% end %> + <% else %> + <%= form.fields_for :evaluation_criteria, include_id: false do |ec| %> +
"> + <%= render partial: 'evaluation_criterion_fields', locals: {f: ec, is_template: false} %> +
+ <% end %> + <% end %> +
+ + + + <%= button_tag type: "button", id: "add-criteria-button", class: "usa-button usa-button--unstyled", title: "Add another criteria" do %> + Add Another Criteria + <% end %>
  • Evaluation Period

    @@ -83,9 +109,6 @@
  • - - -
    <%= form.submit %>
    diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb index 9e049dcc..869bac6d 100644 --- a/config/initializers/inflections.rb +++ b/config/initializers/inflections.rb @@ -5,12 +5,13 @@ # Add new inflection rules using the following format. Inflections # are locale specific, and you may define rules for as many different # locales as you wish. All of these examples are active by default: -# ActiveSupport::Inflector.inflections(:en) do |inflect| +ActiveSupport::Inflector.inflections(:en) do |inflect| # inflect.plural /^(ox)$/i, "\\1en" # inflect.singular /^(ox)en/i, "\\1" # inflect.irregular "person", "people" # inflect.uncountable %w( fish sheep ) -# end + inflect.irregular "criterion", "criteria" +end # These inflection rules are supported but not enabled by default: # ActiveSupport::Inflector.inflections(:en) do |inflect| diff --git a/config/locales/en.yml b/config/locales/en.yml index 6ab6a8f2..8e4b8602 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -35,4 +35,6 @@ en: login_error: "There was an issue with logging in. Please try again." please_try_again: "Please try again." session_expired_alert: "Your session has expired. Please log in again." - evaluation_criterion_unique_title_in_form: "must be unique within the same form." + evaluation_criterion_unique_title_in_form_error: "Evaluation criteria title must be unique within the same form." + evaluation_form_criteria_weight_total_error: "The total weight of all evaluation criteria must add up to 100 when weighted scoring is enabled." + evaluation_criteria_form_title_placeholder: "Add criteria title here" diff --git a/db/migrate/20241017172408_remove_unique_title_index_from_evaluation_criteria.rb b/db/migrate/20241017172408_remove_unique_title_index_from_evaluation_criteria.rb new file mode 100644 index 00000000..06efee1e --- /dev/null +++ b/db/migrate/20241017172408_remove_unique_title_index_from_evaluation_criteria.rb @@ -0,0 +1,6 @@ +class RemoveUniqueTitleIndexFromEvaluationCriteria < ActiveRecord::Migration[7.2] + def change + # remove_index :evaluation_criteria, name: 'index_evaluation_criteria_on_evaluation_form_id_and_title' + remove_index :evaluation_criteria, [:evaluation_form_id, :title] + end +end diff --git a/db/structure.sql b/db/structure.sql index f9a0106b..c996cb26 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -1591,13 +1591,6 @@ CREATE UNIQUE INDEX challenges_custom_url_index ON public.challenges USING btree CREATE INDEX index_evaluation_criteria_on_evaluation_form_id ON public.evaluation_criteria USING btree (evaluation_form_id); --- --- Name: index_evaluation_criteria_on_evaluation_form_id_and_title; Type: INDEX; Schema: public; Owner: - --- - -CREATE UNIQUE INDEX index_evaluation_criteria_on_evaluation_form_id_and_title ON public.evaluation_criteria USING btree (evaluation_form_id, title); - - -- -- Name: index_evaluation_forms_on_challenge_id; Type: INDEX; Schema: public; Owner: - -- @@ -1995,6 +1988,7 @@ ALTER TABLE ONLY public.winners SET search_path TO "$user", public; INSERT INTO "schema_migrations" (version) VALUES +(20241017172408), (20241001143033), (20240927010020), (20240917010803), diff --git a/package.json b/package.json index 7b31639d..a325461b 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,7 @@ "author": "", "license": "ISC", "dependencies": { + "@hotwired/stimulus": "^3.2.2", "@uswds/uswds": "3.8.1", "esbuild": "^0.23.0", "sass": "^1.77.8" diff --git a/yarn.lock b/yarn.lock index cb0ba9d7..f100822f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -146,6 +146,11 @@ normalize-path "^2.0.1" through2 "^2.0.3" +"@hotwired/stimulus@^3.2.2": + version "3.2.2" + resolved "https://registry.yarnpkg.com/@hotwired/stimulus/-/stimulus-3.2.2.tgz#071aab59c600fed95b97939e605ff261a4251608" + integrity sha512-eGeIqNOQpXoPAIP7tC1+1Yc1yl1xnwYqg+3mzqxyrbE5pg5YFBZcA6YoTiByJB6DKAEsiWtl6tjTJS4IYtbB7A== + "@nodelib/fs.scandir@2.1.5": version "2.1.5" resolved "https://registry.yarnpkg.com/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz#7619c2eb21b25483f6d167548b4cfd5a7488c3d5" From 16ed9dce6380a93e42231aba8c8fc2c663ad9aa5 Mon Sep 17 00:00:00 2001 From: Chris Preisinger Date: Fri, 18 Oct 2024 01:02:22 -0400 Subject: [PATCH 02/23] 162 Initial temp styling for eval criteria --- .../_evaluation_criterion_fields.html.erb | 100 +++++++++++------- app/views/evaluation_forms/_form.html.erb | 8 +- 2 files changed, 65 insertions(+), 43 deletions(-) diff --git a/app/views/evaluation_forms/_evaluation_criterion_fields.html.erb b/app/views/evaluation_forms/_evaluation_criterion_fields.html.erb index 650ba1fa..3a5c10b2 100644 --- a/app/views/evaluation_forms/_evaluation_criterion_fields.html.erb +++ b/app/views/evaluation_forms/_evaluation_criterion_fields.html.erb @@ -3,47 +3,69 @@ <%= f.hidden_field :_destroy, class: "destroy-evaluation-criteria" %> <% end %> -<%= f.text_field :title, - id: criteria_field_id(f, "title", is_template), - name: criteria_field_name(f, "title", is_template), - class: 'usa-input', - placeholder: 'Add criteria title here', - required: true, - disabled: is_template -%> +
    + <%= f.label :title, "Criteria title", for: criteria_field_id(f, "title", is_template) %> -<%= button_tag type: "button", class: "delete-criteria-button usa-button usa-button--unstyled", title: "Delete criteria" do %> - X -<% end %> +
    + <%= f.text_field :title, + id: criteria_field_id(f, "title", is_template), + name: criteria_field_name(f, "title", is_template), + class: 'usa-input', + placeholder: 'Add criteria title here', + required: true, + disabled: is_template + %> +
    +
    -<%= f.text_area :description, - id: criteria_field_id(f, "description", is_template), - name: criteria_field_name(f, "description", is_template), - class: 'usa-textarea', - placeholder: 'Description', - required: true, - disabled: is_template -%> +
    + <%= f.label :description, "Criteria description", for: criteria_field_id(f, "description", is_template) %> + <%= f.text_area :description, + id: criteria_field_id(f, "description", is_template), + name: criteria_field_name(f, "description", is_template), + class: 'usa-textarea', + placeholder: 'Add criteria description here', + required: true, + disabled: is_template + %> +
    -<%= f.number_field :points_or_weight, - id: criteria_field_id(f, "points_or_weight", is_template), - name: criteria_field_name(f, "points_or_weight", is_template), - class: 'usa-input', - min: 1, - step: 1, - required: true, - disabled: is_template -%> +
    + <%= f.label :points_or_weight, "Criteria Points/Weight", for: criteria_field_id(f, "points_or_weight", is_template) %> + <%= f.number_field :points_or_weight, + id: criteria_field_id(f, "points_or_weight", is_template), + name: criteria_field_name(f, "points_or_weight", is_template), + class: 'usa-input', + min: 1, + step: 1, + placeholder: "Add criteria points/weight here", + required: true, + disabled: is_template + %> +
    -<% scoring_types = { "numeric" => "Numeric", "rating" => "Rating", "binary" => "Binary" } %> -<% scoring_types.each do |value, label| %> - <%= f.radio_button :scoring_type, value, - id: criteria_field_id(f, "scoring_type_#{value}", is_template), - name: criteria_field_name(f, :scoring_type, is_template), - class: "usa-radio", - checked: (value == "numeric"), - # TODO: Remove when adding other scoring_types - disabled: (value != "numeric") %> +
    + <%= f.label :scoring_type, "Scoring Type", for: criteria_field_id(f, "scoring_type", is_template) %> + <% scoring_types = { "numeric" => "Numeric", "rating" => "Rating", "binary" => "Binary" } %> +
    + <% scoring_types.each do |value, label| %> +
    + <%= f.radio_button :scoring_type, value, + id: criteria_field_id(f, "scoring_type_#{value}", is_template), + name: criteria_field_name(f, :scoring_type, is_template), + class: "usa-radio", + checked: (value == "numeric"), + # TODO: Remove when adding other scoring_types + disabled: (value != "numeric") %> - <%= label_tag criteria_field_id(f, "scoring_type_#{value}", is_template), label %> -<% end %> + <%= label_tag criteria_field_id(f, "scoring_type_#{value}", is_template), label %> +
    + <% end %> +
    +
    + +
    + <%= button_tag type: "button", class: "delete-criteria-button usa-button usa-button--unstyled", title: "Delete criteria" do %> + Remove criteria + <% end %> +
    \ No newline at end of file diff --git a/app/views/evaluation_forms/_form.html.erb b/app/views/evaluation_forms/_form.html.erb index 5b226ec6..735d0d89 100644 --- a/app/views/evaluation_forms/_form.html.erb +++ b/app/views/evaluation_forms/_form.html.erb @@ -73,27 +73,27 @@
    <% if evaluation_form.evaluation_criteria.empty? %> <%= form.fields_for :evaluation_criteria, EvaluationCriterion.new do |ec| %> -
    +
    <%= render partial: 'evaluation_criterion_fields', locals: {f: ec, is_template: false} %>
    <% end %> <% else %> <%= form.fields_for :evaluation_criteria, include_id: false do |ec| %> -
    "> +
    "> <%= render partial: 'evaluation_criterion_fields', locals: {f: ec, is_template: false} %>
    <% end %> <% end %>
    - -
    +
    <%= f.label :rating_scale_options, "Rating Scale Options", for: criteria_field_id(f, "rating_scale_options", is_template) %> +
    <%= f.hidden_field :option_range_start, id: criteria_field_id(f, "option_range_start", is_template), name: criteria_field_name(f, "option_range_start", is_template), + class: "option-range-start", + disabled: !f.object.binary?, value: 0 %> <%= f.hidden_field :option_range_end, id: criteria_field_id(f, "option_range_end", is_template), name: criteria_field_name(f, "option_range_end", is_template), + class: "option-range-end", + disabled: !f.object.binary?, value: 1 %> +
    + +
    +
    + <%= f.select :option_range_start, options_for_select((0..1).to_a, f.object.option_range_start), {}, + id: criteria_field_id(f, "option_range_start", is_template), + name: criteria_field_name(f, "option_range_start", is_template), + class: "usa-select margin-0 option-range-select option-range-start", + disabled: !f.object.rating?, + include_blank: true %> + to + <%= f.select :option_range_end, options_for_select((2..10).to_a, f.object.option_range_end), {}, + id: criteria_field_id(f, "option_range_end", is_template), + name: criteria_field_name(f, "option_range_end", is_template), + class: "usa-select margin-0 option-range-select option-range-end", + disabled: !f.object.rating?, + include_blank: true %> +
    +
    - <% (0..1).each do |index| %> -
    - <%= label_tag criteria_field_id(f, "option_labels", is_template) ++ "_#{index}", index, - class: "margin-right-1" %> +
    + <% (0..10).each do |index| %> + <% disabledOptionLabel = is_template || ((f.object.option_range_start && index < f.object.option_range_start) || (f.object.option_range_end && index > f.object.option_range_end)) %> +
    + <%= label_tag criteria_field_id(f, "option_labels", is_template) ++ "_#{index}", index %> <%= f.text_field "option_labels", id: criteria_field_id(f, "option_labels", is_template) ++ "_#{index}", @@ -85,15 +111,11 @@ class: "usa-input margin-0", value: f.object.option_labels[index.to_s], required: true, - disabled: is_template - %> + disabled: disabledOptionLabel, + data: {index: index} %>
    <% end %>
    - -
    - Rating options -
    From a22b0e8e53ead5cdab860ce16c684a37b33bb933 Mon Sep 17 00:00:00 2001 From: Chris Preisinger Date: Tue, 22 Oct 2024 12:19:32 -0400 Subject: [PATCH 05/23] 165 Fix bug with new criteria option labels --- app/javascript/evaluation_criteria.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/javascript/evaluation_criteria.js b/app/javascript/evaluation_criteria.js index 3fd82ee5..9b2a58be 100644 --- a/app/javascript/evaluation_criteria.js +++ b/app/javascript/evaluation_criteria.js @@ -155,6 +155,13 @@ document.addEventListener("DOMContentLoaded", function () { ratingOptions.querySelectorAll("input, select").forEach(function (input) { input.disabled = true; }); + + let criteriaOptionLabelRows = criteriaRow.querySelectorAll( + ".criteria-option-label-row input" + ); + criteriaOptionLabelRows.forEach(function (input) { + input.disabled = true; + }); } } @@ -183,8 +190,6 @@ document.addEventListener("DOMContentLoaded", function () { criteriaOptionLabelRows.forEach(function (row, index) { row.querySelectorAll("input").forEach(function (input) { - let inputIndex = input.dataset.index; - if (index < optionRangeStart || index > optionRangeEnd) { row.style.display = "none"; input.disabled = true; From d77a3cc79328aab07d0dcb4d47f10266eafa6e4a Mon Sep 17 00:00:00 2001 From: Chris Preisinger Date: Tue, 22 Oct 2024 12:30:19 -0400 Subject: [PATCH 06/23] 165 Option label bug with form validation error --- .../evaluation_forms/_evaluation_criterion_fields.html.erb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/views/evaluation_forms/_evaluation_criterion_fields.html.erb b/app/views/evaluation_forms/_evaluation_criterion_fields.html.erb index b8f345d6..f7b795dd 100644 --- a/app/views/evaluation_forms/_evaluation_criterion_fields.html.erb +++ b/app/views/evaluation_forms/_evaluation_criterion_fields.html.erb @@ -100,7 +100,8 @@
    <% (0..10).each do |index| %> - <% disabledOptionLabel = is_template || ((f.object.option_range_start && index < f.object.option_range_start) || (f.object.option_range_end && index > f.object.option_range_end)) %> + <% disabledOptionLabel = is_template || f.object.numeric? || ((f.object.option_range_start && index < f.object.option_range_start) || (f.object.option_range_end && index > f.object.option_range_end)) %> +
    <%= label_tag criteria_field_id(f, "option_labels", is_template) ++ "_#{index}", index %> From 38d8f2c6ce41fe6d3e5de2a0431149f18794d9fd Mon Sep 17 00:00:00 2001 From: Chris Preisinger Date: Tue, 22 Oct 2024 13:41:52 -0400 Subject: [PATCH 07/23] 165 Fix bug with rating options on new criteria --- app/javascript/evaluation_criteria.js | 29 +++++++++++++-------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/app/javascript/evaluation_criteria.js b/app/javascript/evaluation_criteria.js index 9b2a58be..62d4e3b4 100644 --- a/app/javascript/evaluation_criteria.js +++ b/app/javascript/evaluation_criteria.js @@ -46,25 +46,24 @@ document.addEventListener("DOMContentLoaded", function () { label.setAttribute("for", newFor); }); - newCriteria.querySelectorAll("input, textarea").forEach(function (input) { - let id = input.getAttribute("id"); - let name = input.getAttribute("name"); + newCriteria + .querySelectorAll("input, textarea, select") + .forEach(function (input) { + let id = input.getAttribute("id"); + let name = input.getAttribute("name"); - // TODO: Remove condition when adding other scoring types - if (input.type !== "radio") { input.disabled = false; - } - if (id) { - let newId = id.replace("NEW_CRITERIA", criteriaCounter); - input.setAttribute("id", newId); - } + if (id) { + let newId = id.replace("NEW_CRITERIA", criteriaCounter); + input.setAttribute("id", newId); + } - if (name) { - let newName = name.replace("NEW_CRITERIA", criteriaCounter); - input.setAttribute("name", newName); - } - }); + if (name) { + let newName = name.replace("NEW_CRITERIA", criteriaCounter); + input.setAttribute("name", newName); + } + }); document.getElementById("criteria-list").appendChild(newCriteria); } From 2af7b305b28112925ac2d9b8dc7074686d1653f5 Mon Sep 17 00:00:00 2001 From: Chris Preisinger Date: Sun, 27 Oct 2024 22:48:46 -0400 Subject: [PATCH 08/23] 61 Accordion titles and collapse validity check --- app/javascript/evaluation_criteria.js | 66 ++++++ .../_evaluation_criterion_fields.html.erb | 205 +++++++++--------- app/views/evaluation_forms/_form.html.erb | 16 +- 3 files changed, 183 insertions(+), 104 deletions(-) diff --git a/app/javascript/evaluation_criteria.js b/app/javascript/evaluation_criteria.js index 62d4e3b4..14a0859f 100644 --- a/app/javascript/evaluation_criteria.js +++ b/app/javascript/evaluation_criteria.js @@ -40,6 +40,16 @@ document.addEventListener("DOMContentLoaded", function () { newCriteria.style.display = "block"; newCriteria.removeAttribute("id"); + let accordionButton = newCriteria.querySelector(".usa-accordion__button"); + let accordionContent = newCriteria.querySelector(".usa-accordion__content"); + + let accordionId = accordionContent + .getAttribute("id") + .replace("NEW_CRITERIA", criteriaCounter); + + accordionButton.setAttribute("aria-controls", accordionId); + accordionContent.setAttribute("id", accordionId); + newCriteria.querySelectorAll("label").forEach(function (label) { let oldFor = label.getAttribute("for"); let newFor = oldFor.replace("NEW_CRITERIA", criteriaCounter); @@ -66,6 +76,8 @@ document.addEventListener("DOMContentLoaded", function () { }); document.getElementById("criteria-list").appendChild(newCriteria); + + updateCriteriaRowTitles(); } function destroyCriteriaRow(criteriaRow) { @@ -90,6 +102,23 @@ document.addEventListener("DOMContentLoaded", function () { // Otherwise remove row entirely criteriaRow.remove(); } + + updateCriteriaRowTitles(); + } + + function updateCriteriaRowTitles() { + let visibleCriteriaRows = Array.from(criteriaList.children).filter( + (row) => row.style.display !== "none" + ); + + visibleCriteriaRows.forEach(function (row, index) { + // Find the span with the class 'criteria-number' inside this row + let span = row.querySelector(".criteria-number"); + if (span) { + // Update the inner text of the span with the new index + span.innerHTML = index + 1; + } + }); } // Toggle Binary/Rating Scale Options @@ -199,4 +228,41 @@ document.addEventListener("DOMContentLoaded", function () { }); }); } + + // Accordion Buttons + if (criteriaList) { + criteriaList.addEventListener("click", function (event) { + let accordionButton = event.target.closest(".usa-accordion__button"); + + if (accordionButton) { + const sectionId = accordionButton.getAttribute("aria-controls"); + + if ( + !accordionButton.getAttribute("aria-expanded") || + accordionButton.getAttribute("aria-expanded") === "true" + ) { + const isValid = validateAccordionSection(sectionId); + if (!isValid) { + event.preventDefault(); + event.stopPropagation(); + } + } + } + }); + } + + function validateAccordionSection(sectionId) { + const section = document.getElementById(sectionId); + const requiredFields = section.querySelectorAll("[required]"); + + for (let field of requiredFields) { + if (!field.checkValidity()) { + if (!field.reportValidity()) { + return false; + } + } + } + + return true; + } }); diff --git a/app/views/evaluation_forms/_evaluation_criterion_fields.html.erb b/app/views/evaluation_forms/_evaluation_criterion_fields.html.erb index f7b795dd..5c4e6333 100644 --- a/app/views/evaluation_forms/_evaluation_criterion_fields.html.erb +++ b/app/views/evaluation_forms/_evaluation_criterion_fields.html.erb @@ -1,12 +1,23 @@ -<% if f.object.persisted? %> - <%= f.hidden_field :id, value: f.object.id %> - <%= f.hidden_field :_destroy, class: "destroy-evaluation-criteria" %> -<% end %> +

    + +

    -
    - <%= f.label :title, "Criteria title", for: criteria_field_id(f, "title", is_template) %> +
    " class="usa-accordion__content"> + <% if f.object.persisted? %> + <%= f.hidden_field :id, value: f.object.id %> + <%= f.hidden_field :_destroy, class: "destroy-evaluation-criteria" %> + <% end %> + +
    + <%= f.label :title, "Criteria title", for: criteria_field_id(f, "title", is_template) %> -
    <%= f.text_field :title, id: criteria_field_id(f, "title", is_template), name: criteria_field_name(f, "title", is_template), @@ -16,111 +27,111 @@ disabled: is_template %>
    -
    - -
    - <%= f.label :description, "Criteria description", for: criteria_field_id(f, "description", is_template) %> - <%= f.text_area :description, - id: criteria_field_id(f, "description", is_template), - name: criteria_field_name(f, "description", is_template), - class: 'usa-textarea', - placeholder: 'Add criteria description here', - required: true, - disabled: is_template - %> -
    -
    - <%= f.label :points_or_weight, "Criteria Points/Weight", for: criteria_field_id(f, "points_or_weight", is_template) %> - <%= f.number_field :points_or_weight, - id: criteria_field_id(f, "points_or_weight", is_template), - name: criteria_field_name(f, "points_or_weight", is_template), - class: 'usa-input', - min: 1, - step: 1, - placeholder: "Add criteria points/weight here", - required: true, - disabled: is_template - %> -
    - -
    - <%= f.label :scoring_type, "Scoring Type", for: criteria_field_id(f, "scoring_type", is_template) %> - <% scoring_types = { "numeric" => "Numeric score / points", "rating" => "Rating scale", "binary" => "Binary scale" } %> -
    - <% scoring_types.each do |value, label| %> -
    - <%= f.radio_button :scoring_type, value, - id: criteria_field_id(f, "scoring_type_#{value}", is_template), - name: criteria_field_name(f, :scoring_type, is_template), - class: "usa-radio scoring-type-radio", - checked: f.object.scoring_type == value %> +
    + <%= f.label :description, "Criteria description", for: criteria_field_id(f, "description", is_template) %> + <%= f.text_area :description, + id: criteria_field_id(f, "description", is_template), + name: criteria_field_name(f, "description", is_template), + class: 'usa-textarea', + placeholder: 'Add criteria description here', + required: true, + disabled: is_template + %> +
    - <%= label_tag criteria_field_id(f, "scoring_type_#{value}", is_template), label %> -
    - <% end %> +
    + <%= f.label :points_or_weight, "Criteria Points/Weight", for: criteria_field_id(f, "points_or_weight", is_template) %> + <%= f.number_field :points_or_weight, + id: criteria_field_id(f, "points_or_weight", is_template), + name: criteria_field_name(f, "points_or_weight", is_template), + class: 'usa-input', + min: 1, + step: 1, + placeholder: "Add criteria points/weight here", + required: true, + disabled: is_template + %>
    -
    -
    - <%= f.label :rating_scale_options, "Rating Scale Options", for: criteria_field_id(f, "rating_scale_options", is_template) %> +
    + <%= f.label :scoring_type, "Scoring Type", for: criteria_field_id(f, "scoring_type", is_template) %> + <% scoring_types = { "numeric" => "Numeric score / points", "rating" => "Rating scale", "binary" => "Binary scale" } %> +
    + <% scoring_types.each do |value, label| %> +
    + <%= f.radio_button :scoring_type, value, + id: criteria_field_id(f, "scoring_type_#{value}", is_template), + name: criteria_field_name(f, :scoring_type, is_template), + class: "usa-radio scoring-type-radio", + checked: f.object.scoring_type == value %> -
    - <%= f.hidden_field :option_range_start, - id: criteria_field_id(f, "option_range_start", is_template), - name: criteria_field_name(f, "option_range_start", is_template), - class: "option-range-start", - disabled: !f.object.binary?, - value: 0 %> - <%= f.hidden_field :option_range_end, - id: criteria_field_id(f, "option_range_end", is_template), - name: criteria_field_name(f, "option_range_end", is_template), - class: "option-range-end", - disabled: !f.object.binary?, - value: 1 %> + <%= label_tag criteria_field_id(f, "scoring_type_#{value}", is_template), label %> +
    + <% end %> +
    -
    -
    - <%= f.select :option_range_start, options_for_select((0..1).to_a, f.object.option_range_start), {}, +
    + <%= f.label :rating_scale_options, "Rating Scale Options", for: criteria_field_id(f, "rating_scale_options", is_template) %> + +
    + <%= f.hidden_field :option_range_start, id: criteria_field_id(f, "option_range_start", is_template), name: criteria_field_name(f, "option_range_start", is_template), - class: "usa-select margin-0 option-range-select option-range-start", - disabled: !f.object.rating?, - include_blank: true %> - to - <%= f.select :option_range_end, options_for_select((2..10).to_a, f.object.option_range_end), {}, + class: "option-range-start", + disabled: !f.object.binary?, + value: 0 %> + <%= f.hidden_field :option_range_end, id: criteria_field_id(f, "option_range_end", is_template), name: criteria_field_name(f, "option_range_end", is_template), - class: "usa-select margin-0 option-range-select option-range-end", - disabled: !f.object.rating?, - include_blank: true %> + class: "option-range-end", + disabled: !f.object.binary?, + value: 1 %>
    -
    -
    - <% (0..10).each do |index| %> - <% disabledOptionLabel = is_template || f.object.numeric? || ((f.object.option_range_start && index < f.object.option_range_start) || (f.object.option_range_end && index > f.object.option_range_end)) %> +
    +
    + <%= f.select :option_range_start, options_for_select((0..1).to_a, f.object.option_range_start), {}, + id: criteria_field_id(f, "option_range_start", is_template), + name: criteria_field_name(f, "option_range_start", is_template), + class: "usa-select margin-0 option-range-select option-range-start", + disabled: !f.object.rating?, + include_blank: true %> + to + <%= f.select :option_range_end, options_for_select((2..10).to_a, f.object.option_range_end), {}, + id: criteria_field_id(f, "option_range_end", is_template), + name: criteria_field_name(f, "option_range_end", is_template), + class: "usa-select margin-0 option-range-select option-range-end", + disabled: !f.object.rating?, + include_blank: true %> +
    +
    -
    - <%= label_tag criteria_field_id(f, "option_labels", is_template) ++ "_#{index}", index %> +
    + <% (0..10).each do |index| %> + <% disabledOptionLabel = is_template || f.object.numeric? || ((f.object.option_range_start && index < f.object.option_range_start) || (f.object.option_range_end && index > f.object.option_range_end)) %> - <%= f.text_field "option_labels", - id: criteria_field_id(f, "option_labels", is_template) ++ "_#{index}", - name: criteria_field_name(f, "option_labels", is_template) ++ "[#{index}]", - class: "usa-input margin-0", - value: f.object.option_labels[index.to_s], - required: true, - disabled: disabledOptionLabel, - data: {index: index} %> -
    - <% end %> +
    + <%= label_tag criteria_field_id(f, "option_labels", is_template) ++ "_#{index}", index %> + + <%= f.text_field "option_labels", + id: criteria_field_id(f, "option_labels", is_template) ++ "_#{index}", + name: criteria_field_name(f, "option_labels", is_template) ++ "[#{index}]", + class: "usa-input margin-0", + value: f.object.option_labels[index.to_s], + required: true, + disabled: disabledOptionLabel, + data: {index: index} %> +
    + <% end %> +
    -
    -
    - <%= button_tag type: "button", class: "delete-criteria-button usa-button usa-button--unstyled", title: "Delete criteria" do %> - Remove criteria - <% end %> +
    + <%= button_tag type: "button", class: "delete-criteria-button usa-button usa-button--unstyled", title: "Delete criteria" do %> + Remove criteria + <% end %> +
    \ No newline at end of file diff --git a/app/views/evaluation_forms/_form.html.erb b/app/views/evaluation_forms/_form.html.erb index 3cacf9fd..835c984d 100644 --- a/app/views/evaluation_forms/_form.html.erb +++ b/app/views/evaluation_forms/_form.html.erb @@ -91,26 +91,28 @@
    -
    +
    <% if evaluation_form.evaluation_criteria.empty? %> <%= form.fields_for :evaluation_criteria, EvaluationCriterion.new do |ec| %> -
    +
    <%= render partial: 'evaluation_criterion_fields', locals: {f: ec, is_template: false} %>
    <% end %> <% else %> <%= form.fields_for :evaluation_criteria, include_id: false do |ec| %> -
    "> +
    "> <%= render partial: 'evaluation_criterion_fields', locals: {f: ec, is_template: false} %>
    <% end %> <% end %>
    - @@ -72,48 +85,62 @@
    -
    +
    <%= f.label :rating_scale_options, "Rating Scale Options", for: criteria_field_id(f, "rating_scale_options", is_template) %> -
    +
    <%= f.hidden_field :option_range_start, id: criteria_field_id(f, "option_range_start", is_template), name: criteria_field_name(f, "option_range_start", is_template), class: "option-range-start", disabled: !f.object.binary?, - value: 0 %> + value: 0, + data: {"evaluation-criteria-target": "hiddenOptionRangeStart"} + %> <%= f.hidden_field :option_range_end, id: criteria_field_id(f, "option_range_end", is_template), name: criteria_field_name(f, "option_range_end", is_template), class: "option-range-end", disabled: !f.object.binary?, - value: 1 %> + value: 1, + data: {"evaluation-criteria-target": "hiddenOptionRangeEnd"} + %>
    -
    +
    <%= f.select :option_range_start, options_for_select((0..1).to_a, f.object.option_range_start), {}, id: criteria_field_id(f, "option_range_start", is_template), name: criteria_field_name(f, "option_range_start", is_template), class: "usa-select margin-0 option-range-select option-range-start", disabled: !f.object.rating?, - include_blank: true %> + include_blank: true, + data: { + "evaluation-criteria-target": "selectOptionRangeStart", + action: "change->evaluation-criteria#toggleOptionRange" + } + %> to <%= f.select :option_range_end, options_for_select((2..10).to_a, f.object.option_range_end), {}, id: criteria_field_id(f, "option_range_end", is_template), name: criteria_field_name(f, "option_range_end", is_template), class: "usa-select margin-0 option-range-select option-range-end", disabled: !f.object.rating?, - include_blank: true %> + include_blank: true, + data: { + "evaluation-criteria-target": "selectOptionRangeEnd", + action: "change->evaluation-criteria#toggleOptionRange" + } + %>
    -
    +
    <% (0..10).each do |index| %> <% disabledOptionLabel = is_template || f.object.numeric? || ((f.object.option_range_start && index < f.object.option_range_start) || (f.object.option_range_end && index > f.object.option_range_end)) %>
    + style="<%= disabledOptionLabel ? 'display: none;' : '' %>" data-evaluation-criteria-target="optionLabelRow"> <%= label_tag criteria_field_id(f, "option_labels", is_template) ++ "_#{index}", index %> <%= f.text_field "option_labels", @@ -123,15 +150,16 @@ value: f.object.option_labels[index.to_s], required: true, disabled: disabledOptionLabel, - data: {index: index} %> + data: {"evaluation-criteria-target": "optionLabelInput"} + %>
    <% end %>
    - <%= button_tag type: "button", class: "delete-criteria-button usa-button usa-button--unstyled", title: "Delete criteria" do %> + <%= button_tag type: "button", class: "delete-criteria-button usa-button usa-button--unstyled", title: "Delete criteria", data: {action: "click->evaluation-criteria#removeCriteria"} do %> Remove criteria <% end %>
    -
    \ No newline at end of file +
    diff --git a/app/views/evaluation_forms/_form.html.erb b/app/views/evaluation_forms/_form.html.erb index 2c795bb7..903bf862 100644 --- a/app/views/evaluation_forms/_form.html.erb +++ b/app/views/evaluation_forms/_form.html.erb @@ -92,33 +92,35 @@
    -
    - <% if evaluation_form.evaluation_criteria.empty? %> - <%= form.fields_for :evaluation_criteria, EvaluationCriterion.new do |ec| %> -
    - <%= render partial: 'evaluation_criterion_fields', locals: {f: ec, is_template: false} %> -
    - <% end %> - <% else %> - <%= form.fields_for :evaluation_criteria, include_id: false do |ec| %> -
    "> - <%= render partial: 'evaluation_criterion_fields', locals: {f: ec, is_template: false} %> -
    +
    +
    + <% if evaluation_form.evaluation_criteria.empty? %> + <%= form.fields_for :evaluation_criteria, EvaluationCriterion.new do |ec| %> +
    + <%= render partial: 'evaluation_criterion_fields', locals: { f: ec, is_template: false } %> +
    + <% end %> + <% else %> + <%= form.fields_for :evaluation_criteria, include_id: false do |ec| %> +
    " data-evaluation-criteria-target="criteriaRow"> + <%= render partial: 'evaluation_criterion_fields', locals: { f: ec, is_template: false } %> +
    + <% end %> <% end %> - <% end %> -
    +
    -
    - - - <%= button_tag type: "button", id: "add-criteria-button", class: "usa-button usa-button--unstyled", title: "Add another criteria" do %> - Add another criteria - <% end %>
  • Evaluation Period

    From db830083caf72cc0d108cb2e583c4d29a2433b67 Mon Sep 17 00:00:00 2001 From: Stephen Chudleigh Date: Tue, 29 Oct 2024 08:26:11 -0700 Subject: [PATCH 11/23] update yarn.lock --- yarn.lock | 52 ++++++++++++++++++++++++++-------------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/yarn.lock b/yarn.lock index 5420e54b..8ce411e1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -254,11 +254,11 @@ integrity sha512-Q5Vn3yjTDyCMV50TB6VRIbQNxSE4OmZR86VSbGaNpfUolm0iePBB4KdEEHmxoY5sT2+2DIvXW0rvMDP2nHZ4Mg== "@types/node@*": - version "22.7.6" - resolved "https://registry.yarnpkg.com/@types/node/-/node-22.7.6.tgz#3ec3e2b071e136cd11093c19128405e1d1f92f33" - integrity sha512-/d7Rnj0/ExXDMcioS78/kf1lMzYk4BZV8MZGTBKzTGZ6/406ukkbYlIsZmMPhcR5KlkunDHQLrtAVmSq7r+mSw== + version "22.8.2" + resolved "https://registry.yarnpkg.com/@types/node/-/node-22.8.2.tgz#8e82bb8201c0caf751dcdc61b0a262d2002d438b" + integrity sha512-NzaRNFV+FZkvK/KLCsNdTvID0SThyrs5SHB6tsD/lajr22FGC73N2QeDPM2wHtVde8mgcXuSsHQkH5cX1pbPLw== dependencies: - undici-types "~6.19.2" + undici-types "~6.19.8" "@types/vinyl@^2.0.4": version "2.0.12" @@ -464,14 +464,14 @@ braces@^3.0.3, braces@~3.0.2: fill-range "^7.1.1" browserslist@^4.23.3: - version "4.24.0" - resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.24.0.tgz#a1325fe4bc80b64fda169629fc01b3d6cecd38d4" - integrity sha512-Rmb62sR1Zpjql25eSanFGEhAxcFwfA1K0GuQcLoaJBAcENegrQut3hYdhXFF1obQfiDyqIW/cLM5HSJ/9k884A== + version "4.24.2" + resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.24.2.tgz#f5845bc91069dbd55ee89faf9822e1d885d16580" + integrity sha512-ZIc+Q62revdMcqC6aChtW4jz3My3klmCO1fEmINZY/8J3EpBg5/A/D0AKmBveUh6pgoeycoMkVMko84tuYS+Gg== dependencies: - caniuse-lite "^1.0.30001663" - electron-to-chromium "^1.5.28" + caniuse-lite "^1.0.30001669" + electron-to-chromium "^1.5.41" node-releases "^2.0.18" - update-browserslist-db "^1.1.0" + update-browserslist-db "^1.1.1" buffer-builder@^0.2.0: version "0.2.0" @@ -486,10 +486,10 @@ buffer@^6.0.3: base64-js "^1.3.1" ieee754 "^1.2.1" -caniuse-lite@^1.0.30001646, caniuse-lite@^1.0.30001663: - version "1.0.30001669" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001669.tgz#fda8f1d29a8bfdc42de0c170d7f34a9cf19ed7a3" - integrity sha512-DlWzFDJqstqtIVx1zeSpIMLjunf5SmwOw0N2Ck/QSQdS8PLS4+9HrLaYei4w8BIAL7IB/UEDu889d8vhCTPA0w== +caniuse-lite@^1.0.30001646, caniuse-lite@^1.0.30001669: + version "1.0.30001674" + resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001674.tgz#eb200a716c3e796d33d30b9c8890517a72f862c8" + integrity sha512-jOsKlZVRnzfhLojb+Ykb+gyUSp9Xb57So+fAiFlLzzTKpqg8xxSav0e40c8/4F/v9N8QSvrRRaLeVzQbLqomYw== chalk@^4.1.2: version "4.1.2" @@ -733,10 +733,10 @@ each-props@^3.0.0: is-plain-object "^5.0.0" object.defaults "^1.1.0" -electron-to-chromium@^1.5.28: - version "1.5.41" - resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.5.41.tgz#eae1ba6c49a1a61d84cf8263351d3513b2bcc534" - integrity sha512-dfdv/2xNjX0P8Vzme4cfzHqnPm5xsZXwsolTYr0eyW18IUmNyG08vL+fttvinTfhKfIKdRoqkDIC9e9iWQCNYQ== +electron-to-chromium@^1.5.41: + version "1.5.49" + resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.5.49.tgz#9358f514ab6eeed809a8689f4b39ea5114ae729c" + integrity sha512-ZXfs1Of8fDb6z7WEYZjXpgIRF6MEu8JdeGA0A40aZq6OQbS+eJpnnV49epZRna2DU/YsEjSQuGtQPPtvt6J65A== element-closest@^2.0.1: version "2.0.2" @@ -1518,9 +1518,9 @@ parse5-parser-stream@^7.1.2: parse5 "^7.0.0" parse5@^7.0.0, parse5@^7.1.2: - version "7.2.0" - resolved "https://registry.yarnpkg.com/parse5/-/parse5-7.2.0.tgz#8a0591ce9b7c5e2027173ab737d4d3fc3d826fab" - integrity sha512-ZkDsAOcxsUMZ4Lz5fVciOehNcJ+Gb8gTzcA4yl3wnc273BAybYWrQ+Ks/OjCjSEpjvQkDSeZbybK9qj2VHHdGA== + version "7.2.1" + resolved "https://registry.yarnpkg.com/parse5/-/parse5-7.2.1.tgz#8928f55915e6125f430cc44309765bf17556a33a" + integrity sha512-BuBYQYlv1ckiPdQi/ohiivi9Sagc9JG+Ozs0r7b/0iK3sKmrb0b9FdWdBbOdx6hBCM/F9Ir82ofnBhtZOjCRPQ== dependencies: entities "^4.5.0" @@ -1886,9 +1886,9 @@ sass-embedded@1.77.8: sass-embedded-win32-x64 "1.77.8" sass@^1.77.8: - version "1.80.2" - resolved "https://registry.yarnpkg.com/sass/-/sass-1.80.2.tgz#9d13d85a4f81bb17e09d1dc3e1c0944f7fd7315e" - integrity sha512-9wXY8cGBlUmoUoT+vwOZOFCiS+naiWVjqlreN9ar9PudXbGwlMTFwCR5K9kB4dFumJ6ib98wZyAObJKsWf1nAA== + version "1.80.4" + resolved "https://registry.yarnpkg.com/sass/-/sass-1.80.4.tgz#bc0418fd796cad2f1a1309d8b4d7fe44b7027de0" + integrity sha512-rhMQ2tSF5CsuuspvC94nPM9rToiAFw2h3JTrLlgmNw1MH79v8Cr3DH6KF6o6r+8oofY3iYVPUf66KzC8yuVN1w== dependencies: "@parcel/watcher" "^2.4.1" chokidar "^4.0.0" @@ -2067,7 +2067,7 @@ undertaker@^2.0.0: last-run "^2.0.0" undertaker-registry "^2.0.0" -undici-types@~6.19.2: +undici-types@~6.19.8: version "6.19.8" resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-6.19.8.tgz#35111c9d1437ab83a7cdc0abae2f26d88eda0a02" integrity sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw== @@ -2077,7 +2077,7 @@ undici@^6.19.5: resolved "https://registry.yarnpkg.com/undici/-/undici-6.20.1.tgz#fbb87b1e2b69d963ff2d5410a40ffb4c9e81b621" integrity sha512-AjQF1QsmqfJys+LXfGTNum+qw4S88CojRInG/6t31W/1fk6G59s92bnAvGz5Cmur+kQv2SURXEvvudLmbrE8QA== -update-browserslist-db@^1.1.0: +update-browserslist-db@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/update-browserslist-db/-/update-browserslist-db-1.1.1.tgz#80846fba1d79e82547fb661f8d141e0945755fe5" integrity sha512-R8UzCaa9Az+38REPiJ1tXlImTJXlVfgHZsglwBD/k6nj76ctsH1E3q4doGrukiLQd3sGQYu56r5+lo5r94l29A== From 33943776cad70e36bf8b39124c00944d7103a602 Mon Sep 17 00:00:00 2001 From: Chris Preisinger Date: Tue, 29 Oct 2024 11:28:23 -0400 Subject: [PATCH 12/23] 61 Update dependency versions --- Gemfile.lock | 2 +- .../_evaluation_criterion_fields.html.erb | 2 - yarn.lock | 52 +++++++++---------- 3 files changed, 27 insertions(+), 29 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index d7b75653..a53549bf 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -185,7 +185,7 @@ GEM timeout net-smtp (0.5.0) net-protocol - nio4r (2.7.3) + nio4r (2.7.4) nokogiri (1.16.7-aarch64-linux) racc (~> 1.4) nokogiri (1.16.7-arm-linux) diff --git a/app/views/evaluation_forms/_evaluation_criterion_fields.html.erb b/app/views/evaluation_forms/_evaluation_criterion_fields.html.erb index a6a163c9..acf99613 100644 --- a/app/views/evaluation_forms/_evaluation_criterion_fields.html.erb +++ b/app/views/evaluation_forms/_evaluation_criterion_fields.html.erb @@ -8,8 +8,6 @@ data-action="click->evaluation-criteria#validateInputs" >
    Criteria <%= f.options[:child_index] + 1 %>
    - -
    X
    diff --git a/yarn.lock b/yarn.lock index 5420e54b..8ce411e1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -254,11 +254,11 @@ integrity sha512-Q5Vn3yjTDyCMV50TB6VRIbQNxSE4OmZR86VSbGaNpfUolm0iePBB4KdEEHmxoY5sT2+2DIvXW0rvMDP2nHZ4Mg== "@types/node@*": - version "22.7.6" - resolved "https://registry.yarnpkg.com/@types/node/-/node-22.7.6.tgz#3ec3e2b071e136cd11093c19128405e1d1f92f33" - integrity sha512-/d7Rnj0/ExXDMcioS78/kf1lMzYk4BZV8MZGTBKzTGZ6/406ukkbYlIsZmMPhcR5KlkunDHQLrtAVmSq7r+mSw== + version "22.8.2" + resolved "https://registry.yarnpkg.com/@types/node/-/node-22.8.2.tgz#8e82bb8201c0caf751dcdc61b0a262d2002d438b" + integrity sha512-NzaRNFV+FZkvK/KLCsNdTvID0SThyrs5SHB6tsD/lajr22FGC73N2QeDPM2wHtVde8mgcXuSsHQkH5cX1pbPLw== dependencies: - undici-types "~6.19.2" + undici-types "~6.19.8" "@types/vinyl@^2.0.4": version "2.0.12" @@ -464,14 +464,14 @@ braces@^3.0.3, braces@~3.0.2: fill-range "^7.1.1" browserslist@^4.23.3: - version "4.24.0" - resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.24.0.tgz#a1325fe4bc80b64fda169629fc01b3d6cecd38d4" - integrity sha512-Rmb62sR1Zpjql25eSanFGEhAxcFwfA1K0GuQcLoaJBAcENegrQut3hYdhXFF1obQfiDyqIW/cLM5HSJ/9k884A== + version "4.24.2" + resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.24.2.tgz#f5845bc91069dbd55ee89faf9822e1d885d16580" + integrity sha512-ZIc+Q62revdMcqC6aChtW4jz3My3klmCO1fEmINZY/8J3EpBg5/A/D0AKmBveUh6pgoeycoMkVMko84tuYS+Gg== dependencies: - caniuse-lite "^1.0.30001663" - electron-to-chromium "^1.5.28" + caniuse-lite "^1.0.30001669" + electron-to-chromium "^1.5.41" node-releases "^2.0.18" - update-browserslist-db "^1.1.0" + update-browserslist-db "^1.1.1" buffer-builder@^0.2.0: version "0.2.0" @@ -486,10 +486,10 @@ buffer@^6.0.3: base64-js "^1.3.1" ieee754 "^1.2.1" -caniuse-lite@^1.0.30001646, caniuse-lite@^1.0.30001663: - version "1.0.30001669" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001669.tgz#fda8f1d29a8bfdc42de0c170d7f34a9cf19ed7a3" - integrity sha512-DlWzFDJqstqtIVx1zeSpIMLjunf5SmwOw0N2Ck/QSQdS8PLS4+9HrLaYei4w8BIAL7IB/UEDu889d8vhCTPA0w== +caniuse-lite@^1.0.30001646, caniuse-lite@^1.0.30001669: + version "1.0.30001674" + resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001674.tgz#eb200a716c3e796d33d30b9c8890517a72f862c8" + integrity sha512-jOsKlZVRnzfhLojb+Ykb+gyUSp9Xb57So+fAiFlLzzTKpqg8xxSav0e40c8/4F/v9N8QSvrRRaLeVzQbLqomYw== chalk@^4.1.2: version "4.1.2" @@ -733,10 +733,10 @@ each-props@^3.0.0: is-plain-object "^5.0.0" object.defaults "^1.1.0" -electron-to-chromium@^1.5.28: - version "1.5.41" - resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.5.41.tgz#eae1ba6c49a1a61d84cf8263351d3513b2bcc534" - integrity sha512-dfdv/2xNjX0P8Vzme4cfzHqnPm5xsZXwsolTYr0eyW18IUmNyG08vL+fttvinTfhKfIKdRoqkDIC9e9iWQCNYQ== +electron-to-chromium@^1.5.41: + version "1.5.49" + resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.5.49.tgz#9358f514ab6eeed809a8689f4b39ea5114ae729c" + integrity sha512-ZXfs1Of8fDb6z7WEYZjXpgIRF6MEu8JdeGA0A40aZq6OQbS+eJpnnV49epZRna2DU/YsEjSQuGtQPPtvt6J65A== element-closest@^2.0.1: version "2.0.2" @@ -1518,9 +1518,9 @@ parse5-parser-stream@^7.1.2: parse5 "^7.0.0" parse5@^7.0.0, parse5@^7.1.2: - version "7.2.0" - resolved "https://registry.yarnpkg.com/parse5/-/parse5-7.2.0.tgz#8a0591ce9b7c5e2027173ab737d4d3fc3d826fab" - integrity sha512-ZkDsAOcxsUMZ4Lz5fVciOehNcJ+Gb8gTzcA4yl3wnc273BAybYWrQ+Ks/OjCjSEpjvQkDSeZbybK9qj2VHHdGA== + version "7.2.1" + resolved "https://registry.yarnpkg.com/parse5/-/parse5-7.2.1.tgz#8928f55915e6125f430cc44309765bf17556a33a" + integrity sha512-BuBYQYlv1ckiPdQi/ohiivi9Sagc9JG+Ozs0r7b/0iK3sKmrb0b9FdWdBbOdx6hBCM/F9Ir82ofnBhtZOjCRPQ== dependencies: entities "^4.5.0" @@ -1886,9 +1886,9 @@ sass-embedded@1.77.8: sass-embedded-win32-x64 "1.77.8" sass@^1.77.8: - version "1.80.2" - resolved "https://registry.yarnpkg.com/sass/-/sass-1.80.2.tgz#9d13d85a4f81bb17e09d1dc3e1c0944f7fd7315e" - integrity sha512-9wXY8cGBlUmoUoT+vwOZOFCiS+naiWVjqlreN9ar9PudXbGwlMTFwCR5K9kB4dFumJ6ib98wZyAObJKsWf1nAA== + version "1.80.4" + resolved "https://registry.yarnpkg.com/sass/-/sass-1.80.4.tgz#bc0418fd796cad2f1a1309d8b4d7fe44b7027de0" + integrity sha512-rhMQ2tSF5CsuuspvC94nPM9rToiAFw2h3JTrLlgmNw1MH79v8Cr3DH6KF6o6r+8oofY3iYVPUf66KzC8yuVN1w== dependencies: "@parcel/watcher" "^2.4.1" chokidar "^4.0.0" @@ -2067,7 +2067,7 @@ undertaker@^2.0.0: last-run "^2.0.0" undertaker-registry "^2.0.0" -undici-types@~6.19.2: +undici-types@~6.19.8: version "6.19.8" resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-6.19.8.tgz#35111c9d1437ab83a7cdc0abae2f26d88eda0a02" integrity sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw== @@ -2077,7 +2077,7 @@ undici@^6.19.5: resolved "https://registry.yarnpkg.com/undici/-/undici-6.20.1.tgz#fbb87b1e2b69d963ff2d5410a40ffb4c9e81b621" integrity sha512-AjQF1QsmqfJys+LXfGTNum+qw4S88CojRInG/6t31W/1fk6G59s92bnAvGz5Cmur+kQv2SURXEvvudLmbrE8QA== -update-browserslist-db@^1.1.0: +update-browserslist-db@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/update-browserslist-db/-/update-browserslist-db-1.1.1.tgz#80846fba1d79e82547fb661f8d141e0945755fe5" integrity sha512-R8UzCaa9Az+38REPiJ1tXlImTJXlVfgHZsglwBD/k6nj76ctsH1E3q4doGrukiLQd3sGQYu56r5+lo5r94l29A== From 027e1c44f9defdb820cb3714b7f24db7e95dcf46 Mon Sep 17 00:00:00 2001 From: Stephen Chudleigh Date: Tue, 29 Oct 2024 09:50:01 -0700 Subject: [PATCH 13/23] set node-version for circleci --- .circleci/config.yml | 3 ++- yarn.lock | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index a10030c2..03389488 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -4,7 +4,7 @@ orbs: cloudfoundry: circleci/cloudfoundry@1.0 ruby: circleci/ruby@2.1.3 browser-tools: circleci/browser-tools@1.4.8 - node: circleci/node@5.2.0 + node: circleci/node@6.3.0 docker: circleci/docker@2.6.0 executors: @@ -30,6 +30,7 @@ commands: description: 'Install yarn modules and build assets' steps: - node/install: + node-version: 20.15.1 install-yarn: true - node/install-packages: pkg-manager: yarn diff --git a/yarn.lock b/yarn.lock index 8ce411e1..d1ecafd2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -254,9 +254,9 @@ integrity sha512-Q5Vn3yjTDyCMV50TB6VRIbQNxSE4OmZR86VSbGaNpfUolm0iePBB4KdEEHmxoY5sT2+2DIvXW0rvMDP2nHZ4Mg== "@types/node@*": - version "22.8.2" - resolved "https://registry.yarnpkg.com/@types/node/-/node-22.8.2.tgz#8e82bb8201c0caf751dcdc61b0a262d2002d438b" - integrity sha512-NzaRNFV+FZkvK/KLCsNdTvID0SThyrs5SHB6tsD/lajr22FGC73N2QeDPM2wHtVde8mgcXuSsHQkH5cX1pbPLw== + version "22.8.3" + resolved "https://registry.yarnpkg.com/@types/node/-/node-22.8.3.tgz#ebc5dc6fdd37c4a0f992a7b4ca510c733617eaa7" + integrity sha512-ZlijaZM38In/raEdZoNKKfIVJEA+4NTsvhGQTgQt4y2/Zgokyz4NUvOch108O3Q1q5lJ170h1hShfPfRPW7BwA== dependencies: undici-types "~6.19.8" From d3fb1bed54df0ab859162c79d99ecea723607a9d Mon Sep 17 00:00:00 2001 From: Chris Preisinger Date: Tue, 29 Oct 2024 18:51:00 -0400 Subject: [PATCH 14/23] 61 Make eval criteria respect eval form disabled --- .../_evaluation_criterion_fields.html.erb | 32 ++++++++++--------- app/views/evaluation_forms/_form.html.erb | 24 +++++++------- 2 files changed, 30 insertions(+), 26 deletions(-) diff --git a/app/views/evaluation_forms/_evaluation_criterion_fields.html.erb b/app/views/evaluation_forms/_evaluation_criterion_fields.html.erb index acf99613..4f2cc9ca 100644 --- a/app/views/evaluation_forms/_evaluation_criterion_fields.html.erb +++ b/app/views/evaluation_forms/_evaluation_criterion_fields.html.erb @@ -25,7 +25,7 @@ class: 'usa-input', placeholder: 'Add criteria title here', required: true, - disabled: is_template, + disabled: is_template || form_disabled, data: {"evaluation-criteria-target": "titleField"} %>
  • @@ -38,7 +38,7 @@ class: 'usa-textarea', placeholder: 'Add criteria description here', required: true, - disabled: is_template, + disabled: is_template || form_disabled, data: {"evaluation-criteria-target": "descriptionField"} %>
    @@ -53,7 +53,7 @@ step: 1, placeholder: "Add criteria points/weight here", required: true, - disabled: is_template, + disabled: is_template || form_disabled, data: {"evaluation-criteria-target": "pointsOrWeightField"} %>
    @@ -70,7 +70,7 @@ class: "usa-radio scoring-type-radio", checked: f.object.scoring_type == value, required: true, - disabled: is_template, + disabled: is_template || form_disabled, data: { "evaluation-criteria-target": "scoringTypeRadio", action: "click->evaluation-criteria#toggleScoringType" @@ -83,7 +83,7 @@
    -
    +
    <%= f.label :rating_scale_options, "Rating Scale Options", for: criteria_field_id(f, "rating_scale_options", is_template) %>
    @@ -91,7 +91,7 @@ id: criteria_field_id(f, "option_range_start", is_template), name: criteria_field_name(f, "option_range_start", is_template), class: "option-range-start", - disabled: !f.object.binary?, + disabled: !f.object.binary? || form_disabled, value: 0, data: {"evaluation-criteria-target": "hiddenOptionRangeStart"} %> @@ -99,7 +99,7 @@ id: criteria_field_id(f, "option_range_end", is_template), name: criteria_field_name(f, "option_range_end", is_template), class: "option-range-end", - disabled: !f.object.binary?, + disabled: !f.object.binary? || form_disabled, value: 1, data: {"evaluation-criteria-target": "hiddenOptionRangeEnd"} %> @@ -111,7 +111,7 @@ id: criteria_field_id(f, "option_range_start", is_template), name: criteria_field_name(f, "option_range_start", is_template), class: "usa-select margin-0 option-range-select option-range-start", - disabled: !f.object.rating?, + disabled: !f.object.rating? || form_disabled, include_blank: true, data: { "evaluation-criteria-target": "selectOptionRangeStart", @@ -123,7 +123,7 @@ id: criteria_field_id(f, "option_range_end", is_template), name: criteria_field_name(f, "option_range_end", is_template), class: "usa-select margin-0 option-range-select option-range-end", - disabled: !f.object.rating?, + disabled: !f.object.rating? || form_disabled, include_blank: true, data: { "evaluation-criteria-target": "selectOptionRangeEnd", @@ -147,7 +147,7 @@ class: "usa-input margin-0", value: f.object.option_labels[index.to_s], required: true, - disabled: disabledOptionLabel, + disabled: disabledOptionLabel || form_disabled, data: {"evaluation-criteria-target": "optionLabelInput"} %>
    @@ -155,9 +155,11 @@
    -
    - <%= button_tag type: "button", class: "delete-criteria-button usa-button usa-button--unstyled", title: "Delete criteria", data: {action: "click->evaluation-criteria#removeCriteria"} do %> - Remove criteria - <% end %> -
    + <% if !form_disabled %> +
    + <%= button_tag type: "button", class: "delete-criteria-button usa-button usa-button--unstyled", title: "Delete criteria", data: {action: "click->evaluation-criteria#removeCriteria"} do %> + Remove criteria + <% end %> +
    + <% end %>
    diff --git a/app/views/evaluation_forms/_form.html.erb b/app/views/evaluation_forms/_form.html.erb index 903bf862..266834c1 100644 --- a/app/views/evaluation_forms/_form.html.erb +++ b/app/views/evaluation_forms/_form.html.erb @@ -97,28 +97,30 @@ <% if evaluation_form.evaluation_criteria.empty? %> <%= form.fields_for :evaluation_criteria, EvaluationCriterion.new do |ec| %>
    - <%= render partial: 'evaluation_criterion_fields', locals: { f: ec, is_template: false } %> + <%= render partial: 'evaluation_criterion_fields', locals: { f: ec, is_template: false, form_disabled: false } %>
    <% end %> <% else %> <%= form.fields_for :evaluation_criteria, include_id: false do |ec| %>
    " data-evaluation-criteria-target="criteriaRow"> - <%= render partial: 'evaluation_criterion_fields', locals: { f: ec, is_template: false } %> + <%= render partial: 'evaluation_criterion_fields', locals: { f: ec, is_template: false, form_disabled: disabled } %>
    <% end %> <% end %>
    -
    - - - <%= button_tag type: "button", id: "add-criteria-button", class: "usa-button usa-button--unstyled", title: "Add another criteria", data: {action:"click->evaluation-criteria#addCriteria"} do %> - Add another criteria + + <%= button_tag type: "button", id: "add-criteria-button", class: "usa-button usa-button--unstyled", title: "Add another criteria", data: {action: "click->evaluation-criteria#addCriteria"} do %> + Add another criteria + <% end %> <% end %>
    From 7a7307f095af08415c8954e14eabb5ca37e59512 Mon Sep 17 00:00:00 2001 From: Chris Preisinger Date: Tue, 29 Oct 2024 19:01:22 -0400 Subject: [PATCH 15/23] 61 Simplify eval criteria js for code climate1 --- .../evaluation_criteria_controller.js | 121 ++++++++++-------- 1 file changed, 68 insertions(+), 53 deletions(-) diff --git a/app/javascript/controllers/evaluation_criteria_controller.js b/app/javascript/controllers/evaluation_criteria_controller.js index 78299d37..afc84d6a 100644 --- a/app/javascript/controllers/evaluation_criteria_controller.js +++ b/app/javascript/controllers/evaluation_criteria_controller.js @@ -111,47 +111,59 @@ export default class extends Controller { } updateScoringOptions(row, scoringType) { - const scaleOptions = row.querySelector(".criteria-scale-options"); - const binaryOptions = row.querySelector(".criteria-binary-options"); - const ratingOptions = row.querySelector(".criteria-rating-options"); - const scaleOptionLabels = row.querySelector( - ".criteria-scale-option-labels" - ); - - if (scoringType === "binary") { - scaleOptions.style.display = "block"; - binaryOptions.style.display = "block"; - ratingOptions.style.display = "none"; - - this.enableInputs(binaryOptions); - this.disableInputs(ratingOptions); - - this.toggleOptionLabels(row, 0, 1); - } else if (scoringType === "rating") { - scaleOptions.style.display = "block"; - binaryOptions.style.display = "none"; - ratingOptions.style.display = "block"; - - this.enableInputs(ratingOptions); - this.disableInputs(binaryOptions); + const options = { + scaleOptions: row.querySelector(".criteria-scale-options"), + binaryOptions: row.querySelector(".criteria-binary-options"), + ratingOptions: row.querySelector(".criteria-rating-options"), + scaleOptionLabels: row.querySelector(".criteria-scale-option-labels"), + }; + + console.log(options); + + switch (scoringType) { + case "binary": + this.showBinaryOptions(options); + this.toggleOptionLabels(row, 0, 1); + break; + case "rating": + this.showRatingOptions(row, options); + break; + default: + this.hideAllOptions(options); + break; + } + } - const start = parseInt( - row.querySelector(".option-range-select.option-range-start").value - ); - const end = parseInt( - row.querySelector(".option-range-select.option-range-end").value - ); + showBinaryOptions(options) { + options.scaleOptions.style.display = "block"; + options.binaryOptions.style.display = "block"; + options.ratingOptions.style.display = "none"; + this.enableInputs(options.binaryOptions); + this.disableInputs(options.ratingOptions); + } - this.toggleOptionLabels(row, start, end); - } else { - scaleOptions.style.display = "none"; - binaryOptions.style.display = "none"; - ratingOptions.style.display = "none"; + showRatingOptions(row, options) { + options.scaleOptions.style.display = "block"; + options.binaryOptions.style.display = "none"; + options.ratingOptions.style.display = "block"; + this.enableInputs(options.ratingOptions); + this.disableInputs(options.binaryOptions); + const start = parseInt( + row.querySelector(".option-range-select.option-range-start").value + ); + const end = parseInt( + row.querySelector(".option-range-select.option-range-end").value + ); + this.toggleOptionLabels(row, start, end); + } - this.disableInputs(binaryOptions); - this.disableInputs(ratingOptions); - this.disableInputs(scaleOptionLabels); - } + hideAllOptions(options) { + options.scaleOptions.style.display = "none"; + options.binaryOptions.style.display = "none"; + options.ratingOptions.style.display = "none"; + this.disableInputs(options.binaryOptions); + this.disableInputs(options.ratingOptions); + this.disableInputs(options.scaleOptionLabels); } toggleOptionLabels(row, start, end) { @@ -186,21 +198,24 @@ export default class extends Controller { } validateInputs(event) { - let accordionButton = event.target.closest(".usa-accordion__button"); - let sectionId = accordionButton.getAttribute("aria-controls"); - let section = document.getElementById(sectionId); - let requiredFields = section.querySelectorAll("[required]"); - - for (let field of requiredFields) { - if (!field.checkValidity()) { - if (!field.reportValidity()) { - event.preventDefault(); - event.stopPropagation(); - - return false; - } - } + const section = document.getElementById( + event.target + .closest(".usa-accordion__button") + .getAttribute("aria-controls") + ); + + if (this.checkRequiredFields(section)) { + return true; + } else { + event.preventDefault(); + event.stopPropagation(); + return false; } - return true; + } + + checkRequiredFields(section) { + return Array.from(section.querySelectorAll("[required]")).every((field) => + field.checkValidity() ? true : field.reportValidity() + ); } } From 9e04a71cb246e69d46e0c676d5b432db601c8314 Mon Sep 17 00:00:00 2001 From: Chris Preisinger Date: Tue, 29 Oct 2024 22:13:49 -0400 Subject: [PATCH 16/23] 61 Styling and add max length for eval criteria --- app/models/evaluation_criterion.rb | 2 + .../_evaluation_criterion_fields.html.erb | 85 ++++++++++++------- app/views/evaluation_forms/_form.html.erb | 1 + 3 files changed, 59 insertions(+), 29 deletions(-) diff --git a/app/models/evaluation_criterion.rb b/app/models/evaluation_criterion.rb index b491bcc9..922fb813 100644 --- a/app/models/evaluation_criterion.rb +++ b/app/models/evaluation_criterion.rb @@ -34,5 +34,7 @@ class EvaluationCriterion < ApplicationRecord # Validations validates :title, :description, :points_or_weight, presence: true + validates :title, length: { maximum: 150 } + validates :description, length: { maximum: 1000 } validates :points_or_weight, numericality: { only_integer: true } end diff --git a/app/views/evaluation_forms/_evaluation_criterion_fields.html.erb b/app/views/evaluation_forms/_evaluation_criterion_fields.html.erb index 4f2cc9ca..a36cc5ee 100644 --- a/app/views/evaluation_forms/_evaluation_criterion_fields.html.erb +++ b/app/views/evaluation_forms/_evaluation_criterion_fields.html.erb @@ -17,38 +17,48 @@ <%= f.hidden_field :_destroy, class: "destroy-evaluation-criteria", data: {"evaluation-criteria-target": "destroyField"} %> <% end %> -
    - <%= f.label :title, "Criteria title", for: criteria_field_id(f, "title", is_template) %> +
    + <%= f.label :title, "Criteria title", for: criteria_field_id(f, "title", is_template), class: "text-bold" %> + * + <%= image_tag "images/usa-icons/help_outline.svg", width: 16, height: 16, alt: "Help for criteria title" %> + <%= f.text_field :title, id: criteria_field_id(f, "title", is_template), name: criteria_field_name(f, "title", is_template), - class: 'usa-input', - placeholder: 'Add criteria title here', + class: "usa-input", + placeholder: "Add criteria title here", + maxlength: 150, required: true, disabled: is_template || form_disabled, data: {"evaluation-criteria-target": "titleField"} %>
    -
    - <%= f.label :description, "Criteria description", for: criteria_field_id(f, "description", is_template) %> - <%= f.text_area :description, - id: criteria_field_id(f, "description", is_template), - name: criteria_field_name(f, "description", is_template), - class: 'usa-textarea', - placeholder: 'Add criteria description here', - required: true, - disabled: is_template || form_disabled, - data: {"evaluation-criteria-target": "descriptionField"} - %> +
    +
    + <%= f.label :description, "Criteria description", for: criteria_field_id(f, "description", is_template), class: "text-bold" %> + * + <%= image_tag "images/usa-icons/help_outline.svg", width: 16, height: 16, alt: "Help for criteria title" %> + + <%= f.text_area :description, + id: criteria_field_id(f, "description", is_template), + name: criteria_field_name(f, "description", is_template), + class: "usa-textarea usa-character-count__field", + placeholder: "Add criteria description here", + maxlength: 1000, + required: true, + disabled: is_template || form_disabled, + data: {"evaluation-criteria-target": "descriptionField"} + %> +
    + You can enter up to 1000 characters
    -
    - <%= f.label :points_or_weight, "Criteria Points/Weight", for: criteria_field_id(f, "points_or_weight", is_template) %> +
    <%= f.number_field :points_or_weight, id: criteria_field_id(f, "points_or_weight", is_template), name: criteria_field_name(f, "points_or_weight", is_template), - class: 'usa-input', + class: "usa-input flex-1 margin-top-0 margin-right-2 font-sans-lg", min: 1, step: 1, placeholder: "Add criteria points/weight here", @@ -56,18 +66,35 @@ disabled: is_template || form_disabled, data: {"evaluation-criteria-target": "pointsOrWeightField"} %> + +
    + <%= f.label :points_or_weight, "Criteria Points/Weight", + for: criteria_field_id(f, "points_or_weight", is_template), + class: "text-bold" + %> + + * + + <%= image_tag "images/usa-icons/help_outline.svg", + width: 16, height: 16, alt: "Help for criteria title", + class: "flex-0" + %> +
    -
    - <%= f.label :scoring_type, "Scoring Type", for: criteria_field_id(f, "scoring_type", is_template) %> +
    + <%= f.label :scoring_type, "Scoring Type", for: criteria_field_id(f, "scoring_type", is_template), class: "font-sans-lg text-bold" %> + * + <%= image_tag "images/usa-icons/help_outline.svg", width: 16, height: 16, alt: "Help for criteria title" %> + <% scoring_types = { "numeric" => "Numeric score / points", "rating" => "Rating scale", "binary" => "Binary scale" } %>
    <% scoring_types.each do |value, label| %> -
    +
    <%= f.radio_button :scoring_type, value, id: criteria_field_id(f, "scoring_type_#{value}", is_template), name: criteria_field_name(f, :scoring_type, is_template), - class: "usa-radio scoring-type-radio", + class: "usa-radio__input scoring-type-radio", checked: f.object.scoring_type == value, required: true, disabled: is_template || form_disabled, @@ -77,14 +104,14 @@ } %> - <%= label_tag criteria_field_id(f, "scoring_type_#{value}", is_template), label %> + <%= label_tag criteria_field_id(f, "scoring_type_#{value}", is_template), label, class: "usa-radio__label" %>
    <% end %>
    -
    - <%= f.label :rating_scale_options, "Rating Scale Options", for: criteria_field_id(f, "rating_scale_options", is_template) %> +
    + <%= f.label :rating_scale_options, "Rating Scale Options", for: criteria_field_id(f, "rating_scale_options", is_template), class: "text-bold" %>
    <%= f.hidden_field :option_range_start, @@ -110,7 +137,7 @@ <%= f.select :option_range_start, options_for_select((0..1).to_a, f.object.option_range_start), {}, id: criteria_field_id(f, "option_range_start", is_template), name: criteria_field_name(f, "option_range_start", is_template), - class: "usa-select margin-0 option-range-select option-range-start", + class: "usa-select margin-0 height-auto width-auto font-sans-md text-bold option-range-select option-range-start", disabled: !f.object.rating? || form_disabled, include_blank: true, data: { @@ -118,11 +145,11 @@ action: "change->evaluation-criteria#toggleOptionRange" } %> - to + to <%= f.select :option_range_end, options_for_select((2..10).to_a, f.object.option_range_end), {}, id: criteria_field_id(f, "option_range_end", is_template), name: criteria_field_name(f, "option_range_end", is_template), - class: "usa-select margin-0 option-range-select option-range-end", + class: "usa-select margin-0 height-auto width-auto font-sans-md text-bold option-range-select option-range-end", disabled: !f.object.rating? || form_disabled, include_blank: true, data: { @@ -139,7 +166,7 @@
    - <%= label_tag criteria_field_id(f, "option_labels", is_template) ++ "_#{index}", index %> + <%= label_tag criteria_field_id(f, "option_labels", is_template) ++ "_#{index}", index, class: "font-sans-lg text-bold text-base-light" %> <%= f.text_field "option_labels", id: criteria_field_id(f, "option_labels", is_template) ++ "_#{index}", diff --git a/app/views/evaluation_forms/_form.html.erb b/app/views/evaluation_forms/_form.html.erb index 266834c1..9efcae0c 100644 --- a/app/views/evaluation_forms/_form.html.erb +++ b/app/views/evaluation_forms/_form.html.erb @@ -16,6 +16,7 @@ phase = evaluation_form.phase combo_box_default_value = "#{challenge.id}.#{phase.id}.#{phase.end_date.strftime("%m/%d/%Y")}" disabled = eval_form_disabled?(evaluation_form) + disabled = false end %>
      From a8afc059d802403d521208f53e1bbfb1de89dea0 Mon Sep 17 00:00:00 2001 From: Chris Preisinger Date: Tue, 29 Oct 2024 23:07:40 -0400 Subject: [PATCH 17/23] 61 Styled add another criteria button --- app/assets/stylesheets/application.sass.scss | 8 ++++++++ app/views/evaluation_forms/_form.html.erb | 10 +++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/app/assets/stylesheets/application.sass.scss b/app/assets/stylesheets/application.sass.scss index fa5d1ded..f44a0935 100644 --- a/app/assets/stylesheets/application.sass.scss +++ b/app/assets/stylesheets/application.sass.scss @@ -9,3 +9,11 @@ dialog::backdrop { background-color: black; border-color: black; } + +#add-criteria-button.usa-button { + background-color: #4d8055; +} + +// #criteria-list .usa-accordion__button { +// background-color: #162e51; +// } \ No newline at end of file diff --git a/app/views/evaluation_forms/_form.html.erb b/app/views/evaluation_forms/_form.html.erb index 9efcae0c..8f13e59e 100644 --- a/app/views/evaluation_forms/_form.html.erb +++ b/app/views/evaluation_forms/_form.html.erb @@ -16,7 +16,6 @@ phase = evaluation_form.phase combo_box_default_value = "#{challenge.id}.#{phase.id}.#{phase.end_date.strftime("%m/%d/%Y")}" disabled = eval_form_disabled?(evaluation_form) - disabled = false end %>
        @@ -119,8 +118,13 @@
    - <%= button_tag type: "button", id: "add-criteria-button", class: "usa-button usa-button--unstyled", title: "Add another criteria", data: {action: "click->evaluation-criteria#addCriteria"} do %> - Add another criteria + <%= button_tag type: "button", id: "add-criteria-button", class: "usa-button width-full display-flex flex-column", title: "Add another criteria", data: {action: "click->evaluation-criteria#addCriteria"} do %> + <%= image_tag( + "images/usa-icons/add_circle.svg", + class: "usa-icon icon-white circle-4 margin-bottom-1", + alt: "Add criteria plus icon" + )%> +
    Add another criteria
    <% end %> <% end %>
    From 2ac908c529728c9509efe97cb5698596b4ef9107 Mon Sep 17 00:00:00 2001 From: Chris Preisinger Date: Wed, 30 Oct 2024 11:47:46 -0400 Subject: [PATCH 18/23] 61 Temp darker accordion styling for criteria --- app/assets/stylesheets/application.sass.scss | 9 +++++++++ .../_evaluation_criterion_fields.html.erb | 2 +- app/views/evaluation_forms/_form.html.erb | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/app/assets/stylesheets/application.sass.scss b/app/assets/stylesheets/application.sass.scss index f44a0935..e7415747 100644 --- a/app/assets/stylesheets/application.sass.scss +++ b/app/assets/stylesheets/application.sass.scss @@ -16,4 +16,13 @@ dialog::backdrop { // #criteria-list .usa-accordion__button { // background-color: #162e51; +// background-image: url(asset-path('../builds/images/usa-icons-bg/add--white.svg', image)),linear-gradient(transparent,transparent); +// } + +// #criteria-list .usa-accordion__button { +// background-color: #162e51; +// } + +// #criteria-list .usa-accordion__button[aria-expanded=true] { +// background-image: url(assets/images/usa-icons-bg/remove-white.svg),linear-gradient(transparent,transparent); // } \ No newline at end of file diff --git a/app/views/evaluation_forms/_evaluation_criterion_fields.html.erb b/app/views/evaluation_forms/_evaluation_criterion_fields.html.erb index a36cc5ee..3b252fec 100644 --- a/app/views/evaluation_forms/_evaluation_criterion_fields.html.erb +++ b/app/views/evaluation_forms/_evaluation_criterion_fields.html.erb @@ -1,7 +1,7 @@

    -
    +
    <% if evaluation_form.evaluation_criteria.empty? %> <%= form.fields_for :evaluation_criteria, EvaluationCriterion.new do |ec| %>
    From a631c66ba08a70abbd1597962b61ff9e9902421a Mon Sep 17 00:00:00 2001 From: Stephen Chudleigh Date: Wed, 30 Oct 2024 09:52:46 -0700 Subject: [PATCH 19/23] Update .circleci/config.yml remove duplicate version line --- .circleci/config.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index c3aa54fd..a4fb5cd0 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -30,7 +30,6 @@ commands: description: 'Install yarn modules and build assets' steps: - node/install: - node-version: 20.15.1 install-yarn: true node-version: 20.18.0 - node/install-packages: From a2e5321835789c2693c36d15937e432b194cdb82 Mon Sep 17 00:00:00 2001 From: Stephen Chudleigh Date: Wed, 30 Oct 2024 12:35:10 -0700 Subject: [PATCH 20/23] revert structure.sql --- db/structure.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/structure.sql b/db/structure.sql index 08f0e1f1..eef337bd 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -685,7 +685,7 @@ CREATE TABLE public.oban_jobs ( attempted_by text[], discarded_at timestamp without time zone, priority integer DEFAULT 0 NOT NULL, - tags character varying(255)[] DEFAULT ARRAY[]::character varying[], + tags text[] DEFAULT ARRAY[]::text[], meta jsonb DEFAULT '{}'::jsonb, cancelled_at timestamp without time zone, CONSTRAINT attempt_range CHECK (((attempt >= 0) AND (attempt <= max_attempts))), From ac91b8ee2d165fdadbfc7b35d1a3efff377e2913 Mon Sep 17 00:00:00 2001 From: Chris Preisinger Date: Thu, 31 Oct 2024 12:43:36 -0400 Subject: [PATCH 21/23] 61 Remove unsued targets and code readability --- app/assets/stylesheets/application.sass.scss | 13 ----------- .../evaluation_criteria_controller.js | 22 +++---------------- .../_evaluation_criterion_fields.html.erb | 19 +++++----------- 3 files changed, 9 insertions(+), 45 deletions(-) diff --git a/app/assets/stylesheets/application.sass.scss b/app/assets/stylesheets/application.sass.scss index e7415747..1cf4bba4 100644 --- a/app/assets/stylesheets/application.sass.scss +++ b/app/assets/stylesheets/application.sass.scss @@ -13,16 +13,3 @@ dialog::backdrop { #add-criteria-button.usa-button { background-color: #4d8055; } - -// #criteria-list .usa-accordion__button { -// background-color: #162e51; -// background-image: url(asset-path('../builds/images/usa-icons-bg/add--white.svg', image)),linear-gradient(transparent,transparent); -// } - -// #criteria-list .usa-accordion__button { -// background-color: #162e51; -// } - -// #criteria-list .usa-accordion__button[aria-expanded=true] { -// background-image: url(assets/images/usa-icons-bg/remove-white.svg),linear-gradient(transparent,transparent); -// } \ No newline at end of file diff --git a/app/javascript/controllers/evaluation_criteria_controller.js b/app/javascript/controllers/evaluation_criteria_controller.js index afc84d6a..5bc183a1 100644 --- a/app/javascript/controllers/evaluation_criteria_controller.js +++ b/app/javascript/controllers/evaluation_criteria_controller.js @@ -2,21 +2,7 @@ import { Controller } from "@hotwired/stimulus"; export default class extends Controller { - static targets = [ - "criteriaList", - "template", - "addButton", - "criteriaRow", - "scoringRadio", - "binaryOptions", - "ratingOptions", - "scaleOptions", - "hiddenOptionRangeStart", - "hiddenOptionRangeEnd", - "selectOptionRangeStart", - "selectOptionRangeEnd", - "criteriaLabelRow", - ]; + static targets = ["criteriaList", "template", "criteriaRow"]; connect() { this.counter = this.criteriaRowTargets.length; @@ -118,8 +104,6 @@ export default class extends Controller { scaleOptionLabels: row.querySelector(".criteria-scale-option-labels"), }; - console.log(options); - switch (scoringType) { case "binary": this.showBinaryOptions(options); @@ -173,7 +157,7 @@ export default class extends Controller { labelRow.style.display = index >= start && index <= end ? "flex" : "none"; const input = labelRow.querySelector("input"); - input.disabled = !(index >= start && index <= end); + input.disabled = index < start || index > end; }); } @@ -215,7 +199,7 @@ export default class extends Controller { checkRequiredFields(section) { return Array.from(section.querySelectorAll("[required]")).every((field) => - field.checkValidity() ? true : field.reportValidity() + field.reportValidity() ); } } diff --git a/app/views/evaluation_forms/_evaluation_criterion_fields.html.erb b/app/views/evaluation_forms/_evaluation_criterion_fields.html.erb index 3b252fec..793bf1ff 100644 --- a/app/views/evaluation_forms/_evaluation_criterion_fields.html.erb +++ b/app/views/evaluation_forms/_evaluation_criterion_fields.html.erb @@ -110,17 +110,16 @@
    -
    +
    <%= f.label :rating_scale_options, "Rating Scale Options", for: criteria_field_id(f, "rating_scale_options", is_template), class: "text-bold" %> -
    +
    <%= f.hidden_field :option_range_start, id: criteria_field_id(f, "option_range_start", is_template), name: criteria_field_name(f, "option_range_start", is_template), class: "option-range-start", disabled: !f.object.binary? || form_disabled, - value: 0, - data: {"evaluation-criteria-target": "hiddenOptionRangeStart"} + value: 0 %> <%= f.hidden_field :option_range_end, id: criteria_field_id(f, "option_range_end", is_template), @@ -132,7 +131,7 @@ %>
    -
    +
    <%= f.select :option_range_start, options_for_select((0..1).to_a, f.object.option_range_start), {}, id: criteria_field_id(f, "option_range_start", is_template), @@ -140,10 +139,7 @@ class: "usa-select margin-0 height-auto width-auto font-sans-md text-bold option-range-select option-range-start", disabled: !f.object.rating? || form_disabled, include_blank: true, - data: { - "evaluation-criteria-target": "selectOptionRangeStart", - action: "change->evaluation-criteria#toggleOptionRange" - } + data: { action: "change->evaluation-criteria#toggleOptionRange" } %> to <%= f.select :option_range_end, options_for_select((2..10).to_a, f.object.option_range_end), {}, @@ -152,10 +148,7 @@ class: "usa-select margin-0 height-auto width-auto font-sans-md text-bold option-range-select option-range-end", disabled: !f.object.rating? || form_disabled, include_blank: true, - data: { - "evaluation-criteria-target": "selectOptionRangeEnd", - action: "change->evaluation-criteria#toggleOptionRange" - } + data: { action: "change->evaluation-criteria#toggleOptionRange" } %>
    From 2d052532d17012dc1f7ba82d7e180ac617ce1bf5 Mon Sep 17 00:00:00 2001 From: Chris Preisinger Date: Thu, 31 Oct 2024 16:05:59 -0400 Subject: [PATCH 22/23] 61 Add the confirmation screen for eval form save --- app/controllers/evaluation_forms_controller.rb | 7 +++++-- app/views/evaluation_forms/confirmation.html.erb | 15 +++++++++++++++ config/routes.rb | 1 + 3 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 app/views/evaluation_forms/confirmation.html.erb diff --git a/app/controllers/evaluation_forms_controller.rb b/app/controllers/evaluation_forms_controller.rb index 35f318ef..d8c5fed0 100644 --- a/app/controllers/evaluation_forms_controller.rb +++ b/app/controllers/evaluation_forms_controller.rb @@ -26,7 +26,7 @@ def create respond_to do |format| if @evaluation_form.save format.html do - redirect_to evaluation_forms_url, notice: I18n.t("evaluation_form_saved") + redirect_to evaluation_forms_confirmation_path, notice: I18n.t("evaluation_form_saved") end format.json { render :show, status: :created, location: @evaluation_form } else @@ -41,7 +41,7 @@ def update respond_to do |format| if @evaluation_form.update(evaluation_form_params) format.html do - redirect_to evaluation_forms_url, notice: I18n.t("evaluation_form_saved") + redirect_to evaluation_forms_confirmation_path, notice: I18n.t("evaluation_form_saved") end format.json { render :show, status: :ok, location: @evaluation_form } else @@ -61,6 +61,9 @@ def destroy end end + # GET /evaluation_forms/confirmation + def confirmation; end + private # Use callbacks to share common setup or constraints between actions. diff --git a/app/views/evaluation_forms/confirmation.html.erb b/app/views/evaluation_forms/confirmation.html.erb new file mode 100644 index 00000000..94013c93 --- /dev/null +++ b/app/views/evaluation_forms/confirmation.html.erb @@ -0,0 +1,15 @@ +
    +
    +

    + Evaluation Form Saved +

    +

    + Your evaluation form is saved. + You can edit it until the end date of your challenge. + During evaluation period the form will be available to your evaluators + and you will only be able to edit evaluation period end date if needed. +

    + <%= link_to "Manage Evaluation Forms", evaluation_forms_path, class: "usa-button" %> +
    +
    +
    \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index a4f9a207..f5f5a7b0 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -11,6 +11,7 @@ get '/dashboard', to: "dashboard#index" resources :evaluations, only: [:index] + get '/evaluation_forms/confirmation', to: 'evaluation_forms#confirmation' resources :evaluation_forms post '/evaluation_forms/clone', to: 'evaluation_forms#create_from_existing' resources :manage_submissions, only: [:index] From aba2de01dd275595441f35cfaa3bf1613cf04adc Mon Sep 17 00:00:00 2001 From: Stephen Chudleigh Date: Thu, 31 Oct 2024 16:22:50 -0700 Subject: [PATCH 23/23] grammar --- app/views/evaluation_forms/confirmation.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/evaluation_forms/confirmation.html.erb b/app/views/evaluation_forms/confirmation.html.erb index 94013c93..ea4990d9 100644 --- a/app/views/evaluation_forms/confirmation.html.erb +++ b/app/views/evaluation_forms/confirmation.html.erb @@ -6,7 +6,7 @@

    Your evaluation form is saved. You can edit it until the end date of your challenge. - During evaluation period the form will be available to your evaluators + During the evaluation period, the form will be available to your evaluators, and you will only be able to edit evaluation period end date if needed.

    <%= link_to "Manage Evaluation Forms", evaluation_forms_path, class: "usa-button" %>