Changeset 216
- Timestamp:
- Feb 26, 2010, 3:23:03 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/controllers/dbnp/studycapturing/WizardController.groovy
r213 r216 52 52 [title: 'Event Descriptions'], // event descriptions 53 53 [title: 'Events'], // events 54 [title: 'Confirmation'], 54 [title: 'Confirmation'], // confirmation page 55 55 [title: 'Done'] // finish page 56 56 ] … … 271 271 272 272 // get eventDescription instance by name 273 params.eventDescription = this.getObjectByName(params.get('eventDescription'), flow.eventDescriptions)273 params.eventDescription = this.getObjectByName(params.get('eventDescription'), flow.eventDescriptions) 274 274 275 275 // instantiate Event with parameters 276 276 def event = new Event(params) 277 278 // handle event groupings 279 this.handleEventGrouping(flow, flash, params) 277 280 278 281 // validate event … … 287 290 this.appendErrors(event, flash.errors) 288 291 289 flash.startTime 290 flash.endTime 291 flash.eventDescription 292 292 flash.startTime = params.startTime 293 flash.endTime = params.endTime 294 flash.eventDescription = params.eventDescription 295 293 296 error() 294 297 } … … 296 299 on("addEventGroup") { 297 300 def increment = flow.eventGroups.size() 298 flow.eventGroups[ increment ] = new EventGroup(name: "Group "+(increment+1)) 301 def groupName = "Group " + (increment + 1) 302 303 // check if group name exists 304 def nameExists = true 305 def u = 0 306 307 // make sure a unique name is generated 308 while (nameExists) { 309 u++ 310 def count = 0 311 312 flow.eventGroups.each() { 313 if (it.name == groupName) { 314 groupName = "Group " + (increment + 1) + "," + u 315 } else { 316 count++ 317 } 318 } 319 320 nameExists = !(count == flow.eventGroups.size()) 321 } 322 323 flow.eventGroups[increment] = new EventGroup(name: groupName) 324 }.to "events" 325 on("deleteEventGroup") { 326 def delete = params.get('do') as int; 327 328 // handle event groupings 329 this.handleEventGrouping(flow, flash, params) 330 331 // remove the group with this specific id 332 if (flow.eventGroups[delete] && flow.eventGroups[delete] instanceof EventGroup) { 333 // remove this eventGroup 334 flow.eventGroups.remove(delete) 335 } 299 336 }.to "events" 300 337 on("previous") { 301 // TODO 338 // handle event groupings 339 this.handleEventGrouping(flow, flash, params) 302 340 }.to "eventDescriptions" 303 341 on("next") { 304 342 flash.errors = new LinkedHashMap() 343 344 // handle event groupings 345 this.handleEventGrouping(flow, flash, params) 305 346 306 347 // check if we have at least one subject … … 312 353 error() 313 354 } 314 }.to " confirm"355 }.to "events" 315 356 } 316 357 … … 338 379 // TODO 339 380 }.to "confirm" 381 } 382 } 383 384 /** 385 * re-usable code for handling event grouping in a web flow 386 * @param Map LocalAttributeMap (the flow scope) 387 * @param Map localAttributeMap (the flash scope) 388 * @param Map GrailsParameterMap (the flow parameters = form data) 389 * @returns boolean 390 */ 391 def handleEventGrouping(flow, flash, params) { 392 // walk through eventGroups 393 def g = 0 394 flow.eventGroups.each() { 395 def e = 0 396 def eventGroup = it 397 398 // reset events 399 eventGroup.events = new HashSet() 400 401 // walk through events 402 flow.events.each() { 403 if (params.get('event_' + e + '_group_' + g) == 'on') { 404 eventGroup.addToEvents(it) 405 //} else { 406 // eventGroup.events.minus(it) 407 } 408 e++ 409 } 410 g++ 340 411 } 341 412 } … … 396 467 397 468 flow.eventDescriptions.each() { 398 it.name 399 it.description 400 it.classification 401 it.isSamplingEvent 469 it.name = params.get('eventDescription_' + id + '_name') 470 it.description = params.get('eventDescription_' + id + '_description') 471 it.classification = Term.findByName(params.get('eventDescription_' + id + '_classification')) 472 it.isSamplingEvent = (params.containsKey('eventDescription_' + id + '_isSamplingEvent')) 402 473 403 474 // validate eventDescription … … 443 514 // yeah, also mention the first 444 515 // occurrence in the error message 445 this.appendErrorMap(name: 'The subject name needs to be unique!', flash.errors, 'subject_' +names[it.name]['firstId']+'_')516 this.appendErrorMap(name: 'The subject name needs to be unique!', flash.errors, 'subject_' + names[it.name]['firstId'] + '_') 446 517 } 447 518 448 519 // add to error map 449 this.appendErrorMap([name: 'The subject name needs to be unique!'], flash.errors, 'subject_' +id+'_')520 this.appendErrorMap([name: 'The subject name needs to be unique!'], flash.errors, 'subject_' + id + '_') 450 521 errors = true 451 522 } … … 502 573 } 503 574 504 505 575 /** 506 576 * return the object from a map of objects by searching for a name 507 * @param String 508 * @param Map 577 * @param String name 578 * @param Map map of objects 509 579 * @return Object 510 580 */ … … 545 615 this.appendErrorMap(this.getHumanReadableErrors(object), map) 546 616 } 617 547 618 def appendErrors(object, map, prepend) { 548 619 this.appendErrorMap(this.getHumanReadableErrors(object), map, prepend) … … 560 631 } 561 632 } 633 562 634 def appendErrorMap(map, mapToExtend, prepend) { 563 635 map.each() {key, value -> -
trunk/grails-app/taglib/dbnp/studycapturing/WizardTagLib.groovy
r213 r216 55 55 // javascript function to call after success 56 56 def afterSuccess = attrs['afterSuccess'] 57 58 // src parameter? 59 def src = attrs['src'] 60 def alt = attrs['alt'] 57 61 58 62 // generate a normal submitToRemote button … … 89 93 if (afterSuccess) { 90 94 button = button.replaceFirst(/\.html\(data\)\;/, '.html(data);' + afterSuccess + ';') 95 } 96 97 // got an src parameter? 98 if (src) { 99 def replace = 'type="image" src="' + src + '"' 100 101 if (alt) replace = replace + ' alt="' + alt + '"' 102 103 button = button.replaceFirst(/type="button"/, replace) 91 104 } 92 105 -
trunk/grails-app/views/wizard/common/_wizard.gsp
r145 r216 18 18 <h1>Create a new study</h1> 19 19 <g:form action="pages" name="wizardForm" id="wizardForm"> 20 <g:hiddenField name="do" value="" /> 20 21 <div id="wizardPage"> 21 22 <wizard:ajaxFlowRedirect form="form#wizardForm" name="next" url="[controller:'wizard',action:'pages']" update="[success:'wizardPage',failure:'wizardError']" afterSuccess="onWizardPage()" /> -
trunk/grails-app/views/wizard/pages/_events.gsp
r213 r216 45 45 <div class="column">duration</div> 46 46 <g:if test="${eventGroups}"><g:each var="eventGroup" status="i" in="${eventGroups}"> 47 <div class="column"><g:textField name="eventGroup_${i}_name" value="${eventGroup.name}" /></div> 47 <div class="column"> 48 <g:textField name="eventGroup_${i}_name" value="${eventGroup.name}" /> 49 <wizard:ajaxButton name="deleteEventGroup" src="../images/icons/famfamfam/delete.png" alt="delete this eventgroup" class="famfamfam" value="-" url="[controller:'wizard',action:'pages']" update="[success:'wizardPage',failure:'wizardError']" before="\$(\'input[name=do]\').val(${i});" afterSuccess="onWizardPage()" /> 50 </div> 48 51 </g:each></g:if> 49 <div class="column"><wizard:ajaxButton name="addEventGroup" value="+" url="[controller:'wizard',action:'pages']" update="[success:'wizardPage',failure:'wizardError']" afterSuccess="onWizardPage()" /></div> 52 <div class="column"> 53 <wizard:ajaxButton name="addEventGroup" src="../images/icons/famfamfam/add.png" alt="add a new eventgroup" class="famfamfam" value="+" url="[controller:'wizard',action:'pages']" update="[success:'wizardPage',failure:'wizardError']" afterSuccess="onWizardPage()" /> 54 </div> 50 55 </div> 51 56 <g:each var="event" status="i" in="${events}"> … … 57 62 <div class="column">${event.getShortDuration()}</div> 58 63 <g:if test="${eventGroups}"><g:each var="eventGroup" status="j" in="${eventGroups}"> 59 <div class="column"><input type="checkbox" name="event_${i}_group_${j}"/></div> 64 <div class="column"> 65 <g:if test="${eventGroup.events.find{ it == event} }"> 66 <input type="checkbox" name="event_${i}_group_${j}" checked="checked" /> 67 </g:if><g:else> 68 <input type="checkbox" name="event_${i}_group_${j}"/> 69 </g:else> 70 </div> 60 71 </g:each></g:if> 61 72 <div class="column"></div> … … 63 74 </g:each> 64 75 </div> 76 <div class="sliderContainer"> 77 <div class="slider"/> 78 </div> 65 79 </g:if> 66 80 </wizard:pageContent> -
trunk/web-app/css/default_style.css
r162 r216 30 30 margin: 20px 0 10px; 31 31 } 32 32 33 /** END :: header **/ 33 34 /** START :: topnav **/ -
trunk/web-app/css/wizard.css
r213 r216 21 21 padding-left: 20px; 22 22 background: url(../images/icons/famfamfam/information.png) no-repeat center left; 23 } 24 25 .wizard .famfamfam { 26 width: 16px; 27 height: 16px; 28 margin-top: 5px; 23 29 } 24 30 … … 212 218 } 213 219 214 .wizard .table input , .wizard .table select {220 .wizard .table input[type=text], .wizard .table select { 215 221 border: 1px solid #8e908f; 216 222 margin: 2px 0; … … 219 225 width: 100px; 220 226 } 221 .wizard .table .header input , .wizard .table .header select, .wizard .table .header button {227 .wizard .table .header input[type=text], .wizard .table .header select, .wizard .table .header button { 222 228 border: 1px solid #8e908f; 223 229 margin: 2px 0; 224 230 padding: 2px 4px; 225 231 background-color: #fff; 226 width: 100px;232 width: 75px; 227 233 } 228 234 … … 238 244 239 245 /* END :: TABLE */ 240 241 /* START :: GROUPING */242 .wizard .grouping {243 border: 1px solid black;244 display: inline-block;245 height: auto;246 width: 100%;247 }248 249 .wizard .grouping .ui-selected {250 background-color: red;251 }252 .wizard .grouping .ui-selecting {253 background-color: orange;254 }255 256 .wizard .grouping .subjects {257 display: block;258 float: left;259 }260 .wizard .grouping .subjects .subject {261 margin: 1px;262 padding: 0.2em;263 font-size: .8em;264 height: 14px;265 }266 .wizard .grouping .middle {267 display: inline-block;268 float: left;269 }270 .wizard .grouping .add {271 background: url(../images/wizard/add.png) no-repeat left top;272 width: 149px;273 height: 29px;274 margin-top: 10px;275 margin-left: 14px;276 }277 .wizard .grouping .add-hover {278 background: url(../images/wizard/add-hover.png) no-repeat left top;279 }280 .wizard .grouping .remove {281 background: url(../images/wizard/remove.png) no-repeat left top;282 width: 149px;283 height: 29px;284 margin-top: 10px;285 }286 .wizard .grouping .remove-hover {287 background: url(../images/wizard/remove-hover.png) no-repeat left top;288 }289 .wizard .grouping .right {290 display: inline-block;291 float: right;292 }293 .wizard .grouping .right .form {294 border: 1px solid black;295 }296 .wizard .grouping .group {297 margin: 5px 0px 5px 0px;298 border: 1px solid black;299 height: auto;300 }301 .wizard .grouping .ui-selected {302 border: 4px solid red;303 }304 .wizard .grouping .group .label {305 display: block;306 background-color: #006DBA;307 color: #fff;308 font-weight: bold;309 width: auto;310 height: 32px;311 line-height: 32px;312 text-align: center;313 }314 .wizard .grouping .group .subjects {315 display: inline-block;316 height: auto;317 }318 .wizard .grouping .group .subject {319 display: inline-block;320 width: 100%;321 font-size: 10px;322 }323 324 /* END :: GROUPING */ -
trunk/web-app/js/table-editor.js
r213 r216 91 91 var columnNumber = count; 92 92 $(input).bind('click', function() { 93 console.log(columnNumber+': update checkboxes with value '+input)94 93 that.updateSingleInputElements(input, columnNumber, 'input'); 95 94 });
Note: See TracChangeset
for help on using the changeset viewer.