Changeset 275
- Timestamp:
- Mar 17, 2010, 12:35:31 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/controllers/dbnp/studycapturing/WizardController.groovy
r260 r275 10 10 * The wizard controller handles the handeling of pages and data flow 11 11 * through the study capturing wizard. 12 * 13 * TODO: refactor the 'handle*' methods to work as subflows instead 14 * of methods outside of the flow 12 15 * 13 16 * @author Jeroen Wesbeek … … 160 163 }.to "subjects" 161 164 on("next") { 162 println params163 165 flash.errors = [:] 164 166 … … 175 177 } 176 178 }.to "eventDescriptions" 179 on("delete") { 180 flash.errors = [:] 181 def delete = params.get('do') as int; 182 183 // remove subject 184 if (flow.subjects[ delete ] && flow.subjects[ delete ] instanceof Subject) { 185 flow.subjectTemplates.each() { templateName, templateData -> 186 templateData.subjects.remove(delete) 187 } 188 189 flow.subjects.remove( delete ) 190 } 191 }.to "subjects" 177 192 on("previous") { 178 193 flash.errors = [:] … … 306 321 307 322 // instantiate Event with parameters 308 def event = new Event(params)323 def event = (params.eventDescription.isSamplingEvent) ? new SamplingEvent(params) : new Event(params) 309 324 310 325 // handle event groupings … … 392 407 on("next") { 393 408 flash.values = params 394 395 409 flash.errors = [:] 396 410 … … 417 431 on("toSubjects").to "subjects" 418 432 on("toEvents").to "events" 419 on("previous") { 420 // do nothing 421 }.to "events" 422 on("next") { 423 // store everything in the database! 433 on("previous").to "events" 434 on("next").to "save" 435 } 436 437 // store all study data 438 save { 439 action { 440 println "saving..." 441 flash.errors = [:] 442 443 // start transaction 444 def transaction = sessionFactory.getCurrentSession().beginTransaction() 445 446 // persist data to the database 447 try { 448 // save EventDescriptions 449 flow.eventDescriptions.each() { 450 if (!it.validate() || !it.save()) { 451 this.appendErrors(it, flash.errors) 452 throw new Exception('error saving eventDescription') 453 } 454 println "saved eventdescription "+it 455 } 456 457 // save events 458 flow.events.each() { 459 if (!it.validate() || !it.save()) { 460 this.appendErrors(it, flash.errors) 461 throw new Exception('error saving event') 462 } 463 println "saved event "+it 464 465 // add to study 466 if (it instanceof SamplingEvent) { 467 flow.study.addToSamplingEvents(it) 468 } else { 469 flow.study.addToEvents(it) 470 } 471 } 472 473 // save eventGroups 474 flow.eventGroups.each() { 475 if (!it.validate() || !it.save()) { 476 this.appendErrors(it, flash.errors) 477 throw new Exception('error saving eventGroup') 478 } 479 println "saved eventGroup "+it 480 481 // add to study 482 flow.study.addToEventGroups(it) 483 } 484 485 // save subjects 486 flow.subjects.each() { 487 if (!it.validate() || !it.save()) { 488 this.appendErrors(it, flash.errors) 489 throw new Exception('error saving subject') 490 } 491 println "saved subject "+it 492 493 // add this subject to the study 494 flow.study.addToSubjects(it) 495 } 496 497 // save study 498 if (!flow.study.validate() || !flow.study.save()) { 499 this.appendErrors(flow.study, flash.errors) 500 throw new Exception('error saving study') 501 } 502 println "saved study "+flow.study+" (id: "+flow.study.id+")" 503 504 } catch (Exception e) { 505 // rollback 506 println "rollback" 507 transaction.rollback() 508 error() 509 } 510 511 // commit transaction 512 println "commit" 513 transaction.commit() 424 514 success() 425 }.to "confirm" 515 } 516 on("error").to "error" 517 on(Exception).to "error" 518 on("success").to "done" 519 } 520 521 // error storing data 522 error { 523 render(view: "_error") 524 onRender { 525 flow.page = 6 526 } 527 on("next").to "save" 528 on("previous").to "events" 426 529 } 427 530 … … 430 533 render(view: "_done") 431 534 onRender { 432 flow.page = 6535 flow.page = 7 433 536 } 434 537 on("previous") { -
trunk/grails-app/views/wizard/pages/_done.gsp
r262 r275 16 16 %> 17 17 <wizard:pageContent> 18 You are done!19 18 20 19 <span class="info"> 21 <span class="todo">TODO</span> 22 <ul> 23 <li>persist the data to the database :) nothing is currently being saved...</li> 24 </ul> 20 <span class="todo">Finished!</span> 21 The study you have just created has been properly saved. 25 22 </span> 23 26 24 </wizard:pageContent> -
trunk/grails-app/views/wizard/pages/_eventDescriptions.gsp
r262 r275 45 45 <div class="column">protocol</div> 46 46 <div class="column">sampling event</div> 47 <div class="column">protocol</div>48 47 </div> 49 48 <g:each var="eventDescription" status="i" in="${eventDescriptions}"> … … 57 56 <div class="column"><wizard:protocolSelect name="eventDescription_${i}_protocol" value="${eventDescription.protocol}" /></div> 58 57 <div class="column"><g:checkBox name="eventDescription_${i}_isSamplingEvent" value="${eventDescription.isSamplingEvent}" /></div> 59 <div class="column"><g:if test="${eventDescription.protocol}">${eventDescription.protocol}</g:if><g:else>-</g:else></div>60 58 </div> 61 59 </g:each> -
trunk/grails-app/views/wizard/pages/_events.gsp
r262 r275 79 79 </div> 80 80 <div class="sliderContainer"> 81 <div class="slider" />81 <div class="slider"></div> 82 82 </div> 83 83 </g:if> 84 84 85 <span class="info"> 86 <span class="todo">TODO</span> 87 <ul> 88 <li>parameter values should still be asked and implemented</li> 89 </ul> 90 </span> 85 <span class="info"> 86 <span class="todo">TODO</span> 87 <ul> 88 <li>parameter values should still be asked and implemented</li> 89 </ul> 90 </span> 91 91 92 </wizard:pageContent> -
trunk/grails-app/views/wizard/pages/_subjects.gsp
r262 r275 19 19 <span class="title">Add subjects to your study</span> 20 20 In this screen you can add subjects to your study based on a given template. Note that the 'species' select will probably 21 move to the template as an ontology reference and will not be asked anymore. 21 move to the template as an ontology reference and will not be asked anymore.<br/> 22 <i>Note that you can edit multiple subjects at once by selecting multpiple rows by either ctrl-clicking them or dragging a selection over them.</i> 22 23 </span> 23 24 … … 36 37 <div class="header"> 37 38 <div class="firstColumn">#</div> 39 <div class="firstColumn"></div> 38 40 <div class="column">name</div> 39 41 <div class="column">species</div> … … 42 44 <g:each var="subjectId" in="${subjectTemplate.getValue().subjects}"> 43 45 <div class="row"> 44 <div class="firstColumn">${subjectId}</div> 46 <div class="firstColumn">${subjectId + 1}</div> 47 <div class="firstColumn"> 48 <wizard:ajaxButton name="delete" src="../images/icons/famfamfam/delete.png" alt="delete this subject" class="famfamfam" value="-" url="[controller:'wizard',action:'pages']" update="[success:'wizardPage',failure:'wizardError']" before="\$(\'input[name=do]\').val(${subjectId});" afterSuccess="onWizardPage()" /> 49 </div> 45 50 <div class="column"><g:textField name="subject_${subjectId}_name" value="${subjects[ subjectId ].name}" size="12" maxlength="12" /></div> 46 51 <div class="column"> -
trunk/web-app/js/wizard.js
r260 r275 143 143 $('div#wizard').find("input[type=text][rel$='date']").each(function() { 144 144 $(this).datepicker({ 145 changeMonth : true, 146 changeYear : true, 145 147 dateFormat : 'dd/mm/yy', 146 148 altField : '#' + $(this).attr('name') + 'Example', … … 154 156 $('div#wizard').find("input[type=text][rel$='datetime']").each(function() { 155 157 $(this).datepicker({ 158 changeMonth : true, 159 changeYear : true, 156 160 dateFormat : 'dd/mm/yy', 157 161 altField : '#' + $(this).attr('name') + 'Example',
Note: See TracChangeset
for help on using the changeset viewer.