Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed birth date on student/edit

Closes #195
  • Loading branch information...
commit f675956ca50be69e289239b97f283f74e8e4f1b5 1 parent cb8cc01
@NathanNeff authored
View
8 grails-app/controllers/org/bworks/bworksdb/StudentController.groovy
@@ -69,6 +69,14 @@ class StudentController {
return
}
}
+ // First, zap birthDate and reformat it.
+ def dateFormat = 'MM/dd/yyyy'
+ def birthDate = params.remove('birthDate')
+
+ try {
+ studentInstance.birthDate = Date.parse(dateFormat, birthDate)
+ } catch (Exception e) {
+ }
studentInstance.properties = params
if(!studentInstance.hasErrors() && studentInstance.save()) {
studentService.saveInterests(studentInstance, params['interestInProgram'])
View
22 grails-app/views/student/edit.gsp
@@ -4,7 +4,25 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta name="layout" content="main" />
- <meta name="tabName" content="student" />
+ <script type="text/javascript" src="${resource(dir:'js', file:'jquery-1.3.2.js')}"></script>
+ <script type="text/javascript" src="${resource(dir:'js', file:'ui.core.js')}"></script>
+ <script type="text/javascript" src="${resource(dir:'js', file:'ui.datepicker.js')}"></script>
+ <script type="text/javascript" src="${resource(dir:'js', file:'date.js')}"></script>
+ <script type="text/javascript">
+ $(document).ready(function(){
+ // Birth Date picker.
+ // We want to display from -110 years ago to today's year.
+ // NOTE: yearRange is relative to defaultDate (hence the -100:+10)
+ $('#birthDate').datepicker({
+ defaultDate: '-10y',
+ yearRange: '-100:+10',
+ changeMonth: true,
+ changeYear: true
+ });
+ });
+
+ </script>
+ <meta name="tabName" content="student" />
<title>Edit Student</title>
</head>
<body>
@@ -43,7 +61,7 @@
<g:set var="existingBday"
value="${fieldValue(bean:studentInstance, field:'birthDate')}" />
- <input type="text" id="newStudentBirthDate"
+ <input type="text" id="birthDate"
name="birthDate"
value="${formatDate(format:'MM/dd/yyyy', date:studentInstance?.birthDate)}"
/>
View
4 grails-app/views/student/show.gsp
@@ -33,7 +33,9 @@
<tr class="prop">
<td valign="top" class="name">Birth Date:</td>
- <td valign="top" class="value">${fieldValue(bean:studentInstance, field:'birthDate')}</td>
+ <td valign="top" class="value">
+ <enrollio:formatDate date="${studentInstance.birthDate}" />
+ </td>
</tr>
View
18 test/functional/StudentFunctionalTests.groovy
@@ -61,6 +61,24 @@ class StudentFunctionalTests extends functionaltestplugin.FunctionalTestCase {
}
+ void testEditStudentBirthDate() {
+ gotoStudentShow()
+ assertStatus 200
+
+ click "Edit"
+ assertStatus 200
+
+ form('editStudentForm') {
+ birthDate = '1/1/2000'
+ click "Save"
+ }
+
+ assertStatus 200
+ assertTitleContains('Student:')
+ assertContentContains('Updated')
+ assertContentContains('January 1, 2000')
+ }
+
void testEditStudentInterests() {
testDataService.deleteIntegrationTestData()
testDataService.loadIntegrationTestData()
Please sign in to comment.
Something went wrong with that request. Please try again.