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(e&o): add school picker to case creation
Jira: PWNN-1659
- Loading branch information
1 parent
2cf512d
commit 1dde104
Showing
28 changed files
with
726 additions
and
301 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
app/controllers/engagement/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,28 @@ | ||
module Engagement | ||
module CaseRequests | ||
class SchoolPickersController < ApplicationController | ||
def edit | ||
@case_request = CaseRequest.find(params[:id]) | ||
@back_url = params[:source] == "change_link" ? engagement_case_request_path(@case_request) : edit_engagement_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 | ||
@case_request = CaseRequest.find(params[:id]) | ||
@school_picker = @case_request.school_picker(school_urns: form_params[:school_urns].compact_blank) | ||
@school_picker.save! | ||
redirect_to engagement_case_request_path(@case_request) | ||
end | ||
|
||
private | ||
|
||
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
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
12 changes: 12 additions & 0 deletions
12
app/controllers/support/cases/request_details/participating_schools_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,12 @@ | ||
module Support | ||
module Cases | ||
module RequestDetails | ||
class ParticipatingSchoolsController < Cases::ApplicationController | ||
def show | ||
@back_url = support_case_request_details_path | ||
@participating_schools = @current_case.request.selected_schools.map { |s| Support::OrganisationPresenter.new(s) } | ||
end | ||
end | ||
end | ||
end | ||
end |
4 changes: 2 additions & 2 deletions
4
...lers/support/cases/requests_controller.rb → ...pport/cases/request_details_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
12 changes: 0 additions & 12 deletions
12
app/controllers/support/cases/requests/participating_schools_controller.rb
This file was deleted.
Oops, something went wrong.
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,12 @@ | ||
module CaseRequest::SchoolPickable | ||
extend ActiveSupport::Concern | ||
|
||
def school_picker(school_urns: self.school_urns) | ||
CaseRequest::SchoolPicker.new(case_request: self, school_urns:) | ||
end | ||
|
||
def pick_schools(school_urns) | ||
self.school_urns = school_urns | ||
save! | ||
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
class CaseRequest::SchoolPicker | ||
include ActiveModel::Model | ||
|
||
attr_accessor( | ||
:case_request, | ||
:school_urns, | ||
) | ||
|
||
def save! | ||
case_request.pick_schools(school_urns) | ||
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
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
Oops, something went wrong.