Skip to content

Commit

Permalink
Require reference on applications when award is either Innovation or …
Browse files Browse the repository at this point in the history
…Promoting Opportunity
  • Loading branch information
Lubosky committed Jun 21, 2024
1 parent 76a716d commit 4763139
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 11 deletions.
3 changes: 3 additions & 0 deletions app/models/form_answer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ class FormAnswer < ApplicationRecord

BUSINESS_AWARD_TYPES = %w[trade innovation development mobility]

AWARD_TYPES_WITH_NICKNAME_REQUIRED = %w[innovation mobility]

AWARD_TYPE_FULL_NAMES = {
"trade" => "International Trade",
"innovation" => "Innovation",
Expand Down Expand Up @@ -133,6 +135,7 @@ def secondary
inclusion: {
in: POSSIBLE_AWARDS,
}
validates :nickname, presence: true, if: -> { award_type.in?(AWARD_TYPES_WITH_NICKNAME_REQUIRED) }
validates :urn, uniqueness: { allow_blank: true } # rubocop:disable Rails/UniqueValidationWithoutIndex
validates :sic_code, format: { with: SicCode::REGEX }, allow_blank: true
validate :validate_answers
Expand Down
13 changes: 8 additions & 5 deletions app/views/content_only/_award_nickname.html.slim
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
- is_nickname_required = award_type.in?(FormAnswer::AWARD_TYPES_WITH_NICKNAME_REQUIRED)
- is_promotion = award_type == "promotion"

.page-pre-eligibility
h2.govuk-heading-l The Process

Expand All @@ -7,7 +10,7 @@
ul.govuk-list.govuk-list--bullet
li
' This is to ensure that your
- if award_type == "promotion"
- if is_promotion
' nominee
- else
' organisation
Expand All @@ -25,7 +28,7 @@
li
p.govuk-body
' Submit your
- if award_type == "promotion"
- if is_promotion
' nomination
- else
' application
Expand All @@ -36,15 +39,15 @@
' .
li
' You can still edit submitted
- if award_type == "promotion"
- if is_promotion
' nominations
- else
' applications
' up to this date.

- if award_type == "innovation"
- if is_nickname_required
= render "content_only/award_nickname_block"

p#get-started.get-started.group.govuk-body
- title = award_type == "innovation" ? "Save and start eligibility questionnaire" : "Start eligibility questionnaire"
- title = is_nickname_required ? "Save and start eligibility questionnaire" : "Start eligibility questionnaire"
= submit_tag title, class: "govuk-button", rel: "external"
4 changes: 2 additions & 2 deletions app/views/content_only/_award_nickname_block.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ br

.govuk-form-group
h2.govuk-label-wrapper
= label_tag :nickname, "Please choose a reference for this application (optional):", class: 'govuk-label govuk-label--l', for: 'award-nickname'
= label_tag :nickname, "Please choose a reference for this application:", class: 'govuk-label govuk-label--l', for: 'award-nickname'

p.govuk-hint
| If you have more than one innovation (and want them to be considered for an award), you will have to submit a separate application for each of them.
p.govuk-hint
| You can create a reference, for example, 'Fibre optic device' so that it helps you and your collaborators to distinguish between different innovation applications. It will appear on the Applications page. Once chosen, your reference is permanent.

= text_field_tag :nickname, "", autocomplete: "off", type: "text", class: "govuk-input govuk-!-width-two-thirds", id: 'award-nickname'
= text_field_tag :nickname, "", autocomplete: "off", required: true, type: "text", class: "govuk-input govuk-!-width-two-thirds", id: 'award-nickname'
7 changes: 3 additions & 4 deletions app/views/content_only/apply_social_mobility_award.html.slim
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
h1.govuk-heading-xl Promoting Opportunity Award (through social mobility) Application

.article-related-positioning-container
.article-container
article.group role="article"
= form_tag new_social_mobility_form_path, method: :get do
= render "award_nickname", award_type: "mobility"
article.group role="article"
= form_tag new_social_mobility_form_path, method: :get do
= render "award_nickname", award_type: "mobility"

0 comments on commit 4763139

Please sign in to comment.