Skip to content

Commit

Permalink
Merge pull request #3702 from Crown-Commercial-Service/feature/FMFR-1…
Browse files Browse the repository at this point in the history
…371-add-new-options-for-sector

FMFR-1371 - Add new sector options for buyer details
  • Loading branch information
tim-s-ccs authored Apr 26, 2023
2 parents 13d0145 + aaa3d5d commit ee9f347
Show file tree
Hide file tree
Showing 18 changed files with 195 additions and 233 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def buyer_detail_params
:organisation_address_town,
:organisation_address_county,
:organisation_address_postcode,
:central_government,
:sector,
:contact_opt_in
)
end
Expand Down
40 changes: 20 additions & 20 deletions app/javascript/src/facilitiesManagement/contactDetailsInStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,29 +33,29 @@ const initContactDetailsInStorage = (): void => {
name: 'contactDetailsOrgName',
$element: $(`#${modelName}_organisation_name`),
type: ContactDetailType.TextInput
},
{
name: 'contactDetailsSectorTrue',
$element: $(`#${modelName}_central_government_true`),
type: ContactDetailType.RadioInput
},
{
name: 'contactDetailsSectorFalse',
$element: $(`#${modelName}_central_government_false`),
type: ContactDetailType.RadioInput
},
{
name: 'contactDetailsContactOptInTrue',
$element: $(`#${modelName}_contact_opt_in_true`),
type: ContactDetailType.RadioInput
},
{
name: 'contactDetailsContactOptInFalse',
$element: $(`#${modelName}_contact_opt_in_false`),
type: ContactDetailType.RadioInput
}
]

Array<string>('defence_and_security', 'health', 'government_policy', 'local_community_and_housing', 'infrastructure', 'education', 'culture_media_and_sport').forEach(sector => {
contactDetailsOptions.push(
{
name: `contactDetailsSector_${sector}`,
$element: $(`#${modelName}_sector_${sector}`),
type: ContactDetailType.RadioInput
}
)
})

Array<string>('true', 'false').forEach(sector => {
contactDetailsOptions.push(
{
name: `contactDetailsContactOptIn_${sector}`,
$element: $(`#${modelName}_contact_opt_in_${sector}`),
type: ContactDetailType.RadioInput
}
)
})

