Changeset 201


Ignore:
Timestamp:
Feb 16, 2010, 3:13:09 PM (13 years ago)
Author:
jahn
Message:

Added some features: subgrouping by event groups and times, select all and select none, autmatic checking of all samples belonging to a subject and of all samples and subjects belonging to a study. Beatufied some outputs.

Ideally, there should be some extra functionality for automatically putting samples into the right subgroup and for selecting the correct subgroup upon checking its commading subject or study.

Location:
trunk/grails-app
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/grails-app/controllers/SearchableController.groovy

    r198 r201  
    2727
    2828    def selectsample = {
     29
     30
     31            // produce error message here if studies don't contain samples!
     32            // redirect back or use error
     33
    2934
    3035            println "in selectsample: "
     
    8085
    8186                  // testing:
    82                   // there is a lack of data in the mockup
    83                   // as long as there are no groups in the bootstart,
     87                  // there is a lack of data in the mockup (subject groups are still missing)
     88                  // as long as there are no groups in the boot script,
    8489                  // we use this
    8590                  subgroups = studyGroups.size()<=0 ?
    86                       ["subject group 1","subject group 2"] : studyGroups
     91                       ["subject group 1","subject group 2"] : studyGroups
    8792
    8893                  render(view:"selectsample",model:[selectedStudies:selectedStudies,selectedStudyIds:selectedStudyIds,subgroups:subgroups])
    8994                  break
     95
    9096             case "Event Groups":
    91                   render("Event Groups")
    92                   subgroups=["event group 1","event group 2"]
     97                  def eventGroups = []
     98                  if(selectedStudies!=null)
     99                  {
     100                    selectedStudies.each{ study ->
     101                         println study.id
     102                         println study.samplingEvents.each{ eventGroups.add(it) }
     103                    }
     104                  }
     105                  subgroups=eventGroups
    93106                  render(view:"selectsample",model:[selectedStudies:selectedStudies,selectedStudyIds:selectedStudyIds,subgroups:subgroups])
    94107                  break
     108
    95109             case "Starting Time Groups":
     110
     111                  def timeGroups = []
     112                  if(selectedStudies!=null)
     113                  {
     114                    selectedStudies.each{ study ->
     115                         println study.samplingEvents.each{
     116                             def timeDiff = it.getPrettyDuration( study.startDate, it.startTime )
     117                             if( !timeGroups.contains(timeDiff) ) timeGroups.add(timeDiff)
     118                         }
     119                    }
     120                  }
     121                  subgroups=timeGroups
    96122                  render("Starting Time Groups")
    97                   subgroups=["time group 1","time group 2"]
    98123                  render(view:"selectsample",model:[selectedStudies:selectedStudies,selectedStudyIds:selectedStudyIds,subgroups:subgroups])
    99124                  break
     125
    100126             case ">> Execute and continue with biomarker selection":
    101127                  render("Starting Time Groups")
  • trunk/grails-app/domain/dbnp/studycapturing/Event.groovy

    r197 r201  
    8383        }
    8484
     85
     86        def String toString() {
     87                return eventDescription ? eventDescription.name : ""
     88        }
     89
    8590}
  • trunk/grails-app/views/searchable/selectsample.gsp

    r199 r201  
    2020   <br> <%= params %>
    2121   <br> <%= selectedStudyIds.each{ println it } %>
     22   <br> <b> Subgroups </b>:
    2223   <br> <%= subgroups%>
    2324   <input type="hidden" name="selectedStudyIds" value="${selectedStudyIds}"   </div>
    2425
     26   <% showSubgroups = (subgroups.size()>0) %>
     27    <g:if test="${selectedStudies.size()>0}">
    2528
    26   <% if (selectedStudies.size()>0) {%>
    2729       <table >
    2830         <tr>
     
    3436           <td><b> Sample Material </b></td>
    3537           <td><b> Start Time </b></td>
    36            <g:if test="${subgroups.size>0}"> <td><b> Subgroups </b></td> </g:if>
     38           <g:if test="${showSubgroups}"> <td><b> Subgroups </b></td> </g:if>
     39           <g:else> <td><b> Selection </b></td> </g:else>
    3740         </tr>
    3841
    39   <g:each in="${selectedStudies}" status="j" var="studyIns">
    40   <tr>
    41   <td> <input type="checkbox" name="${studyIns.title}" id="${studyIns.title}" class="checkbox1${studyIns.id}"> </td>
    42           <td> ${studyIns.title} </td>
    43   </tr>
     42
     43         <g:each in="${selectedStudies}" status="j" var="studyIns">
     44         <tr>
     45         <td> <input type="checkbox" name="${studyIns.title}" id="${studyIns.title}" class="checkbox1_${studyIns.id}"> </td>
     46                 <td> ${studyIns.title} </td>
     47         </tr>
    4448
    4549
    4650
    47   <g:if test="${studyIns.samplingEvents.size ()>0}" >
    48   <g:each in ="${studyIns.samplingEvents}" var="event">
    49      <g:each in ="${event.samples}" var="sample">
    50         <tr>
    51           <td></td><td></td>
    52           <td> <input type="checkbox" name="${studyIns.id}.${event.subject.name}" id="${event.subject.name}" class="checkbox2${studyIns.id}" >
    53                ${event.subject.name} </td>
    54           <td> ${studyIns.samplingEvents} </td>
    55           <td> ${sample.name}</td>
    56           <td> ${sample.material}</td>
    57           <td> ${event.getPrettyDuration( studyIns.startDate, event.startTime)} </td>
     51         <g:if test="${studyIns.samplingEvents.size ()>0}" >
     52         <g:each in ="${studyIns.samplingEvents}" var="event">
     53           <% def firstRow = true %>
     54            <g:each in ="${event.samples}" var="sample">
     55               <tr>
     56                 <td></td><td></td>
    5857
    59           <g:if test="${subgroups.size>0}">
    60           <td> <select id="demo">
    61               <g:each in ="${subgroups}" var="p">
    62                   <option value = "${p}"> "${p}" </option>
    63               </g:each>
    64           </select> </td>
    65           </g:if>
    66         </tr>
    67      </g:each>
    68     </g:each>
    69   </g:if>
     58                 <td>
     59                 <g:if test="${firstRow}">
     60                     <% firstRow=false %>
     61                     <input type="checkbox" name="${studyIns.id}.${event.subject.name}" id="${event.subject.name}" class="checkbox2_${studyIns.id}_${event.subject.id}" >
     62                          ${event.subject.name}
     63                 </g:if>
     64                 </td>
     65
     66                 <td> ${event.eventDescription.name} </td>
     67                 <td> ${sample.name}</td>
     68                 <td> ${sample.material}</td>
     69
     70                 <td> ${event.getPrettyDuration( studyIns.startDate, event.startTime)} </td>
     71
     72                 <td>
     73                 <g:if test="${showSubgroups}">
     74                 <select id="demo">
     75                     <g:each in ="${subgroups}" var="p">
     76                         <option value = "${p}"> "${p}" </option>
     77                     </g:each>
     78                 </select>
     79                 </g:if>
     80                 <g:else>
     81                     <input type="checkbox" name="${studyIns.id}.${event.subject.id}.${sample.id}" id="${event.subject.name}" class="checkbox3_${studyIns.id}_${event.subject.id}_${sample.id}" >
     82                 </g:else>
     83                 </td>
     84
     85               </tr>
     86            </g:each>
     87           </g:each>
     88         </g:if>
    7089
    7190
    72   <g:else>
    73         <tr>
    74             <td></td> <td>Study does not cotain any samples. </td>
    75             <td></td> <td></td> <td></td> <td></td> <td></td>
    76             <g:if test="${subgroups.size>0}"> <td></td> </g:if>
    77         </tr>
    78     </g:else>
    79     </g:each>
     91         <g:else>
     92               <tr>
     93                   <td></td> <td>Study does not cotain any samples. </td>
     94                   <td></td> <td></td> <td></td> <td></td> <td></td>
     95                   <g:if test="${showSubgroups}"> <td></td> </g:if>
     96               </tr>
     97           </g:else>
     98           </g:each>
    8099
    81      </table>
     100       </table>
    82101
    83102
    84103
    85     <g:each in="${selectedStudies}" status="j" var="studyIns">
    86         <% def cb1 = '\'.checkbox1' + studyIns.id + '\''  %>
    87         <% def cb2 = '\'.checkbox2' + studyIns.id + '\''  %>
    88         <script>
    89               $(${cb1}).click(function () {
    90                   if($(this).attr("checked")==true)
    91                      $(${cb2}).attr("checked", "checked");
    92                   });
    93               $(${cb2}).click(function () {
    94                   if($(this).attr("checked")==false)
    95                          $(${cb1}).attr("checked", false);
    96                   });
    97         </script>
    98     </g:each>
     104       <g:each in="${selectedStudies}" status="j" var="studyIns">
     105            <g:each in ="${studyIns.samplingEvents}" var="event">
     106               <g:each in ="${event.samples}" var="sample">
     107               <% def cb1 = '\'.checkbox1_' + studyIns.id + '\''  %>
     108               <% def cb2 = '\'.checkbox2_' + studyIns.id + '_' + event.subject.id + '\''  %>
     109               <% def cb3 = '\'.checkbox3_' + studyIns.id + '_' + event.subject.id + '_' + sample.id + '\''  %>
     110                    <script>
     111                         $(${cb1}).click(function () {
     112                             if($(this).attr("checked")==true) {
     113                                $(${cb2}).attr("checked", "checked");
     114                                $(${cb3}).attr("checked", "checked");
     115                             } });
     116                         $(${cb2}).click(function () {
     117                             if($(this).attr("checked")==true)
     118                                    $(${cb3}).attr("checked", true);
     119                             else
     120                                    $(${cb1}).attr("checked", false);
     121                             });
     122                         $(${cb3}).click(function () {
     123                             if($(this).attr("checked")==false) {
     124                                    $(${cb1}).attr("checked", false);
     125                                    $(${cb2}).attr("checked", false);
     126                             } });
     127                    </script>
     128               </g:each>
     129            </g:each>
     130       </g:each>
    99131
    100   <%}%>
    101132
     133    </g:if>
     134
     135
     136    <br>
     137
     138    <script>
     139       function checkAll(value){
     140           var list = document.getElementsByTagName("input");
     141           for(i=0; i<list.length; i++)
     142           {
     143               if(list[i].type=="checkbox")
     144               {
     145                   list[i].checked=value;
     146               }
     147           }
     148       }
     149    </script>
     150
     151
     152    Select samples:
     153    <input type="button" name="CheckAll" value="All" onClick="checkAll(true)">
     154    <input type="button" name="UncheckAll" value="None" onClick="checkAll(false)">
    102155
    103156     Infer subgroups:
     
    105158    <INPUT TYPE=submit name=submit Value="Event Groups">
    106159    <INPUT TYPE=submit name=submit Value="Starting Time Groups">
     160    <br>
     161
     162
     163
    107164
    108165    <% if (selectedStudies.size()==0) { %>
Note: See TracChangeset for help on using the changeset viewer.