diff --git a/app/controllers/schemes_controller.rb b/app/controllers/schemes_controller.rb
index e97a08e4b..541e72666 100644
--- a/app/controllers/schemes_controller.rb
+++ b/app/controllers/schemes_controller.rb
@@ -25,6 +25,14 @@ class SchemesController < ApplicationController
@total_count = @scheme.locations.size
end
+ def new
+ @resource = Scheme.new
+ end
+
+ def create
+ debugger
+ end
+
private
def search_term
diff --git a/app/models/scheme.rb b/app/models/scheme.rb
index 90f027f2f..ecbe40ecb 100644
--- a/app/models/scheme.rb
+++ b/app/models/scheme.rb
@@ -9,7 +9,7 @@ class Scheme < ApplicationRecord
scope :search_by, ->(param) { search_by_postcode(param).or(search_by_service_name(param)).or(search_by_code(param)).distinct }
SCHEME_TYPE = {
- 0 => "Missings",
+ 0 => "Missing",
4 => "Foyer",
5 => "Direct Access Hostel",
6 => "Other Supported Housing",
diff --git a/app/views/schemes/new.html.erb b/app/views/schemes/new.html.erb
new file mode 100644
index 000000000..0778c8c1e
--- /dev/null
+++ b/app/views/schemes/new.html.erb
@@ -0,0 +1,59 @@
+<% content_for :title, "Create a new supported housing scheme" %>
+
+<% content_for :before_content do %>
+ <%= govuk_back_link(
+ text: "Back",
+ href: :back,
+ ) %>
+<% end %>
+
+<%= form_for(@resource, as: :scheme, html: { method: :post }) do |f| %>
+
+
+ <%= f.govuk_error_summary %>
+
+
+ <%= content_for(:title) %>
+
+
+ <%= 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,
+ multiple: false,
+ label: { text: "This scheme contains confidential information" } %>
+
+ <% if current_user.support? %>
+ <% 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 %>
+ <% if @organisation_id %>
+ <% organisation = Organisation.find(@organisation_id) %>
+ <% answer_options = [OpenStruct.new(id: organisation.id, name: organisation.name)] %>
+ <% end %>
+
+ <%= f.govuk_collection_select :organisation_id,
+ answer_options,
+ :id,
+ :name,
+ label: { text: "Which organisation manages this scheme", size: "m" },
+ hint: { text: "Enter organisation name" },
+ options: { disabled: [""], selected: selected_option(answer_options) },
+ "data-controller": %w[accessible-autocomplete conditional-filter] %>
+ <% end %>
+
+ <% roles = current_user.assignable_roles.map { |key, _| OpenStruct.new(id: key, name: key.to_s.humanize) } %>
+
+ <%= f.govuk_collection_radio_buttons :scheme_type,
+ roles,
+ :id,
+ :name,
+ legend: { text: "Role", size: "m" } %>
+
+ <%= f.govuk_submit "Save and continue" %>
+
+
+<% end %>
diff --git a/config/routes.rb b/config/routes.rb
index 01efc2623..5c663bb13 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -35,7 +35,7 @@ Rails.application.routes.draw do
get "edit/password", to: "users#edit_password"
end
- resources :schemes, only: %i[index show] do
+ resources :schemes do
member do
get "locations", to: "schemes#locations"
end