generated from dxw/rails-template
-
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.
feat(cms): add school picker to case creation
Jira: PWNN-1659
- Loading branch information
1 parent
1f7f064
commit 25e2df4
Showing
4 changed files
with
56 additions
and
1 deletion.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
app/controllers/support/case_requests/school_pickers_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,32 @@ | ||
module Support | ||
module CaseRequests | ||
class SchoolPickersController < ApplicationController | ||
before_action :case_request, only: %i[edit update] | ||
|
||
def edit | ||
@back_url = params[:source] == "change_link" ? support_case_request_path(@case_request) : edit_support_case_request_path(@case_request) | ||
@school_picker = @case_request.school_picker | ||
@group = @case_request.organisation | ||
@all_schools = @group.organisations.order(:name) | ||
@filters = @all_schools.filtering(form_params[:filters] || {}) | ||
@filtered_schools = @filters.results.map { |s| Support::OrganisationPresenter.new(s) } | ||
end | ||
|
||
def update | ||
@school_picker = @case_request.school_picker(school_urns: form_params[:school_urns].compact_blank.excluding("all")) | ||
@school_picker.save! | ||
redirect_to support_case_request_path(@case_request) | ||
end | ||
|
||
private | ||
|
||
def case_request | ||
@case_request = CaseRequest.find_by(id: params[:id]) | ||
end | ||
|
||
def form_params | ||
params.fetch(:case_request, {}).permit(filters: params.key?(:clear) ? nil : { local_authorities: [], phases: [] }, school_urns: []) | ||
end | ||
end | ||
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
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,9 @@ | ||
<h1 class="govuk-heading-l"><%= I18n.t("support.case_hub_migration.school_picker.title") %></h1> | ||
|
||
<%= render "components/school_picker/school_picker", | ||
results_model: @school_picker, | ||
filters_model: @filters, | ||
scope: :case_request, | ||
update_url: support_case_request_school_picker_path(@case_request), | ||
filters_url: edit_support_case_request_school_picker_path(@case_request), | ||
method: :patch %> |
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