Changeset 536 for trunk/grails-app/views
- Timestamp:
- Jun 7, 2010, 9:20:00 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/views/study/show.gsp
r522 r536 1 1 2 2 <%@ page import="dbnp.studycapturing.Study" %> 3 <%@ page import="dbnp.studycapturing.EventGroup" %> 3 4 <%@ page import="dbnp.studycapturing.RelTime" %> 4 5 <html> … … 20 21 show: function(event, ui) { 21 22 // If the events tab is shown, the timeline should be redrawn 22 if( ui.tab.hash == '#events ' && !timelineloaded ) {23 if( ui.tab.hash == '#events-timeline' && !timelineloaded ) { 23 24 loadTimeline( 'eventstimeline', 'eventtitles', 0 ); 24 25 timelineloaded = true; … … 86 87 87 88 <g:set var="bandNr" value="${bandNr+1}" /> 88 89 <g:each in="${study.eventGroups}" var="eventGroup" status="i"> 89 <% 90 def sortedEventGroups = study.eventGroups.sort( { a, b -> 91 return a.name <=> b.name; 92 } as Comparator ); 93 94 def orphans = study.getOrphanEvents(); 95 if( orphans.size() > 0 ) { 96 sortedEventGroups.add( new EventGroup( 97 id: -1, 98 name: 'No group', 99 events: orphans, 100 subjects: [] 101 )); 102 } 103 104 %> 105 <g:each in="${sortedEventGroups}" var="eventGroup" status="i"> 90 106 91 107 //------------- Eventgroup ${bandNr} --------------- … … 95 111 96 112 // Load events for this eventsource (using jquery) 97 var event_url = '${createLink(controller:'study', action:'events', id: eventGroup.id, params: [startDate: study.startDate.getTime()])}';113 var event_url = '${createLink(controller:'study', action:'events', id:( eventGroup.id ? eventGroup.id : -1 ), params: [ startDate: study.startDate.getTime(), study: study.id ])}'; 98 114 $.getJSON(event_url, $.callback( _loadJSONEvents, [0, ${bandNr}, eventSources[${bandNr}], overviewEventSource, event_url] ) ); 99 115 … … 156 172 bandTitleInfo[ timelineNr ][ ${bandNr} ] = { 157 173 title: "${eventGroup.name}", 174 className: "<g:if test="${ eventGroup.id == -1 || !eventGroup.id }">no_group</g:if>", 158 175 subjects: "${showSubjects}" 159 176 }; … … 163 180 164 181 // Synchronize all bands 165 <g:each in="${s tudy.eventGroups}" var="eventGroup" status="i">182 <g:each in="${sortedEventGroups}" var="eventGroup" status="i"> 166 183 bandInfos[${i + datesBandNr +1}].syncWith = ${datesBandNr}; 167 184 </g:each> … … 185 202 <li><a href="#study">Study Information</a></li> 186 203 <li><a href="#subjects">Subjects</a></li> 187 <li><a href="#events ">Events</a></li>188 <li><a href="#event -group">Event Groups</a></li>204 <li><a href="#events-timeline">Events timeline</a></li> 205 <li><a href="#events-table">Events table</a></li> 189 206 <li><a href="#assays">Assays</a></li> 207 <li><a href="#samples">Samples</a></li> 190 208 <li><a href="#persons">Persons</a></li> 191 209 <li><a href="#publications">Publications</a></li> … … 313 331 // so the list is filtered for unique values 314 332 subjectTemplates = studyList*.giveSubjectTemplates().flatten().unique() 315 subjectFields = subjectTemplates*.fields.flatten().unique() 316 317 showSubjectFields = subjectFields 318 319 /* 333 if( !subjectTemplates ) { 334 subjectTemplates = []; 335 subjectFields = []; 336 } else { 337 subjectFields = subjectTemplates*.fields.flatten().unique() 338 if( !subjectFields ) { 339 subjectFields = []; 340 } 341 } 342 343 /* 320 344 * These lines are rewritten because 321 345 * performance sucked … … 393 417 </div> 394 418 395 <div id="events ">419 <div id="events-timeline"> 396 420 <g:if test="${studyList*.events.flatten().size()==0 && studyInstance*.samplingEvents.flatten().size()==0 }"> 397 421 No events in these studies … … 472 496 </div> 473 497 474 <div id="event -group">498 <div id="events-table"> 475 499 <g:if test="${studyList*.eventGroups.flatten().size()==0}"> 476 500 No event groups in this study … … 510 534 511 535 <g:each in="${studyList}" var="studyInstance"> 512 513 <g:each in="${studyInstance.eventGroups}" var="eventGroup" status="j"> 536 <% 537 def sortedEventGroups = studyInstance.eventGroups.sort( { a, b -> 538 return a.name <=> b.name; 539 } as Comparator ); 540 541 def orphans = studyInstance.getOrphanEvents(); 542 if( orphans.size() > 0 ) { 543 sortedEventGroups.add( new EventGroup( 544 id: -1, 545 name: 'No group', 546 events: orphans, 547 subjects: [] 548 )); 549 } 550 551 %> 552 <g:each in="${sortedEventGroups}" var="eventGroup" status="j"> 514 553 <tr class="${(i % 2) == 0 ? 'odd' : 'even'}"> 515 554 <g:if test="${multipleStudies && j==0}"> 516 <td class="studytitle" rowspan="${s tudyInstance.eventGroups.size()}">555 <td class="studytitle" rowspan="${sortedEventGroups.size()}"> 517 556 ${studyInstance.title} 518 557 </td> … … 595 634 </g:each> 596 635 </g:each> 636 </table> 637 </g:else> 638 </div> 639 640 <div id="samples"> 641 642 <g:if test="${studyList*.samples.flatten().size()==0}"> 643 No samples in the selected studies 644 </g:if> 645 <g:else> 646 <table> 647 <thead> 648 <tr> 649 <g:if test="${multipleStudies}"> 650 <th></th> 651 </g:if> 652 <g:each in="${new dbnp.studycapturing.Sample().giveDomainFields()}" var="field"> 653 <th>${field}</th> 654 </g:each> 655 656 <% 657 // Determine a union of the fields for all different 658 // samples in all studies. In order to show a proper list. 659 // We want every field to appear just once, 660 // so the list is filtered for unique values 661 sampleTemplates = studyList*.giveSampleTemplates().flatten().unique() 662 663 if( !sampleTemplates ) { 664 sampleTemplates = []; 665 sampleFields = []; 666 showSampleFields = []; 667 } else { 668 sampleFields = sampleTemplates*.fields.flatten().unique() 669 if( !sampleFields ) { 670 sampleFields = []; 671 showSampleFields = []; 672 } else { 673 // Filter out all fields that are left blank for all samples 674 allSamples = studyList*.samples.flatten() 675 676 showSampleFields = []; 677 sampleFields.each { sampleField -> 678 for( sample in allSamples ) 679 { 680 // If the field is filled for this subject, we have to 681 // show the field and should not check any other 682 // samples (hence the break) 683 if( sample.fieldExists( sampleField.name ) && sample.getFieldValue( sampleField.name ) ) { 684 showSampleFields << sampleField; 685 break; 686 } 687 } 688 } 689 } 690 } 691 %> 692 693 <g:each in="${showSampleFields}" var="field"> 694 <th>${field}</th> 695 </g:each> 696 697 </tr> 698 </thead> 699 700 <g:set var="i" value="${1}" /> 701 702 <g:each in="${studyList}" var="studyInstance"> 703 <% 704 // Sort samples by name 705 samples = studyInstance.samples; 706 sortedSamples = samples.sort( { a, b -> a.name <=> b.name } as Comparator ) 707 %> 708 709 <g:each in="${sortedSamples}" var="sample" status="j"> 710 <tr class="${(i % 2) == 0 ? 'odd' : 'even'}"> 711 <g:if test="${multipleStudies && j==0}"> 712 <td class="studytitle" rowspan="${sortedSamples.size()}"> 713 ${studyInstance.title} 714 </td> 715 </g:if> 716 <g:each in="${sample.giveDomainFields()}" var="field"> 717 <td>${sample.getFieldValue(field.name)}</td> 718 </g:each> 719 720 <g:each in="${showSampleFields}" var="field"> 721 <td> 722 <g:if test="${sample.fieldExists(field.name)}"> 723 ${sample.getFieldValue(field.name)} 724 </g:if> 725 <g:else> 726 N/A 727 </g:else> 728 </td> 729 </g:each> 730 731 </tr> 732 <g:set var="i" value="${i + 1}" /> 733 </g:each> 734 </g:each> 735 597 736 </table> 598 737 </g:else>
Note: See TracChangeset
for help on using the changeset viewer.