- Timestamp:
- Mar 31, 2011, 5:03:31 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/controllers/dbnp/studycapturing/SimpleWizardController.groovy
r1678 r1684 58 58 error() 59 59 }.to "decisionState" 60 on("refresh") { handleStudy( flow.study, params ); }.to "study" 61 on( "success" ) { handleStudy( flow.study, params ) }.to "study" 60 on("refresh") { handleStudy( flow.study, params ); }.to "study" 61 on( "save" ) { 62 handleStudy( flow.study, params ); 63 if( !validateObject( flow.study ) ) 64 return error() 65 66 if( flow.study.save( flush: true ) ) { 67 flash.message = "Your study is succesfully saved."; 68 } else { 69 flash.error = "An error occurred while saving your study: <br />" 70 flow.study.getErrors().each { flash.error += it.toString() + "<br />"} 71 } 72 success() 73 }.to "study" 62 74 } 63 75 … … 66 78 // Create data in the flow 67 79 flow.templates = [ 68 'Sample': Template.findAllByEntity( Sample.class ),69 80 'Subject': Template.findAllByEntity( Subject.class ), 70 81 'Event': Template.findAllByEntity( Event.class ), 71 'SamplingEvent': Template.findAllByEntity( SamplingEvent.class ) 82 'SamplingEvent': Template.findAllByEntity( SamplingEvent.class ), 83 'Sample': Template.findAllByEntity( Sample.class ) 72 84 ]; 73 85 74 86 flow.encodedEntity = [ 75 'Sample': gdtService.encryptEntity( Sample.class.name ),76 87 'Subject': gdtService.encryptEntity( Subject.class.name ), 77 88 'Event': gdtService.encryptEntity( Event.class.name ), 78 'SamplingEvent': gdtService.encryptEntity( SamplingEvent.class.name ) 89 'SamplingEvent': gdtService.encryptEntity( SamplingEvent.class.name ), 90 'Sample': gdtService.encryptEntity( Sample.class.name ) 79 91 ] 80 92 … … 103 115 handleExistingSamples( flow.study, params, flow ) ? success() : error() 104 116 }.to "startAssays" 117 on( "save" ) { 118 if( !handleExistingSamples( flow.study, params, flow ) ) 119 return error() 120 121 if( flow.study.save( flush: true ) ) { 122 flash.message = "Your study is succesfully saved."; 123 } else { 124 flash.error = "An error occurred while saving your study: <br />" 125 flow.study.getErrors().each { flash.error += it.toString() + "<br />"} 126 } 127 success() 128 }.to "existingSamples" 129 105 130 on("previous").to "study" 106 131 on("update") { … … 153 178 154 179 flow.templates = [ 155 'Sample': Template.findAllByEntity( Sample.class ),156 180 'Subject': Template.findAllByEntity( Subject.class ), 157 181 'Event': Template.findAllByEntity( Event.class ), 158 'SamplingEvent': Template.findAllByEntity( SamplingEvent.class ) 182 'SamplingEvent': Template.findAllByEntity( SamplingEvent.class ), 183 'Sample': Template.findAllByEntity( Sample.class ) 159 184 ]; 160 185 … … 241 266 startAssays { 242 267 action { 243 if( !flow.assay ) 244 flow.assay = new Assay( parent: flow.study ); 245 268 if( !flow.assay ) { 269 if( flow.study.assays ) { 270 flow.assay = flow.study.assays[ 0 ] 271 println "Existing assay: " + flow.assay 272 } else { 273 flow.assay = new Assay( parent: flow.study ); 274 } 275 } 246 276 success(); 247 277 } … … 252 282 on( "next" ) { 253 283 handleAssays( flow.assay, params, flow ); 254 if( !validateObject( flow.assay ) )284 if( flow.assay.template && !validateObject( flow.assay ) ) 255 285 error(); 286 256 287 }.to "overview" 257 288 on( "skip" ) { … … 267 298 // Refresh the templates, since the template editor has been opened. To make this happen 268 299 // the hibernate session has to be cleared first 269 sessionFactory.getCurrentSession().clear();270 300 //sessionFactory.getCurrentSession().clear(); 301 271 302 handleAssays( flow.assay, params, flow ); 272 303 … … 291 322 saveStudy { 292 323 action { 293 if( flow.assay && !flow.study.assays?.contains( flow.assay ) ) {324 if( flow.assay && flow.assay.template && !flow.study.assays?.contains( flow.assay ) ) { 294 325 flow.study.addToAssays( flow.assay ); 295 326 } … … 426 457 427 458 def objects = [ 428 'Sample': study.samples,429 459 'Subject': study.samples.parentSubject.findAll { it }, 430 460 'SamplingEvent': study.samples.parentEvent.findAll { it }, 431 'Event': events.flatten().findAll { it } 461 'Event': events.flatten().findAll { it }, 462 'Sample': study.samples 432 463 ]; 433 464 objects.each { … … 504 535 flow.sampleForm.dataMatrixStart = dataMatrixStart 505 536 flow.sampleForm.headerRow = headerRow 537 flow.sampleForm.importFile = filename 506 538 507 539 def importedfile = fileService.get( filename ) … … 618 650 619 651 // Save form data in session 620 flow.sampleForm = [ 621 templateId: [ 622 'Sample': sampleTemplateId, 652 if( !flow.sampleForm ) 653 flow.sampleForm = [:] 654 655 flow.sampleForm.templateId = [ 623 656 'Subject': subjectTemplateId, 624 657 'Event': eventTemplateId, 625 'SamplingEvent': samplingEventTemplateId 626 ],627 template: [628 'Sample': sampleTemplateId ? Template.get( sampleTemplateId ) : null,658 'SamplingEvent': samplingEventTemplateId, 659 'Sample': sampleTemplateId 660 ]; 661 flow.sampleForm.template = [ 629 662 'Subject': subjectTemplateId ? Template.get( subjectTemplateId ) : null, 630 663 'Event': eventTemplateId ? Template.get( eventTemplateId ) : null, 631 'SamplingEvent': samplingEventTemplateId ? Template.get( samplingEventTemplateId ) : null 632 ],633 664 'SamplingEvent': samplingEventTemplateId ? Template.get( samplingEventTemplateId ) : null, 665 'Sample': sampleTemplateId ? Template.get( sampleTemplateId ) : null 666 ]; 634 667 } 635 668 -
trunk/grails-app/services/dbnp/importer/ImporterService.groovy
r1677 r1684 229 229 protected retrieveEntitiesBySample( Sample s ) { 230 230 return [ 231 'Sample': s,232 231 'Subject': s?.parentSubject, 233 232 'SamplingEvent': s?.parentEvent, 234 'Event': s?.parentEventGroup?.events?.toList()?.getAt(0) 233 'Event': s?.parentEventGroup?.events?.toList()?.getAt(0), 234 'Sample': s 235 235 ] 236 236 } -
trunk/grails-app/views/simpleWizard/simpleWizard/columns.gsp
r1610 r1684 9 9 <body> 10 10 <div class="simpleWizard"> 11 <h1> Columns</h1>11 <h1>Imported file</h1> 12 12 13 13 <g:if test="${error}"> … … 26 26 27 27 <span class="info"> 28 <span class="title">Assign properties to columns</span>28 <span class="title">Assign columns to template fields</span> 29 29 You uploaded: ${excel.filename}. This list shows the first ${excel.data.dataMatrix?.size()} rows of the uploaded file for reference. 30 30 Please match the columns from the excel file with the fields in the database. 31 31 </span> 32 32 33 <div class="importcolumns"> 34 <table> 35 <thead> 36 <tr> 37 <g:each in="${excel.data.header}" var="header"> 38 <th>${header.name}</th> 33 <div class="importcolumns"> 34 <table cellspacing="0"> 35 <tr class="headerrow"> 36 <td nowrap class="explanation">Excel columns</td> 37 <g:each in="${excel.data.header}" var="header"> 38 <th>${header.name}</th> 39 </g:each> 40 </tr> 41 <g:each in="${excel.data.dataMatrix}" var="exampleRow" status="i"> 42 <tr class="example"> 43 <g:if test="${i == 0}"> 44 <td nowrap class="explanation">Example data</td> 45 </g:if> 46 <g:else> 47 <td class="explanation"></td> 48 </g:else> 49 <g:each in="${exampleRow}" var="exampleCell"> 50 <td class="exampleCell"><div> 51 ${exampleCell} 52 </div> 53 </td> 39 54 </g:each> 40 55 </tr> 41 </thead> 56 </g:each> 57 42 58 <tr class="matchWith"> 59 <td nowrap class="explanation">Template field</td> 60 43 61 <g:each in="${excel.data.header}" var="mappingcolumn" status="i"> 44 62 <% … … 77 95 </g:each> 78 96 </tr> 79 <g:each in="${excel.data.dataMatrix}" var="exampleRow"> 80 <tr class="example"> 81 <g:each in="${exampleRow}" var="exampleCell"> 82 <td> 83 ${exampleCell} 84 </td> 85 </g:each> 86 </tr> 87 </g:each> 97 88 98 </table> 89 99 </div> -
trunk/grails-app/views/simpleWizard/simpleWizard/existingSamples.gsp
r1678 r1684 56 56 <g:each var="entity" in="${record.objects}"> 57 57 <g:if test="${entity.value}"> 58 <div class="column">${entity.key} 58 <div class="column">${entity.key}<br />template</div> 59 59 <af:templateColumnHeaders includeEntities="${true}" entity="${entity.value}" class="column" columnWidths="[Name:100]"/> 60 60 </g:if> … … 86 86 <p class="options"> 87 87 <a href="#" onClick="submitForm( 'existingSamples', 'previous' ); return false;" class="previous">Previous</a> 88 <a href="#" onClick="submitForm( 'existingSamples', 'save' ); return false;" class="save">Save</a> 88 89 <a href="#" onClick="submitForm( 'existingSamples', 'next' ); return false;" class="next">Next</a> 89 90 <a href="#" onClick="submitForm( 'existingSamples', 'update' ); return false;" class="excel">Update using excel</a> -
trunk/grails-app/views/simpleWizard/simpleWizard/samples.gsp
r1683 r1684 34 34 35 35 <div id="samplesDialog"> 36 37 36 <table border="0"> 38 37 <tr> … … 40 39 Excel file to import: 41 40 </td> 42 <td width="25%"> 43 <af:fileField name="importfile" value="${sampleForm?.importFile}"/> 44 </td> 45 <td width="40%"></td> 46 </tr> 47 <tr> 48 <td class="required"> 49 <div id="datatemplate">Sample template:</div> 50 </td> 51 <td> 52 <% /* The select is written manually, since the grails select tag can't handle option titles */ %> 53 <select rel="template" entity="${encodedEntity.Sample}" onChange="showTemplateDescription( 'templateDescription_sample', $( 'option:selected', $(this) ).attr( 'title' ) ); " name="sample_template_id"> 54 <g:each in="${templates.Sample}" var="templ"> 55 <option 56 value="${templ.id}" 57 <g:if test="${templ.id == sampleForm?.templateId?.Sample}">selected="selected"</g:if> 58 title="${templ.description?.encodeAsHTML()}" 59 >${templ.name?.encodeAsHTML()}</option> 60 </g:each> 61 </select> 62 </td> 63 <td> 64 <% 65 def sampleTemplate = sampleForm?.template?.Sample ?: templates.Sample?.getAt(0) 66 def sampleTemplateDescription = sampleTemplate?.description 67 %> 68 <div class="templatedescription" id="templateDescription_sample" <g:if test="${!sampleTemplateDescription}">style="display: none;"</g:if>> 69 ${sampleTemplateDescription?.encodeAsHTML()} 70 </div> 41 <td colspan="2"> 42 <af:fileField buttonText="Open" hideDelete="${true}" name="importfile" value="${sampleForm?.importFile}"/> 71 43 </td> 72 44 </tr> … … 148 120 </div> 149 121 </td> 150 </tr> 122 </tr> 123 <tr> 124 <td class="required"> 125 <div id="datatemplate">Sample template:</div> 126 </td> 127 <td width="25%"> 128 <% /* The select is written manually, since the grails select tag can't handle option titles */ %> 129 <select rel="template" entity="${encodedEntity.Sample}" onChange="showTemplateDescription( 'templateDescription_sample', $( 'option:selected', $(this) ).attr( 'title' ) ); " name="sample_template_id"> 130 <g:each in="${templates.Sample}" var="templ"> 131 <option 132 value="${templ.id}" 133 <g:if test="${templ.id == sampleForm?.templateId?.Sample}">selected="selected"</g:if> 134 title="${templ.description?.encodeAsHTML()}" 135 >${templ.name?.encodeAsHTML()}</option> 136 </g:each> 137 </select> 138 </td> 139 <td width="40%"> 140 <% 141 def sampleTemplate = sampleForm?.template?.Sample ?: templates.Sample?.getAt(0) 142 def sampleTemplateDescription = sampleTemplate?.description 143 %> 144 <div class="templatedescription" id="templateDescription_sample" <g:if test="${!sampleTemplateDescription}">style="display: none;"</g:if>> 145 ${sampleTemplateDescription?.encodeAsHTML()} 146 </div> 147 </td> 148 </tr> 151 149 </table> 152 150 </div> -
trunk/grails-app/views/simpleWizard/simpleWizard/study.gsp
r1678 r1684 9 9 <body> 10 10 <div class="simpleWizard studypage"> 11 <h1>Study</h1> 12 13 <g:if test="${flash.error}"> 11 <h1> 12 <g:if test="${study.id}"> 13 Edit study [${study.title?.encodeAsHTML()}] 14 </g:if> 15 <g:else> 16 Study 17 </g:else> 18 </h1> 19 <g:if test="${error}"> 14 20 <div class="errormessage"> 15 ${ flash.error.toString().encodeAsHTML()}21 ${error.toString().encodeAsHTML()} 16 22 </div> 17 23 </g:if> 18 <g:if test="${ flash.message}">24 <g:if test="${message}"> 19 25 <div class="message"> 20 ${ flash.message.toString().encodeAsHTML()}26 ${message.toString().encodeAsHTML()} 21 27 </div> 22 </g:if> 28 </g:if> 23 29 24 30 <span class="info"> … … 95 101 96 102 <p class="options"> 103 <a class="save" href="#" onClick="submitForm( 'study', 'save' ); return false;">Save</a> 97 104 <a href="#" onClick="submitForm( 'study', 'next' ); return false;" class="next">Next</a> 98 105 </p> -
trunk/web-app/css/simplewizard.css
r1683 r1684 27 27 28 28 /* template descriptions */ 29 .templatedescription { display: block; padding: 3px; border: 1px solid #4CAAED; /* #006DBA; */ }30 .studypage .templatedescription, .assayspage .templatedescription{ width: 22 2px; margin: 5px 0 5px 174px; }29 .templatedescription { display: block; padding: 2px 4px; border: 1px solid #4CAAED; /* #006DBA; */ } 30 .studypage .templatedescription, .assayspage .templatedescription{ width: 220px; margin: 5px 0 5px 174px; } 31 31 .samplespage .templatedescription { width: 300px; } 32 32 … … 40 40 /** SAMPLES PAGE **/ 41 41 .simpleWizard #samplesDialog table { border-width: 0; } 42 .simpleWizard .upload_del { margin-left: 20px; } 43 .simpleWizard .upload_info { width: 250px; overflow: hidden; } 42 44 43 45 /** COLUMNS PAGE **/ 44 46 .simpleWizard .importcolumns { position: relative; width: 100%; overflow: auto; border: 1px solid #ccc; } 45 47 .simpleWizard .importcolumns table { border-width: 0; } 48 .simpleWizard .importcolumns .explanation { border-right: 1px solid black; background-color: #eee; } 49 .simpleWizard .importcolumns .headerrow td, .simpleWizard .importcolumns .headerrow th { border-bottom: 1px solid #999; } 50 .simpleWizard .importcolumns .matchWith td { border-top: 1px solid #999; } 51 .simpleWizard .importcolumns td.exampleCell div { 52 white-space: nowrap; 53 width: 200px; 54 overflow: hidden; 55 text-overflow: ellipsis; 56 } 57 .simpleWizard .importcolumns .matchWith select { width: auto; } 46 58 47 59 /** MISSING FIELDS PAGE / TABLE EDITOR **/
Note: See TracChangeset
for help on using the changeset viewer.