-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1db3ad8
commit 7fda689
Showing
11 changed files
with
222 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
app/controllers/claims/support/gias_school_suggestions_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
class Claims::Support::GiasSchoolSuggestionsController < ApplicationController | ||
def index | ||
gias_schools = GiasSchool.search_scope(query_params) | ||
render json: gias_schools.map { |school| formatted_school(school) } | ||
end | ||
|
||
private | ||
|
||
def query_params | ||
params.require(:query).downcase | ||
end | ||
|
||
def formatted_school(school) | ||
{ | ||
urn: school.urn, | ||
name: school.name, | ||
} | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,30 @@ | ||
class Claims::Support::SchoolsController < Claims::Support::ApplicationController | ||
def new | ||
@school = Claims::School.new | ||
end | ||
|
||
def create | ||
school = gias_school.school || gias_school.build_school | ||
school.claims = true | ||
|
||
if school.save | ||
redirect_to claims_support_schools_path | ||
else | ||
render :new | ||
end | ||
end | ||
|
||
def check | ||
@school = gias_school | ||
end | ||
|
||
private | ||
|
||
def gias_school | ||
@gias_school ||= GiasSchool.find_by_urn(gias_school_urn) | ||
end | ||
|
||
def gias_school_urn | ||
params[:gias_school_urn] || params.dig(:gias_school, :urn) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
import { initAll } from "govuk-frontend"; | ||
import autocompleteSetup from "./autocomplete"; | ||
import accreditedProviderAutocompleteSetup from "./accredited_provider"; | ||
import giasSchoolAutocompleteSetup from "./gias_school_autocomplete"; | ||
|
||
initAll(); | ||
autocompleteSetup(); | ||
accreditedProviderAutocompleteSetup(); | ||
accreditedProviderAutocompleteSetup(); | ||
giasSchoolAutocompleteSetup(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import initAutocomplete from "./autocomplete"; | ||
|
||
const giasSchoolTemplate = (result) => result && result.name; | ||
const giasSchoolSuggestionTemplate = (result) => | ||
result && `${result.name}`; | ||
const onConfirm = (input) => (option) => | ||
(input.value = option ? option.urn : ""); | ||
|
||
function init() { | ||
const options = { | ||
path: `/support/gias_school_suggestions`, | ||
template: { | ||
inputValue: giasSchoolTemplate, | ||
suggestion: giasSchoolSuggestionTemplate, | ||
}, | ||
minLength: 2, | ||
inputName: "gias_school_urn", | ||
onConfirm, | ||
}; | ||
|
||
initAutocomplete( | ||
"gias-school-autocomplete", | ||
"gias-school-search-form-query-field", | ||
options, | ||
); | ||
} | ||
|
||
export default init; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
<%= content_for(:before_content) do %> | ||
<%= govuk_back_link(href: new_claims_support_school_path) %> | ||
<% end %> | ||
|
||
<div class="govuk-grid-row"> | ||
<div class="govuk-grid-column-two-thirds"> | ||
<%= form_with(model: @school, url: claims_support_schools_path, method: "post", data: { turbo: false }) do |f| %> | ||
<%= f.hidden_field :urn, value: @school.urn %> | ||
|
||
<label class="govuk-label govuk-label--l"> | ||
<span class="govuk-caption-l"><%= t(".add_organisation") %></span> | ||
<%= t(".title") %> | ||
</label> | ||
|
||
<dl class="govuk-summary-list"> | ||
<div class="govuk-summary-list__row"> | ||
<dt class="govuk-summary-list__key"> | ||
<%= t(".organisation_name") %> | ||
</dt> | ||
<dd class="govuk-summary-list__value"> | ||
<%= @school.name %> | ||
</dd> | ||
</div> | ||
|
||
<div class="govuk-summary-list__row govuk-summary-list__row--no-actions"> | ||
<dt class="govuk-summary-list__key"> | ||
<%= t(".urn") %> | ||
</dt> | ||
<dd class="govuk-summary-list__value"> | ||
<%= @school.urn %> | ||
</dd> | ||
</div> | ||
</dl> | ||
|
||
<h2 class="govuk-heading-m govuk-!-margin-top-7"> | ||
<%= t(".contact_details") %> | ||
</h2> | ||
<dl class="govuk-summary-list"> | ||
<div class="govuk-summary-list__row govuk-summary-list__row--no-actions"> | ||
<dt class="govuk-summary-list__key"> | ||
<%= t(".telephone") %> | ||
</dt> | ||
<dd class="govuk-summary-list__value"> | ||
<%= @school.telephone %> | ||
</dd> | ||
</div> | ||
|
||
<div class="govuk-summary-list__row govuk-summary-list__row--no-actions"> | ||
<dt class="govuk-summary-list__key"> | ||
<%= t(".website") %> | ||
</dt> | ||
<dd class="govuk-summary-list__value"> | ||
<%= @school.website %> | ||
</dd> | ||
</div> | ||
|
||
<div class="govuk-summary-list__row"> | ||
<dt class="govuk-summary-list__key"> | ||
<%= t(".address") %> | ||
</dt> | ||
<dd class="govuk-summary-list__value"> | ||
<p class="govuk-body"> | ||
<%= @school.address1 %> | ||
<br> | ||
<%= @school.address2 %> | ||
<br> | ||
<%= @school.address3 %> | ||
<br> | ||
<%= @school.town %> | ||
<br> | ||
<%= @school.postcode %> | ||
</p> | ||
</dd> | ||
</div> | ||
</dl> | ||
|
||
<%= f.govuk_submit t(".add_organisation") %> | ||
<p class="govuk-body"> | ||
<%= govuk_link_to(t(".cancel"), claims_support_schools_path) %> | ||
</p> | ||
<% end %> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
Support / Schools | ||
|
||
<%= govuk_button_to(t("add_organisation"), new_claims_support_school_path, method: :get) %> | ||
|
||
<ul> | ||
<li><%= link_to "School 1", claims_support_school_path(1) %></li> | ||
</ul> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<%= content_for(:before_content) do %> | ||
<%= govuk_back_link(href: root_path) %> | ||
<% end %> | ||
|
||
<%= form_with(model: @school, url: check_claims_support_schools_path, method: "get", data: { turbo: false }) do |f| %> | ||
<%= f.govuk_error_summary %> | ||
|
||
<div class="govuk-grid-row"> | ||
<div class="govuk-grid-column-two-thirds"> | ||
<div class="govuk-form-group"> | ||
<%= f.label :query, { class: "govuk-label govuk-label--l", for: "gias-school-search-form-query-field" } do %> | ||
<span class="govuk-caption-l"><%= t(".caption") %></span> | ||
<%= t(".title") %> | ||
<% end %> | ||
|
||
<%= f.text_field :query, | ||
id: "gias-school-search-form-query-field", | ||
value: params[:query], | ||
class: "govuk-input" %> | ||
<div id="gias-school-autocomplete" class="govuk-!-margin-bottom-7"></div> | ||
</div> | ||
|
||
<%= f.govuk_submit t("continue") %> | ||
|
||
<p class="govuk-body"> | ||
<%= govuk_link_to(t("cancel"), root_path) %> | ||
</p> | ||
</div> | ||
</div> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters