Browse Source

SPIKEEEE

pull/671/head
JG 3 years ago
parent
commit
18bb1770f5
  1. 8
      app/controllers/schemes_controller.rb
  2. 2
      app/models/scheme.rb
  3. 59
      app/views/schemes/new.html.erb
  4. 2
      config/routes.rb

8
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

2
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",

59
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| %>
<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’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" %>
</div>
</div>
<% end %>

2
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

Loading…
Cancel
Save