initDetailsStorage(
'contactDetails',
contactDetailsOptions,
Expand Down
7 changes: 6 additions & 1 deletion app/models/facilities_management/buyer_detail.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class BuyerDetail < ApplicationRecord
end

MAX_FIELD_LENGTH = 255
SECTORS = %w[culture_media_and_sport defence_and_security education government_policy health infrastructure local_community_and_housing].freeze

validates :full_name, presence: true, length: { maximum: MAX_FIELD_LENGTH }, on: :update
validates :job_title, presence: true, length: { maximum: MAX_FIELD_LENGTH }, on: :update
Expand All @@ -18,13 +19,17 @@ class BuyerDetail < ApplicationRecord

include AddressValidator

validates :central_government, inclusion: { in: [true, false] }, on: :update
validates :sector, inclusion: { in: SECTORS }, on: :update
validates :contact_opt_in, inclusion: { in: [true, false] }, on: :update

delegate :email, to: :user

def full_organisation_address
[organisation_address_line_1, organisation_address_line_2, organisation_address_town, organisation_address_county].compact.reject(&:empty?).join(', ') + " #{organisation_address_postcode}"
end

def sector_name
sector.nil? ? I18n.t("facilities_management.buyer_details.edit.central_government.options.#{central_government}") : I18n.t("facilities_management.buyer_details.edit.sector.options.#{sector}")
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def self.create_procurement_row(procurement)
localised_datetime(procurement.created_at),
procurement.user.buyer_detail.organisation_name,
procurement.user.buyer_detail.full_organisation_address,
procurement.user.buyer_detail.central_government ? 'Central government' : 'Wider public sector',
procurement.user.buyer_detail.sector_name,
procurement.user.buyer_detail.contact_opt_in ? procurement.user.buyer_detail.full_name : '',
procurement.user.buyer_detail.job_title,
procurement.user.buyer_detail.contact_opt_in ? procurement.user.email : '',
Expand Down
27 changes: 12 additions & 15 deletions app/views/facilities_management/buyer_details/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -99,28 +99,25 @@

<hr class="govuk-section-break govuk-section-break--m">

<%= form_group_with_error(f.object, :central_government) do |displayed_error| %>
<fieldset class="govuk-fieldset" aria-describedby="central_government-hint">
<%= form_group_with_error(f.object, :sector) do |displayed_error| %>
<fieldset class="govuk-fieldset">
<legend class="govuk-fieldset__legend govuk-fieldset__legend--m">
<%= t('.central_government.legend') %>
<%= t('.sector.legend') %>
</legend>
<div id="central_government-hint" class="govuk-hint">
<%= t('.search_html', url: 'https://www.gov.uk/government/organisations') %>
</div>
<%= displayed_error %>
<div class="govuk-radios govuk-radios--inline" data-module="govuk-radios">
<div class="govuk-radios__item">
<%= f.radio_button :central_government, true, class: 'govuk-radios__input' %>
<%= f.label :central_government, t('.central_government.options.true'), value: true, class: 'govuk-label govuk-radios__label' %>
</div>
<div class="govuk-radios__item">
<%= f.radio_button :central_government, false, class: 'govuk-radios__input' %>
<%= f.label :central_government, t('.central_government.options.false'), value: false, class: 'govuk-label govuk-radios__label' %>
</div>
<div class="govuk-radios" data-module="govuk-radios">
<% FacilitiesManagement::BuyerDetail::SECTORS.each do |sector| %>
<div class="govuk-radios__item">
<%= f.radio_button :sector, sector, class: 'govuk-radios__input' %>
<%= f.label :sector, t(".sector.options.#{sector}"), value: sector, class: 'govuk-label govuk-radios__label' %>
</div>
<% end %>
</div>
</fieldset>
<% end %>

<hr class="govuk-section-break govuk-section-break--m">

<%= form_group_with_error(f.object, :contact_opt_in) do |displayed_error| %>
<fieldset class="govuk-fieldset" aria-describedby="contact_opt_in-hint">
<legend class="govuk-fieldset__legend govuk-fieldset__legend--m">
Expand Down
157 changes: 0 additions & 157 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,163 +66,6 @@ en:
password_confirmation:
blank: Enter your password
confirmation: Passwords don't match
legal_services/journey/check_suitability:
attributes:
under_threshold:
inclusion: Select yes if the fees will be under £20,000
legal_services/journey/choose_jurisdiction:
attributes:
jurisdiction:
blank: Select the jurisdiction you need
legal_services/journey/choose_organisation_type:
attributes:
central_government:
inclusion: Select yes if you work for central government
legal_services/journey/choose_regions:
attributes:
region_codes:
full_national_coverage: Select full national coverage or the region or regions you require the services in
too_short: Select the region or regions you require the services in
legal_services/journey/choose_services:
attributes:
services:
blank: Select at least one legal service
legal_services/journey/select_lot:
attributes:
lot:
blank: Select the lot you need
management_consultancy/journey/choose_expenses:
attributes:
expenses:
inclusion: Please say whether you pay expenses
management_consultancy/journey/choose_help_needed:
attributes:
help_needed:
inclusion: Select what you need
management_consultancy/journey/choose_lot:
attributes:
lot:
inclusion: Select the lot you need
management_consultancy/journey/choose_regions:
attributes:
region_codes:
too_short: Select the region or regions you want the consultants to work
management_consultancy/journey/choose_services:
attributes:
services:
too_short: Select the service or services you need
supply_teachers/journey/agency_payroll:
attributes:
job_type:
blank: Select the type of worker you need
location:
invalid_location: Enter a valid postcode
term:
blank: Select how long you need the worker for
supply_teachers/journey/fta_calculator_contract_end:
attributes:
contract_end_date:
after_contract_start_date: The date the contract ended must be after the date the worker’s current contract started
blank: Enter the contract end date, including the day, month and year
invalid: Enter a real date
supply_teachers/journey/fta_calculator_contract_start:
attributes:
contract_start_date:
blank: Enter the contract start date, including the day, month and year
invalid: Enter a real date
supply_teachers/journey/fta_calculator_salary:
attributes:
salary:
blank: Enter the annual salary
invalid: Enter a valid salary
supply_teachers/journey/fta_to_perm_contract_end:
attributes:
contract_end_date:
after_contract_start_date: The date the contract ended must be after the date the worker’s current contract started.
blank: Enter the contract end date, including the day, month and year
invalid: Enter a real date
supply_teachers/journey/fta_to_perm_contract_start:
attributes:
contract_start_date:
blank: Enter the contract start date, including the day, month and year
invalid: Enter a real date
supply_teachers/journey/fta_to_perm_fixed_term_fee:
attributes:
fixed_term_fee:
blank: Enter the fixed term fee
supply_teachers/journey/fta_to_perm_hire_date:
attributes:
hire_date:
after_contract_end_date: The date that you wish to hire the worker must be after the date the fixed term contract ended.
blank: Enter the date, including the day, month and year
invalid: Enter a real date
supply_teachers/journey/looking_for:
attributes:
looking_for:
inclusion: Select individual worker, managed service provider, or calculate temp-to-perm fee
supply_teachers/journey/managed_service_provider:
attributes:
managed_service_provider:
inclusion: Select master vendor or neutral vendor managed service
supply_teachers/journey/payroll_provider:
attributes:
payroll_provider:
inclusion: Select yes if you want to put the worker on the school’s payroll
supply_teachers/journey/school_postcode_agency_supplied_worker:
attributes:
location:
invalid_location: Enter a valid postcode
supply_teachers/journey/school_postcode_nominated_worker:
attributes:
location:
invalid_location: Enter a valid postcode
supply_teachers/journey/temp_to_perm_calculator:
attributes:
contract_start_date:
blank: Enter the contract start date, including the day, month and year
invalid: Enter a real date
day_rate:
blank: Enter the number of pounds charged per day
greater_than: The number of pounds charged per day must be more than 0
not_a_number: The number of pounds charged per day must be a number
not_an_integer: The number of pounds charged per day must be a whole number
days_per_week:
blank: Enter the number of days worked per week
greater_than: The number of days worked per week must be between 0 and 5
less_than_or_equal_to: The number of days worked per week must be between 0 and 5
not_a_number: The number of days worked per week must be a number
hire_date:
after_contract_start_date: The date you want to take the worker on permanently must be after the date the worker’s current contract started
blank: Enter the date you want to take the worker on permanently, including the day, month and year
invalid: Enter a real date
holiday_1_end_date:
before_start_date: The end date of the first school holiday must be after the start date
blank: Enter the date the first school holiday ended, including the day, month and year
invalid: Enter a real date
holiday_1_start_date:
blank: Enter the date the first school holiday started, including the day, month and year
invalid: Enter a real date
holiday_2_end_date:
before_start_date: The end date of the second school holiday must be after the start date
blank: Enter the date the second school holiday ended, including the day, month and yea
invalid: Enter a real date
holiday_2_start_date:
blank: Enter the date the second school holiday started, including the day, month and year
invalid: Enter a real date
markup_rate:
blank: Enter a mark-up percentage
greater_than_or_equal_to: The mark-up percentage must be between 0 and 100
less_than_or_equal_to: The mark-up percentage must be between 0 and 100
not_a_number: The mark-up percentage must be a number
notice_date:
after_hire_date: The date you notified the agency that you wish to hire the worker must be before the date you want to take the worker on permanently
before_contract_start_date: The date you notified the agency that you wish to hire the worker must be after the date the worker’s current contract started
blank: Enter the date you notified the agency that you wish to hire the worker, including the day, month and year
invalid: Enter a real date
supply_teachers/journey/worker_type:
attributes:
worker_type:
inclusion: Select yes if you want an agency to supply the worker
activerecord:
errors:
models:
Expand Down
16 changes: 12 additions & 4 deletions config/locales/views/facilities_management.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,6 @@ en:
attributes:
base:
not_selected: You must select an address to save your details
central_government:
inclusion: Select the type of public sector organisation you’re buying for
contact_opt_in:
inclusion: You must select an option
full_name:
Expand All @@ -94,6 +92,8 @@ en:
organisation_name:
blank: Enter your organisation name
invalid: Enter your organisation name
sector:
inclusion: Select the type of public sector organisation you’re buying for
telephone_number:
blank: Enter a UK telephone number, for example 020 7946 0000
invalid: Enter a UK telephone number, for example 020 7946 0000
Expand Down Expand Up @@ -312,7 +312,6 @@ en:
buyer_details: Manage your details
cant_find_address: Enter address manually, if you can’t find address
central_government:
legend: Which type of public sector organisation are you buying for?
options:
'false': Wider public sector
'true': Central government
Expand All @@ -327,7 +326,16 @@ en:
organisation_address: Organisation address
organisation_details: Organisation details
organisation_name: Organisation name
search_html: Search <a href="%{url}" target="_blank">central government departments, agencies and public bodies</a> if you’re unsure.
sector:
legend: Which type of public sector organisation are you buying for?
options:
culture_media_and_sport: Culture, Media and Sport
defence_and_security: Defence and Security
education: Education
government_policy: Government Policy
health: Health
infrastructure: Infrastructure
local_community_and_housing: Local Community and Housing
submit: Save and continue
telephone_number: Telephone number
your_details: Personal details
Expand Down
5 changes: 5 additions & 0 deletions db/migrate/20230425131936_add_sector_for_buyer_details.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddSectorForBuyerDetails < ActiveRecord::Migration[7.0]
def change
add_column :facilities_management_buyer_details, :sector, :string, limit: 255
end
end
3 changes: 2 additions & 1 deletion 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.0].define(version: 2023_04_25_075107) do
ActiveRecord::Schema[7.0].define(version: 2023_04_25_131936) do
# These are extensions that must be enabled in order to support this database
enable_extension "pgcrypto"
enable_extension "plpgsql"
Expand Down Expand Up @@ -84,6 +84,7 @@
t.datetime "updated_at", precision: nil, null: false
t.uuid "user_id", null: false
t.boolean "contact_opt_in"
t.string "sector", limit: 255
t.index ["user_id"], name: "index_facilities_management_buyer_details_on_user_id"
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Feature: Buyer details
| Telephone number | 01610161016 |
| Organisation name | Feel Good inc. |
| Postcode | ST16 1AA |
And I check 'Central government' for the sector
And I check 'Health' for the sector
And I check 'Yes' for being contacted

Scenario: Save details for the buyer - add address normally
Expand All @@ -25,7 +25,7 @@ Feature: Buyer details
| Telephone number | 01610161016 |
| Organisation name | Feel Good inc. |
| Organisation address | Stafford Delivery Office, Newport Road, Stafford ST16 1AA |
| Sector | Central government |
| Sector | Health |
| Contact opt in | Yes |

Scenario: Save details for the buyer - add address manually
Expand All @@ -48,5 +48,5 @@ Feature: Buyer details
| Telephone number | 01610161016 |
| Organisation name | Feel Good inc. |
| Organisation address | 112 Test street, Westminister AA1 1AA |
| Sector | Central government |
| Sector | Health |
| Contact opt in | Yes |
Loading

0 comments on commit ee9f347

Please sign in to comment.