diff --git a/Gemfile.lock b/Gemfile.lock index 8dd993d79..24dcf86b9 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -356,7 +356,7 @@ GEM public_suffix (5.0.3) puma (6.4.0) nio4r (~> 2.0) - racc (1.7.1) + racc (1.7.2) rack (2.2.8) rack-cors (2.0.1) rack (>= 2.0.0) diff --git a/app/controllers/admin/cx_collection_details_controller.rb b/app/controllers/admin/cx_collection_details_controller.rb index 95debf307..8a66f4e5b 100644 --- a/app/controllers/admin/cx_collection_details_controller.rb +++ b/app/controllers/admin/cx_collection_details_controller.rb @@ -1,5 +1,6 @@ class Admin::CxCollectionDetailsController < AdminController before_action :set_cx_collection_detail, only: %i[ show edit update destroy ] + before_action :set_cx_collections, only: %i[ new edit ] def index @cx_collection_details = CxCollectionDetail.all @@ -56,6 +57,14 @@ def set_cx_collection_detail @cx_collection_detail = CxCollectionDetail.find(params[:id]) end + def set_cx_collections + if service_manager_permissions? + @cx_collections = CxCollection.all.includes(:organization) + else + @cx_collections = current_user.organization.cx_collections + end + end + def cx_collection_detail_params params.require(:cx_collection_detail).permit(:cx_collection_id, :service_id, :transaction_point, :channel, :service_stage_id, :volume_of_customers, :volume_of_customers_provided_survey_opportunity, :volume_of_respondents, :omb_control_number, :federal_register_url, :reflection_text, :survey_type, :survey_title, :trust_question_text) end diff --git a/app/models/organization.rb b/app/models/organization.rb index f277fd030..0a08b31e2 100644 --- a/app/models/organization.rb +++ b/app/models/organization.rb @@ -8,6 +8,7 @@ class Organization < ApplicationRecord has_many :services has_many :websites has_many :collections + has_many :cx_collections has_many :cscrm_data_collections has_many :cscrm_data_collections2, class_name: "CscrmDataCollection2" has_many :goals diff --git a/app/views/admin/cscrm_data_collections/_form.html.erb b/app/views/admin/cscrm_data_collections/_form.html.erb index 27bb48986..5617ba857 100644 --- a/app/views/admin/cscrm_data_collections/_form.html.erb +++ b/app/views/admin/cscrm_data_collections/_form.html.erb @@ -43,7 +43,7 @@
<%= form.label :quarter, class: "usa-label" %> - <%= form.text_field :quarter, class: "usa-input", required: true %> + <%= form.number_field :quarter, class: "usa-input", required: true, min: 1, max: 4 %>
diff --git a/app/views/admin/cscrm_data_collections2/_form.html.erb b/app/views/admin/cscrm_data_collections2/_form.html.erb index 6b0ae5c5d..6f70490a1 100644 --- a/app/views/admin/cscrm_data_collections2/_form.html.erb +++ b/app/views/admin/cscrm_data_collections2/_form.html.erb @@ -53,7 +53,7 @@
<%= form.label :quarter, class: "usa-label" %> - <%= form.text_field :quarter, class: "usa-input", required: true %> + <%= form.number_field :quarter, class: "usa-input", required: true, min: 1, max: 4 %>
diff --git a/app/views/admin/cx_collection_details/_form.html.erb b/app/views/admin/cx_collection_details/_form.html.erb index 3b73e2f5b..bd25ed744 100644 --- a/app/views/admin/cx_collection_details/_form.html.erb +++ b/app/views/admin/cx_collection_details/_form.html.erb @@ -15,7 +15,7 @@ <%= form.label :cx_collection_id, class: "usa-label" %> <%= form.hidden_field :cx_collection_id, class: "usa-input", value: cx_collection_detail.cx_collection_id %> <%= form.select :cx_collection_id, - CxCollection.all.map { |collection| ["#{collection.name} - #{collection.organization.name}", collection.id]}, + cx_collections.map { |collection| ["#{collection.name} - #{collection.organization.name}", collection.id]}, { include_blank: true }, class: "usa-select" %>
@@ -53,7 +53,7 @@
<%= form.label :survey_type, class: "usa-label" %> - <%= form.select :survey_type, [:seven_questions, :yes_no_buttons], + <%= form.select :survey_type, [["A-11 7 driver questions", :seven_questions], ["A-11 Yes/no thumbs buttons", :yes_no_buttons] ], { include_blank: true }, { class: "usa-select" } %>
@@ -75,7 +75,7 @@
<%= form.label :federal_register_url, class: "usa-label" %> - <%= form.number_field :federal_register_url, class: "usa-input" %> + <%= form.text_field :federal_register_url, class: "usa-input" %>
diff --git a/app/views/admin/cx_collection_details/edit.html.erb b/app/views/admin/cx_collection_details/edit.html.erb index 527168549..256da82e4 100644 --- a/app/views/admin/cx_collection_details/edit.html.erb +++ b/app/views/admin/cx_collection_details/edit.html.erb @@ -9,7 +9,9 @@ <% end %>

