Changeset 150


Ignore:
Timestamp:
Jan 29, 2010, 6:08:49 PM (13 years ago)
Author:
jahn
Message:

Updated editing of Events. RemoteFunction? calls work. Still needs cleaning up (but its Friday evening).

Location:
trunk/grails-app
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/grails-app/controllers/dbnp/studycapturing/EventController.groovy

    r123 r150  
    22import java.text.SimpleDateFormat
    33import dbnp.data.Term
     4import dbnp.data.Ontology
    45
    56class EventController {
     
    2526
    2627    def createForEventDescription = {
    27 
    2828        if( params["id"]==null)
    2929        {
     
    5050    // Output format: "01/20/2010 20:45"
    5151    // Note: the "am" amd "pm" suffixes are removed.
    52 
    5352    def parseDate = {  st ->
    5453            def subst = st.substring(0,16)
     
    6968    def save = {
    7069        println "In EventController.save: ${params}"
    71 
    7270        params["startTime"] = parseDate(params["startTime"])     // parse the date strings
    7371        params["endTime"] = parseDate(params["endTime"])
     
    139137            def eDate = new Date( params["endTime"])
    140138            def description = EventDescription.findById((params["eventDescription"])["id"])
    141             return [testo:params.clone(), sDate:sDate, eDate:eDate, description:description ]
     139            return [eventInstance:eventInstance, testo:params.clone(), sDate:sDate, eDate:eDate, description:description ]
    142140        }
    143141
     
    149147                redirect(action: "list")
    150148            }
    151             return [testo:params.clone(), sDate:eventInstance.startTime, eDate:eventInstance.endTime, description:eventInstance.eventDescription]
    152         }
    153 
    154     }
    155 
    156 
     149            return [eventInstance:eventInstance, testo:params.clone(), sDate:eventInstance.startTime, eDate:eventInstance.endTime, description:eventInstance.eventDescription]
     150        }
     151
     152    }
    157153
    158154
     
    204200    }
    205201
    206 
    207 
    208     def createDummies = {
    209 
    210          ["ONE","TWO"].each{ x -> println x }
    211          def t = new Term()
    212          t.name =  "homo politicus russicus"
    213          t.ontology = "Ontology: Monkies and Typewriters"
    214          t.accession = "up or down"
    215          t.save()
    216 
    217          def pp = new ProtocolParameter()
    218          pp.name = "LSD reatment"
    219          pp.unit = "Tt"
    220          pp.description = "feed the LSD to the subject"
    221          pp.reference = t
    222          pp.type = "String"     // should become ProtocolParameterType at some point
    223          pp.save()
    224 
    225          def p = new Protocol()
    226          p.name = "Hugo (dummy #1)"
    227          p.reference = t
    228          p.save()
    229          p.addToParameters(pp)
    230 
    231          def ppi = new ProtocolParameterInstance()
    232          ppi.value = "1.2"
    233          ppi.protocolParameter = pp
    234          ppi.save()
    235 
    236          def ppi2 = new ProtocolParameterInstance()
    237          ppi2.value = "23.5"
    238          ppi2.protocolParameter = pp
    239          ppi2.save()
    240 
    241          def pi = new ProtocolInstance()
    242          pi.protocol = p.find("from Protocol p ")
    243          pi.save()
    244          pi.addToValues(ppi)
    245          pi.addToValues(ppi2)
    246 
    247          def s= new Subject()
    248          s.name = "Vladimir Putin"
    249          s.species = t
    250          s.save()
    251 
    252          def ed = new EventDescription()
    253          ed.name = "dummmy name"
    254          ed.description = "dummmy description"
    255          ed.protocol = pi
    256          ed.classification = Term.find("from Term t")
    257          ed.save()
    258 
    259          def sdfh = new SimpleDateFormat("dd/MM/yyyy hh:mm")
    260          def eventInstance = new Event()
    261          def someDate = sdfh.parse("29/11/2008 18:00")
    262          eventInstance.subject = s
    263          eventInstance.eventDescription= ed
    264          eventInstance.startTime = someDate
    265          eventInstance.endTime = someDate
    266          if( eventInstance.save() )
    267          { redirect( action:show, id: eventInstance.id ) }
    268          else { chain( action:list ) }
    269 
    270 
    271 
    272     }
     202    def showMySample = {
     203          render( view:"showMySample" )
     204    }
     205
     206   
    273207}
  • trunk/grails-app/controllers/dbnp/studycapturing/EventDescriptionController.groovy

    r123 r150  
    4747
    4848    def showMyProtocol = {
     49        println params  // dbg, remove
    4950
    50         def protocol = ( params.protocol) ?  Protocol.get(params.protocol) : Protocol.find("for Protocol id")
    51         def description = EventDescription.get(params.id)
    52         def protocolInstance = description.protocol
     51        def protocol = ( params.protocolid) ?  Protocol.get(params.protocolid) : Protocol.find("for Protocol id")
     52        def event = Event.get(params.id)
     53        def protocolInstance = event.eventDescription.protocol
    5354
    5455        println params
     56        println event
    5557        println protocol
    56         println description
    5758        println protocolInstance
    5859
    59 
    60         if( protocol.id==protocolInstance.protocol.id ) {
    61             println "redner this FILLED rubish"
    62             println protocolInstance
    63             println "the fuck?"
    64             render( view:"showMyProtocolFilled", model:["protocolInstance":protocolInstance] )
     60        if( protocolInstance && protocolInstance && protocol.id==protocolInstance.id ) {
     61            def parameterStringValues = event.parameterStringValues
     62            println parameterStringValues
     63            print "showFull"
     64            render( view:"showMyProtocolFilled", model:["protocolInstance":protocolInstance,"event":event,"parameterStringValues":parameterStringValues] )
    6565        }
    6666        else {
    67             println "redner this EMPTY rubish"
    68             render( view: "showMyProtocolEmpty", model:[protocol:protocol] )
    69             //render( view:"showMyProtocolEmpty", model:[protocol:protocol] )
     67            print "showEmpty"
     68            if(protocol!=null) render( view: "showMyProtocolEmpty", model:["protocolInstance":protocol] )
     69            else               render( "NULL" )
    7070        }
    7171}
     
    131131
    132132
    133     /* Jahn - For development only
    134      * Create one dummy instance of EventDescription */
    135     def createDummies =
    136     {
    137          def newInstance = new EventDescription()
    138          newInstance.name = "dummmy name"
    139          newInstance.description = "dummmy description"
    140          newInstance.protocol = ProtocolInstance.find("from ProtocolInstance p ")
    141          newInstance.classification = Term.find("from Term t")
    142 
    143          if( newInstance.save() )
    144               { redirect( action:show, id: newInstance.id ) }
    145          else { chain( action:list ) }
    146     }
    147 
    148 
    149     def test = { render("test") }
     133    def test = { println "test"
     134            render("test") }
    150135}
  • trunk/grails-app/domain/dbnp/studycapturing/ProtocolParameterType.groovy

    r139 r150  
    1111
    1212    String name
     13    ProtocolParameterType(String name) { this.name = name }
    1314
    14     ProtocolParameterType(String name) {
    15      this.name = name
    16     }
    1715
    1816    static list() {
  • trunk/grails-app/views/common/_eventDescriptionTableRows.gsp

    r118 r150  
    1 
    21<!-- Rows for a two column table -->
    3 
    4 
    5 
    6 
    7         <tr class="prop">
    8             <td valign="top" class="name">
    9               <label for="protocol"><g:message code="eventDescription.protocol.label" default="Protocol" /></label>
    10             </td>
    11             <td valign="top" class="value ${hasErrors(bean: description, field: 'protocol', 'errors')}">
    12                 <g:select name="protocol.id" id="protocol" from="${dbnp.studycapturing.Protocol.list()}" optionKey="id" optionValue="${{it.id}}" value="${description?.protocol?.id}" onchange="${remoteFunction(action:'showMyProtocol', controller:'eventDescription', id:description.id, update:'preview', onComplete:'Effect.Appear(preview)', params:'\'protocol=\' + this.value' )}" />
    13             </td>
    14         </tr>
    15 
    162
    173        <tr class="prop">
     
    239            </td>
    2410        </tr>
    25 
    26 
    2711
    2812
     
    3721
    3822
    39         <!-- changes here on select -->
     23        <!-- select -->
     24
     25        <tr class="prop">
     26
     27            <td valign="top" class="name" width=200 >
     28              <label for="protocol"><g:message code="eventDescription.protocol.label" default="Protocol" /></label>
     29            </td>
     30            <td valign="top" class="value ${hasErrors(bean: description, field: 'protocol', 'errors')}">
     31                <g:select name="protocol.id" id="protocol" from="${dbnp.studycapturing.Protocol.list()}" optionKey="id" optionValue="${{it.name}}" value="${{it?.id}}" onchange="${remoteFunction(action:'showMyProtocol', controller:'eventDescription', update:'preview', onComplete:'Effect.Appear(preview)', params:'\'protocolid=\' + this.value', id:params['id'])}" />
     32            </td>
     33        </tr>
     34
     35
     36        <!-- this part changes dynamiccally on select -->
     37
    4038        <tbody id="preview">
    41             <g:each in="${description.protocol.values}">
     39            <% def list = [] %>
     40            <g:each in="${description.protocol.parameters}" > <% list.add( it )%> </g:each>
     41            <% list.sort{ a,b -> a.name <=> b.name }%>
     42
     43            <g:each in="${list}">
    4244
    4345                 <tr class="prop">
    44                  <td valign="top" class="name">
    45                  <label for="protocolInstance"><g:message code="${it.protocolParameter.name}" /></label>
     46                 <td valign="top" class="name" width=200>
     47                 <label for="parameter"><g:message code="${it.name}" /></label>
    4648                 </td>
    4749
    4850                 <td valign="top" class="name">
    49                  <g:textField name="protocolInstance.${it.id}" value="${it.value}" />
     51                 <g:textField name="protocolParameter.${it.id}" value="${eventInstance.parameterStringValues[it.name]}" />
    5052                 </td>
     53                 </tr>
    5154
    52                  </tr>
    5355            </g:each>
    5456        </tbody>
  • trunk/grails-app/views/event/edit.gsp

    r119 r150  
     1<html>
    12
    2 
    3 <html>
    43<head>
    5         <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    6         <meta name="layout" content="main" />
    7         <g:set var="entityName" value="${message(code: 'event.label', default: 'Event')}" />
    8         <title><g:message code="default.create.label" args="[entityName]" /></title>
    9         <g:render template="../common/jquerysetup"/>
    10         <g:render template="../common/jqueryuisetup"/>
    11         <g:render template="../common/jquerytmsetup"/>
     4      <meta name="layout" content="main" />
     5      <g:set var="entityName" value="${message(code: 'event.label', default: 'Event')}" />
     6      <g:setProvider library="jquery"/>
     7      <script src="${createLinkTo(dir: 'js', file: 'timepicker-0.2.1.js')}" type="text/javascript"></script>
    128</head>
    139
    1410
    15 
    1611<body>
    17 
    18         <div class="nav">
    19             <span class="menuButton"><a class="home" href="${createLink(uri: '/')}">Home</a></span>
    20             <span class="menuButton"><g:link class="list" action="list"><g:message code="default.list.label" args="[entityName]" /></g:link></span>
    21         </div>
    2212
    2313
     
    2717
    2818            <g:if test="${flash.message}">
    29             <div class="message">${flash.message}</div>
     19                <div class="message">${flash.message}</div>
    3020            </g:if>
    3121            <g:hasErrors bean="${eventInstance}">
    32                     <div class="errors"> <g:renderErrors bean="${eventInstance}" as="list" /> </div>
     22                <div class="errors"> <g:renderErrors bean="${eventInstance}" as="list" /> </div>
    3323            </g:hasErrors>
    3424
     
    4737                                </td>
    4838                                <td valign="top" class="value" >
    49                                     <g:select id="subject" name="subject.id" from="${dbnp.studycapturing.Subject.list()}" optionKey="id" optionValue="name" value="${eventInstance?.subject?.id}"  onchange="displayVals()" />
     39                                    <g:select id="subject" name="subject.id" from="${dbnp.studycapturing.Subject.list()}" optionKey="id" optionValue="name" value="${eventInstance?.subject?.id}" />
    5040                                </td>
    5141                            </tr>
     
    8575                            </tr>
    8676
    87 
    88 
    89                             <g:render template="../common/eventDescriptionTableRows" model="${[description:description]}"/>
     77                            <g:render template="../common/eventDescriptionTableRows" model="${[description:description, event:event]}"/>
    9078
    9179
    9280                        </tbody>
     81
     82
     83
     84                             <tbody id="samplePartial"> </tbody>
     85
     86
     87
    9388                    </table>
    9489                </div>
  • trunk/grails-app/views/eventDescription/showMyProtocolEmpty.gsp

    r120 r150  
    1 <g:each in="${protocol.parameters}">
     1<% def list = [] %>
     2<g:each in="${protocolInstance.parameters}" > <% list.add( it )%> </g:each>
     3<% list.sort{ a,b -> a.name <=> b.name }%>
     4
     5<g:each in="${list}">
    26
    37<tr class="prop">
    4 
     8    <td valign="top" class="name" width=200 >
     9    <label for="protocol"><g:message code="${it.name}" /></label>
     10    </td>
    511    <td valign="top" class="name">
    6     <label for="startTime"><g:message code="${it.name}" /></label>
     12    <g:textField name="protocolParameter.${it.id}" value="" />
    713    </td>
    8 
    9     <td valign="top" class="name">
    10      <g:textField id="protocolParameterValue.${it.id}" value="${""}" />
    11      </td>
    12 
    1314</tr>
    1415
    15 
    1616</g:each>
  • trunk/grails-app/views/eventDescription/showMyProtocolFilled.gsp

    r120 r150  
    1 <g:each in="${protocolInstance.values}">
     1<% def list = [] %>
     2<g:each in="${protocolInstance.parameters}" > <% list.add( it )%> </g:each>
     3<% list.sort{ a,b -> a.name <=> b.name }%>
    24
    3 <tr class="prop">
     5<g:each in ="${list}" >
     6    <tr class="prop">
    47
    5     <td valign="top" class="name">
    6     <label for="protocolInstance"><g:message code="${it.protocolParameter.name}" /></label>
    7     </td>
     8         <td valign="top" class="name" width=200>
     9         <label for="protocolInstance"><g:message code="${it.name}" /></label>
     10         </td>
    811
    9     <td valign="top" class="name">
    10      <g:textField name="protocolInstance.${it.id}" value="${it.value}" />
    11      </td>
    12 
    13 </tr>
    14 
    15 
     12         <td valign="top" class="name">
     13         <g:textField name="protocolParameter.${it.id}" value="${parameterStringValues[it.name]}" />
     14         </td>
     15    </tr>
    1616</g:each>
Note: See TracChangeset for help on using the changeset viewer.