Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updates to CX Collections #1285

Merged
merged 2 commits into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 9 additions & 0 deletions app/controllers/admin/cx_collection_details_controller.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions app/models/organization.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/cscrm_data_collections/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

<div class="field">
<%= 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 %>
</div>

<div class="field">
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/cscrm_data_collections2/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@

<div class="field">
<%= 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 %>
</div>

<div class="field">
Expand Down
6 changes: 3 additions & 3 deletions app/views/admin/cx_collection_details/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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" %>
</div>
Expand Down Expand Up @@ -53,7 +53,7 @@

<div>
<%= 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" } %>
</div>
Expand All @@ -75,7 +75,7 @@

<div>
<%= 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" %>
</div>

<div>
Expand Down
4 changes: 3 additions & 1 deletion app/views/admin/cx_collection_details/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
<% end %>
</p>

<%= render "form", cx_collection_detail: @cx_collection_detail %>
<%= render "form",
cx_collection_detail: @cx_collection_detail,
cx_collections: @cx_collections %>

<br>

Expand Down
9 changes: 4 additions & 5 deletions app/views/admin/cx_collection_details/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@
<% end %>
</p>

<%= render "form", cx_collection_detail: @cx_collection_detail %>
<%= render "form",
cx_collection_detail: @cx_collection_detail,
cx_collections: @cx_collections %>

<br>

<div>
<%= link_to "Back to cx collection details", admin_cx_collection_details_path %>
</div>
<br>
11 changes: 3 additions & 8 deletions app/views/admin/cx_collections/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<% if performance_manager_permissions? %>
<div class="field">
<%= 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" } %>
</div>
<% else %>
<%= form.hidden_field :user_id, value: current_user.id %>
Expand All @@ -36,12 +36,7 @@

<div class="field">
<%= 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 } %>
</div>

<div class="field">
<%= 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 } %>
</div>

<div class="field">
Expand All @@ -51,7 +46,7 @@

<div class="field">
<%= 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 %>
</div>

<div class="field usa-form-group">
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/forms/_admin_options.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
<div class="grid-col-6">
<div class="field">
<%= 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" %>
</div>
</div>
<div class="grid-col-6">
Expand Down
42 changes: 42 additions & 0 deletions app/views/components/_form_a11_v2_script.html.erb
Original file line number Diff line number Diff line change
@@ -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()
})
42 changes: 42 additions & 0 deletions app/views/components/_form_a11_yes_no_script.html.erb
Original file line number Diff line number Diff line change
@@ -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()
})
6 changes: 6 additions & 0 deletions app/views/components/widget/_fba.js.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
14 changes: 8 additions & 6 deletions app/views/components/widget/_no_modal.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,27 @@
id="touchpoints-form-<%= form.short_uuid %>"
data-touchpoints-form-id="<%= form.short_uuid %>" tabindex="-1">
<div class="wrapper">
<%- if form.title.present? || form.logo.present? %>
<h2 class="justify-vertical word-break fba-modal-title">
<% 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") %>
<br>
<% 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" %>
</h2>
<%= form.title %>
</h2>
<% end %>

<% unless form.delivery_method == "inline" %>
<%- unless form.delivery_method == "inline" %>
<a class="fba-modal-close"
type="button"
href="#"
aria-label="Close this window">×</a>
<% end -%>

<% if form.instructions? %>
<%- if form.instructions? %>
<p class="fba-instructions">
<%= sanitize(form.instructions) %>
</p>
Expand Down
3 changes: 2 additions & 1 deletion app/views/components/widget/_widget.css.erb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
}

.fba-modal-dialog .wrapper {
padding: 20px 20px 0 20px;
padding-left: 20px;
padding-right: 20px;
}

.fixed-tab-button {
Expand Down
2 changes: 1 addition & 1 deletion app/views/devise/sessions/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<% end %>
<% if ENV['GITHUB_CLIENT_ID'].present? %>
<p>
<%= 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" %>
Expand Down
49 changes: 1 addition & 48 deletions app/views/submissions/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -18,51 +18,4 @@
<%= render 'form', form: @form %>
</div>
<% end %>
</div>

<% if @form.kind == "a11_v2" %>
<script>
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()
})
</script>
<% end %>
</div>
5 changes: 5 additions & 0 deletions db/migrate/20231102184253_change_federal_register_url.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class ChangeFederalRegisterUrl < ActiveRecord::Migration[7.1]
def change
change_column :cx_collection_details, :federal_register_url, :string
end
end
4 changes: 2 additions & 2 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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"
Expand Down
Loading