-<%= render "form", cx_collection_detail: @cx_collection_detail %> +<%= render "form", + cx_collection_detail: @cx_collection_detail, + cx_collections: @cx_collections %>
diff --git a/app/views/admin/cx_collection_details/new.html.erb b/app/views/admin/cx_collection_details/new.html.erb index 3cdde43f5..0866da321 100644 --- a/app/views/admin/cx_collection_details/new.html.erb +++ b/app/views/admin/cx_collection_details/new.html.erb @@ -8,10 +8,9 @@ <% end %>

-<%= render "form", cx_collection_detail: @cx_collection_detail %> +<%= render "form", + cx_collection_detail: @cx_collection_detail, + cx_collections: @cx_collections %>
- -
- <%= link_to "Back to cx collection details", admin_cx_collection_details_path %> -
+
\ No newline at end of file diff --git a/app/views/admin/cx_collections/_form.html.erb b/app/views/admin/cx_collections/_form.html.erb index e35191578..784a6b1e7 100644 --- a/app/views/admin/cx_collections/_form.html.erb +++ b/app/views/admin/cx_collections/_form.html.erb @@ -14,7 +14,7 @@ <% if performance_manager_permissions? %>
<%= form.label :user_id, class: "usa-label" %> - <%= form.select :user_id, options_for_select(User.all.collect { |u| [u.email, u.id] }, cx_collection.user_id), { prompt: "Which User?", include_blank: true }, { class: "usa-select" } %> + <%= form.select :user_id, options_for_select(User.all.collect { |u| [u.email, u.id] }, cx_collection.user_id || current_user.id), { prompt: "Which User?", include_blank: true }, { class: "usa-select" } %>
<% else %> <%= form.hidden_field :user_id, value: current_user.id %> @@ -36,12 +36,7 @@
<%= form.label :service_provider_id, "HISP Service Provider", class: "usa-label" %> - <%= form.select :service_provider_id, ServiceProvider.all.map { |h| ["#{h.organization.abbreviation} - #{h.organization.name} - #{h.name}", h.id] }, { include_blank: true }, { class: "usa-select", required: true } %> -
- -
- <%= form.label :service_id, "Service", class: "usa-label" %> - <%= form.select :service_id, Service.all.map { |h| ["#{h.organization.abbreviation} - #{h.organization.name} - #{h.name}", h.id] }, { include_blank: true }, { class: "usa-select", required: true } %> + <%= form.select :service_provider_id, ServiceProvider.all.includes(:organization).map { |h| ["#{h.organization.abbreviation} - #{h.organization.name} - #{h.name}", h.id] }, { include_blank: true }, { class: "usa-select", required: true } %>
@@ -51,7 +46,7 @@
<%= form.label :quarter, class: "usa-label" %> - <%= form.text_field :quarter, class: "usa-input", required: true %> + <%= form.number_field :quarter, class: "usa-input", required: true, min: 1, max: 4 %>
diff --git a/app/views/admin/forms/_admin_options.html.erb b/app/views/admin/forms/_admin_options.html.erb index 632d14dec..928eaefee 100644 --- a/app/views/admin/forms/_admin_options.html.erb +++ b/app/views/admin/forms/_admin_options.html.erb @@ -42,7 +42,7 @@
<%= f.label :kind, class: "usa-label" %> - <%= f.text_field :kind, class: "usa-input" %> + <%= f.select :kind, options_for_select(["a11", "a11_v2", "a11_yes_no", "open_ended", "other"], selected: @form.kind), { include_blank: true }, class: "usa-select" %>
diff --git a/app/views/components/_form_a11_v2_script.html.erb b/app/views/components/_form_a11_v2_script.html.erb new file mode 100644 index 000000000..7f10267ff --- /dev/null +++ b/app/views/components/_form_a11_v2_script.html.erb @@ -0,0 +1,42 @@ +window.addEventListener('load', function() { + + function hideQ2() { + const q2 = document.getElementById("answer_02"); + const q2_container = q2.closest(".question"); + q2_container.style.display = 'none'; + } + function showQ2() { + const q2 = document.getElementById("answer_02"); + const q2_container = q2.closest(".question"); + q2_container.style.display = 'block'; + } + + function hideQ3() { + const q3 = document.getElementById("answer_03"); + const q3_container = q3.closest(".question"); + q3_container.style.display = 'none'; + } + function showQ3() { + const q3 = document.getElementById("answer_03"); + const q3_container = q3.closest(".question"); + q3_container.style.display = 'block'; + } + + function handleThumbsUpDownClick(a, b, c) { + if(a.currentTarget.value === '1') { + showQ2() + hideQ3() + } else if(a.currentTarget.value === '0') { + hideQ2() + showQ3() + } + } + + const radioButtons = document.getElementById("answer_01").getElementsByTagName("input"); + for (const radioButton of radioButtons) { + radioButton.addEventListener("click", handleThumbsUpDownClick) + } + + hideQ2() + hideQ3() +}) diff --git a/app/views/components/_form_a11_yes_no_script.html.erb b/app/views/components/_form_a11_yes_no_script.html.erb new file mode 100644 index 000000000..72b722a07 --- /dev/null +++ b/app/views/components/_form_a11_yes_no_script.html.erb @@ -0,0 +1,42 @@ +// Assumes: 2 questions: +// 1. radio buttons. +// 2. open text +// Hides the 2nd question to start, and reveals it when selecting a radio button +// +window.addEventListener('load', function() { + const q2 = document.getElementById("answer_02"); + const q2_container = q2.closest(".question"); + const submitButton = document.getElementById("touchpoints-form-<%= form.short_uuid %>").getElementsByClassName("submit-button")[0] + + function hideQ2() { + q2_container.style.display = 'none'; + } + function showQ2() { + q2_container.style.display = 'block'; + } + + function hideSubmitButton() { + submitButton.style.display = 'none'; + } + function showSubmitButton() { + submitButton.style.display = 'block'; + } + + function handleThumbsUpDownClick(a, b, c) { + if(a.currentTarget.value === '1') { + showQ2() + showSubmitButton() + } else if(a.currentTarget.value === '0') { + showQ2() + showSubmitButton() + } + } + + const radioButtons = document.getElementById("answer_01").getElementsByTagName("input"); + for (const radioButton of radioButtons) { + radioButton.addEventListener("click", handleThumbsUpDownClick) + } + + hideQ2() + hideSubmitButton() +}) diff --git a/app/views/components/widget/_fba.js.erb b/app/views/components/widget/_fba.js.erb index 7c061f5ef..524dfd8c5 100644 --- a/app/views/components/widget/_fba.js.erb +++ b/app/views/components/widget/_fba.js.erb @@ -42,8 +42,14 @@ function FBAform(d, N) { this.dialogOpen = false; // initially false this.successState = false; // initially false this.pagination(); + this.formSpecificScript(); return this; }, + formSpecificScript: function() { + <%- if ["a11_v2", "a11_yes_no"].include?(form.kind) %> + <%= render "components/form_#{form.kind}_script", form: form %> + <% end %> + }, bindEventListeners: function() { var self = this; d.addEventListener('keyup', function (event) { diff --git a/app/views/components/widget/_no_modal.html.erb b/app/views/components/widget/_no_modal.html.erb index 4909187b1..fc6d6d65b 100644 --- a/app/views/components/widget/_no_modal.html.erb +++ b/app/views/components/widget/_no_modal.html.erb @@ -2,25 +2,27 @@ id="touchpoints-form-<%= form.short_uuid %>" data-touchpoints-form-id="<%= form.short_uuid %>" tabindex="-1">
+ <%- if form.title.present? || form.logo.present? %>

