-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LUPEYALPHA-552 - hours-teaching-eligible-subjects page
* Add new form * List all the courses selected in previous steps * Yes/No options * Validation added
- Loading branch information
Showing
22 changed files
with
332 additions
and
140 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
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
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
43 changes: 43 additions & 0 deletions
43
app/forms/journeys/further_education_payments/hours_teaching_eligible_subjects_form.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,43 @@ | ||
module Journeys | ||
module FurtherEducationPayments | ||
class HoursTeachingEligibleSubjectsForm < Form | ||
include CoursesHelper | ||
|
||
attribute :hours_teaching_eligible_subjects, :boolean | ||
|
||
validates :hours_teaching_eligible_subjects, | ||
inclusion: { | ||
in: [true, false], | ||
message: i18n_error_message(:inclusion) | ||
} | ||
|
||
def radio_options | ||
[ | ||
OpenStruct.new(id: true, name: "Yes"), | ||
OpenStruct.new(id: false, name: "No") | ||
] | ||
end | ||
|
||
def courses | ||
ALL_COURSE_FIELDS.map { |course_field| | ||
course_descriptions(course_field) | ||
}.flatten | ||
end | ||
|
||
def save | ||
return false unless valid? | ||
|
||
journey_session.answers.assign_attributes(hours_teaching_eligible_subjects:) | ||
journey_session.save! | ||
end | ||
|
||
private | ||
|
||
def course_descriptions(course_field) | ||
journey_session.answers.send(course_field).map { |course| | ||
course_option_description(course, i18n_form_namespace: course_field).html_safe | ||
} | ||
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
Oops, something went wrong.