Changeset 349


Ignore:
Timestamp:
Apr 19, 2010, 1:05:48 PM (9 years ago)
Author:
duh
Message:
  • added more templates to bootstrap
  • added a 300ms delay to ontology-chooser
  • refactored wizard subject page's "add subjects" dialogue (not working yet!) to incorporate an ontology field instead of a term select... this has to change though...
  • added template elements to tag library (ajaxButtonField and ontologyField)
  • minified ontology-chooser javascript
  • minified wizard.css
Location:
trunk
Files:
8 edited

Legend:

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

    r347 r349  
    2727
    2828                        // adding the academic
    29                         println "Adding academic study template..."
     29                        println ".adding academic study template..."
    3030                        def studyTemplate = new Template(
    3131                                name: 'Academic study', entity: dbnp.studycapturing.Study)
     
    3636                                .addToFields(new TemplateField(name: 'Lab code',type: TemplateFieldType.STRING))
    3737                                .addToFields(new TemplateField(name: 'Institute',type: TemplateFieldType.STRING))
     38                        .with { if (!validate()) { errors.each { println it} } else save()}
     39
     40                        // Mouse template
     41                        println ".adding mouse subject template..."
     42                        def mouseTemplate = new Template(
     43                                name: 'Mouse', entity: dbnp.studycapturing.Subject)
     44                        .addToFields(new TemplateField(
     45                                name: 'Strain', type: TemplateFieldType.ONTOLOGYTERM))
     46                        //.addToFields(genotypeField)
     47                        //.addToFields(genotypeTypeField)
     48                        //.addToFields(genderField)
     49                        .addToFields(new TemplateField(
     50                                name: 'Age (weeks)', type: TemplateFieldType.INTEGER, unit: 'weeks'))
     51                        .addToFields(new TemplateField(
     52                                name: 'Age type',type: TemplateFieldType.STRINGLIST,
     53                                listEntries: [new TemplateFieldListItem(name:'postnatal'),new TemplateFieldListItem(name:'embryonal')]))
     54                        .addToFields(new TemplateField(
     55                                name: 'Cage',type: TemplateFieldType.STRING))
     56                        .addToFields(new TemplateField(
     57                                name: '#Mice in cage',type: TemplateFieldType.INTEGER))
     58                        .addToFields(new TemplateField(
     59                                name: 'Litter size',type: TemplateFieldType.INTEGER))
     60                        .addToFields(new TemplateField(
     61                                name: 'Weight (g)', type: TemplateFieldType.DOUBLE, unit: 'gram'))
     62                        .with { if (!validate()) { errors.each { println it} } else save()}
     63
     64                        // Human template
     65                        println ".adding human subject template..."
     66                        def humanTemplate = new Template(
     67                                name: 'Human', entity: dbnp.studycapturing.Subject)
     68                        //.addToFields(genderField)
     69                        //.addToFields(ageField)
     70                        .addToFields(new TemplateField(
     71                                name: 'DOB',type: TemplateFieldType.DATE))
     72                        .addToFields(new TemplateField(
     73                                name: 'Height',type: TemplateFieldType.DOUBLE, unit: 'm'))
     74                        .addToFields(new TemplateField(
     75                                name: 'Weight (kg)',type: TemplateFieldType.DOUBLE, unit: 'kg'))
     76                        .addToFields(new TemplateField(
     77                                name: 'BMI',type: TemplateFieldType.DOUBLE, unit: 'kg/m2'))
     78                        .addToFields(new TemplateField(
     79                                name: 'Race',type: TemplateFieldType.STRING))
     80                        .addToFields(new TemplateField(
     81                                name: 'Waist circumference',type: TemplateFieldType.FLOAT, unit: 'cm'))
     82                        .addToFields(new TemplateField(
     83                                name: 'Hip circumference',type: TemplateFieldType.FLOAT, unit: 'cm'))
     84                        .addToFields(new TemplateField(
     85                                name: 'Systolic blood pressure',type: TemplateFieldType.FLOAT, unit: 'mmHg'))
     86                        .addToFields(new TemplateField(
     87                                name: 'Diastolic blood pressure',type: TemplateFieldType.FLOAT, unit: 'mmHg'))
     88                        .addToFields(new TemplateField(
     89                                name: 'Heart rate',type: TemplateFieldType.FLOAT, unit: 'beats/min'))
     90                        .addToFields(new TemplateField(
     91                                name: 'Run-in-food',type: TemplateFieldType.TEXT))
    3892                        .with { if (!validate()) { errors.each { println it} } else save()}
    3993
  • trunk/grails-app/controllers/dbnp/studycapturing/WizardController.groovy

    r343 r349  
    152152                        }
    153153                        on("add") {
     154                                println params
     155                                flash.values = params
     156/*
    154157                                // fetch species by name (as posted by the form)
    155158                                def speciesTerm = Term.findByName(params.addSpecies)
     
    182185                                        flow.subjectTemplates[ subjectTemplateName ]['subjects'][ subjectsSize ] = increment
    183186                                }
     187*/
    184188                        }.to "subjects"
    185189                        on("next") {
  • trunk/grails-app/domain/dbnp/studycapturing/TemplateField.groovy

    r348 r349  
    11package dbnp.studycapturing
     2
     3import dbnp.data.Ontology
    24
    35/**
     
    1416        String unit
    1517        String comment // help string for the user interface
     18        List listEntries
    1619
    17         List listEntries
    18         static hasMany = [listEntries : TemplateFieldListItem,
    19  // to store the entries to choose from when the type is 'item from predefined list'
    20            ontologies : Ontology // to store the ontologies to choose from when the type is 'ontology term'
    21 ]
     20    static hasMany = [listEntries : TemplateFieldListItem,
     21                // to store the entries to choose from when the type is 'item from predefined list'
     22                ontologies : Ontology // to store the ontologies to choose from when the type is 'ontology term'
     23        ]
     24       
    2225        static constraints = {
    2326                name(unique: true)
  • trunk/grails-app/taglib/dbnp/studycapturing/WizardTagLib.groovy

    r341 r349  
    212212                def addExampleElement = attrs.remove('addExampleElement')
    213213                def addExample2Element = attrs.remove('addExample2Element')
     214                def helpText = help().trim()
    214215
    215216                // got an ajax onchange action?
     
    243244                out << ' <div class="input">'
    244245                out << renderedElement
    245                 if (help()) {
     246                if (helpText.size() > 0) {
    246247                        out << '        <div class="helpIcon"></div>'
    247248                }
     
    272273
    273274                // add help content if it is available
    274                 if (help()) {
     275                if (helpText.size() > 0) {
    275276                        out << '  <div class="helpContent">'
    276                         out << '    ' + help()
     277                        out << '    ' + helpText
    277278                        out << '  </div>'
    278279                }
    279280
    280281                out << '</div>'
     282        }
     283
     284        /**
     285         * render an ajaxButtonElement
     286         * @param Map attrs
     287         * @param Closure body  (help text)
     288         */
     289        def ajaxButtonElement = { attrs, body ->
     290                baseElement.call(
     291                        'ajaxButton',
     292                        attrs,
     293                        body
     294                )
    281295        }
    282296
     
    436450        }
    437451
     452        /**
     453         * Ontology form element
     454         * @param Map attributes
     455         * @param Closure help content
     456         */
     457        def ontologyElement = { attrs, body ->
     458                // @see http://www.bioontology.org/wiki/index.php/NCBO_Widgets#Term-selection_field_on_a_form
     459                // @see ontology-chooser.js, table-editor.js
     460                baseElement.call(
     461                        'textField',
     462                        [
     463                            name: attrs.name,
     464                                value: attrs.value,
     465                                description: attrs.description,
     466                                rel: 'ontology-' + ((attrs.ontology) ? attrs.ontology : 'all') + '-name',
     467                                size: 25
     468                        ],
     469                        body
     470                )
     471                out << hiddenField(
     472                        name: attrs.name + '-concept_id'
     473                )
     474                out << hiddenField(
     475                        name: attrs.name + '-ontology_id'
     476                )
     477                out << hiddenField(
     478                        name: attrs.name + '-full_id'
     479                )
     480        }
    438481
    439482        /**
  • trunk/grails-app/views/wizard/pages/_subjects.gsp

    r342 r349  
    2323        </span>
    2424
    25         <wizard:ajaxButton name="add" value="Add" url="[controller:'wizard',action:'pages']" update="[success:'wizardPage',failure:'wizardError']" afterSuccess="onWizardPage()" />
    26         <input name="addNumber" size="4" maxlength="4" value="1">
    27         subjects of species
    28         <wizard:speciesSelect name="addSpecies" />
    29         using the
    30         <wizard:templateSelect name="template" description="Template" value="${study?.template}" entity="${dbnp.studycapturing.Subject}" />
    31         template
     25        <wizard:textFieldElement name="addNumber" description="Number of subjects to add" error="addNumber" value="1" size="4" maxlength="4">
     26                The number of subjects to add to your study
     27        </wizard:textFieldElement>
     28        <wizard:ontologyElement name="species" description="of species" value="" ontology="1132">
     29                The species of the subjects you would like to add to your study
     30        </wizard:ontologyElement>
     31        <wizard:templateElement name="template" description="with template" value="" error="template" entity="${dbnp.studycapturing.Subject}" >
     32                The template to use for this study
     33        </wizard:templateElement>
     34        <wizard:ajaxButtonElement name="add" value="Add" url="[controller:'wizard',action:'pages']" update="[success:'wizardPage',failure:'wizardError']" afterSuccess="onWizardPage()">
     35        </wizard:ajaxButtonElement>
     36
    3237
    3338<g:if test="${subjects}">
  • trunk/web-app/css/wizard.min.css

    r302 r349  
    1 .wizard{display:block;padding-top:10px;}.wizard .info{display:block;border:1px solid #006DBA;background-color:#EEE;padding:10px;font-size:10px;margin:10px 0 10px 0;}.wizard .info .title{color:#006DBA;font-size:14px;font-weight:normal;display:block;margin-bottom:5px;padding-left:20px;background:url(../images/icons/famfamfam/information.png) no-repeat center left;}.wizard .info .todo{color:#006DBA;font-size:14px;font-weight:normal;display:block;margin-bottom:5px;padding-left:20px;background:url(../images/icons/famfamfam/wrench.png) no-repeat center left;}.wizard .info .known{color:#006DBA;font-size:14px;font-weight:normal;display:block;margin-bottom:5px;padding-left:20px;background:url(../images/icons/famfamfam/eye.png) no-repeat center left;}.wizard .famfamfam{width:16px;height:16px;}.wizard .spinner{background:url(../images/spinner.gif) no-repeat left top;width:16px;height:16px;display:none;}.wizard .sliderContainer{display:block;margin-top:10px;width:150px;}.wizard .tabs{display:block;height:18px;padding-top:20px;background-color:#EEE;}.wizard .tabs .element{background-color:#EEE;border-bottom:4px solid #006DBA;border-right:1px solid #006DBA;color:#006DBA;cursor:default;display:inline;font-size:10px;height:20px;margin:0;padding:20px 15px 0 15px;text-align:center;text-decoration:none;}.wizard .tabs .active{background-color:#add9ee;color:#fff;font-weight:bold;}.wizard .content{display:block;}.wizard .navigation{display:block;color:#666;font-size:10px;padding-top:10px;}.wizard .prevnext{cursor:pointer;color:#006DBA;background-color:transparent;border:none;}.wizard .element .input .isExample{color:#006DBA;background-color:transparent;border:0;input:disabled;}.wizard .element{display:block;}.wizard .element .description{display:inline-block;font-size:11px;width:250px;word-wrap:break-word;}.wizard .element .input{display:inline;}.wizard .error{background:url(../images/icons/famfamfam/exclamation.png) no-repeat 230px 4px;}.wizard .element .input input{vertical-align:top;border:1px solid #CCC;margin:2px 0;padding:2px 4px;}.wizard .element .input input:focus,select:focus,textarea:focus{border:1px solid #B2D1FF;}.wizard .element .helpIcon{display:inline-block;margin-top:4px;background:url(../images/icons/famfamfam/help.png) no-repeat left top;width:16px;height:16px;}.wizard .element .helpContent{display:none;}.wizard .element .help{vertical-align:top;display:inline-block;}.wizard .element .help .icon{margin-top:4px;background:url(../images/icons/famfamfam/help.png) no-repeat left top;width:16px;height:16px;}.wizard .element .help .content{display:none;}.wizard .table{display:block;border:1px solid #575a5d;background-color:#ebf7fc;margin-top:10px;font-size:11px;overflow:hidden;white-space:nowrap;}.wizard .table .header{display:block;background-color:#006DBA;color:#fff;font-weight:bold;width:auto;height:32px;line-height:32px;}.wizard .column{display:inline-block;padding:2px 4px;width:120px;}.wizard .firstColumn{display:inline-block;padding:2px 4px;width:20px;}.wizard .table .row{display:block;height:32px;border-top:1px solid #8e908f;width:auto;}.wizard .table .row input,.wizard .table .row select{background-color:#fff;}.wizard .table .ui-selected{background-color:#ffab7b;}.wizard .table .ui-selecting{background-color:#f2e3bc;}.wizard .table .row .warning{color:red;font-size:8px;height:10px;}.wizard .table .row .error{background-color:#ffb0b7;}.wizard .table input[type=text],.wizard .table select{border:1px solid #8e908f;margin:2px 0;padding:2px 4px;background-color:transparent;width:100px;}.wizard .table .header input[type=text],.wizard .table .header select,.wizard .table .header button{border:1px solid #8e908f;margin:2px 0;padding:2px 4px;background-color:#fff;width:75px;}.wizard .table .highlight,.wizard .table .highlight input,.wizard .table .highlight select{background-color:#006DBA;color:#fff;}.wizard .table .highlight input,.wizard .table .highlight select{background-color:#6e99d4;color:#fff;}
     1.wizard{display:block;padding-top:10px;}.wizard .info{display:block;border:1px solid #006DBA;background-color:#EEE;padding:10px;font-size:10px;margin:10px 0 10px 0;}.wizard .info .title{color:#006DBA;font-size:14px;font-weight:normal;display:block;margin-bottom:5px;padding-left:20px;background:url(../images/icons/famfamfam/information.png) no-repeat center left;}.wizard .info .todo{color:#006DBA;font-size:14px;font-weight:normal;display:block;margin-bottom:5px;padding-left:20px;background:url(../images/icons/famfamfam/wrench.png) no-repeat center left;}.wizard .info .known{color:#006DBA;font-size:14px;font-weight:normal;display:block;margin-bottom:5px;padding-left:20px;background:url(../images/icons/famfamfam/eye.png) no-repeat center left;}.wizard .famfamfam{width:16px;height:16px;}.wizard .spinner{background:url(../images/spinner.gif) no-repeat left top;width:16px;height:16px;display:none;}.wizard .sliderContainer{display:block;margin-top:10px;width:150px;}.wizard .tabs{display:block;padding-bottom:2px;border-bottom:2px solid #006DBA;width:100%;}.wizard .tabs ul{list-style-type:none;padding:0;font-size:10px;margin:0;font-family:Verdana,Arial,Helvetica,sans-serif;font-size:10px;height:20px;width:100%;}.wizard .tabs img{border:0;}.wizard .tabs li{float:left;margin:0;height:20px;float:left;display:block;text-align:center;text-decoration:none;color:#006DBA;background:#CCC;font-weight:bold;}.wizard .tabs .content{padding:0 10px 0 10px;display:inline;border:0;}.wizard .tabs .active{background-color:#006DBA!important;color:#fff!important;}.wizard .tabs .arrow{position:inherit;margin-top:0;margin-bottom:0;display:inline;}.wizard .content{display:block;padding-bottom:10px;border-bottom:2px solid #006DBA;}.wizard .navigation{display:block;color:#666;font-size:10px;}.wizard .prevnext{cursor:pointer;color:#006DBA;background-color:transparent;border:none;}.wizard .element .input .isExample{color:#006DBA;background-color:transparent;border:0;input:disabled;}.wizard .element{display:block;}.wizard .element .description{display:inline-block;font-size:11px;width:250px;word-wrap:break-word;}.wizard .element .input{display:inline;}.wizard .error{background:url(../images/icons/famfamfam/exclamation.png) no-repeat 230px 4px;}.wizard .element .input input{vertical-align:top;border:1px solid #CCC;margin:2px 0;padding:2px 4px;}.wizard .element .input input:focus,select:focus,textarea:focus{border:1px solid #B2D1FF;}.wizard .element .helpIcon{display:inline-block;margin-top:4px;background:url(../images/icons/famfamfam/help.png) no-repeat left top;width:16px;height:16px;}.wizard .element .helpContent{display:none;}.wizard .element .help{vertical-align:top;display:inline-block;}.wizard .element .help .icon{margin-top:4px;background:url(../images/icons/famfamfam/help.png) no-repeat left top;width:16px;height:16px;}.wizard .element .help .content{display:none;}.wizard .table{display:block;border:1px solid #575a5d;background-color:#ebf7fc;margin-top:10px;font-size:11px;overflow:hidden;white-space:nowrap;}.wizard .table .header{display:block;background-color:#006DBA;color:#fff;font-weight:bold;width:auto;height:32px;line-height:32px;}.wizard .column{display:inline-block;padding:2px 4px;width:120px;}.wizard .firstColumn{display:inline-block;padding:2px 4px;width:20px;}.wizard .table .row{display:block;height:32px;border-top:1px solid #8e908f;width:auto;}.wizard .table .row input,.wizard .table .row select{background-color:#fff;}.wizard .table .ui-selected{background-color:#ffab7b;}.wizard .table .ui-selecting{background-color:#f2e3bc;}.wizard .table .row .warning{color:red;font-size:8px;height:10px;}.wizard .table .row .error{background-color:#ffb0b7;}.wizard .table input[type=text],.wizard .table select{border:1px solid #8e908f;margin:2px 0;padding:2px 4px;background-color:transparent;width:100px;}.wizard .table .header input[type=text],.wizard .table .header select,.wizard .table .header button{border:1px solid #8e908f;margin:2px 0;padding:2px 4px;background-color:#fff;width:75px;}.wizard .table .highlight,.wizard .table .highlight input,.wizard .table .highlight select{background-color:#006DBA;color:#fff;}.wizard .table .highlight input,.wizard .table .highlight select{background-color:#6e99d4;color:#fff;}.wizard .bigbutton{background:url(../images/wizard/big-button.jpg) no-repeat left top;border:0;width:454px;height:53px;color:#fff;font-size:18pt;}.wizard .bigbutton:hover{color:#000;}.wizard .bigtext{color:#006dba;font-weight:normal;font-size:24px;margin:.8em 0 .3em 0;display:block;width:100%;text-align:center;}
  • trunk/web-app/js/ontology-chooser.js

    r310 r349  
    2424 * @package     wizard
    2525 * @requires    jquery, jquery-ui
    26  * @see         http://www.bioontology.org/wiki/index.php/NCBO_Widgets#Term-selection_field_on_a_form
     26 * @see         http://bioportal.bioontology.org/ontologies/
    2727 * @see         http://bioportal.bioontology.org/search/json_search/?q=musculus
    2828 *
     
    3535}
    3636OntologyChooser.prototype = {
    37     minLength   : 2,    // minimum input length before launching Ajax request
     37    minLength   : 3,    // minimum input length before launching Ajax request
    3838    cache       : [],   // ontology cache
    3939
     
    6868        inputElement.autocomplete({
    6969            minLength: that.minLength,
     70            delay: 300,
    7071            search: function(event, ui) {
    7172                selected = false;
  • trunk/web-app/js/ontology-chooser.min.js

    r310 r349  
    1 function OntologyChooser(){}OntologyChooser.prototype={minLength:2,cache:[],init:function(){var a=this;$("input[rel*='ontology']").each(function(){a.initAutocomplete(this)})},initAutocomplete:function(d){var f=this;var g=$(d);var e=false;var c=g.attr("rel").split("-");var b=c[1];var a=c[2];if(b=="all"){b=""}g.autocomplete({minLength:f.minLength,search:function(h,i){e=false},source:function(j,h){var k=$.trim(j.term);var i="http://bioportal.bioontology.org/search/json_search/"+b+"?q="+j.term+"&response=json&callback=?";if(f.cache[k]){h(f.cache[k])}else{$.getJSON(i,function(m){var l=f.parseData(m.data);f.cache[k]=l;h(f.parseData(m.data))})}},select:function(i,j){e=true;var h=g;f.setInputValue(h,"concept_id",j.item.concept_id);f.setInputValue(h,"ontology_id",j.item.ontology_id);f.setInputValue(h,"full_id",j.item.full_id);h.removeClass("error")},close:function(i,j){if(!e){var h=g;g.val("");f.setInputValue(h,"concept_id","");f.setInputValue(h,"ontology_id","");f.setInputValue(h,"full_id","");h.addClass("error")}}})},setInputValue:function(e,c,d){var a=e.attr("name")+"-"+c;var b=e.parent().find("input[name='"+a+"']");if(b.size()>0){$(b[0]).val(d)}else{e.after('<input type="hidden" name="'+a+'" value="'+d+'"/>')}},parseData:function(d){var a=[];var c=d.split("~!~");for(var b=0;b<c.length;b++){var f=$.trim(c[b]);if(f){var e=f.split("|");a[a.length]={value:e[0],label:e[0]+' <span class="about">('+e[2]+')</span> <span class="from">from: '+e[(e.length-1)]+"</span>",preferred_name:e[0],concept_id:e[1],ontology_id:e[3],full_id:e[4]}}}return a}};
     1function OntologyChooser(){}OntologyChooser.prototype={minLength:3,cache:[],init:function(){var a=this;$("input[rel*='ontology']").each(function(){a.initAutocomplete(this)})},initAutocomplete:function(d){var f=this;var g=$(d);var e=false;var c=g.attr("rel").split("-");var b=c[1];var a=c[2];if(b=="all"){b=""}g.autocomplete({minLength:f.minLength,delay:300,search:function(h,i){e=false},source:function(j,h){var k=$.trim(j.term);var i="http://bioportal.bioontology.org/search/json_search/"+b+"?q="+j.term+"&response=json&callback=?";if(f.cache[k]){h(f.cache[k])}else{$.getJSON(i,function(m){var l=f.parseData(m.data);f.cache[k]=l;h(f.parseData(m.data))})}},select:function(i,j){e=true;var h=g;f.setInputValue(h,"concept_id",j.item.concept_id);f.setInputValue(h,"ontology_id",j.item.ontology_id);f.setInputValue(h,"full_id",j.item.full_id);h.removeClass("error")},close:function(i,j){if(!e){var h=g;g.val("");f.setInputValue(h,"concept_id","");f.setInputValue(h,"ontology_id","");f.setInputValue(h,"full_id","");h.addClass("error")}}})},setInputValue:function(e,c,d){var a=e.attr("name")+"-"+c;var b=e.parent().find("input[name='"+a+"']");if(b.size()>0){$(b[0]).val(d)}else{e.after('<input type="hidden" name="'+a+'" value="'+d+'"/>')}},parseData:function(d){var a=[];var c=d.split("~!~");for(var b=0;b<c.length;b++){var f=$.trim(c[b]);if(f){var e=f.split("|");a[a.length]={value:e[0],label:e[0]+' <span class="about">('+e[2]+')</span> <span class="from">from: '+e[(e.length-1)]+"</span>",preferred_name:e[0],concept_id:e[1],ontology_id:e[3],full_id:e[4]}}}return a}};
Note: See TracChangeset for help on using the changeset viewer.