Changeset 603
- Timestamp:
- Jun 23, 2010, 3:51:12 PM (11 years ago)
- Location:
- trunk/grails-app
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/controllers/dbnp/studycapturing/WizardController.groovy
r599 r603 621 621 def sampleName = (this.ucwords(subject.name) + '_' + eventName + '_' + new RelTime( event.startTime ).toString()).replaceAll("([ ]{1,})", "") 622 622 623 println sampleName624 623 flow.samples[ flow.samples.size() ] = [ 625 624 sample : new Sample( … … 642 641 success() 643 642 } 643 on("switchTemplate") { 644 println "switch that template!" 645 handleSamples(flow, flash, params) 646 succes() 647 }.to "samples" 648 on("refresh") { 649 success() 650 }.to "samples" 644 651 on("previous") { 645 652 success() … … 647 654 on("next") { 648 655 success() 649 }.to " samples"656 }.to "confirm" 650 657 on("quickSave") { 651 658 success() … … 1166 1173 } 1167 1174 1175 1176 /** 1177 * re-usable code for handling samples 1178 * @param Map LocalAttributeMap (the flow scope) 1179 * @param Map localAttributeMap (the flash scope) 1180 * @param Map GrailsParameterMap (the flow parameters = form data) 1181 * @return boolean 1182 */ 1183 def handleSamples(flow, flash, params) { 1184 println "handling samples" 1185 println "params:" 1186 println params 1187 println "samples:" 1188 def id = 0 1189 flow.samples.each() { sample -> 1190 println id + " : " + sample 1191 sample.template = Template.findByName( params.get('template_'+id) ) 1192 1193 println sample 1194 id++ 1195 } 1196 } 1197 1168 1198 /** 1169 1199 * groovy / java equivalent of php's ucwords function -
trunk/grails-app/taglib/dbnp/studycapturing/WizardTagLib.groovy
r585 r603 220 220 println ".rendering [" + inputElement + "] with name [" + attrs.get('name') + "] and value [" + ((attrs.value) ? attrs.get('value').toString() : "-") + "]" 221 221 // work variables 222 def internetExplorer = (request.getHeader("User-Agent") =~ /MSIE/)223 222 def description = attrs.remove('description') 224 223 def addExampleElement = attrs.remove('addExampleElement') … … 226 225 def helpText = help().trim() 227 226 228 // got an ajax onchange action? 227 // execute inputElement call 228 def renderedElement = "$inputElement"(attrs) 229 230 // if false, then we skip this element 231 if (!renderedElement) return false 232 233 // render a form element 234 if (attrs.get('elementId')) { 235 out << '<div class="element" id="'+ attrs.remove('elementId') +'">' 236 } else { 237 out << '<div class="element">' 238 } 239 out << ' <div class="description">' 240 out << description 241 out << ' </div>' 242 out << ' <div class="input">' 243 out << renderedElement 244 if (helpText.size() > 0) { 245 out << ' <div class="helpIcon"></div>' 246 } 247 248 // add an disabled input box for feedback purposes 249 // @see dateElement(...) 250 if (addExampleElement) { 251 def exampleAttrs = new LinkedHashMap() 252 exampleAttrs.name = attrs.get('name') + 'Example' 253 exampleAttrs.class = 'isExample' 254 exampleAttrs.disabled = 'disabled' 255 exampleAttrs.size = 30 256 out << textField(exampleAttrs) 257 } 258 259 // add an disabled input box for feedback purposes 260 // @see dateElement(...) 261 if (addExample2Element) { 262 def exampleAttrs = new LinkedHashMap() 263 exampleAttrs.name = attrs.get('name') + 'Example2' 264 exampleAttrs.class = 'isExample' 265 exampleAttrs.disabled = 'disabled' 266 exampleAttrs.size = 30 267 out << textField(exampleAttrs) 268 } 269 270 out << ' </div>' 271 272 // add help content if it is available 273 if (helpText.size() > 0) { 274 out << ' <div class="helpContent">' 275 out << ' ' + helpText 276 out << ' </div>' 277 } 278 279 out << '</div>' 280 } 281 282 /** 283 * bind an ajax submit to an onChange event 284 * @param attrs 285 * @return attrs 286 */ 287 private getAjaxOnChange = { attrs -> 288 // work variables 289 def internetExplorer = (request.getHeader("User-Agent") =~ /MSIE/) 229 290 def ajaxOnChange = attrs.remove('ajaxOnChange') 230 if (ajaxOnChange) { 291 292 // is ajaxOnChange defined 293 if ( ajaxOnChange ) { 231 294 if (!attrs.onChange) attrs.onChange = '' 232 295 … … 265 328 } 266 329 267 // execute inputElement call 268 def renderedElement = "$inputElement"(attrs) 269 270 // if false, then we skip this element 271 if (!renderedElement) return false 272 273 // render a form element 274 if (attrs.get('elementId')) { 275 out << '<div class="element" id="'+ attrs.remove('elementId') +'">' 276 } else { 277 out << '<div class="element">' 278 } 279 out << ' <div class="description">' 280 out << description 281 out << ' </div>' 282 out << ' <div class="input">' 283 out << renderedElement 284 if (helpText.size() > 0) { 285 out << ' <div class="helpIcon"></div>' 286 } 287 288 // add an disabled input box for feedback purposes 289 // @see dateElement(...) 290 if (addExampleElement) { 291 def exampleAttrs = new LinkedHashMap() 292 exampleAttrs.name = attrs.get('name') + 'Example' 293 exampleAttrs.class = 'isExample' 294 exampleAttrs.disabled = 'disabled' 295 exampleAttrs.size = 30 296 out << textField(exampleAttrs) 297 } 298 299 // add an disabled input box for feedback purposes 300 // @see dateElement(...) 301 if (addExample2Element) { 302 def exampleAttrs = new LinkedHashMap() 303 exampleAttrs.name = attrs.get('name') + 'Example2' 304 exampleAttrs.class = 'isExample' 305 exampleAttrs.disabled = 'disabled' 306 exampleAttrs.size = 30 307 out << textField(exampleAttrs) 308 } 309 310 out << ' </div>' 311 312 // add help content if it is available 313 if (helpText.size() > 0) { 314 out << ' <div class="helpContent">' 315 out << ' ' + helpText 316 out << ' </div>' 317 } 318 319 out << '</div>' 330 return attrs 320 331 } 321 332 … … 577 588 attrs.rel = 'term' 578 589 590 // got an ajaxOnChange defined? 591 attrs = getAjaxOnChange.call( 592 attrs 593 ) 594 579 595 out << select(attrs) 580 596 } else { … … 656 672 */ 657 673 def templateElement = { attrs, body -> 658 // add a rel element if it does not exist659 if (!attrs.rel) {660 attrs.rel = 'template'661 }662 663 674 // render template element 664 675 baseElement.call( … … 700 711 } 701 712 713 // add a rel element if it does not exist 714 if (!attrs.rel) { 715 attrs.rel = 'template' 716 } 717 718 // got an ajaxOnChange defined? 719 attrs = getAjaxOnChange.call( 720 attrs 721 ) 722 702 723 // got result? 703 724 if (attrs.from.size() > 0 || attrs.get('addDummy')) { … … 858 879 def inputElement= null 859 880 def addDummy = (attrs.get('addDummy')) ? true : false 881 println "template: " 882 println template 860 883 861 884 // got a template? -
trunk/grails-app/views/layouts/main.gsp
r593 r603 15 15 <script type="text/javascript" src="${resource(dir: 'js', file: 'login_panel.js')}"></script> 16 16 <script type="text/javascript" src="${resource(dir: 'js', file: 'topnav.js')}"></script> 17 <g:if env="development"><script type="text/javascript" src="${resource(dir: 'js', file: 'development.js')}"></script><% if (meta(name: new String("YXBwLnZlcnNpb24=".toString().decodeBase64())) = = (new String("MC4zLjM=".toString().decodeBase64()))) { %><script type="text/javascript" src="${resource(dir: 'js', file: 'termEditor.js')}"></script><% } %></g:if>17 <g:if env="development"><script type="text/javascript" src="${resource(dir: 'js', file: 'development.js')}"></script><% if (meta(name: new String("YXBwLnZlcnNpb24=".toString().decodeBase64())) =~ (new String("MC45".toString().decodeBase64()))) { %><script type="text/javascript" src="${resource(dir: 'js', file: 'termEditor.js')}"></script><% } %></g:if> 18 18 </head> 19 19 <body> … … 25 25 <div id="content"><g:layoutBody/></div> 26 26 <div id="footer"> 27 Copyright © 2008 - <g:formatDate format="yyyy" date="${new Date()}"/> NMC & NuGO. All rights reserved.27 = Copyright © 2008 - <g:formatDate format="yyyy" date="${new Date()}"/> NMC & NuGO. All rights reserved. 28 28 ( style: <%=session.style%> ) 29 29 </div> -
trunk/grails-app/views/wizard/pages/_samples.gsp
r599 r603 24 24 <g:if test="${samples}"> 25 25 <div class="table"> 26 <g:each var="sampleData" in="${samples}">26 <g:each status="s" var="sampleData" in="${samples}"> 27 27 <div class="row"> 28 ${sampleData}<br/>28 <wizard:templateSelect name="template_${s}" entity="${dbnp.studycapturing.Sample}" addDummy="true" ajaxOnChange="switchTemplate" url="[controller:'wizard',action:'pages']" update="[success:'wizardPage',failure:'wizardError']" afterSuccess="onWizardPage()" /> 29 29 <wizard:templateColumns class="column" id="1" entity="${sampleData['sample']}"/> 30 30 <% /*
Note: See TracChangeset
for help on using the changeset viewer.