- <% if form.display_header_logo && form.logo.present? %> + <%- if form.display_header_logo && form.logo.present? %> <%= image_tag(form.logo.tag.url, alt: "Organization logo", class: "form-header-logo") %>
<% end %> - <% if form.display_header_square_logo && form.logo.present? %> + <%- if form.display_header_square_logo && form.logo.present? %> <%= image_tag(form.logo.logo_square.url, alt: "Organization logo", class: "form-header-logo-square") %> <% end %> - <%= form.title || "Form Title" %> -

+ <%= form.title %> + + <% end %> - <% unless form.delivery_method == "inline" %> + <%- unless form.delivery_method == "inline" %> × <% end -%> - <% if form.instructions? %> + <%- if form.instructions? %>

<%= sanitize(form.instructions) %>

diff --git a/app/views/components/widget/_widget.css.erb b/app/views/components/widget/_widget.css.erb index 07d4da602..84b79d432 100644 --- a/app/views/components/widget/_widget.css.erb +++ b/app/views/components/widget/_widget.css.erb @@ -19,7 +19,8 @@ } .fba-modal-dialog .wrapper { - padding: 20px 20px 0 20px; + padding-left: 20px; + padding-right: 20px; } .fixed-tab-button { diff --git a/app/views/devise/sessions/new.html.erb b/app/views/devise/sessions/new.html.erb index 46df5d74b..12089a3ab 100644 --- a/app/views/devise/sessions/new.html.erb +++ b/app/views/devise/sessions/new.html.erb @@ -28,7 +28,7 @@ <% end %> <% if ENV['GITHUB_CLIENT_ID'].present? %>

- <%= link_to "Agree and sign in with GitHub", user_github_omniauth_authorize_path, + <%= button_to "Agree and sign in with GitHub", user_github_omniauth_authorize_path, id: "agree-button", data: { turbo: "false" }, class: "usa-button" %> diff --git a/app/views/submissions/new.html.erb b/app/views/submissions/new.html.erb index 7165178ad..8fbebd5ba 100644 --- a/app/views/submissions/new.html.erb +++ b/app/views/submissions/new.html.erb @@ -18,51 +18,4 @@ <%= render 'form', form: @form %>

<% end %> -
- -<% if @form.kind == "a11_v2" %> - -<% end %> \ No newline at end of file +
\ No newline at end of file diff --git a/db/migrate/20231102184253_change_federal_register_url.rb b/db/migrate/20231102184253_change_federal_register_url.rb new file mode 100644 index 000000000..e16f9df95 --- /dev/null +++ b/db/migrate/20231102184253_change_federal_register_url.rb @@ -0,0 +1,5 @@ +class ChangeFederalRegisterUrl < ActiveRecord::Migration[7.1] + def change + change_column :cx_collection_details, :federal_register_url, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index 55188491b..695ed061b 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.1].define(version: 2023_10_30_231924) do +ActiveRecord::Schema[7.1].define(version: 2023_11_02_184253) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -197,7 +197,7 @@ t.integer "volume_of_customers_provided_survey_opportunity" t.integer "volume_of_respondents" t.string "omb_control_number" - t.integer "federal_register_url" + t.string "federal_register_url" t.text "reflection_text" t.text "survey_type" t.text "survey_title"