Changeset 1200
- Timestamp:
- Nov 25, 2010, 1:56:54 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/views/study/show.gsp
r1188 r1200 522 522 // We want every field to appear just once, 523 523 // so the list is filtered for unique values 524 groupTemplates = studyList*.giveAllEventTemplates()?.flatten().unique() 524 def groupTemplates = studyList*.giveAllEventTemplates()?.flatten().unique() 525 def showTemplates = groupTemplates; 526 527 def showProperties = [:]; 528 def allEvents = studyList*.events.flatten() + studyList*.samplingEvents.flatten(); 529 def eventColumns = 0; 530 531 showTemplates.each { template -> 532 // We want to show all properties only once. If the properties are never filled 533 // we shouldn't show them at all. 534 def showFields = [] 535 template.fields.each { field -> 536 for( def event: allEvents.findAll { it.template == template } ) { 537 if( event.getFieldValue( field.name ) ) { 538 showFields << field; 539 break; 540 } 541 } 542 } 543 544 showProperties[ template.name ] = showFields; 545 546 // Compute the total number of columns under 'Events' (the +1 is 547 // because of the 'start time' column) 548 eventColumns += [ 1, showFields.size() + 1 ].max(); 549 } 550 525 551 %> 526 552 <table> … … 531 557 </g:if> 532 558 <th>Name</th> 533 <th colspan="${ groupTemplates?.size()}">Events</th>559 <th colspan="${eventColumns}">Events</th> 534 560 <th>Subjects</th> 535 561 </tr> … … 539 565 </g:if> 540 566 <th></th> 541 <g:each in="${groupTemplates}" var="eventTemplate"> 542 <th>${eventTemplate.name}</th> 567 <g:each in="${showTemplates}" var="eventTemplate"> 568 <th colspan="${[1, showProperties[ eventTemplate.name ].size() ].max() + 1}">${eventTemplate.name}</th> 569 </g:each> 570 <th></th> 571 </tr> 572 <tr class="templateFields"> 573 <g:if test="${multipleStudies}"> 574 <th></th> 575 </g:if> 576 <th></th> 577 <g:each in="${showTemplates}" var="eventTemplate"> 578 <th>start time</th> 579 <g:if test="${showProperties[ eventTemplate.name ].size() > 0}"> 580 <g:each in="${showProperties[ eventTemplate.name ]}" var="field"> 581 <th>${field.name}</th> 582 </g:each> 583 </g:if> 543 584 </g:each> 544 585 <th></th> … … 550 591 <g:each in="${studyList}" var="studyInstance"> 551 592 <% 552 def sortedEventGroups = studyInstance.eventGroups.sort( { a, b -> 593 // Sort the groups by name 594 def sortedEventGroups = studyInstance.eventGroups.sort( { a, b -> 553 595 return a.name <=> b.name; 554 596 } as Comparator ); 597 598 // Determine the number of rows per group (depending on the max 599 // number of events per template in a group) 600 def maxNumberEventsPerTemplate = [:]; 601 def rowsPerStudy = 0; 602 sortedEventGroups.each { group -> 603 def max = 1; 604 showTemplates.each { template -> 605 def num = ( group.events + group.samplingEvents ).findAll { it.template == template }.size(); 606 if( num > max ) 607 max = num; 608 } 609 maxNumberEventsPerTemplate[group.name] = max; 610 rowsPerStudy += max; 611 } 555 612 556 613 def orphans = studyInstance.getOrphanEvents(); … … 563 620 )); 564 621 } 565 566 622 %> 567 623 <g:each in="${sortedEventGroups}" var="eventGroup" status="j"> 568 <tr class="${(i % 2) == 0 ? 'odd' : 'even'}"> 569 <g:if test="${multipleStudies && j==0}"> 570 <td class="studytitle" rowspan="${sortedEventGroups?.size()}"> 571 ${studyInstance.title} 572 </td> 573 </g:if> 574 <td>${eventGroup.name}</td> 575 576 <g:each in="${groupTemplates}" var="currentEventTemplate"> 577 <td> 578 <g:each in="${eventGroup.events}" var="event"> 579 <g:if test="${event.template.name==currentEventTemplate.name}"> 580 581 <g:set var="fieldCounter" value="${1}" /> 582 <g:each in="${event.giveTemplateFields()}" var="field"> 583 <g:if test="${event.getFieldValue(field.name)}"> 584 <g:if test="${fieldCounter > 1}">, </g:if> 585 ${field.name} = <wizard:showTemplateField field="${field}" entity="${event}" /> 586 <g:set var="fieldCounter" value="${fieldCounter + 1}" /> 587 </g:if> 588 </g:each> 589 </g:if> 590 </g:each> 591 </td> 592 </g:each> 593 <td> 594 <% sortedGroupSubjects = eventGroup.subjects.sort( { a, b -> a.name <=> b.name } as Comparator ) %> 595 ${sortedGroupSubjects.name.join( ', ' )} 596 </td> 597 </tr> 624 <g:set var="n" value="${1}" /> 625 <g:while test="${n <= maxNumberEventsPerTemplate[ eventGroup.name ]}"> 626 627 <tr class="${(i % 2) == 0 ? 'odd' : 'even'}"> 628 <g:if test="${n == 1}"> 629 <g:if test="${multipleStudies && j==0}"> 630 <td class="studytitle" rowspan="${rowsPerStudy}"> 631 ${studyInstance.title} 632 </td> 633 </g:if> 634 <td rowspan="${maxNumberEventsPerTemplate[ eventGroup.name ]}">${eventGroup.name}</td> 635 </g:if> 636 637 <g:each in="${showTemplates}" var="currentEventTemplate"> 638 <g:if test="${showProperties[ currentEventTemplate.name ].size() == 0}"> 639 <td> </td> 640 </g:if> 641 <g:else> 642 <% 643 def templateEvents = (eventGroup.events + eventGroup.samplingEvents).findAll { it.template == currentEventTemplate }.sort { a, b -> a.startTime <=> b.startTime }.asType(List) 644 def event = templateEvents.size() >= n ? templateEvents[ n - 1 ] : null; 645 %> 646 <td class="templateFieldValue"><g:if test="${event}">${new RelTime( event.startTime ).toString()}</g:if></td> 647 <g:each in="${showProperties[ currentEventTemplate.name ]}" var="field"> 648 <td class="templateFieldValue"><wizard:showTemplateField field="${field}" entity="${event}" /></td> 649 </g:each> 650 </g:else> 651 </g:each> 652 653 <g:if test="${n == 1}"> 654 <td rowspan="${maxNumberEventsPerTemplate[ eventGroup.name ]}"> 655 <% sortedGroupSubjects = eventGroup.subjects.sort( { a, b -> a.name <=> b.name } as Comparator ) %> 656 ${sortedGroupSubjects.name.join( ', ' )} 657 </td> 658 </g:if> 659 </tr> 660 661 662 <g:set var="n" value="${n+1}" /> 663 </g:while> 598 664 599 665 <g:set var="i" value="${i + 1}" /> -
trunk/web-app/css/studies.css
r959 r1200 24 24 vertical-align: center; 25 25 } 26 27 .templateFields th { font-weight: normal; font-size: 0.8em; } 28 .templateFieldValue { font-size: 0.9em;} 26 29 27 30 /*
Note: See TracChangeset
for help on using the changeset viewer.