Changeset 453 for trunk/grails-app/views
- Timestamp:
- May 20, 2010, 5:02:22 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/views/study/show.gsp
r442 r453 12 12 }); 13 13 </script> 14 <link rel="stylesheet" href="${resource(dir: 'css', file: 'studies.css')}"/> 14 15 15 16 </head> 16 17 <body> 17 18 18 <div class="body" >19 <div class="body" id="studies"> 19 20 <h1><g:message code="default.show.label" args="[entityName]" /></h1> 20 21 <g:if test="${flash.message}"> … … 37 38 38 39 <table> 40 <!-- only show the head section if there are multiple studies --> 41 <g:if test="${studyList.size()>1}"> 42 <thead> 43 <tr> 44 <th></th> 45 <g:each in="${studyList}" var="studyInstance"> 46 <th>${studyInstance.title}</th> 47 </g:each> 48 </tr> 49 </thead> 50 </g:if> 51 <% 52 // Determine a union of the fields from all studies, in order 53 // to show a proper list. We want every field to appear just once, 54 // so the list is filtered for unique values 55 studyFields = studyList[0].giveDomainFields() + studyList*.giveTemplateFields().flatten().unique() 56 %> 39 57 <!-- Show all template and domain fields, if filled --> 40 <g:each in="${studyInstance.giveFields()}" var="field"> 41 <g:if test="${studyInstance.getFieldValue(field.name)}"> 58 <g:each in="${studyFields}" var="field"> 59 <% 60 // If a value is not set for any of the selected studies, the 61 // field should not appear in the list 62 showField = true in studyList.collect { it.fieldExists( field.name ) && it.getFieldValue( field.name ) != null }.flatten() 63 %> 64 <g:if test="${showField}"> 42 65 <tr> 43 66 <td>${field}</td> 44 <td>${studyInstance.getFieldValue(field.name)}</td> 67 <g:each in="${studyList}" var="studyInstance"> 68 <td>${studyInstance.getFieldValue(field.name)}</td> 69 </g:each> 45 70 </tr> 46 71 </g:if> … … 50 75 <tr> 51 76 <td>Events</td> 52 <td> 53 <g:if test="${studyInstance.giveEventTemplates().size()==0}"> 54 - 55 </g:if> 56 <g:else> 57 ${studyInstance.giveEventTemplates().name.join(", ")} 58 </g:else> 59 </td> 77 <g:each in="${studyList}" var="studyInstance"> 78 <td> 79 <g:if test="${studyInstance.giveEventTemplates().size()==0}"> 80 - 81 </g:if> 82 <g:else> 83 ${studyInstance.giveEventTemplates().name.join(", ")} 84 </g:else> 85 </td> 86 </g:each> 60 87 </tr> 61 88 <tr> 62 89 <td>Sampling events</td> 63 <td> 64 <g:if test="${studyInstance.giveSamplingEventTemplates().size()==0}"> 65 - 66 </g:if> 67 <g:else> 68 ${studyInstance.giveSamplingEventTemplates().name.join(", ")} 69 </g:else> 70 </td> 90 <g:each in="${studyList}" var="studyInstance"> 91 <td> 92 <g:if test="${studyInstance.giveSamplingEventTemplates().size()==0}"> 93 - 94 </g:if> 95 <g:else> 96 ${studyInstance.giveSamplingEventTemplates().name.join(", ")} 97 </g:else> 98 </td> 99 </g:each> 71 100 </tr> 72 101 <tr> 73 102 <td>Readers</td> 74 <td> 75 <g:if test="${studyInstance.readers.size()==0}"> 76 - 77 </g:if> 78 <g:else> 79 <g:each in="${studyInstance.readers}" var="r" status="i"> 80 <g:if test="${i > 0}">, </g:if> 81 <g:link controller="user" action="show" id="${r.id}">${r?.encodeAsHTML()}</g:link> 82 </g:each> 83 </g:else> 84 </td> 103 <g:each in="${studyList}" var="studyInstance"> 104 <td> 105 <g:if test="${studyInstance.readers.size()==0}"> 106 - 107 </g:if> 108 <g:else> 109 <g:each in="${studyInstance.readers}" var="r" status="i"> 110 <g:if test="${i > 0}">, </g:if> 111 <g:link controller="user" action="show" id="${r.id}">${r?.encodeAsHTML()}</g:link> 112 </g:each> 113 </g:else> 114 </td> 115 </g:each> 85 116 </tr> 86 117 <tr> 87 118 <td>Editors</td> 88 <td> 89 <g:if test="${studyInstance.editors.size()==0}"> 90 - 91 </g:if> 92 <g:else> 93 <g:each in="${studyInstance.editors}" var="r" status="i"> 94 <g:if test="${i > 0}">, </g:if> 95 <g:link controller="user" action="show" id="${r.id}">${r?.encodeAsHTML()}</g:link> 96 </g:each> 97 </g:else> 98 </td> 119 <g:each in="${studyList}" var="studyInstance"> 120 <td> 121 <g:if test="${studyInstance.editors.size()==0}"> 122 - 123 </g:if> 124 <g:else> 125 <g:each in="${studyInstance.editors}" var="r" status="i"> 126 <g:if test="${i > 0}">, </g:if> 127 <g:link controller="user" action="show" id="${r.id}">${r?.encodeAsHTML()}</g:link> 128 </g:each> 129 </g:else> 130 </td> 131 </g:each> 99 132 </tr> 100 133 … … 103 136 104 137 <div id="subjects"> 105 <g:each in="${studyInstance.giveSubjectTemplates()}" var="template"> 138 139 <g:if test="${studyList*.subjects.flatten().size()==0}"> 140 No subjects in the selected studies 141 </g:if> 142 <g:else> 106 143 <table> 107 144 <thead> 108 145 <tr> 146 <th></th> 109 147 <g:each in="${new dbnp.studycapturing.Subject().giveDomainFields()}" var="field"> 110 148 <th>${field}</th> 111 149 </g:each> 112 <g:each in="${template.fields}" var="field"> 150 151 <% 152 // Determine a union of the fields for all different 153 // subjects in all studies. In order to show a proper list. 154 // We want every field to appear just once, 155 // so the list is filtered for unique values 156 subjectTemplates = studyList*.giveSubjectTemplates().flatten().unique() 157 subjectFields = subjectTemplates*.fields.flatten().unique() 158 159 showSubjectFields = subjectFields 160 161 /* 162 * These lines are rewritten because 163 * performance sucked 164 * 165 * // These took about 9 seconds (for 31 subjects and 166 * allSubjects = studyList*.subjects.flatten() 167 * 168 * subjectFields = subjectFields.findAll { subjectField -> 169 * ( true in allSubjects.collect { subject -> subject.fieldExists( subjectField.name ) && subject.getFieldValue( subjectField.name ) != null }.flatten() ) 170 * } 171 */ 172 173 // Filter out all fields that are left blank for all subjects 174 allSubjects = studyList*.subjects.flatten() 175 176 showSubjectFields = [] 177 subjectFields.each { subjectField -> 178 for( subject in allSubjects ) 179 { 180 // If the field is filled for this subject, we have to 181 // show the field and should not check any other 182 // subjects (hence the break) 183 if( subject.fieldExists( subjectField.name ) && subject.getFieldValue( subjectField.name ) ) { 184 showSubjectFields << subjectField; 185 break; 186 } 187 } 188 } 189 190 %> 191 192 <g:each in="${showSubjectFields}" var="field"> 113 193 <th>${field}</th> 114 194 </g:each> 195 115 196 </tr> 116 197 </thead> 117 118 <% 119 subjects = studyInstance.subjects.findAll {it.template == template}; 120 sortedSubjects = subjects.sort( { a, b -> a.name <=> b.name } as Comparator ) 121 %> 122 <g:each in="${sortedSubjects}" var="s" status="i"> 123 <tr class="${(i % 2) == 0 ? 'odd' : 'even'}"> 124 <g:each in="${s.giveDomainFields()}" var="field"> 125 <td>${s.getFieldValue(field.name)}</td> 126 </g:each> 127 <g:each in="${template.fields}" var="field"> 128 <td> 129 ${s.getFieldValue(field.name)} 130 </td> 198 199 <g:set var="i" value="${1}" /> 200 201 <g:each in="${studyList}" var="studyInstance"> 202 <% 203 // Sort subjects by name 204 subjects = studyInstance.subjects; 205 sortedSubjects = subjects.sort( { a, b -> a.name <=> b.name } as Comparator ) 206 %> 207 208 <g:each in="${sortedSubjects}" var="subject" status="j"> 209 <tr class="${(i % 2) == 0 ? 'odd' : 'even'}"> 210 <g:if test="${j==0}"> 211 <td class="studytitle" rowspan="${sortedSubjects.size()}"> 212 ${studyInstance.title} 213 </td> 214 </g:if> 215 <g:each in="${subject.giveDomainFields()}" var="field"> 216 <td>${subject.getFieldValue(field.name)}</td> 217 </g:each> 218 219 <g:each in="${showSubjectFields}" var="field"> 220 <td> 221 <g:if test="${subject.fieldExists(field.name)}"> 222 ${subject.getFieldValue(field.name)} 223 </g:if> 224 <g:else> 225 N/A 226 </g:else> 227 </td> 228 </g:each> 229 230 </tr> 231 <g:set var="i" value="${i + 1}" /> 131 232 </g:each> 132 </tr> 133 </g:each> 134 233 </g:each> 135 234 </table> 136 137 </g:each> 235 </g:else> 138 236 </div> 139 237 140 238 <div id="events"> 141 <g:if test="${study Instance.events.size()==0}">142 No events in th is study239 <g:if test="${studyList*.events.flatten().size()==0 && studyInstance*.samplingEvents.flatten().size()==0 }"> 240 No events in these studies 143 241 </g:if> 144 242 <g:else> … … 147 245 <thead> 148 246 <tr> 247 <th></th> 149 248 <th>Start time</th> 150 249 <th>Duration</th> … … 155 254 </thead> 156 255 157 <% 158 // Sort events by starttime and duration 159 events = studyInstance.events + studyInstance.samplingEvents; 160 sortedEvents = events.sort( { a, b -> 161 a.startTime == b.startTime ? 162 a.getDuration().toMilliseconds() <=> b.getDuration().toMilliseconds() : 163 a.startTime <=> b.startTime 164 } as Comparator ) 165 %> 166 167 <g:each in="${sortedEvents}" var="event" status="i"> 168 <tr class="${(i % 2) == 0 ? 'odd' : 'even'}"> 169 <td>${event.getPrettyDuration(studyInstance.startDate,event.startTime)}</td> 170 <td>${event.getPrettyDuration()}</td> 171 <td>${event.template.name}</td> 172 <td> 173 <g:if test="${event instanceof dbnp.studycapturing.SamplingEvent}"> 174 <g:checkBox name="samplingEvent" disabled="${true}" value="${true}"/> 256 <g:set var="i" value="${1}" /> 257 258 <g:each in="${studyList}" var="studyInstance"> 259 <% 260 // Sort events by starttime and duration 261 events = studyInstance.events + studyInstance.samplingEvents; 262 sortedEvents = events.sort( { a, b -> 263 a.startTime == b.startTime ? 264 a.getDuration().toMilliseconds() <=> b.getDuration().toMilliseconds() : 265 a.startTime <=> b.startTime 266 } as Comparator ) 267 %> 268 269 <g:each in="${sortedEvents}" var="event" status="j"> 270 <tr class="${(i % 2) == 0 ? 'odd' : 'even'}"> 271 <g:if test="${j==0}"> 272 <td class="studytitle" rowspan="${sortedEvents.size()}"> 273 ${studyInstance.title} 274 </td> 175 275 </g:if> 176 <g:else> 177 <g:checkBox name="event" disabled="${true}" value="${false}" /> 178 </g:else> 179 </td> 180 <td> 181 <g:set var="fieldCounter" value="${1}" /> 182 <g:each in="${event.giveTemplateFields()}" var="field"> 183 <g:if test="${event.getFieldValue(field.name)}"> 184 <g:if test="${fieldCounter > 1}">, </g:if> 185 ${field.name} = ${event.getFieldValue( field.name )} 186 <g:set var="fieldCounter" value="${fieldCounter + 1}" /> 276 <td>${event.getPrettyDuration(studyInstance.startDate,event.startTime)}</td> 277 <td>${event.getPrettyDuration()}</td> 278 <td>${event.template.name}</td> 279 <td> 280 <g:if test="${event instanceof dbnp.studycapturing.SamplingEvent}"> 281 <g:checkBox name="samplingEvent" disabled="${true}" value="${true}"/> 187 282 </g:if> 188 </g:each> 189 </td> 190 </tr> 283 <g:else> 284 <g:checkBox name="event" disabled="${true}" value="${false}" /> 285 </g:else> 286 </td> 287 <td> 288 <g:set var="fieldCounter" value="${1}" /> 289 <g:each in="${event.giveTemplateFields()}" var="field"> 290 <g:if test="${event.getFieldValue(field.name)}"> 291 <g:if test="${fieldCounter > 1}">, </g:if> 292 ${field.name} = ${event.getFieldValue( field.name )} 293 <g:set var="fieldCounter" value="${fieldCounter + 1}" /> 294 </g:if> 295 </g:each> 296 </td> 297 </tr> 298 299 <g:set var="i" value="${i + 1}" /> 300 </g:each> 191 301 </g:each> 192 193 302 </table> 194 303 … … 197 306 198 307 <div id="event-group"> 199 <g:if test="${study Instance.eventGroups.size()==0}">308 <g:if test="${studyList*.eventGroups.flatten().size()==0}"> 200 309 No event groups in this study 201 310 </g:if> 202 311 <g:else> 312 <% 313 // Determine a union of the event templates for all different 314 // eventgroups in all studies, in order to show a proper list. 315 // We want every field to appear just once, 316 // so the list is filtered for unique values 317 groupTemplates = studyList*.giveAllEventTemplates().flatten().unique() 318 subjectFields = subjectTemplates*.fields.flatten().unique() 319 %> 203 320 <table> 204 <tr> 205 <td><b>Name</b></td> 206 <td colspan="${studyInstance.giveAllEventTemplates().size()}"><b>Events</b></td> 207 <td><b>Subjects</b></td> 208 </tr> 209 <tr> 210 <td></td> 211 <g:each in="${studyInstance.giveAllEventTemplates()}" var="eventTemplate"> 212 <td><b>${eventTemplate.name}</b></td> 321 <thead> 322 <tr> 323 <th></th> 324 <th>Name</th> 325 <th colspan="${groupTemplates.size()}">Events</th> 326 <th>Subjects</th> 327 </tr> 328 <tr> 329 <th></th> 330 <th></th> 331 <g:each in="${groupTemplates}" var="eventTemplate"> 332 <th>${eventTemplate.name}</th> 333 </g:each> 334 <th></th> 335 </tr> 336 </thead> 337 338 <g:set var="i" value="${1}" /> 339 340 <g:each in="${studyList}" var="studyInstance"> 341 342 <g:each in="${studyInstance.eventGroups}" var="eventGroup" status="j"> 343 <tr class="${(i % 2) == 0 ? 'odd' : 'even'}"> 344 <g:if test="${j==0}"> 345 <td class="studytitle" rowspan="${studyInstance.eventGroups.size()}"> 346 ${studyInstance.title} 347 </td> 348 </g:if> 349 <td>${eventGroup.name}</td> 350 351 <g:each in="${groupTemplates}" var="currentEventTemplate"> 352 <td> 353 <g:each in="${eventGroup.events}" var="event"> 354 <g:if test="${event.template.name==currentEventTemplate.name}"> 355 356 <g:set var="fieldCounter" value="${1}" /> 357 <g:each in="${event.giveTemplateFields()}" var="field"> 358 <g:if test="${event.getFieldValue(field.name)}"> 359 <g:if test="${fieldCounter > 1}">, </g:if> 360 ${field.name} = ${event.getFieldValue( field.name )} 361 <g:set var="fieldCounter" value="${fieldCounter + 1}" /> 362 </g:if> 363 </g:each> 364 </g:if> 365 </g:each> 366 </td> 367 </g:each> 368 <td> 369 <% sortedGroupSubjects = eventGroup.subjects.sort( { a, b -> a.name <=> b.name } as Comparator ) %> 370 ${sortedGroupSubjects.name.join( ', ' )} 371 </td> 372 </tr> 373 374 <g:set var="i" value="${i + 1}" /> 213 375 </g:each> 214 <td></td> 215 </tr> 216 <g:each in="${studyInstance.eventGroups}" var="eventGroup"> 217 <tr> 218 <td>${eventGroup.name}</td> 219 220 <g:each in="${studyInstance.giveAllEventTemplates()}" var="currentEventTemplate"> 221 <td> 222 <g:each in="${eventGroup.events}" var="event"> 223 <g:if test="${event.template.name==currentEventTemplate.name}"> 224 225 <g:set var="fieldCounter" value="${1}" /> 226 <g:each in="${event.giveTemplateFields()}" var="field"> 227 <g:if test="${event.getFieldValue(field.name)}"> 228 <g:if test="${fieldCounter > 1}">, </g:if> 229 ${field.name} = ${event.getFieldValue( field.name )} 230 <g:set var="fieldCounter" value="${fieldCounter + 1}" /> 231 </g:if> 232 </g:each> 233 </g:if> 234 </g:each> 235 </td> 236 </g:each> 237 <td> 238 <% sortedGroupSubjects = eventGroup.subjects.sort( { a, b -> a.name <=> b.name } as Comparator ) %> 239 ${sortedGroupSubjects.name.join( ', ' )} 240 </td> 241 </tr> 242 </g:each> 376 377 </g:each> 378 243 379 </table> 244 380 </g:else> … … 246 382 247 383 <div id="assays"> 248 <g:if test="${study Instance.assays.size()==0}">249 No assays in th is study384 <g:if test="${studyList*.assays.flatten().size()==0}"> 385 No assays in these studies 250 386 </g:if> 251 387 <g:else> … … 253 389 <thead> 254 390 <tr> 391 <th></th> 255 392 <th width="100">Assay Name</th> 256 393 <th width="100">Module</th> … … 261 398 </tr> 262 399 </thead> 263 <g:each in="${studyInstance.assays}" var="assay" status="i"> 264 <tr class="${(i % 2) == 0 ? 'odd' : 'even'}"> 265 <td>${assay.name}</td> 266 <td>${assay.module.name}</td> 267 <td>${assay.module.type}</td> 268 <td>${assay.module.platform}</td> 269 <td>${assay.module.url}</td> 270 <td> 271 <% sortedAssaySamples = assay.samples.sort( { a, b -> a.name <=> b.name } as Comparator ) %> 272 ${sortedAssaySamples.name.join( ', ' )} 273 </td> 274 </tr> 275 </g:each> 276 400 <g:set var="i" value="${1}" /> 401 402 <g:each in="${studyList}" var="studyInstance"> 403 <g:each in="${studyInstance.assays}" var="assay" status="j"> 404 <tr class="${(i % 2) == 0 ? 'odd' : 'even'}"> 405 <g:if test="${j==0}"> 406 <td class="studytitle" rowspan="${studyInstance.assays.size()}"> 407 ${studyInstance.title} 408 </td> 409 </g:if> 410 <td>${assay.name}</td> 411 <td>${assay.module.name}</td> 412 <td>${assay.module.type}</td> 413 <td>${assay.module.platform}</td> 414 <td>${assay.module.url}</td> 415 <td> 416 <% sortedAssaySamples = assay.samples.sort( { a, b -> a.name <=> b.name } as Comparator ) %> 417 ${sortedAssaySamples.name.join( ', ' )} 418 </td> 419 </tr> 420 <g:set var="i" value="${i + 1}" /> 421 422 </g:each> 423 </g:each> 277 424 </table> 278 425 </g:else> … … 280 427 281 428 <div id="persons"> 282 <g:if test="${studyInstance.persons.size()==0}"> 283 No persons involved in this study 429 <% 430 // Determine a list of all persons 431 allPersons = studyList*.persons*.person.flatten().unique() 432 %> 433 <g:if test="${allPersons.size()==0}"> 434 No persons involved in these studies 284 435 </g:if> 285 436 <g:else> … … 289 440 <th>Name</th> 290 441 <th>Affiliations</th> 291 <th>Role</th>292 442 <th>Phone</th> 293 443 <th>Email</th> 444 <g:each in="${studyList}" var="studyInstance"> 445 <th>${studyInstance.title}</th> 446 </g:each> 294 447 </thead> 295 448 </tr> 296 <g:each in="${ studyInstance.persons}" var="studyperson" status="i">449 <g:each in="${allPersons}" var="person" status="i"> 297 450 <tr class="${(i % 2) == 0 ? 'odd' : 'even'}"> 298 <td>${ studyperson.person.firstName} ${studyperson.person.prefix} ${studyperson.person.lastName}</td>451 <td>${person.firstName} ${person.prefix} ${person.lastName}</td> 299 452 <td> 300 ${ studyperson.person.affiliations.join(', ')}453 ${person.affiliations.join(', ')} 301 454 </td> 302 <td>${studyperson.role.name}</td> 303 <td>${studyperson.person.phone}</td> 304 <td>${studyperson.person.email}</td> 455 <td>${person.phone}</td> 456 <td>${person.email}</td> 457 <g:each in="${studyList}" var="studyInstance"> 458 <% 459 studyperson = studyInstance.persons.find { it.person == person } 460 %> 461 <td> 462 <g:if test="${studyperson}"> 463 ${studyperson.role.name} 464 </g:if> 465 </td> 466 </g:each> 467 305 468 </tr> 306 469 </g:each> … … 310 473 311 474 <div id="publications"> 312 <g:if test="${studyInstance.publications.size()==0}"> 313 No publications attached to this study 475 <% 476 // Determine a list of all persons 477 allPublications = studyList*.publications.flatten().unique() 478 %> 479 <g:if test="${allPublications.size()==0}"> 480 No publications attached to these studies 314 481 </g:if> 315 482 <g:else> … … 320 487 <th>Authors</th> 321 488 <th>Comments</th> 489 <g:each in="${studyList}" var="studyInstance"> 490 <th>${studyInstance.title}</th> 491 </g:each> 322 492 </thead> 323 493 </tr> 324 <g:each in="${ studyInstance.publications}" var="publication" status="i">494 <g:each in="${allPublications}" var="publication" status="i"> 325 495 <tr class="${(i % 2) == 0 ? 'odd' : 'even'}"> 326 496 <td>${publication.title}</td> 327 497 <td> 328 ${publication.author list}498 ${publication.authorsList} 329 499 </td> 330 <td>${publication.comment}</td> 500 <td>${publication.comments}</td> 501 <g:each in="${studyList}" var="studyInstance"> 502 <td> 503 <g:if test="${publication in studyInstance.publications}"> 504 x 505 </g:if> 506 </td> 507 </g:each> 331 508 </tr> 332 509 </g:each> … … 340 517 <div class="buttons"> 341 518 <g:form> 342 <g:hiddenField name="id" value="${studyInstance?.id}" /> 343 <span class="button"><g:actionSubmit class="edit" action="edit" value="${message(code: 'default.button.edit.label', default: 'Edit')}" /></span> 344 <span class="button"><g:actionSubmit class="delete" action="delete" value="${message(code: 'default.button.delete.label', default: 'Delete')}" onclick="return confirm('${message(code: 'default.button.delete.confirm.message', default: 'Are you sure?')}');" /></span> 519 <g:if test="${studyList.size() == 1}"> 520 <g:set var="studyInstance" value="${studyList[0]}" /> 521 <g:hiddenField name="id" value="${studyInstance?.id}" /> 522 <span class="button"><g:actionSubmit class="edit" action="edit" value="${message(code: 'default.button.edit.label', default: 'Edit')}" /></span> 523 <span class="button"><g:actionSubmit class="delete" action="delete" value="${message(code: 'default.button.delete.label', default: 'Delete')}" onclick="return confirm('${message(code: 'default.button.delete.confirm.message', default: 'Are you sure?')}');" /></span> 524 </g:if> 345 525 <span class="button"><g:link class="backToList" action="list">Back to list</g:link></span> 346 526 </g:form> 347 527 </div> 528 348 529 </div> 349 530 </body>
Note: See TracChangeset
for help on using the changeset viewer.