Changeset 257
- Timestamp:
- Mar 11, 2010, 2:23:53 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/controllers/dbnp/studycapturing/WizardController.groovy
r252 r257 586 586 def value = params.get('subject_' + subjectId + '_' + subjectField.name) 587 587 588 if (value) flow.subjects[ subjectId ].setFieldValue(subjectField.name, value) 588 if (value) { 589 flow.subjects[ subjectId ].setFieldValue(subjectField.name, value) 590 } 589 591 } 590 592 -
trunk/grails-app/domain/dbnp/studycapturing/TemplateEntity.groovy
r247 r257 90 90 } 91 91 else { 92 TemplateField field = this.template.fields.find { it.name == fieldName} 92 TemplateField field = this.template.fields.find { it.name == fieldName} 93 93 if (field == null) { 94 94 throw new NoSuchFieldException("Field ${fieldName} not found in class properties or template fields") … … 99 99 value = field.listEntries.find { it.name == value } 100 100 } 101 102 // handle string values for date fields 103 if (field.type == TemplateFieldType.DATE && value.class == String) { 104 // a string was given, attempt to transform it into a date instance 105 // and -for now- assume the dd/mm/yyyy format 106 def dateMatch = value =~ /^([0-9]{1,})([^0-9]{1,})([0-9]{1,})([^0-9]{1,})([0-9]{1,})((([^0-9]{1,})([0-9]{1,2}):([0-9]{1,2})){0,})/ 107 if (dateMatch.matches()) { 108 // create limited 'autosensing' datetime parser 109 // assume dd mm yyyy or dd mm yy 110 def parser = 'd' + dateMatch[0][2] + 'M' + dateMatch[0][4] + (((dateMatch[0][5] as int) > 999) ? 'yyyy' : 'yy') 111 112 // add time as well? 113 if (dateMatch[0][7] != null) { 114 parser += dateMatch[0][6] + 'HH:mm' 115 } 116 117 value = new Date().parse(parser, value) 118 } 119 } 120 101 121 // Caution: this assumes that all template...Field Maps are already initialized 102 122 // Otherwise, the results are pretty much unpredictable! -
trunk/grails-app/taglib/dbnp/studycapturing/WizardTagLib.groovy
r250 r257 584 584 // output columns for these subjectFields 585 585 template.fields.each() { 586 def fieldValue = subject.getFieldValue(it.name) 587 586 588 // output div 587 589 out << '<div class="' + attrs.get('class') + '">' 588 590 591 // handle field types 589 592 switch (it.type.toString()) { 590 593 case ['STRING', 'TEXT', 'INTEGER', 'FLOAT', 'DOUBLE']: 591 594 out << textField( 592 595 name: attrs.name + '_' + it.name, 593 value: (intFields) ? intFields.get(it.name) : ''596 value: fieldValue 594 597 ) 595 598 break … … 600 603 name: attrs.name + '_' + it.name, 601 604 from: it.listEntries, 602 value: (stringFields) ? stringFields.get(it.name) : ''605 value: fieldValue 603 606 ) 604 607 } else { … … 606 609 } 607 610 break 611 case 'DATE': 612 // transform value? 613 if (fieldValue instanceof Date) { 614 if (fieldValue.getHours() == 0 && fieldValue.getMinutes() == 0) { 615 // transform date instance to formatted string (dd/mm/yyyy) 616 fieldValue = String.format('%td/%<tm/%<tY', fieldValue) 617 } else { 618 // transform to date + time 619 fieldValue = String.format('%td/%<tm/%<tY %<tH:%<tM', fieldValue) 620 } 621 } 622 623 // output a date field (not the 'rel' which makes the 624 // javascript front-end bind the jquery-ui datepicker) 625 out << textField( 626 name: attrs.name + '_' + it.name, 627 value: fieldValue, 628 rel: 'date' 629 ) 630 break 631 case 'ONTOLOGYTERM': 632 out << it.getClass() 633 break 608 634 default: 609 635 // unsupported field type 610 636 out << '<span class="warning">!' + it.type + '</span>' 611 //out << subject.getFieldValue(it.name) 612 break; 637 break 613 638 } 614 639 -
trunk/grails-app/views/wizard/index.gsp
r247 r257 22 22 <script type="text/javascript" src="${resource(dir: 'js', file: 'jquery.qtip-1.0.0-rc3.min.js')}"></script> 23 23 <script type="text/javascript" src="${resource(dir: 'js', file: 'swfobject.js')}"></script> 24 <script type="text/javascript" src="${resource(dir: 'js', file: 'grouping.js')}"></script>25 24 <script type="text/javascript" src="${resource(dir: 'js', file: 'table-editor.js')}"></script> 26 25 <script type="text/javascript" src="${resource(dir: 'js', file: 'timepicker-0.2.1.js')}"></script> 27 26 <script type="text/javascript" src="${resource(dir: 'js', file: 'wizard.js')}"></script> 27 <script type="text/javascript" src="http://bioportal.bioontology.org/javascripts/widgets/form_complete.js"></script> 28 28 </head> 29 29 <body> -
trunk/web-app/js/wizard.js
r250 r257 55 55 var re = /^#/gi; 56 56 57 // bind to the anchor? 57 58 if (!element.attr('href').match(/^#/gi) && !element.attr('href').match(/\/([^\/]+)\/wizard\/pages/gi)) { 58 59 // bind a warning to the onclick event 59 element.bind('click',function() { 60 return confirm('Warning: navigating away from the wizard causes loss of work and unsaved data. Are you sure you want to continue?'); 61 }) 60 element.bind('click',function() { return onDirectWarning(); }); 62 61 } 63 62 }) 63 } 64 65 function onDirectWarning() { 66 return confirm('Warning: navigating away from the wizard causes loss of work and unsaved data. Are you sure you want to continue?'); 64 67 } 65 68
Note: See TracChangeset
for help on using the changeset viewer.