Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Quick-enroll from contact/show

  • Loading branch information...
commit 7097045c14a7fa7ff6e82dc5a3381e81e63b41fc 1 parent c71e121
@NathanNeff authored
View
1  grails-app/conf/UrlMappings.groovy
@@ -51,6 +51,7 @@ class UrlMappings {
"/loadDataRequest"(controller:'configSetting', action:'loadDataRequest')
"/saveEnrollments"(controller: 'course', action: 'saveEnrollments')
"/enrollmentForm/$id"(controller: 'course', action: 'enrollmentForm')
+ "/quickEnroll"(controller:'classSession', action:'quickEnroll')
// userSetting controller
'/userSettings'(controller: 'userSetting', action: 'list')
View
9 grails-app/controllers/org/bworks/bworksdb/ClassSessionController.groovy
@@ -443,5 +443,14 @@ class ClassSessionController {
}
}
+ def quickEnroll = {
+ def classSessionInstanceList = classSessionService.nearClassSessions()
+
+ def model = [ classSessionInstanceList : classSessionInstanceList,
+ studentId : params.studentId ]
+
+ render(view:'/course/enrollmentForm', model: model)
+ }
+
}
View
4 grails-app/services/org/bworks/bworksdb/ClassSessionService.groovy
@@ -216,6 +216,10 @@ class ClassSessionService {
}
+ // retrieve class sessions starting after [Date]
+ def nearClassSessions(startDate = new Date() - 30) {
+ ClassSession.findAllByStartDateGreaterThan(startDate)
+ }
}
View
9 grails-app/taglib/EnrollioTagLib.groovy
@@ -31,6 +31,15 @@ class EnrollioTagLib {
return formattedFieldName
}
+ def classSessionCheckbox = { attrs ->
+ def cs = attrs['classSession']
+ def studentId = attrs['studentId']
+ out << g.checkBox(id:"enrollInSession${cs.id}",
+ name:"classSessions[${cs.id}]",
+ class:"enrollStudent",
+ value: cs.enrollments.find { it.student.id.toString() == studentId.toString() })
+ }
+
def contactStudentList = { attrs ->
def c = attrs['contact']
out << c.students.collect {
View
34 grails-app/views/contact/show.gsp
@@ -32,6 +32,38 @@
$("#moreNotes").toggle();
return false;
});
+
+ var url = "${createLink(action:'quickEnroll', controller:'classSession')}";
+ $('.enrollStudent').click(function() {
+ var studentId = $(this).attr('data-student-id')
+ // populate enrollmentform
+ $.get(url, { studentId : studentId } , function(data) {
+ $('#dialog-form').html(data);
+ });
+ $( "#dialog-form" ).dialog({
+ title : 'Quick Enroll: ' + $(this).attr('data-student-name'),
+ position : 'center',
+ height: 300,
+ width: 350,
+ modal: true,
+ buttons: {
+ "Save": function() {
+ // hack an ajax call by using the form's action
+ var action = $(this).children('form').attr('action');
+ var formData = $(this).children('form').serialize();
+ $.post(action, formData, function(resultData) {
+ $("#studentEnrollmentData" + studentId).html(resultData)
+ });
+ $(this).dialog( "close" );
+ },
+ Cancel: function() {
+ $( this ).dialog( "close" );
+ }
+ }
+ });
+ return false;
+ });
+
});
</script>
@@ -127,5 +159,7 @@
</div>
</g:form>
</div>
+ <div id="dialog-form" ></div>
+
</body>
</html>
View
10 grails-app/views/course/enrollmentForm.gsp
@@ -1,12 +1,10 @@
<g:form action="saveEnrollments" controller="course">
-<g:hiddenField name="studentId" value="${studentInstance.id}" />
+<g:hiddenField name="studentId" value="${studentId}" />
<g:each var="classSession" in="${classSessionInstanceList}">
<div class="field">
-<label for="classSession${classSession.id}">${classSession.name} <enrollio:formatDate date="${classSession.startDate}" /></label>
-<g:checkBox id="enrollInSession${classSession.id}"
- name="classSessions[${classSession.id}]"
- class="enrollStudent"
- value="${classSession.enrollments.find { it.student.id == studentInstance.id }}" />
+ <label for="classSession${classSession.id}">${classSession.course.name}: ${classSession.name}</label>
+ <enrollio:classSessionCheckbox studentId="${studentId}"
+ classSession="${classSession}" />
</div>
</g:each>
</g:form>
Please sign in to comment.
Something went wrong with that request. Please try again.