Changeset 219


Ignore:
Timestamp:
Mar 1, 2010, 5:47:26 PM (13 years ago)
Author:
jahn
Message:

EventDescription? in progress. This is still ugly, because it uses a lot of JS to avoid to much loading from the server; however, the JS lines are just dumped into the page. Instead of this dumping, the JS should go into a tag library or something similar.

Still missing are: (1) a popup box for adding parameter string lists, (2) parsing the parameters form the view into the database in the model upon completion of the action.

File:
1 edited

Legend:

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

    r162 r219  
    4747
    4848    def showMyProtocol = {
    49 
    50         def protocol = ( params.protocolid) ?  Protocol.get(params.protocolid) : Protocol.find("for Protocol id")
    51         def event = Event.get(params.id)
    52         def protocolInstance = event.eventDescription.protocol
    53 
    54         if( protocolInstance && protocolInstance && protocol.id==protocolInstance.id ) {
    55             def parameterStringValues = event.parameterStringValues
    56             render( view:"showMyProtocolFilled", model:["protocolInstance":protocolInstance,"event":event,"parameterStringValues":parameterStringValues] )
     49        def description = EventDescription.get(params.id)
     50        if( description.protocol==null ) {
     51            protocol = new Protocol()
     52            render( view:"showMyProtocolEmpty", model:[protocol:protocol,description:description] )
    5753        }
    5854        else {
    59             if(protocol!=null) render( view: "showMyProtocolEmpty", model:["protocolInstance":protocol] )
    60             else               render( "NULL" )
     55            render( view: "showMyProtocolFilled", model:[protocol:description.protocol,description:description] )
    6156        }
    62 }
     57    }
     58
     59
     60    def showMyProtocolEmpty = {
     61       println "in showMyProtocolEmpty"
     62    }
     63
     64
     65    def showMyProtocolFilled = {
     66       println "in showMyProtocolFilled"
     67    }
     68
     69
     70
    6371
    6472
     
    121129
    122130
    123     def test = { println "test"
    124             render("test") }
     131    def test = { render(params) }
     132
     133    def test2 = {
     134        def eventDescriptionInstance = EventDescription.get(params.id)
     135        if (!eventDescriptionInstance) {
     136            flash.message = "${message(code: 'default.not.found.message', args: [message(code: 'eventDescription.label', default: 'EventDescription'), params.id])}"
     137            redirect(action: "list")
     138        }
     139        else {
     140            return [eventDescriptionInstance: eventDescriptionInstance]
     141        }
     142    }
     143
     144
     145    def addProtocolParameter = {
     146        render( action:"showProtocolParameters", model:['addNew':true] )
     147    }
     148
     149
     150    def showProtocolParameters = {
     151        println params
     152
     153        def description = EventDescription.get(params.id)
     154        def protocol =  description.protocol==null ? new Protocol() : description.protocol
     155
     156        if( params['addOneParameter']=='true') {    // add a new parameter
     157            println "adding"
     158            def parameter = new ProtocolParameter()
     159            protocol.addToParameters(parameter)
     160        }
     161
     162        def list = []
     163        protocol.parameters.each {
     164            list.add(it)
     165            list.sort{ a,b -> a.name <=> b.name }
     166        }
     167
     168        render( view:"showProtocolParameters", model:[protocol:protocol,description:description,list:list] )
     169    }
     170
    125171}
Note: See TracChangeset for help on using the changeset viewer.