source: trunk/grails-app/taglib/dbnp/studycapturing/WizardTagLib.groovy @ 399

Last change on this file since 399 was 399, checked in by duh, 13 years ago
  • changed term / ontology fields to select elements instead
  • todo: bootrstrap needs improvement as genotype and strain do not yet contain ontologies
  • Property svn:keywords set to Date Author Rev
File size: 21.2 KB
Line 
1package dbnp.studycapturing
2
3import org.codehaus.groovy.grails.plugins.web.taglib.JavascriptTagLib
4import dbnp.studycapturing.*
5import dbnp.data.*
6import cr.co.arquetipos.crypto.Blowfish
7
8/**
9 * Wizard tag library
10 *
11 * @author Jeroen Wesbeek
12 * @since 20100113
13 * @package wizard
14 *
15 * Revision information:
16 * $Rev: 399 $
17 * $Author: duh $
18 * $Date: 2010-05-10 14:32:45 +0000 (ma, 10 mei 2010) $
19 */
20class WizardTagLib extends JavascriptTagLib {
21        // define the tag namespace (e.g.: <wizard:action ... />
22        static namespace = "wizard"
23
24        // define the AJAX provider to use
25        static ajaxProvider = "jquery"
26
27        // define default text field width
28        static defaultTextFieldSize = 25;
29
30        /**
31         * ajaxButton tag, this is a modified version of the default
32         * grails submitToRemote tag to work with grails webflows.
33         * Usage is identical to submitToRemote with the only exception
34         * that a 'name' form element attribute is required. E.g.
35         * <wizard:ajaxButton name="myAction" value="myButton ... />
36         *
37         * you can also provide a javascript function to execute after
38         * success. This behaviour differs from the default 'after'
39         * action which always fires after a button press...
40         *
41         * @see http://blog.osx.eu/2010/01/18/ajaxifying-a-grails-webflow/
42         * @see http://www.grails.org/WebFlow
43         * @see http://www.grails.org/Tag+-+submitToRemote
44         * @todo perhaps some methods should be moved to a more generic
45         *        'webflow' taglib or plugin
46         * @param Map attributes
47         * @param Closure body
48         */
49        def ajaxButton = {attrs, body ->
50                // get the jQuery version
51                def jQueryVersion = grailsApplication.getMetadata()['plugins.jquery']
52
53                // fetch the element name from the attributes
54                def elementName = attrs['name'].replaceAll(/ /, "_")
55
56                // javascript function to call after success
57                def afterSuccess = attrs['afterSuccess']
58
59                // src parameter?
60                def src = attrs['src']
61                def alt = attrs['alt']
62
63                // generate a normal submitToRemote button
64                def button = submitToRemote(attrs, body)
65
66                /**
67                 * as of now (grails 1.2.0 and jQuery 1.3.2.4) the grails webflow does
68                 * not properly work with AJAX as the submitToRemote button does not
69                 * handle and submit the form properly. In order to support webflows
70                 * this method modifies two parts of a 'normal' submitToRemote button:
71                 *
72                 * 1) replace 'this' with 'this.form' as the 'this' selector in a button
73                 *    action refers to the button and / or the action upon that button.
74                 *    However, it should point to the form the button is part of as the
75                 *    the button should submit the form data.
76                 * 2) prepend the button name to the serialized data. The default behaviour
77                 *    of submitToRemote is to remove the element name altogether, while
78                 *    the grails webflow expects a parameter _eventId_BUTTONNAME to execute
79                 *    the appropriate webflow action. Hence, we are going to prepend the
80                 *    serialized formdata with an _eventId_BUTTONNAME parameter.
81                 */
82                if (jQueryVersion =~ /^1.([1|2|3]).(.*)/) {
83                        // fix for older jQuery plugin versions
84                        button = button.replaceFirst(/data\:jQuery\(this\)\.serialize\(\)/, "data:\'_eventId_${elementName}=1&\'+jQuery(this.form).serialize()")
85                } else {
86                        // as of jQuery plugin version 1.4.0.1 submitToRemote has been modified and the
87                        // this.form part has been fixed. Consequently, our wrapper has changed as well...
88                        button = button.replaceFirst(/data\:jQuery/, "data:\'_eventId_${elementName}=1&\'+jQuery")
89                }
90
91                // add an after success function call?
92                // usefull for performing actions on success data (hence on refreshed
93                // wizard pages, such as attaching tooltips)
94                if (afterSuccess) {
95                        button = button.replaceFirst(/\.html\(data\)\;/, '.html(data);' + afterSuccess + ';')
96                }
97
98                // got an src parameter?
99                if (src) {
100                        def replace = 'type="image" src="' + src + '"'
101
102                        if (alt) replace = replace + ' alt="' + alt + '"'
103
104                        button = button.replaceFirst(/type="button"/, replace)
105                }
106
107                // replace double semi colons
108                button = button.replaceAll(/;{2,}/, ';')
109
110                // render button
111                out << button
112        }
113
114        /**
115         * generate a ajax submit JavaScript
116         * @see WizardTagLib::ajaxFlowRedirect
117         * @see WizardTagLib::baseElement (ajaxSubmitOnChange)
118         */
119        def ajaxSubmitJs = {attrs, body ->
120                // define AJAX provider
121                setProvider([library: ajaxProvider])
122
123                // got a function name?
124                def functionName = attrs.remove('functionName')
125                if (functionName && !attrs.get('name')) {
126                        attrs.name = functionName
127                }
128
129                // generate an ajax button
130                def button = this.ajaxButton(attrs, body)
131
132                // strip the button part to only leave the Ajax call
133                button = button.replaceFirst(/<[^\"]*\"jQuery.ajax/, 'jQuery.ajax')
134                button = button.replaceFirst(/return false.*/, '')
135
136                // change form if a form attribute is present
137                if (attrs.get('form')) {
138                        button = button.replaceFirst(/this\.form/,
139                                "\\\$('" + attrs.get('form') + "')"
140                        )
141                }
142
143                out << button
144        }
145
146        /**
147         * generate ajax webflow redirect javascript
148         *
149         * As we have an Ajaxified webflow, the initial wizard page
150         * cannot contain a wizard form, as upon a failing submit
151         * (e.g. the form data does not validate) the form should be
152         * shown again. However, the Grails webflow then renders the
153         * complete initial wizard page into the success div. As this
154         * ruins the page layout (a page within a page) we want the
155         * initial page to redirect to the first wizard form to enter
156         * the webflow correctly. We do this by emulating an ajax post
157         * call which updates the wizard content with the first wizard
158         * form.
159         *
160         * Usage: <wizard:ajaxFlowRedirect form="form#wizardForm" name="next" url="[controller:'wizard',action:'pages']" update="[success:'wizardPage',failure:'wizardError']" />
161         * form = the form identifier
162         * name = the action to execute in the webflow
163         * update = the divs to update upon success or error
164         *
165         * OR: to generate a JavaScript function you can call yourself, use 'functionName' instead of 'name'
166         *
167         * Example initial webflow action to work with this javascript:
168         * ...
169         * mainPage {*  render(view: "/wizard/index")
170         *      onRender {*             flow.page = 1
171         *}*    on("next").to "pageOne"
172         *}* ...
173         *
174         * @param Map attributes
175         * @param Closure body
176         */
177        def ajaxFlowRedirect = {attrs, body ->
178                // generate javascript
179                out << '<script type="text/javascript">'
180                out << '$(document).ready(function() {'
181                out << ajaxSubmitJs(attrs, body)
182                out << '});'
183                out << '</script>'
184        }
185
186        /**
187         * render the content of a particular wizard page
188         * @param Map attrs
189         * @param Closure body  (help text)
190         */
191        def pageContent = {attrs, body ->
192                // define AJAX provider
193                setProvider([library: ajaxProvider])
194
195                // render new body content
196                out << render(template: "/wizard/common/tabs")
197                out << '<div class="content">'
198                out << body()
199                out << '</div>'
200                out << render(template: "/wizard/common/navigation")
201                out << render(template: "/wizard/common/error")
202        }
203
204        /**
205         * generate a base form element
206         * @param String inputElement name
207         * @param Map attributes
208         * @param Closure help content
209         */
210        def baseElement = {inputElement, attrs, help ->
211println ".rendering [" + inputElement + "] with name [" + attrs.get('name') + "] and value [" + ((attrs.value) ? attrs.get('value').toString() : "-") + "]"
212                // work variables
213                def description = attrs.remove('description')
214                def addExampleElement = attrs.remove('addExampleElement')
215                def addExample2Element = attrs.remove('addExample2Element')
216                def helpText = help().trim()
217
218                // got an ajax onchange action?
219                def ajaxOnChange = attrs.remove('ajaxOnChange')
220                if (ajaxOnChange) {
221                        if (!attrs.onChange) attrs.onChange = ''
222
223                        // add onChange AjaxSubmit javascript
224                        attrs.onChange += ajaxSubmitJs(
225                                [
226                                        functionName: ajaxOnChange,
227                                        url: attrs.get('url'),
228                                        update: attrs.get('update'),
229                                        afterSuccess: attrs.get('afterSuccess')
230                                ],
231                                ''
232                        )
233                }
234
235                // execute inputElement call
236                def renderedElement = "$inputElement"(attrs)
237
238                // if false, then we skip this element
239                if (!renderedElement) return false
240
241                // render a form element
242                out << '<div class="element">'
243                out << ' <div class="description">'
244                out << description
245                out << ' </div>'
246                out << ' <div class="input">'
247                out << renderedElement
248                if (helpText.size() > 0) {
249                        out << '        <div class="helpIcon"></div>'
250                }
251
252                // add an disabled input box for feedback purposes
253                // @see dateElement(...)
254                if (addExampleElement) {
255                        def exampleAttrs = new LinkedHashMap()
256                        exampleAttrs.name = attrs.get('name') + 'Example'
257                        exampleAttrs.class = 'isExample'
258                        exampleAttrs.disabled = 'disabled'
259                        exampleAttrs.size = 30
260                        out << textField(exampleAttrs)
261                }
262
263                // add an disabled input box for feedback purposes
264                // @see dateElement(...)
265                if (addExample2Element) {
266                        def exampleAttrs = new LinkedHashMap()
267                        exampleAttrs.name = attrs.get('name') + 'Example2'
268                        exampleAttrs.class = 'isExample'
269                        exampleAttrs.disabled = 'disabled'
270                        exampleAttrs.size = 30
271                        out << textField(exampleAttrs)
272                }
273
274                out << ' </div>'
275
276                // add help content if it is available
277                if (helpText.size() > 0) {
278                        out << '  <div class="helpContent">'
279                        out << '    ' + helpText
280                        out << '  </div>'
281                }
282
283                out << '</div>'
284        }
285
286        /**
287         * render an ajaxButtonElement
288         * @param Map attrs
289         * @param Closure body  (help text)
290         */
291        def ajaxButtonElement = { attrs, body ->
292                baseElement.call(
293                        'ajaxButton',
294                        attrs,
295                        body
296                )
297        }
298
299        /**
300         * render a textFieldElement
301         * @param Map attrs
302         * @param Closure body  (help text)
303         */
304        def textFieldElement = {attrs, body ->
305                // set default size, or scale to max length if it is less than the default size
306                if (!attrs.get("size")) {
307                        if (attrs.get("maxlength")) {
308                                attrs.size = ((attrs.get("maxlength") as int) > defaultTextFieldSize) ? defaultTextFieldSize : attrs.get("maxlength")
309                        } else {
310                                attrs.size = defaultTextFieldSize
311                        }
312                }
313
314                // render template element
315                baseElement.call(
316                        'textField',
317                        attrs,
318                        body
319                )
320        }
321
322        /**
323         * render a select form element
324         * @param Map attrs
325         * @param Closure body  (help text)
326         */
327        def selectElement = {attrs, body ->
328                baseElement.call(
329                        'select',
330                        attrs,
331                        body
332                )
333        }
334
335        /**
336         * render a checkBox form element
337         * @param Map attrs
338         * @param Closure body  (help text)
339         */
340        def checkBoxElement = {attrs, body ->
341                baseElement.call(
342                        'checkBox',
343                        attrs,
344                        body
345                )
346        }
347
348        /**
349         * render a dateElement
350         * NOTE: datepicker is attached through wizard.js!
351         * @param Map attrs
352         * @param Closure body  (help text)
353         */
354        def dateElement = {attrs, body ->
355                // transform value?
356                if (attrs.value instanceof Date) {
357                        // transform date instance to formatted string (dd/mm/yyyy)
358                        attrs.value = String.format('%td/%<tm/%<tY', attrs.value)
359                }
360
361                // add 'rel' field to identity the datefield using javascript
362                attrs.rel = 'date'
363
364                // set some textfield values
365                attrs.maxlength = (attrs.maxlength) ? attrs.maxlength : 10
366                attrs.addExampleElement = true
367
368                // render a normal text field
369                //out << textFieldElement(attrs,body)
370                textFieldElement.call(
371                        attrs,
372                        body
373                )
374        }
375
376        /**
377         * render a dateElement
378         * NOTE: datepicker is attached through wizard.js!
379         * @param Map attrs
380         * @param Closure body  (help text)
381         */
382        def timeElement = {attrs, body ->
383                // transform value?
384                if (attrs.value instanceof Date) {
385                        // transform date instance to formatted string (dd/mm/yyyy)
386                        attrs.value = String.format('%td/%<tm/%<tY %<tH:%<tM', attrs.value)
387                }
388
389                // add 'rel' field to identity the field using javascript
390                attrs.rel = 'datetime'
391
392                attrs.addExampleElement = true
393                attrs.addExample2Element = true
394                attrs.maxlength = 16
395
396                // render a normal text field
397                //out << textFieldElement(attrs,body)
398                textFieldElement.call(
399                        attrs,
400                        body
401                )
402        }
403
404        /**
405         * Button form element
406         * @param Map attributes
407         * @param Closure help content
408         */
409        def buttonElement = {attrs, body ->
410                // render template element
411                baseElement.call(
412                        'ajaxButton',
413                        attrs,
414                        body
415                )
416        }
417
418
419        /**
420         * Term form element
421         * @param Map attributes
422         * @param Closure help content
423         */
424        def termElement = { attrs, body ->
425                // render term element
426                baseElement.call(
427                        'termSelect',
428                        attrs,
429                        body
430                )
431        }
432
433        /**
434         * Term select element
435         * @param Map attributes
436         */
437        def termSelect = { attrs ->
438                def from = []
439
440                // got ontologies?
441                if (attrs.ontologies) {
442                        // are the ontologies a string?
443                        if (attrs.ontologies instanceof String) {
444                                attrs.ontologies.split(/\,/).each() { ncboId ->
445                                        // trim the id
446                                        ncboId.trim()
447
448                                        // fetch all terms for this ontology
449                                        def ontology = Ontology.findAllByNcboId(ncboId)
450
451                                        // does this ontology exist?
452                                        if (ontology) {
453                                                ontology.each() {
454                                                        Term.findAllByOntology(it).each() {
455                                                                // key = ncboId:concept-id
456                                                                from[ from.size() ] = it.name
457                                                        }
458                                                }
459                                        }
460                                }
461                        } else if (attrs.ontologies instanceof Set) {
462                                // are they a set instead?
463                                def ontologyList = ""
464
465                                // iterate through set
466                                attrs.ontologies.each() { ontology ->
467                                        ontologyList += ontology.ncboId + ","
468
469                                        Term.findAllByOntology(ontology).each() {
470                                                from[ from.size() ] = it.name
471                                        }
472
473                                        // strip trailing comma
474                                        attrs.ontologies = ontologyList[0..-2]
475                                }
476                        }
477
478                        // sort alphabetically
479                        from.sort()
480                       
481                        // define 'from'
482                        attrs.from = from
483
484                        // add 'rel' attribute
485                        attrs.rel = 'term'
486
487                        out << select(attrs)
488                } else {
489                        out << "<b>ontologies missing!</b>"
490                }
491        }
492
493        /**
494         * Ontology form element
495         * @param Map attributes
496         * @param Closure help content
497         */
498        def ontologyElement = { attrs, body ->
499                // @see http://www.bioontology.org/wiki/index.php/NCBO_Widgets#Term-selection_field_on_a_form
500                // @see ontology-chooser.js, table-editor.js
501                baseElement.call(
502                        'textField',
503                        [
504                            name: attrs.name,
505                                value: attrs.value,
506                                description: attrs.description,
507                                rel: 'ontology-' + ((attrs.ontology) ? attrs.ontology : 'all'),
508                                size: 25
509                        ],
510                        body
511                )
512                out << hiddenField(
513                        name: attrs.name + '-concept_id'
514                )
515                out << hiddenField(
516                        name: attrs.name + '-ontology_id'
517                )
518                out << hiddenField(
519                        name: attrs.name + '-full_id'
520                )
521        }
522
523        /**
524         * Study form element
525         * @param Map attributes
526         * @param Closure help content
527         */
528        def studyElement = { attrs, body ->
529                // render study element
530                baseElement.call(
531                        'studySelect',
532                        attrs,
533                        body
534                )
535        }
536
537        /**
538         * render a study select element
539         * @param Map attrs
540         */
541        def studySelect = { attrs ->
542                // for now, just fetch all studies
543                attrs.from = Study.findAll()
544
545                // got a name?
546                if (!attrs.name) {
547                        attrs.name = "study"
548                }
549
550                // got result?
551                if (attrs.from.size() > 0) {
552                        out << select(attrs)
553                } else {
554                        // no, return false to make sure this element
555                        // is not rendered in the template
556                        return false
557                }
558        }
559
560        /**
561         * Template form element
562         * @param Map attributes
563         * @param Closure help content
564         */
565        def templateElement = {attrs, body ->
566                // add a rel element if it does not exist
567                if (!attrs.rel) {
568                        attrs.rel = 'template'
569                }
570               
571                // render template element
572                baseElement.call(
573                        'templateSelect',
574                        attrs,
575                        body
576                )
577        }
578
579        /**
580         * render a template select element
581         * @param Map attrs
582         */
583        def templateSelect = {attrs ->
584                def entity = attrs.remove('entity')
585
586                // add the entity class name to the element
587                // do we have crypto information available?
588                if (grailsApplication.config.crypto) {
589                        // generate a Blowfish encrypted and Base64 encoded string.
590                        attrs['entity'] = Blowfish.encryptBase64(
591                                entity.toString().replaceAll(/^class /, ''),
592                                grailsApplication.config.crypto.shared.secret
593                        )
594                } else {
595                        // base64 only; this is INSECURE! As this class
596                        // is instantiated elsewehere. Possibly exploitable!
597                        attrs['entity'] = entity.toString().replaceAll(/^class /, '').bytes.encodeBase64()
598                }
599
600                // fetch templates
601                if (attrs.remove('addDummy')) {
602                        attrs.from = ['']
603                        if (entity && entity instanceof Class) {
604                                Template.findAllByEntity(entity).each() {
605                                        attrs.from[attrs.from.size()] = it
606                                }
607                        }
608                } else {
609                        attrs.from = (entity) ? Template.findAllByEntity(entity) : Template.findAll()
610                }
611
612                // got a name?
613                if (!attrs.name) {
614                        attrs.name = 'template'
615                }
616
617                // got result?
618                if (attrs.from.size() > 0) {
619                        // transform all values into strings
620                        def from = []
621                        attrs.from.each { from[ from.size() ] = it.toString() }
622                        attrs.from = from
623                        attrs.value = (attrs.value) ? attrs.value.toString() : ''
624
625                        // output select element
626                        out << select(attrs)
627                } else {
628                        // no, return false to make sure this element
629                        // is not rendered in the template
630                        return false
631                }
632        }
633
634        /**
635         * Protocol form element
636         * @param Map attributes
637         * @param Closure help content
638         */
639        def protocolElement = {attrs, body ->
640                // render protocol element
641                baseElement.call(
642                        'protocolSelect',
643                        attrs,
644                        body
645                )
646        }
647
648        /**
649         * render a protocol select element
650         * @param Map attrs
651         */
652        def protocolSelect = {attrs ->
653                // fetch all protocold
654                attrs.from = Protocol.findAll() // for now, all protocols
655
656                // got a name?
657                if (!attrs.name) {
658                        attrs.name = 'protocol'
659                }
660
661                out << select(attrs)
662        }
663
664        def show = {attrs ->
665                // is object parameter set?
666                def o = attrs.object
667
668                println o.getProperties();
669                o.getProperties().each {
670                        println it
671                }
672
673                out << "!! test version of 'show' tag !!"
674        }
675
676        /**
677         * render table headers for all subjectFields in a template
678         * @param Map attributes
679         */
680        def templateColumnHeaders = { attrs ->
681                def entity              = (attrs.get('entity'))
682                def template    = (entity && entity instanceof TemplateEntity) ? entity.template : null
683
684                // got a template?
685                if (template) {
686                        // render template fields
687                        entity.giveFields().each() {
688                                out << '<div class="' + attrs.get('class') + '">' + it.name + '</div>'
689                        }
690                }
691        }
692
693        def templateColumns = { attrs ->
694                // render template fields as columns
695                attrs.renderType = 'column'
696                out << renderTemplateFields(attrs)
697        }
698
699        def templateElements = { attrs ->
700                // render template fields as form elements
701                attrs.renderType = 'element'
702                out << renderTemplateFields(attrs)
703        }
704
705        /**
706         * render form elements based on an entity's template
707         * @param Map attributes
708         * @param String body
709         */
710        def renderTemplateFields = { attrs ->
711                def renderType  = attrs.remove('renderType')
712                def entity              = (attrs.get('entity'))
713                def prependName = (attrs.get('name')) ? attrs.remove('name')+'_' : ''
714                def template    = (entity && entity instanceof TemplateEntity) ? entity.template : null
715                def inputElement= null
716
717                // got a template?
718                if (template) {
719                        // render template fields
720                        entity.giveFields().each() {
721                                def fieldValue = entity.getFieldValue(it.name)
722
723                                // output column opening element?
724                                if (renderType == 'column') {
725                                        out << '<div class="' + attrs.get('class') + '">'
726                                }
727
728                                switch (it.type.toString()) {
729                                        case ['STRING', 'TEXT', 'INTEGER', 'FLOAT', 'DOUBLE']:
730                                                inputElement = (renderType == 'element') ? 'textFieldElement' : 'textField'
731                                                out << "$inputElement"(
732                                                        description: it.name,
733                                                        name: prependName + it.escapedName(),
734                                                        value: fieldValue
735                                                )
736                                                break
737                                        case 'STRINGLIST':
738                                                inputElement = (renderType == 'element') ? 'selectElement' : 'select'
739                                                if (!it.listEntries.isEmpty()) {
740                                                        out << "$inputElement"(
741                                                                description: it.name,
742                                                                name: prependName + it.escapedName(),
743                                                                from: it.listEntries,
744                                                                value: fieldValue
745                                                        )
746                                                } else {
747                                                        out << '<span class="warning">no values!!</span>'
748                                                }
749                                                break
750                                        case 'ONTOLOGYTERM':
751                                                // @see http://www.bioontology.org/wiki/index.php/NCBO_Widgets#Term-selection_field_on_a_form
752                                                // @see ontology-chooser.js
753                                                inputElement = (renderType == 'element') ? 'termElement' : 'termSelect'
754
755                                                if (it.ontologies) {
756                                                        out << "$inputElement"(
757                                                                description     : it.name,
758                                                                name            : prependName + it.escapedName(),
759                                                                value           : fieldValue,
760                                                                ontologies      : it.ontologies
761                                                        )
762                                                } else {
763                                                        out << "$inputElement"(
764                                                                description     : it.name,
765                                                                name            : prependName + it.escapedName(),
766                                                                value           : fieldValue
767                                                        )
768                                                }
769                                                break
770                                        case 'ONTOLOGYTERM-old':
771                                                // @see http://www.bioontology.org/wiki/index.php/NCBO_Widgets#Term-selection_field_on_a_form
772                                                // @see ontology-chooser.js
773                                                inputElement = (renderType == 'element') ? 'textFieldElement' : 'textField'
774                                                out << "$inputElement"(
775                                                        name: prependName + it.escapedName(),
776                                                        value: fieldValue,
777                                                        rel: 'ontology-all',
778                                                        size: 100
779                                                )
780                                                out << hiddenField(
781                                                        name: prependName + it.name + '-concept_id',
782                                                        value: fieldValue
783                                                )
784                                                out << hiddenField(
785                                                        name: prependName + it.escapedName() + '-ontology_id',
786                                                        value: fieldValue
787                                                )
788                                                out << hiddenField(
789                                                        name: prependName + it.escapedName() + '-full_id',
790                                                        value: fieldValue
791                                                )
792                                                break
793                                        case 'DATE':
794                                                inputElement = (renderType == 'element') ? 'dateElement' : 'textField'
795
796                                                // transform value?
797                                                if (fieldValue instanceof Date) {
798                                                        if (fieldValue.getHours() == 0 && fieldValue.getMinutes() == 0) {
799                                                                // transform date instance to formatted string (dd/mm/yyyy)
800                                                                fieldValue = String.format('%td/%<tm/%<tY', fieldValue)
801                                                        } else {
802                                                                // transform to date + time
803                                                                fieldValue = String.format('%td/%<tm/%<tY %<tH:%<tM', fieldValue)
804                                                        }
805                                                }
806
807                                                // render element
808                                                out << "$inputElement"(
809                                                        description: it.name,
810                                                        name: prependName + it.escapedName(),
811                                                        value: fieldValue,
812                                                        rel: 'date'
813                                                )
814                                                break
815                                        default:
816                                                // unsupported field type
817                                                out << '<span class="warning">!' + it.type + '</span>'
818                                                break
819                                }
820
821                                // output column closing element?
822                                if (renderType == 'column') {
823                                        out << '</div>'
824                                }
825                        }
826                }
827        }
828}
Note: See TracBrowser for help on using the repository browser.