diff --git a/app/controllers/admin/services_controller.rb b/app/controllers/admin/services_controller.rb
index 1bb7e2c01..ec0df35c7 100644
--- a/app/controllers/admin/services_controller.rb
+++ b/app/controllers/admin/services_controller.rb
@@ -88,6 +88,7 @@ def show; end
def new
@service = Service.new
@service.service_owner_id = current_user.id
+ set_channel_options
end
def edit
diff --git a/app/controllers/api/v1/digital_products_controller.rb b/app/controllers/api/v1/digital_products_controller.rb
index 4b9228d71..50f56ecda 100644
--- a/app/controllers/api/v1/digital_products_controller.rb
+++ b/app/controllers/api/v1/digital_products_controller.rb
@@ -20,7 +20,7 @@ def index
meta: {
size: size,
page: page,
- totalPages: (DigitalProduct.count / size).floor
+ totalPages: (@total_count / size).floor
},
links: links(page, size),
each_serializer: DigitalProductSerializer
diff --git a/app/controllers/api/v1/digital_service_accounts_controller.rb b/app/controllers/api/v1/digital_service_accounts_controller.rb
index 66101fd09..f9955a3f9 100644
--- a/app/controllers/api/v1/digital_service_accounts_controller.rb
+++ b/app/controllers/api/v1/digital_service_accounts_controller.rb
@@ -21,7 +21,7 @@ def index
meta: {
size: size,
page: page,
- totalPages: (DigitalProduct.count / size).floor
+ totalPages: (@total_count / size).floor
},
links: links(page, size),
each_serializer: DigitalServiceAccountSerializer
diff --git a/app/models/cscrm_data_collection.rb b/app/models/cscrm_data_collection.rb
index eaa81e0f1..e1a8dfc56 100644
--- a/app/models/cscrm_data_collection.rb
+++ b/app/models/cscrm_data_collection.rb
@@ -4,6 +4,9 @@
class CscrmDataCollection < ApplicationRecord
belongs_to :organization
+ validates :year, presence: true
+ validates :quarter, presence: true
+
def self.to_csv
collections = CscrmDataCollection.order('year, quarter')
diff --git a/app/views/admin/cscrm_data_collections/_form.html.erb b/app/views/admin/cscrm_data_collections/_form.html.erb
index d2f0ee83a..df0477645 100644
--- a/app/views/admin/cscrm_data_collections/_form.html.erb
+++ b/app/views/admin/cscrm_data_collections/_form.html.erb
@@ -14,17 +14,24 @@
<%= form.label :organization_id,
"Organization" %>
- <%= form.select :organization_id, options_for_select(organization_dropdown_options, cscrm_data_collection.organization_id), { prompt: "Which Organization?" }, { class: "usa-select" } %>
+ <%= form.select :organization_id, options_for_select(organization_dropdown_options, cscrm_data_collection.organization_id), { prompt: "Which Organization?" }, { class: "usa-select", required: true } %>
+
+
+
+
+ <%= form.label :bureau_id,
+ "Bureau" %>
+ <%= form.select :bureau_id, options_for_select(organization_dropdown_options, cscrm_data_collection.bureau_id), { prompt: "Which Bureau?" }, { class: "usa-select" } %>
<%= form.label :year, class: "usa-label" %>
- <%= form.text_field :year, class: "usa-input" %>
+ <%= form.text_field :year, class: "usa-input", required: true %>
<%= form.label :quarter, class: "usa-label" %>
- <%= form.text_field :quarter, class: "usa-input" %>
+ <%= form.text_field :quarter, class: "usa-input", required: true %>
@@ -505,6 +512,6 @@
- <%= form.submit class: "usa-button" %>
+ <%= form.submit (cscrm_data_collection.persisted? ? "Update CSCRM Data Collection" : "Create CSCRM Data Collection"), class: "usa-button" %>
<% end %>
diff --git a/app/views/admin/services/_form.html.erb b/app/views/admin/services/_form.html.erb
index d099a02fb..0cd2529b7 100644
--- a/app/views/admin/services/_form.html.erb
+++ b/app/views/admin/services/_form.html.erb
@@ -17,7 +17,7 @@
<%= form.select :organization_id, options_for_select(organization_dropdown_options, service.organization_id), { prompt: "Which Agency?" }, { class: "usa-select", required: true } %>
-
+
<%= form.label :bureau_id, "Subcomponent/Bureau", class: "usa-label" %>
<%= form.select :bureau_id, options_for_select(organization_dropdown_options, service.bureau_id), { prompt: "Which Bureau?" }, { class: "usa-select" } %>
@@ -55,7 +55,7 @@
-
+
<%= form.label :multi_agency_explanation, "What other agencies? ", class: "usa-label" %>
Because "Yes" was selected regarding multiple agencies, please list the other agency or agencies.
@@ -88,7 +88,7 @@
<% end %>
-
+
<%= form.label :other_service_type, "Other service type", class: "usa-label" %>
Because "Other" was selected for Service Type,
@@ -112,8 +112,8 @@
<%= form.select :estimated_annual_volume_of_customers, options_for_select(volume_options, service.service_provider_id), { prompt: "Select Volume of Customers" }, { class: "usa-select" } %>
-
- <%= form.label :customer_volume_explanation, "Unknown customer volume" , class: "usa-label" %>
+
+ <%= form.label :customer_volume_explanation, "Unknown customer volume", class: "usa-label" %>
Because "Unknown" was selected for Customer Volume,
please explain why customer volume cannot currently be estimated.
@@ -143,7 +143,7 @@
-
+
<%= form.label :designated_for_improvement_a11_280, "Is this service designated for improvement as required by Circular A-11 Section 280?" ,
class: "usa-label" %>
@@ -249,26 +249,28 @@
-
- <%= form.label :fully_digital_service, "Does this service offer a fully digital option?" , class: "usa-label" %>
+
+ <%= form.label :fully_digital_service, "Does this service offer a fully digital option?", class: "usa-label" %>
Does this service offer a fully digital option?
- <%= form.radio_button(:fully_digital_service, "Yes" , class: "usa-radio__input usa-radio__input--tile" ) %>
+ <%= form.radio_button(:fully_digital_service, "Yes" , class: "usa-radio__input usa-radio__input--tile", checked: service.persisted? && service.fully_digital_service ) %>
<%= form.label(:fully_digital_service, class: "usa-radio__label" , value: "Yes" ) %>
- <%= form.radio_button(:fully_digital_service, "No" , { class: "usa-radio__input usa-radio__input--tile" }) %>
+ <%= form.radio_button(:fully_digital_service, "No" , { class: "usa-radio__input usa-radio__input--tile", checked: service.persisted? && !service.fully_digital_service }) %>
<%= form.label(:fully_digital_service, class: "usa-radio__label" , value: "No" ) %>
-
- <%= form.label :barriers_to_fully_digital_service,
- "What are the barriers to make this service fully digital? (e.g. existing technologies, procedural changes, regulatory changes, legislative changes)?",
- class: "usa-label" %>
- <%= form.text_area :barriers_to_fully_digital_service, class: "usa-textarea" %>
+
+
+ <%= form.label :barriers_to_fully_digital_service,
+ "What are the barriers to make this service fully digital? (e.g. existing technologies, procedural changes, regulatory changes, legislative changes)?",
+ class: "usa-label" %>
+ <%= form.text_area :barriers_to_fully_digital_service, class: "usa-textarea" %>
+
<% if service_manager_permissions? && service.persisted? %>
@@ -363,38 +365,41 @@
// handle the conditions for form elements on change events
// 2 ifs for each applicable form component
$("#service_hisp_yes").on('click', function() {
- alert('hi')
$("#service_designated_for_improvement_a11_280").attr('required', true);
$("#designated_for_improvement_a11_280_option").show();
})
$("#service_hisp_no").on('click', function() {
- alert('bye')
$("#service_designated_for_improvement_a11_280").attr('required', false);
$("#designated_for_improvement_a11_280_option").hide();
})
$("#service_digital_service_yes").on('click', function() {
- alert('hi')
$("#service_designated_for_improvement_a11_280").attr('required', true);
$("#resources_needed_to_provide_digital_service_option").show();
})
$("#service_digital_service_no").on('click', function() {
- alert('bye')
$("#service_designated_for_improvement_a11_280").attr('required', false);
$("#resources_needed_to_provide_digital_service_option").hide();
})
$("#service_multi_agency_service_yes").on('click', function() {
- alert('hi')
$("#service_multi_agency_explanation").attr('required', true);
$("#multi_agency_explanation_option").show();
})
$("#service_multi_agency_service_no").on('click', function() {
- alert('bye')
$("#service_multi_agency_explanation").attr('required', false);
$("#multi_agency_explanation_option").hide();
})
+ $("#service_fully_digital_service_yes").on('click', function() {
+ $("#barriers_to_fully_digital_service_option textarea").attr('required', true);
+ $("#barriers_to_fully_digital_service_option").show();
+ })
+ $("#service_fully_digital_service_no").on('click', function() {
+ $("#barriers_to_fully_digital_service_option textarea").attr('required', false);
+ $("#barriers_to_fully_digital_service_option").hide();
+ })
+
// if "Unknown" is selected
$("#service_estimated_annual_volume_of_customers").on('change', function(e) {
if (e.target.value == 'Unknown') {
@@ -407,9 +412,19 @@
}
})
+ $("#service_kind_other").on("click", function(event) {
+ if (event.target.checked) {
+ $("#kind_option").show();
+ $("#kind_option input").attr("required", true)
+ } else {
+ $("#kind_option").hide();
+ $("#kind_option input").attr("required", false)
+ }
+ })
+
<%# Don't try to set existing values when creating a new record %>
- <% unless new_admin_service_path %>
+ <% unless current_page?(new_admin_service_path) %>
// handle selected items on page load
// 1 if for each applicable form component
if ($("#service_hisp_yes").prop('checked', true) ) {
@@ -417,16 +432,20 @@
$("#service_designated_for_improvement_a11_280").attr('required', true);
$("#designated_for_improvement_a11_280_option").show();
}
- if ($("#service_digital_service_yes").prop('checked', true) ) {
-
+ if ($("#service_digital_service_yes:checked") ) {
$("#service_multi_agency_explanation").attr('required', true);
$("#multi_agency_explanation_option").show();
}
- if ($("#service_multi_agency_service_yes").prop('checked', true) ) {
-
+ if ($("#service_multi_agency_service_yes:checked")) {
$("#service_multi_agency_explanation").attr('required', true);
$("#multi_agency_explanation_option").show();
}
+
+ if ($("#service_fully_digital_service_yes:checked")) {
+ $("#barriers_to_fully_digital_service_option").show();
+ $("#barriers_to_fully_digital_service_option textarea").attr('required', true);
+ }
+
<% end %>
})
diff --git a/db/migrate/20221207055927_add_bureau_to_cscrm.rb b/db/migrate/20221207055927_add_bureau_to_cscrm.rb
new file mode 100644
index 000000000..e156cbc1a
--- /dev/null
+++ b/db/migrate/20221207055927_add_bureau_to_cscrm.rb
@@ -0,0 +1,5 @@
+class AddBureauToCscrm < ActiveRecord::Migration[7.0]
+ def change
+ add_column :cscrm_data_collections, :bureau_id, :integer
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 049f0f925..d2a9be98c 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.0].define(version: 2022_11_29_214736) do
+ActiveRecord::Schema[7.0].define(version: 2022_12_07_055927) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -98,6 +98,7 @@
t.string "rating"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
+ t.integer "bureau_id"
t.index ["organization_id"], name: "index_cscrm_data_collections_on_organization_id"
t.index ["user_id"], name: "index_cscrm_data_collections_on_user_id"
end