Changeset 192


Ignore:
Timestamp:
Feb 11, 2010, 5:47:49 PM (14 years ago)
Author:
duh
Message:
  • temporary commit
  • rewriting grouping javascript
  • uncommented the bootstrap part I commented previously, it appeared to be a grails cache issue that was resolved after issuing a 'grails clean' command...
Location:
trunk
Files:
6 edited

Legend:

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

    r191 r192  
    239239                        }
    240240
    241                         println 'Adding PPSH study... --> DISABLED due to bootstrapping errors'
    242 /*
     241                        println 'Adding PPSH study'
     242                       
    243243            def humanStudy = new Study(
    244244                                title:"NuGO PPS human study",
     
    355355                        humanStudy.addToAssays(lipidAssayRef);
    356356                        humanStudy.save()
    357 */
    358357                }
    359358        }
  • trunk/grails-app/controllers/dbnp/studycapturing/WizardController.groovy

    r189 r192  
    127127                                flash.errors = new LinkedHashMap()
    128128
    129                                 // handle form data
    130                                 if (!this.handleSubjects(flow, flash, params)) {
     129                                // check if we have at least one subject
     130                                // and check form data
     131                                if (flow.subjects.size() < 1) {
     132                                        // append error map
     133                                        this.appendErrorMap(['subjects': 'You need at least to create one subject for your study'], flash.errors)
     134                                        error()
     135                                } else if (!this.handleSubjects(flow, flash, params)) {
    131136                                        error()
    132137                                } else {
     
    182187        /**
    183188         * re-usable code for handling subject form data in a web flow
    184          * @param Map   LocalAttributeMap (the flow scope)
    185          * @param Map   localAttributeMap (the flash scope)
    186          * @param Map   GrailsParameterMap (the flow parameters = form data)
     189         * @param Map LocalAttributeMap (the flow scope)
     190         * @param Map localAttributeMap (the flash scope)
     191         * @param Map GrailsParameterMap (the flow parameters = form data)
    187192         * @returns boolean
    188193         */
    189194        def handleSubjects(flow, flash, params) {
    190                 if (flow.subjects.size() < 1) {
    191                         return false
    192                 } else {
    193                         def names = new LinkedHashMap();
    194                         def errors = false;
    195                         def id = 0;
    196 
    197                         // iterate through subjects
    198                         flow.subjects.each() {
    199                                 // store subject properties
    200                                 def name = params.get('subject_' + id + '_name')
    201                                 it.name = params.get('subject_' + id + '_name')
    202                                 it.species = Term.findByName(params.get('subject_' + id + '_species'))
    203 
    204                                 // remember name and check for duplicates
    205                                 if (!names[ it.name ]) {
    206                                         names[ it.name ] = [count: 1, first: 'subject_' + id + '_name']
    207                                 } else {
    208                                         // duplicate name found, set error flag
    209                                         names[ it.name ]['count']++
    210 
    211                                         // second occurence?
    212                                         if (names[ it.name ]['count'] == 2) {
    213                                                 // yeah, also mention the first
    214                                                 // occurrence in the error message
    215                                                 this.appendErrorMap([[names[ it.name ]['first']]: 'The subject name needs to be unique!'], flash.errors)
     195                def names = new LinkedHashMap();
     196                def errors = false;
     197                def id = 0;
     198
     199                // iterate through subjects
     200                flow.subjects.each() {
     201                        // store subject properties
     202                        def name = params.get('subject_' + id + '_name')
     203                        it.name = params.get('subject_' + id + '_name')
     204                        it.species = Term.findByName(params.get('subject_' + id + '_species'))
     205
     206                        // remember name and check for duplicates
     207                        if (!names[it.name]) {
     208                                names[it.name] = [count: 1, first: 'subject_' + id + '_name']
     209                        } else {
     210                                // duplicate name found, set error flag
     211                                names[it.name]['count']++
     212
     213                                // second occurence?
     214                                if (names[it.name]['count'] == 2) {
     215                                        // yeah, also mention the first
     216                                        // occurrence in the error message
     217                                        this.appendErrorMap([[names[it.name]['first']]: 'The subject name needs to be unique!'], flash.errors)
     218                                }
     219
     220                                // add to error map
     221                                this.appendErrorMap([['subject_' + id + '_name']: 'The subject name needs to be unique!'], flash.errors)
     222                                errors = true
     223                        }
     224
     225                        // clear lists
     226                        def stringList = new LinkedHashMap();
     227                        def intList = new LinkedHashMap();
     228                        def floatList = new LinkedHashMap();
     229                        def termList = new LinkedHashMap();
     230
     231                        // get all template fields
     232                        flow.study.template.subjectFields.each() {
     233                                // valid type?
     234                                if (!it.type) throw new NoSuchFieldException("Field name ${fieldName} not recognized")
     235
     236                                // get value
     237                                def value = params.get('subject_' + id + '_' + it.name);
     238                                if (value) {
     239                                        // add to template parameters
     240                                        switch (it.type) {
     241                                                case 'STRINGLIST':
     242                                                        stringList[it.name] = value
     243                                                        break;
     244                                                case 'INTEGER':
     245                                                        intList[it.name] = value
     246                                                        break;
     247                                                case 'FLOAT':
     248                                                        floatList[it.name] = value
     249                                                        break;
     250                                                default:
     251                                                        // unsupported type?
     252                                                        throw new NoSuchFieldException("Field type ${it.type} not recognized")
     253                                                        break;
    216254                                        }
    217 
    218                                         // add to error map
    219                                         this.appendErrorMap([['subject_' + id + '_name']: 'The subject name needs to be unique!'], flash.errors)
    220                                         errors = true
    221                                 }
    222 
    223                                 // clear lists
    224                                 def stringList  = new LinkedHashMap();
    225                                 def intList             = new LinkedHashMap();
    226                                 def floatList   = new LinkedHashMap();
    227                                 def termList    = new LinkedHashMap();
    228 
    229                                 // get all template fields
    230                                 flow.study.template.subjectFields.each() {
    231                                         // valid type?
    232                                         if (!it.type) throw new NoSuchFieldException("Field name ${fieldName} not recognized")
    233 
    234                                         // get value
    235                                         def value = params.get('subject_' + id + '_' + it.name);
    236                                         if (value) {
    237                                                 // add to template parameters
    238                                                 switch (it.type) {
    239                                                         case 'STRINGLIST':
    240                                                                 stringList[it.name]     = value
    241                                                                 break;
    242                                                         case 'INTEGER':
    243                                                                 intList[it.name]        = value
    244                                                                 break;
    245                                                         case 'FLOAT':
    246                                                                 floatList[it.name]      = value
    247                                                                 break;
    248                                                         default:
    249                                                                 // unsupported type?
    250                                                                 throw new NoSuchFieldException("Field type ${it.type} not recognized")
    251                                                                 break;
    252                                                 }
    253                                         }
    254                                 }
    255 
    256                                 // set field data
    257                                 it.templateStringFields         = stringList
    258                                 it.templateIntegerFields        = intList
    259                                 it.templateFloatFields          = floatList
    260                                 it.templateTermFields           = termList
    261 
    262                                 // validate subject
    263                                 if (!it.validate()) {
    264                                         errors = true
    265                                         println id + ' :: ' + it.errors.getAllErrors()
    266                                         this.appendErrors(it, flash.errors)
    267                                 }
    268 
    269                                 id++;
    270                         }
    271 
    272                         return !errors
    273                 }
     255                                }
     256                        }
     257
     258                        // set field data
     259                        it.templateStringFields = stringList
     260                        it.templateIntegerFields = intList
     261                        it.templateFloatFields = floatList
     262                        it.templateTermFields = termList
     263
     264                        // validate subject
     265                        if (!it.validate()) {
     266                                errors = true
     267                                println id + ' :: ' + it.errors.getAllErrors()
     268                                this.appendErrors(it, flash.errors)
     269                        }
     270
     271                        id++;
     272                }
     273
     274                return !errors
    274275        }
    275276
  • trunk/grails-app/domain/dbnp/studycapturing/AssayType.groovy

    r190 r192  
    33/**
    44 * Enum describing the different assay types (aka omics submodules).
     5 *
     6 * Revision information:
     7 * $Rev$
     8 * $Author$
     9 * $Date$
    510 */
    611public enum AssayType {
    7     TRANSCRIPTOMICS('Transcriptomics'),
    8     METABOLOMICS('Metabolomics'),
    9     CLINICAL_DATA('Clinical data')
     12        TRANSCRIPTOMICS('Transcriptomics'),
     13        METABOLOMICS('Metabolomics'),
     14        CLINICAL_DATA('Clinical data')
    1015
    11     String name
     16        String name
    1217
    13     AssayType(String name) {
    14      this.name = name
    15     }
     18        AssayType(String name) {
     19                this.name = name
     20        }
    1621
    17     static list() {
    18      [TRANSCRIPTOMICS, METABOLOMICS, CLINICAL_DATA]
    19     }
     22        static list() {
     23                [TRANSCRIPTOMICS, METABOLOMICS, CLINICAL_DATA]
     24        }
    2025
    21     /*def String toString() {
    22         return this.name
    23     }*/
    24 
     26        /*
     27        def String toString() {
     28                return this.name
     29        }
     30        */
    2531}
  • trunk/web-app/css/wizard.css

    r178 r192  
    217217}
    218218
    219 .wizard .grouping .subjects {
    220     display: block;
    221     float: left;
    222 }
    223219.wizard .grouping .ui-selected {
    224220    background-color: red;
     
    228224}
    229225
     226.wizard .grouping .subjects {
     227    display: block;
     228    float: left;
     229}
     230.wizard .grouping .subjects .subject {
     231    margin: 1px;
     232    padding: 0.2em;
     233    font-size: .8em;
     234    height: 14px;
     235}
    230236.wizard .grouping .right {
    231237    display: inline-block;
     
    252258.wizard .grouping .group .subjects {
    253259    display: inline-block;
     260    height: auto;
    254261}
    255262.wizard .grouping .group .subject {
    256     display: block;
     263    display: inline-block;
    257264    width: 100%;
    258265    font-size: 10px;
  • trunk/web-app/js/grouping.js

    r189 r192  
    2929
    3030        this.initItems();
     31        this.initGroupItems();
     32        this.initGroups();
     33        //this.initGroups();
     34       
     35        console.log('bla')
    3136    },
    3237
    3338    initItems: function() {
     39        var that = this;
     40       
    3441        //$(this.itemsIdentifier).
     42        $(this.itemsIdentifier).first().selectable({
     43            filter: that.itemIdentifier,
     44            stop: function() {
     45                // done selecting, make all selected items draggable
     46                //that.makeDraggable(this);
     47            }
     48        });
     49    },
     50
     51    initGroups: function() {
     52        this.initGroupItems();
     53    },
     54
     55    initGroupItems: function() {
     56        var that = this;
     57
     58        $(this.groupsIdentifier).selectable({
     59            filter: that.itemIdentifier
     60        })
    3561    }
    3662}
     
    156182}
    157183*/
     184
     185// for debugging purposes this is here
     186// TODO: to be be migrated to wizard.js....
     187$(document).ready(function() {
     188    new Grouping().init('div.subjects', 'div.subject', 'div.groups', 'div.group');
     189});
  • trunk/web-app/js/wizard.js

    r189 r192  
    4343   
    4444    // GROUPING PAGE
    45     new Grouping().init('div.subjects', 'div.subject', 'div.groups', 'div.group');
     45    //new Grouping().init('div.subjects', 'div.subject', 'div.groups', 'div.group');
    4646}
    4747
Note: See TracChangeset for help on using the changeset viewer.