Changeset 629 for trunk/grails-app/views


Ignore:
Timestamp:
Jun 28, 2010, 10:17:03 AM (13 years ago)
Author:
duh
Message:
  • fixed bug in study view page caused by revision # 602
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/grails-app/views/study/show.gsp

    r578 r629  
    1414     
    1515      // Number of timelines that should be loaded
    16       var numTimelines = ${studyList.size()};
     16      var numTimelines = ${studyList?.size()};
    1717     
    1818      // This method is called on the event body.onLoad
     
    9393
    9494                def orphans = study.getOrphanEvents();
    95                 if( orphans.size() > 0 ) {
     95                if( orphans?.size() > 0 ) {
    9696                  sortedEventGroups.add( new EventGroup(
    9797                    id: -1,
     
    138138                  // We can only show appr. 30 characters per line and as many lines as there are events
    139139                  def charsPerLine = 30;
    140                   def numEvents = eventGroup.events.size();
     140                  def numEvents = eventGroup.events?.size();
    141141                  def maxChars = numEvents * charsPerLine;
    142142
    143143                  // If the subjects will fit, show them all
    144                   if( simpleSubjects.size() < maxChars ) {
     144                  if( simpleSubjects?.size() < maxChars ) {
    145145                    showSubjects = simpleSubjects;
    146146                  } else {
     
    152152                    sortedGroupSubjects.each { subject ->
    153153                      if( id > 0 ) {
    154                         println( "ID: " + id + " - " + subjectNames.size() + " - " + subject.name.size() + " - " + maxChars );
    155                         if( subjectNames.size() + subject.name.size() < maxChars - 15 ) {
     154                        println( "ID: " + id + " - " + subjectNames?.size() + " - " + subject.name?.size() + " - " + maxChars );
     155                        if( subjectNames?.size() + subject.name?.size() < maxChars - 15 ) {
    156156                          subjectNames += ", " + subject.name;
    157157                        } else {
     
    163163
    164164                    // Add a postfix
    165                     subjectNames += " and " + ( sortedGroupSubjects.size() - id ) + " more";
     165                    subjectNames += " and " + ( sortedGroupSubjects?.size() - id ) + " more";
    166166
    167167                    showSubjects = subjectNames;
     
    227227              // to show a proper list. We want every field to appear just once,
    228228              // so the list is filtered for unique values
    229               studyFields = studyList[0].giveDomainFields() + studyList*.giveTemplateFields().flatten().unique()
     229              studyFields = studyList[0].giveDomainFields() + studyList*.giveTemplateFields()?.flatten().unique()
    230230            %>
    231231            <!-- Show all template and domain fields, if filled -->
     
    234234                // If a value is not set for any of the selected studies, the
    235235                // field should not appear in the list
    236                 showField = true in studyList.collect { it.fieldExists( field.name ) && it.getFieldValue( field.name ) != null }.flatten()
     236                showField = true in studyList.collect { it.fieldExists( field.name ) && it.getFieldValue( field.name ) != null }?.flatten()
    237237              %>
    238238              <g:if test="${showField}">
     
    251251              <g:each in="${studyList}" var="studyInstance">
    252252                <td>
    253                   <g:if test="${studyInstance.giveEventTemplates().size()==0}">
     253                  <g:if test="${studyInstance.giveEventTemplates()?.size()==0}">
    254254                    -
    255255                  </g:if>
     
    264264              <g:each in="${studyList}" var="studyInstance">
    265265                <td>
    266                   <g:if test="${studyInstance.giveSamplingEventTemplates().size()==0}">
     266                  <g:if test="${studyInstance.giveSamplingEventTemplates()?.size()==0}">
    267267                    -
    268268                  </g:if>
     
    277277              <g:each in="${studyList}" var="studyInstance">
    278278                <td>
    279                   <g:if test="${studyInstance.readers.size()==0}">
     279                  <g:if test="${studyInstance.readers?.size()==0}">
    280280                    -
    281281                  </g:if>
     
    293293              <g:each in="${studyList}" var="studyInstance">
    294294                <td>
    295                   <g:if test="${studyInstance.editors.size()==0}">
     295                  <g:if test="${studyInstance.editors?.size()==0}">
    296296                    -
    297297                  </g:if>
     
    311311        <div id="subjects">
    312312
    313           <g:if test="${studyList*.subjects.flatten().size()==0}">
     313          <g:if test="${studyList*.subjects?.flatten()?.size()==0}">
    314314            No subjects in the selected studies
    315315          </g:if>
     
    330330                    // We want every field to appear just once,
    331331                    // so the list is filtered for unique values
    332                     subjectTemplates = studyList*.giveSubjectTemplates().flatten().unique()
     332                    subjectTemplates = studyList*.giveSubjectTemplates()?.flatten().unique()
    333333                    if( !subjectTemplates ) {
    334334                      subjectTemplates = [];
    335335                      subjectFields = [];
    336336                    } else {
    337                       subjectFields = subjectTemplates*.fields.flatten().unique()
     337                      subjectFields = subjectTemplates*.fields?.flatten().unique()
    338338                      if( !subjectFields ) {
    339339                        subjectFields = [];
     
    346346                     *
    347347                     *   // These took about 9 seconds (for 31 subjects and
    348                      *   allSubjects = studyList*.subjects.flatten()
     348                     *   allSubjects = studyList*.subjects?.flatten()
    349349                     *
    350350                     *   subjectFields = subjectFields.findAll { subjectField ->
     
    354354
    355355                    // Filter out all fields that are left blank for all subjects
    356                     allSubjects = studyList*.subjects.flatten()
     356                    allSubjects = studyList*.subjects?.flatten()
    357357
    358358                    showSubjectFields = []
     
    390390                  <tr class="${(i % 2) == 0 ? 'odd' : 'even'}">
    391391                    <g:if test="${multipleStudies && j==0}">
    392                       <td class="studytitle" rowspan="${sortedSubjects.size()}">
     392                      <td class="studytitle" rowspan="${sortedSubjects?.size()}">
    393393                        ${studyInstance.title}
    394394                      </td>
     
    418418
    419419        <div id="events-timeline">
    420           <g:if test="${studyList*.events.flatten().size()==0 && studyInstance*.samplingEvents.flatten().size()==0 }">
     420          <g:if test="${studyList*.events?.flatten()?.size()==0 && studyInstance*.samplingEvents?.flatten()?.size()==0 }">
    421421            No events in these studies
    422422          </g:if>
     
    459459                    <tr class="${(i % 2) == 0 ? 'odd' : 'even'}">
    460460                      <g:if test="${multipleStudies && j==0}">
    461                         <td class="studytitle" rowspan="${sortedEvents.size()}">
     461                        <td class="studytitle" rowspan="${sortedEvents?.size()}">
    462462                          ${studyInstance.title}
    463463                        </td>
     
    497497
    498498        <div id="events-table">
    499           <g:if test="${studyList*.eventGroups.flatten().size()==0}">
     499          <g:if test="${studyList*.eventGroups?.flatten()?.size()==0}">
    500500            No event groups in this study
    501501          </g:if>
     
    506506              // We want every field to appear just once,
    507507              // so the list is filtered for unique values
    508               groupTemplates = studyList*.giveAllEventTemplates().flatten().unique()
     508              groupTemplates = studyList*.giveAllEventTemplates()?.flatten().unique()
    509509            %>
    510510            <table>
     
    515515                  </g:if>
    516516                  <th>Name</th>
    517                   <th colspan="${groupTemplates.size()}">Events</th>
     517                  <th colspan="${groupTemplates?.size()}">Events</th>
    518518                  <th>Subjects</th>
    519519                </tr>
     
    539539
    540540                  def orphans = studyInstance.getOrphanEvents();
    541                   if( orphans.size() > 0 ) {
     541                  if( orphans?.size() > 0 ) {
    542542                    sortedEventGroups.add( new EventGroup(
    543543                      id: -1,
     
    552552                  <tr class="${(i % 2) == 0 ? 'odd' : 'even'}">
    553553                    <g:if test="${multipleStudies && j==0}">
    554                       <td class="studytitle" rowspan="${sortedEventGroups.size()}">
     554                      <td class="studytitle" rowspan="${sortedEventGroups?.size()}">
    555555                        ${studyInstance.title}
    556556                      </td>
     
    591591
    592592        <div id="assays">
    593           <g:if test="${studyList*.assays.flatten().size()==0}">
     593          <g:if test="${studyList*.assays?.flatten()?.size()==0}">
    594594            No assays in these studies
    595595          </g:if>
     
    615615                  <tr class="${(i % 2) == 0 ? 'odd' : 'even'}">
    616616                    <g:if test="${multipleStudies && j==0}">
    617                       <td class="studytitle" rowspan="${studyInstance.assays.size()}">
     617                      <td class="studytitle" rowspan="${studyInstance.assays?.size()}">
    618618                        ${studyInstance.title}
    619619                      </td>
     
    639639        <div id="samples">
    640640
    641           <g:if test="${studyList*.samples.flatten().size()==0}">
     641          <g:if test="${studyList*.samples.flatten()?.size()==0}">
    642642            No samples in the selected studies
    643643          </g:if>
     
    709709                  <tr class="${(i % 2) == 0 ? 'odd' : 'even'}">
    710710                    <g:if test="${multipleStudies && j==0}">
    711                       <td class="studytitle" rowspan="${sortedSamples.size()}">
     711                      <td class="studytitle" rowspan="${sortedSamples?.size()}">
    712712                        ${studyInstance.title}
    713713                      </td>
     
    742742            allPersons = studyList*.persons*.person.flatten().unique()
    743743          %>
    744           <g:if test="${allPersons.size()==0}">
     744          <g:if test="${allPersons?.size()==0}">
    745745            No persons involved in these studies
    746746          </g:if>
     
    793793            allPublications = studyList*.publications.flatten().unique()
    794794          %>
    795           <g:if test="${allPublications.size()==0}">
     795          <g:if test="${allPublications?.size()==0}">
    796796            No publications attached to these studies
    797797          </g:if>
     
    838838    <div class="buttons">
    839839      <g:form>
    840         <g:if test="${studyList.size() == 1}">
     840        <g:if test="${studyList?.size() == 1}">
    841841          <g:set var="studyInstance" value="${studyList[0]}" />
    842842          <g:hiddenField name="id" value="${studyInstance?.id}" />
Note: See TracChangeset for help on using the changeset viewer.