From ec20259f24ccee6ef0e9d68ca20ef6a93ddb188f Mon Sep 17 00:00:00 2001 From: Ryan Wold <64987852+ryanwoldatwork@users.noreply.github.com> Date: Tue, 26 Sep 2023 15:16:30 -0700 Subject: [PATCH] show required fields on a form * use radio button tile styles for dropdown options to improve draggability * update stimulus npm package * add id for 0 star value * remove top margin from question option inputs * add short_description and year_designated to Service * update footer url --- Gemfile.lock | 29 +++++++++---------- app/controllers/admin/services_controller.rb | 2 ++ app/serializers/service_serializer.rb | 2 ++ app/views/admin/services/_form.html.erb | 15 +++++++++- app/views/admin/services/show.html.erb | 10 +++++++ app/views/components/_question_title.html.erb | 3 ++ .../components/_question_title_label.html.erb | 7 +++-- .../components/forms/_custom_layout.html.erb | 3 ++ .../components/forms/_footer_banner.html.erb | 2 +- .../edit/question_types/_dropdown.html.erb | 4 +-- .../question_types/_dropdown_option.html.erb | 6 ++-- .../_update_value_text_fields.html.erb | 4 +-- .../_star_radio_buttons.html.erb | 2 +- .../components/widget/_no_modal.html.erb | 6 ++++ app/views/components/widget/_widget.css.erb | 5 ++++ .../20230926183233_add_hisp_service_fields.rb | 6 ++++ db/schema.rb | 4 ++- db/seeds.rb | 7 ++++- package.json | 2 +- spec/features/admin/services_spec.rb | 4 +++ yarn.lock | 8 ++--- 21 files changed, 97 insertions(+), 34 deletions(-) create mode 100644 db/migrate/20230926183233_add_hisp_service_fields.rb diff --git a/Gemfile.lock b/Gemfile.lock index 6d46a8963..ee317c9f8 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -96,10 +96,10 @@ GEM aes_key_wrap (1.1.0) ast (2.4.2) aws-eventstream (1.2.0) - aws-partitions (1.824.0) + aws-partitions (1.828.0) aws-record (2.11.0) aws-sdk-dynamodb (~> 1, >= 1.85.0) - aws-sdk-core (3.181.1) + aws-sdk-core (3.183.1) aws-eventstream (~> 1, >= 1.0.2) aws-partitions (~> 1, >= 1.651.0) aws-sigv4 (~> 1.5) @@ -156,13 +156,12 @@ GEM nokogiri (~> 1.6) rubyzip (~> 1.1) tilt (>= 1.4) - carrierwave (2.2.3) - activemodel (>= 5.0.0) - activesupport (>= 5.0.0) + carrierwave (3.0.3) + activemodel (>= 6.0.0) + activesupport (>= 6.0.0) addressable (~> 2.6) image_processing (~> 1.1) marcel (~> 1.0.0) - mini_mime (>= 0.1.3) ssrf_filter (~> 1.0) case_transform (0.2) activesupport @@ -200,7 +199,7 @@ GEM railties (>= 5.0.0) faraday (0.17.6) multipart-post (>= 1.2, < 3) - ffi (1.15.5) + ffi (1.16.2) fog-aws (3.19.0) fog-core (~> 2.1) fog-json (~> 1.1) @@ -295,7 +294,7 @@ GEM timeout net-smtp (0.3.3) net-protocol - newrelic_rpm (9.4.2) + newrelic_rpm (9.5.0) nio4r (2.5.9) nokogiri (1.15.4) mini_portile2 (~> 2.8.2) @@ -320,9 +319,9 @@ GEM oauth2 (>= 1.4, < 3) omniauth (~> 2.0) orm_adapter (0.5.0) - paper_trail (12.3.0) - activerecord (>= 5.2) - request_store (~> 1.1) + paper_trail (15.0.0) + activerecord (>= 6.1) + request_store (~> 1.4) parallel (1.23.0) parser (3.2.2.3) ast (~> 2.4.1) @@ -332,7 +331,7 @@ GEM coderay (~> 1.1) method_source (~> 1.0) public_suffix (5.0.3) - puma (5.6.5) + puma (5.6.7) nio4r (~> 2.0) racc (1.7.1) rack (2.2.8) @@ -428,7 +427,7 @@ GEM unicode-display_width (>= 2.4.0, < 3.0) rubocop-ast (1.29.0) parser (>= 3.2.1.0) - rubocop-capybara (2.18.0) + rubocop-capybara (2.19.0) rubocop (~> 1.41) rubocop-factory_bot (2.24.0) rubocop (~> 1.33) @@ -506,7 +505,7 @@ GEM nokogiri (~> 1.6) rubyzip (>= 1.3.0) selenium-webdriver (~> 4.0, < 4.11) - websocket (1.2.9) + websocket (1.2.10) websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) @@ -514,7 +513,7 @@ GEM chronic (>= 0.6.3) xpath (3.2.0) nokogiri (~> 1.8) - zeitwerk (2.6.11) + zeitwerk (2.6.12) PLATFORMS ruby diff --git a/app/controllers/admin/services_controller.rb b/app/controllers/admin/services_controller.rb index 456baeaaa..ff670f41e 100644 --- a/app/controllers/admin/services_controller.rb +++ b/app/controllers/admin/services_controller.rb @@ -255,6 +255,8 @@ def service_params :bureau, :department, :description, + :short_description, + :year_designated, :digital_service, :estimated_annual_volume_of_customers, :hisp, diff --git a/app/serializers/service_serializer.rb b/app/serializers/service_serializer.rb index 963b22e42..4e116d9ae 100644 --- a/app/serializers/service_serializer.rb +++ b/app/serializers/service_serializer.rb @@ -10,7 +10,9 @@ class ServiceSerializer < ActiveModel::Serializer :service_provider_id, :service_provider_name, :service_provider_slug, + :short_description, :justification_text, + :year_designated, :contact_center, :kind, :transactional, diff --git a/app/views/admin/services/_form.html.erb b/app/views/admin/services/_form.html.erb index 9982195ec..830b07338 100644 --- a/app/views/admin/services/_form.html.erb +++ b/app/views/admin/services/_form.html.erb @@ -26,11 +26,16 @@ <%= form.label :office, "Office" , class: "usa-label" %> <%= form.text_field :office, class: "usa-input" %> + +
+ <%= form.label :year_designated, "Year designated", class: "usa-label" %> + <%= form.text_field :year_designated, class: "usa-input", placeholder: 2023 %> +
<% end %>
<%= form.label :name, "What is the name of this service?", class: "usa-label" %> - + For example, “Applying for a replacement Social Security card”, “Visiting a National Wildlife Refuge”, or “Utilizing in-person primary care” @@ -42,6 +47,14 @@ <%= form.text_area :description, class: "usa-textarea" %>
+
+ <%= form.label :short_description, "Provide a short description for this Service", class: "usa-label" %> + + This text will be displayed on Performance.gov. + + <%= form.text_area :short_description, class: "usa-textarea" %> +
+
Contact Center? diff --git a/app/views/admin/services/show.html.erb b/app/views/admin/services/show.html.erb index cec15c0e9..ce3a2c06c 100644 --- a/app/views/admin/services/show.html.erb +++ b/app/views/admin/services/show.html.erb @@ -63,11 +63,21 @@
<%= @service.name %>

+

+ Year designated +
+ <%= @service.year_designated? ? @service.year_designated : "---" %> +

Description
<%= @service.description? ? to_markdown(@service.description) : "---" %>

+

+ Short Description +
+ <%= @service.short_description? ? to_markdown(@service.short_description) : "---" %> +

Service type diff --git a/app/views/components/_question_title.html.erb b/app/views/components/_question_title.html.erb index a3451eef5..9b6895fe5 100644 --- a/app/views/components/_question_title.html.erb +++ b/app/views/components/_question_title.html.erb @@ -1,6 +1,9 @@

<%= question.text %> + <% if question.is_required? %> + * + <% end -%> <% if question.help_text? %>

diff --git a/app/views/components/_question_title_label.html.erb b/app/views/components/_question_title_label.html.erb index 41d3beb62..d1148ba45 100644 --- a/app/views/components/_question_title_label.html.erb +++ b/app/views/components/_question_title_label.html.erb @@ -1,12 +1,15 @@

<%= question.help_text %>

- <% end %> + <% end -%> <% if local_assigns[:form_builder] && form_builder %> @@ -18,5 +21,5 @@ <% end %> - <% end %> + <% end -%> diff --git a/app/views/components/forms/_custom_layout.html.erb b/app/views/components/forms/_custom_layout.html.erb index 926b90786..917fb1e9b 100644 --- a/app/views/components/forms/_custom_layout.html.erb +++ b/app/views/components/forms/_custom_layout.html.erb @@ -15,6 +15,9 @@ <%= sanitize(form.instructions) %>

