-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #470 from commercekitchen/develop
Nashville custom school program registration
- Loading branch information
Showing
46 changed files
with
728 additions
and
220 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
var schoolsForm = (function () { | ||
function showForm() { | ||
$("#school_fields").show(); | ||
$("#user_acting_as").trigger("change"); | ||
} | ||
|
||
function hideForm() { | ||
$("#school_fields").hide(); | ||
$("#user_student_id").prop("required", false); | ||
} | ||
|
||
function loadSchoolsByType(schoolType) { | ||
$.get("/ajax/schools", { school_type: schoolType }).done(function (data) { | ||
newOptions = data.map(function (obj) { | ||
return [obj.id, obj.school_name]; | ||
}); | ||
|
||
$("#user_school_id").updateDropdown("School", newOptions); | ||
$("#school_fields .hideUntilActive").show(); | ||
}); | ||
} | ||
|
||
function showStudentFields() { | ||
$("#student-only").show(); | ||
} | ||
|
||
function hideStudentFields() { | ||
$("#student-only").hide(); | ||
} | ||
|
||
function makeStudentIdRequired() { | ||
$("#user_student_id").prop("required", true); | ||
} | ||
|
||
function makeStudentIdOptional() { | ||
$("#user_student_id").prop("required", false); | ||
} | ||
|
||
return { | ||
showForm: showForm, | ||
hideForm: hideForm, | ||
loadSchoolsByType: loadSchoolsByType, | ||
showStudentFields: showStudentFields, | ||
hideStudentFields: hideStudentFields, | ||
makeStudentIdRequired: makeStudentIdRequired, | ||
makeStudentIdOptional: makeStudentIdOptional, | ||
}; | ||
})(); | ||
|
||
$(document).ready(function () { | ||
$("#user_acting_as").change(function (e) { | ||
var newRole = $(this).val(); | ||
|
||
if (newRole == "Student") { | ||
schoolsForm.showStudentFields(); | ||
schoolsForm.makeStudentIdRequired(); | ||
} else { | ||
schoolsForm.hideStudentFields(); | ||
schoolsForm.makeStudentIdOptional(); | ||
} | ||
}); | ||
|
||
$("#school_type").change(function () { | ||
var schoolType = $(this).val(); | ||
|
||
if (schoolType !== "") { | ||
$("#school_type option[value='']").remove(); | ||
schoolsForm.loadSchoolsByType(schoolType); | ||
} | ||
}); | ||
}); |
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,5 @@ | ||
.new-school-form { | ||
select { | ||
max-width: 200px; | ||
} | ||
} |
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.