Changeset 246
- Timestamp:
- Mar 8, 2010, 6:25:07 PM (14 years ago)
- Location:
- trunk/grails-app
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/conf/BaseFilters.groovy
r172 r246 24 24 session.style = 'default_style' 25 25 } 26 27 // set session lifetime to 1 week 28 session.setMaxInactiveInterval(604800) 26 29 } 27 30 } -
trunk/grails-app/conf/BootStrap.groovy
r239 r246 20 20 def init = {servletContext -> 21 21 // define timezone 22 System.setProperty('user.timezone', 'CET') 22 System.setProperty('user.timezone', 'CET') 23 23 24 24 if (GrailsUtil.environment == GrailsApplication.ENV_DEVELOPMENT) { … … 134 134 135 135 def bloodSamplingProtocol = new Protocol( 136 name: ' Liversampling'136 name: 'Blood sampling' 137 137 ).with { if (!validate()) { errors.each { println it} } else save()} 138 138 -
trunk/grails-app/controllers/dbnp/studycapturing/WizardController.groovy
r240 r246 91 91 } 92 92 on("switchTemplate") { 93 println "switching template..."94 println params95 93 this.handleStudy(flow, flash, params) 96 94 }.to "study" … … 159 157 }.to "subjects" 160 158 on("next") { 161 println flow.subjectTemplates162 println flow.subjects163 159 flash.errors = new LinkedHashMap() 164 160 … … 200 196 // fetch classification by name (as posted by the form) 201 197 //params.classification = Term.findByName(params.classification) 198 199 // fetch protocol by name (as posted by the form) 200 params.protocol = Protocol.findByName(params.protocol) 202 201 203 202 // transform checkbox form value to boolean … … 452 451 453 452 // if a template is selected, get template instance 454 if (params.get('template')) { 455 params.template = Template.findByName(params.get('template')) 453 def template = params.remove('template') 454 if (template instanceof String && template.size() > 0) { 455 params.template = Template.findByName(template) 456 } else if (template instanceof Template) { 457 params.template = template 456 458 } 457 459 … … 489 491 it.name = params.get('eventDescription_' + id + '_name') 490 492 it.description = params.get('eventDescription_' + id + '_description') 493 it.protocol = Protocol.findByName(params.get('eventDescription_' + id + '_protocol')) 491 494 //it.classification = Term.findByName(params.get('eventDescription_' + id + '_classification')) 492 495 it.isSamplingEvent = (params.containsKey('eventDescription_' + id + '_isSamplingEvent')) -
trunk/grails-app/domain/dbnp/studycapturing/Protocol.groovy
r190 r246 22 22 reference(nullable: true, blank: true) 23 23 } 24 25 /** 26 * overloaded toString method 27 * @return String 28 */ 29 def String toString() { 30 return this.name; 31 } 24 32 } -
trunk/grails-app/domain/dbnp/studycapturing/Study.groovy
r236 r246 41 41 owner(nullable: true, blank: true) 42 42 title(nullable: false, blank: false) 43 template(nullable: true, blank: true)43 template(nullable: false, blank: false) 44 44 } 45 45 -
trunk/grails-app/taglib/dbnp/studycapturing/WizardTagLib.groovy
r240 r246 46 46 * @param Closure body 47 47 */ 48 def ajaxButton = { 48 def ajaxButton = {attrs, body -> 49 49 // get the jQuery version 50 50 def jQueryVersion = grailsApplication.getMetadata()['plugins.jquery'] … … 87 87 button = button.replaceFirst(/data\:jQuery/, "data:\'_eventId_${elementName}=1&\'+jQuery") 88 88 } 89 89 90 90 // add an after success function call? 91 91 // usefull for performing actions on success data (hence on refreshed … … 106 106 // replace double semi colons 107 107 button = button.replaceAll(/;{2,}/, ';') 108 108 109 109 // render button 110 110 out << button … … 116 116 * @see WizardTagLib::baseElement (ajaxSubmitOnChange) 117 117 */ 118 def ajaxSubmitJs = { 118 def ajaxSubmitJs = {attrs, body -> 119 119 // define AJAX provider 120 120 setProvider([library: ajaxProvider]) … … 130 130 131 131 // strip the button part to only leave the Ajax call 132 button = button.replaceFirst(/<[^\"]*\"jQuery.ajax/, 'jQuery.ajax')133 button = button.replaceFirst(/return false.*/, '')132 button = button.replaceFirst(/<[^\"]*\"jQuery.ajax/, 'jQuery.ajax') 133 button = button.replaceFirst(/return false.*/, '') 134 134 135 135 // change form if a form attribute is present … … 166 166 * Example initial webflow action to work with this javascript: 167 167 * ... 168 * mainPage { 169 * render(view: "/wizard/index") 170 * onRender { 171 * flow.page = 1 172 * } 173 * on("next").to "pageOne" 174 * } 175 * ... 168 * mainPage {* render(view: "/wizard/index") 169 * onRender {* flow.page = 1 170 *}* on("next").to "pageOne" 171 *}* ... 176 172 * 177 173 * @param Map attributes 178 174 * @param Closure body 179 175 */ 180 def ajaxFlowRedirect = { 176 def ajaxFlowRedirect = {attrs, body -> 181 177 // generate javascript 182 178 out << '<script type="text/javascript">' … … 207 203 /** 208 204 * generate a base form element 209 * @param String 210 * @param Map 211 * @param Closure 212 */ 213 def baseElement = { 205 * @param String inputElement name 206 * @param Map attributes 207 * @param Closure help content 208 */ 209 def baseElement = {inputElement, attrs, help -> 214 210 // work variables 215 211 def description = attrs.remove('description') 216 212 def addExampleElement = attrs.remove('addExampleElement') 217 def addExample2Element 213 def addExample2Element = attrs.remove('addExample2Element') 218 214 219 215 // got an ajax onchange action? … … 247 243 out << ' <div class="input">' 248 244 out << renderedElement 249 if (help()) {245 if (help()) { 250 246 out << ' <div class="helpIcon"></div>' 251 247 } … … 255 251 if (addExampleElement) { 256 252 def exampleAttrs = new LinkedHashMap() 257 exampleAttrs.name = attrs.get('name') +'Example'258 exampleAttrs.class 253 exampleAttrs.name = attrs.get('name') + 'Example' 254 exampleAttrs.class = 'isExample' 259 255 exampleAttrs.disabled = 'disabled' 260 256 exampleAttrs.size = 30 … … 266 262 if (addExample2Element) { 267 263 def exampleAttrs = new LinkedHashMap() 268 exampleAttrs.name = attrs.get('name') +'Example2'269 exampleAttrs.class 264 exampleAttrs.name = attrs.get('name') + 'Example2' 265 exampleAttrs.class = 'isExample' 270 266 exampleAttrs.disabled = 'disabled' 271 267 exampleAttrs.size = 30 … … 290 286 * @param Closure body (help text) 291 287 */ 292 def textFieldElement = { 288 def textFieldElement = {attrs, body -> 293 289 // set default size, or scale to max length if it is less than the default size 294 290 if (!attrs.get("size")) { … … 308 304 } 309 305 310 311 306 /** 312 307 * render a select form element … … 314 309 * @param Closure body (help text) 315 310 */ 316 def selectElement = { 311 def selectElement = {attrs, body -> 317 312 baseElement.call( 318 313 'select', … … 327 322 * @param Closure body (help text) 328 323 */ 329 def checkBoxElement = { 324 def checkBoxElement = {attrs, body -> 330 325 baseElement.call( 331 326 'checkBox', … … 341 336 * @param Closure body (help text) 342 337 */ 343 def dateElement = { 338 def dateElement = {attrs, body -> 344 339 // transform value? 345 340 if (attrs.value instanceof Date) { … … 347 342 attrs.value = String.format('%td/%<tm/%<tY', attrs.value) 348 343 } 349 344 350 345 // set some textfield values 351 346 attrs.maxlength = (attrs.maxlength) ? attrs.maxlength : 10 352 347 attrs.addExampleElement = true 353 348 354 349 // render a normal text field 355 350 //out << textFieldElement(attrs,body) … … 366 361 * @param Closure body (help text) 367 362 */ 368 def timeElement = { 363 def timeElement = {attrs, body -> 369 364 // transform value? 370 365 if (attrs.value instanceof Date) { … … 384 379 ) 385 380 } 386 381 387 382 /** 388 383 * Template form element 389 * @param Map 390 * @param Closure 391 */ 392 def speciesElement = { 384 * @param Map attributes 385 * @param Closure help content 386 */ 387 def speciesElement = {attrs, body -> 393 388 // render template element 394 389 baseElement.call( … … 401 396 /** 402 397 * Button form element 403 * @param Map 404 * @param Closure 405 */ 406 def buttonElement = { 398 * @param Map attributes 399 * @param Closure help content 400 */ 401 def buttonElement = {attrs, body -> 407 402 // render template element 408 403 baseElement.call( … … 417 412 * @param Map attrs 418 413 */ 419 def speciesSelect = { 414 def speciesSelect = {attrs -> 420 415 // fetch the speciesOntology 421 416 // note that this is a bit nasty, probably the ontologyName should … … 437 432 /** 438 433 * Template form element 439 * @param Map 440 * @param Closure 441 */ 442 def templateElement = { 434 * @param Map attributes 435 * @param Closure help content 436 */ 437 def templateElement = {attrs, body -> 443 438 // render template element 444 439 baseElement.call( … … 448 443 ) 449 444 } 450 445 451 446 /** 452 447 * render a template select element 453 448 * @param Map attrs 454 449 */ 455 def templateSelect = { 450 def templateSelect = {attrs -> 456 451 def entity = attrs.remove('entity') 457 452 458 453 // fetch templates 459 attrs.from = (entity) ? Template.findAllByEntity(entity) : Template.findAll() 454 if (attrs.remove('addDummy')) { 455 attrs.from = [''] 456 if (entity && entity instanceof Class) { 457 Template.findAllByEntity(entity).each() { 458 attrs.from[attrs.from.size()] = it 459 } 460 } 461 } else { 462 attrs.from = (entity) ? Template.findAllByEntity(entity) : Template.findAll() 463 } 460 464 461 465 // got a name? … … 465 469 466 470 // got result? 467 if (attrs.from.size() > 0) {471 if (attrs.from.size() > 0) { 468 472 out << select(attrs) 469 473 } else { … … 476 480 /** 477 481 * Term form element 478 * @param Map 479 * @param Closure 480 */ 481 def termElement = { 482 * @param Map attributes 483 * @param Closure help content 484 */ 485 def termElement = {attrs, body -> 482 486 // render term element 483 487 baseElement.call( … … 492 496 * @param Map attrs 493 497 */ 494 def termSelect = { 498 def termSelect = {attrs -> 495 499 // fetch all terms 496 500 attrs.from = Term.findAll() // for now, all terms as we cannot identify terms as being treatment terms... … … 504 508 } 505 509 506 def show = { attrs -> 510 /** 511 * Protocol form element 512 * @param Map attributes 513 * @param Closure help content 514 */ 515 def protocolElement = {attrs, body -> 516 // render protocol element 517 baseElement.call( 518 'protocolSelect', 519 attrs, 520 body 521 ) 522 } 523 524 /** 525 * render a protocol select element 526 * @param Map attrs 527 */ 528 def protocolSelect = {attrs -> 529 // fetch all protocold 530 attrs.from = Protocol.findAll() // for now, all protocols 531 532 // got a name? 533 if (!attrs.name) { 534 attrs.name = 'protocol' 535 } 536 537 out << select(attrs) 538 } 539 540 def show = {attrs -> 507 541 // is object parameter set? 508 542 def o = attrs.object … … 520 554 * @param Map attributes 521 555 */ 522 def templateColumnHeaders = { 556 def templateColumnHeaders = {attrs -> 523 557 def template = attrs.remove('template') 524 558 … … 533 567 * @param Map attributes 534 568 */ 535 def templateColumns = { 536 def subject 537 def subjectId 538 def template 539 def intFields 540 def stringFields 541 def floatFields 542 def termFields 569 def templateColumns = {attrs, body -> 570 def subject = attrs.remove('subject') 571 def subjectId = attrs.remove('id') 572 def template = attrs.remove('template') 573 def intFields = subject.templateIntegerFields 574 def stringFields = subject.templateStringFields 575 def floatFields = subject.templateFloatFields 576 def termFields = subject.templateTermFields 543 577 544 578 // output columns for these subjectFields … … 555 589 from: it.listEntries, 556 590 value: (stringFields) ? stringFields.get(it.name) : '' 557 ) 591 ) 558 592 } else { 559 593 out << '<span class="warning">no values!!</span>' … … 576 610 default: 577 611 // unsupported field type 578 out << '<span class="warning">!' +it.type+'</span>'612 out << '<span class="warning">!' + it.type + '</span>' 579 613 //out << subject.getFieldValue(it.name) 580 614 break; … … 584 618 } 585 619 } 620 621 /** 622 * render form elements based on an entity's template 623 * @param Map attributes 624 * @param String body 625 */ 626 def templateElements = {attrs -> 627 def entity = (attrs.get('entity')) 628 def template = (entity && entity instanceof TemplateEntity) ? entity.template : null 629 630 // got a template? 631 if (template) { 632 // render template fields 633 template.fields.each() { 634 switch (it.type) { 635 case 'STRINGLIST': 636 if (!it.listEntries.isEmpty()) { 637 out << selectElement( 638 description: it.name, 639 name: it.name, 640 from: it.listEntries, 641 value: attrs 642 ) 643 } else { 644 out << '<span class="warning">no values!!</span>' 645 } 646 break 647 case 'STRING': 648 out << textFieldElement( 649 description: it.name, 650 name: it.name 651 ) 652 break 653 case 'DATE': 654 out << dateElement( 655 description: it.name, 656 name: it.name 657 ) 658 break 659 case 'INTEGER': 660 out << textFieldElement( 661 description: it.name, 662 name: it.name 663 ) 664 break 665 case 'DOUBLE': 666 out << textFieldElement( 667 description: it.name, 668 name: it.name 669 ) 670 break 671 default: 672 out << "unkown field type '" + it.type + "'<br/>" 673 break 674 } 675 } 676 } 677 } 586 678 } -
trunk/grails-app/views/wizard/pages/_eventDescriptions.gsp
r238 r246 23 23 </span> 24 24 25 <span class="info">26 <span class="title">Note!</span>27 Currently 'classification' display all terms because there is no way to machine interpret28 the different values. So please -for now- make sure to pick the Ontology reference applicable for29 events until this particular challenge is solved.30 </span>31 32 25 <wizard:textFieldElement name="name" description="Name" error="name" value="${values?.name}"> 33 26 The name of the event description you are creating … … 36 29 A short description summarizing your event description 37 30 </wizard:textFieldElement> 31 <wizard:protocolElement name="protocol" description="Protocol" error="protocol" value="${values?.protocol}" > 32 Select the protocol for this event description 33 </wizard:protocolElement> 38 34 <wizard:checkBoxElement name="isSamplingEvent" description="Sampling event" error="isSamplingEvent" value="${values?.isSamplingEvent}"> 39 35 Is this a sampling event description? … … 47 43 <div class="column">name</div> 48 44 <div class="column">description</div> 45 <div class="column">protocol</div> 49 46 <div class="column">sampling event</div> 50 47 <div class="column">protocol</div> … … 58 55 <div class="column"><g:textField name="eventDescription_${i}_name" value="${eventDescription.name}" size="12" maxlength="12" /></div> 59 56 <div class="column"><g:textField name="eventDescription_${i}_description" value="${eventDescription.description}" size="12" maxlength="12" /></div> 57 <div class="column"><wizard:protocolSelect name="eventDescription_${i}_protocol" value="${eventDescription.protocol}" /></div> 60 58 <div class="column"><g:checkBox name="eventDescription_${i}_isSamplingEvent" value="${eventDescription.isSamplingEvent}" /></div> 61 59 <div class="column"><g:if test="${eventDescription.protocol}">${eventDescription.protocol}</g:if><g:else>-</g:else></div> -
trunk/grails-app/views/wizard/pages/_study.gsp
r240 r246 21 21 </span> 22 22 23 <wizard:templateElement name="template" description="Template" value="${study?.template}" entity="${dbnp.studycapturing.S ubject}" ajaxOnChange="switchTemplate" url="[controller:'wizard',action:'pages']" update="[success:'wizardPage',failure:'wizardError']" afterSuccess="onWizardPage()" >23 <wizard:templateElement name="template" description="Template" value="${study?.template}" entity="${dbnp.studycapturing.Study}" addDummy="true" ajaxOnChange="switchTemplate" url="[controller:'wizard',action:'pages']" update="[success:'wizardPage',failure:'wizardError']" afterSuccess="onWizardPage()" > 24 24 The template to use for this study 25 25 </wizard:templateElement> … … 45 45 <span class="info"> 46 46 <span class="title">TODO</span> 47 This page should also contain the template fields of the study template selected above (if available). This is48 scheduled for implementation in a later version47 Below you will see the template fields of the study template selected above. These fields are not yet 48 properly handled so you can ignore them for now... To be completed at a later stage 49 49 </span> 50 50 51 <wizard:templateElements entity="${study}" /> 52 51 53 </wizard:pageContent>
Note: See TracChangeset
for help on using the changeset viewer.