source: trunk/grails-app/views/importer/common/_on_page.gsp @ 1430

Last change on this file since 1430 was 1430, checked in by work@…, 10 years ago
  • set keyword expansion
  • Property svn:keywords set to Rev Author Date
File size: 2.8 KB
Line 
1<%
2/**
3 * wizard refresh flow action
4 *
5 * When a page (/ partial) is rendered, any DOM event handlers need to be
6 * (re-)attached. The af:ajaxButton, af:ajaxSubmitJs and af:redirect tags
7 * supports calling a JavaScript after the page has been rendered by passing
8 * the 'afterSuccess' argument.
9 *
10 * Example:     af:redirect afterSuccess="onPage();"
11 *              af:redirect afterSuccess="console.log('redirecting...');"
12 *
13 * Generally one would expect this code to add jQuery event handlers to
14 * DOM objects in the rendered page (/ partial).
15 *
16 * @author Jeroen Wesbeek
17 * @since  20101206
18 *
19 * Revision information:
20 * $Rev: 1430 $
21 * $Author: work@osx.eu $
22 * $Date: 2011-01-21 20:05:36 +0000 (vr, 21 jan 2011) $
23 */
24%>
25<script type="text/javascript">
26
27    // Initially called when starting the import wizard
28    function onPage() {
29
30    $(document).ready(function() {
31
32    handleWizardTable();   
33
34    $('#simplewizardform').submit(function() {
35        if ($('#file').val() == "") {
36            alert ("Please choose your Excel file to import.");
37            return false
38        } else
39        if ($('#entity').val() == "") {
40            $('#datatemplate').addClass("validationfail");
41            return false
42        } else
43            $('#simplewizardform').submit();
44
45        return false;
46    });
47    });
48 }
49
50 
51/**
52 * Update one select based on another select
53 *
54 * @author
55 * @see     http://www.grails.org/Tag+-+remoteFunction
56 * @param   string  select (form) name
57 * @param   string  JSON data
58 * @param   boolean keep the first option
59 * @param   int     selected option
60 * @param   string  if null, show this as option instead
61 * @void
62 */
63function updateSelect(name,data,keepFirstOption,selected,presentNullAsThis) {
64    var rselect = $('#'+name).get(0)
65    var items = data
66
67    // If a study has been selected, don't show the "Choose study" field, otherwise do
68    if ($('#'+'entity :selected').text() == 'Study')
69      $('#studyfield').hide();
70    else $('#studyfield').show();
71
72    $('select[name=template_id]').attr('entity', $('#'+'entity').val());
73
74    if (items) {
75
76        // remove old options
77        var start = (keepFirstOption) ? 0 : -1;
78        var i = rselect.length
79
80        while (i > start) {
81            rselect.remove(i)
82            i--
83        }
84
85        // add new options
86        $.each(items,function() {
87            var i = rselect.options.length
88
89            rselect.options[i] = new Option(
90                (presentNullAsThis && this.name == null) ? presentNullAsThis : this.name,
91                this.id
92            );
93            if (this.id == selected) rselect.options[i].selected = true
94        });
95    }
96
97 // handle template selects
98  new SelectAddMore().init({
99       rel     : 'typetemplate',
100       url     : baseUrl + '/templateEditor',
101       vars    : 'entity', // can be a comma separated list of variable names to pass on
102       label   : 'add / modify ...',
103       style   : 'modify',
104       onClose : function(scope) {
105           location.reload();
106       }
107    });
108}
109
110</script>
111
Note: See TracBrowser for help on using the repository browser.