source: trunk/grails-app/views/importer/index_simple.gsp @ 449

Last change on this file since 449 was 449, checked in by tabma, 14 years ago
  • first page of simple import wizard working with entity-/templatefilter
File size: 2.7 KB
Line 
1<!--
2  To change this template, choose Tools | Templates
3  and open the template in the editor.
4-->
5
6<%@ page contentType="text/html;charset=UTF-8" %>
7<g:setProvider library="jquery"/>
8
9<html>
10  <head>
11    <meta name="layout" content="main"/>
12    <title>Importer wizard (simple)</title>
13
14<g:javascript>
15/**
16 * Update one select based on another select
17 *
18 * @author
19 * @see     http://www.grails.org/Tag+-+remoteFunction
20 * @param   string  select (form) name
21 * @param   string  JSON data
22 * @param   boolean keep the first option
23 * @param   int     selected option
24 * @param   string  if null, show this as option instead
25 * @void
26 */
27function updateSelect(name,data,keepFirstOption,selected,presentNullAsThis) {   
28    var rselect = $('#'+name).get(0)
29    var items = data
30
31    if (items) {
32
33        // remove old options
34        var start = (keepFirstOption) ? 0 : -1;
35        var i = rselect.length
36
37        while (i > start) {
38            rselect.remove(i)
39            i--
40        }
41
42        // add new options
43        $.each(items,function() {
44            var i = rselect.options.length
45
46            rselect.options[i] = new Option(
47                (presentNullAsThis && this.name == null) ? presentNullAsThis : this.name,
48                this.id
49            );
50            if (this.id == selected) rselect.options[i].selected = true
51        });
52    }
53}
54</g:javascript>
55</head>
56  <body>
57    <h1>Importer wizard (simple)</h1>
58    <p>You can import your Excel data to the server by choosing a file from your local harddisk in the form below.</p>
59        <g:form controller="importer" method="post" action="upload" enctype="multipart/form-data">
60        <table border="0">
61        <tr>
62            <td width="100px">
63                Choose your Excel file to import:
64            </td>
65            <td width="100px">
66                <input type="file" name="importfile"/>
67            </td>
68        </tr>
69        <tr>
70            <td>
71                Choose your study:
72            </td>
73            <td>
74                <g:select name="study_id" from="${studies}" optionKey="id"/>
75            </td>
76        </tr>
77        <tr>
78            <td>
79                Choose type of data:
80            </td>
81            <td>
82                <g:select
83                name="entity"
84                from="${entities}"             
85                optionValue="${{it.value.name}}"
86                optionKey="key"
87                noSelection="['':'-Choose type of data-']"
88                onChange="${remoteFunction( controller: 'importer',
89                                            action:'ajaxGetTemplatesByEntity',
90                                            params: '\'entity=\'+escape(this.value)',
91                                            onSuccess:'updateSelect(\'template_id\',data,false,false,\'default\')')}" />
92            </td>
93        </tr>
94        <tr>
95            <td>
96                Choose type of data template:
97            </td>
98            <td>
99                <g:select name="template_id" optionKey="id" optionValue="name" from="[]" />
100            </td>
101        </tr>
102
103
104        <tr>
105            <td colspan="2">
106                <input type="submit" value="Next"/>
107            </td>
108        </tr>
109        </table>
110        </g:form>
111
112  </body>
113</html>
Note: See TracBrowser for help on using the repository browser.