Changeset 180
- Timestamp:
- Feb 9, 2010, 3:22:46 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/controllers/dbnp/studycapturing/WizardController.groovy
r178 r180 94 94 // validation failed, feedback errors 95 95 flash.errors = new LinkedHashMap() 96 this.appendErrors(flow.study, flash.errors)96 this.appendErrors(flow.study, flash.errors) 97 97 error() 98 98 } … … 110 110 } 111 111 } 112 on 112 on("add") { 113 113 // fetch species by name (as posted by the form) 114 114 def speciesTerm = Term.findByName(params.addSpecies) 115 115 116 116 // add x subject of species y 117 117 (params.addNumber as int).times { 118 118 def increment = flow.subjects.size() 119 flow.subjects[ increment ] = new Subject( 120 name: 'Subject ' + (increment+1), 121 species: speciesTerm 119 flow.subjects[increment] = new Subject( 120 name: 'Subject ' + (increment + 1), 121 species: speciesTerm, 122 template: flow.study.template 122 123 ) 123 124 } 124 125 }.to "subjects" 125 126 on("next") { 127 def errors = false 128 flash.errors = new LinkedHashMap() 129 126 130 // got one or more subjects? 127 131 if (flow.subjects.size() < 1) { 132 errors = true; 133 } else { 134 // handle form data 135 def id = 0; 136 flow.subjects.each() { 137 // store subject properties 138 it.name = params.get('subject_' + id + '_name') 139 it.species = Term.findByName(params.get('subject_' + id + '_species')) 140 141 // clear lists 142 def stringList = new LinkedHashMap(); 143 def intList = new LinkedHashMap(); 144 145 // get all template fields 146 flow.study.template.subjectFields.each() { 147 // get value 148 def value = params.get('subject_' + id + '_' + it.name); 149 if (value) { 150 // add to template parameters 151 switch (it.type) { 152 case 'STRINGLIST': 153 stringList[it.name] = value 154 break; 155 case 'INTEGER': 156 intList[ it.name ] = value 157 break; 158 default: 159 // unsupported type? 160 println "ERROR: unsupported type: "+it.type 161 break; 162 } 163 } 164 } 165 166 // set field data 167 it.templateStringFields = stringList 168 it.templateIntegerFields = intList 169 170 // validate subject 171 if (!it.validate()) { 172 errors = true 173 //println id + ' :: ' + it.errors.getAllErrors() 174 this.appendErrors(it, flash.errors) 175 } 176 177 id++; 178 } 179 } 180 181 // got errors? 182 if (errors) { 183 println flash.errors 128 184 error() 129 } 130 println params 185 } else { 186 success() 187 } 131 188 }.to "groups" 132 189 on("previous") { … … 146 203 on("add") { 147 204 def increment = flow.groups.size() 148 flow.groups[ increment] = new SubjectGroup(params)205 flow.groups[increment] = new SubjectGroup(params) 149 206 150 207 println flow.groups -
trunk/grails-app/taglib/dbnp/studycapturing/WizardTagLib.groovy
r162 r180 352 352 */ 353 353 def templateColumns = { attrs, body -> 354 def subjectId = attrs.remove('id') 355 def template = attrs.remove('template') 354 def subject = attrs.remove('subject') 355 def subjectId = attrs.remove('id') 356 def template = attrs.remove('template') 357 def intFields = subject.templateIntegerFields 358 def stringFields = subject.templateStringFields 356 359 357 360 // output columns for these subjectFields 358 361 template.subjectFields.each() { 362 // output div 359 363 out << '<div class="' + attrs.get('class') + '">' 360 364 … … 364 368 if (!it.listEntries.isEmpty()) { 365 369 out << select( 366 name: it.name, 367 from: it.listEntries 370 name: attrs.name + '_' + it.name, 371 from: it.listEntries, 372 value: (stringFields) ? stringFields.get(it.name) : '' 368 373 ) 369 374 } else { … … 374 379 // render integer subjectfield 375 380 out << textField( 376 name: it.name 381 name: attrs.name + '_' + it.name, 382 value: (intFields) ? intFields.get(it.name) : '' 377 383 ) 378 384 break; -
trunk/grails-app/views/wizard/pages/_groups.gsp
r178 r180 32 32 <div class="label">${group.name}</div> 33 33 <div class="subjects"> 34 <div class="subject">test subject 1</div> 35 <div class="subject">test subject 2</div> 36 <div class="subject">test subject 3</div> 34 37 </div> 35 38 </div> -
trunk/grails-app/views/wizard/pages/_subjects.gsp
r172 r180 35 35 <wizard:speciesSelect value="${subject.species}" name="subject_${i}_species" /> 36 36 </div> 37 <wizard:templateColumns id="${i}" template="${study.template}" class="column" />37 <wizard:templateColumns id="${i}" template="${study.template}" name="subject_${i}" class="column" subject="${subject}" /> 38 38 </div> 39 39 </g:each> -
trunk/web-app/js/grouping.js
r178 r180 14 14 function Grouping() { 15 15 } 16 /* 16 17 Grouping.prototype = { 17 18 itemsIdentifier: null, 18 itemIdentifier: null,19 itemIdentifier: null, 19 20 groupsIdentifier: null, 20 groupIdentifier: null, 21 groupIdentifier: null, 22 23 init: function(itemsIdentifier, itemIdentifier, groupsIdentifier, groupIdentifier) { 24 var that = this; 25 26 this.itemsIdentifier = itemsIdentifier; 27 this.itemIdentifier = itemIdentifier; 28 this.groupsIdentifier = groupsIdentifier; 29 this.groupIdentifier = groupIdentifier; 30 31 this.initItems(); 32 }, 33 34 initItems: function() { 35 $(this.itemsIdentifier). 36 } 37 } 38 */ 39 40 Grouping.prototype = { 41 itemsIdentifier: null, 42 itemIdentifier: null, 43 groupsIdentifier: null, 44 groupIdentifier: null, 21 45 22 46 init: function(itemsIdentifier, itemIdentifier, groupsIdentifier, groupIdentifier) { … … 36 60 37 61 // make all items selectable 62 console.log($(this.itemsIdentifier)) 38 63 $(this.itemsIdentifier).selectable({ 39 64 filter: that.itemIdentifier, … … 62 87 $('.ui-selected', $(that.itemsIdentifier)).each(function() { 63 88 var E = $(this); 64 89 65 90 // add to list 66 91 E.appendTo(list); … … 132 157 } 133 158 134
Note: See TracChangeset
for help on using the changeset viewer.