Browse Source
* added test to find link to create a new scheme * added button to create a new scheme * testing arriving to the new scheme form * non exsiting link to controller new action * SPIKEEEE * first page complete * posting to create * refactored scheme to enums * refactored new scheme page to use enums as well * views * SPIKE WIP * SPIKE WIP * SPIKE WIP * drawing list of scheme details * expanded on feature seeing more fields to fill in * expanded on feature seeing more fields to fill in 2nd page * refactored * working back buttons * working flash * more change in wip * default value for org * working spike * some spacing * filling answers * spike finished * correct name for details * testing fill in details * removed gem and further tests * Add has other client group field to schemes. Display it in the check answers. Fix tests and routing * remove details view and path Co-authored-by: baarkerlounger <baarkerlounger@users.noreply.github.com> * WIP change update paths * Implement changing answers (except the details one) * Add details page back for editing scheme details * added missing test for support questions and nested check answers under correct context * checking the back functionality * rubo and lint * checking the back functionality for primary gourp * checking the back functionality for confirm secondary * checking the back functionality for secondary group * checking the back functionality for support answers * checking the back functionality for returning to check answers from details page * checking the back functionality for returning to check answers from primary group page * checking the back functionality for secondary group confirm yes * checking the back functionality for secondary group confirm yes - fixed * checking the back functionality for secondary group * checking the back functionality for secondary group -fixed * checking the back functionality for returning from support page * Do not display secondary client group if the scheme doesn't have one * Add details path to schemes controller update method * Add more tests for back button * Add tests for new controller method * Add tests for creating schemes as data coordinator * fixed schema * added test for missing params when creating scheme * create for support user with or withotu required param * code to get controller render errors when required param is missing * code to implement correct validation * code to implement correct validation - part 2 * highlight missing field * doing silly dance to get correct field highlighted on the error * testing patch for schemes * testing patch for schemes - correct path * small refactoring * testing primary client group update via regular path * testing primary client group update via check answers page * testing confirm secondary group update with YES NO and returning from check answers page * testing updating secondary client group update and returning from check answers page * testing support answers and returning from check answers page * testing details and returning from check answers page * weird path when no names supplied * rubocop * lost in rebasing * started id to code refactoring * model specs remastered * fixed scheme controller specs * further refactorings * fixing feature schemes * final touches * removed code from db * remaining code purged * rubocop * included check for owning org field * checking for stock owning org selection * added stock owning org * added stock owning org on new page * added stock owning org to details * removed total units * managing related schems properly via Org * managing related schems properly via Org - rubocop * small refactoring * small refactoring - 2 * small refactoring - 3 * tests for owned_schemes and managed_schemes * rubocop * added tests for support user creating scheme * rubocop -a * tests for a primary-client-group * tests for a secondary-client-group * tests for a confirm-secondary-client-group * tests for a check-answers * tests for a details * rubocop * redundant action in controller * Trigger WF * switched to int for confirm * flashing test * flashing test for support user * flashing test rubocop Co-authored-by: Kat <katrina@madetech.com> Co-authored-by: baarkerlounger <baarkerlounger@users.noreply.github.com>pull/706/head
J G
3 years ago
committed by
GitHub
30 changed files with 2023 additions and 213 deletions
@ -1,110 +1,145 @@ |
|||||||
class Scheme < ApplicationRecord |
class Scheme < ApplicationRecord |
||||||
belongs_to :organisation |
belongs_to :organisation |
||||||
|
belongs_to :stock_owning_organisation, optional: true, class_name: "Organisation" |
||||||
has_many :locations |
has_many :locations |
||||||
has_many :case_logs |
has_many :case_logs |
||||||
|
|
||||||
scope :search_by_code, ->(code) { where("code ILIKE ?", "%#{code}%") } |
scope :filter_by_id, ->(id) { where(id: (id.start_with?("S") ? id[1..] : id)) } |
||||||
scope :search_by_service_name, ->(name) { where("service_name ILIKE ?", "%#{name}%") } |
scope :search_by_service_name, ->(name) { where("service_name ILIKE ?", "%#{name}%") } |
||||||
scope :search_by_postcode, ->(postcode) { joins(:locations).where("locations.postcode ILIKE ?", "%#{postcode.delete(' ')}%") } |
scope :search_by_postcode, ->(postcode) { joins(:locations).where("locations.postcode ILIKE ?", "%#{postcode.delete(' ')}%") } |
||||||
scope :search_by, ->(param) { search_by_postcode(param).or(search_by_service_name(param)).or(search_by_code(param)).distinct } |
scope :search_by, ->(param) { search_by_postcode(param).or(search_by_service_name(param)).or(filter_by_id(param)).distinct } |
||||||
|
|
||||||
SCHEME_TYPE = { |
SENSITIVE = { |
||||||
0 => "Missings", |
No: 0, |
||||||
4 => "Foyer", |
Yes: 1, |
||||||
5 => "Direct Access Hostel", |
|
||||||
6 => "Other Supported Housing", |
|
||||||
7 => "Housing for older people", |
|
||||||
}.freeze |
}.freeze |
||||||
|
|
||||||
PRIMARY_CLIENT_GROUP = { |
enum sensitive: SENSITIVE, _suffix: true |
||||||
"O" => "Homeless families with support needs", |
|
||||||
"H" => "Offenders & people at risk of offending", |
REGISTERED_UNDER_CARE_ACT = { |
||||||
"M" => "Older people with support needs", |
"No": 0, |
||||||
"L" => "People at risk of domestic violence", |
"Yes – registered care home providing nursing care": 1, |
||||||
"A" => "People with a physical or sensory disability", |
"Yes – registered care home providing personal care": 2, |
||||||
"G" => "People with alcohol problems", |
"Yes – part registered as a care home": 3, |
||||||
"F" => "People with drug problems", |
|
||||||
"B" => "People with HIV or AIDS", |
|
||||||
"D" => "People with learning disabilities", |
|
||||||
"E" => "People with mental health problems", |
|
||||||
"I" => "Refugees (permanent)", |
|
||||||
"S" => "Rough sleepers", |
|
||||||
"N" => "Single homeless people with support needs", |
|
||||||
"R" => "Teenage parents", |
|
||||||
"Q" => "Young people at risk", |
|
||||||
"P" => "Young people leaving care", |
|
||||||
"X" => "Missing", |
|
||||||
}.freeze |
}.freeze |
||||||
|
|
||||||
|
enum registered_under_care_act: REGISTERED_UNDER_CARE_ACT |
||||||
|
|
||||||
|
SCHEME_TYPE = { |
||||||
|
"Missing": 0, |
||||||
|
"Foyer": 4, |
||||||
|
"Direct Access Hostel": 5, |
||||||
|
"Other Supported Housing": 6, |
||||||
|
"Housing for older people": 7, |
||||||
|
}.freeze |
||||||
|
|
||||||
|
enum scheme_type: SCHEME_TYPE, _suffix: true |
||||||
|
|
||||||
SUPPORT_TYPE = { |
SUPPORT_TYPE = { |
||||||
0 => "Missing", |
"Missing": 0, |
||||||
1 => "Resettlement Support", |
"Resettlement support": 1, |
||||||
2 => "Low levels of support", |
"Low levels of support": 2, |
||||||
3 => "Medium levels of support", |
"Medium levels of support": 3, |
||||||
4 => "High levels of care and support", |
"High levels of care and support": 4, |
||||||
5 => "Nursing care services to a care home", |
"Nursing care services to a care home": 5, |
||||||
6 => "Floating Support", |
"Floating Support": 6, |
||||||
}.freeze |
}.freeze |
||||||
|
|
||||||
INTENDED_STAY = { |
enum support_type: SUPPORT_TYPE, _suffix: true |
||||||
"M" => "Medium stay", |
|
||||||
"P" => "Permanent", |
PRIMARY_CLIENT_GROUP = { |
||||||
"S" => "Short Stay", |
"Homeless families with support needs": "O", |
||||||
"V" => "Very short stay", |
"Offenders & people at risk of offending": "H", |
||||||
"X" => "Missing", |
"Older people with support needs": "M", |
||||||
|
"People at risk of domestic violence": "L", |
||||||
|
"People with a physical or sensory disability": "A", |
||||||
|
"People with alcohol problems": "G", |
||||||
|
"People with drug problems": "F", |
||||||
|
"People with HIV or AIDS": "B", |
||||||
|
"People with learning disabilities": "D", |
||||||
|
"People with mental health problems": "E", |
||||||
|
"Refugees (permanent)": "I", |
||||||
|
"Rough sleepers": "S", |
||||||
|
"Single homeless people with support needs": "N", |
||||||
|
"Teenage parents": "R", |
||||||
|
"Young people at risk": "Q", |
||||||
|
"Young people leaving care": "P", |
||||||
|
"Missing": "X", |
||||||
}.freeze |
}.freeze |
||||||
|
|
||||||
REGISTERED_UNDER_CARE_ACT = { |
enum primary_client_group: PRIMARY_CLIENT_GROUP, _suffix: true |
||||||
0 => "No", |
enum secondary_client_group: PRIMARY_CLIENT_GROUP, _suffix: true |
||||||
1 => "Yes – part registered as a care home", |
|
||||||
|
INTENDED_STAY = { |
||||||
|
"Medium stay": "M", |
||||||
|
"Permanent": "P", |
||||||
|
"Short stay": "S", |
||||||
|
"Very short stay": "V", |
||||||
|
"Missing": "X", |
||||||
}.freeze |
}.freeze |
||||||
|
|
||||||
SENSITIVE = { |
HAS_OTHER_CLIENT_GROUP = { |
||||||
0 => "No", |
No: 0, |
||||||
1 => "Yes", |
Yes: 1, |
||||||
}.freeze |
}.freeze |
||||||
|
|
||||||
def display_attributes |
enum intended_stay: INTENDED_STAY, _suffix: true |
||||||
|
enum has_other_client_group: HAS_OTHER_CLIENT_GROUP, _suffix: true |
||||||
|
|
||||||
|
def id_to_display |
||||||
|
"S#{id}" |
||||||
|
end |
||||||
|
|
||||||
|
def check_details_attributes |
||||||
[ |
[ |
||||||
{ name: "Service code", value: code }, |
{ name: "Service code", value: id_to_display }, |
||||||
{ name: "Name", value: service_name }, |
{ name: "Name", value: service_name }, |
||||||
{ name: "Confidential information", value: sensitive_display }, |
{ name: "Confidential information", value: sensitive }, |
||||||
|
{ name: "Housing stock owned by", value: stock_owning_organisation&.name }, |
||||||
{ name: "Managed by", value: organisation.name }, |
{ name: "Managed by", value: organisation.name }, |
||||||
{ name: "Type of scheme", value: scheme_type_display }, |
{ name: "Type of scheme", value: scheme_type }, |
||||||
{ name: "Registered under Care Standards Act 2000", value: registered_under_care_act_display }, |
{ name: "Registered under Care Standards Act 2000", value: registered_under_care_act }, |
||||||
{ name: "Total number of units", value: total_units }, |
|
||||||
{ name: "Primary client group", value: primary_client_group_display }, |
|
||||||
{ name: "Secondary client group", value: secondary_client_group_display }, |
|
||||||
{ name: "Level of support given", value: support_type_display }, |
|
||||||
{ name: "Intended length of stay", value: intended_stay_display }, |
|
||||||
] |
] |
||||||
end |
end |
||||||
|
|
||||||
def scheme_type_display |
def check_primary_client_attributes |
||||||
SCHEME_TYPE[scheme_type] |
[ |
||||||
end |
{ name: "Primary client group", value: primary_client_group }, |
||||||
|
] |
||||||
def sensitive_display |
|
||||||
SENSITIVE[sensitive] |
|
||||||
end |
|
||||||
|
|
||||||
def registered_under_care_act_display |
|
||||||
REGISTERED_UNDER_CARE_ACT[registered_under_care_act] |
|
||||||
end |
end |
||||||
|
|
||||||
def primary_client_group_display |
def check_secondary_client_confirmation_attributes |
||||||
PRIMARY_CLIENT_GROUP[primary_client_group] |
[ |
||||||
|
{ name: "Has another client group", value: has_other_client_group }, |
||||||
|
] |
||||||
end |
end |
||||||
|
|
||||||
def secondary_client_group_display |
def check_secondary_client_attributes |
||||||
PRIMARY_CLIENT_GROUP[secondary_client_group] |
[ |
||||||
|
{ name: "Secondary client group", value: secondary_client_group }, |
||||||
|
] |
||||||
end |
end |
||||||
|
|
||||||
def support_type_display |
def check_support_attributes |
||||||
SUPPORT_TYPE[support_type] |
[ |
||||||
|
{ name: "Level of support given", value: support_type }, |
||||||
|
{ name: "Intended length of stay", value: intended_stay }, |
||||||
|
] |
||||||
end |
end |
||||||
|
|
||||||
def intended_stay_display |
def display_attributes |
||||||
INTENDED_STAY[intended_stay] |
[ |
||||||
|
{ name: "Service code", value: id_to_display }, |
||||||
|
{ name: "Name", value: service_name }, |
||||||
|
{ name: "Confidential information", value: sensitive }, |
||||||
|
{ name: "Housing stock owned by", value: stock_owning_organisation&.name }, |
||||||
|
{ name: "Managed by", value: organisation.name }, |
||||||
|
{ name: "Type of scheme", value: scheme_type }, |
||||||
|
{ name: "Registered under Care Standards Act 2000", value: registered_under_care_act }, |
||||||
|
{ name: "Primary client group", value: primary_client_group }, |
||||||
|
{ name: "Secondary client group", value: secondary_client_group }, |
||||||
|
{ name: "Level of support given", value: support_type }, |
||||||
|
{ name: "Intended length of stay", value: intended_stay }, |
||||||
|
] |
||||||
end |
end |
||||||
end |
end |
||||||
|
@ -0,0 +1,65 @@ |
|||||||
|
<% content_for :title, "Check your answers before creating this scheme" %> |
||||||
|
|
||||||
|
<%= render partial: "organisations/headings", locals: { main: "Check your changes before updating this scheme", sub: @scheme.service_name } %> |
||||||
|
|
||||||
|
<%= govuk_tabs(title: "Check your answers before creating this scheme") do |component| %> |
||||||
|
<% component.tab(label: "Scheme") do %> |
||||||
|
<%= govuk_summary_list do |summary_list| %> |
||||||
|
<% @scheme.check_details_attributes.each do |attr| %> |
||||||
|
<% next if current_user.data_coordinator? && attr[:name] == ("Managed by") %> |
||||||
|
<%= summary_list.row do |row| %> |
||||||
|
<% row.key { attr[:name].to_s } %> |
||||||
|
<% row.value { details_html(attr) } %> |
||||||
|
<% row.action( |
||||||
|
text: "Change", |
||||||
|
href: scheme_details_path(scheme_id: @scheme.id, check_answers: true), |
||||||
|
) %> |
||||||
|
<% end %> |
||||||
|
<% end %> |
||||||
|
<% @scheme.check_primary_client_attributes.each do |attr| %> |
||||||
|
<%= summary_list.row do |row| %> |
||||||
|
<% row.key { attr[:name].to_s } %> |
||||||
|
<% row.value { details_html(attr) } %> |
||||||
|
<% row.action( |
||||||
|
text: "Change", |
||||||
|
href: scheme_primary_client_group_path(scheme_id: @scheme.id, check_answers: true), |
||||||
|
) %> |
||||||
|
<% end %> |
||||||
|
<% end %> |
||||||
|
<% @scheme.check_secondary_client_confirmation_attributes.each do |attr| %> |
||||||
|
<%= summary_list.row do |row| %> |
||||||
|
<% row.key { attr[:name].to_s } %> |
||||||
|
<% row.value { details_html(attr) } %> |
||||||
|
<% row.action( |
||||||
|
text: "Change", |
||||||
|
href: scheme_confirm_secondary_client_group_path(scheme_id: @scheme.id, check_answers: true), |
||||||
|
) %> |
||||||
|
<% end %> |
||||||
|
<% end %> |
||||||
|
<% if @scheme.has_other_client_group == "Yes" %> |
||||||
|
<% @scheme.check_secondary_client_attributes.each do |attr| %> |
||||||
|
<%= summary_list.row do |row| %> |
||||||
|
<% row.key { attr[:name].to_s } %> |
||||||
|
<% row.value { details_html(attr) } %> |
||||||
|
<% row.action( |
||||||
|
text: "Change", |
||||||
|
href: scheme_secondary_client_group_path(scheme_id: @scheme.id, check_answers: true), |
||||||
|
) %> |
||||||
|
<% end %> |
||||||
|
<% end %> |
||||||
|
<% end %> |
||||||
|
<% @scheme.check_support_attributes.each do |attr| %> |
||||||
|
<%= summary_list.row do |row| %> |
||||||
|
<% row.key { attr[:name].to_s } %> |
||||||
|
<% row.value { details_html(attr) } %> |
||||||
|
<% row.action( |
||||||
|
text: "Change", |
||||||
|
href: scheme_support_path(scheme_id: @scheme.id, check_answers: true), |
||||||
|
) %> |
||||||
|
<% end %> |
||||||
|
<% end %> |
||||||
|
<% end %> |
||||||
|
<% end %> |
||||||
|
<% end %> |
||||||
|
|
||||||
|
<%= govuk_button_link_to "Create scheme", schemes_path(scheme_id: @scheme.id), html: { method: :get } %> |
@ -0,0 +1,32 @@ |
|||||||
|
<% content_for :title, "Does this scheme provide for another client group?" %> |
||||||
|
|
||||||
|
<% content_for :before_content do %> |
||||||
|
<%= govuk_back_link( |
||||||
|
text: "Back", |
||||||
|
href: request.query_parameters["check_answers"] ? "/schemes/#{@scheme.id}/check-answers" : "/schemes/#{@scheme.id}/primary-client-group", |
||||||
|
) %> |
||||||
|
<% end %> |
||||||
|
|
||||||
|
<%= render partial: "organisations/headings", locals: { main: "Does this scheme provide for another client group?", sub: @scheme.service_name } %> |
||||||
|
|
||||||
|
<%= form_for(@scheme, method: :patch) do |f| %> |
||||||
|
<div class="govuk-grid-row"> |
||||||
|
<div class="govuk-grid-column-two-thirds"> |
||||||
|
|
||||||
|
<% selection = [OpenStruct.new(id: "Yes", name: "Yes"), OpenStruct.new(id: "No", name: "No")] %> |
||||||
|
|
||||||
|
<%= f.govuk_collection_radio_buttons :has_other_client_group, |
||||||
|
selection, |
||||||
|
:id, |
||||||
|
:name, |
||||||
|
legend: nil %> |
||||||
|
|
||||||
|
<%= f.hidden_field :page, value: "confirm-secondary" %> |
||||||
|
<% if request.query_parameters["check_answers"] == "true" %> |
||||||
|
<%= f.hidden_field :check_answers, value: "true" %> |
||||||
|
<% end %> |
||||||
|
|
||||||
|
<%= f.govuk_submit "Save and continue" %> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
<% end %> |
@ -0,0 +1,76 @@ |
|||||||
|
<% content_for :title, "Create a new supported housing scheme" %> |
||||||
|
|
||||||
|
<% content_for :before_content do %> |
||||||
|
<%= govuk_back_link( |
||||||
|
text: "Back", |
||||||
|
href: :back, |
||||||
|
) %> |
||||||
|
<% end %> |
||||||
|
|
||||||
|
<%= render partial: "organisations/headings", locals: { main: "Create a new supported housing scheme", sub: nil } %> |
||||||
|
|
||||||
|
<%= form_for(@scheme, method: :patch) do |f| %> |
||||||
|
<div class="govuk-grid-row"> |
||||||
|
<div class="govuk-grid-column-two-thirds"> |
||||||
|
<%= f.govuk_error_summary %> |
||||||
|
|
||||||
|
<%= f.govuk_text_field :service_name, |
||||||
|
label: { text: "Scheme name", size: "m" }, |
||||||
|
hint: { text: "This is how you’ll refer to this supported housing scheme within your organisation. For example, the name could relate to the address or location. You’ll be able to see the client group when selecting it." } %> |
||||||
|
|
||||||
|
<%= f.govuk_check_box :sensitive, |
||||||
|
1, |
||||||
|
0, |
||||||
|
checked: @scheme.sensitive?, |
||||||
|
multiple: false, |
||||||
|
label: { text: "This scheme contains confidential information" } %> |
||||||
|
|
||||||
|
<% null_option = [OpenStruct.new(id: "", name: "Select an option")] %> |
||||||
|
<% organisations = Organisation.all.map { |org| OpenStruct.new(id: org.id, name: org.name) } %> |
||||||
|
<% stock_org_answer_options = null_option + organisations %> |
||||||
|
|
||||||
|
<%= f.govuk_collection_select :stock_owning_organisation_id, |
||||||
|
stock_org_answer_options, |
||||||
|
:id, |
||||||
|
:name, |
||||||
|
label: { text: "Which organisation owns the housing stock for this scheme?", size: "m" }, |
||||||
|
"data-controller": %w[accessible-autocomplete conditional-filter] %> |
||||||
|
|
||||||
|
<% if current_user.support? %> |
||||||
|
<%= f.govuk_collection_select :organisation_id, |
||||||
|
organisations, |
||||||
|
:id, |
||||||
|
:name, |
||||||
|
label: { text: "Which organisation manages this scheme?", size: "m" }, |
||||||
|
options: { required: true }, |
||||||
|
"data-controller": %w[accessible-autocomplete conditional-filter] %> |
||||||
|
<% end %> |
||||||
|
|
||||||
|
<% if current_user.data_coordinator? %> |
||||||
|
<%= f.hidden_field :organisation_id, value: current_user.organisation.id %> |
||||||
|
<% end %> |
||||||
|
|
||||||
|
<% scheme_types_selection = Scheme.scheme_types.keys.excluding("Missing").map { |key, _| OpenStruct.new(id: key, name: key.to_s.humanize) } %> |
||||||
|
|
||||||
|
<%= f.govuk_collection_radio_buttons :scheme_type, |
||||||
|
scheme_types_selection, |
||||||
|
:id, |
||||||
|
:name, |
||||||
|
legend: { text: "What is this type of scheme?", size: "m" } %> |
||||||
|
|
||||||
|
<% care_acts_selection = Scheme.registered_under_care_acts.keys.reverse.map { |key, _| OpenStruct.new(id: key, name: key.to_s.humanize) } %> |
||||||
|
|
||||||
|
<%= f.govuk_collection_radio_buttons :registered_under_care_act, |
||||||
|
care_acts_selection, |
||||||
|
:id, |
||||||
|
:name, |
||||||
|
legend: { text: "Is this scheme registered under the Care Standards Act 2000?", size: "m" } %> |
||||||
|
|
||||||
|
<%= f.hidden_field :page, value: "details" %> |
||||||
|
<% if request.query_parameters["check_answers"] %> |
||||||
|
<%= f.hidden_field :check_answers, value: "true" %> |
||||||
|
<% end %> |
||||||
|
<%= f.govuk_submit "Save and continue" %> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
<% end %> |
@ -0,0 +1,72 @@ |
|||||||
|
<% content_for :title, "Create a new supported housing scheme" %> |
||||||
|
|
||||||
|
<% content_for :before_content do %> |
||||||
|
<%= govuk_back_link( |
||||||
|
text: "Back", |
||||||
|
href: "javascript:history.go(-1);", |
||||||
|
) %> |
||||||
|
<% end %> |
||||||
|
|
||||||
|
<%= form_for(@scheme, as: :scheme, method: :post) do |f| %> |
||||||
|
<div class="govuk-grid-row"> |
||||||
|
<div class="govuk-grid-column-two-thirds"> |
||||||
|
<%= f.govuk_error_summary %> |
||||||
|
|
||||||
|
<h1 class="govuk-heading-l"> |
||||||
|
<%= content_for(:title) %> |
||||||
|
</h1> |
||||||
|
|
||||||
|
<%= f.govuk_text_field :service_name, |
||||||
|
label: { text: "Scheme name", size: "m" }, |
||||||
|
hint: { text: "This is how you refer to this supported housing scheme within your organisation. For example, the name could relate to the address or location. You’ll be able to see the client group when selecting it." } %> |
||||||
|
|
||||||
|
<%= f.govuk_check_box :sensitive, |
||||||
|
"Yes", |
||||||
|
checked: @scheme.sensitive?, |
||||||
|
multiple: false, |
||||||
|
label: { text: "This scheme contains confidential information" } %> |
||||||
|
|
||||||
|
<% null_option = [OpenStruct.new(id: "", name: "Select an option")] %> |
||||||
|
<% organisations = Organisation.all.map { |org| OpenStruct.new(id: org.id, name: org.name) } %> |
||||||
|
<% answer_options = null_option + organisations %> |
||||||
|
|
||||||
|
<%= f.govuk_collection_select :stock_owning_organisation_id, |
||||||
|
answer_options, |
||||||
|
:id, |
||||||
|
:name, |
||||||
|
label: { text: "Which organisation owns the housing stock for this scheme?", size: "m" }, |
||||||
|
"data-controller": %w[accessible-autocomplete conditional-filter] %> |
||||||
|
|
||||||
|
<% if current_user.support? %> |
||||||
|
<%= f.govuk_collection_select :organisation_id, |
||||||
|
answer_options, |
||||||
|
:id, |
||||||
|
:name, |
||||||
|
label: { text: "Which organisation manages this scheme?", size: "m" }, |
||||||
|
"data-controller": %w[accessible-autocomplete conditional-filter] %> |
||||||
|
<% end %> |
||||||
|
|
||||||
|
<% if current_user.data_coordinator? %> |
||||||
|
<%= f.hidden_field :organisation_id, value: current_user.organisation.id %> |
||||||
|
<% end %> |
||||||
|
|
||||||
|
<% scheme_types_selection = Scheme.scheme_types.keys.excluding("Missing").map { |key, _| OpenStruct.new(id: key, name: key.to_s.humanize) } %> |
||||||
|
|
||||||
|
<%= f.govuk_collection_radio_buttons :scheme_type, |
||||||
|
scheme_types_selection, |
||||||
|
:id, |
||||||
|
:name, |
||||||
|
legend: { text: "What is this type of scheme?", size: "m" } %> |
||||||
|
|
||||||
|
<% care_acts_selection = Scheme.registered_under_care_acts.keys.reverse.map { |key, _| OpenStruct.new(id: key, name: key.to_s.humanize) } %> |
||||||
|
|
||||||
|
<%= f.govuk_collection_radio_buttons :registered_under_care_act, |
||||||
|
care_acts_selection, |
||||||
|
:id, |
||||||
|
:name, |
||||||
|
legend: { text: "Is this scheme registered under the Care Standards Act 2000?", size: "m" } %> |
||||||
|
|
||||||
|
<%= f.govuk_submit "Save and continue" %> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
<% end %> |
@ -0,0 +1,35 @@ |
|||||||
|
<% content_for :title, "What client group is this scheme intended for?" %> |
||||||
|
|
||||||
|
<% content_for :before_content do %> |
||||||
|
<%= govuk_back_link( |
||||||
|
text: "Back", |
||||||
|
href: request.query_parameters["check_answers"] ? "/schemes/#{@scheme.id}/check-answers" : "/schemes/#{@scheme.id}/details", |
||||||
|
) %> |
||||||
|
<% end %> |
||||||
|
|
||||||
|
<%= render partial: "organisations/headings", locals: { main: "What client group is this scheme intended for?", sub: @scheme.service_name } %> |
||||||
|
|
||||||
|
<%= form_for(@scheme, method: :patch) do |f| %> |
||||||
|
<div class="govuk-grid-row"> |
||||||
|
<div class="govuk-grid-column-two-thirds"> |
||||||
|
<%= f.govuk_error_summary %> |
||||||
|
|
||||||
|
<legend class="govuk-fieldset__legend"> |
||||||
|
</legend> |
||||||
|
|
||||||
|
<% primary_client_group_selection = Scheme.primary_client_groups.keys.excluding("Missing").map { |key, _| OpenStruct.new(id: key, name: key.to_s.humanize) } %> |
||||||
|
<%= f.govuk_collection_radio_buttons :primary_client_group, |
||||||
|
primary_client_group_selection, |
||||||
|
:id, |
||||||
|
:name, |
||||||
|
legend: nil %> |
||||||
|
|
||||||
|
<%= f.hidden_field :page, value: "primary-client-group" %> |
||||||
|
<% if request.query_parameters["check_answers"] == "true" %> |
||||||
|
<%= f.hidden_field :check_answers, value: "true" %> |
||||||
|
<% end %> |
||||||
|
|
||||||
|
<%= f.govuk_submit "Save and continue" %> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
<% end %> |
@ -0,0 +1,35 @@ |
|||||||
|
<% content_for :title, "What is the other client group?" %> |
||||||
|
|
||||||
|
<% content_for :before_content do %> |
||||||
|
<%= govuk_back_link( |
||||||
|
text: "Back", |
||||||
|
href: request.query_parameters["check_answers"] ? "/schemes/#{@scheme.id}/check-answers" : "/schemes/#{@scheme.id}/confirm-secondary-client-group", |
||||||
|
) %> |
||||||
|
<% end %> |
||||||
|
|
||||||
|
<%= render partial: "organisations/headings", locals: { main: "What is the other client group?", sub: @scheme.service_name } %> |
||||||
|
|
||||||
|
<%= form_for(@scheme, method: :patch) do |f| %> |
||||||
|
<div class="govuk-grid-row"> |
||||||
|
<div class="govuk-grid-column-two-thirds"> |
||||||
|
<%= f.govuk_error_summary %> |
||||||
|
|
||||||
|
<legend class="govuk-fieldset__legend"> |
||||||
|
</legend> |
||||||
|
|
||||||
|
<% secondary_client_group_selection = Scheme.secondary_client_groups.keys.excluding("Missing").map { |key, _| OpenStruct.new(id: key, name: key.to_s.humanize) } %> |
||||||
|
<%= f.govuk_collection_radio_buttons :secondary_client_group, |
||||||
|
secondary_client_group_selection, |
||||||
|
:id, |
||||||
|
:name, |
||||||
|
legend: nil %> |
||||||
|
|
||||||
|
<%= f.hidden_field :page, value: "secondary-client-group" %> |
||||||
|
<% if request.query_parameters["check_answers"] == "true" %> |
||||||
|
<%= f.hidden_field :check_answers, value: "true" %> |
||||||
|
<% end %> |
||||||
|
|
||||||
|
<%= f.govuk_submit "Save and continue" %> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
<% end %> |
@ -0,0 +1,39 @@ |
|||||||
|
<% content_for :title, "What support does this scheme provide?" %> |
||||||
|
|
||||||
|
<% content_for :before_content do %> |
||||||
|
<%= govuk_back_link( |
||||||
|
text: "Back", |
||||||
|
href: request.query_parameters["check_answers"] ? "/schemes/#{@scheme.id}/check-answers" : "/schemes/#{@scheme.id}/secondary-client-group", |
||||||
|
) %> |
||||||
|
<% end %> |
||||||
|
|
||||||
|
<%= render partial: "organisations/headings", locals: { main: "What support does this scheme provide?", sub: @scheme.service_name } %> |
||||||
|
|
||||||
|
<%= form_for(@scheme, method: :patch) do |f| %> |
||||||
|
<div class="govuk-grid-row"> |
||||||
|
<div class="govuk-grid-column-two-thirds"> |
||||||
|
<%= f.govuk_error_summary %> |
||||||
|
|
||||||
|
<legend class="govuk-fieldset__legend"> |
||||||
|
</legend> |
||||||
|
|
||||||
|
<% support_type_selection = Scheme.support_types.keys.excluding("Missing").map { |key, _| OpenStruct.new(id: key, name: key.to_s.humanize) } %> |
||||||
|
<%= f.govuk_collection_radio_buttons :support_type, |
||||||
|
support_type_selection, |
||||||
|
:id, |
||||||
|
:name, |
||||||
|
legend: { text: "Level of support given", size: "m" } %> |
||||||
|
|
||||||
|
<% intended_stay_selection = Scheme.intended_stays.keys.excluding("Missing").map { |key, _| OpenStruct.new(id: key, name: key.to_s.humanize) } %> |
||||||
|
<%= f.govuk_collection_radio_buttons :intended_stay, |
||||||
|
intended_stay_selection, |
||||||
|
:id, |
||||||
|
:name, |
||||||
|
legend: { text: "Intended length of stay", size: "m" } %> |
||||||
|
|
||||||
|
<%= f.hidden_field :page, value: "support" %> |
||||||
|
|
||||||
|
<%= f.govuk_submit "Save and continue" %> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
<% end %> |
@ -1,5 +1,5 @@ |
|||||||
class AddReferenceToCaseLog < ActiveRecord::Migration[7.0] |
class AddReferenceToCaseLog < ActiveRecord::Migration[7.0] |
||||||
def change |
def change |
||||||
add_reference :case_logs, :scheme, foreign_key: true |
add_reference :case_logs, :scheme, foreign_key: true, null: true |
||||||
end |
end |
||||||
end |
end |
||||||
|
@ -0,0 +1,7 @@ |
|||||||
|
class AddHasOtherClientGroupField < ActiveRecord::Migration[7.0] |
||||||
|
def change |
||||||
|
change_table :schemes, bulk: true do |t| |
||||||
|
t.column :has_other_client_group, :integer |
||||||
|
end |
||||||
|
end |
||||||
|
end |
@ -0,0 +1,5 @@ |
|||||||
|
class RemoveCodeFromSchemes < ActiveRecord::Migration[7.0] |
||||||
|
def change |
||||||
|
remove_column :schemes, :code, :string |
||||||
|
end |
||||||
|
end |
@ -0,0 +1,5 @@ |
|||||||
|
class AddStockOwningOrganisationToSchemes < ActiveRecord::Migration[7.0] |
||||||
|
def change |
||||||
|
add_reference :schemes, :stock_owning_organisation, foreign_key: { to_table: :organisations } |
||||||
|
end |
||||||
|
end |
Loading…
Reference in new issue