Changeset 250


Ignore:
Timestamp:
Mar 9, 2010, 2:16:07 PM (13 years ago)
Author:
duh
Message:
  • date and datetimefields are now handled independent of naming but by field type (a rel='date' and rel='datetime' argument is added to the rendered input element)
  • client side error reporting did not work properly for select elements
  • dynamically inserted javascript confirmation warning in the DOM-anchors outside of the wizard (navigating away from the wizard without saving causes loss of data and work)
Location:
trunk
Files:
4 edited

Legend:

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

    r247 r250  
    580580                                        def value = params.get('subject_' + subjectId + '_' + subjectField.name)
    581581
    582 // TODO: UNCOMMENT THIS         if (value) flow.subjects[ subjectId ].setFieldValue(subjectField.name, value)
     582                                        if (value) flow.subjects[ subjectId ].setFieldValue(subjectField.name, value)
    583583                                }
    584584
  • trunk/grails-app/taglib/dbnp/studycapturing/WizardTagLib.groovy

    r247 r250  
    343343                }
    344344
     345                // add 'rel' field to identity the datefield using javascript
     346                attrs.rel = 'date'
     347
    345348                // set some textfield values
    346349                attrs.maxlength = (attrs.maxlength) ? attrs.maxlength : 10
     
    367370                        attrs.value = String.format('%td/%<tm/%<tY %<tH:%<tM', attrs.value)
    368371                }
     372
     373                // add 'rel' field to identity the field using javascript
     374                attrs.rel = 'datetime'
    369375
    370376                attrs.addExampleElement = true
     
    581587                        out << '<div class="' + attrs.get('class') + '">'
    582588
    583                         switch (it.type) {
     589                        switch (it.type.toString()) {
     590                                case ['STRING', 'TEXT', 'INTEGER', 'FLOAT', 'DOUBLE']:
     591                                        out << textField(
     592                                                name: attrs.name + '_' + it.name,
     593                                                value: (intFields) ? intFields.get(it.name) : ''
     594                                        )
     595                                        break
    584596                                case 'STRINGLIST':
    585597                                        // render stringlist subjectfield
     
    593605                                                out << '<span class="warning">no values!!</span>'
    594606                                        }
    595                                         break;
    596                                 case 'INTEGER':
    597                                         // render integer subjectfield
    598                                         out << textField(
    599                                                 name: attrs.name + '_' + it.name,
    600                                                 value: (intFields) ? intFields.get(it.name) : ''
    601                                         )
    602                                         break;
    603                                 case 'FLOAT':
    604                                         // render float subjectfield
    605                                         out << textField(
    606                                                 name: attrs.name + '_' + it.name,
    607                                                 value: (floatFields) ? floatFields.get(it.name) : ''
    608                                         )
    609                                         break;
     607                                        break
    610608                                default:
    611609                                        // unsupported field type
     
    632630                        // render template fields
    633631                        template.fields.each() {
    634                                 switch (it.type) {
     632                                switch (it.type.toString()) {
     633                                        case ['STRING', 'TEXT', 'INTEGER', 'FLOAT', 'DOUBLE']:
     634                                                out << textFieldElement(
     635                                                        description: it.name,
     636                                                        name: it.name
     637                                                )
     638                                                break
    635639                                        case 'STRINGLIST':
    636640                                                if (!it.listEntries.isEmpty()) {
     
    645649                                                }
    646650                                                break
    647                                         case 'STRING':
    648                                                 out << textFieldElement(
    649                                                         description: it.name,
    650                                                         name: it.name
    651                                                 )
    652                                                 break
    653651                                        case 'DATE':
    654652                                                out << dateElement(
    655                                                         description: it.name,
    656                                                         name: it.name
    657                                                 )
    658                                                 break
    659                                         case 'INTEGER':
    660                                                 out << textFieldElement(
    661                                                         description: it.name,
    662                                                         name: it.name
    663                                                 )
    664                                                 break
    665                                         case 'DOUBLE':
    666                                                 out << textFieldElement(
    667653                                                        description: it.name,
    668654                                                        name: it.name
  • trunk/grails-app/views/wizard/common/_error.gsp

    r247 r250  
    2121                                <g:if test="${!e}"><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 50px 0;"></span></g:if>
    2222                                ${error.value['key']} &rarr; ${error.value['value']}
     23${error.value['dynamic']}
    2324                        </p>
    2425                </g:each>
     
    2829                <g:each in="${errors}" var="error">
    2930                <g:if test="${error.value['dynamic']}">
    30                 $("input:[name='${error.key}']").addClass('error');
     31                $("input:[name='${error.key}'], select:[name='${error.key}']").addClass('error');
    3132                </g:if><g:else>
    32                 $("input:[name='${error.key}']").parent().parent().addClass('error');
     33                $("input:[name='${error.key}'], select:[name='${error.key}']").parent().parent().addClass('error');
    3334                </g:else>
    3435                </g:each>
     
    3738                $(function() {
    3839                        $("div#wizardError").dialog({
    39                                 bgiframe: true,
    4040                                modal: true,
    4141                                width: 600,
  • trunk/web-app/js/wizard.js

    r247 r250  
    2626
    2727    // attach Tooltips
     28    insertOnRedirectWarning();
    2829    onWizardPage();
    2930});
     
    4445    // accordeon(s)
    4546    $("#accordion").accordion();
     47}
     48
     49// insert a redirect confirmation dialogue to all anchors leading the
     50// user away from the wizard
     51function insertOnRedirectWarning() {
     52    // find all anchors that lie outside the wizard
     53    $('a').each(function() {
     54        var element = $(this)
     55        var re = /^#/gi;
     56
     57        if (!element.attr('href').match(/^#/gi) && !element.attr('href').match(/\/([^\/]+)\/wizard\/pages/gi)) {
     58            // bind a warning to the onclick event
     59            element.bind('click',function() {
     60                return confirm('Warning: navigating away from the wizard causes loss of work and unsaved data. Are you sure you want to continue?');
     61            })
     62        }
     63    })
    4664}
    4765
     
    117135// add datepickers to date fields
    118136function attachDatePickers() {
    119     $('div#wizard').find("input[type=text][name$='Date']").each(function() {
     137    $('div#wizard').find("input[type=text][rel$='date']").each(function() {
    120138        $(this).datepicker({
    121139            dateFormat  : 'dd/mm/yy',
     
    128146// add datetimepickers to date fields
    129147function attachDateTimePickers() {
    130     $('div#wizard').find("input[type=text][name$='Time']").each(function() {
     148    $('div#wizard').find("input[type=text][rel$='datetime']").each(function() {
    131149        $(this).datepicker({
    132150            dateFormat      : 'dd/mm/yy',
Note: See TracChangeset for help on using the changeset viewer.