<% end %> +

+ A red asterisk (*) indicates a required field. +

<%= render 'components/forms/flash', form: form %> <%= render partial: "components/forms/custom", locals: { form: form, questions: form.questions } %>
diff --git a/app/views/components/forms/_footer_banner.html.erb b/app/views/components/forms/_footer_banner.html.erb index ccaeee8c4..f04e035d5 100644 --- a/app/views/components/forms/_footer_banner.html.erb +++ b/app/views/components/forms/_footer_banner.html.erb @@ -8,7 +8,7 @@

<%= t :official_form %> <%= t :provided_by %> - <%= t 'touchpoints' %> + <%= t 'touchpoints' %>
<% if form.present? %> <% if form.omb_approval_number.present? %> diff --git a/app/views/components/forms/edit/question_types/_dropdown.html.erb b/app/views/components/forms/edit/question_types/_dropdown.html.erb index cf672b0b7..0b475f4bc 100644 --- a/app/views/components/forms/edit/question_types/_dropdown.html.erb +++ b/app/views/components/forms/edit/question_types/_dropdown.html.erb @@ -3,9 +3,7 @@ <%= select_tag(question.answer_field.to_sym, options_for_select(question.question_options.each_with_index.map { |option, index| [option.text, option.value] }), { prompt: (t 'form.select_one'), class: "usa-select", required: question.is_required }) %>

<% question.question_options.each_with_index do |option, index| %> -

- <%= render "components/forms/edit/question_types/dropdown_option", question: question, option: option, index: index %> -

