Changeset 138


Ignore:
Timestamp:
Jan 26, 2010, 4:46:01 PM (13 years ago)
Author:
duh
Message:
  • added development version of wizard subjects page and logic
  • modified some domain classes (again, who reverted them?) to implement Serializable
Location:
trunk
Files:
8 edited
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/grails-app/conf/BootStrap.groovy

    r136 r138  
    1818class BootStrap {
    1919        def init = {servletContext ->
     20                // define timezone
     21                System.setProperty('user.timezone', 'CET')     
    2022
    2123                if (GrailsUtil.environment == GrailsApplication.ENV_DEVELOPMENT) {
  • trunk/grails-app/controllers/dbnp/studycapturing/WizardController.groovy

    r105 r138  
    22
    33import dbnp.studycapturing.*
     4import dbnp.data.*
    45import grails.converters.*
    56
     
    4950                        flow.pages = [
    5051                                [title: 'Study'],               // study
    51                                 [title: 'Twoooo'],
    52                                 [title: 'Trois']
     52                                [title: 'Subjects'],    // subjects
     53                                [title: 'Form elements demo page']
    5354                        ]
    5455
     
    7576                        }
    7677                        on("next") {
     78                                // create date instance from date string?
     79                                // @see WizardTagLibrary::dateElement{...}
     80                                if (params.get('startDate')) {
     81                                        params.startDate = new Date().parse("d/M/yyyy", params.get('startDate').toString())
     82                                }
     83
    7784                                // create a study instance
    7885                                flow.study = new Study(params)
     
    8087                                // validate study
    8188                                if (flow.study.validate()) {
     89                                        println "ok"
    8290                                        success()
    8391                                } else {
     
    8795                                        error()
    8896                                }
    89                         }.to "pageTwo"
     97                        }.to "subjects"
    9098                }
    9199
    92100                // render page two
    93                 pageTwo {
    94                         render(view: "_two")
     101                subjects {
     102                        render(view: "_subjects")
    95103                        onRender {
    96                                 println "render page two"
    97104                                flow.page = 2
     105
     106                                if (!flow.subjects) {
     107                                        flow.subjects = new LinkedHashMap()
     108                                }
    98109                        }
     110                        on ("add") {
     111                                def speciesTerm = Term.findByName(params.addSpecies)
     112                               
     113                                // add x subject of species y
     114                                (params.addNumber as int).times {
     115                                        def increment = flow.subjects.size()
     116                                        flow.subjects[ increment ] = new Subject(
     117                                                name: 'Subject ' + (increment+1),
     118                                                species: speciesTerm
     119                                        )
     120                                }
     121                        }.to "subjects"
    99122                        on("next") {
    100                                 println "next page!"
     123                                // got one or more subjects?
     124                                if (flow.subjects.size() < 1) {
     125                                        error()
     126                                }
    101127                        }.to "pageThree"
    102128                        on("previous") {
    103                                 println "previous page!"
     129                                // handle data?
     130                                // go to study page
    104131                        }.to "study"
    105132                }
     
    114141                        on("previous") {
    115142                                println "previous page!"
    116                         }.to "pageTwo"
     143                        }.to "subjects"
    117144                }
    118145        }
  • trunk/grails-app/domain/dbnp/data/Term.groovy

    r106 r138  
    77 * The Term object should point to an existing term in an online ontology, therefore instances of this class can also
    88 * be seen as a cache of elements of the external ontology.
     9 *
     10 * Revision information:
     11 * $Rev$
     12 * $Author$
     13 * $Date$
    914 */
    10 class Term {
     15class Term implements Serializable {
     16        String name
     17        Ontology ontology
     18        String accession
    1119
    12     String name
    13     Ontology ontology
    14     String accession
     20        static constraints = {
     21        }
    1522
    16     static constraints = {
    17     }
    18 
    19   def String toString() {
    20     return name
    21   }
    22 
    23 
     23        def String toString() {
     24                return name
     25        }
    2426}
  • trunk/grails-app/domain/dbnp/studycapturing/Study.groovy

    r136 r138  
    99 * $Date$
    1010 */
    11 class Study {
     11class Study implements Serializable {
    1212        nimble.User owner
    1313        String title
     
    2121        Template template
    2222
    23         static hasMany = [      editors:                nimble.User,
    24                                 readers:                nimble.User,
    25                                 subjects:               Subject,
    26                                 groups:                 SubjectGroup,
    27                                 events:                 Event,
    28                                 samplingEvents: SamplingEvent
     23        static hasMany = [      editors: nimble.User,
     24                                                readers: nimble.User,
     25                                                subjects: Subject,
     26                                                groups: SubjectGroup,
     27                                                events: Event,
     28                                                samplingEvents: SamplingEvent
    2929        ]
    3030
  • trunk/grails-app/domain/dbnp/studycapturing/Subject.groovy

    r136 r138  
    11package dbnp.studycapturing
    2 
    32import dbnp.data.Term
    43
    54/**
    65 * This domain class describes the subjects in a study.
     6 *
     7 * Revision information:
     8 * $Rev$
     9 * $Author$
     10 * $Date$
    711 */
    8 class Subject {
    9 
     12class Subject implements Serializable {
    1013        String name
    1114        Term species
     
    1619
    1720        static hasMany = [
    18                 templateStringFields : String,
    19                 templateNumberFields : float,
    20                 templateStringListFields : String,
    21                 templateTermFields : Term
     21                templateStringFields: String,
     22                templateNumberFields: float,
     23                templateStringListFields: String,
     24                templateTermFields: Term
    2225        ]
    23        
     26
    2427        static constraints = {
    2528        }
  • trunk/grails-app/taglib/dbnp/studycapturing/WizardTagLib.groovy

    r107 r138  
    22
    33import org.codehaus.groovy.grails.plugins.web.taglib.JavascriptTagLib
     4import dbnp.data.Term
    45
    56/**
     
    9091
    9192                // replace double semi colons
    92                 button = button.replaceAll(/;{2,}/, '!!!')
     93                button = button.replaceAll(/;{2,}/, ';')
    9394               
    9495                // render button
     
    236237         */
    237238        def dateElement = { attrs, body ->
     239                // transform value?
     240                if (attrs.value instanceof Date) {
     241                        // transform date instance to formatted string (dd/mm/yyyy)
     242                        attrs.value = String.format('%td/%<tm/%<tY', attrs.value)
     243                }
     244               
    238245                // set some textfield values
    239246                attrs.maxlength = 10
     
    246253                out << '<script type="text/javascript">'
    247254                out << '$(document).ready(function() {'
    248                 out << '        $("#' + attrs.get('name') + '").datepicker({altField: \'#' + attrs.get('name') + 'Example\', altFormat: \'DD, d MM, yy\'});'
     255                out << '        $("#' + attrs.get('name') + '").datepicker({'
     256                out << '                dateFormat: \'dd/mm/yy\','
     257                out << '                altField: \'#' + attrs.get('name') + 'Example\', altFormat: \'DD, d MM, yy\''
     258                out << '        });'
    249259                out << '});'
    250260                out << '</script>'
    251261        }
     262
     263        /**
     264         * render a species select element
     265         * @param Map attrs
     266         * @param Closure body (help text)
     267         */
     268        def speciesSelect = { attrs, body ->
     269                // fetch all species
     270                attrs.from = Term.findAll()     // for now, all terms, should be refactored to be species ontology only!
     271
     272                // got a name?
     273                if (!attrs.name) {
     274                        attrs.name = 'species'
     275                }
     276
     277                out << select(attrs)
     278        }
    252279}
  • trunk/grails-app/views/wizard/pages/_subjects.gsp

    r130 r138  
    11<%
    22/**
    3  * Wizard page two
     3 * Subjects page
    44 *
    55 * @author  Jeroen Wesbeek
     
    1616%>
    1717<wizard:pageContent>
    18   <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec sodales porta enim, sed ornare sapien molestie mollis. Maecenas at pretium turpis. Duis fermentum lectus vitae nisl venenatis id hendrerit sapien dictum. Duis blandit ornare augue nec porttitor. Quisque at tortor sapien, ac volutpat sem. Nullam venenatis placerat risus a euismod. Donec massa dui, porttitor sed fermentum eu, ornare ac velit. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. In id odio nisl, non semper neque. Vivamus facilisis, neque sed lacinia blandit, odio nisi sagittis turpis, accumsan iaculis tellus magna at velit. In sed turpis metus. Phasellus id sem eget dui sollicitudin ultrices. Duis cursus vehicula diam vel pharetra. Donec mattis libero eget tortor venenatis at cursus felis scelerisque. Nunc hendrerit metus quis leo sollicitudin sodales. In urna quam, aliquet in eleifend eget, rutrum tempor elit.</p>
    19 
    20   <p>Suspendisse magna mauris, pretium eget elementum sed, aliquam nec neque. Nam et lorem lacus. Phasellus dapibus, erat nec tristique commodo, turpis tellus tempor est, tincidunt dignissim urna tortor at dui. Nulla faucibus, velit in lobortis venenatis, neque sapien lobortis neque, ut varius sem tortor id purus. Duis posuere condimentum ante, quis mattis arcu fringilla quis. Vivamus in augue tellus, posuere mattis nisl. Praesent sit amet ligula a turpis ullamcorper elementum non quis felis. Nulla elit ipsum, viverra ut cursus at, pharetra eget nibh. Vivamus mauris velit, elementum eu ornare vitae, imperdiet id velit. Phasellus sit amet mi vel est lobortis sagittis. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. </p>
     18<wizard:ajaxButton name="add" value="Add" url="[controller:'wizard',action:'pages']" update="[success:'wizardPage',failure:'wizardError']" afterSuccess="attachHelpTooltips()" />
     19<input name="addNumber" size="4" maxlength="4" value="1">
     20subjects of species
     21<wizard:speciesSelect name="addSpecies" />
     22<g:if test="${subjects}">
     23<div class="subjects">
     24<g:each var="subject" status="i" in="${subjects}">
     25        <div class="subject<g:if test="${i>0}"> topborder</g:if>">
     26                <div class="row">subject ${i}</div>
     27                <div class="row">${subject}</div>
     28        </div>
     29</g:each>
     30</div>
     31</g:if>
    2132</wizard:pageContent>
  • trunk/grails-app/views/wizard/pages/_three.gsp

    r101 r138  
    3030                <p>Nullam a blandit quam. Cras porta tempus lectus, vel varius lacus vulputate in. Aenean ac nunc lectus, hendrerit tempor elit. Sed ut varius diam.</p>
    3131        </wizard:textFieldElement>
     32        <wizard:dateElement name="startDate" description="Date element" error="startDate" value="${study?.startDate}">
     33                <object width="320" height="265"><param name="movie" value="http://www.youtube.com/v/2WNrx2jq184&hl=en_US&fs=1&rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/2WNrx2jq184&hl=en_US&fs=1&rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="320" height="265"></embed></object>
     34        </wizard:dateElement>
    3235</wizard:pageContent>
  • trunk/web-app/css/wizard.css

    r107 r138  
    122122    display: none;
    123123}
     124
     125.wizard .subjects {
     126    display: block;
     127    /*
     128    background-color: #c0ddea;
     129    border: 1px solid #575a5d;
     130    margin-top: 2px;
     131    */
     132    border: 1px solid #575a5d;
     133    background-color: #ebf7fc;
     134    margin-top: 10px;
     135}
     136
     137.wizard .subjects .subject {
     138    display: block;
     139}
     140
     141.wizard .topborder {
     142    border-top: 1px solid #8e908f;
     143}
     144
     145.wizard .subjects .subject .row {
     146    display: inline-block;
     147    /*
     148    border: 1px solid #575a5d;
     149    margin: 1px 1px 0px 0px;
     150    */
     151}
Note: See TracChangeset for help on using the changeset viewer.