Changeset 103


Ignore:
Timestamp:
Jan 21, 2010, 1:56:10 PM (13 years ago)
Author:
duh
Message:
  • added error handling to the wizard
  • changed jquery-ui interface style to Redmond
Location:
trunk
Files:
1 added
2 deleted
5 edited
1 moved

Legend:

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

    r101 r103  
    4848                        flow.page = 0
    4949                        flow.pages = [
    50                                 [title: 'Een'],
     50                                [title: 'Study'],
    5151                                [title: 'Twoooo'],
    5252                                [title: 'Trois']
     
    6161                                flow.page = 1
    6262                        }
    63                         on("next").to "pageOne"
     63                        on("next").to "study"
    6464                }
    6565
    66                 pageOne {
    67                         render(view: "_one")
     66                study {
     67                        render(view: "_study")
    6868                        onRender {
    6969                                println "render page one"
     
    7272                        on("next") {
    7373                                // create a study instance
    74                                 /*
    7574                                println params
    76                                 def study = new Study(params)
     75                                flow.study = new Study(params)
    7776
    78                                
    79                                 if (study.validate()) {
     77                                // validate study
     78                                if (flow.study.validate()) {
    8079                                        println "study validates"
    8180                                } else {
     81                                        // validation failed, feedback errors
     82                                        flash.errors = new LinkedHashMap()
     83                                        this.appendErrors(flow.study,flash.errors)
    8284                                        println "errorrrs"
     85                                        println flash.errors
    8386                                        error()
    8487                                }
    85                                 */
    8688                        }.to "pageTwo"
    8789                }
     
    99101                        on("previous") {
    100102                                println "previous page!"
    101                         }.to "pageOne"
     103                        }.to "study"
    102104                }
    103105
     
    114116                }
    115117        }
     118
     119        /**
     120         * transform domain class validation errors into a human readable
     121         * linked hash map
     122         * @param object validated domain class
     123         * @returns object  linkedHashMap
     124         */
     125        def getHumanReadableErrors(object) {
     126                def errors = new LinkedHashMap()
     127
     128                object.errors.getAllErrors().each() {
     129                        errors[it.getArguments()[0]] = it.getDefaultMessage()
     130                }
     131
     132                return errors
     133        }
     134
     135        /**
     136         * append errors of a particular object to a map
     137         * @param object
     138         * @param map linkedHashMap
     139         * @void
     140         */
     141        def appendErrors(object, map) {
     142                this.appendErrorMap(this.getHumanReadableErrors(object), map)
     143        }
     144
     145        /**
     146         * append errors of one map to another map
     147         * @param map linkedHashMap
     148         * @param map linkedHashMap
     149         * @void
     150         */
     151        def appendErrorMap(map, mapToExtend) {
     152                map.each() {key, value ->
     153                        mapToExtend[key] = value
     154                }
     155        }
     156
    116157}
  • trunk/grails-app/domain/dbnp/studycapturing/Study.groovy

    r101 r103  
    33/**
    44 * Domain class describing the basic entity in the study capture part: the Study class.
     5 *
     6 * Revision information:
     7 * $Rev$
     8 * $Author$
     9 * $Date$
    510 */
    6 class Study {
     11class Study implements Serializable {
    712        nimble.User owner
    813        String title
     
    1621        Template template
    1722
    18         static hasMany = [editors: nimble.User, readers: nimble.User,
    19                 subjects: Subject, groups: SubjectGroup,
    20                 events: Event, samplingEvents: SamplingEvent]
     23        static hasMany = [      editors:                nimble.User,
     24                                                readers:                nimble.User,
     25                                                subjects:               Subject,
     26                                                groups:                 SubjectGroup,
     27                                                events:                 Event,
     28                                                samplingEvents: SamplingEvent
     29        ]
    2130
    2231        static constraints = {
     
    3140        }
    3241
    33   def String toString() {
    34     return title;
    35   }
    36 
    37 
     42        def String toString() {
     43                return title;
     44        }
    3845}
  • trunk/grails-app/taglib/dbnp/studycapturing/WizardTagLib.groovy

    r101 r103  
    182182                out << '</div>'
    183183                out << render(template: "/wizard/common/navigation")
     184                out << render(template: "/wizard/common/error")
    184185        }
    185186
  • trunk/grails-app/views/wizard/common/_error.gsp

    r88 r103  
    11<%
    2 /**
    3  * Wizard error template
    4  *
    5  * @author Jeroen Wesbeek
    6  * @since  20100114
    7  * @package wizard
    8  * @see    dbnp.studycapturing.WizardTagLib
    9  * @see    dbnp.studycapturing.WizardController
    10  *
    11  * Revision information:
    12  * $Rev$
    13  * $Author$
    14  * $Date$
    15  */
     2        /**
     3        * Wizard error template
     4        *
     5         * @author Jeroen Wesbeek
     6         * @since 20100114
     7        * @package wizard
     8         * @see dbnp.studycapturing.WizardTagLib
     9         * @see dbnp.studycapturing.WizardController
     10        *
     11        * Revision information:
     12        * $Rev$
     13        * $Author$
     14        * $Date$
     15        */
    1616%>
    17 <div id="wizardError" class="error"/>
     17<g:if test="${errors}">
     18        <div id="wizardError" class="error" title="errors">
     19                <g:each in="${errors}" var="error" status="e">
     20                        <p>
     21                                <g:if test="${!e}"><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 50px 0;"></span></g:if>
     22                                ${error.key} &rarr; ${error.value}
     23                        </p>
     24                </g:each>
     25        </div>
     26        <script type="text/javascript">
     27                $(function() {
     28                        $("div#wizardError").dialog({
     29                                bgiframe: true,
     30                                modal: true,
     31                                width: 600,
     32                                buttons: {
     33                                        Ok: function() {
     34                                                $(this).dialog('close');
     35                                        }
     36                                }
     37                        });
     38                });
     39        </script>
     40</g:if>
  • trunk/grails-app/views/wizard/common/_wizard.gsp

    r102 r103  
    2121                        <wizard:ajaxFlowRedirect form="form#wizardForm" name="next" url="[controller:'wizard',action:'pages']" update="[success:'wizardPage',failure:'wizardError']" afterSuccess="attachHelpTooltips()" />
    2222                </div>
    23                 <g:render template="common/error"/>
     23                <!--g:render template="common/error"//-->
    2424        </g:form>
    2525</div>
Note: See TracChangeset for help on using the changeset viewer.