+ <%= render "components/forms/edit/question_types/dropdown_option", question: question, option: option, index: index %> <% end %>
diff --git a/app/views/components/forms/edit/question_types/_dropdown_option.html.erb b/app/views/components/forms/edit/question_types/_dropdown_option.html.erb index 7034e18d0..20fd10de5 100644 --- a/app/views/components/forms/edit/question_types/_dropdown_option.html.erb +++ b/app/views/components/forms/edit/question_types/_dropdown_option.html.erb @@ -1,5 +1,7 @@ -
- <%= label_tag(nil, for: "#{question.answer_field}_#{(index + 1).to_s}") do %> +
+ <% @option_id = "#{question.answer_field}_#{(index + 1).to_s}" %> + <%= radio_button_tag(@option_id, index + 1, nil, { name: question.answer_field, value: option.value, class: "usa-radio__input usa-radio__input--tile", required: question.is_required }) %> + <%= label_tag(nil, for: @option_id, class: "usa-radio__label") do %> <%= render 'components/forms/edit/question_types/update_value_text_fields', { question: question, option: option } %> <% end %>
diff --git a/app/views/components/forms/edit/question_types/_update_value_text_fields.html.erb b/app/views/components/forms/edit/question_types/_update_value_text_fields.html.erb index 2905c950b..e625a631a 100644 --- a/app/views/components/forms/edit/question_types/_update_value_text_fields.html.erb +++ b/app/views/components/forms/edit/question_types/_update_value_text_fields.html.erb @@ -3,8 +3,8 @@ <% if option.text != option.value %>(<%= option.value %>)<% end %> -    -    +    +    <%= link_to admin_form_question_question_option_path(question.form, question, option), class: "button form-save-question-option" do %> <% end %> diff --git a/app/views/components/forms/question_types/_star_radio_buttons.html.erb b/app/views/components/forms/question_types/_star_radio_buttons.html.erb index e422574f1..bccde741e 100644 --- a/app/views/components/forms/question_types/_star_radio_buttons.html.erb +++ b/app/views/components/forms/question_types/_star_radio_buttons.html.erb @@ -10,7 +10,7 @@ aria-describedby="<%= "question-id-#{question.id}-help-text" %>" <% end -%> > - +
diff --git a/app/views/components/widget/_widget.css.erb b/app/views/components/widget/_widget.css.erb index 6b0a527f9..94fbb8c2e 100644 --- a/app/views/components/widget/_widget.css.erb +++ b/app/views/components/widget/_widget.css.erb @@ -610,6 +610,11 @@ margin-top:0; } +.fba-modal-dialog .usa-label--required, +.fba-modal-dialog .usa-hint--required{ + color:#b50909; +} + .fba-modal-dialog .usa-error-message{ padding-bottom:0.25rem; padding-top:0.25rem; diff --git a/db/migrate/20230926183233_add_hisp_service_fields.rb b/db/migrate/20230926183233_add_hisp_service_fields.rb new file mode 100644 index 000000000..6fafac507 --- /dev/null +++ b/db/migrate/20230926183233_add_hisp_service_fields.rb @@ -0,0 +1,6 @@ +class AddHispServiceFields < ActiveRecord::Migration[7.0] + def change + add_column :services, :year_designated, :integer + add_column :services, :short_description, :text + end +end diff --git a/db/schema.rb b/db/schema.rb index d2d31788d..07a472680 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: 2023_09_05_201752) do +ActiveRecord::Schema[7.0].define(version: 2023_09_26_183233) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -682,6 +682,8 @@ t.string "office", comment: "Text description for the office (below a Bureau)" t.boolean "designated_for_improvement_a11_280", default: false, comment: "Is this Service designated, per the OMB Circular A-11 Section 280" t.boolean "contact_center", default: false, comment: "True or False for whether the service involves a contact center and/or an interaction with a contact center" + t.integer "year_designated" + t.text "short_description" t.index ["organization_id"], name: "index_services_on_organization_id" end diff --git a/db/seeds.rb b/db/seeds.rb index 9b7756551..ec20497ed 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -174,8 +174,10 @@ def production_suitable_seeds name: 'USPTO Trademarks', organization: Organization.first, hisp: true, + year_designated: 2023, notes: 'Headline notes about the service', description: 'A blurb describing this service. A few hundred words...', + short_description: 'A short description of this service.', department: 'Department of Commerce', bureau: 'Patents and Trademarks', service_abbreviation: 'uspto', @@ -187,6 +189,8 @@ def production_suitable_seeds service_2 = Service.create!({ organization: service_provider_2.organization, service_provider: service_provider_2, + year_designated: 2022, + short_description: 'A short description of this service.', name: 'Example', service_owner_id: admin_user.id, hisp: true, @@ -194,6 +198,7 @@ def production_suitable_seeds service_3 = Service.create!({ organization: Organization.first, service_provider: service_provider_2, + year_designated: 2021, service_owner_id: webmaster.id, name: 'HUD', hisp: true, @@ -204,7 +209,7 @@ def production_suitable_seeds service_owner_id: webmaster.id, name: 'IRS', hisp: true, - }) +}) service_5 = Service.create!({ organization: Organization.first, service_provider: service_provider_1, diff --git a/package.json b/package.json index 00b03b6a2..e61ff1185 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "@hotwired/stimulus": "^3.2.1" + "@hotwired/stimulus": "^3.2.2" } } diff --git a/spec/features/admin/services_spec.rb b/spec/features/admin/services_spec.rb index c18236a74..4f79508c7 100644 --- a/spec/features/admin/services_spec.rb +++ b/spec/features/admin/services_spec.rb @@ -42,6 +42,8 @@ select(organization.name, from: 'service[organization_id]') fill_in :service_name, with: 'New Service Name' fill_in :service_description, with: "Lots of text\n\n#### Heading\n\n* 1\n* 2\n* 3" + fill_in :service_year_designated, with: "2040" + fill_in :service_short_description, with: "Abbreviated text" find("[for=service_contact_center]").click find("label[for='service_hisp']").click @@ -52,6 +54,8 @@ it 'create Service successfully' do expect(page).to have_content('Service was successfully created') expect(page).to have_content('New Service Name') + expect(page).to have_content('2040') + expect(page).to have_content('Abbreviated text') # renders markdown expect(page).to have_css('h4', text: 'Heading') diff --git a/yarn.lock b/yarn.lock index ea533e65a..b3c0b8d7e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,7 +2,7 @@ # yarn lockfile v1 -"@hotwired/stimulus@^3.2.1": - version "3.2.1" - resolved "https://registry.npmjs.org/@hotwired/stimulus/-/stimulus-3.2.1.tgz" - integrity sha512-HGlzDcf9vv/EQrMJ5ZG6VWNs8Z/xMN+1o2OhV1gKiSG6CqZt5MCBB1gRg5ILiN3U0jEAxuDTNPRfBcnZBDmupQ== +"@hotwired/stimulus@^3.2.2": + version "3.2.2" + resolved "https://registry.npmjs.org/@hotwired/stimulus/-/stimulus-3.2.2.tgz" + integrity sha512-eGeIqNOQpXoPAIP7tC1+1Yc1yl1xnwYqg+3mzqxyrbE5pg5YFBZcA6YoTiByJB6DKAEsiWtl6tjTJS4IYtbB7A==